/* ===========================================================================
   M & N Fitness — stylesheet
   Light and dark themes. The accent colour follows whichever profile is
   active (M = indigo, N = teal) so it is always obvious whose data is on
   screen without having to read the switcher.
   ======================================================================== */

*, *::before, *::after { box-sizing: border-box; }

:root {
  --m-color: #6366f1;
  --m-color-soft: #6366f11f;
  --n-color: #0d9488;
  --n-color-soft: #0d94881f;

  --accent: var(--m-color);
  --accent-soft: var(--m-color-soft);

  --good: #16a34a;
  --bad: #dc2626;
  --warn: #d97706;

  --bronze: #a97142;
  --silver: #8a93a3;
  --gold: #c99a06;
  --legendary: #a855f7;

  --radius: 14px;
  --radius-sm: 9px;
  --radius-lg: 20px;

  --shadow-sm: 0 1px 2px rgba(16, 18, 24, .06), 0 1px 3px rgba(16, 18, 24, .05);
  --shadow: 0 2px 6px rgba(16, 18, 24, .07), 0 8px 24px rgba(16, 18, 24, .07);
  --shadow-lg: 0 12px 48px rgba(16, 18, 24, .18);

  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;

  /* light */
  --bg: #f4f5f9;
  --bg-2: #eceef4;
  --surface: #ffffff;
  --surface-2: #f8f9fc;
  --border: #e2e5ee;
  --border-strong: #cdd2e0;
  --text: #171a21;
  --text-2: #5a6172;
  --text-3: #8b93a5;
  --grid-line: #e8eaf1;
}

:root[data-theme="dark"] {
  --bg: #0c0e13;
  --bg-2: #11141b;
  --surface: #171b23;
  --surface-2: #1d222c;
  --border: #272d3a;
  --border-strong: #39414f;
  --text: #e9ecf3;
  --text-2: #a2abbd;
  --text-3: #6d7688;
  --grid-line: #232935;
  --m-color: #818cf8;
  --m-color-soft: #818cf826;
  --n-color: #2dd4bf;
  --n-color-soft: #2dd4bf26;
  --good: #4ade80;
  --bad: #f87171;
  --warn: #fbbf24;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow: 0 2px 8px rgba(0, 0, 0, .35), 0 12px 32px rgba(0, 0, 0, .35);
  --shadow-lg: 0 16px 60px rgba(0, 0, 0, .6);
}

/* Follow the OS unless something has explicitly asked for light. `:not(...)`
   rather than `[data-theme="auto"]` so this still applies when the attribute
   is absent or set by a host page, while an explicit light choice always wins
   over a dark OS. The `[data-theme="dark"]` block above is the mirror case. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0c0e13;
    --bg-2: #11141b;
    --surface: #171b23;
    --surface-2: #1d222c;
    --border: #272d3a;
    --border-strong: #39414f;
    --text: #e9ecf3;
    --text-2: #a2abbd;
    --text-3: #6d7688;
    --grid-line: #232935;
    --m-color: #818cf8;
    --m-color-soft: #818cf826;
    --n-color: #2dd4bf;
    --n-color-soft: #2dd4bf26;
    --good: #4ade80;
    --bad: #f87171;
    --warn: #fbbf24;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow: 0 2px 8px rgba(0, 0, 0, .35), 0 12px 32px rgba(0, 0, 0, .35);
    --shadow-lg: 0 16px 60px rgba(0, 0, 0, .6);
  }
}

body[data-active="N"] { --accent: var(--n-color); --accent-soft: var(--n-color-soft); }
body[data-active="M"] { --accent: var(--m-color); --accent-soft: var(--m-color-soft); }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  padding-bottom: 96px;
}

h1, h2, h3, h4 { margin: 0; line-height: 1.25; font-weight: 650; letter-spacing: -.01em; }
p { margin: 0 0 .7em; }
button { font: inherit; color: inherit; cursor: pointer; }
a { color: var(--accent); }

/* ------------------------------------------------------------------ topbar */

