/* ============================================================
   DoseIQ — DESIGN SYSTEM
   Clinical · precise · quiet · trustworthy
   ------------------------------------------------------------
   PRINCIPLES
   1. Light is the default. Clinical means white space, not neon.
   2. One accent colour. Deep teal, reserved for Guru and primary
      actions only. Everything else is ink and hairline.
   3. Type does the work. Tabular numerals everywhere numbers
      are compared — a dosing chart that doesn't align is not
      a clinical instrument.
   4. Depth by hairline and shadow, never by glow.
   5. Motion is 160ms and invisible. If you notice it, it's wrong.
   ============================================================ */

/* ─── FONT ──────────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

/* ─── TOKENS ────────────────────────────────────────────── */
:root {
  /* Surface — warm-neutral, never stark white */
  --bg:          #F7F8FA;
  --surface:     #FFFFFF;
  --surface-2:   #F1F3F6;
  --surface-3:   #E8EBF0;

  /* Ink */
  --text:        #0D1520;
  --text-2:      #46536B;
  --text-3:      #6B7A93;
  --muted:       #97A3B6;

  /* Hairlines */
  --border:      #E3E7EE;
  --border-2:    #D2D8E3;

  /* Accent — deep clinical teal. The ONLY colour in the chrome. */
  --accent:      #0D7A6B;
  --accent-hover:#0A6357;
  --accent-soft: #E6F4F1;
  --accent-line: #B4DED6;

  /* Semantic — desaturated, never alarming without cause */
  --success:     #12805C;
  --success-soft:#E7F5EF;
  --warning:     #A66A08;
  --warning-soft:#FDF3E3;
  --danger:      #B3261E;
  --danger-soft: #FCEDEC;

  /* Elevation — layered and soft, no glow */
  --sh-1: 0 1px 2px rgba(13,21,32,.05);
  --sh-2: 0 1px 3px rgba(13,21,32,.06), 0 4px 12px rgba(13,21,32,.05);
  --sh-3: 0 2px 6px rgba(13,21,32,.07), 0 12px 32px rgba(13,21,32,.09);
  --ring: 0 0 0 3px rgba(13,122,107,.14);

  /* Geometry */
  --r-sm: 6px;  --r: 10px;  --r-lg: 14px;  --r-xl: 20px;  --r-full: 999px;

  /* Rhythm — 4px grid */
  --s1:4px; --s2:8px; --s3:12px; --s4:16px; --s5:20px;
  --s6:24px; --s8:32px; --s10:40px; --s12:48px; --s16:64px;

  --nav-h: 60px;
  --maxw: 1120px;
  --ease: cubic-bezier(.32,.72,0,1);
}

[data-theme="dark"] {
  --bg:          #0B0F14;
  --surface:     #121820;
  --surface-2:   #1A222C;
  --surface-3:   #232D3A;

  --text:        #E9EDF3;
  --text-2:      #A6B2C4;
  --text-3:      #7C8A9E;
  --muted:       #5E6B7E;

  --border:      #212B36;
  --border-2:    #2D3945;

  --accent:      #2FBFA8;
  --accent-hover:#4ED0BA;
  --accent-soft: #0F2621;
  --accent-line: #1E4A42;

  --success:     #35B37E;
  --success-soft:#0E2620;
  --warning:     #D99A2B;
  --warning-soft:#2A2013;
  --danger:      #E5675E;
  --danger-soft: #2B1614;

  --sh-1: 0 1px 2px rgba(0,0,0,.4);
  --sh-2: 0 1px 3px rgba(0,0,0,.45), 0 4px 12px rgba(0,0,0,.3);
  --sh-3: 0 2px 6px rgba(0,0,0,.5), 0 12px 32px rgba(0,0,0,.45);
  --ring: 0 0 0 3px rgba(47,191,168,.2);
}

/* ─── RESET ─────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: 'cv02','cv03','cv04','ss01';
  transition: background .2s var(--ease), color .2s var(--ease);
}

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: none; }
a { color: inherit; text-decoration: none; }
svg { display: block; }

:focus-visible { outline: none; box-shadow: var(--ring); border-radius: var(--r-sm); }

::selection { background: var(--accent-soft); color: var(--accent); }

/* ─── TYPE ──────────────────────────────────────────────── */
h1,h2,h3,h4 { font-weight: 600; letter-spacing: -.018em; line-height: 1.25; }
h1 { font-size: 1.75rem; letter-spacing: -.026em; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.0625rem; }
h4 { font-size: .9375rem; }

.num { font-variant-numeric: tabular-nums; font-feature-settings: 'tnum'; }

.eyebrow {
  font-size: .6875rem; font-weight: 600; letter-spacing: .09em;
  text-transform: uppercase; color: var(--text-3);
}
.lead   { font-size: 1.0625rem; color: var(--text-2); line-height: 1.6; }
.small  { font-size: .8125rem; }
.dim    { color: var(--text-3); }
.dimmer { color: var(--muted); }

/* ═══════════════ NAVIGATION ═══════════════ */

.nav {
  position: sticky; top: 0; z-index: 60;
  height: var(--nav-h);
  display: flex; align-items: center; gap: var(--s6);
  padding: 0 var(--s6);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(180%) blur(16px);
  -webkit-backdrop-filter: saturate(180%) blur(16px);
  border-bottom: 1px solid var(--border);
}

.brand { display: flex; align-items: center; gap: 9px; flex-shrink: 0; }
.brand-mark {
  width: 26px; height: 26px; border-radius: 7px;
  background: var(--accent);
  display: grid; place-items: center;
  color: #fff; font-weight: 700; font-size: .8125rem; letter-spacing: -.03em;
}
.brand-name {
  font-size: 1.0625rem; font-weight: 600; letter-spacing: -.03em;
}

.nav-links { display: flex; align-items: center; gap: 2px; margin-left: var(--s4); }

.nav-link {
  position: relative;
  padding: 7px 13px;
  border-radius: var(--r-sm);
  font-size: .875rem; font-weight: 500;
  color: var(--text-3);
  transition: color .16s var(--ease), background .16s var(--ease);
}
.nav-link:hover { color: var(--text); background: var(--surface-2); }
.nav-link.active { color: var(--text); font-weight: 600; }
.nav-link.active::after {
  content: ''; position: absolute; left: 13px; right: 13px; bottom: -19px;
  height: 2px; background: var(--accent); border-radius: 2px 2px 0 0;
}

/* Guru — the one accented item in the chrome */
.nav-link.guru {
  color: var(--accent); font-weight: 600;
  background: var(--accent-soft);
  border: 1px solid var(--accent-line);
  padding: 6px 13px; margin-left: var(--s2);
}
.nav-link.guru:hover { background: var(--accent-line); color: var(--accent-hover); }
.nav-link.guru.active::after { display: none; }

.nav-right { margin-left: auto; display: flex; align-items: center; gap: var(--s2); }

.nav-status {
  font-size: .75rem; color: var(--text-3);
  display: flex; align-items: center; gap: 5px;
  padding-right: var(--s2);
}
.nav-status::before {
  content: ''; width: 5px; height: 5px; border-radius: 50%;
  background: var(--success);
}
.nav-status.saving::before { background: var(--warning); }
.nav-status.error::before  { background: var(--danger); }

.avatar-btn {
  display: flex; align-items: center; gap: 7px;
  padding: 4px 9px 4px 4px; border-radius: var(--r-full);
  border: 1px solid var(--border);
  font-size: .8125rem; font-weight: 500; color: var(--text-2);
  transition: border-color .16s var(--ease), background .16s var(--ease);
}
.avatar-btn:hover { background: var(--surface-2); border-color: var(--border-2); }
.avatar {
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--surface-3); color: var(--text-2);
  display: grid; place-items: center;
  font-size: .6875rem; font-weight: 600;
}

