/* =========================================================================
   Flowers Law & Ethics
   Tokens are copied from the Flowers marketing site
   (Therapy Assistant/website/styles.css :root), which ports them from the
   app's DesignTokens.swift. Keep the light values in sync with that file.
   ========================================================================= */

:root {
  /* Brand */
  --pink:   #FFB5CC;
  --yellow: #FFF58C;
  --brand-gradient: linear-gradient(135deg, var(--pink) 0%, var(--yellow) 100%);
  --on-brand: #4A2238;

  /* Neutrals */
  --bg:     #FDF6F1;   /* --cream */
  --bg-2:   #FBEFE9;   /* --cream-2 */
  --paper:  #FFFFFF;
  --ink:    #2B2530;
  --ink-2:  #6A6270;
  --ink-3:  #8E8794;   /* a touch darker than the site's #9A93A0 for 4.5:1 on cream */
  --hair:   rgba(43, 37, 48, 0.08);
  --hair-2: rgba(43, 37, 48, 0.14);

  /* Pastel accents (one per BBS content area) */
  --blue:   #7FB1E3;
  --teal:   #6FC6C0;
  --purple: #B49BE0;
  --orange: #F2B57E;
  --rose:   #F5A0C0;
  --green:  #94CFA3;

  /* Text-safe accent shades (pastels are too light for text on cream) */
  --good:     #2E7D4F;
  --good-bg:  #E7F5EC;
  --bad:      #B23A5B;
  --bad-bg:   #FCE8EE;
  --warn-bg:  #FFF6D6;
  --link:     #B2456E;
  --nav-active: #D2557F;

  --r-sm: 8px;
  --r:    14px;
  --r-lg: 22px;
  --r-pill: 999px;

  --shadow-sm: 0 1px 2px rgba(43,37,48,.04), 0 2px 8px rgba(43,37,48,.04);
  --shadow:    0 4px 16px rgba(43,37,48,.06), 0 12px 36px rgba(43,37,48,.07);

  --font: -apple-system, "SF Pro Text", BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, monospace;

  --maxw: 680px;
  --side-w: 248px;
  --top-h: 52px;
  --tab-h: 58px;
  --fs: 17px;

  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:     #1C1820;
    --bg-2:   #231E28;
    --paper:  #2A2430;
    --ink:    #F4EDF0;
    --ink-2:  #C2B8C6;
    --ink-3:  #9B91A0;
    --hair:   rgba(255, 240, 248, 0.09);
    --hair-2: rgba(255, 240, 248, 0.16);
    --good:    #8FD9A8;
    --good-bg: #1F3328;
    --bad:     #F5A0BC;
    --bad-bg:  #3A2230;
    --warn-bg: #3A3420;
    --link:    #FFB5CC;
    --nav-active: var(--pink);
    --shadow-sm: none;
    --shadow:    0 6px 24px rgba(0,0,0,.35);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg:     #1C1820;
  --bg-2:   #231E28;
  --paper:  #2A2430;
  --ink:    #F4EDF0;
  --ink-2:  #C2B8C6;
  --ink-3:  #9B91A0;
  --hair:   rgba(255, 240, 248, 0.09);
  --hair-2: rgba(255, 240, 248, 0.16);
  --good:    #8FD9A8;
  --good-bg: #1F3328;
  --bad:     #F5A0BC;
  --bad-bg:  #3A2230;
  --warn-bg: #3A3420;
  --link:    #FFB5CC;
  --nav-active: var(--pink);
  --shadow-sm: none;
  --shadow:    0 6px 24px rgba(0,0,0,.35);
  color-scheme: dark;
}

:root[data-text="s"] { --fs: 15.5px; }
:root[data-text="l"] { --fs: 19px; }
:root[data-text="xl"] { --fs: 21px; }