.topbar {
  position: sticky; top: 0; z-index: 40;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  max-width: 1180px; margin: 0 auto;
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px;
}
.brand { display: flex; align-items: center; gap: 9px; font-weight: 700; font-size: 16px; letter-spacing: -.02em; }
.brand-mark { font-size: 20px; }
.brand-light { color: var(--text-3); font-weight: 550; }
.brand-text { white-space: nowrap; }

.profile-switch {
  margin-left: auto;
  display: flex; gap: 3px; padding: 3px;
  background: var(--bg-2); border: 1px solid var(--border);
  border-radius: 999px;
}
.pswitch {
  border: 0; background: transparent; color: var(--text-2);
  padding: 5px 16px; border-radius: 999px;
  font-weight: 700; font-size: 13px; letter-spacing: .02em;
  transition: background .15s, color .15s;
}
.pswitch:hover { color: var(--text); }
.pswitch[data-profile="M"].is-on { background: var(--m-color); color: #fff; }
.pswitch[data-profile="N"].is-on { background: var(--n-color); color: #fff; }

.sync-pill {
  display: flex; align-items: center; gap: 6px;
  border: 1px solid var(--border); background: var(--surface);
  color: var(--text-2); padding: 5px 11px; border-radius: 999px;
  font-size: 12px; font-weight: 620; white-space: nowrap;
  transition: background .15s, border-color .15s, color .15s;
}
.sync-pill:hover { background: var(--surface-2); border-color: var(--border-strong); }
.sync-pill[data-tone="good"] { color: var(--good); border-color: color-mix(in srgb, var(--good) 32%, var(--border)); }
.sync-pill[data-tone="bad"]  { color: var(--bad);  border-color: color-mix(in srgb, var(--bad) 38%, var(--border)); }
.sync-pill[data-tone="warn"] { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 38%, var(--border)); }
.sync-pill .sync-ico { font-size: 12px; line-height: 1; }
.sync-pill:empty { display: none; }

.icon-btn {
  border: 1px solid var(--border); background: var(--surface);
  color: var(--text-2); width: 34px; height: 34px;
  border-radius: 10px; display: grid; place-items: center;
  font-size: 15px; transition: background .15s, color .15s, border-color .15s;
  flex-shrink: 0;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); border-color: var(--border-strong); }

/* -------------------------------------------------------------------- tabs */

.tabs {
  position: sticky; top: 55px; z-index: 35;
  display: flex; gap: 2px;
  padding: 8px 16px;
  max-width: 1180px; margin: 0 auto;
  overflow-x: auto; scrollbar-width: none;
  background: color-mix(in srgb, var(--bg) 90%, transparent);
  backdrop-filter: blur(10px);
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  border: 0; background: transparent; color: var(--text-2);
  padding: 7px 13px; border-radius: 10px;
  font-size: 13.5px; font-weight: 600; white-space: nowrap;
  display: flex; align-items: center; gap: 6px;
  transition: background .15s, color .15s;
}
.tab:hover { background: var(--bg-2); color: var(--text); }
.tab.is-on { background: var(--accent); color: #fff; }
.tab-ico { font-size: 14px; }

/* -------------------------------------------------------------------- view */

.view { max-width: 1180px; margin: 0 auto; padding: 6px 16px 40px; }

.section-head {
  display: flex; align-items: baseline; gap: 10px;
  margin: 26px 0 12px; flex-wrap: wrap;
}
.section-head:first-child { margin-top: 12px; }
.section-head h2 { font-size: 17px; }
.section-head .sub { color: var(--text-3); font-size: 13px; }
.section-head .spacer { flex: 1; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow-sm);
}
.card.pad-lg { padding: 20px; }
.card-title { font-size: 13px; font-weight: 650; color: var(--text-2); margin-bottom: 10px; }

.grid { display: grid; gap: 12px; }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-auto { grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }
.grid-auto-lg { grid-template-columns: repeat(auto-fill, minmax(310px, 1fr)); }

/* -------------------------------------------------------------- stat tiles */