/* Dropdown */
.menu {
  position: absolute; top: calc(100% + 6px); right: 0;
  min-width: 190px; padding: 5px;
  background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--r);
  box-shadow: var(--sh-3);
  opacity: 0; visibility: hidden; transform: translateY(-4px);
  transition: opacity .16s var(--ease), transform .16s var(--ease), visibility .16s;
}
.menu.open { opacity: 1; visibility: visible; transform: translateY(0); }
.menu-item {
  display: flex; align-items: center; gap: 9px; width: 100%;
  padding: 8px 10px; border-radius: var(--r-sm);
  font-size: .875rem; color: var(--text-2); text-align: left;
  transition: background .12s var(--ease), color .12s var(--ease);
}
.menu-item:hover { background: var(--surface-2); color: var(--text); }
.menu-item.danger { color: var(--danger); }
.menu-item.danger:hover { background: var(--danger-soft); }
.menu-sep { height: 1px; background: var(--border); margin: 5px 0; }

/* Mobile bottom tabs */
.tabbar { display: none; }

@media (max-width: 860px) {
  .nav-links, .nav-status { display: none; }
  .nav { padding: 0 var(--s4); }

  .tabbar {
    position: fixed; bottom: 0; left: 0; right: 0; z-index: 60;
    display: grid; grid-template-columns: repeat(5, 1fr);
    align-items: end;
    height: 62px; padding-bottom: env(safe-area-inset-bottom);
    background: color-mix(in srgb, var(--surface) 94%, transparent);
    backdrop-filter: saturate(180%) blur(16px);
    -webkit-backdrop-filter: saturate(180%) blur(16px);
    border-top: 1px solid var(--border);
  }
  .tab {
    display: flex; flex-direction: column; align-items: center; gap: 3px;
    padding: 9px 0 8px;
    font-size: .625rem; font-weight: 500; color: var(--muted);
    transition: color .16s var(--ease);
  }
  .tab svg { width: 21px; height: 21px; stroke-width: 1.75; }
  .tab.active { color: var(--accent); font-weight: 600; }

  /* Guru — raised centre tab */
  .tab.tab-guru { position: relative; color: var(--text-3); }
  .tab.tab-guru .tab-fab {
    position: absolute; top: -17px; left: 50%; transform: translateX(-50%);
    width: 46px; height: 46px; border-radius: 50%;
    background: var(--accent); color: #fff;
    display: grid; place-items: center;
    box-shadow: 0 4px 14px rgba(13,122,107,.34);
    border: 3px solid var(--surface);
    transition: transform .16s var(--ease);
  }
  .tab.tab-guru:active .tab-fab { transform: translateX(-50%) scale(.94); }
  .tab.tab-guru .tab-label { margin-top: 30px; }
  .tab.tab-guru svg { width: 22px; height: 22px; stroke-width: 2; }

  body { padding-bottom: 62px; }
}

/* ═══════════════ LAYOUT ═══════════════ */
.page { max-width: var(--maxw); margin: 0 auto; padding: var(--s8) var(--s6) var(--s16); }
@media (max-width: 860px) { .page { padding: var(--s5) var(--s4) var(--s10); } }

.page-head { margin-bottom: var(--s6); }
.page-head h1 { margin-bottom: 3px; }
.page-head .sub { color: var(--text-3); font-size: .9375rem; }

.row  { display: flex; align-items: center; gap: var(--s3); }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); }
.stack { display: flex; flex-direction: column; }
.spacer { flex: 1; }

.section { margin-bottom: var(--s8); }
.section-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--s3); margin-bottom: var(--s3);
}

/* ═══════════════ SURFACES ═══════════════ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-1);
}
.card-pad { padding: var(--s5); }
.card-head {
  padding: var(--s4) var(--s5);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; gap: var(--s3);
}
.card-body { padding: var(--s5); }

/* ─── Stat tiles ─── */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--s3); }
@media (max-width: 860px) { .stats { grid-template-columns: repeat(2, 1fr); } }

.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--s4) var(--s4) var(--s4);
  box-shadow: var(--sh-1);
}
.stat-label {
  font-size: .6875rem; font-weight: 600; letter-spacing: .07em;
  text-transform: uppercase; color: var(--text-3);
  margin-bottom: 7px;
}
.stat-value {
  font-size: 1.75rem; font-weight: 600; letter-spacing: -.03em;
  line-height: 1.1; font-variant-numeric: tabular-nums;
}
.stat-value .unit { font-size: .9375rem; font-weight: 500; color: var(--text-3); margin-left: 2px; }
.stat-meta { font-size: .75rem; color: var(--muted); margin-top: 4px; }

/* Thin progress rail */
.rail { height: 3px; border-radius: 2px; background: var(--surface-3); overflow: hidden; margin-top: 10px; }
.rail-fill { height: 100%; border-radius: 2px; background: var(--accent); transition: width .5s var(--ease); }
.rail-fill.success { background: var(--success); }
.rail-fill.warning { background: var(--warning); }

/* ═══════════════ DOSE LIST ═══════════════ */
.dose-list { display: flex; flex-direction: column; }

.dose {
  display: flex; align-items: center; gap: var(--s4);
  padding: var(--s4) var(--s5);
  border-bottom: 1px solid var(--border);
  transition: background .14s var(--ease);
}
.dose:last-child { border-bottom: none; }
.dose:hover { background: var(--surface-2); }
.dose:hover .dose-ask { opacity: 1; }
.dose.done .dose-name { color: var(--text-3); }
.dose.done .dose-name::after {
  content: ''; position: absolute; left: 0; right: 0; top: 50%;
  height: 1px; background: var(--border-2);
}

