:root {
  --bg: #0e1320; --card: #1a2133; --card2: #151b2b; --line: #2f3a52; --track: #2a3248;
  --text: #eef1f8; --soft: #c9d2e6; --muted: #9aa6c2;
  --day: #f5b544; --dayInk: #241a05; --dayBg: #3a2c12;
  --night: #9db0ff; --nightInk: #0f1633; --nightBg: #222b4d;
  --ok: #8fe0b0; --miss: #d9604c;
  --mono: 'DM Mono', ui-monospace, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-family: Outfit, system-ui, sans-serif; -webkit-tap-highlight-color: transparent; }
body { min-height: 100dvh; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
main { max-width: 520px; margin: 0 auto; padding: calc(env(safe-area-inset-top) + 24px) 20px calc(env(safe-area-inset-bottom) + 100px); display: flex; flex-direction: column; gap: 14px; }
.eyebrow { font-family: var(--mono); font-size: 13px; letter-spacing: .08em; color: var(--muted); text-transform: uppercase; }
h1 { margin: 2px 0 6px; font-size: 32px; font-weight: 600; letter-spacing: -.01em; }
h2 { margin: 0; font-size: 20px; font-weight: 600; }
.sub { color: var(--muted); font-size: 15px; margin-top: -6px; }
.mono { font-family: var(--mono); font-size: 13px; color: var(--muted); }
.label { font-family: var(--mono); font-size: 12px; letter-spacing: .08em; color: var(--muted); padding: 8px 4px 0; }

.card { background: var(--card); border-radius: 22px; padding: 20px; display: flex; flex-direction: column; gap: 16px; }
.card.soft { background: var(--card2); }
.card.due-pm { box-shadow: inset 0 0 0 2px var(--night); }
.card.due-am { box-shadow: inset 0 0 0 2px var(--day); }
.row { display: flex; align-items: center; gap: 14px; }
.grow { flex-grow: 1; min-width: 0; }
.badge { width: 48px; height: 48px; border-radius: 16px; display: grid; place-items: center; flex-shrink: 0; }
.badge svg { width: 26px; height: 26px; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.badge.am { background: var(--dayBg); } .badge.am svg { stroke: var(--day); }
.badge.pm { background: var(--nightBg); } .badge.pm svg { stroke: var(--night); }
.pill-tag { font-family: var(--mono); font-size: 12px; padding: 6px 10px; border-radius: 999px; background: var(--nightBg); color: var(--night); white-space: nowrap; }
.pill-tag.am { background: var(--dayBg); color: var(--day); }

.btn { height: 52px; border-radius: 14px; border: 0; font-size: 17px; font-weight: 600; display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; }
.btn.am { background: var(--day); color: var(--dayInk); }
.btn.pm { background: var(--night); color: var(--nightInk); }
.btn.done { background: transparent; border: 1px solid var(--line); color: var(--ok); font-weight: 500; font-size: 16px; }
.btn.done svg { width: 20px; height: 20px; fill: none; stroke: var(--ok); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.btn.ghost { background: transparent; color: var(--day); font-weight: 500; font-size: 15px; height: 46px; }
.btn.outline { background: var(--card); border: 1px solid var(--line); color: var(--text); font-weight: 500; font-size: 16px; height: 46px; }
.btn.danger { background: transparent; color: var(--miss); font-weight: 500; font-size: 15px; height: 46px; }
.btn:disabled { opacity: .5; }
.meds-list { display: flex; flex-direction: column; gap: 4px; font-size: 14px; color: var(--soft); }

a.supply-link { text-decoration: none; color: inherit; }
.bar { height: 8px; border-radius: 999px; background: var(--track); position: relative; }
.bar.big { height: 10px; }
.bar > i { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 999px; background: var(--ok); }
.bar > i.low { background: var(--day); }
.bar > b { position: absolute; top: -5px; bottom: -5px; width: 2px; background: var(--day); border-radius: 1px; }

.week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.week > div { display: flex; flex-direction: column; align-items: center; gap: 5px; }
.week span { width: 30px; height: 12px; border-radius: 6px; background: var(--track); }
.week span.ok { background: var(--ok); } .week span.miss { background: var(--miss); }
.week small { font-family: var(--mono); font-size: 11px; color: var(--muted); }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); padding: 0 4px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }

.photos { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.photo { height: 150px; border-radius: 18px; border: 1px dashed #3a4664; background: var(--card2); color: var(--muted); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; padding: 0; overflow: hidden; position: relative; font-size: 12px; }
.photo strong { font-size: 14px; color: var(--text); font-weight: 500; }
.photo svg { width: 38px; height: 38px; fill: none; stroke: var(--soft); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.photo.has { border: 0; }
.photo img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.photo .cap { position: absolute; left: 8px; bottom: 8px; background: rgba(14,19,32,.8); color: var(--text); padding: 4px 8px; border-radius: 8px; font-size: 12px; }

.big-num { font-size: 56px; font-weight: 600; line-height: 1; letter-spacing: -.02em; }
.days { font-size: 28px; font-weight: 600; color: var(--ok); text-align: right; }
.days.low { color: var(--day); }
.scale { display: flex; justify-content: space-between; font-family: var(--mono); font-size: 11px; color: var(--muted); }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.hist { display: flex; justify-content: space-between; font-size: 14px; color: var(--soft); padding: 2px 4px; }
.hist span:last-child { color: var(--muted); }
.med-tabs { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px; }
.med-tabs button { flex-shrink: 0; height: 40px; padding: 0 16px; border-radius: 999px; border: 1px solid var(--line); background: transparent; color: var(--soft); font-size: 15px; }
.med-tabs button.on { background: var(--day); color: var(--dayInk); border-color: var(--day); font-weight: 600; }

.list { background: var(--card); border-radius: 20px; display: flex; flex-direction: column; }
.list > * { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; min-height: 60px; border-bottom: 1px solid #262f45; }
.list > *:last-child { border-bottom: 0; }
.list label { font-size: 16px; }
.list small { display: block; font-size: 13px; color: var(--muted); }
input[type=time], input[type=number], select { background: #222b40; border: 0; border-radius: 10px; padding: 9px 10px; font-family: var(--mono); font-size: 15px; color: var(--text); color-scheme: dark; }
.switch { appearance: none; width: 50px; height: 30px; border-radius: 999px; background: var(--track); position: relative; flex-shrink: 0; margin: 0; transition: background .15s; }
.switch::after { content: ''; position: absolute; left: 3px; top: 3px; width: 24px; height: 24px; border-radius: 50%; background: var(--soft); transition: transform .15s; }
.switch:checked { background: var(--ok); }
.switch:checked::after { transform: translateX(20px); background: var(--bg); }
.notice { background: var(--dayBg); color: #ffe2a8; border-radius: 16px; padding: 14px 16px; font-size: 14px; line-height: 1.45; display: flex; flex-direction: column; gap: 10px; }
.notice.ok { background: #16302a; color: var(--ok); }

nav#tabs { position: fixed; left: 0; right: 0; bottom: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); padding: 8px 12px calc(env(safe-area-inset-bottom) + 12px); border-top: 1px solid #1f2740; background: #0b0f1a; z-index: 5; }
nav#tabs button { background: none; border: 0; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 6px; font-size: 12px; min-height: 48px; }
nav#tabs button.on { color: var(--day); }
nav#tabs svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

dialog#sheet { border: 0; padding: 0; margin: auto 0 0; width: 100%; max-width: 100%; background: transparent; color: var(--text); }
dialog#sheet::backdrop { background: rgba(5,8,15,.7); }
.sheet { max-width: 520px; margin: 0 auto; background: #151b2b; border-radius: 24px 24px 0 0; padding: 20px 20px calc(env(safe-area-inset-bottom) + 20px); display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 14px; color: var(--muted); }
.field input { font-family: Outfit, sans-serif; font-size: 17px; padding: 12px 14px; border-radius: 12px; background: #222b40; color: var(--text); border: 1px solid #3a4664; color-scheme: dark; outline: none; }
.field input:focus { border-color: var(--day); }
.field input::placeholder { color: #7f8aa6; }
.two { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }

#toast { position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 92px); transform: translateX(-50%) translateY(20px); background: var(--soft); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-size: 15px; opacity: 0; transition: .2s; pointer-events: none; z-index: 10; white-space: nowrap; }
#toast.show { opacity: 1; transform: translateX(-50%); }

.login { min-height: 80dvh; justify-content: center; }
.login input { font-family: var(--mono); font-size: 22px; letter-spacing: .3em; text-align: center; padding: 14px; border-radius: 14px; background: #222b40; border: 0; color: var(--text); }
.err { color: var(--miss); font-size: 14px; min-height: 18px; }
.empty { text-align: center; color: var(--muted); padding: 30px 10px; display: flex; flex-direction: column; gap: 14px; align-items: center; }
nav#tabs[hidden] { display: none; }