.stat {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 15px;
  box-shadow: var(--shadow-sm);
  display: flex; flex-direction: column; gap: 2px;
  min-width: 0;
}
.stat-label {
  font-size: 11.5px; font-weight: 650; letter-spacing: .04em;
  text-transform: uppercase; color: var(--text-3);
}
.stat-value {
  font-size: 25px; font-weight: 700; letter-spacing: -.025em;
  font-variant-numeric: tabular-nums; line-height: 1.15;
}
.stat-value.sm { font-size: 20px; }
.stat-note { font-size: 12.5px; color: var(--text-2); }
.stat-note.good { color: var(--good); font-weight: 600; }
.stat-note.bad  { color: var(--bad); font-weight: 600; }

/* ------------------------------------------------------------- hero / level */

.hero {
  background: linear-gradient(145deg,
              color-mix(in srgb, var(--accent) 92%, #000 8%),
              color-mix(in srgb, var(--accent) 62%, #7c3aed 38%));
  border-radius: var(--radius-lg);
  padding: 20px 22px;
  color: #fff;
  box-shadow: var(--shadow);
  position: relative; overflow: hidden;
}
.hero::after {
  content: ""; position: absolute; right: -50px; top: -70px;
  width: 220px; height: 220px; border-radius: 50%;
  background: rgba(255, 255, 255, .10);
}
.hero-top { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; position: relative; }
.hero-level {
  font-size: 11px; font-weight: 750; letter-spacing: .09em; text-transform: uppercase;
  background: rgba(255, 255, 255, .2); padding: 4px 11px; border-radius: 999px;
  backdrop-filter: blur(4px);
}
.hero-name { font-size: 22px; font-weight: 700; letter-spacing: -.02em; }
.hero-xp { margin-left: auto; font-size: 13px; opacity: .9; font-variant-numeric: tabular-nums; }
.hero-bar {
  position: relative; margin-top: 14px;
  height: 8px; border-radius: 999px; background: rgba(255, 255, 255, .25); overflow: hidden;
}
.hero-bar > i { display: block; height: 100%; background: #fff; border-radius: 999px; transition: width .5s cubic-bezier(.2,.8,.2,1); }
.hero-next { margin-top: 7px; font-size: 12.5px; opacity: .88; position: relative; }

.hero-chips { display: flex; gap: 8px; margin-top: 15px; flex-wrap: wrap; position: relative; }
.hero-chip {
  background: rgba(255, 255, 255, .18); backdrop-filter: blur(4px);
  padding: 6px 12px; border-radius: 10px; font-size: 12.5px; font-weight: 600;
  display: flex; align-items: center; gap: 6px;
}

/* ------------------------------------------------------------------- chart */

.chart-wrap { position: relative; width: 100%; overflow-x: auto; }
.chart { width: 100%; height: auto; display: block; touch-action: pan-y; }
.chart .grid-l { stroke: var(--grid-line); stroke-width: 1; }
.chart .axis-t { fill: var(--text-3); font-size: 10.5px; font-family: var(--sans); }
.chart .goal-l { stroke: var(--warn); stroke-width: 1.5; stroke-dasharray: 5 4; opacity: .85; }
.chart .goal-t { fill: var(--warn); font-size: 10.5px; font-weight: 650; }
.chart .trend-l { fill: none; stroke-width: 2; stroke-dasharray: 4 3; opacity: .55; }
.chart .series-l { fill: none; stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.chart .series-a { opacity: .12; }
.chart .dot { stroke: var(--surface); stroke-width: 2; }
.chart .hit { fill: transparent; cursor: pointer; }

.chart-legend { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 10px; font-size: 12.5px; color: var(--text-2); }
.legend-item { display: flex; align-items: center; gap: 6px; }
.legend-swatch { width: 11px; height: 11px; border-radius: 3px; }
.legend-swatch.dash { height: 0; border-top: 2px dashed currentColor; border-radius: 0; width: 14px; }

.range-btns { display: flex; gap: 3px; padding: 3px; background: var(--bg-2); border: 1px solid var(--border); border-radius: 10px; }
.range-btn {
  border: 0; background: transparent; color: var(--text-2);
  padding: 4px 11px; border-radius: 7px; font-size: 12.5px; font-weight: 620;
}
.range-btn.is-on { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }

.chart-empty {
  display: grid; place-items: center; text-align: center;
  padding: 40px 20px; color: var(--text-3); gap: 6px;
}
.chart-empty .big { font-size: 30px; }

/* ------------------------------------------------------------------ tooltip */

.chart-tip {
  position: absolute; pointer-events: none; z-index: 5;
  background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); padding: 7px 10px;
  box-shadow: var(--shadow); font-size: 12.5px; white-space: nowrap;
  transform: translate(-50%, -120%); opacity: 0; transition: opacity .12s;
}
.chart-tip.on { opacity: 1; }
.chart-tip b { font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------------------ buttons */

.btn {
  border: 1px solid var(--border-strong); background: var(--surface);
  color: var(--text); padding: 8px 15px; border-radius: 10px;
  font-size: 13.5px; font-weight: 620;
  display: inline-flex; align-items: center; gap: 7px;
  transition: background .15s, border-color .15s, transform .06s;
}
.btn:hover { background: var(--surface-2); border-color: var(--text-3); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); border-color: transparent; color: #fff; }
.btn-primary:hover { background: color-mix(in srgb, var(--accent) 86%, #000); border-color: transparent; }
.btn-ghost { border-color: transparent; background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--bg-2); color: var(--text); }
.btn-danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 35%, var(--border)); }
.btn-danger:hover { background: color-mix(in srgb, var(--bad) 10%, var(--surface)); }
.btn-sm { padding: 5px 11px; font-size: 12.5px; border-radius: 8px; }
.btn-block { width: 100%; justify-content: center; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

/* ------------------------------------------------------------------- forms */

.field { margin-bottom: 14px; }
.field label {
  display: block; font-size: 12.5px; font-weight: 650;
  color: var(--text-2); margin-bottom: 5px;
}
.field .hint { font-size: 12px; color: var(--text-3); margin-top: 5px; font-weight: 500; }
input[type="text"], input[type="number"], input[type="date"], select, textarea {
  width: 100%; padding: 9px 11px;
  border: 1px solid var(--border-strong); border-radius: 10px;
  background: var(--surface); color: var(--text);
  font: inherit; font-size: 14px;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
textarea { resize: vertical; min-height: 62px; }
.field-row { display: flex; gap: 10px; }
.field-row > * { flex: 1; min-width: 0; }

.seg { display: flex; gap: 3px; padding: 3px; background: var(--bg-2); border: 1px solid var(--border); border-radius: 10px; }
.seg button {
  flex: 1; border: 0; background: transparent; color: var(--text-2);
  padding: 7px 10px; border-radius: 7px; font-size: 13px; font-weight: 620;
}
.seg button.is-on { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }

/* ------------------------------------------------------------------ chips */

.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  border: 1px solid var(--border); background: var(--surface);
  color: var(--text-2); padding: 4px 11px; border-radius: 999px;
  font-size: 12.5px; font-weight: 600;
  transition: background .15s, color .15s, border-color .15s;
}
.chip:hover { border-color: var(--border-strong); color: var(--text); }
.chip.is-on { background: var(--accent); border-color: transparent; color: #fff; }
.tag {
  display: inline-block; padding: 2px 8px; border-radius: 6px;
  background: var(--bg-2); color: var(--text-2);
  font-size: 11.5px; font-weight: 600; white-space: nowrap;
}
.tag.accent { background: var(--accent-soft); color: var(--accent); }

/* ------------------------------------------------------------------- lists */

.list { display: flex; flex-direction: column; }
.row {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 2px; border-bottom: 1px solid var(--border);
}
.row:last-child { border-bottom: 0; }
.row-main { flex: 1; min-width: 0; }
.row-title { font-weight: 620; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-sub { font-size: 12.5px; color: var(--text-3); }
.row-val { font-variant-numeric: tabular-nums; font-weight: 700; font-size: 15px; }
.row-actions { display: flex; gap: 4px; opacity: .35; transition: opacity .15s; }
.row:hover .row-actions { opacity: 1; }
@media (hover: none) { .row-actions { opacity: 1; } }

.empty {
  text-align: center; padding: 34px 20px; color: var(--text-3);
  border: 1px dashed var(--border-strong); border-radius: var(--radius);
}
.empty .big { font-size: 28px; display: block; margin-bottom: 6px; }

/* ----------------------------------------------------------- recipe cards */

.rcard {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
  box-shadow: var(--shadow-sm); display: flex; flex-direction: column;
  transition: transform .15s, box-shadow .15s, border-color .15s;
}
.rcard:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--border-strong); }
.rcard-head { padding: 14px 15px 10px; }
.rcard-meal { font-size: 11px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--accent); }
.rcard-name { font-size: 15.5px; font-weight: 650; margin-top: 3px; letter-spacing: -.01em; }
.rcard-macros {
  display: flex; gap: 0; border-top: 1px solid var(--border);
  background: var(--surface-2); margin-top: auto;
}
.macro { flex: 1; padding: 9px 4px; text-align: center; border-right: 1px solid var(--border); }
.macro:last-child { border-right: 0; }
.macro-v { font-size: 14px; font-weight: 700; font-variant-numeric: tabular-nums; }
.macro-l { font-size: 10px; color: var(--text-3); text-transform: uppercase; letter-spacing: .05em; font-weight: 650; }
.rcard-tags { padding: 0 15px 13px; display: flex; gap: 5px; flex-wrap: wrap; }

/* ---------------------------------------------------------- workout cards */

.wcard {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px;
  box-shadow: var(--shadow-sm); display: flex; flex-direction: column; gap: 9px;
  transition: transform .15s, box-shadow .15s, border-color .15s;
}
.wcard:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--border-strong); }
.wcard-top { display: flex; align-items: flex-start; gap: 10px; }
.wcard-name { font-size: 15.5px; font-weight: 650; flex: 1; letter-spacing: -.01em; }
.wcard-sum { font-size: 13px; color: var(--text-2); }
.wcard-foot { display: flex; gap: 8px; align-items: center; margin-top: auto; padding-top: 4px; }

.block { border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; margin-bottom: 12px; }
.block-head {
  background: var(--surface-2); padding: 9px 13px;
  display: flex; align-items: baseline; gap: 9px;
  border-bottom: 1px solid var(--border);
}
.block-name { font-weight: 680; font-size: 13.5px; }
.block-note { font-size: 12px; color: var(--text-3); margin-left: auto; }
.ex { padding: 10px 13px; border-bottom: 1px solid var(--border); }
.ex:last-child { border-bottom: 0; }
.ex-top { display: flex; gap: 10px; align-items: baseline; }
.ex-name { font-weight: 600; font-size: 13.5px; flex: 1; }
.ex-scheme {
  font-variant-numeric: tabular-nums; font-size: 12.5px; font-weight: 650;
  color: var(--accent); white-space: nowrap;
}
.ex-rest { font-size: 11.5px; color: var(--text-3); white-space: nowrap; }
.ex-cue { font-size: 12.5px; color: var(--text-2); margin-top: 3px; font-style: italic; }

/* ------------------------------------------------------------------ badges */

.badge-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 10px; }
.badge {
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); padding: 14px 8px; text-align: center;
  box-shadow: var(--shadow-sm); transition: transform .15s;
}
.badge.earned { border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); background: var(--accent-soft); }
.badge.locked { opacity: .42; filter: grayscale(1); }
.badge:hover { transform: translateY(-2px); }
.badge-ico { font-size: 26px; line-height: 1.1; }
.badge-name { font-size: 12px; font-weight: 680; margin-top: 5px; }
.badge-desc { font-size: 11px; color: var(--text-3); margin-top: 2px; line-height: 1.35; }