/* Check control */
.check {
  flex-shrink: 0; width: 24px; height: 24px;
  border: 1.5px solid var(--border-2); border-radius: 7px;
  background: var(--surface);
  display: grid; place-items: center;
  transition: all .16s var(--ease);
}
.check svg { width: 14px; height: 14px; stroke-width: 3; color: #fff; opacity: 0; transform: scale(.7); transition: all .16s var(--ease); }
.check:hover { border-color: var(--accent); }
.check.checked { background: var(--success); border-color: var(--success); }
.check.checked svg { opacity: 1; transform: scale(1); }

.dose-main { flex: 1; min-width: 0; }
.dose-name { position: relative; display: inline-block; font-weight: 600; font-size: .9375rem; letter-spacing: -.01em; }
.dose-meta { font-size: .8125rem; color: var(--text-3); margin-top: 1px; }
.dose-meta .sep { color: var(--border-2); margin: 0 6px; }

.dose-amount { text-align: right; flex-shrink: 0; }
.dose-dose  { font-weight: 600; font-size: .9375rem; font-variant-numeric: tabular-nums; }
.dose-units { font-size: .75rem; color: var(--text-3); font-variant-numeric: tabular-nums; margin-top: 1px; }

.dose-ask {
  flex-shrink: 0; width: 30px; height: 30px; border-radius: var(--r-sm);
  display: grid; place-items: center;
  color: var(--accent); background: transparent;
  opacity: 0; transition: all .16s var(--ease);
}
.dose-ask:hover { background: var(--accent-soft); }
.dose-ask svg { width: 16px; height: 16px; stroke-width: 1.75; }
@media (max-width: 860px) { .dose-ask { opacity: 1; } .dose { padding: var(--s4); gap: var(--s3); } }

/* ═══════════════ WEEK GRID ═══════════════ */
.week { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.week th {
  font-size: .6875rem; font-weight: 600; letter-spacing: .06em;
  text-transform: uppercase; color: var(--text-3);
  padding: 0 0 var(--s3); text-align: center; width: 40px;
}
.week th:first-child { text-align: left; width: auto; }
.week td { padding: 5px 0; text-align: center; border-top: 1px solid var(--border); }
.week td:first-child {
  text-align: left; font-size: .875rem; font-weight: 500;
  padding-right: var(--s4); white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; max-width: 150px;
}
.week tr:first-child td { border-top: none; }

.cell {
  width: 28px; height: 28px; border-radius: 8px; margin: 0 auto;
  display: grid; place-items: center;
  transition: all .14s var(--ease);
}
.cell.due     { background: var(--surface-2); border: 1px solid var(--border); }
.cell.due:hover { border-color: var(--accent); }
.cell.done    { background: var(--success); }
.cell.done svg{ width: 13px; height: 13px; stroke-width: 3; color: #fff; }
.cell.today   { box-shadow: 0 0 0 2px var(--accent-line); }
.cell.off     { color: var(--muted); font-size: .75rem; }
.cell.off::after { content: '·'; }

/* ═══════════════ BUTTONS ═══════════════ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 9px 16px; border-radius: var(--r);
  font-size: .875rem; font-weight: 550; letter-spacing: -.005em;
  border: 1px solid transparent; white-space: nowrap;
  transition: all .16s var(--ease);
}
.btn svg { width: 16px; height: 16px; stroke-width: 2; }
.btn:active { transform: scale(.985); }
.btn:disabled { opacity: .45; pointer-events: none; }

.btn-primary { background: var(--accent); color: #fff; box-shadow: var(--sh-1); }
.btn-primary:hover { background: var(--accent-hover); box-shadow: var(--sh-2); }

.btn-secondary { background: var(--surface); color: var(--text-2); border-color: var(--border-2); }
.btn-secondary:hover { background: var(--surface-2); color: var(--text); border-color: var(--text-3); }

.btn-ghost { color: var(--text-3); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }

.btn-guru {
  background: var(--accent-soft); color: var(--accent);
  border-color: var(--accent-line);
}
.btn-guru:hover { background: var(--accent-line); }

.btn-danger { background: var(--danger); color: #fff; }
.btn-sm  { padding: 6px 12px; font-size: .8125rem; border-radius: var(--r-sm); }
.btn-sm svg { width: 14px; height: 14px; }
.btn-lg  { padding: 12px 22px; font-size: .9375rem; }
.btn-block { width: 100%; }

/* ═══════════════ PILLS ═══════════════ */
.pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: var(--r-full);
  font-size: .6875rem; font-weight: 600; letter-spacing: .01em;
  background: var(--surface-2); color: var(--text-2);
  border: 1px solid var(--border);
}
.pill-accent  { background: var(--accent-soft);  color: var(--accent);  border-color: var(--accent-line); }
.pill-success { background: var(--success-soft); color: var(--success); border-color: transparent; }
.pill-warning { background: var(--warning-soft); color: var(--warning); border-color: transparent; }
.pill-danger  { background: var(--danger-soft);  color: var(--danger);  border-color: transparent; }

/* ═══════════════ CALLOUT ═══════════════ */
.callout {
  display: flex; align-items: center; gap: var(--s3);
  padding: var(--s4);
  border-radius: var(--r-lg);
  border: 1px solid var(--accent-line);
  background: var(--accent-soft);
  transition: all .16s var(--ease);
}
.callout:hover { border-color: var(--accent); }
.callout-icon {
  flex-shrink: 0; width: 34px; height: 34px; border-radius: var(--r);
  background: var(--surface); color: var(--accent);
  display: grid; place-items: center; box-shadow: var(--sh-1);
}
.callout-icon svg { width: 17px; height: 17px; stroke-width: 1.75; }
.callout-text { flex: 1; min-width: 0; }
.callout-title { font-size: .875rem; font-weight: 600; color: var(--text); }
.callout-sub   { font-size: .8125rem; color: var(--text-2); margin-top: 1px; }
.callout svg.chev { width: 17px; height: 17px; color: var(--accent); flex-shrink: 0; }

.callout-warning { background: var(--warning-soft); border-color: transparent; }
.callout-warning .callout-icon { color: var(--warning); }

/* ═══════════════ EMPTY STATE ═══════════════ */
.empty { text-align: center; padding: var(--s12) var(--s5); }
.empty-icon {
  width: 46px; height: 46px; margin: 0 auto var(--s4);
  border-radius: var(--r-lg); background: var(--surface-2);
  display: grid; place-items: center; color: var(--text-3);
}
.empty-icon svg { width: 22px; height: 22px; stroke-width: 1.5; }
.empty h3 { margin-bottom: 5px; }
.empty p { color: var(--text-3); font-size: .875rem; margin-bottom: var(--s5); }
.empty-actions { display: flex; gap: var(--s2); justify-content: center; flex-wrap: wrap; }

/* ═══════════════ FORMS ═══════════════ */
.field { margin-bottom: var(--s4); }
.label {
  display: block; margin-bottom: 6px;
  font-size: .8125rem; font-weight: 550; color: var(--text-2);
}
.input, .select, .textarea {
  width: 100%; padding: 9px 12px;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border-2); border-radius: var(--r);
  font-size: .9375rem;
  transition: border-color .16s var(--ease), box-shadow .16s var(--ease);
}
.input:hover, .select:hover { border-color: var(--text-3); }
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: var(--ring);
}
.input::placeholder { color: var(--muted); }
.select {
  appearance: none; padding-right: 32px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236B7A93' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; background-size: 15px;
}
.textarea { resize: vertical; min-height: 84px; line-height: 1.55; }
.hint { font-size: .75rem; color: var(--muted); margin-top: 5px; }

/* ═══════════════ MODAL ═══════════════ */
.overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(13,21,32,.34);
  backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
  display: grid; place-items: center; padding: var(--s5);
  opacity: 0; visibility: hidden;
  transition: opacity .2s var(--ease), visibility .2s;
}
.overlay.open { opacity: 1; visibility: visible; }
.modal {
  width: 100%; max-width: 460px; max-height: 88vh; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-xl); box-shadow: var(--sh-3);
  transform: translateY(10px) scale(.985);
  transition: transform .2s var(--ease);
}
.overlay.open .modal { transform: none; }
.modal-head {
  padding: var(--s5) var(--s5) var(--s4);
  display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s3);
}
.modal-body { padding: 0 var(--s5) var(--s5); }
.modal-foot {
  padding: var(--s4) var(--s5); border-top: 1px solid var(--border);
  display: flex; gap: var(--s2); justify-content: flex-end;
}
@media (max-width: 560px) {
  .overlay { align-items: flex-end; padding: 0; }
  .modal { max-width: 100%; border-radius: var(--r-xl) var(--r-xl) 0 0; max-height: 92vh; }
}

/* ═══════════════ TOAST ═══════════════ */
.toast {
  position: fixed; bottom: var(--s6); left: 50%;
  transform: translate(-50%, 16px);
  z-index: 200; display: flex; align-items: center; gap: 9px;
  padding: 11px 17px; border-radius: var(--r-full);
  background: var(--text); color: var(--bg);
  font-size: .875rem; font-weight: 500;
  box-shadow: var(--sh-3);
  opacity: 0; visibility: hidden;
  transition: all .22s var(--ease);
}
.toast.show { opacity: 1; visibility: visible; transform: translate(-50%, 0); }
.toast svg { width: 16px; height: 16px; stroke-width: 2.5; }
.toast.error { background: var(--danger); color: #fff; }
@media (max-width: 860px) { .toast { bottom: 76px; } }

/* ═══════════════ GURU FLOATING ═══════════════ */
.guru-fab {
  position: fixed; right: var(--s6); bottom: var(--s6); z-index: 55;
  display: flex; align-items: center; gap: 9px;
  padding: 11px 18px 11px 14px; border-radius: var(--r-full);
  background: var(--accent); color: #fff;
  font-size: .875rem; font-weight: 600;
  box-shadow: 0 4px 18px rgba(13,122,107,.32);
  transition: all .18s var(--ease);
}
.guru-fab:hover { background: var(--accent-hover); transform: translateY(-1px); box-shadow: 0 7px 24px rgba(13,122,107,.38); }
.guru-fab svg { width: 18px; height: 18px; stroke-width: 1.75; }
@media (max-width: 860px) { .guru-fab { display: none; } }

/* ═══════════════ SKELETON ═══════════════ */
.skel {
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 37%, var(--surface-2) 63%);
  background-size: 400% 100%;
  animation: shimmer 1.4s ease-in-out infinite;
  border-radius: var(--r-sm);
}
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }

/* ═══════════════ PROTOCOL EDITOR ═══════════════
   One markup structure, two layouts. Desktop reads as a
   spreadsheet; below 900px the same grid reflows into cards.
   No duplicate DOM, no `toggleMobRow` hack. */

.sec { margin-bottom: var(--s4); }

.sec-head {
  display: flex; align-items: center; gap: var(--s3);
  width: 100%; padding: var(--s4) var(--s5);
  background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--r-lg);
  transition: background .16s var(--ease), border-radius .16s var(--ease);
}
.sec.open .sec-head { border-radius: var(--r-lg) var(--r-lg) 0 0; border-bottom-color: transparent; }
.sec-head:hover { background: var(--surface-2); }

