/* Light and dark blue. Light by default; dark only when the phone is set to dark. */
:root {
  --bg: #f2f6ff;
  --surface: #ffffff;
  --surface-2: #e5edfd;
  --text: #0f1d3a;
  --muted: #55658a;
  --line: #d6e1f6;
  --control-line: #7086b3;
  --danger: #c8221a;
  --accent: #2457d6;
  --accent-strong: #1a43a8;
  --accent-text: #ffffff;
  --accent-soft: #e2ebff;
  --tag-bg: #c9dbff;
  --tag-text: #163a94;
  --good: #137a3d;
  --warn: #9a5b00;
  --grab: #00863f;
  --gofood: #c8221a;
  --shadow: 0 1px 2px rgb(15 29 58 / 6%), 0 6px 20px rgb(36 87 214 / 8%);
  --radius: 18px;
  --font: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0a1428; --surface: #12213d; --surface-2: #1a2c4f; --text: #e9f0ff; --muted: #9fb0d3;
    --line: #243a63; --control-line: #5b78ad; --danger: #ff6b62; --accent: #7aa5ff; --accent-strong: #a9c4ff; --accent-text: #0a1428; --accent-soft: #1c3366; --tag-bg: #9cc0ff; --tag-text: #0a1a3d;
    --good: #5ad58c; --warn: #f2c14e; --grab: #3ccf7c; --gofood: #ff6b62; --shadow: none; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0a1428; --surface: #12213d; --surface-2: #1a2c4f; --text: #e9f0ff; --muted: #9fb0d3;
  --line: #243a63; --control-line: #5b78ad; --danger: #ff6b62; --accent: #7aa5ff; --accent-strong: #a9c4ff; --accent-text: #0a1428; --accent-soft: #1c3366; --tag-bg: #9cc0ff; --tag-text: #0a1a3d;
  --good: #5ad58c; --warn: #f2c14e; --grab: #3ccf7c; --gofood: #ff6b62; --shadow: none; color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.5 var(--font);
  padding-bottom: calc(76px + env(safe-area-inset-bottom));
}
main { max-width: 560px; margin: 0 auto; padding-block: 20px 24px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
h1 { font-size: 27px; line-height: 1.15; margin: 0; letter-spacing: -0.02em; font-weight: 800; text-wrap: balance; }
h2 { font-size: 18px; margin: 28px 0 10px; }
h3 { font-size: 19px; margin: 0; }
p { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }

.sub { color: var(--muted); font-size: 15px; margin-bottom: 18px; }

.segmented { display: flex; background: var(--surface-2); border: 1px solid var(--control-line); border-radius: 14px; padding: 4px; gap: 4px; margin-bottom: 14px; }
.segmented button { flex: 1; border: 0; background: transparent; padding: 9px 8px; min-height: 44px; border-radius: 10px; font-weight: 600; color: var(--muted); }
.segmented button[aria-pressed="true"] { background: var(--accent); color: var(--accent-text); }

.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 12px; margin: 0 -16px; padding-inline: 16px; scrollbar-width: none;
  -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 32px), transparent); mask-image: linear-gradient(to right, #000 calc(100% - 32px), transparent); }
.chips.wrap { -webkit-mask-image: none; mask-image: none; }
.chips.wrap { flex-wrap: wrap; overflow: visible; margin: 0; padding-inline: 0; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; border: 1px solid var(--control-line); background: var(--surface); border-radius: 999px; padding: 9px 16px; min-height: 44px; font-size: 15px; white-space: nowrap; }
.chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
.chip.ghost { border-style: dashed; color: var(--muted); }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 12px; box-shadow: var(--shadow); }
.card .top { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.card .note { margin-top: 4px; font-size: 15px; }
.card .meta { display: flex; flex-wrap: wrap; gap: 6px 12px; margin-top: 10px; font-size: 14px; color: var(--muted); }
.card .tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.tag { font-size: 13px; font-weight: 600; background: var(--tag-bg); border-radius: 999px; padding: 3px 11px; color: var(--tag-text); }
.chip.day { min-width: 56px; justify-content: center; }
.chip.day[aria-pressed="false"] { color: var(--muted); text-decoration: line-through; }
.badge { font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); white-space: nowrap; }
.open { color: var(--good); font-weight: 600; }
.unknown { color: var(--muted); }
.error { color: var(--danger); font-weight: 600; }
.actions { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.actions.pair { flex-wrap: nowrap; }
.actions.pair:has(.gofood) { flex-wrap: wrap; }

.btn { border: 1px solid var(--control-line); color: var(--text); background: var(--surface); border-radius: 12px; padding: 10px 14px; font-weight: 600; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.grab { color: var(--grab); }
.btn.gofood { color: var(--gofood); }
.btn.wide { width: 100%; }
.btn.accent { color: var(--accent-strong); border-color: var(--accent); }
.btn.sm { min-height: 44px; padding: 8px 12px; font-size: 15px; }
.btn.flex { flex: 1; }
.btn:disabled { opacity: 0.5; }
.linklike { border: 0; background: none; padding: 10px 4px; min-height: 44px; color: var(--accent); font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }

.banner { background: var(--accent-soft); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 16px; }
.banner p { font-size: 16px; }
.banner .actions { margin-top: 10px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.banner .actions .btn { padding-inline: 6px; }
.banner .actions .linklike { grid-column: 1 / -1; justify-self: start; display: inline-flex; align-items: center; min-height: 44px; padding: 0 2px; margin-bottom: -8px; color: var(--muted); font-weight: 500; }

.fallback { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px; border: 1px dashed var(--control-line); border-radius: var(--radius); margin-top: 20px; }
.empty { text-align: center; padding: 20px 16px 28px; color: var(--muted); }
.empty strong { color: var(--text); font-size: 17px; }
.empty p + p { margin-top: 4px; }
.empty .actions { justify-content: center; }

.list { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; border-top: 1px solid var(--line); width: 100%; text-align: left; background: none; border-left: 0; border-right: 0; border-bottom: 0; }
.row:first-child { border-top: 0; }
.row .name { font-weight: 600; }
.row .text { flex: 1; min-width: 0; }
.row .text .name { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .chev { color: var(--muted); font-size: 22px; line-height: 1; }
.row .end { display: flex; align-items: center; gap: 10px; flex: none; }
.verdicts { display: flex; gap: 6px; flex: none; }
.verdicts button { border: 1px solid var(--control-line); background: var(--surface); border-radius: 10px; min-width: 44px; min-height: 44px; padding: 0 10px; font-size: 14px; font-weight: 600; }
.rate-cue { color: var(--accent-strong); font-weight: 600; }
.verdicts .delete { margin-left: 8px; color: var(--muted); }
/* History rows stack: name and date on top, rating buttons underneath, delete pinned right. */
.history .row { flex-wrap: wrap; gap: 8px 12px; }
.history .row .text { flex: 1 1 100%; }
.history .row .text .name { white-space: normal; }
.history .verdicts { flex: 1 1 100%; }
.history .verdicts .delete { margin-left: auto; }
.verdicts .delete[data-armed] { color: var(--danger); border-color: currentColor; font-weight: 700; padding-inline: 10px; }
.verdicts button[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }

input[type=text], input[type=url], input[type=password], input[type=search], input[type=time], select, textarea {
  width: 100%; border: 1px solid var(--control-line); background: var(--surface); border-radius: 12px; padding: 11px 12px; min-height: 44px;
}
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
label { display: block; font-weight: 600; font-size: 14px; margin: 14px 0 6px; }
.inline { display: flex; gap: 8px; align-items: center; }
.inline > * { flex: 1; }
.check { display: flex; align-items: center; gap: 10px; font-weight: 500; font-size: 15px; margin: 12px 0; }
.check input { width: 20px; height: 20px; accent-color: var(--accent); }

.tabs { position: fixed; inset: auto 0 0 0; display: flex; background: var(--surface); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); z-index: 5; }
.tabs button { flex: 1; border: 0; background: none; padding: 14px 4px; font-weight: 600; color: var(--muted); min-height: 56px; }
.tabs button[aria-current="page"] { color: var(--accent); }

.sheet { position: fixed; inset: 0; background: rgb(5 12 30 / 55%); z-index: 10; display: flex; align-items: flex-end; justify-content: center; }
.sheet .panel { background: var(--surface); border-top: 1px solid var(--line); width: 100%; max-width: 560px; max-height: 92vh; overflow-y: auto; overscroll-behavior: contain; border-radius: 22px 22px 0 0; padding: 0 16px; }
.sheet .panel::before { content: ""; display: block; width: 36px; height: 4px; border-radius: 2px; background: var(--control-line); margin: 8px auto 0; }
.sheet .panel header { position: sticky; top: 0; z-index: 1; background: var(--surface); display: flex; justify-content: space-between; align-items: center; gap: 12px; padding-block: 10px; border-bottom: 1px solid var(--line); }
.sheet .panel header h2 { margin: 0; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sheet .panel footer { position: sticky; bottom: 0; background: var(--surface); padding-block: 12px calc(12px + env(safe-area-inset-bottom)); margin-top: 16px; border-top: 1px solid var(--line); }
.sheet input, .sheet select { background: var(--bg); }
body.locked { overflow: hidden; }

.toast { position: fixed; left: 16px; right: 16px; bottom: calc(72px + env(safe-area-inset-bottom)); max-width: 528px; margin: 0 auto; background: var(--text); color: var(--bg); border-radius: 14px; padding: 12px 16px; display: flex; justify-content: space-between; align-items: center; gap: 12px; z-index: 20; }
.toast button { background: none; border: 0; color: inherit; font-weight: 700; text-decoration: underline; padding: 10px 12px; margin: -10px -12px; min-height: 44px; }

.login { max-width: 360px; margin: 8vh auto 0; text-align: center; }
.login form { margin-top: 20px; display: grid; gap: 10px; }
.login .sticker { width: 120px; }

/* Header with Aqiang's sticker */
.hero { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.hero > div { flex: 1; min-width: 0; }
.hero .sub { margin: 4px 0 0; }
.hero img { width: 84px; height: auto; flex: none; }

.sticker { display: block; height: auto; margin: 0 auto 10px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 6px 0 10px; }
.section-head h2 { margin: 0; font-size: 17px; }
.alt-list { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.loading { padding: 40px 0; text-align: center; color: var(--muted); }
.pill { font-size: 12px; font-weight: 600; background: var(--surface-2); color: var(--muted); border-radius: 999px; padding: 2px 9px; }
.banner { display: flex; gap: 12px; align-items: center; }
.banner > div { flex: 1; min-width: 0; }
.banner img { width: 56px; flex: none; }
.icon { width: 18px; height: 18px; flex: none; }