/* ------------------------------------------------------------------ treats */

.treat {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 15px;
  box-shadow: var(--shadow-sm); display: flex; flex-direction: column; gap: 9px;
  position: relative; overflow: hidden;
}
.treat::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px;
  background: var(--tier-c, var(--border-strong));
}
.treat[data-tier="bronze"]    { --tier-c: var(--bronze); }
.treat[data-tier="silver"]    { --tier-c: var(--silver); }
.treat[data-tier="gold"]      { --tier-c: var(--gold); }
.treat[data-tier="legendary"] { --tier-c: var(--legendary); }

.treat.is-locked { opacity: .82; }
.treat.is-unlocked { border-color: color-mix(in srgb, var(--good) 40%, var(--border)); }
.treat.is-claimed { opacity: .6; }
.treat.is-claimed .treat-title { text-decoration: line-through; text-decoration-color: var(--text-3); }

.treat-top { display: flex; gap: 11px; align-items: flex-start; }
.treat-ico { font-size: 24px; line-height: 1; }
.treat-title { font-weight: 650; font-size: 14.5px; letter-spacing: -.01em; }
.treat-tier {
  font-size: 10px; font-weight: 750; letter-spacing: .08em; text-transform: uppercase;
  color: var(--tier-c);
}
.treat-reward {
  font-size: 13px; color: var(--text-2);
  background: var(--surface-2); border-radius: var(--radius-sm);
  padding: 9px 11px; border: 1px solid var(--border);
}
.treat-foot { display: flex; align-items: center; gap: 10px; margin-top: auto; }
.treat-prog { flex: 1; min-width: 0; }
.prog-bar { height: 6px; border-radius: 999px; background: var(--bg-2); overflow: hidden; }
.prog-bar > i { display: block; height: 100%; border-radius: 999px; background: var(--accent); transition: width .5s cubic-bezier(.2,.8,.2,1); }
.treat.is-unlocked .prog-bar > i { background: var(--good); }
.prog-txt { font-size: 11.5px; color: var(--text-3); margin-top: 4px; font-variant-numeric: tabular-nums; font-weight: 600; }
.ribbon {
  font-size: 10.5px; font-weight: 750; letter-spacing: .06em; text-transform: uppercase;
  padding: 3px 9px; border-radius: 999px; white-space: nowrap;
}
.ribbon.unlocked { background: color-mix(in srgb, var(--good) 16%, transparent); color: var(--good); }
.ribbon.claimed  { background: var(--bg-2); color: var(--text-3); }