.sec-chev { color: var(--text-3); transition: transform .2s var(--ease); }
.sec-chev svg { width: 17px; height: 17px; }
.sec.open .sec-chev { transform: rotate(90deg); }

.sec-title { font-size: .9375rem; font-weight: 600; letter-spacing: -.01em; }
.sec-count {
  font-size: .75rem; font-weight: 600; color: var(--text-3);
  background: var(--surface-2); border: 1px solid var(--border);
  padding: 1px 8px; border-radius: var(--r-full);
}

.sec-body {
  display: none;
  background: var(--surface);
  border: 1px solid var(--border); border-top: none;
  border-radius: 0 0 var(--r-lg) var(--r-lg);
  overflow: hidden;
}
.sec.open .sec-body { display: block; }

/* ─── Row grid ─── */
.prow-head, .prow {
  display: grid;
  grid-template-columns: minmax(150px,1.7fr) 92px 128px 104px 74px 132px 62px;
  gap: var(--s3); align-items: center;
  padding: var(--s3) var(--s5);
}
.prow-head {
  padding-top: var(--s3); padding-bottom: var(--s2);
  border-bottom: 1px solid var(--border);
  font-size: .6875rem; font-weight: 600; letter-spacing: .07em;
  text-transform: uppercase; color: var(--text-3);
}
.prow { border-bottom: 1px solid var(--border); transition: background .14s var(--ease); }
.prow:last-child { border-bottom: none; }
.prow:hover { background: var(--surface-2); }

.pf { min-width: 0; }
.pf-label { display: none; font-size: .6875rem; font-weight: 600; color: var(--text-3); margin-bottom: 4px; text-transform: uppercase; letter-spacing: .06em; }

/* Compact controls inside rows */
.pin {
  width: 100%; padding: 7px 9px;
  background: transparent; color: var(--text);
  border: 1px solid transparent; border-radius: var(--r-sm);
  font-size: .875rem;
  transition: border-color .14s var(--ease), background .14s var(--ease);
}
.pin:hover  { border-color: var(--border); background: var(--surface); }
.pin:focus  { outline: none; border-color: var(--accent); background: var(--surface); box-shadow: var(--ring); }
.pin.sel {
  appearance: none; cursor: pointer; padding-right: 26px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2397A3B6' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 7px center; background-size: 14px;
}
.pin.name { font-weight: 600; }

/* Computed units — read-only, visibly derived */
.punits {
  font-size: .875rem; font-weight: 600; font-variant-numeric: tabular-nums;
  color: var(--accent); text-align: right; padding-right: 4px;
}
.punits.none { color: var(--muted); font-weight: 400; }

.prow-actions { display: flex; align-items: center; gap: 2px; justify-content: flex-end; }
.icon-btn {
  width: 28px; height: 28px; border-radius: var(--r-sm);
  display: grid; place-items: center; color: var(--text-3);
  opacity: 0; transition: all .14s var(--ease);
}
.prow:hover .icon-btn { opacity: 1; }
.icon-btn svg { width: 15px; height: 15px; stroke-width: 1.75; }
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.icon-btn.ask:hover    { background: var(--accent-soft); color: var(--accent); }
.icon-btn.del:hover    { background: var(--danger-soft); color: var(--danger); }

/* Derived detail line under each row */
.prow-sub {
  grid-column: 1 / -1;
  display: flex; flex-wrap: wrap; gap: var(--s1) var(--s3);
  font-size: .75rem; color: var(--text-3);
  padding-left: 9px; margin-top: -2px;
}
.prow-sub .k { display: inline-flex; align-items: center; gap: 4px; }
.prow-sub .k b { font-weight: 600; color: var(--text-2); font-variant-numeric: tabular-nums; }

.sec-foot { padding: var(--s3) var(--s5); border-top: 1px solid var(--border); background: var(--surface-2); }

/* ─── Mobile: same grid becomes a card ─── */
@media (max-width: 900px) {
  .prow-head { display: none; }
  .prow {
    grid-template-columns: 1fr 1fr;
    gap: var(--s3); padding: var(--s4) var(--s4) var(--s3);
    position: relative;
  }
  .pf-label { display: block; }
  .pf-name { grid-column: 1 / -1; padding-right: 68px; }
  .pin { border-color: var(--border); background: var(--surface); }
  .punits { text-align: left; padding: 7px 0 0; }
  .prow-actions { position: absolute; top: var(--s3); right: var(--s3); }
  .icon-btn { opacity: 1; }
}

/* ═══════════════ CALCULATOR ═══════════════ */
.calc-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s5); align-items: start; }
@media (max-width: 760px) { .calc-grid { grid-template-columns: 1fr; } }

.calc-out {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: var(--s5);
}
.calc-big {
  font-size: 2.25rem; font-weight: 600; letter-spacing: -.035em;
  color: var(--accent); font-variant-numeric: tabular-nums; line-height: 1.05;
}
.calc-big .u { font-size: 1rem; font-weight: 500; color: var(--text-3); margin-left: 4px; }
.calc-sub { font-size: .8125rem; color: var(--text-2); margin-top: 5px; }

/* Syringe */
.syr { margin-top: var(--s5); }
.syr-barrel {
  position: relative; height: 30px;
  background: var(--surface); border: 1.5px solid var(--border-2);
  border-radius: 5px 14px 14px 5px; overflow: hidden;
}
.syr-fill {
  position: absolute; inset: 0 auto 0 0;
  background: var(--accent); opacity: .82;
  transition: width .35s var(--ease);
}
.syr-ticks { position: absolute; inset: 0; display: flex; }
.syr-ticks span { flex: 1; border-right: 1px solid var(--border); }
.syr-ticks span:last-child { border-right: none; }
.syr-scale {
  display: flex; justify-content: space-between;
  font-size: .6875rem; color: var(--muted);
  font-variant-numeric: tabular-nums; margin-top: 5px;
}
.calc-warn {
  display: flex; gap: 9px; align-items: flex-start;
  margin-top: var(--s4); padding: 11px 13px;
  border-radius: var(--r); font-size: .8125rem;
  background: var(--warning-soft); color: var(--warning);
}
.calc-warn svg { width: 15px; height: 15px; flex-shrink: 0; margin-top: 2px; }

/* ═══════════════ GURU ═══════════════ */
.guru-hero { text-align: center; padding: var(--s8) 0 var(--s6); }
.guru-mark {
  width: 52px; height: 52px; margin: 0 auto var(--s4);
  border-radius: var(--r-lg); background: var(--accent); color: #fff;
  display: grid; place-items: center;
  box-shadow: 0 5px 18px rgba(13,122,107,.28);
}
.guru-mark svg { width: 26px; height: 26px; stroke-width: 1.75; }
.guru-hero h1 { font-size: 1.625rem; margin-bottom: 6px; }
.guru-hero p  { color: var(--text-3); font-size: .9375rem; max-width: 400px; margin: 0 auto; }

/* Composer */
.ask {
  display: flex; align-items: flex-end; gap: var(--s2);
  padding: 9px 9px 9px 15px;
  background: var(--surface);
  border: 1px solid var(--border-2); border-radius: var(--r-xl);
  box-shadow: var(--sh-2);
  transition: border-color .16s var(--ease), box-shadow .16s var(--ease);
}
.ask:focus-within { border-color: var(--accent); box-shadow: var(--ring), var(--sh-2); }
.ask textarea {
  flex: 1; border: none; background: none; resize: none;
  font-size: .9375rem; line-height: 1.5; padding: 7px 0;
  max-height: 168px; outline: none;
}
.ask textarea::placeholder { color: var(--muted); }
.ask-send {
  flex-shrink: 0; width: 34px; height: 34px; border-radius: 50%;
  background: var(--accent); color: #fff; display: grid; place-items: center;
  transition: all .16s var(--ease);
}
.ask-send:hover:not(:disabled) { background: var(--accent-hover); }
.ask-send:disabled { background: var(--surface-3); color: var(--muted); }
.ask-send svg { width: 16px; height: 16px; stroke-width: 2.5; }

