/* =====================================================================
   Fuel styles
   Themes set CSS variables on [data-theme] (any element, so the
   account page's previews can render each theme in place).
   Chart colors --s1/--s2/--s3 (protein / carbs / fat; --s1 also draws
   calories and the weight line) were checked with the dataviz palette
   validator against each theme's surface.
   ===================================================================== */

/* ---------- Modern (default): light, auto-dark ---------- */
:root, [data-theme="modern"] {
  color-scheme: light;
  --bg: #f4f3ef;
  --bg-fill: var(--bg);
  --surface: #fcfcfb;
  --surface-2: #f0efec;
  --line: #e4e2dc;
  --grid: #ebe9e4;
  --text: #0b0b0b;
  --text-2: #52514e;
  --muted: #7a7974;
  --accent: #2a78d6;
  --on-accent: #ffffff;
  --s1: #2a78d6;
  --s2: #eb6834;
  --s3: #1baf7a;
  --raw: #a8a7a0;
  --note-bg: #fff6e6;
  --note-line: #f3d9a6;
  --danger: #c23434;
  --radius: 14px;
  --radius-sm: 9px;
  --card-shadow: none;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-display: var(--font);
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Consolas, monospace;
  --label-case: none;
  --label-spacing: 0;
  --display-weight: 650;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]), :root[data-theme="modern"], [data-theme="modern"] {
    color-scheme: dark;
    --bg: #121211;
    --surface: #1a1a19;
    --surface-2: #232321;
    --line: #2e2e2b;
    --grid: #2a2a27;
    --text: #f0efec;
    --text-2: #c3c2b7;
    --muted: #8f8e86;
    --accent: #3987e5;
    --on-accent: #ffffff;
    --s1: #3987e5;
    --s2: #d95926;
    --s3: #199e70;
    --raw: #6b6a64;
    --note-bg: #2a2416;
    --note-line: #4d4020;
    --danger: #e66767;
  }
}

/* ---------- Classic: ink on paper ---------- */
[data-theme="classic"] {
  color-scheme: light;
  --bg: #f1eee6;
  --bg-fill: var(--bg);
  --surface: #fffdf8;
  --surface-2: #f5f1e7;
  --line: #d9d3c4;
  --grid: #ebe6da;
  --text: #1a1814;
  --text-2: #4a453b;
  --muted: #7a7366;
  --accent: #2a5ea6;
  --on-accent: #ffffff;
  --s1: #2a5ea6;
  --s2: #b5442c;
  --s3: #1e9070;
  --raw: #aaa392;
  --note-bg: #fbf3df;
  --note-line: #e6d6aa;
  --danger: #b5442c;
  --radius: 6px;
  --radius-sm: 4px;
  --card-shadow: 0 1px 0 rgba(0,0,0,.04);
  --font: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  --font-display: "Iowan Old Style", "Palatino Linotype", Georgia, "Times New Roman", serif;
  --label-case: uppercase;
  --label-spacing: .08em;
  --display-weight: 600;
}

/* ---------- Marathon: Bungie-inspired neon on black ---------- */
[data-theme="marathon"] {
  color-scheme: dark;
  --bg: #0a0a0a;
  --bg-fill:
    linear-gradient(rgba(198,255,0,.035) 1px, transparent 1px) 0 0 / 28px 28px,
    linear-gradient(90deg, rgba(198,255,0,.035) 1px, transparent 1px) 0 0 / 28px 28px,
    #0a0a0a;
  --surface: #101010;
  --surface-2: #1a1a1a;
  --line: #2b2b2b;
  --grid: #1f1f1f;
  --text: #ecefe6;
  --text-2: #b9bdb1;
  --muted: #7d8177;
  --accent: #c6ff00;
  --on-accent: #0a0a0a;
  --s1: #c6ff00;
  --s2: #ff2e9a;
  --s3: #00d9ff;
  --raw: #5d6058;
  --note-bg: #1b1f0a;
  --note-line: #4b5f00;
  --danger: #ff2e9a;
  --radius: 2px;
  --radius-sm: 2px;
  --card-shadow: none;
  --font: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  --font-display: "Cascadia Mono", "SF Mono", ui-monospace, Consolas, monospace;
  --label-case: uppercase;
  --label-spacing: .14em;
  --display-weight: 700;
}