/* ----------------------------------------------------------------- reset */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: var(--fs);
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}
h1, h2, h3, h4 { margin: 0; line-height: 1.2; letter-spacing: -0.015em; }
h1 { font-size: 1.6em; }
h2 { font-size: 1.22em; }
h3 { font-size: 1.05em; }
p { margin: 0; }
a { color: var(--link); }
button { font: inherit; color: inherit; cursor: pointer; }
img, svg { display: block; }
ul, ol { margin: 0; padding-left: 1.25em; }
:focus-visible { outline: 2.5px solid var(--rose); outline-offset: 2px; border-radius: 6px; }
[hidden] { display: none !important; }

.skip { position: absolute; left: -9999px; }
.skip:focus { left: 12px; top: 12px; z-index: 100; background: var(--paper); padding: 8px 12px; border-radius: var(--r-sm); }

/* --------------------------------------------------------------- chrome */
.topbar {
  position: sticky; top: 0; z-index: 20;
  height: calc(var(--top-h) + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) max(12px, env(safe-area-inset-right)) 0 max(12px, env(safe-area-inset-left));
  display: flex; align-items: center; gap: 6px;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: saturate(1.6) blur(16px);
  -webkit-backdrop-filter: saturate(1.6) blur(16px);
  border-bottom: 1px solid var(--hair);
}
.brand { display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--ink); font-weight: 700; font-size: 17px; min-width: 0; }
.brand img { border-radius: 7px; }
.brand span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 8px; font-variant-numeric: tabular-nums; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 50%;
  display: inline-grid; place-items: center;
  background: transparent; border: 0; color: var(--ink);
}
.icon-btn svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn:active { background: var(--hair); }

main {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 18px max(16px, env(safe-area-inset-right)) calc(var(--tab-h) + env(safe-area-inset-bottom) + 28px) max(16px, env(safe-area-inset-left));
  outline: none;
}
main:focus-visible { outline: none; } /* focused on each route change for screen readers */
body.immersive main { padding-bottom: calc(env(safe-area-inset-bottom) + 28px); }
body.immersive .tabbar { display: none; }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  height: calc(var(--tab-h) + env(safe-area-inset-bottom));
  padding: 4px max(4px, env(safe-area-inset-right)) env(safe-area-inset-bottom) max(4px, env(safe-area-inset-left));
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.6) blur(16px);
  -webkit-backdrop-filter: saturate(1.6) blur(16px);
  border-top: 1px solid var(--hair);
}
.tabbar a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  text-decoration: none; color: var(--ink-3); font-size: 11px; font-weight: 600; letter-spacing: .01em;
  border-radius: var(--r);
}
.tabbar svg { width: 25px; height: 25px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tabbar a[aria-current="page"] { color: var(--ink); }
.tabbar a[aria-current="page"] svg { stroke: var(--nav-active); }

.loading { color: var(--ink-3); text-align: center; padding: 40px 0; }
.noscript { padding: 24px; }

/* ------------------------------------------------------------ building blocks */
.stack > * + * { margin-top: 14px; }
.stack-lg > * + * { margin-top: 22px; }
.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.spacer { flex: 1; }
.muted { color: var(--ink-2); }
.small { font-size: .86em; }
.tiny { font-size: .76em; }
.center { text-align: center; }
.num { font-variant-numeric: tabular-nums; }

.page-head { margin-bottom: 18px; }
.page-head h1 + p { margin-top: 6px; color: var(--ink-2); }

.eyebrow {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 12px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--ink-2);
}
.eyebrow .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--brand-gradient); }

.card {
  background: var(--paper);
  border: 1px solid var(--hair);
  border-radius: var(--r-lg);
  padding: 18px;
  box-shadow: var(--shadow-sm);
}
.card.tight { padding: 14px; }
.card.hero { background: var(--brand-gradient); color: var(--on-brand); border: 0; }
.card.hero .muted { color: rgba(74, 34, 56, .75); }
a.card { display: block; color: inherit; text-decoration: none; }
a.card:active, button.card:active { transform: scale(.99); }
button.card { width: 100%; text-align: left; font: inherit; }