/* ------------------------------------------------------------------- modal */

.modal-backdrop {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(8, 10, 15, .55); backdrop-filter: blur(3px);
  display: grid; place-items: center; padding: 16px;
  animation: fade .16s ease;
}
.modal-backdrop[hidden] { display: none; }
.modal {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  width: min(660px, 100%); max-height: min(86vh, 900px);
  display: flex; flex-direction: column;
  animation: pop .18s cubic-bezier(.2, .9, .3, 1.1);
}
.modal-head {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 18px; border-bottom: 1px solid var(--border);
}
.modal-head h2 { font-size: 16.5px; flex: 1; }
.modal-body { padding: 18px; overflow-y: auto; }
.modal-actions { display: flex; gap: 9px; margin-top: 18px; }
.modal-actions .spacer { flex: 1; }

@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(14px) scale(.97); } }

/* --------------------------------------------------------------------- fab */

.fab-wrap {
  position: fixed; right: 18px; bottom: 20px; z-index: 50;
  display: flex; flex-direction: column-reverse; gap: 10px; align-items: center;
}
.fab {
  width: 54px; height: 54px; border-radius: 50%;
  border: 0; background: var(--accent); color: #fff;
  font-size: 24px; font-weight: 400; line-height: 1;
  box-shadow: 0 6px 22px color-mix(in srgb, var(--accent) 45%, transparent);
  display: grid; place-items: center;
  transition: transform .15s, box-shadow .15s;
}
.fab:hover { transform: scale(1.06); }
.fab:active { transform: scale(.96); }
.fab-secondary {
  width: 44px; height: 44px; font-size: 18px;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border-strong); box-shadow: var(--shadow);
}