/* ---------- Wizarding: Harry Potter-inspired parchment ---------- */
[data-theme="wizarding"] {
  color-scheme: light;
  --bg: #e7d7b1;
  --bg-fill: radial-gradient(ellipse at 50% 0%, #f1e5c6 0%, #e7d7b1 55%, #d9c494 100%) fixed;
  --surface: #f6ecd4;
  --surface-2: #efe2c2;
  --line: #cdb47e;
  --grid: #e5d5ad;
  --text: #2b1d0e;
  --text-2: #5a4630;
  --muted: #806a4c;
  --accent: #8e1b1b;
  --on-accent: #f6ecd4;
  --s1: #a62626;
  --s2: #a87a0c;
  --s3: #2f5fa8;
  --raw: #b39d74;
  --note-bg: #f3e3b8;
  --note-line: #c9a227;
  --danger: #8e1b1b;
  --radius: 4px;
  --radius-sm: 3px;
  --card-shadow: inset 0 0 0 3px var(--surface), inset 0 0 0 4px #e0cc98, 0 2px 6px rgba(60,35,10,.12);
  --font: "Palatino Linotype", "Book Antiqua", Palatino, Georgia, serif;
  --font-display: "Palatino Linotype", "Book Antiqua", Palatino, Georgia, serif;
  --label-case: none;
  --label-spacing: .04em;
  --display-weight: 700;
}

/* ---------- Ember: Fuel's own ---------- */
[data-theme="ember"] {
  color-scheme: dark;
  --bg: #141110;
  --bg-fill: radial-gradient(ellipse at 50% -10%, rgba(255,122,26,.16), transparent 55%) fixed, #141110;
  --surface: #1d1916;
  --surface-2: #27211d;
  --line: #352c26;
  --grid: #2a231f;
  --text: #f6eee6;
  --text-2: #d2c4b6;
  --muted: #9a8a7c;
  --accent: #ff7a1a;
  --on-accent: #1a0f08;
  --s1: #e06a1e;
  --s2: #3b8fd6;
  --s3: #d65c9c;
  --raw: #6e6158;
  --note-bg: #2b1d12;
  --note-line: #5c3716;
  --danger: #ff7a6b;
  --radius: 16px;
  --radius-sm: 10px;
  --card-shadow: 0 1px 0 rgba(255,140,60,.05) inset;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --font-display: var(--font);
  --label-case: none;
  --label-spacing: 0;
  --display-weight: 700;
}

/* ---------- Synthwave ---------- */
[data-theme="synthwave"] {
  color-scheme: dark;
  --bg: #1a0b2e;
  --bg-fill: linear-gradient(180deg, #170a29 0%, #250d40 55%, #3a1150 100%) fixed;
  --surface: #1d1230;
  --surface-2: #2a1a44;
  --line: #3d2660;
  --grid: #2e1d4a;
  --text: #fbeaff;
  --text-2: #dcc6f0;
  --muted: #a88dc6;
  --accent: #ff4fa3;
  --on-accent: #1a0b2e;
  --s1: #f0428f;
  --s2: #17a5b5;
  --s3: #a66bff;
  --raw: #6f5a8e;
  --note-bg: #2f1440;
  --note-line: #6a2a78;
  --danger: #ff6b9a;
  --radius: 12px;
  --radius-sm: 8px;
  --card-shadow: 0 0 0 1px rgba(255,79,163,.08), 0 8px 30px rgba(166,107,255,.10);
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --font-display: var(--font);
  --label-case: uppercase;
  --label-spacing: .12em;
  --display-weight: 800;
}

/* ---------- Matcha ---------- */
[data-theme="matcha"] {
  color-scheme: light;
  --bg: #eeece0;
  --bg-fill: var(--bg);
  --surface: #fbfaf3;
  --surface-2: #f1efe3;
  --line: #dfdccb;
  --grid: #ebe8da;
  --text: #23281f;
  --text-2: #4b5243;
  --muted: #7b8070;
  --accent: #4f8a3c;
  --on-accent: #ffffff;
  --s1: #4f8a3c;
  --s2: #c0527a;
  --s3: #3a6fb8;
  --raw: #b3b4a2;
  --note-bg: #f6f0d6;
  --note-line: #e1d49a;
  --danger: #b4463c;
  --radius: 20px;
  --radius-sm: 12px;
  --card-shadow: 0 1px 2px rgba(40,50,30,.05), 0 4px 14px rgba(40,50,30,.04);
  --font: "Nunito", "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  --font-display: "Nunito", "Segoe UI Variable Display", "Segoe UI", system-ui, sans-serif;
  --label-case: none;
  --label-spacing: 0;
  --display-weight: 700;
}

/* =====================================================================
   Base
   ===================================================================== */
* { box-sizing: border-box; }
html, body { margin: 0; }
html { background: var(--bg); }
body {
  font-family: var(--font);
  background: var(--bg-fill);
  color: var(--text);
  font-size: 15px;
  line-height: 1.45;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
button, input { font: inherit; color: inherit; }
a { color: inherit; }
.muted { color: var(--muted); }
.center { text-align: center; }
.num { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--mono); font-size: 13px; word-break: break-all; }
code { font-family: var(--mono); font-size: 12px; background: var(--surface-2); padding: 1px 5px; border-radius: 4px; }

/* ---------- Brand ---------- */
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 20px; letter-spacing: -0.01em; font-family: var(--font-display); }
.brand img { display: block; border-radius: 7px; }
.brand-lg { font-size: 28px; justify-content: center; margin-bottom: 6px; }

/* ---------- Buttons ---------- */
button { cursor: pointer; }
.primary {
  width: 100%; padding: 12px 16px; border: 0; border-radius: var(--radius-sm);
  background: var(--accent); color: var(--on-accent); font-weight: 600;
}
.primary:hover { filter: brightness(1.06); }
.ghost, .chip {
  background: transparent; border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 6px 12px; color: var(--text-2); text-decoration: none;
}
.ghost:hover, .chip:hover { background: var(--surface-2); color: var(--text); }
.ghost.danger { color: var(--danger); }
.ghost.danger:hover { border-color: var(--danger); }
.chip[aria-pressed="true"] { background: var(--text); color: var(--surface); border-color: var(--text); }
.icon-btn { width: 36px; height: 36px; padding: 0; display: grid; place-items: center; font-size: 18px; }
:is(button, a, input, [tabindex]):focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button:disabled { opacity: .35; cursor: default; }

/* ---------- Login ---------- */
.login-page { display: grid; place-items: center; padding: 24px; }
.login-card {
  width: 100%; max-width: 360px; background: var(--surface); border: 1px solid var(--line);
  border-radius: calc(var(--radius) + 4px); padding: 32px 28px; text-align: center; box-shadow: var(--card-shadow);
}
.login-card form { text-align: left; margin-top: 20px; display: grid; gap: 8px; }
.login-card label { font-size: 13px; font-weight: 600; color: var(--text-2); }
.login-card input[type=password] {
  padding: 11px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--bg);
  margin-bottom: 8px;
}
.error { color: var(--danger); font-size: 14px; margin: 0 0 4px; }