.ask-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--s3); margin-top: var(--s3); flex-wrap: wrap;
}
.ctx-toggle {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: .8125rem; color: var(--text-2); cursor: pointer;
  padding: 5px 11px; border-radius: var(--r-full);
  border: 1px solid var(--border); background: var(--surface);
  transition: all .16s var(--ease);
}
.ctx-toggle:hover { border-color: var(--border-2); }
.ctx-toggle input { accent-color: var(--accent); width: 14px; height: 14px; }
.ctx-toggle.on { background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent); }
.quota { font-size: .75rem; color: var(--muted); font-variant-numeric: tabular-nums; }

/* Starter cards */
.starters { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s2); }
@media (max-width: 700px) { .starters { grid-template-columns: 1fr; } }
.starter {
  display: flex; align-items: flex-start; gap: var(--s3);
  padding: var(--s4); text-align: left;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg);
  transition: all .16s var(--ease);
}
.starter:hover { border-color: var(--accent-line); background: var(--accent-soft); }
.starter-ico {
  flex-shrink: 0; width: 30px; height: 30px; border-radius: 8px;
  background: var(--surface-2); color: var(--accent);
  display: grid; place-items: center;
}
.starter:hover .starter-ico { background: var(--surface); }
.starter-ico svg { width: 15px; height: 15px; stroke-width: 1.75; }
.starter-t { font-size: .875rem; font-weight: 600; line-height: 1.35; }
.starter-s { font-size: .75rem; color: var(--text-3); margin-top: 2px; line-height: 1.4; }

/* Compound chips */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  padding: 6px 12px; border-radius: var(--r-full);
  font-size: .8125rem; font-weight: 500; color: var(--text-2);
  background: var(--surface); border: 1px solid var(--border);
  transition: all .14s var(--ease);
}
.chip:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.chip.mine { border-color: var(--accent-line); color: var(--accent); background: var(--accent-soft); }
.chip.mine::before { content: '●'; font-size: .5rem; margin-right: 5px; vertical-align: middle; }

