:root {
  --bg: #f6f5f1;
  --card: #ffffff;
  --text: #1d1d1b;
  --muted: #6b6a64;
  --line: #e4e2da;
  --accent: #2f6f5e;
  --accent-text: #ffffff;
  --accent-soft: #e3efea;
  --p1: #b93a2e;
  --p2: #a8741a;
  --p3: #55687a;
  --danger: #b93a2e;
  --radius: 18px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121413;
    --card: #1c1f1d;
    --text: #efeee9;
    --muted: #9a9a92;
    --line: #2d312e;
    --accent: #4aa088;
    --accent-text: #07120e;
    --accent-soft: #1f2e29;
    --p1: #e0675a;
    --p2: #d9a441;
    --p3: #8fa3b5;
    --danger: #e0675a;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 17px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  min-height: 100vh; min-height: 100dvh;
}
#app { max-width: 560px; margin: 0 auto; padding: calc(14px + var(--safe-t)) 16px calc(96px + var(--safe-b)); }
h1 { font-size: 15px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 6px 0 14px; }
h2 { font-size: 13px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin: 22px 0 8px; }
button { font: inherit; color: inherit; cursor: pointer; }
input, select, textarea { font: inherit; font-size: 16px; color: var(--text); }

/* buttons */
.btn { border: 1px solid var(--line); background: var(--card); border-radius: 14px; padding: 14px 18px; font-weight: 600; min-height: 50px; }
.btn.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.btn.big { font-size: 20px; min-height: 64px; width: 100%; }
.btn.danger { color: var(--danger); }
.btn.ghost { background: transparent; }
.btn:active { transform: scale(.98); }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; }

/* chips */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { white-space: nowrap; border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: 8px 14px; font-size: 15px; min-height: 38px; }
.chip.on { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.chip.small { padding: 4px 10px; min-height: 0; font-size: 13px; color: var(--muted); }
.avail { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; overflow-x: auto; }
.avail span { color: var(--muted); font-size: 14px; white-space: nowrap; }

/* now card */
.now { background: var(--card); border: 1px solid var(--line); border-radius: 26px; padding: 24px 20px 20px; box-shadow: 0 6px 24px rgba(0,0,0,.05); }
.kicker { font-size: 13px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); margin-bottom: 10px; }
.now .title { font-size: 28px; line-height: 1.2; font-weight: 700; margin: 0 0 12px; overflow-wrap: anywhere; }
.now .reason { color: var(--muted); margin: 0 0 16px; }
.meta { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 20px; }
.tag { font-size: 13px; padding: 4px 10px; border-radius: 999px; background: var(--accent-soft); color: var(--text); }
.tag.p1 { color: var(--p1); background: transparent; border: 1px solid var(--p1); }
.tag.p2 { color: var(--p2); background: transparent; border: 1px solid var(--p2); }
.tag.p3 { color: var(--p3); background: transparent; border: 1px solid var(--p3); }
.tag.late { color: var(--danger); font-weight: 600; }
.timer { font-size: 54px; font-weight: 700; text-align: center; font-variant-numeric: tabular-nums; margin: 4px 0 18px; letter-spacing: .02em; }
.stack { display: grid; gap: 10px; }
.empty { text-align: center; padding: 40px 10px; color: var(--muted); }
.empty b { display: block; color: var(--text); font-size: 24px; margin-bottom: 6px; }
.upnext { margin-top: 26px; }
.upnext .item { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); color: var(--muted); font-size: 15px; }
.upnext .item span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stat { text-align: center; color: var(--muted); font-size: 14px; margin-top: 18px; }

/* lists */
.list { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.li { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-top: 1px solid var(--line); }
.li:first-child { border-top: 0; }
.li .grow { flex: 1; min-width: 0; text-align: left; background: none; border: 0; padding: 0; }
.li .name { display: block; font-weight: 600; overflow-wrap: anywhere; }
.li .sub { display: block; font-size: 13px; color: var(--muted); }
.li.done .name { text-decoration: line-through; color: var(--muted); }
.check { width: 30px; height: 30px; border-radius: 50%; border: 2px solid var(--line); background: transparent; flex: none; padding: 0; }
.check.on { background: var(--accent); border-color: var(--accent); }
.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.dot.p1 { background: var(--p1); } .dot.p2 { background: var(--p2); } .dot.p3 { background: var(--p3); }
.mini { border: 1px solid var(--line); background: var(--card); border-radius: 10px; width: 36px; height: 36px; padding: 0; }
.bar { display: flex; gap: 8px; align-items: center; justify-content: space-between; }
.filters { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 6px; margin-bottom: 4px; }
.filters .chip { white-space: nowrap; }

/* tab bar + add button */
.tabs { position: fixed; left: 0; right: 0; bottom: 0; background: var(--card); border-top: 1px solid var(--line); display: flex; justify-content: center; padding-bottom: var(--safe-b); z-index: 5; }
.tabs .in { display: flex; width: 100%; max-width: 560px; }
.tab { flex: 1; border: 0; background: none; padding: 12px 4px 10px; font-size: 12px; color: var(--muted); display: grid; gap: 2px; justify-items: center; }
.tab .ico { font-size: 22px; line-height: 1; }
.tab.on { color: var(--accent); font-weight: 700; }
.fab { position: fixed; right: max(18px, calc(50% - 262px)); bottom: calc(80px + var(--safe-b)); width: 60px; height: 60px; border-radius: 50%; border: 0; background: var(--accent); color: var(--accent-text); font-size: 34px; line-height: 1; box-shadow: 0 8px 22px rgba(0,0,0,.25); z-index: 6; }

/* sheet */
#sheet:empty { display: none; }
.scrim { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 20; display: flex; align-items: flex-end; justify-content: center; }
.panel { background: var(--bg); width: 100%; max-width: 560px; max-height: 92vh; max-height: 92dvh; overflow-y: auto; border-radius: 24px 24px 0 0; padding: 18px 16px calc(20px + var(--safe-b)); }
.panel h3 { margin: 0 0 14px; font-size: 20px; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 6px; }
.in, .field input[type=text], .field input[type=date], .field input[type=number], .field input[type=email], .field input[type=password], .field input[type=url], .field textarea, .field select {
  width: 100%; border: 1px solid var(--line); background: var(--card); border-radius: 12px; padding: 12px 14px; min-height: 48px;
}
.field textarea { min-height: 80px; resize: vertical; }
.quick { font-size: 20px; }
.hint { font-size: 13px; color: var(--muted); margin: 6px 0 0; }
.preview { font-size: 14px; color: var(--accent); margin: 0 0 14px; min-height: 20px; }
.note { font-size: 14px; color: var(--muted); background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; margin: 10px 0; }
.status-ok { color: var(--accent); font-weight: 600; }
.status-bad { color: var(--danger); font-weight: 600; }

/* toast */
#toast { position: fixed; left: 50%; bottom: calc(150px + var(--safe-b)); transform: translateX(-50%) translateY(20px); background: var(--text); color: var(--bg); padding: 12px 18px; border-radius: 999px; font-weight: 600; opacity: 0; pointer-events: none; transition: all .25s; z-index: 30; max-width: 90vw; text-align: center; }
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
