/* Tonic: a quiet, green-black room; the mint check is the only bright thing. */
:root {
  color-scheme: dark;
  --bg: #0f1411;
  --panel: #171e1a;
  --panel-2: #1e2722;
  --line: #2a352e;
  --text: #ece9e1;
  --muted: #8f9a93;
  --dim: #5c6862;
  --mint: #5fd3a8;
  --mint-2: #7ee6bf;
  --mint-ink: #0b1f17;
  --amber: #f0a35e;
  --red: #e0604f;
  --radius: 16px;
  --pad: 16px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --tabs-h: 62px;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: 16px; line-height: 1.45; -webkit-font-smoothing: antialiased;
  min-height: 100vh; min-height: 100dvh;
  padding-bottom: calc(var(--tabs-h) + 24px + var(--safe-b));
}
a { color: var(--mint-2); text-decoration: none; }
button { font: inherit; color: inherit; }
input, select, textarea { font: inherit; }
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: 26px; }
h2 { font-size: 17px; color: var(--muted); font-weight: 500; }
.num { font-variant-numeric: tabular-nums; }
:focus-visible { outline: 2px solid var(--mint-2); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* Header */
.top { display: flex; align-items: center; gap: 14px; padding: calc(14px + env(safe-area-inset-top, 0px)) var(--pad) 8px; max-width: 760px; margin: 0 auto; }
@media (display-mode: standalone) { .top { padding-top: calc(26px + env(safe-area-inset-top, 0px)); } }
.brand { color: var(--text); font-weight: 700; font-size: 18px; letter-spacing: 0.02em; margin-right: auto; }
.hdr-actions { display: flex; gap: 8px; align-items: center; }
.hdr-actions a { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 50%; border: 1px solid var(--mint); color: var(--mint-2); font-weight: 700; font-size: 17px; line-height: 1; }
.hdr-actions a svg { width: 18px; height: 18px; }
.hdr-actions a:hover { background: rgba(95,211,168,.12); }

.view { max-width: 760px; margin: 0 auto; padding: 4px var(--pad) 0; }
.section { margin-top: 24px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 10px; gap: 12px; }
.section-head .link { font-size: 14px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.empty { color: var(--muted); padding: 24px 16px; text-align: center; }
.hint { color: var(--dim); font-size: 13px; }
.err { color: var(--red); font-size: 14px; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 11px 18px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel-2); cursor: pointer; font-weight: 500; min-height: 44px; }
.btn:hover { border-color: #3a4a40; }
.btn.primary { background: var(--mint); color: var(--mint-ink); border-color: var(--mint); font-weight: 600; }
.btn.primary:hover { background: var(--mint-2); }
.btn.danger { color: var(--red); }
.btn.ghost { background: none; }
.btn.small { padding: 7px 12px; min-height: 36px; font-size: 14px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.row.end { justify-content: flex-end; }
.row.between { justify-content: space-between; }
.spacer { flex: 1; }
.linkbtn { background: none; border: 0; padding: 0; color: var(--mint-2); font-size: 14px; cursor: pointer; }

/* Tabs */
.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 5; display: flex; justify-content: space-around; background: rgba(15,20,17,.92); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-top: 1px solid var(--line); padding: 6px 0 calc(6px + var(--safe-b)); }
.tabs a { display: flex; flex-direction: column; align-items: center; gap: 3px; color: var(--dim); font-size: 11px; width: 72px; padding: 4px 0; border-radius: 10px; }
.tabs a svg { width: 22px; height: 22px; }
.tabs a.on { color: var(--mint-2); }
.tabs:empty { display: none; }

/* Day header */
.dayhead { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 6px 0 14px; }
.dayhead .nav { width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--line); background: var(--panel); display: grid; place-items: center; color: var(--muted); cursor: pointer; font-size: 20px; line-height: 1; }
.dayhead .nav:hover { color: var(--text); }
.dayhead .title { text-align: center; }
.dayhead .title b { display: block; font-size: 20px; font-weight: 700; }
.dayhead .title span { color: var(--muted); font-size: 13px; }
.progress { margin: 0 0 18px; }
.progress .line { display: flex; justify-content: space-between; font-size: 14px; color: var(--muted); margin-bottom: 6px; }
.progress .line b { color: var(--text); }
.progress .bar { height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; }
.progress .bar span { display: block; height: 100%; background: var(--mint); border-radius: 3px; transition: width .35s ease; }
.progress.done .bar span { background: var(--mint-2); }
.progress .alldone { color: var(--mint-2); font-weight: 600; }

/* Slot groups */
.slot { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 12px; overflow: hidden; }
.slot.overdue { border-color: rgba(240,163,94,.5); }
.slot.flash { animation: flash 1.2s ease; }
@keyframes flash { 0% { box-shadow: 0 0 0 0 rgba(95,211,168,.5); } 100% { box-shadow: 0 0 0 14px rgba(95,211,168,0); } }
.slothead { display: flex; align-items: center; gap: 10px; padding: 12px 14px 10px; border-bottom: 1px solid var(--line); }
.slothead .ico { width: 30px; height: 30px; border-radius: 9px; background: var(--panel-2); display: grid; place-items: center; color: var(--mint-2); flex: none; }
.slothead .ico svg { width: 17px; height: 17px; }
.slot.overdue .slothead .ico { color: var(--amber); }
.slothead .t { font-weight: 600; }
.slothead .s { color: var(--muted); font-size: 13px; }
.slothead .right { margin-left: auto; font-size: 14px; }
.slothead .done { color: var(--mint-2); font-weight: 600; font-size: 14px; }
.slothead .late { color: var(--amber); font-weight: 600; font-size: 13px; margin-right: 8px; }
.dose { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-bottom: 1px solid var(--line); cursor: pointer; -webkit-tap-highlight-color: transparent; user-select: none; }
.dose:last-child { border-bottom: 0; }
.dose:active { background: var(--panel-2); }
.chk { width: 44px; height: 44px; border-radius: 50%; border: 2px solid var(--dim); display: grid; place-items: center; flex: none; color: var(--mint-ink); transition: background .18s, border-color .18s, transform .18s; }
.chk svg { width: 22px; height: 22px; stroke-dasharray: 30; stroke-dashoffset: 30; transition: stroke-dashoffset .25s ease .05s; }
.dose.taken .chk { background: var(--mint); border-color: var(--mint); }
.dose.taken .chk svg { stroke-dashoffset: 0; }
.dose.pop .chk { animation: pop .3s ease; }
@keyframes pop { 0% { transform: scale(.85); } 60% { transform: scale(1.12); } 100% { transform: scale(1); } }
.dose.skipped .chk { border-style: dashed; border-color: var(--dim); }
.dose.skipped .chk::after { content: ""; width: 14px; height: 2px; background: var(--dim); border-radius: 1px; }
.dose .name { font-weight: 500; }
.dose.taken .name, .dose.skipped .name { color: var(--muted); }
.dose .sub { color: var(--muted); font-size: 13px; }
.dose .main { flex: 1; min-width: 0; }
.dose .when { color: var(--mint-2); font-size: 13px; white-space: nowrap; }
.dose .skip { background: none; border: 0; color: var(--dim); font-size: 13px; white-space: nowrap; padding: 8px 6px; cursor: pointer; border-radius: 8px; }
.dose .skip:hover { color: var(--muted); }
.dose.skipped .when { color: var(--dim); }
.dose .pill { display: inline-block; font-size: 11px; padding: 1px 7px; border-radius: 999px; background: var(--panel-2); color: var(--muted); margin-left: 6px; vertical-align: middle; }

/* Items list */
.item { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-bottom: 1px solid var(--line); color: var(--text); }
.item:last-child { border-bottom: 0; }
.item .main { flex: 1; min-width: 0; }
.item .name { font-weight: 500; }
.item .sub { color: var(--muted); font-size: 13px; }
.item .stock { font-size: 13px; color: var(--muted); white-space: nowrap; }
.item .stock.low { color: var(--amber); }
.item.paused { opacity: .55; }
.kindtag { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--panel-2); color: var(--mint-2); flex: none; }
.kindtag.medication { color: var(--amber); }
.kindtag svg { width: 18px; height: 18px; }
.handle { color: var(--dim); font-size: 18px; padding: 4px; cursor: grab; }