.list { list-style: none; padding: 0; margin: 0; background: var(--paper); border: 1px solid var(--hair); border-radius: var(--r-lg); overflow: hidden; }
.list > li + li { border-top: 1px solid var(--hair); }
.list a, .list button.li {
  display: flex; align-items: center; gap: 12px;
  min-height: 54px; padding: 12px 16px;
  color: var(--ink); text-decoration: none; background: none; border: 0; width: 100%; text-align: left;
}
.list .chev { margin-left: auto; color: var(--ink-3); }
.list .li-sub { display: block; font-size: .82em; color: var(--ink-2); }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 360px) { .grid-2 { grid-template-columns: 1fr; } }

/* --------------------------------------------------------------- buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 12px 20px;
  border-radius: var(--r-pill); border: 1px solid transparent;
  font-weight: 650; font-size: 1em; line-height: 1.1; text-decoration: none;
  transition: transform .15s ease;
}
.btn:active { transform: scale(.98); }
.btn.block { width: 100%; }
.btn-primary { background: var(--brand-gradient); color: var(--on-brand); box-shadow: 0 6px 18px rgba(255,150,185,.35); }
.btn-ghost { background: var(--paper); color: var(--ink); border-color: var(--hair-2); }
.btn-quiet { background: transparent; color: var(--ink-2); }
.btn-danger { background: var(--bad-bg); color: var(--bad); }
.btn[disabled] { opacity: .45; pointer-events: none; }
.btn-sm { min-height: 38px; padding: 8px 14px; font-size: .9em; }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 12px; min-height: 36px;
  border-radius: var(--r-pill); border: 1px solid var(--hair-2);
  background: var(--paper); color: var(--ink); font-size: .88em; font-weight: 600;
}
.chip[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }

.tag {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 700; letter-spacing: .02em;
  padding: 3px 9px; border-radius: var(--r-pill);
  background: var(--bg-2); color: var(--ink-2);
}
.tag .sw { width: 8px; height: 8px; border-radius: 50%; background: var(--area, var(--ink-3)); }
.tag-exam { background: var(--brand-gradient); color: var(--on-brand); }

/* area colors */
[data-area="1A"] { --area: var(--blue); }
[data-area="1B"] { --area: var(--rose); }
[data-area="1C"] { --area: var(--orange); }
[data-area="2A"] { --area: var(--purple); }
[data-area="2B"] { --area: var(--teal); }
[data-area="2C"] { --area: var(--green); }

/* ------------------------------------------------------------ progress */
.bar { height: 8px; border-radius: var(--r-pill); background: var(--bg-2); overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: inherit; background: var(--area, var(--brand-gradient)); }
.area-row { display: grid; grid-template-columns: 1fr auto; gap: 6px 10px; align-items: center; }
.area-row .bar { grid-column: 1 / -1; }
.area-row .area-cov { grid-column: 1 / -1; }
a.area-row { padding: 6px 0; color: inherit; text-decoration: none; }