/* Recent list */
.chat-item {
  display: flex; align-items: center; gap: var(--s3); width: 100%;
  padding: var(--s3) var(--s4); text-align: left;
  border-bottom: 1px solid var(--border);
  transition: background .14s var(--ease);
}
.chat-item:last-child { border-bottom: none; }
.chat-item:hover { background: var(--surface-2); }
.chat-item svg { width: 15px; height: 15px; color: var(--text-3); flex-shrink: 0; }
.chat-t { flex: 1; font-size: .875rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-d { font-size: .75rem; color: var(--muted); flex-shrink: 0; }

/* ─── Thread ─── */
.thread { max-width: 760px; margin: 0 auto; }
.thread-head {
  display: flex; align-items: center; gap: var(--s3);
  padding-bottom: var(--s4); margin-bottom: var(--s5);
  border-bottom: 1px solid var(--border);
}
.thread-title { font-size: .9375rem; font-weight: 600; flex: 1; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.msg { display: flex; gap: var(--s3); margin-bottom: var(--s6); }
.msg-av {
  flex-shrink: 0; width: 28px; height: 28px; border-radius: 8px;
  display: grid; place-items: center; font-size: .6875rem; font-weight: 600;
}
.msg.user .msg-av { background: var(--surface-3); color: var(--text-2); }
.msg.bot  .msg-av { background: var(--accent); color: #fff; }
.msg.bot  .msg-av svg { width: 15px; height: 15px; stroke-width: 2; }
.msg-body { flex: 1; min-width: 0; padding-top: 2px; }
.msg.user .msg-body { color: var(--text); font-weight: 500; }

.msg-body p  { margin-bottom: var(--s3); }
.msg-body p:last-child { margin-bottom: 0; }
.msg-body h3 { font-size: .9375rem; margin: var(--s4) 0 var(--s2); }
.msg-body h4 { font-size: .875rem; margin: var(--s4) 0 var(--s2); color: var(--text-2); }
.msg-body ul, .msg-body ol { margin: 0 0 var(--s3) var(--s5); }
.msg-body li { margin-bottom: 5px; }
.msg-body code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: .8125em; background: var(--surface-2);
  padding: 2px 5px; border-radius: 4px; border: 1px solid var(--border);
}
.guru-pre {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--r); padding: var(--s3) var(--s4);
  overflow-x: auto; margin-bottom: var(--s3);
}
.guru-pre code { background: none; border: none; padding: 0; font-size: .8125rem; }
.guru-table-wrap { overflow-x: auto; margin-bottom: var(--s3); }
.guru-table { width: 100%; border-collapse: collapse; font-size: .8125rem; }
.guru-table th, .guru-table td { padding: 7px 11px; border: 1px solid var(--border); text-align: left; }
.guru-table th { background: var(--surface-2); font-weight: 600; }

.msg-tools { display: flex; gap: 2px; margin-top: var(--s2); opacity: 0; transition: opacity .16s var(--ease); }
.msg:hover .msg-tools { opacity: 1; }
.msg-tools button {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 9px; border-radius: var(--r-sm);
  font-size: .75rem; color: var(--text-3);
  transition: all .14s var(--ease);
}
.msg-tools button:hover { background: var(--surface-2); color: var(--text); }
.msg-tools button.on { color: var(--accent); }
.msg-tools svg { width: 13px; height: 13px; }

.msg-err {
  background: var(--danger-soft); color: var(--danger);
  border-radius: var(--r); padding: var(--s3) var(--s4); font-size: .875rem;
}
.msg-err.quota { background: var(--warning-soft); color: var(--warning); }

.typing { display: inline-flex; gap: 4px; padding: 6px 0; }
.typing i {
  width: 6px; height: 6px; border-radius: 50%; background: var(--muted);
  animation: bounce 1.3s infinite;
}
.typing i:nth-child(2) { animation-delay: .18s; }
.typing i:nth-child(3) { animation-delay: .36s; }
@keyframes bounce { 0%,60%,100% { opacity:.3; transform:translateY(0) } 30% { opacity:1; transform:translateY(-3px) } }

.thread-composer {
  position: sticky; bottom: 0; padding: var(--s4) 0 var(--s5);
  background: linear-gradient(to bottom, transparent, var(--bg) 22%);
}
@media (max-width: 860px) { .thread-composer { bottom: 62px; } }

.disclaimer {
  font-size: .75rem; color: var(--muted); text-align: center;
  max-width: 520px; margin: var(--s8) auto 0; line-height: 1.6;
}

/* ═══════════════ TABS ═══════════════ */
.tabs {
  display: inline-flex; gap: 2px; padding: 3px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--r); margin-bottom: var(--s6);
}
.tab-btn {
  padding: 7px 15px; border-radius: var(--r-sm);
  font-size: .875rem; font-weight: 500; color: var(--text-3);
  transition: all .16s var(--ease);
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active {
  background: var(--surface); color: var(--text); font-weight: 600;
  box-shadow: var(--sh-1);
}

/* ═══════════════ ADHERENCE BARS ═══════════════ */
.bars { display: flex; flex-direction: column; }
.bar-row {
  display: grid; grid-template-columns: minmax(120px,1.4fr) 1fr 56px 62px;
  gap: var(--s4); align-items: center;
  padding: var(--s3) var(--s5); border-bottom: 1px solid var(--border);
}
.bar-row:last-child { border-bottom: none; }
.bar-name { font-size: .875rem; font-weight: 500; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; }
.bar-track { height: 6px; border-radius: 3px; background: var(--surface-3); overflow: hidden; }
.bar-fill  { height: 100%; border-radius: 3px; background: var(--success); transition: width .5s var(--ease); }
.bar-fill.mid { background: var(--warning); }
.bar-fill.low { background: var(--danger); }
.bar-pct {
  font-size: .875rem; font-weight: 600; text-align: right;
  font-variant-numeric: tabular-nums;
}
.bar-meta { font-size: .75rem; color: var(--muted); text-align: right;
  font-variant-numeric: tabular-nums; }
.bar-delta { font-size: .75rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.bar-delta.up   { color: var(--success); }
.bar-delta.down { color: var(--danger); }
@media (max-width: 700px) {
  .bar-row { grid-template-columns: 1fr 52px; gap: var(--s2) var(--s3); padding: var(--s3) var(--s4); }
  .bar-name { grid-column: 1; }
  .bar-pct  { grid-column: 2; grid-row: 1; }
  .bar-track{ grid-column: 1 / -1; }
  .bar-meta { grid-column: 1 / -1; text-align: left; }
}

/* ═══════════════ MONTH CALENDAR ═══════════════ */
.cal-head {
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px;
  margin-bottom: var(--s2);
}
.cal-head span {
  text-align: center; font-size: .6875rem; font-weight: 600;
  letter-spacing: .06em; text-transform: uppercase; color: var(--text-3);
}
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; }
.cal-cell {
  aspect-ratio: 1; border-radius: var(--r-sm);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; font-size: .8125rem; font-variant-numeric: tabular-nums;
  border: 1px solid transparent;
  transition: all .14s var(--ease);
}
.cal-cell.blank { visibility: hidden; }
.cal-cell.none  { color: var(--muted); }
.cal-cell.future{ color: var(--muted); background: var(--surface-2); }
.cal-cell.full  { background: var(--success); color: #fff; font-weight: 600; }
.cal-cell.part  { background: var(--warning-soft); color: var(--warning); font-weight: 600; }
.cal-cell.miss  { background: var(--danger-soft);  color: var(--danger);  font-weight: 600; }
.cal-cell.today { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.cal-dot { font-size: .5625rem; opacity: .85; }

.legend { display: flex; flex-wrap: wrap; gap: var(--s4); margin-top: var(--s4); }
.legend span { display: inline-flex; align-items: center; gap: 6px; font-size: .75rem; color: var(--text-3); }
.legend i { width: 11px; height: 11px; border-radius: 3px; display: inline-block; }

/* ═══════════════ JOURNAL ═══════════════ */
.scale { display: flex; gap: 5px; }
.scale button {
  flex: 1; padding: 9px 0; border-radius: var(--r-sm);
  border: 1px solid var(--border); background: var(--surface);
  font-size: .875rem; font-weight: 500; color: var(--text-2);
  font-variant-numeric: tabular-nums;
  transition: all .14s var(--ease);
}
.scale button:hover { border-color: var(--border-2); }
.scale button.on { background: var(--accent); border-color: var(--accent); color: #fff; }

.jentry { padding: var(--s4) var(--s5); border-bottom: 1px solid var(--border); }
.jentry:last-child { border-bottom: none; }
.jentry-top { display: flex; align-items: center; gap: var(--s3); margin-bottom: 7px; }
.jentry-date { font-size: .8125rem; font-weight: 600; }
.jentry-text { font-size: .875rem; color: var(--text-2); line-height: 1.6; white-space: pre-wrap; }
.jentry .icon-btn { opacity: 0; }
.jentry:hover .icon-btn { opacity: 1; }

/* ═══════════════ SETTINGS ═══════════════ */
.settings { display: grid; grid-template-columns: 186px 1fr; gap: var(--s8); align-items: start; }
@media (max-width: 820px) { .settings { grid-template-columns: 1fr; gap: var(--s5); } }

.set-nav { position: sticky; top: calc(var(--nav-h) + var(--s5)); display: flex; flex-direction: column; gap: 1px; }
@media (max-width: 820px) {
  .set-nav {
    position: static; flex-direction: row; gap: 4px;
    overflow-x: auto; padding-bottom: var(--s2);
    scrollbar-width: none;
  }
  .set-nav::-webkit-scrollbar { display: none; }
  .set-nav button { white-space: nowrap; }
}
.set-nav button {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 11px; border-radius: var(--r-sm);
  font-size: .875rem; font-weight: 500; color: var(--text-3);
  text-align: left; transition: all .14s var(--ease);
}
.set-nav button:hover { background: var(--surface-2); color: var(--text); }
.set-nav button.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.set-nav svg { width: 15px; height: 15px; stroke-width: 1.75; flex-shrink: 0; }

.set-pane { min-width: 0; }
.set-pane h2 { font-size: 1.125rem; margin-bottom: 3px; }
.set-pane .sub { color: var(--text-3); font-size: .875rem; margin-bottom: var(--s5); }

.set-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--s4); padding: var(--s4) var(--s5);
  border-bottom: 1px solid var(--border);
}
.set-row:last-child { border-bottom: none; }
.set-row-label { font-size: .875rem; font-weight: 500; }
.set-row-sub   { font-size: .75rem; color: var(--text-3); margin-top: 2px; }
.set-row-ctl   { flex-shrink: 0; min-width: 180px; }
@media (max-width: 620px) {
  .set-row { flex-direction: column; align-items: stretch; }
  .set-row-ctl { min-width: 0; }
}

/* Switch */
.switch { position: relative; display: inline-block; width: 40px; height: 23px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span {
  position: absolute; inset: 0; cursor: pointer;
  background: var(--surface-3); border-radius: var(--r-full);
  transition: background .18s var(--ease);
}
.switch span::before {
  content: ''; position: absolute; height: 17px; width: 17px;
  left: 3px; bottom: 3px; background: #fff; border-radius: 50%;
  box-shadow: var(--sh-1); transition: transform .18s var(--ease);
}
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::before { transform: translateX(17px); }

/* Reminders */
.rem {
  display: flex; align-items: center; gap: var(--s4);
  padding: var(--s4) var(--s5); border-bottom: 1px solid var(--border);
}
.rem:last-child { border-bottom: none; }
.rem-time {
  font-size: 1.0625rem; font-weight: 600; font-variant-numeric: tabular-nums;
  min-width: 78px; letter-spacing: -.02em;
}
.rem-main { flex: 1; min-width: 0; }
.rem-name { font-size: .875rem; font-weight: 500; }
.rem-meta { font-size: .75rem; color: var(--text-3); margin-top: 1px; }
.rem.off .rem-time, .rem.off .rem-name { color: var(--muted); }

.pill-pro {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 9px; border-radius: var(--r-full);
  font-size: .625rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase;
  background: var(--accent); color: #fff;
}

/* Plan card */
.plan-card {
  border: 1px solid var(--border); border-radius: var(--r-lg);
  padding: var(--s5); background: var(--surface);
}
.plan-card.current { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.plan-price { font-size: 1.75rem; font-weight: 600; letter-spacing: -.03em; }
.plan-price .per { font-size: .875rem; font-weight: 500; color: var(--text-3); }
.plan-list { list-style: none; margin: var(--s4) 0 0; font-size: .8125rem; }
.plan-list li { display: flex; gap: 8px; padding: 4px 0; color: var(--text-2); }
.plan-list svg { width: 14px; height: 14px; color: var(--success); flex-shrink: 0; margin-top: 3px; }

/* Danger zone */
.danger-zone {
  border: 1px solid var(--danger); border-radius: var(--r-lg);
  background: var(--danger-soft); padding: var(--s5); margin-top: var(--s8);
}
.danger-zone h3 { color: var(--danger); font-size: .9375rem; margin-bottom: 4px; }
.danger-zone p  { font-size: .8125rem; color: var(--text-2); margin-bottom: var(--s4); }

.msg-inline {
  padding: 10px 13px; border-radius: var(--r); font-size: .8125rem;
  margin-bottom: var(--s4);
}
.msg-inline.ok  { background: var(--success-soft); color: var(--success); }
.msg-inline.err { background: var(--danger-soft);  color: var(--danger); }

/* ═══════════════ AUTH ═══════════════ */
.auth-wrap { min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr; }
@media (max-width: 900px) { .auth-wrap { grid-template-columns: 1fr; } .auth-aside { display: none; } }

.auth-main { display: flex; flex-direction: column; padding: var(--s6) var(--s8); }
.auth-form { width: 100%; max-width: 356px; margin: auto; padding: var(--s8) 0; }
.auth-form h1 { font-size: 1.5rem; margin-bottom: 5px; }
.auth-form .sub { color: var(--text-3); font-size: .9375rem; margin-bottom: var(--s6); }

.auth-aside {
  background: var(--surface); border-left: 1px solid var(--border);
  padding: var(--s16) var(--s10); display: flex; flex-direction: column; justify-content: center;
}
.auth-points { list-style: none; margin-top: var(--s6); }
.auth-points li { display: flex; gap: var(--s3); padding: var(--s3) 0; }
.auth-points svg { width: 18px; height: 18px; color: var(--accent); flex-shrink: 0; margin-top: 2px; }
.auth-points b { display: block; font-size: .9375rem; font-weight: 600; }
.auth-points span { font-size: .8125rem; color: var(--text-3); }

.pw-wrap { position: relative; }
.pw-eye {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  width: 28px; height: 28px; border-radius: var(--r-sm);
  display: grid; place-items: center; color: var(--text-3);
}
.pw-eye:hover { background: var(--surface-2); color: var(--text); }
.pw-eye svg { width: 16px; height: 16px; }

.auth-alt { text-align: center; font-size: .875rem; color: var(--text-3); margin-top: var(--s5); }
.auth-alt a { color: var(--accent); font-weight: 500; }

/* ═══════════════ ONBOARDING ═══════════════ */
.steps { display: flex; gap: 6px; margin-bottom: var(--s8); }
.step-dot { flex: 1; height: 3px; border-radius: 2px; background: var(--surface-3); transition: background .3s var(--ease); }
.step-dot.on { background: var(--accent); }

.choice-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s3); }
@media (max-width: 560px) { .choice-grid { grid-template-columns: 1fr; } }
.choice {
  display: flex; align-items: center; gap: var(--s3);
  padding: var(--s4); text-align: left;
  border: 1px solid var(--border); border-radius: var(--r-lg);
  background: var(--surface); transition: all .16s var(--ease);
}
.choice:hover { border-color: var(--border-2); }
.choice.on { border-color: var(--accent); background: var(--accent-soft); }
.choice-check {
  width: 20px; height: 20px; border-radius: 6px; flex-shrink: 0;
  border: 1.5px solid var(--border-2); display: grid; place-items: center;
}
.choice.on .choice-check { background: var(--accent); border-color: var(--accent); }
.choice-check svg { width: 12px; height: 12px; stroke-width: 3; color: #fff; opacity: 0; }
.choice.on .choice-check svg { opacity: 1; }
.choice-t { font-size: .9375rem; font-weight: 600; }
.choice-s { font-size: .75rem; color: var(--text-3); }

/* ═══════════════ LIBRARY ═══════════════ */
.lib-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(215px, 1fr)); gap: var(--s3); }
.lib-card {
  display: flex; flex-direction: column; gap: 7px;
  padding: var(--s4); text-align: left;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); transition: all .16s var(--ease);
}
.lib-card:hover { border-color: var(--accent); box-shadow: var(--sh-2); }
.lib-name { font-size: .9375rem; font-weight: 600; letter-spacing: -.01em; }
.lib-sum {
  font-size: .75rem; color: var(--text-3); line-height: 1.5;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.lib-foot { display: flex; flex-wrap: wrap; gap: 5px; margin-top: auto; padding-top: 5px; }

.filters { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: var(--s5); }
.filter {
  padding: 6px 13px; border-radius: var(--r-full);
  font-size: .8125rem; font-weight: 500; color: var(--text-2);
  background: var(--surface); border: 1px solid var(--border);
  transition: all .14s var(--ease);
}
.filter:hover  { border-color: var(--border-2); }
.filter.on { background: var(--text); color: var(--bg); border-color: var(--text); }

.lib-detail { max-width: 720px; }
.lib-detail h1 { font-size: 1.75rem; margin-bottom: 6px; }
.lib-aka { font-size: .875rem; color: var(--text-3); margin-bottom: var(--s4); }
.spec { display: grid; grid-template-columns: 152px 1fr; gap: var(--s3) var(--s5);
  padding: var(--s5) 0; border-top: 1px solid var(--border); }
@media (max-width: 620px) { .spec { grid-template-columns: 1fr; gap: 4px var(--s3); } }
.spec dt { font-size: .8125rem; font-weight: 600; color: var(--text-3); }
.spec dd { font-size: .875rem; line-height: 1.6; }
.caution-box {
  background: var(--warning-soft); border-radius: var(--r-lg);
  padding: var(--s4) var(--s5); margin-top: var(--s5);
}
.caution-box h3 { font-size: .875rem; color: var(--warning); margin-bottom: 6px; }
.caution-box p  { font-size: .875rem; color: var(--text-2); line-height: 1.65; }

/* ═══════════════ MARKETING ═══════════════ */
.hero { text-align: center; padding: var(--s16) 0 var(--s12); }
.hero h1 {
  font-size: clamp(2rem, 5vw, 3rem); letter-spacing: -.04em;
  line-height: 1.08; margin-bottom: var(--s4);
}
.hero h1 em { font-style: normal; color: var(--accent); }
.hero p { font-size: 1.0625rem; color: var(--text-2); max-width: 500px; margin: 0 auto var(--s6); line-height: 1.6; }
.hero-cta { display: flex; gap: var(--s3); justify-content: center; flex-wrap: wrap; }

.feature-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(238px, 1fr)); gap: var(--s4); }
.feature { padding: var(--s5); }
.feature-ico {
  width: 34px; height: 34px; border-radius: var(--r); margin-bottom: var(--s3);
  background: var(--accent-soft); color: var(--accent); display: grid; place-items: center;
}
.feature-ico svg { width: 17px; height: 17px; stroke-width: 1.75; }
.feature h3 { font-size: .9375rem; margin-bottom: 5px; }
.feature p  { font-size: .8125rem; color: var(--text-3); line-height: 1.6; }

