:root {
  color-scheme: light dark;
  --bg: #f4f8fc;
  --card: #ffffff;
  --text: #10243a;
  --muted: #5c748c;
  --accent: #1a7fd4;
  --accent-strong: #0d63ad;
  --line: #dbe6f1;
  --ok: #128a63;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1721;
    --card: #152331;
    --text: #e8f1f9;
    --muted: #93a8bb;
    --accent: #4aa8ef;
    --accent-strong: #78c2f8;
    --line: #22364a;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { background: var(--bg); color: var(--text); font: 16px/1.55 system-ui, -apple-system, "Segoe UI", sans-serif; }
#app { padding: 16px; max-width: 720px; margin: 0 auto; display: flex; flex-direction: column; gap: 12px; }
.hero { padding: 4px 4px 0; }
.hero-title { display: flex; align-items: center; gap: 8px; }
.hero h1 { font-size: 20px; margin: 0; }
.drop { font-size: 22px; }
.status { margin: 6px 0 0; color: var(--muted); font-size: 13px; min-height: 18px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 16px; }
.card h2 { margin: 0 0 8px; font-size: 16px; }
.banner { display: flex; flex-wrap: wrap; gap: 12px; justify-content: space-between; align-items: center;
  background: var(--accent); color: #fff; border-radius: 14px; padding: 14px 16px; }
.banner-copy { display: flex; flex-direction: column; }
.banner-copy span { font-size: 13px; opacity: 0.9; }
.banner-actions { display: flex; gap: 8px; }
.banner .primary { background: #fff; color: var(--accent-strong); }
.banner .ghost { border-color: rgba(255,255,255,0.7); color: #fff; }
.today-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; }
.label { margin: 0 0 4px; color: var(--muted); font-size: 12px; letter-spacing: 0.04em; text-transform: uppercase; }
.value { margin: 0; font-size: 32px; font-weight: 700; line-height: 1.1; }
.value.small { font-size: 18px; font-weight: 600; }
.unit { font-size: 13px; font-weight: 500; color: var(--muted); margin-left: 4px; }
.goal { text-align: right; }
.progress { height: 10px; border-radius: 999px; background: var(--line); margin: 14px 0 8px; overflow: hidden; }
.progress-bar { height: 100%; width: 0%; background: var(--accent); border-radius: inherit; transition: width 200ms ease; }
.hint { margin: 0; color: var(--muted); font-size: 13px; }
.cup-row { display: flex; gap: 8px; flex-wrap: wrap; }
button, select, input { font: inherit; }
button { min-height: 44px; border-radius: 10px; border: 1px solid var(--line); background: transparent; color: var(--text); padding: 0 14px; cursor: pointer; }
button:disabled { opacity: 0.55; cursor: not-allowed; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
button.ghost { background: transparent; }
.cup { flex: 1 1 0; min-width: 88px; }
.custom-row { display: flex; gap: 8px; margin-top: 10px; }
.custom-row input { flex: 1 1 auto; min-height: 44px; border-radius: 10px; border: 1px solid var(--line); background: transparent; color: var(--text); padding: 0 12px; }
.field { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.field:last-of-type { border-bottom: none; }
.field select, .field input[type="number"] { min-height: 44px; min-width: 128px; border-radius: 10px; border: 1px solid var(--line); background: transparent; color: var(--text); padding: 0 10px; }
.field input[type="checkbox"] { width: 24px; height: 24px; }
.settings-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.history-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.history-list li { display: flex; justify-content: space-between; align-items: center; gap: 12px; font-size: 14px; }
.history-list .day { color: var(--muted); }
.history-list .amount { font-weight: 600; }
.footnote { color: var(--muted); font-size: 12px; margin: 4px 4px 24px; }
.error { border-color: #e0574a; }
.error p { margin: 0 0 12px; color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
@media (max-width: 360px) {
  #app { padding: 12px; }
  .value { font-size: 28px; }
  .cup { min-width: 72px; }
}

.error-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.link-button { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 0 14px;
  border-radius: 10px; border: 1px solid var(--line); color: var(--text); text-decoration: none; font-size: 15px; }
.link-button:hover { border-color: var(--accent); color: var(--accent); }
.chaos-copy { margin: 0 0 12px; color: var(--muted); font-size: 13px; }
.chaos-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.chaos .hint { margin-top: 10px; }