/* ------------------------------------------------------------------ toasts */

.toast-stack {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  z-index: 200; display: flex; flex-direction: column; gap: 8px;
  align-items: center; pointer-events: none; width: min(440px, calc(100% - 32px));
}
.toast {
  background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: 12px; padding: 11px 15px; box-shadow: var(--shadow-lg);
  font-size: 13.5px; font-weight: 600;
  display: flex; align-items: center; gap: 10px; width: 100%;
  animation: toastIn .25s cubic-bezier(.2, .9, .3, 1.1);
}
.toast.win { border-color: color-mix(in srgb, var(--good) 55%, var(--border)); }
.toast-ico { font-size: 19px; }
.toast-sub { font-size: 12px; color: var(--text-3); font-weight: 500; }
@keyframes toastIn { from { opacity: 0; transform: translateY(14px); } }

/* ------------------------------------------------------------- comparison */

.vs-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.vs-row:last-child { border-bottom: 0; }
.vs-label { flex: 0 0 128px; font-size: 12.5px; color: var(--text-2); font-weight: 600; }
.vs-bar { flex: 1; display: flex; align-items: center; gap: 8px; }
.vs-track { flex: 1; height: 8px; background: var(--bg-2); border-radius: 999px; overflow: hidden; }
.vs-track > i { display: block; height: 100%; border-radius: 999px; transition: width .5s cubic-bezier(.2,.8,.2,1); }
.vs-num { font-variant-numeric: tabular-nums; font-weight: 700; font-size: 13px; flex: 0 0 62px; text-align: right; }
.vs-m > i { background: var(--m-color); }
.vs-n > i { background: var(--n-color); }
.dot-m { color: var(--m-color); }
.dot-n { color: var(--n-color); }