.band { border-top: 1px solid var(--border); padding: var(--s16) 0; }
.band-head { text-align: center; max-width: 520px; margin: 0 auto var(--s8); }
.band-head h2 { font-size: 1.75rem; letter-spacing: -.03em; margin-bottom: var(--s3); }
.band-head p  { color: var(--text-3); font-size: .9375rem; }

.site-foot {
  border-top: 1px solid var(--border); padding: var(--s8) 0;
  display: flex; flex-wrap: wrap; gap: var(--s4); align-items: center;
  font-size: .8125rem; color: var(--text-3);
}
.site-foot a { color: var(--text-3); }
.site-foot a:hover { color: var(--accent); }

/* ═══════════════ LONG-FORM PROTOCOL GUIDE ═══════════════ */
.guide-wrap { display: grid; grid-template-columns: 216px minmax(0,1fr); gap: var(--s10); align-items: start; }
@media (max-width: 1000px) { .guide-wrap { grid-template-columns: 1fr; gap: var(--s5); } }

.toc { position: sticky; top: calc(var(--nav-h) + var(--s5)); max-height: calc(100vh - var(--nav-h) - var(--s10)); overflow-y: auto; }
.toc-title { font-size: .6875rem; font-weight: 600; letter-spacing: .09em; text-transform: uppercase;
  color: var(--text-3); margin-bottom: var(--s3); }
.toc a {
  display: block; padding: 5px 11px; border-left: 2px solid var(--border);
  font-size: .8125rem; color: var(--text-3); line-height: 1.45;
  transition: all .14s var(--ease);
}
.toc a:hover { color: var(--text); border-left-color: var(--border-2); }
.toc a.active { color: var(--accent); border-left-color: var(--accent); font-weight: 600; }
@media (max-width: 1000px) {
  .toc { position: static; max-height: none; }
  .toc-inner { display: flex; gap: 4px; overflow-x: auto; padding-bottom: var(--s2); scrollbar-width: none; }
  .toc-inner::-webkit-scrollbar { display: none; }
  .toc a { border-left: none; border: 1px solid var(--border); border-radius: var(--r-full);
           white-space: nowrap; padding: 5px 12px; }
  .toc a.active { background: var(--accent-soft); border-color: var(--accent-line); }
}

.guide { max-width: 720px; }
.guide h1 { font-size: clamp(1.5rem, 3.2vw, 2rem); letter-spacing: -.032em; line-height: 1.15; margin-bottom: var(--s3); }
.guide-intro { font-size: 1.0625rem; color: var(--text-2); line-height: 1.65; margin-bottom: var(--s4); }
.guide-byline { display: flex; flex-wrap: wrap; gap: var(--s3); font-size: .8125rem;
  color: var(--text-3); padding-bottom: var(--s5); border-bottom: 1px solid var(--border); }

