/* Palette nods to the liked title-card reference (navy + gold). It is a reference only, not a final design. */
:root, [data-theme="dark"] {
  --bg: #0e1424; --panel: #162038; --panel2: #1c2847; --line: #2a3a62;
  --text: #ece6d6; --muted: #a9a693; --gold: #d4af37; --gold2: #f0d376;
  --ok: #5cc28a; --warn: #e6a23c; --bad: #e0656b; --info: #7fb2e6;
  --radius: 14px; --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif;
}
[data-theme="light"] {
  --bg: #f6f1e4; --panel: #fffaf0; --panel2: #f1e8d2; --line: #d8cba8;
  --text: #1c2236; --muted: #6a6450; --gold: #9a7a12; --gold2: #7a5f08;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.45 var(--sans); }
body { padding-bottom: calc(76px + env(safe-area-inset-bottom)); -webkit-text-size-adjust: 100%; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px; border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, var(--panel), var(--bg)); position: sticky; top: 0; z-index: 5; }
.brand { display: flex; flex-direction: column; font-family: var(--serif); color: var(--gold); line-height: 1.1; }
.brand-small { font-variant: small-caps; letter-spacing: .08em; font-size: 13px; }
.brand-big { font-size: 22px; letter-spacing: .04em; text-transform: uppercase; color: var(--gold2); }
.brand-sub { font-size: 12px; font-style: italic; color: var(--muted); }
.icon-btn { background: none; border: 1px solid var(--line); color: var(--gold); border-radius: 50%; width: 42px; height: 42px; font-size: 20px; }
.proto-banner { font-size: 13px; color: var(--muted); text-align: center; padding: 6px 12px; background: var(--panel); }
main { max-width: 760px; margin: 0 auto; padding: 12px 14px 24px; outline: none; }
h2 { font-family: var(--serif); color: var(--gold2); font-weight: 600; margin: 8px 0 10px; font-size: 22px; }
h3 { font-family: var(--serif); color: var(--gold); margin: 0 0 8px; font-size: 18px; font-weight: 600; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin: 0 0 14px; }
.card.alert { border-color: var(--warn); }
.muted { color: var(--muted); } .small { font-size: 13px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.spread { justify-content: space-between; }
.list { list-style: none; margin: 0; padding: 0; }
.list > li { padding: 12px 0; border-top: 1px solid var(--line); }
.list > li:first-child { border-top: 0; }
.item-name { font-weight: 600; }
.badge { display: inline-block; font-size: 12px; padding: 2px 9px; border-radius: 999px; border: 1px solid currentColor; white-space: nowrap; }
.b-taken { color: var(--ok); } .b-missed { color: var(--bad); } .b-uncertain { color: var(--warn); } .b-low { color: var(--warn); } .b-empty { color: var(--bad); } .b-info { color: var(--info); }
button, .btn { font: inherit; border-radius: 10px; border: 1px solid var(--line); background: var(--panel2); color: var(--text);
  padding: 10px 14px; min-height: 44px; cursor: pointer; }
button.primary { background: var(--gold); color: #1a1405; border-color: var(--gold); font-weight: 600; }
button.ok { border-color: var(--ok); color: var(--ok); } button.bad { border-color: var(--bad); color: var(--bad); }
button.warn { border-color: var(--warn); color: var(--warn); } button.link { background: none; border: 0; color: var(--gold); padding: 6px; min-height: 0; text-decoration: underline; }
button:disabled { opacity: .45; cursor: not-allowed; }
.btns { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.btns.check button { flex: 1 1 0; min-width: 90px; }
label { display: block; font-size: 14px; color: var(--muted); margin: 10px 0 4px; }
input, select, textarea { width: 100%; font: inherit; font-size: 16px; color: var(--text); background: var(--bg); border: 1px solid var(--line);
  border-radius: 10px; padding: 10px 12px; min-height: 44px; }
textarea { min-height: 70px; }
input[type="checkbox"], input[type="radio"] { width: 22px; height: 22px; min-height: 0; accent-color: var(--gold); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 10px; }
.days { display: flex; gap: 6px; flex-wrap: wrap; } .days label { display: flex; align-items: center; gap: 4px; margin: 4px 6px 4px 0; color: var(--text); }
.choice { display: flex; gap: 10px; align-items: flex-start; padding: 10px; border: 1px solid var(--line); border-radius: 10px; margin: 8px 0; color: var(--text); }
.choice.disabled { opacity: .5; }
.result { background: var(--bg); border: 1px dashed var(--gold); border-radius: 10px; padding: 12px; margin-top: 10px; }
.result .big { font-size: 26px; font-family: var(--serif); color: var(--gold2); }
.bar { height: 8px; background: var(--bg); border-radius: 99px; overflow: hidden; margin-top: 6px; }
.bar > div { height: 100%; background: var(--gold); }
.bar.low > div { background: var(--warn); }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.seg button { border: 0; border-radius: 0; min-height: 38px; padding: 6px 14px; }
.seg button.on { background: var(--gold); color: #1a1405; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 8px 6px; border-top: 1px solid var(--line); }
.table-wrap { overflow-x: auto; }
.chart { width: 100%; height: auto; display: block; }
.chart-grid { stroke: var(--line); stroke-width: 1; } .chart-label { fill: var(--muted); font-size: 12px; }
.chart-line { fill: none; stroke: var(--gold); stroke-width: 2.5; } .chart-dot { fill: var(--gold2); } .chart-empty { fill: var(--muted); }
.disclaimer { max-width: 760px; margin: 0 auto; padding: 0 16px 16px; font-size: 12px; color: var(--muted); text-align: center; font-style: italic; }
.tabbar { position: fixed; bottom: 0; left: 0; right: 0; display: grid; grid-template-columns: repeat(8, 1fr);
  background: var(--panel); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); z-index: 6; }
.tabbar button { border: 0; border-radius: 0; background: none; color: var(--muted); font-size: 11px; padding: 8px 0; display: flex; flex-direction: column; align-items: center; gap: 2px; min-height: 58px; }
.tabbar button span { font-size: 20px; line-height: 1; }
.tabbar button.active { color: var(--gold2); }
dialog { width: min(560px, 94vw); max-height: 90vh; overflow: auto; background: var(--panel); color: var(--text); border: 1px solid var(--gold); border-radius: var(--radius); padding: 16px; }
dialog::backdrop { background: rgba(0,0,0,.6); }
#toast { position: fixed; left: 50%; bottom: calc(86px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--gold); color: #1a1405;
  padding: 10px 16px; border-radius: 10px; font-weight: 600; opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 20; max-width: 90vw; }
#toast.show { opacity: 1; }
.empty { color: var(--muted); font-style: italic; }
@media (max-width: 420px) { .grid3 { grid-template-columns: 1fr 1fr; } .brand-big { font-size: 19px; } }

.admin-link { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; margin-right: 6px; }
.topbar > .icon-btn:last-child { margin-left: 0; }
.announcement { background: var(--gold); color: #1a1405; padding: 8px 14px; text-align: center; font-weight: 600; font-size: 14px; }
.marker { margin-bottom: 6px; }
code.code { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 15px; letter-spacing: .03em; word-break: break-all; color: var(--gold2); }
.stat { font-family: var(--serif); font-size: 24px; color: var(--gold2); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.stats > div { background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 10px; }
a.btn { display: inline-flex; align-items: center; text-decoration: none; }
[hidden] { display: none !important; }
/* Lab PDF reader */
.b-high { color: var(--bad); }
.tiny { font-size: 11px; line-height: 1.3; margin-top: 2px; overflow-wrap: anywhere; }
div.alert { border: 1px solid var(--warn); border-radius: 10px; padding: 4px 12px; margin: 8px 0; }
.pdf-table td { vertical-align: top; padding: 4px; }
.pdf-table input:not([type=checkbox]) { min-width: 64px; padding: 6px; }
.pdf-table .pdf-name { min-width: 130px; }
.pdf-table select { padding: 6px; }
.pdf-table tr.dup { opacity: .65; }
input.guess { border-style: dashed; }
#pdf-import input[type=file] { flex: 1; min-width: 0; }

/* unit picker + comma-friendly number inputs */
.unit-picker { display: flex; flex-direction: column; gap: 6px; }
.unit-picker .unit-custom[hidden] { display: none; }
input.invalid { border-color: #c0392b; box-shadow: 0 0 0 2px rgba(192, 57, 43, .25); }

/* two-factor recovery codes */
ol.codes { columns: 2; font-size: 1rem; padding-left: 1.4em; }
ol.codes code { letter-spacing: .05em; }
#mfa-qr { background: #fff; border-radius: 8px; }

/* Medication calendar + streaks (v0.7.0) */
:root { --s-taken: var(--ok); --s-late: #c9a227; --s-missed: var(--bad); --s-unsure: var(--warn); --s-unlogged: #8a8fa3; --s-due: var(--info); --s-planned: var(--line); --s-extra: #b48ee0; }
.cal-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.cal-head h3 { margin: 0; flex: 1; text-align: center; }
.cal-head button:not(.link) { min-width: 44px; font-size: 20px; padding: 4px 10px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; margin-top: 10px; }
.cal-dow { text-align: center; font-size: 12px; color: var(--muted); padding: 2px 0; }
.cal-day { min-height: 58px; padding: 4px; border-radius: 8px; display: flex; flex-direction: column; align-items: stretch; gap: 3px; background: var(--bg); text-align: left; }
.cal-day.out { opacity: .4; }
.cal-day.today { border-color: var(--gold); box-shadow: inset 0 0 0 1px var(--gold); }
.cal-num { font-size: 13px; font-weight: 600; }
.cal-dots { display: flex; flex-wrap: wrap; gap: 3px; }
.cal-dots small { font-size: 10px; color: var(--muted); }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--s-planned); flex: none; }
.dot.s-taken { background: var(--s-taken); } .dot.s-late { background: var(--s-late); } .dot.s-missed { background: var(--s-missed); }
.dot.s-unsure { background: var(--s-unsure); } .dot.s-unlogged { background: transparent; box-shadow: inset 0 0 0 2px var(--s-unlogged); }
.dot.s-due { background: transparent; box-shadow: inset 0 0 0 2px var(--s-due); } .dot.s-planned { background: transparent; box-shadow: inset 0 0 0 1.5px var(--muted); opacity: .7; }
.dot.s-extra { background: var(--s-extra); border-radius: 2px; }
.cal-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12px; color: var(--muted); margin-top: 10px; }
.cal-legend span { display: inline-flex; align-items: center; gap: 5px; }
.badge.cal-b.s-taken { color: var(--s-taken); } .badge.cal-b.s-late { color: var(--s-late); } .badge.cal-b.s-missed { color: var(--s-missed); }
.badge.cal-b.s-unsure { color: var(--s-unsure); } .badge.cal-b.s-unlogged { color: var(--muted); } .badge.cal-b.s-due { color: var(--info); } .badge.cal-b.s-planned { color: var(--muted); }
.streak-hero { display: flex; align-items: center; gap: 12px; margin: 4px 0 8px; }
.streak-hero .stat { font-size: 40px; line-height: 1; min-width: 1.4em; text-align: center; }
.list.compact > li { padding: 7px 0; }
@media (max-width: 420px) { .cal-day { min-height: 48px; padding: 3px; } .dot { width: 7px; height: 7px; } }

/* Lab trends (v0.8.0) */
.chart-band { fill: var(--ok); opacity: .12; } .chart-band-edge { stroke: var(--ok); stroke-opacity: .45; stroke-dasharray: 4 4; }
.chart-band-opt { fill: var(--info); opacity: .14; } .chart-band-opt-edge { stroke: var(--info); stroke-opacity: .5; stroke-dasharray: 2 3; }
.chart-dot.pt-high, .chart-dot.pt-low { fill: var(--bad); stroke: var(--panel); stroke-width: 1.5; }
.dot.pt-high { background: var(--bad); }
.swatch { display: inline-block; width: 16px; height: 10px; border-radius: 3px; }
.swatch.band { background: color-mix(in srgb, var(--ok) 30%, transparent); border: 1px dashed var(--ok); }
.swatch.band-opt { background: color-mix(in srgb, var(--info) 30%, transparent); border: 1px dashed var(--info); }
.badge.lt-high, .badge.lt-low { color: var(--bad); } .badge.lt-in { color: var(--ok); } .badge.lt-unknown { color: var(--muted); }
.badge.lt-opt-in { color: var(--info); } .badge.lt-opt-high, .badge.lt-opt-low { color: var(--warn); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0 4px; }
.chip { min-height: 34px; padding: 4px 12px; border-radius: 999px; font-size: 14px; }
.chip.lt-high, .chip.lt-low { border-color: var(--bad); } .chip.on { background: var(--gold); color: #1a1405; border-color: var(--gold); }
.chip.on .muted { color: #1a1405; }
.lt-head { margin: 10px 0 6px; }
.lt-notes { margin: 8px 0; padding-left: 1.2em; font-size: 14px; } .lt-notes li { margin: 3px 0; }
.lt-disclaimer { border-left: 3px solid var(--gold); padding-left: 8px; }
.lt-all summary { cursor: pointer; color: var(--gold); margin-top: 10px; }
#lab-overview tr.sel td { background: var(--panel2); }

/* Header logo block: title + tagline + Schmooie the alchemist emblem as one unit (v0.8.0) */
.brand-block { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-emblem-wrap { display: block; flex: none; line-height: 0; }
.brand-emblem { height: 64px; width: auto; display: block; filter: drop-shadow(0 0 6px rgba(212, 175, 55, .28)) drop-shadow(0 2px 3px rgba(0, 0, 0, .45)); }
[data-theme="light"] .brand-emblem { filter: drop-shadow(0 2px 3px rgba(28, 34, 54, .25)); }
.brand-small { font-size: 15px; }
.brand-big { font-size: 27px; }
.brand-sub { font-size: 14.5px; color: #c9c3ad; letter-spacing: .01em; }
[data-theme="light"] .brand-sub { color: var(--muted); }
@media (max-width: 420px) {
  .brand-small { font-size: 13px; } .brand-big { font-size: 20px; } .brand-sub { font-size: 12.5px; }
  .brand-emblem { height: 52px; } .brand-block { gap: 8px; }
}
@media (max-width: 360px) { .brand-sub { font-size: 11.5px; } .brand-emblem { height: 46px; } }

/* Scale screenshot import (v0.9.0) */
#scale-import input[type=file] { flex: 1; min-width: 0; }
.scale-row.found td { background: color-mix(in srgb, var(--ok) 6%, transparent); }
pre.ocr-text { white-space: pre-wrap; font-size: 12px; max-height: 180px; overflow: auto; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 8px; }
.more-fields summary { cursor: pointer; color: var(--gold); margin: 10px 0 2px; }

/* ===== v1.0.0 visual polish + wide-screen layout (mobile layout unchanged) ===== */
:root, [data-theme="dark"] { --shadow: 0 1px 0 rgba(255,255,255,.035) inset, 0 8px 24px rgba(0,0,0,.28); --accent-line: linear-gradient(90deg, var(--gold), transparent 70%); }
[data-theme="light"] { --shadow: 0 1px 0 rgba(255,255,255,.6) inset, 0 6px 18px rgba(60,48,20,.10); --bad: #b8434a; --ok: #2f8a58; --warn: #a8670f; --info: #2f6ea8; }
.card { box-shadow: var(--shadow); position: relative; }
.card > h3:first-child, .card > .row.spread:first-child h3 { letter-spacing: .01em; }
.card > h3:first-child::after, .card > .row.spread:first-child h3::after { content: ''; display: block; height: 2px; width: 44px; margin-top: 5px; background: var(--accent-line); border-radius: 2px; }
h2 { letter-spacing: .01em; }
.topbar { box-shadow: 0 2px 14px rgba(0,0,0,.25); border-bottom-color: color-mix(in srgb, var(--gold) 35%, var(--line)); }
[data-theme="light"] .topbar { box-shadow: 0 2px 10px rgba(60,48,20,.08); }
.brand-big { text-shadow: 0 1px 0 rgba(0,0,0,.35); }
:focus-visible { outline: 2px solid var(--gold2); outline-offset: 2px; border-radius: 6px; }
button:focus-visible, .btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--gold2); outline-offset: 2px; }
input:focus, select:focus, textarea:focus { border-color: var(--gold); }
button.primary:hover { filter: brightness(1.06); } button:not(.link):not(:disabled):hover { border-color: color-mix(in srgb, var(--gold) 50%, var(--line)); }
/* friendlier empty states */
p.empty, li.empty { font-style: normal; text-align: center; padding: 18px 12px; border: 1px dashed var(--line); border-radius: 12px; background: color-mix(in srgb, var(--bg) 55%, transparent); }
p.empty::before, li.empty::before { content: '✧'; display: block; font-size: 20px; color: var(--gold); opacity: .7; margin-bottom: 4px; }
.list > li.empty { border-top: 1px dashed var(--line); }
.stat { font-variant-numeric: tabular-nums; }
table th { color: var(--muted); font-weight: 600; font-size: 13px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

@media (min-width: 1024px) {
  body { padding-bottom: 0; display: grid; grid-template-columns: 220px minmax(0, 1fr);
    grid-template-areas: "top top" "ann ann" "banner banner" "nav main" "nav foot"; min-height: 100vh; align-content: start; }
  .topbar { grid-area: top; padding: 14px 28px; }
  #announcement { grid-area: ann; } .proto-banner { grid-area: banner; }
  .brand-emblem { height: 68px; }
  nav.tabbar { grid-area: nav; position: sticky; top: 104px; bottom: auto; left: auto; right: auto; align-self: start;
    display: flex; flex-direction: column; gap: 2px; padding: 16px 10px; background: none; border-top: 0; border-right: 1px solid var(--line); min-height: calc(100vh - 104px); }
  .tabbar button { flex-direction: row; justify-content: flex-start; gap: 12px; font-size: 15px; padding: 10px 14px; min-height: 46px; border-radius: 10px; color: var(--muted); }
  .tabbar button span { font-size: 18px; width: 22px; text-align: center; }
  .tabbar button:hover { background: var(--panel); color: var(--text); }
  .tabbar button.active { background: var(--panel2); color: var(--gold2); box-shadow: inset 3px 0 0 var(--gold); }
  main { grid-area: main; max-width: 1260px; width: 100%; margin: 0 auto; padding: 18px 28px 32px;
    columns: 2; column-gap: 18px; }
  /* dashboard: cards flow into two columns (no gaps); wide cards, headings and alerts span the full width */
  main > * { break-inside: avoid; column-span: all; }
  main > .card { column-span: none; display: inline-block; width: 100%; margin: 0 0 18px; padding: 18px 20px; }
  main > .card.wide, main > .card.alert, main > .card:has(.table-wrap table), main > .card:has(#lab-trends), main > .card:has(.cal-grid), main > .card:has(#pdf-import), main > #pdf-import { column-span: all; display: block; }
  main > h2, main > .row { margin: 4px 0 14px; }
  h2 { font-size: 28px; } h3 { font-size: 19px; }
  .disclaimer { grid-area: foot; max-width: 1260px; padding: 0 28px 20px; }
  #toast { bottom: 28px; }
  .cal-day { min-height: 86px; padding: 6px 8px; } .cal-num { font-size: 14px; } .dot { width: 11px; height: 11px; }
  .cal-grid { gap: 6px; }
  .chart { max-height: 420px; max-width: 820px; margin: 0 auto; }
  .grid3 { grid-template-columns: repeat(4, 1fr); }
}
@media (min-width: 1600px) { main { max-width: 1440px; columns: 3; } }

/* ===== v1.1.0: idle pause overlay ===== */
#idle-overlay { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 20px;
  background: rgba(6, 10, 24, .72); backdrop-filter: blur(3px); }
#idle-overlay .idle-card { max-width: 420px; width: 100%; margin: 0; }
body.is-idle { overflow: hidden; }
[data-theme="light"] #idle-overlay { background: rgba(40, 34, 20, .45); }

p.warn { color: var(--warn); }
#bodyimp-table td:last-child { white-space: nowrap; }

/* ===== v1.3.0: Train (fitness log) ===== */
.train-ex { border: 1px solid var(--line); border-radius: 12px; padding: 12px; margin: 12px 0; background: var(--panel2); }
.train-ex .ex-name { font-weight: 600; flex: 1; margin-right: 8px; }
table.sets { width: 100%; border-collapse: collapse; margin: 6px 0; }
table.sets th { font-size: 12px; color: var(--muted); text-align: left; font-weight: 500; padding: 2px 4px; }
table.sets td { padding: 3px 4px; } table.sets td:first-child { width: 2.2em; color: var(--muted); }
table.sets input.num { width: 100%; min-width: 0; }
.ex-suggest { margin: 4px 0; } .ex-last { margin: 4px 0 0; }
.train-item { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.walk-bar { height: 6px; border-radius: 3px; background: var(--panel2); overflow: hidden; margin: 4px 0 12px; }
.walk-bar span { display: block; height: 100%; background: var(--gold); transition: width .3s; }
.walk-ex { font-family: var(--serif, Georgia, serif); font-size: 26px; color: var(--gold2); margin: 4px 0; }
.walk-rest { font-size: 56px; text-align: center; margin: 8px 0; font-variant-numeric: tabular-nums; }
#walk-finished { font-size: 26px; }
#train-walk input.num { font-size: 22px; }
.swap { margin: 6px 0; } .swap summary { cursor: pointer; color: var(--gold); }

.plan-day { border-top: 1px solid var(--line); padding: 10px 0 4px; } .plan-ex { margin: 6px 0 0; padding-left: 18px; } .plan-ex li { margin: 2px 0; }