/* ---------------------------------------------------------------- utility */

.muted { color: var(--text-2); }
.dim { color: var(--text-3); }
.small { font-size: 12.5px; }
.center { text-align: center; }
.mt-0 { margin-top: 0; } .mt-1 { margin-top: 8px; } .mt-2 { margin-top: 16px; } .mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; } .mb-2 { margin-bottom: 16px; }
.flex { display: flex; gap: 10px; align-items: center; }
.flex-wrap { flex-wrap: wrap; }
.spacer { flex: 1; }
.nowrap { white-space: nowrap; }
.tabular { font-variant-numeric: tabular-nums; }
.divider { height: 1px; background: var(--border); margin: 18px 0; }
ul.clean { margin: 0; padding-left: 20px; }
ul.clean li { margin-bottom: 5px; }
ol.clean { margin: 0; padding-left: 20px; }
ol.clean li { margin-bottom: 7px; }

.callout {
  background: var(--accent-soft); border: 1px solid color-mix(in srgb, var(--accent) 28%, transparent);
  border-radius: var(--radius-sm); padding: 11px 13px; font-size: 13px; color: var(--text-2);
}
.callout b { color: var(--text); }

/* ------------------------------------------------------------- responsive */

@media (max-width: 860px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 620px) {
  body { font-size: 14.5px; padding-bottom: 110px; }
  .view { padding: 4px 12px 40px; }
  .topbar-inner { padding: 9px 12px; gap: 8px; }
  .brand-text { font-size: 14.5px; }
  .brand-light { display: none; }
  .tabs { padding: 7px 12px; top: 53px; }
  .tab span:not(.tab-ico) { display: none; }
  .tab { padding: 8px 14px; }
  .tab-ico { font-size: 17px; }
  /* On a phone the icon alone carries the status; the label costs a line. */
  .sync-pill .sync-txt { display: none; }
  .sync-pill { padding: 6px 9px; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-auto, .grid-auto-lg { grid-template-columns: 1fr; }
  .stat-value { font-size: 21px; }
  .hero { padding: 17px; border-radius: var(--radius); }
  .hero-name { font-size: 19px; }
  .vs-label { flex-basis: 92px; font-size: 12px; }
  .field-row { flex-direction: column; gap: 0; }
  .modal { max-height: 92vh; }
  .modal-body { padding: 15px; }
  .badge-grid { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); }
}

@media (max-width: 400px) {
  .grid-4, .grid-3 { grid-template-columns: repeat(2, 1fr); }
  .stat-value { font-size: 19px; }
}

@media print {
  .topbar, .tabs, .fab-wrap, .toast-stack { display: none; }
  body { padding: 0; background: #fff; }
}