.gsec { padding-top: var(--s10); scroll-margin-top: calc(var(--nav-h) + var(--s5)); }
.gsec > h2 { font-size: 1.375rem; letter-spacing: -.026em; margin-bottom: var(--s4); }
.gsec > h3 { font-size: 1rem; margin: var(--s6) 0 var(--s3); }
.gsec p { line-height: 1.7; margin-bottom: var(--s4); color: var(--text-2); }
.gsec p strong { color: var(--text); font-weight: 600; }
.gsec > ul { margin: 0 0 var(--s4) var(--s5); }
.gsec > ul li { line-height: 1.7; margin-bottom: 9px; color: var(--text-2); }

/* Quick-start definition grid */
.qs { display: grid; grid-template-columns: 138px minmax(0,1fr); gap: 0; }
@media (max-width: 620px) { .qs { grid-template-columns: 1fr; } }
.qs dt {
  font-size: .75rem; font-weight: 600; letter-spacing: .05em; text-transform: uppercase;
  color: var(--text-3); padding: var(--s4) var(--s4) var(--s4) 0; border-top: 1px solid var(--border);
}
.qs dd { padding: var(--s4) 0; border-top: 1px solid var(--border); font-size: .9375rem; line-height: 1.65; }
@media (max-width: 620px) {
  .qs dt { border-top: 1px solid var(--border); padding-bottom: 4px; }
  .qs dd { border-top: none; padding-top: 0; }
}

/* Data tables */
.gtable-wrap { overflow-x: auto; margin-bottom: var(--s4); border: 1px solid var(--border); border-radius: var(--r-lg); }
.gtable { width: 100%; border-collapse: collapse; font-size: .875rem; }
.gtable th {
  background: var(--surface-2); text-align: left; padding: 11px 15px;
  font-size: .6875rem; font-weight: 600; letter-spacing: .06em; text-transform: uppercase;
  color: var(--text-3); white-space: nowrap; border-bottom: 1px solid var(--border);
}
.gtable td { padding: 12px 15px; border-bottom: 1px solid var(--border); vertical-align: top; line-height: 1.55; }
.gtable tr:last-child td { border-bottom: none; }
.gtable td.num, .gtable th.num { font-variant-numeric: tabular-nums; }
.gtable td:first-child { font-weight: 500; color: var(--text); }
.gtable .note { color: var(--text-3); font-size: .8125rem; }
.gtable tr.hl td { background: var(--accent-soft); }

/* Callout blocks */
.note-box {
  border-left: 3px solid var(--border-2); border-radius: 0;
  padding: var(--s3) 0 var(--s3) var(--s4); margin-bottom: var(--s4);
  font-size: .875rem; color: var(--text-2); line-height: 1.65;
}
.note-box.accent  { border-left-color: var(--accent); }
.note-box.warning { border-left-color: var(--warning); }

.boundary {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: var(--s5); margin-bottom: var(--s4);
}
.boundary h3 {
  display: flex; align-items: center; gap: 8px;
  font-size: .875rem; color: var(--text); margin: 0 0 var(--s3);
}
.boundary h3 svg { width: 16px; height: 16px; color: var(--warning); }
.boundary p { font-size: .9375rem; line-height: 1.7; margin: 0; color: var(--text-2); }

.avoid-list { list-style: none; margin: 0; }
.avoid-list li {
  display: flex; gap: var(--s3); padding: var(--s3) 0;
  border-bottom: 1px solid var(--border); font-size: .9375rem; line-height: 1.65; color: var(--text-2);
}
.avoid-list li:last-child { border-bottom: none; }
.avoid-list svg { width: 16px; height: 16px; color: var(--danger); flex-shrink: 0; margin-top: 4px; }

.se-grid { display: grid; gap: var(--s4); }
.se-block h4 {
  font-size: .75rem; font-weight: 600; letter-spacing: .06em; text-transform: uppercase;
  margin-bottom: var(--s2);
}
.se-block.common   h4 { color: var(--text-3); }
.se-block.uncommon h4 { color: var(--warning); }
.se-block.serious  h4 { color: var(--danger); }
.se-block ul { margin: 0 0 0 var(--s5); }
.se-block li { font-size: .875rem; line-height: 1.65; color: var(--text-2); margin-bottom: 6px; }

/* Numbered steps */
.steps-list { list-style: none; counter-reset: st; margin: 0; }
.steps-list li { counter-increment: st; display: flex; gap: var(--s4); padding: var(--s4) 0;
  border-bottom: 1px solid var(--border); }
.steps-list li:last-child { border-bottom: none; }
.steps-list li::before {
  content: counter(st, decimal-leading-zero);
  flex-shrink: 0; width: 28px; height: 28px; border-radius: 8px;
  background: var(--surface-2); color: var(--text-3);
  display: grid; place-items: center;
  font-size: .75rem; font-weight: 600; font-variant-numeric: tabular-nums;
}
.steps-list b { display: block; font-size: .9375rem; margin-bottom: 3px; }
.steps-list span { font-size: .875rem; color: var(--text-2); line-height: 1.65; }

/* Timeline */
.tl { list-style: none; margin: 0; }
.tl li { display: grid; grid-template-columns: 128px minmax(0,1fr); gap: var(--s4);
  padding: var(--s3) 0; border-bottom: 1px solid var(--border); }
.tl li:last-child { border-bottom: none; }
.tl b { font-size: .8125rem; font-weight: 600; color: var(--accent); }
.tl span { font-size: .875rem; color: var(--text-2); line-height: 1.65; }
@media (max-width: 620px) { .tl li { grid-template-columns: 1fr; gap: 2px; } }

/* FAQ */
.faq details {
  border-bottom: 1px solid var(--border);
}
.faq summary {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s3);
  padding: var(--s4) 0; cursor: pointer; list-style: none;
  font-size: .9375rem; font-weight: 600;
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after {
  content: ''; width: 9px; height: 9px; flex-shrink: 0;
  border-right: 2px solid var(--text-3); border-bottom: 2px solid var(--text-3);
  transform: rotate(45deg) translateY(-2px); transition: transform .2s var(--ease);
}
.faq details[open] summary::after { transform: rotate(-135deg) translateY(-2px); }
.faq details p { font-size: .9375rem; line-height: 1.7; color: var(--text-2);
  padding-bottom: var(--s4); margin: 0; }

/* References */
.refs { list-style: none; margin: 0; counter-reset: rf; }
.refs li { counter-increment: rf; display: flex; gap: var(--s3); padding: var(--s3) 0;
  border-bottom: 1px solid var(--border); font-size: .875rem; }
.refs li:last-child { border-bottom: none; }
.refs li::before { content: counter(rf) '.'; color: var(--muted); flex-shrink: 0;
  font-variant-numeric: tabular-nums; }
.refs b { font-weight: 500; display: block; line-height: 1.5; }
.refs span { color: var(--text-3); font-size: .8125rem; }

/* Supplier slot — content-neutral placeholder until partners exist */
.supplier-slot {
  border: 1px dashed var(--border-2); border-radius: var(--r-lg);
  padding: var(--s5); text-align: center; color: var(--text-3); font-size: .875rem;
}

/* ═══════════════ UTILITIES ═══════════════ */
.hidden { display: none !important; }
.mt-2 { margin-top: var(--s2); } .mt-4 { margin-top: var(--s4); } .mt-6 { margin-top: var(--s6); }
.mb-2 { margin-bottom: var(--s2); } .mb-4 { margin-bottom: var(--s4); } .mb-6 { margin-bottom: var(--s6); }
.divider { height: 1px; background: var(--border); border: none; }

/* ═══════════════ MOTION / A11Y ═══════════════ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important; animation-iteration-count: 1 !important;
    transition-duration: .01ms !important; scroll-behavior: auto !important;
  }
}
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

/* ═══════════════ PRINT ═══════════════ */
@media print {
  :root { --bg:#fff; --surface:#fff; --text:#000; --border:#ccc; }
  .nav, .tabbar, .guru-fab, .toast, .btn, .dose-ask { display: none !important; }
  .page { max-width: 100%; padding: 0; }
  .card { border: 1px solid #ccc; box-shadow: none; break-inside: avoid; }
  body { padding-bottom: 0; }
}