.stat { display: flex; flex-direction: column; gap: 2px; }
.stat b { font-size: 1.6em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat span { font-size: .8em; color: var(--ink-2); }

.ring { --p: 0; width: 92px; height: 92px; border-radius: 50%; display: grid; place-items: center;
  background: conic-gradient(#E98AB0 calc(var(--p) * 1%), var(--hair) 0); }
.ring > div { width: 74px; height: 74px; border-radius: 50%; background: var(--paper); display: grid; place-items: center; font-weight: 800; font-size: 1.25em; }
.card.hero .ring { background: conic-gradient(var(--on-brand) calc(var(--p) * 1%), rgba(74,34,56,.15) 0); }
.card.hero .ring > div { background: rgba(255,255,255,.75); color: var(--on-brand); }

/* ------------------------------------------------------------ questions */
.q-meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 10px; }
.q-stem { font-size: 1.04em; line-height: 1.55; }
.q-stem p + p { margin-top: .6em; }
.choices { list-style: none; padding: 0; margin: 16px 0 0; display: grid; gap: 10px; }
.choice {
  width: 100%; text-align: left;
  display: grid; grid-template-columns: 30px 1fr; gap: 10px; align-items: start;
  padding: 13px 14px; min-height: 52px;
  background: var(--paper); border: 1.5px solid var(--hair-2); border-radius: var(--r);
  font: inherit; color: var(--ink); line-height: 1.4;
}
.choice .letter {
  width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center;
  font-weight: 700; font-size: .85em; background: var(--bg-2); color: var(--ink-2);
}
.choice[aria-pressed="true"] { border-color: var(--ink); }
.choice[aria-pressed="true"] .letter { background: var(--ink); color: var(--bg); }
.choice.correct { border-color: var(--good); background: var(--good-bg); }
.choice.correct .letter { background: var(--good); color: var(--paper); }
.choice.wrong { border-color: var(--bad); background: var(--bad-bg); }
.choice.wrong .letter { background: var(--bad); color: var(--paper); }
.choice[disabled] { cursor: default; }
.choice .why { grid-column: 2; font-size: .86em; color: var(--ink-2); margin-top: 4px; }

.explain { border-left: 4px solid var(--area, var(--pink)); }
.explain h3 { display: flex; align-items: center; gap: 8px; }
.verdict-good { color: var(--good); }
.verdict-bad { color: var(--bad); }
.cites { list-style: none; padding: 0; display: grid; gap: 6px; }
.cites li { font-size: .86em; color: var(--ink-2); }
.cites a { font-weight: 600; }

.sticky-actions {
  position: sticky; bottom: calc(var(--tab-h) + env(safe-area-inset-bottom) + 8px);
  display: flex; gap: 10px; margin-top: 18px;
  padding: 10px; border-radius: var(--r-pill);
  background: color-mix(in srgb, var(--bg) 80%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
}
body.immersive .sticky-actions { bottom: calc(env(safe-area-inset-bottom) + 8px); }
.sticky-actions .btn { flex: 1; }

/* ------------------------------------------------------------ flashcards */
.flash-wrap { perspective: 1400px; }
.flash {
  position: relative; min-height: 300px; width: 100%;
  border: 0; padding: 0; background: none; text-align: left; font: inherit; color: inherit;
  transform-style: preserve-3d; transition: transform .45s cubic-bezier(.2,.7,.2,1);
  touch-action: pan-y;
}
.flash.flipped { transform: rotateY(180deg); }
.flash .face {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; gap: 12px;
  padding: 22px; border-radius: var(--r-lg);
  background: var(--paper); border: 1px solid var(--hair); box-shadow: var(--shadow);
  backface-visibility: hidden; -webkit-backface-visibility: hidden;
  overflow-y: auto;
}
.flash .back { transform: rotateY(180deg); }
.flash .face .big { font-size: 1.18em; font-weight: 650; line-height: 1.4; margin: auto 0; }
.flash .face .ans { line-height: 1.5; }
.flash .hint { margin-top: auto; font-size: .78em; color: var(--ink-3); text-align: center; }
.grades { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 16px; }
.grades .btn { flex-direction: column; gap: 2px; min-height: 58px; padding: 8px 4px; border-radius: var(--r); font-size: .9em; }
.grades .btn small { font-weight: 500; font-size: .78em; opacity: .75; }
.g-again { background: var(--bad-bg); color: var(--bad); }
.g-hard { background: var(--warn-bg); color: var(--ink); }
.g-good { background: var(--good-bg); color: var(--good); }
.g-easy { background: var(--paper); border-color: var(--hair-2) !important; color: var(--ink); }
@media (prefers-reduced-motion: reduce) { .flash { transition: none; } }

/* ------------------------------------------------------------ exam */
.timer { font-weight: 700; padding: 6px 12px; border-radius: var(--r-pill); background: var(--paper); border: 1px solid var(--hair-2); font-size: .95em; }
.timer.low { background: var(--bad-bg); color: var(--bad); border-color: transparent; }
.navgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(44px, 1fr)); gap: 8px; }
.navgrid button {
  height: 44px; border-radius: 12px; border: 1.5px solid var(--hair-2); background: var(--paper);
  font-weight: 650; font-variant-numeric: tabular-nums; position: relative;
}
.navgrid button.answered { background: var(--bg-2); border-color: transparent; }
.navgrid button.flagged::after { content: ""; position: absolute; top: 4px; right: 4px; width: 8px; height: 8px; border-radius: 50%; background: #E98AB0; }
.navgrid button.current { border-color: var(--ink); }
.navgrid button.right { background: var(--good-bg); color: var(--good); border-color: transparent; }
.navgrid button.miss { background: var(--bad-bg); color: var(--bad); border-color: transparent; }
.navgrid button.current.right, .navgrid button.current.miss { border-color: var(--ink); }
.pace { font-size: .86em; padding: 10px 14px; border-radius: var(--r); background: var(--bg-2); }

/* ------------------------------------------------------------ reference */
.ref-body h3 { margin-top: 1.1em; }
.ref-body p, .ref-body ul, .ref-body ol { margin-top: .55em; }
.ref-body li + li { margin-top: .3em; }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin-top: .8em; border-radius: var(--r); border: 1px solid var(--hair); }
table { border-collapse: collapse; width: 100%; font-size: .88em; background: var(--paper); }
th, td { text-align: left; vertical-align: top; padding: 10px 12px; border-bottom: 1px solid var(--hair); }
th { background: var(--bg-2); font-weight: 700; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
/* Phones: tables with 3+ columns become stacked cards, each cell labeled by its column. */
@media (max-width: 560px) {
  .table-wrap.stack-sm { overflow: visible; border: 0; }
  .table-wrap.stack-sm table, .table-wrap.stack-sm tbody, .table-wrap.stack-sm tr,
  .table-wrap.stack-sm th, .table-wrap.stack-sm td { display: block; width: 100%; }
  .table-wrap.stack-sm thead { display: none; }
  .table-wrap.stack-sm table { background: none; }
  .table-wrap.stack-sm tr { background: var(--paper); border: 1px solid var(--hair); border-radius: var(--r); margin-bottom: 10px; overflow: hidden; }
  .table-wrap.stack-sm th[scope="row"] { background: var(--bg-2); white-space: normal; }
  .table-wrap.stack-sm td { border-bottom: 1px solid var(--hair); }
  .table-wrap.stack-sm td:last-child { border-bottom: 0; }
  .table-wrap.stack-sm td::before { content: attr(data-label); display: block; font-size: .78em; font-weight: 700; color: var(--ink-3); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 2px; }
  .table-wrap.stack-sm td[data-label=""]::before { display: none; }
}
.callout { padding: 12px 14px; border-radius: var(--r); background: var(--warn-bg); font-size: .92em; }
.callout.info { background: var(--bg-2); }
mark { background: color-mix(in srgb, var(--yellow) 70%, transparent); color: inherit; border-radius: 3px; padding: 0 2px; }

/* ------------------------------------------------------------ forms */
.field { display: grid; gap: 6px; }
.field label { font-weight: 650; font-size: .92em; }
input[type="search"], input[type="date"], input[type="number"], select, textarea {
  font: inherit; color: var(--ink); background: var(--paper);
  border: 1.5px solid var(--hair-2); border-radius: var(--r); padding: 12px 14px; min-height: 48px; width: 100%;
}
input[type="search"] { -webkit-appearance: none; appearance: none; }
.seg { display: inline-flex; padding: 3px; border-radius: var(--r-pill); background: var(--bg-2); gap: 2px; flex-wrap: wrap; }
.seg button { border: 0; background: none; padding: 8px 14px; border-radius: var(--r-pill); font-weight: 650; font-size: .9em; color: var(--ink-2); min-height: 38px; }
.seg button[aria-pressed="true"] { background: var(--paper); color: var(--ink); box-shadow: var(--shadow-sm); }

/* ------------------------------------------------------------ footer + toast */
.disclaimer {
  margin-top: 34px; padding-top: 14px; border-top: 1px solid var(--hair);
  font-size: .76em; color: var(--ink-3); line-height: 1.5;
}
.disclaimer a { color: inherit; }
.toast {
  position: fixed; left: 50%; bottom: calc(var(--tab-h) + env(safe-area-inset-bottom) + 14px); z-index: 50;
  transform: translate(-50%, 20px); opacity: 0; transition: all .25s ease;
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: var(--r-pill); font-size: .9em; font-weight: 600;
  max-width: calc(100vw - 32px);
}
.toast.show { transform: translate(-50%, 0); opacity: 1; }

dialog {
  border: 0; border-radius: var(--r-lg); padding: 22px; max-width: min(420px, calc(100vw - 32px));
  background: var(--paper); color: var(--ink); box-shadow: var(--shadow);
}
dialog::backdrop { background: rgba(20, 15, 22, .45); }

/* Flowers mentions stay small and below the study content. */
.flowers-note { margin-top: 22px; padding-top: 14px; border-top: 1px solid var(--hair); }
.flowers-card img { border-radius: 7px; }
.sb-flowers { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; padding: 6px 10px; border-radius: 12px; color: var(--ink-2); text-decoration: none; }
.sb-flowers img { border-radius: 6px; flex: none; }
.sb-flowers b { display: block; font-size: 13px; color: var(--ink); }
.sb-flowers small { display: block; font-size: 12px; line-height: 1.35; }
.sb-flowers:hover { background: var(--hair); }

/* "New here?" line on Home: one line until opened */
.welcome-line { display: flex; align-items: flex-start; gap: 6px; padding: 4px 4px 4px 14px; border-radius: var(--r); background: var(--bg-2); }
.welcome-line details { flex: 1; min-width: 0; padding: 8px 0; }
.welcome-line summary { cursor: pointer; font-size: .92em; font-weight: 600; color: var(--ink-2); }
.welcome-line ol { display: grid; gap: 6px; margin-top: 10px; }
.welcome-line .btn { min-height: 34px; padding: 6px 10px; }

/* Install the app */
.install-card img { border-radius: 8px; flex: none; }
.install-steps { list-style: none; padding: 0; display: grid; gap: 12px; }
.install-steps li { display: flex; align-items: center; gap: 12px; }
.install-steps .ico { width: 40px; height: 40px; flex: none; display: grid; place-items: center; border-radius: 12px; background: var(--bg-2); color: var(--link); }
.install-steps svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.install-steps img { border-radius: 6px; }

.empty { text-align: center; padding: 28px 12px; color: var(--ink-2); }
.empty .big-emoji { font-size: 40px; margin-bottom: 6px; }

button.toast { border: 0; font: inherit; font-weight: 600; font-size: .9em; }

/* ------------------------------------------------------------ home */
.home-hero { padding: 16px 18px; }
.home-hero h1 { font-size: 1.35em; margin-top: 6px; }
.home-hero p { margin-top: 4px; }
.home-hero .ring { width: 66px; height: 66px; flex: none; }
.home-hero .ring > div { width: 52px; height: 52px; font-size: .95em; }

.plan-card h2, .progress-card h2 { font-size: 1.1em; }
.plan-steps { list-style: none; padding: 0; margin: 12px 0 14px; display: grid; gap: 4px; }
.plan-step { display: flex; gap: 12px; align-items: flex-start; padding: 10px; border-radius: 14px; color: inherit; text-decoration: none; }
.plan-step .dot { width: 28px; height: 28px; flex: none; display: grid; place-items: center; border-radius: 50%; background: var(--bg-2); color: var(--ink-2); font-weight: 750; font-size: .85em; }
.plan-step > span:last-child { flex: 1; min-width: 0; }
.plan-step strong { display: block; font-size: .98em; }
.plan-step .sub { display: block; margin-top: 1px; font-size: .8em; color: var(--ink-2); }
.plan-step .bar { display: block; height: 6px; margin-top: 6px; }
.plan-step.now { background: color-mix(in srgb, var(--pink) 18%, var(--paper)); }
.plan-step.now .dot { background: var(--ink); color: var(--paper); }
.plan-step.done strong { color: var(--ink-2); font-weight: 600; }
.plan-step.done .dot { background: var(--good-bg); color: var(--good); }
.plan-done { text-align: center; padding: 4px 0 2px; }
.plan-done .big { font-size: 34px; line-height: 1.2; }
.plan-done p { margin-top: 4px; }
.plan-more-label { margin: 0 0 8px 2px; }
.plan-more { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.plan-more .btn { min-height: 44px; padding: 8px 10px; font-size: .9em; }
.plan-date { display: flex; align-items: center; gap: 10px; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--hair); color: inherit; text-decoration: none; font-size: .9em; }
.plan-date .chev { margin-left: auto; color: var(--ink-3); }

.progress-head { display: flex; align-items: center; gap: 14px; }
.progress-head .ring { width: 70px; height: 70px; flex: none; }
.progress-head .ring > div { width: 56px; height: 56px; font-size: 1em; }
.weak-callout { display: flex; align-items: center; gap: 10px; margin-top: 12px; padding: 10px 12px; border-radius: 12px; background: var(--bg-2); color: inherit; text-decoration: none; font-size: .88em; }
.weak-callout strong { color: var(--link); }
.progress-card details { margin-top: 12px; }
.progress-card summary { cursor: pointer; font-size: .9em; font-weight: 650; color: var(--link); }
.progress-card details[open] summary { margin-bottom: 6px; }

/* ------------------------------------------------------------ desktop
   Below 1024px nothing here applies: phones and tablets keep the tab bar.
   From 1024px a sidebar replaces the tab bar. From 1180px question views put
   the explanation beside the question (SPLIT_MQ in components.js must match). */
.sidebar, .exam-rail, .kbd-hint, .split-only { display: none; }
.narrow { max-width: 560px; margin-inline: auto; }
.home-top > * + * { margin-top: 22px; }
/* Until the split kicks in, the wrappers drop out of layout so the action bar
   stays sticky against the whole question view, as it always has on phones. */
.split, .split-side { display: contents; }
.split-side > .explain { margin-top: 14px; }
kbd {
  display: inline-block; min-width: 1.7em; padding: 3px 6px;
  font: 650 11.5px/1.2 var(--font); text-align: center; color: var(--ink-2);
  background: var(--paper); border: 1px solid var(--hair-2); border-bottom-width: 2px; border-radius: 6px;
}

@media (max-width: 1023.98px) { .desk-only { display: none !important; } }

@media (min-width: 1024px) {
  :root { --maxw: 780px; }
  body.wide { --maxw: 1120px; }
  body { padding-left: var(--side-w); }
  body.immersive { padding-left: 0; }
  .tabbar, .mobile-only, .grid-btn { display: none !important; }

  /* The top bar only holds a back button, title, or exam timer here, so it
     hides when a view has none of those, and lines up with the content column. */
  body.bare .topbar { display: none; }
  .topbar { padding: 0 max(16px, calc((100% - var(--maxw)) / 2 + 28px)); }
  body:not(.immersive) .topbar .brand img { display: none; }

  main, body.immersive main { padding: 30px 40px 56px; }
  .sticky-actions, body.immersive .sticky-actions { bottom: 16px; }
  .toast { bottom: 24px; }

  .sidebar {
    display: flex; flex-direction: column;
    position: fixed; top: 0; bottom: 0; left: 0; z-index: 25; width: var(--side-w);
    padding: 18px 14px; overflow-y: auto;
    background: var(--bg-2); border-right: 1px solid var(--hair);
  }
  body.immersive .sidebar { display: none; }
  .sidebar svg { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
  .sb-brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 16px; color: var(--ink); font-weight: 750; font-size: 17px; text-decoration: none; }
  .sb-brand img { border-radius: 8px; }
  .sb-search {
    display: flex; align-items: center; gap: 8px; margin-bottom: 14px; padding: 8px 10px;
    border-radius: 12px; background: var(--paper); border: 1px solid var(--hair);
    color: var(--ink-3); font-size: 14px; text-decoration: none;
  }
  .sb-search kbd { margin-left: auto; }
  .sidebar nav a, .sb-foot > a:not(.sb-exam) {
    display: flex; align-items: center; gap: 11px; min-height: 40px; padding: 8px 10px;
    border-radius: 12px; color: var(--ink-2); font-weight: 600; font-size: 15px; text-decoration: none;
  }
  .sidebar nav a:hover, .sb-foot > a:not(.sb-exam):hover { background: var(--hair); color: var(--ink); }
  .sidebar a[aria-current="page"] { background: var(--paper); color: var(--ink); box-shadow: var(--shadow-sm); }
  .sidebar a[aria-current="page"] svg { stroke: var(--nav-active); }
  .sb-count {
    margin-left: auto; padding: 1px 8px; border-radius: var(--r-pill);
    background: var(--paper); border: 1px solid var(--hair);
    font-size: 12px; font-weight: 700; color: var(--ink-2); font-variant-numeric: tabular-nums;
  }
  .sb-label { padding: 18px 10px 6px; font-size: 11.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3); }
  .sb-foot { margin-top: auto; padding-top: 16px; display: grid; gap: 2px; }
  .sb-exam {
    display: block; margin-bottom: 10px; padding: 14px;
    border-radius: 16px; background: var(--paper); border: 1px solid var(--hair);
    color: var(--ink); text-decoration: none; font-size: 13px;
  }
  .sb-exam:hover { border-color: var(--hair-2); }
  .sb-exam b { display: block; font-size: 22px; line-height: 1.25; }
  .sb-exam b.cta { font-size: 16px; margin: 2px 0; }
  .sb-exam .bar { height: 6px; margin-top: 10px; }

  @media (hover: hover) and (pointer: fine) { .kbd-hint { display: block; margin-top: 12px; } }

  /* Home */
  .home-top { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 18px; align-items: start; }
  .home-top > * + * { margin-top: 0; }
  .home-hero { padding: 24px 30px; }
  .home-hero h1 { font-size: 1.6em; }
  .home-hero .ring { width: 96px; height: 96px; }
  .home-hero .ring > div { width: 78px; height: 78px; font-size: 1.3em; }
  .home-tools .tool-list { display: grid; grid-template-columns: 1fr 1fr; column-gap: 28px; }
  .home-tools .tool-list li:nth-child(2) { border-top: 0; }
  .areas-table .area-row { grid-template-columns: minmax(0, 13em) minmax(0, 1fr) 3.4em; column-gap: 16px; }
  .areas-table .area-row .bar { grid-column: 2; grid-row: 1; }
  .areas-table .area-row > :nth-child(2) { grid-column: 3; grid-row: 1; text-align: right; }
  .areas-table .area-row + .area-row { border-top: 1px solid var(--hair); padding-top: 10px; }
  .tool-list { list-style: none; padding: 0; }
  .tool-list li + li { border-top: 1px solid var(--hair); }
  .tool-list a { display: flex; align-items: center; gap: 12px; padding: 11px 0; color: var(--ink); text-decoration: none; }
  .tool-list .ico { width: 34px; height: 34px; flex: none; display: grid; place-items: center; border-radius: 10px; background: var(--bg-2); font-size: 18px; }
  .tool-list .chev { margin-left: auto; color: var(--ink-3); }
  .tool-list .li-sub { display: block; font-size: .82em; color: var(--ink-2); }

  /* Mock exam: question on the left, a navigator you can always see on the right */
  .exam-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 28px; align-items: start; }
  .exam-rail {
    display: grid; gap: 14px;
    position: sticky; top: calc(var(--top-h) + 18px);
    max-height: calc(100vh - var(--top-h) - 36px); overflow-y: auto;
  }
  .exam-rail h2 { font-size: 1em; }
  .exam-rail .navgrid { grid-template-columns: repeat(auto-fill, minmax(36px, 1fr)); gap: 6px; }
  .exam-rail .navgrid button { height: 36px; border-radius: 10px; font-size: .85em; }
}

@media (min-width: 1180px) {

  .split { display: grid; grid-template-columns: minmax(0, 1.08fr) minmax(0, 1fr); gap: 24px; align-items: start; }
  .split-side { display: block; }
  .split-side > .explain { margin-top: 0; }
  .split-only { display: block; }
  .pending { color: var(--ink-2); font-size: .92em; border-style: dashed; box-shadow: none; background: transparent; }
}
