@font-face {
  font-family: "Michroma";
  src: url("fonts/michroma.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

:root {
  --sign: Michroma, "Arial Black", system-ui, sans-serif;
  --body: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --radius: 10px;
}
:root[data-theme="dark"] {
  --bg: #0f1317; --panel: #181e25; --panel2: #222a33; --line: #323c47;
  --text: #f3efe4; --muted: #9aa5b1; --amber: #ffbf1f; --amber-ink: #1a1400;
  --sign-bg: #000; --sign-fg: #ffbf1f; --ok: #4fd18b; --warn: #ffbf1f; --bad: #ff7b6e;
}
:root[data-theme="light"] {
  --bg: #f2eee3; --panel: #fffdf7; --panel2: #e8e3d4; --line: #cfc8b4;
  --text: #14181d; --muted: #566069; --amber: #ffbf1f; --amber-ink: #1a1400;
  --sign-bg: #14181d; --sign-fg: #ffbf1f; --ok: #1f8a55; --warn: #9a6a00; --bad: #c4372a;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text); font: 16px/1.45 var(--body);
  padding-bottom: env(safe-area-inset-bottom);
}
body.noscroll { overflow: hidden; }
a { color: inherit; }
h1, h2, h3, p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }

/* header */
#bar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 10px;
  padding: calc(env(safe-area-inset-top) + 10px) 14px 10px; background: var(--sign-bg);
  border-bottom: 3px solid var(--amber); color: var(--sign-fg);
}
.brand { font: 13px/1 var(--sign); letter-spacing: .06em; text-transform: uppercase; text-decoration: none; color: var(--sign-fg); flex: 1; white-space: nowrap; }
.sync {
  display: inline-flex; align-items: center; gap: 7px; max-width: 48vw; background: transparent; border: 1px solid #3b434d;
  color: #d8d3c4; padding: 6px 10px; border-radius: 999px; font-size: 12px; cursor: pointer; white-space: nowrap;
}
.sync .synctext { overflow: hidden; text-overflow: ellipsis; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: #7a838d; flex: none; }
.sync.ok .dot { background: #4fd18b; } .sync.warn .dot { background: #ffbf1f; }
.sync.bad .dot { background: #ff7b6e; } .sync.busy .dot { background: #6db5ff; animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .3; } }
.gear { color: var(--sign-fg); display: inline-flex; padding: 4px; }

main { max-width: 600px; margin: 0 auto; padding: 14px 14px 70px; }
.view { display: flex; flex-direction: column; gap: 12px; }

/* sign-style code tiles */
.code {
  flex: none; display: inline-flex; align-items: center; justify-content: center; width: 74px; height: 46px; padding: 0;
  background: var(--sign-bg); color: var(--sign-fg); border: 2px solid var(--amber); border-radius: 6px;
  font: 15px/1 var(--sign); letter-spacing: .04em;
}
.code.big { width: 104px; height: 64px; font-size: 22px; }
.code.small { width: 56px; height: 34px; font-size: 12px; }

.search {
  width: 100%; padding: 13px 14px; font-size: 16px; background: var(--panel); border: 2px solid var(--line);
  border-radius: var(--radius); outline: none;
}
.search:focus, input:focus, select:focus, textarea:focus { border-color: var(--amber); }

.group {
  margin-top: 8px; font: 11px/1.2 var(--sign); letter-spacing: .1em; text-transform: uppercase; color: var(--amber);
  padding: 6px 2px; border-bottom: 1px solid var(--line);
}
:root[data-theme="light"] .group { color: var(--warn); }

#list { display: flex; flex-direction: column; gap: 8px; }
.row { display: flex; align-items: stretch; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.rowlink { flex: 1; display: flex; align-items: center; gap: 12px; padding: 10px 6px 10px 10px; text-decoration: none; min-width: 0; }
.rowtext { display: flex; flex-direction: column; min-width: 0; }
.city { font-weight: 650; }
.sub, .meta, .hint { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; }
.meta { color: var(--text); opacity: .85; }
.hint { color: var(--warn); font-size: 12px; }
.star {
  flex: none; width: 52px; background: transparent; border: 0; border-left: 1px solid var(--line); font-size: 24px; color: var(--line); cursor: pointer;
}
.star.on { color: var(--amber); }
.addcity { padding: 14px 0; display: flex; justify-content: center; }

/* cards and buttons */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.card h3 { font: 12px/1.3 var(--sign); letter-spacing: .06em; text-transform: uppercase; }
.card.callout { border-color: var(--amber); }
.card.tip { flex-direction: row; align-items: center; justify-content: space-between; font-size: 14px; }
.card.empty { align-items: flex-start; color: var(--muted); }
.fine { font-size: 13px; color: var(--muted); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 11px 16px; min-height: 44px;
  background: var(--panel2); color: var(--text); border: 1px solid var(--line); border-radius: 8px; font-weight: 600; cursor: pointer;
}
.btn.primary { background: var(--amber); border-color: var(--amber); color: var(--amber-ink); }
.btn.ghost { background: transparent; }
.btn.small { padding: 7px 12px; min-height: 36px; font-size: 14px; }
.btn.wide { width: 100%; }
.btn.danger { background: var(--bad); border-color: var(--bad); color: #140400; }
:root[data-theme="light"] .btn.danger { color: #fff; }
.confirmtext { line-height: 1.5; }
.btn:active { transform: translateY(1px); }

.inline { display: flex; gap: 8px; }
.inline input { flex: 1; min-width: 0; }
input[type=text], input[type=search], select, textarea {
  width: 100%; padding: 11px 12px; font-size: 16px; background: var(--bg); border: 2px solid var(--line); border-radius: 8px; outline: none;
}
textarea { resize: vertical; }
.codein { font-family: var(--sign); letter-spacing: .15em; text-transform: uppercase; }

.back { text-decoration: none; color: var(--muted); font-size: 14px; padding: 4px 0; align-self: flex-start; }
.pagetitle { font: 18px/1.2 var(--sign); text-transform: uppercase; letter-spacing: .04em; }

/* station page */
.stationhead { display: flex; align-items: center; gap: 12px; }
.stationtext { flex: 1; min-width: 0; }
.stationtext h1 { font-size: 21px; line-height: 1.2; }
.stationtext p { color: var(--muted); font-size: 14px; }
.stationhead .star { width: 44px; border: 0; }
.tabs { display: grid; grid-template-columns: 1fr 1fr; border: 2px solid var(--line); border-radius: 8px; overflow: hidden; }
.tabs button { padding: 12px 6px; background: var(--panel); border: 0; font-weight: 650; cursor: pointer; }
.tabs button + button { border-left: 2px solid var(--line); }
.tabs button.on { background: var(--amber); color: var(--amber-ink); }

.note .notehead { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.note h3 { font: 650 17px/1.3 var(--body); text-transform: none; letter-spacing: 0; }
.badge { flex: none; font-size: 12px; font-weight: 700; padding: 4px 8px; background: var(--sign-bg); color: var(--sign-fg); border: 1px solid var(--amber); border-radius: 4px; }
.where { color: var(--muted); font-size: 14px; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { font-size: 12px; padding: 4px 8px; border-radius: 999px; background: var(--panel2); border: 1px solid var(--line); }
.kv { display: flex; flex-direction: column; font-size: 14px; }
.kv .k { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.kv .v { white-space: pre-wrap; overflow-wrap: anywhere; }
.noteline { display: flex; align-items: center; justify-content: space-between; gap: 8px; border-top: 1px solid var(--line); padding-top: 10px; }
.when { font-size: 12px; color: var(--muted); }
.actions { display: flex; gap: 6px; }
.danger { display: flex; justify-content: center; padding-top: 18px; }
.danger .btn { color: var(--bad); border-color: var(--bad); }

/* settings */
.seg { display: grid; grid-template-columns: 1fr 1fr; border: 2px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { padding: 11px; background: var(--panel); border: 0; font-weight: 650; cursor: pointer; }
.seg button + button { border-left: 2px solid var(--line); }
.seg button.on { background: var(--amber); color: var(--amber-ink); }
.remrow { display: flex; align-items: center; gap: 10px; }
.remcity { flex: 1; }

/* sheet (add/edit forms) */
#overlay[hidden] { display: none; }
#overlay { position: fixed; inset: 0; z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, .6); }
.sheet {
  position: relative; width: 100%; max-width: 600px; max-height: 92vh; max-height: 92dvh; display: flex; flex-direction: column;
  background: var(--bg); border: 2px solid var(--amber); border-bottom: 0; border-radius: 16px 16px 0 0;
}
.sheethead { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.sheethead h2 { font: 13px/1.2 var(--sign); text-transform: uppercase; letter-spacing: .06em; }
.sheetbody { overflow-y: auto; padding: 14px; -webkit-overflow-scrolling: touch; }
.sheetfoot { padding: 10px 14px calc(env(safe-area-inset-bottom) + 12px); border-top: 1px solid var(--line); background: var(--bg); }
.form { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 5px; }
.lbl { font-size: 13px; font-weight: 650; }
.fhint { font-size: 12px; color: var(--muted); }
.ferr { color: var(--bad); font-size: 14px; min-height: 1px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { position: relative; }
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip span {
  display: inline-block; padding: 9px 12px; border: 2px solid var(--line); border-radius: 999px; background: var(--panel); font-size: 14px; cursor: pointer;
}
.chip input:checked + span { background: var(--amber); border-color: var(--amber); color: var(--amber-ink); font-weight: 650; }
.chip input:focus-visible + span { outline: 2px solid var(--text); outline-offset: 2px; }

/* toast */
#toast {
  position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 18px); z-index: 80; transform: translate(-50%, 140%);
  display: flex; align-items: center; gap: 12px; max-width: min(92vw, 520px); padding: 12px 16px; border-radius: 10px;
  background: var(--text); color: var(--bg); font-size: 14px; transition: transform .2s ease; pointer-events: none;
}
#toast.show { transform: translate(-50%, 0); pointer-events: auto; }
#toast button { background: transparent; border: 0; color: inherit; font-weight: 800; text-decoration: underline; cursor: pointer; padding: 4px; }

@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