/* =====================================================================
   App shell
   ===================================================================== */
.top {
  position: sticky; top: 0; z-index: 10;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.top-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 20px; max-width: 1180px; margin: 0 auto;
}
.daynav { display: flex; align-items: center; gap: 6px; }
.daynav .day { width: 160px; text-align: center; font-weight: 600; font-family: var(--font-display); }
.daynav .day small { display: block; font-weight: 400; color: var(--muted); font-size: 12px; line-height: 1.2; font-family: var(--font); }
.top form { margin: 0; }
.account-btn { border-radius: 999px; color: var(--text-2); }
.back-btn { display: inline-flex; align-items: center; gap: 4px; padding: 6px 12px 6px 8px; }
.page-title { margin: 0; font-size: 17px; font-weight: 650; font-family: var(--font-display); }

/* "Back to today" sits just under the header line */
.today-bar { display: flex; justify-content: flex-start; margin-bottom: -4px; }
.today-bar[hidden] { display: none; }
.today-btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 7px 16px; border-radius: 999px;
  background: var(--surface); color: var(--text-2);
  border: 1px solid var(--line); box-shadow: var(--card-shadow);
  font-size: 13px; font-weight: 600;
}
.today-btn:hover { color: var(--text); border-color: var(--accent); }

main.app { max-width: 1180px; margin: 0 auto; padding: 20px; display: grid; gap: 16px; }
main.app.narrow { max-width: 760px; }
.grid { display: grid; gap: 16px; }
.grid.three { grid-template-columns: 1.15fr 1fr 1fr; }
.grid.two { grid-template-columns: 1fr 1fr; }
@media (max-width: 960px) { .grid.three, .grid.two { grid-template-columns: 1fr; } }
@media (max-width: 560px) {
  .top-row { padding: 10px 12px; gap: 8px; }
  .top .brand span { display: none; }
  .daynav { gap: 4px; }
  .daynav .day { width: 118px; }
  .back-btn span { display: none; }
  main.app { padding: 12px; gap: 12px; }
}

