:root {
  --bg: #f4f6fb; --card: #ffffff; --ink: #16202e; --muted: #66738a; --line: #e3e8f0;
  --brand: #2f6bd6; --brand-ink: #fff; --ok: #1f9d55; --warn: #d9822b; --bad: #d7263d;
  --chip: #eef2f9; --shadow: 0 1px 3px rgba(20,30,50,.08), 0 6px 20px rgba(20,30,50,.06);
  --r: 14px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1420; --card: #171e2c; --ink: #e7ecf5; --muted: #9aa7bd; --line: #263145;
    --brand: #5b8def; --chip: #202a3c; --shadow: 0 1px 3px rgba(0,0,0,.4);
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg); color: var(--ink); padding-bottom: 72px;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; cursor: pointer; border: none; border-radius: 10px; padding: 9px 14px; background: var(--chip); color: var(--ink); }
button.primary { background: var(--brand); color: var(--brand-ink); }
button.ghost { background: transparent; border: 1px solid var(--line); }
button:disabled { opacity: .5; cursor: not-allowed; }
a { color: var(--brand); }
input { font: inherit; width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); color: var(--ink); }
label { display: block; margin: 8px 0; font-size: 13px; color: var(--muted); }
label input { margin-top: 4px; }

/* Top bar */
.topbar {
  position: sticky; top: 0; z-index: 20; background: var(--brand); color: #fff;
  padding: max(10px, env(safe-area-inset-top)) 16px 10px; box-shadow: var(--shadow);
}
.brand { font-weight: 800; font-size: 20px; letter-spacing: .3px; }
.brand span { opacity: .8; }
.kidbar { display: flex; gap: 8px; margin-top: 10px; overflow-x: auto; scrollbar-width: none; }
.kidbar::-webkit-scrollbar { display: none; }
.kidbar button {
  white-space: nowrap; background: rgba(255,255,255,.15); color: #fff; padding: 6px 12px; font-size: 13px;
}
.kidbar button.sel { background: #fff; color: var(--brand); font-weight: 700; }

/* Tabs — top on desktop, bottom bar on mobile */
.tabs {
  position: sticky; top: 0; z-index: 15; display: flex; gap: 4px; padding: 8px 12px;
  background: var(--card); border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tabs button { background: transparent; color: var(--muted); padding: 8px 12px; white-space: nowrap; font-size: 14px; }
.tabs button.active { color: var(--brand); background: var(--chip); font-weight: 700; }

.view { max-width: 760px; margin: 0 auto; padding: 16px; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r);
  padding: 16px; margin: 0 0 14px; box-shadow: var(--shadow);
}
.card h3 { margin: 0 0 10px; font-size: 16px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.spread { justify-content: space-between; }
.muted { color: var(--muted); }
.section-title { font-size: 13px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); margin: 18px 4px 8px; }
.empty { text-align: center; color: var(--muted); padding: 30px 10px; }
.spin { display: inline-block; width: 18px; height: 18px; border: 2px solid var(--line); border-top-color: var(--brand); border-radius: 50%; animation: sp .7s linear infinite; vertical-align: -4px; }
@keyframes sp { to { transform: rotate(360deg); } }

/* Badges / pills */
.pill { display: inline-block; font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 999px; }
.pill.ok { background: color-mix(in srgb, var(--ok) 16%, transparent); color: var(--ok); }
.pill.warn { background: color-mix(in srgb, var(--warn) 18%, transparent); color: var(--warn); }
.pill.bad { background: color-mix(in srgb, var(--bad) 16%, transparent); color: var(--bad); }
.pill.mut { background: var(--chip); color: var(--muted); }

/* Order slot */
.slot { border: 1px solid var(--line); border-radius: 12px; padding: 12px; margin-bottom: 10px; background: var(--card); }
.slot .head { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.slot .date { font-weight: 700; }
.opts { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }
.opts label {
  margin: 0; display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; border: 1px solid var(--line);
  border-radius: 999px; color: var(--ink); cursor: pointer; font-size: 13px; background: var(--card);
}
.opts label:has(input:checked) { border-color: var(--brand); background: color-mix(in srgb, var(--brand) 12%, transparent); font-weight: 600; }
.opts input { width: auto; }
.opts label.disabled { opacity: .5; pointer-events: none; }

.kf-msg { margin: 8px 0 0; font-size: 13px; }
.kf-msg.ok { color: var(--ok); } .kf-msg.bad { color: var(--bad); }
.kidrow { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.kidrow:last-child { border-bottom: none; }

.post-body { font-size: 14px; }
.post-body p { margin: 6px 0; }
.post-body img { max-width: 100%; height: auto; border-radius: 8px; }

.toast {
  position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%);
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 999px; z-index: 50;
  box-shadow: var(--shadow); font-size: 14px; max-width: 90vw;
}

.codebox { background: var(--chip); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; font: 12px/1.4 ui-monospace, Menlo, monospace; word-break: break-all; }

@media (max-width: 640px) {
  .tabs { position: fixed; bottom: 0; left: 0; right: 0; top: auto; justify-content: space-around; border-top: 1px solid var(--line); border-bottom: none; padding-bottom: max(8px, env(safe-area-inset-bottom)); }
  .tabs button { flex-direction: column; font-size: 11px; gap: 2px; padding: 6px 8px; }
}