/* Forms */
.form { display: grid; gap: 18px; }
.form .grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; align-items: start; }
@media (max-width: 420px) { .form .grid2.stack { grid-template-columns: 1fr; } }
label.f, div.f { display: grid; gap: 7px; font-size: 13px; color: var(--muted); align-content: start; }
label.f > span, div.f > span { padding-left: 2px; }
.f input, .f select, .f textarea { -webkit-appearance: none; appearance: none; margin: 0; width: 100%; height: 46px; line-height: 22px; background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 12px; padding: 0 12px; font-size: 16px; display: block; }
.f input[type="time"], .f input[type="date"] { display: flex; align-items: center; }
.f textarea { height: auto; min-height: 90px; padding: 11px 12px; resize: vertical; }
.f input:focus, .f select:focus, .f textarea:focus { border-color: var(--mint); outline: none; }
.f input::placeholder { color: var(--dim); }
.f select { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%238f9a93' stroke-width='1.8'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 32px; }
.seg { display: flex; background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 3px; gap: 3px; }
.seg button { flex: 1; border: 0; background: none; border-radius: 9px; padding: 9px 6px; color: var(--muted); font-size: 14px; cursor: pointer; min-height: 38px; }
.seg button.on { background: var(--panel-2); color: var(--text); font-weight: 600; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { border: 1px solid var(--line); background: var(--bg); color: var(--muted); border-radius: 999px; padding: 9px 14px; font-size: 14px; cursor: pointer; min-height: 40px; display: inline-flex; align-items: center; gap: 6px; }
.chip.on { background: rgba(95,211,168,.14); border-color: var(--mint); color: var(--text); }
.chip small { color: var(--dim); font-size: 12px; }
.chip.on small { color: var(--mint-2); }
.check { display: flex; align-items: center; gap: 10px; font-size: 15px; color: var(--text); }
.check input { width: 22px; height: 22px; accent-color: var(--mint); }
.confirm { background: rgba(224,96,79,.1); border: 1px solid rgba(224,96,79,.4); border-radius: 12px; padding: 12px 14px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
.page-head { display: flex; align-items: center; gap: 12px; margin: 6px 0 18px; }
.page-head .back { color: var(--muted); font-size: 14px; }
.page-head h1 { font-size: 22px; }
.actions { margin-top: 28px; }
.money { position: relative; }

/* Stats */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.stat b { display: block; font-size: 28px; font-weight: 700; line-height: 1.1; }
.stat b.mint { color: var(--mint-2); }
.stat span { color: var(--muted); font-size: 13px; }
.strip { display: flex; gap: 3px; align-items: flex-end; height: 64px; padding: 14px 14px 8px; }
.strip .d { flex: 1; border-radius: 3px 3px 1px 1px; background: var(--line); min-height: 4px; position: relative; }
.strip .d.full { background: var(--mint); }
.strip .d.part { background: var(--amber); }
.strip .d.none { background: var(--red); }
.strip .d.today { outline: 1px solid var(--text); outline-offset: 1px; }
.striplabels { display: flex; justify-content: space-between; padding: 0 14px 12px; color: var(--dim); font-size: 12px; }
.pbar { height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; margin-top: 6px; }
.pbar span { display: block; height: 100%; background: var(--mint); }

/* Welcome */
.welcome { text-align: center; padding: 28px 18px; }
.welcome h1 { font-size: 24px; margin-bottom: 6px; }
.welcome p { color: var(--muted); margin: 0 0 18px; }
.quick { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 14px; }

/* Login */
.login { max-width: 360px; margin: 10vh auto 0; text-align: center; }
.login .mark { width: 72px; height: 72px; margin: 0 auto 18px; border-radius: 22px; background: linear-gradient(160deg, #1d2a24, #121a16); border: 1px solid var(--line); display: grid; place-items: center; color: var(--mint-2); }
.login .mark svg { width: 38px; height: 38px; }
.login p { color: var(--muted); }
.pwmeter { margin: -8px 0 0; }
.pwbar { display: flex; gap: 4px; margin: 6px 0 4px; }
.pwbar span { flex: 1; height: 4px; border-radius: 2px; background: var(--line); }
.pwlabel { font-size: 12px; color: var(--dim); }
.pwmeter[data-level="1"] .pwbar span:nth-child(1) { background: var(--red); }
.pwmeter[data-level="2"] .pwbar span:nth-child(-n+2) { background: var(--amber); }
.pwmeter[data-level="3"] .pwbar span { background: var(--mint); }

/* Guide */
.lead { font-size: 17px; line-height: 1.5; color: var(--text); max-width: 680px; margin: -6px 0 18px; }
.toc { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; margin-bottom: 8px; }
.toc a { display: flex; align-items: center; gap: 8px; padding: 9px 11px; border-radius: 12px; background: var(--panel); border: 1px solid var(--line); color: var(--text); font-size: 14px; line-height: 1.2; }
.toc .ico { width: 18px; height: 18px; flex: none; color: var(--mint-2); }
.toc .ico svg { width: 100%; height: 100%; display: block; }
.gsec { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px 6px; margin-top: 14px; max-width: 760px; scroll-margin-top: 12px; }
.ghead { display: flex; align-items: center; gap: 12px; margin-bottom: 6px; }
.gico { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; flex: none; background: rgba(95,211,168,.14); color: var(--mint-2); border: 1px solid rgba(95,211,168,.3); }
.gico svg { width: 21px; height: 21px; }
.gico.vtag { font-size: 12px; font-weight: 700; width: auto; padding: 0 10px; }
.ghead h3 { font-size: 18px; font-weight: 600; color: var(--text); }
.gbody p, .changes { margin: 0 0 10px; color: #cfd6d1; line-height: 1.55; }
.gbody b { color: var(--text); }
.changes { padding-left: 20px; }
.changes li { margin-bottom: 5px; }
.version { color: var(--dim); font-size: 13px; text-align: center; margin: 28px 0 0; }
.version a { color: var(--muted); }
.steps { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 4px 0 12px; }
@media (max-width: 560px) { .steps { grid-template-columns: 1fr; } }
.step { background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.step > b { display: block; color: var(--text); margin-bottom: 6px; }
.step ol { margin: 0; padding-left: 20px; color: #cfd6d1; line-height: 1.5; }
.mono { font-family: ui-monospace, Menlo, monospace; font-size: 14px; color: var(--mint-2); }

/* Toast */
.toast { position: fixed; left: 50%; bottom: calc(var(--tabs-h) + 14px + var(--safe-b)); transform: translateX(-50%) translateY(20px); background: #263129; color: var(--text); padding: 10px 16px; border-radius: 999px; font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 9; white-space: nowrap; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (min-width: 900px) {
  .view, .top { max-width: 1040px; }
  .form, .page-head, .login { max-width: 680px; }
  .two { display: grid; grid-template-columns: minmax(0, 6fr) minmax(0, 5fr); gap: 28px; align-items: start; }
}

/* Upcoming + ramp steps */
.upcoming { background: var(--panel); border: 1px dashed var(--line); border-radius: 12px; padding: 10px 14px; margin: -6px 0 14px; color: var(--muted); font-size: 13px; display: grid; gap: 4px; }
.upcoming b { color: var(--text); font-weight: 600; }
.steps-list { display: grid; gap: 10px; }
.step-row { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; display: grid; gap: 12px; }

/* Reference files */
.docrow { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.docrow:last-child { border-bottom: 0; }
.docrow .thumb { width: 56px; height: 56px; border-radius: 10px; overflow: hidden; border: 1px solid var(--line); display: grid; place-items: center; color: var(--muted); font-size: 12px; flex: none; background: var(--panel-2); }
.docrow .thumb img { width: 100%; height: 100%; object-fit: cover; }
.docrow .name { font-weight: 500; }
.docrow .sub { color: var(--muted); font-size: 13px; }
.upload { display: block; border: 1px dashed var(--line); border-radius: 12px; padding: 14px; text-align: center; color: var(--muted); cursor: pointer; font-size: 14px; }
.upload input { display: none; }

html { touch-action: manipulation; -webkit-text-size-adjust: 100%; }
button, a, .dose, .rem, .svc, .chip { touch-action: manipulation; }