.card {
  position: relative;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 20px; min-width: 0; box-shadow: var(--card-shadow);
}
.card h2 {
  margin: 0 0 12px; font-size: 13px; font-weight: 600; color: var(--text-2);
  display: flex; align-items: baseline; gap: 8px;
  text-transform: var(--label-case); letter-spacing: var(--label-spacing);
}
.card h2 .sub { margin-left: auto; font-weight: 400; color: var(--muted); text-transform: none; letter-spacing: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.card-head h2 { margin: 0; }
.chips { display: flex; gap: 4px; }
.chips .chip { padding: 3px 10px; font-size: 12px; }
.card-intro { margin: -4px 0 16px; color: var(--muted); font-size: 14px; }

/* ---------- Notes ---------- */
.notes { display: grid; gap: 8px; }
.notes:empty { display: none; }
.note {
  background: var(--note-bg); border: 1px solid var(--note-line); border-radius: var(--radius-sm);
  padding: 10px 14px; font-size: 14px; color: var(--text);
}
.note b { font-weight: 600; }

/* ---------- Calories hero ---------- */
.hero-value { font-family: var(--font-display); font-size: 44px; font-weight: var(--display-weight); letter-spacing: -0.02em; line-height: 1; }
.hero-value .unit { font-family: var(--font); font-size: 16px; font-weight: 500; color: var(--muted); margin-left: 4px; letter-spacing: 0; }
.hero-sub { margin-top: 6px; color: var(--text-2); }
.meter { height: 10px; border-radius: 999px; background: color-mix(in srgb, var(--s1) 22%, var(--surface)); overflow: hidden; margin-top: 16px; }
.meter > span { display: block; height: 100%; border-radius: 999px; background: var(--s1); }
.meter.carbs { background: color-mix(in srgb, var(--s2) 22%, var(--surface)); } .meter.carbs > span { background: var(--s2); }
.meter.fat { background: color-mix(in srgb, var(--s3) 22%, var(--surface)); } .meter.fat > span { background: var(--s3); }
.meter.thin { height: 8px; margin-top: 6px; }
.kv { display: flex; justify-content: space-between; gap: 8px; margin-top: 12px; font-size: 13px; color: var(--muted); }
.kv b { color: var(--text); font-weight: 600; }

.macro { margin-bottom: 14px; }
.macro:last-child { margin-bottom: 0; }
.macro-row { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.macro-name { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.swatch { width: 10px; height: 10px; border-radius: 3px; display: inline-block; flex: none; }
.swatch.protein { background: var(--s1); } .swatch.carbs { background: var(--s2); } .swatch.fat { background: var(--s3); }
.macro-val { color: var(--text-2); font-size: 14px; }
.macro-val b { color: var(--text); }

.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px; }
.stat .label { font-size: 12px; color: var(--muted); }
.stat .value { font-family: var(--font-display); font-size: 22px; font-weight: var(--display-weight); letter-spacing: -0.01em; }
.stat .value small { font-family: var(--font); font-size: 13px; font-weight: 500; color: var(--muted); }
.stat.big { grid-column: 1 / -1; }
.stat.big .value { font-size: 36px; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 8px 6px; text-align: left; border-bottom: 1px solid var(--grid); vertical-align: top; }
th { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: var(--label-case); letter-spacing: var(--label-spacing); }
td.r, th.r { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tr.group td { padding-top: 14px; font-weight: 650; border-bottom: 1px solid var(--line); }
tr.group td.r { color: var(--text-2); font-weight: 600; }
tr:last-child td { border-bottom: 0; }
.item-note { display: block; font-size: 12px; color: var(--muted); margin-top: 2px; }
.time { color: var(--muted); font-size: 12px; margin-left: 6px; font-weight: 400; }
tr.sel td { background: var(--surface-2); }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--surface-2); }
.empty { color: var(--muted); padding: 18px 0; text-align: center; }

/* ---------- Charts ---------- */
.chart { position: relative; width: 100%; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart text { fill: var(--muted); font-size: 11px; font-family: var(--font); }
.chart text.val { fill: var(--text); font-weight: 600; }
.chart .gridline { stroke: var(--grid); stroke-width: 1; }
.chart .axis { stroke: var(--line); stroke-width: 1; }
.chart .ref { stroke: var(--text-2); stroke-width: 1; opacity: .7; }
.chart .bar { fill: var(--s1); }
.chart .bar.dim { opacity: .45; }
.chart .avg-line { fill: none; stroke: var(--s1); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .avg-area { fill: var(--s1); opacity: .1; }
.chart .raw { fill: var(--raw); stroke: var(--surface); stroke-width: 2; }
.chart .end-dot { fill: var(--s1); stroke: var(--surface); stroke-width: 2; }
.chart .cross { stroke: var(--text-2); stroke-width: 1; opacity: .5; }
.chart .hit { fill: transparent; }
.tip {
  position: absolute; pointer-events: none; z-index: 5; background: var(--text); color: var(--surface);
  border-radius: 8px; padding: 6px 9px; font-size: 12px; line-height: 1.35; white-space: nowrap;
  transform: translate(-50%, calc(-100% - 10px));
}
.tip b { font-weight: 600; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 12px; color: var(--text-2); margin-top: 8px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.key-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--raw); }
.key-line { width: 16px; height: 2px; border-radius: 2px; background: var(--s1); }
.chart-foot { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; margin-top: 10px; font-size: 13px; color: var(--muted); }
.chart-foot b { color: var(--text); }

/* ---------- Targets markdown ---------- */
.md { font-size: 14px; color: var(--text-2); }
.md h1, .md h2, .md h3, .md h4 { color: var(--text); font-size: 14px; margin: 14px 0 6px; display: block; text-transform: none; letter-spacing: 0; }
.md h1:first-child, .md h2:first-child, .md h3:first-child { margin-top: 0; }
.md p { margin: 6px 0; }
.md ul { margin: 6px 0; padding-left: 18px; }
.md li { margin: 2px 0; }
.md strong { color: var(--text); }
.md table { margin: 8px 0; }

footer.foot { text-align: center; font-size: 12px; color: var(--muted); padding: 8px 0 28px; }

/* =====================================================================
   Account page
   ===================================================================== */
.theme-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
@media (max-width: 560px) { .theme-grid { grid-template-columns: 1fr 1fr; gap: 10px; } }
.theme-option {
  display: flex; flex-direction: column; text-align: left; padding: 0; overflow: hidden;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm);
  color: var(--text);
}
.theme-option:hover { border-color: var(--text-2); }
.theme-option[aria-checked="true"] { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.theme-text { display: block; padding: 10px 12px 12px; }
.theme-name { display: flex; align-items: center; justify-content: space-between; font-weight: 650; }
.theme-name .check { color: var(--accent); visibility: hidden; flex: none; }
.theme-name .check path { stroke: var(--on-accent); }
.theme-option[aria-checked="true"] .check { visibility: visible; }
.theme-desc { display: block; font-size: 12px; color: var(--muted); margin-top: 3px; line-height: 1.35; }

/* Each preview re-resolves the variables of its own data-theme. */
.theme-preview {
  display: grid; grid-template-columns: 1.3fr 1fr; gap: 6px; padding: 10px; height: 96px;
  background: var(--bg-fill); background-attachment: scroll; font-family: var(--font);
  border-bottom: 1px solid var(--line);
}
.tp-card {
  display: flex; flex-direction: column; justify-content: center; gap: 4px; padding: 8px;
  background: var(--surface); border: 1px solid var(--line); border-radius: min(var(--radius), 10px);
  box-shadow: var(--card-shadow); min-width: 0;
}
.tp-label { white-space: nowrap; overflow: hidden; font-size: 9px; color: var(--muted); text-transform: var(--label-case); letter-spacing: var(--label-spacing); }
.tp-num { font-family: var(--font-display); font-weight: var(--display-weight); font-size: 20px; line-height: 1; color: var(--text); }
.tp-meter { display: block; height: 5px; border-radius: 9px; background: color-mix(in srgb, var(--s1) 22%, var(--surface)); }
.tp-meter i { display: block; width: 62%; height: 100%; border-radius: 9px; background: var(--s1); }
.tp-macros { gap: 7px; }
.tp-bar { display: block; height: 5px; border-radius: 9px; }
.tp-bar i { display: block; height: 100%; border-radius: 9px; }
.tp-bar.b1 { background: color-mix(in srgb, var(--s1) 22%, var(--surface)); } .tp-bar.b1 i { width: 70%; background: var(--s1); }
.tp-bar.b2 { background: color-mix(in srgb, var(--s2) 22%, var(--surface)); } .tp-bar.b2 i { width: 45%; background: var(--s2); }
.tp-bar.b3 { background: color-mix(in srgb, var(--s3) 22%, var(--surface)); } .tp-bar.b3 i { width: 80%; background: var(--s3); }

.setting-row {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 12px 0; border-top: 1px solid var(--grid);
}
.card h2 + .setting-row { border-top: 0; padding-top: 0; }
.setting-row form { margin: 0; flex: none; }
.setting-name { font-weight: 600; }
.setting-desc { font-size: 13px; color: var(--muted); margin-top: 2px; }

/* =====================================================================
   Theme flourishes
   ===================================================================== */

/* Marathon: hard edges, technical labels, corner ticks */
[data-theme="marathon"] .card h2::before,
.theme-preview[data-theme="marathon"] .tp-label::before { content: "// "; color: var(--accent); }
[data-theme="marathon"] .card::before {
  content: ""; position: absolute; top: -1px; left: -1px; width: 18px; height: 2px; background: var(--accent);
}
[data-theme="marathon"] .card::after {
  content: ""; position: absolute; bottom: -1px; right: -1px; width: 2px; height: 18px; background: var(--accent);
}
[data-theme="marathon"] .brand { text-transform: uppercase; letter-spacing: .18em; font-size: 16px; }
[data-theme="marathon"] .daynav .day { text-transform: uppercase; letter-spacing: .08em; font-size: 14px; }
[data-theme="marathon"] .hero-value { letter-spacing: -0.04em; }
[data-theme="marathon"] .meter, [data-theme="marathon"] .meter > span,
.theme-preview[data-theme="marathon"] :is(.tp-meter, .tp-meter i, .tp-bar, .tp-bar i) { border-radius: 0; }
[data-theme="marathon"] .today-btn, [data-theme="marathon"] .account-btn { border-radius: 2px; }
[data-theme="marathon"] .today-btn { text-transform: uppercase; letter-spacing: .1em; font-size: 12px; }
[data-theme="marathon"] .tip { background: var(--accent); color: var(--on-accent); border-radius: 0; }
[data-theme="marathon"] .chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }

/* Wizarding: crimson header with a gold rule, small caps, framed cards */
[data-theme="wizarding"] .top {
  --text: #f6ecd4; --text-2: #f0dcb0; --muted: #e1c27e; --line: #b0413c; --surface-2: #9a2424; --accent: #e8c25a;
  background: linear-gradient(180deg, #8e1b1b, #741414); border-bottom: 2px solid #c9a227; color: var(--text);
}
[data-theme="wizarding"] .card h2 { font-variant: small-caps; font-size: 15px; color: var(--text); }
[data-theme="wizarding"] .card h2 .sub { font-variant: normal; font-size: 12px; font-style: italic; }
[data-theme="wizarding"] .hero-value { letter-spacing: 0; }
[data-theme="wizarding"] .tip { background: #2b1d0e; color: #f6ecd4; }
[data-theme="wizarding"] .chip[aria-pressed="true"] { background: #8e1b1b; border-color: #8e1b1b; color: #f6ecd4; }

/* Classic: double rule under the masthead, serif headings */
[data-theme="classic"] .top { border-bottom: 3px double var(--text); background: color-mix(in srgb, var(--surface) 92%, transparent); }
[data-theme="classic"] .brand { font-size: 22px; letter-spacing: 0; }
[data-theme="classic"] .card h2 { font-size: 11px; }
[data-theme="classic"] .card h2 .sub { font-family: var(--font-display); font-style: italic; font-size: 13px; }

/* Ember: warm glow on the hero number */
[data-theme="ember"] .hero-value { text-shadow: 0 0 28px rgba(255,122,26,.25); }
[data-theme="ember"] .card { background: linear-gradient(180deg, rgba(255,122,26,.045), transparent 45%), var(--surface); }

/* Synthwave: neon glow */
[data-theme="synthwave"] .hero-value, .theme-preview[data-theme="synthwave"] .tp-num { text-shadow: 0 0 18px rgba(255,79,163,.55); }
[data-theme="synthwave"] .brand { font-style: italic; letter-spacing: .02em; }
[data-theme="synthwave"] .top { border-bottom: 1px solid rgba(255,79,163,.35); box-shadow: 0 1px 18px rgba(255,79,163,.12); }
[data-theme="synthwave"] .card { background: color-mix(in srgb, var(--surface) 88%, transparent); backdrop-filter: blur(6px); }
[data-theme="synthwave"] .chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }

/* Matcha: soft and round */
[data-theme="matcha"] .card { border-color: transparent; }
[data-theme="matcha"] .today-btn { border-color: transparent; }
