/* ============================================================================
   PostMaker · app.css

   Tokens and component styles are copied from the approved design,
   docs/design/screens.html (v2). The design file draws five phone frames on a
   presentation stage; this stylesheet drops the .page/.row/figure/.phone stage
   wrappers and styles the real app instead: one full height column
   (100dvh, max 640px, centred) that scrolls its own content.

   ---------------------------------------------------------------------------
   ID CONTRACT (public/app.js, public/card.js, public/history.js,
   public/settings.js). Every id the front end touches is listed here. The
   templates are cloned into #view, so their ids exist only while the view is
   mounted.

   App shell (index.html)
     #app                the shell column
     #appbar             header; app.js swaps brand/title/buttons per view
     #appbar-cancel      icon button, X mark       (writing view)
     #appbar-back        icon button, chevron      (review + card views)
     #appbar-brand       wordmark "PostMaker"      (write view)
     #appbar-title       small title text          (every other view)
     #appbar-action      icon button, write again  (review view)
     #view               <main>; app.js clones a template into it
     #actions            bottom action bar; hidden except on the review view
     #action-linkedin    "Post to LinkedIn"
     #action-x           "Open in X"
     #action-share       icon button, copy/share sheet
     #navbar             bottom nav; the active link carries class "on"
     #snackbar           toast (role=status)
     #snackbar-text      toast message
     #snackbar-action    toast action button (optional)
     #sheet              bottom sheet container
     #sheet-scrim        dimmed backdrop, tap closes the sheet
     #sheet-body         sheet content, filled by ui.openSheet()

   Templates
     #tpl-login          #tpl-write     #tpl-writing  #tpl-review
     #tpl-card           #tpl-history   #tpl-settings
   Every template holds one root section, id #view-<name>:
     #view-login  #view-write  #view-writing  #view-review  #view-card
     #view-history  #view-settings

   Login view
     #login-form  #login-password  #login-error  #login-submit
   Write view
     #write-source  #write-box  #write-detected  #write-detected-avatar
     #write-detected-name  #write-detected-meta
     #write-length  #write-length-label  #write-ending  #write-ending-label
     #write-keyword-field  #write-keyword
     #write-angle  #write-submit  #write-hint
   Writing view
     #writing-progress  #writing-progress-bar  #writing-src  #writing-avatar
     #writing-name  #writing-meta  #writing-text  #writing-meta-row
     #writing-steps  #writing-retry
   Review view
     #review-tabs  #review-part  #review-edit  #review-verdict  #review-score
     #review-grade  #review-note  #review-proof  #review-editor
     #review-hooks  #review-counts  #review-count-li  #review-count-x
     #review-count-premium  #review-notes  #review-comment
     #review-comment-copy
   Card view
     #card-canvas  #card-styles  #card-light  #card-dark  #card-headline
     #card-highlight  #card-stat  #card-stat-label  #card-save  #card-share
     #card-attach
   History view
     #history-list  #history-empty  #history-write  #history-more
   Settings view
     #settings-linkedin  #settings-linkedin-state  #settings-linkedin-sub
     #settings-x-sub
     #settings-voice  #settings-voice-sub  #settings-cta  #settings-cta-sub
     #settings-name  #settings-name-sub  #settings-handle  #settings-handle-sub
     #settings-emoji  #settings-links  #settings-premium  #settings-autogen
     #settings-hashtags  #settings-hashtags-sub  #settings-banned
     #settings-banned-sub  #settings-version  #settings-signout
   ---------------------------------------------------------------------------
   ============================================================================ */

/* ---------- tokens (Material colour roles) ---------- */
:root {
  --ground: #EEF1F5;
  --c-low: #F7F9FB;
  --c: #E6EAF0;
  --c-high: #DCE2EA;
  --on: #121722;
  --on-var: #465061;
  --outline: #6F7A8B;
  --outline-var: #CCD3DD;
  --primary: #2340E0;
  --on-primary: #FFFFFF;
  --p-cont: #DCE2FF;
  --on-p-cont: #0D1E7A;
  --pencil: #C7E6F0;
  --on-pencil: #0A4558;
  --good: #1B7A45;
  --warn: #8F5600;
  --error: #B3261E;
  --scrim: rgba(18, 23, 34, .32);
  --display: "Bricolage Grotesque", "Hanken Grotesk", system-ui, sans-serif;
  --body: "Hanken Grotesk", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, Consolas, monospace;
  --ease: cubic-bezier(.2, 0, 0, 1);
  --shell: 640px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ground: #0E1219;
    --c-low: #151A23;
    --c: #1B212C;
    --c-high: #242B37;
    --on: #E3E7EE;
    --on-var: #A6AFBE;
    --outline: #7E8899;
    --outline-var: #343C4A;
    --primary: #9DACFF;
    --on-primary: #0B1A66;
    --p-cont: #26378F;
    --on-p-cont: #DDE2FF;
    --pencil: #173E4B;
    --on-pencil: #A9DDEC;
    --good: #6CCB94;
    --warn: #E5A84B;
    --error: #F2B8B5;
    --scrim: rgba(0, 0, 0, .5);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --ground: #0E1219;
  --c-low: #151A23;
  --c: #1B212C;
  --c-high: #242B37;
  --on: #E3E7EE;
  --on-var: #A6AFBE;
  --outline: #7E8899;
  --outline-var: #343C4A;
  --primary: #9DACFF;
  --on-primary: #0B1A66;
  --p-cont: #26378F;
  --on-p-cont: #DDE2FF;
  --pencil: #173E4B;
  --on-pencil: #A9DDEC;
  --good: #6CCB94;
  --warn: #E5A84B;
  --error: #F2B8B5;
  --scrim: rgba(0, 0, 0, .5);
  color-scheme: dark;
}

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

[hidden] { display: none !important; }

html {
  height: 100%;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--ground);
  color: var(--on);
  font: 1rem/1.5 var(--body);
  caret-color: var(--primary);
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}

::selection { background: var(--pencil); color: var(--on-pencil); }

button, input, textarea, select {
  font: inherit;
  color: inherit;
  margin: 0;
}

button {
  background: transparent;
  border: 0;
  padding: 0;
  touch-action: manipulation;
}

:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

html, .content, .sheet-panel {
  scrollbar-width: thin;
  scrollbar-color: var(--outline-var) transparent;
}

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--outline-var);
  border: 2px solid transparent;
  border-radius: 6px;
  background-clip: content-box;
}

/* ---------- app shell ---------- */
.app {
  height: 100vh;
  height: 100dvh;
  max-width: var(--shell);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--ground);
}

.appbar {
  flex: none;
  display: flex;
  align-items: center;
  gap: 4px;
  min-height: 64px;
  padding: calc(8px + env(safe-area-inset-top, 0px)) 6px 4px 6px;
}

.appbar .title {
  flex: 1;
  min-width: 0;
  font: 700 1.375rem/1 var(--display);
  letter-spacing: -.02em;
  padding-left: 12px;
}

.appbar .title.sm {
  font: 600 1.125rem/1.2 var(--body);
  letter-spacing: 0;
  padding-left: 4px;
}

.wm i { font-style: normal; color: var(--primary); }

.ib {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: transparent;
  display: grid;
  place-items: center;
  cursor: pointer;
  flex: none;
}

.ib:hover { background: color-mix(in srgb, var(--on) 8%, transparent); }

svg.i {
  width: 24px;
  height: 24px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.content {
  flex: 1;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 4px max(16px, env(safe-area-inset-right, 0px)) 20px max(16px, env(safe-area-inset-left, 0px));
}

.view {
  display: flex;
  flex-direction: column;
  gap: 20px;
  min-width: 0;
}

.navbar {
  flex: none;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  background: var(--c);
  padding-top: 12px;
  padding-right: max(8px, env(safe-area-inset-right, 0px));
  padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  padding-left: max(8px, env(safe-area-inset-left, 0px));
}

.navbar a {
  display: grid;
  justify-items: center;
  gap: 4px;
  text-decoration: none;
  color: var(--on-var);
  font-weight: 600;
  font-size: .75rem;
  min-height: 48px;
  align-content: center;
}

.navbar .pill {
  width: 64px;
  height: 32px;
  border-radius: 16px;
  display: grid;
  place-items: center;
}

.navbar a.on { color: var(--on); }
.navbar a.on .pill { background: var(--p-cont); color: var(--on-p-cont); }

/* ---------- fields ---------- */
.field { display: grid; gap: 8px; }
.field > label { font-weight: 600; font-size: .875rem; color: var(--on); }
.sub { font-weight: 400; color: var(--on-var); }

.textarea {
  background: var(--c-low);
  border: 1px solid var(--outline-var);
  border-radius: 16px;
  padding: 14px 16px 12px;
  display: grid;
  gap: 12px;
}

.textarea:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 1px var(--primary);
}

.textarea .val {
  font-size: 1rem;
  line-height: 1.5;
  word-break: break-all;
  color: var(--on);
}

textarea.val {
  display: block;
  width: 100%;
  min-height: 76px;
  border: 0;
  background: transparent;
  resize: vertical;
  outline: none;
}

/* The textarea holds prose, not a URL: break between words, not inside them. */
.textarea textarea.val {
  word-break: normal;
  overflow-wrap: anywhere;
}

.detected {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-top: 12px;
  border-top: 1px solid var(--outline-var);
}

.av {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--c-high);
  display: grid;
  place-items: center;
  font: 700 .875rem var(--display);
  color: var(--on-var);
  flex: none;
}

.detected .av { font-size: .875rem; }
.detected b { font-size: .9375rem; display: block; font-weight: 600; }
.detected span { font-size: .8125rem; color: var(--on-var); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 48px;
  padding: 0 14px;
  border-radius: 10px;
  border: 1px solid var(--outline-var);
  background: transparent;
  font-weight: 600;
  font-size: .875rem;
  color: var(--on-var);
  cursor: pointer;
}

.chip.on { background: var(--p-cont); border-color: transparent; color: var(--on-p-cont); }
.chip svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 2; }
/* The tick marks the selected chip; every chip carries one so the mark can
   move when the selection changes. */
.chip svg { display: none; }
.chip.on svg { display: block; }

.input1 {
  min-height: 52px;
  width: 100%;
  border-radius: 12px;
  border: 1px solid var(--outline-var);
  background: var(--c-low);
  padding: 0 16px;
  display: flex;
  align-items: center;
  color: var(--on);
  font-size: 1rem;
}

input.input1 { line-height: normal; }

.input1::placeholder { color: var(--on-var); }

.filled {
  min-height: 56px;
  border: 0;
  border-radius: 28px;
  background: var(--primary);
  color: var(--on-primary);
  font-weight: 700;
  font-size: 1rem;
  width: 100%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .15);
}

.filled[disabled] { opacity: .45; cursor: not-allowed; }
.filled svg { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 2; }

.tonal {
  min-height: 48px;
  border: 0;
  border-radius: 24px;
  background: var(--p-cont);
  color: var(--on-p-cont);
  font-weight: 700;
  cursor: pointer;
}

.text-btn {
  border: 0;
  background: transparent;
  color: var(--primary);
  font-weight: 700;
  font-size: .875rem;
  min-height: 48px;
  padding: 0 12px;
  border-radius: 20px;
  cursor: pointer;
}

.hint { font-size: .8125rem; color: var(--on-var); text-align: center; margin: 0; }

/* ---------- writing ---------- */
.src {
  background: var(--c-low);
  border-radius: 16px;
  padding: 16px;
  display: grid;
  gap: 10px;
}

.src p { margin: 0; font-size: .9375rem; }
.meta-row { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: .8125rem; color: var(--on-var); }
.meta-row .n { font-family: var(--mono); color: var(--on); }

.steps { list-style: none; margin: 0; padding: 0; display: grid; }
.steps li {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  gap: 12px;
  padding: 14px 0;
  border-bottom: 1px solid var(--outline-var);
  align-items: start;
}
.steps li:last-child { border-bottom: 0; }
.steps .s b { font-weight: 600; font-size: .9375rem; display: block; }
.steps .s span { font-size: .8125rem; color: var(--on-var); }
.steps .tm { font: .8125rem var(--mono); color: var(--on-var); padding-top: 2px; }
.ck {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--good) 16%, transparent);
  color: var(--good);
  display: grid;
  place-items: center;
}
.ck svg { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 2.6; }
.run {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2.5px solid var(--p-cont);
  border-top-color: var(--primary);
  animation: spin .9s linear infinite;
}
.wait { width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--outline-var); }
.steps li.dim .s b { color: var(--on-var); }
.steps li.err .s b { color: var(--error); }

.progress { height: 4px; border-radius: 2px; background: var(--p-cont); overflow: hidden; }
.progress i {
  display: block;
  height: 100%;
  width: 0;
  background: var(--primary);
  border-radius: 2px;
  transition: width .3s var(--ease);
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- review ---------- */
.seg {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border: 1px solid var(--outline);
  border-radius: 20px;
  overflow: hidden;
}

.seg > span, .seg > button {
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  font-weight: 600;
  font-size: .8125rem;
  border: 0;
  border-left: 1px solid var(--outline);
  background: transparent;
  color: var(--on);
  padding: 0 4px;
  cursor: pointer;
}

.seg > :first-child { border-left: 0; }
.seg > .on { background: var(--p-cont); color: var(--on-p-cont); }
.seg svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 2.4; }
/* The tick marks the selected tab; every tab carries one so the mark can move. */
.seg svg { display: none; }
.seg > .on svg { display: block; }

.verdict { display: flex; align-items: center; gap: 14px; padding: 4px 2px; }
.verdict .num { font: 500 2rem/1 var(--mono); color: var(--good); letter-spacing: -.03em; }
.verdict b { display: block; font-size: .9375rem; }
.verdict span { font-size: .8125rem; color: var(--on-var); }
.verdict .num.warn { color: var(--warn); }

.between { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.between > span { font-weight: 600; font-size: .875rem; }

.proof {
  background: var(--c-low);
  border-radius: 16px;
  padding: 16px 16px 16px 6px;
  display: grid;
  gap: 12px;
}

.para { display: grid; grid-template-columns: 44px 1fr; gap: 4px; align-items: start; }
.para p { margin: 0; font-size: 1rem; line-height: 1.55; min-width: 0; }
.para.hook p { font-weight: 700; }

.mk {
  justify-self: center;
  margin-top: 3px;
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  color: var(--outline);
}
.mk svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; }
.mk.flag {
  width: auto;
  min-width: 24px;
  height: 22px;
  padding: 0 4px;
  border-radius: 11px;
  background: var(--pencil);
  color: var(--on-pencil);
  font: 500 .6875rem var(--mono);
  letter-spacing: .02em;
}

.mark {
  text-decoration: underline wavy var(--on-pencil);
  text-decoration-thickness: 1.5px;
  text-underline-offset: 4px;
  background: color-mix(in srgb, var(--pencil) 60%, transparent);
  border-radius: 3px;
  padding: 0 1px;
}

.editor {
  background: var(--c-low);
  border: 1px solid var(--outline-var);
  border-radius: 16px;
  padding: 14px 16px;
  font-size: 1rem;
  line-height: 1.55;
  width: 100%;
  min-height: 180px;
  resize: vertical;
  outline: none;
}

.editor:focus-visible { border-color: var(--primary); }

.counts { display: flex; gap: 16px; flex-wrap: wrap; font-size: .8125rem; color: var(--on-var); }
.counts b { font-family: var(--mono); font-weight: 500; color: var(--on); }

/* A note: the badge and the label on the first row, the hint under it and
   the button under that. */
.note {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 12px;
  padding: 14px 16px;
  border-radius: 16px;
  background: color-mix(in srgb, var(--pencil) 45%, var(--c-low));
}
.note .mk.flag { grid-area: 1 / 1; margin: 0; }
.note b { grid-area: 1 / 2; font-size: .9375rem; }
.note .note-hint { grid-area: 2 / 2; font-size: .8125rem; color: var(--on-var); }
.note .act {
  grid-area: 3 / 2;
  justify-self: start;
  margin-top: 4px;
  min-height: 48px;
  padding: 0 14px;
  border-radius: 20px;
  border: 0;
  background: transparent;
  color: var(--primary);
  font-weight: 700;
  font-size: .875rem;
  cursor: pointer;
  margin-left: -14px;
}

.comment {
  display: grid;
  gap: 4px;
  padding: 14px 16px;
  border-radius: 16px;
  background: var(--c);
  position: relative;
}
.comment b { font-size: .875rem; }
.comment span { font-size: .875rem; color: var(--on-var); word-break: break-word; }
.comment .text-btn { justify-self: start; margin-left: -12px; }

.hooks { display: grid; gap: 10px; }
.notes { display: grid; gap: 10px; }
.hook-card {
  display: grid;
  gap: 4px;
  text-align: left;
  padding: 14px 16px;
  border-radius: 16px;
  border: 1px solid var(--outline-var);
  background: var(--c-low);
  cursor: pointer;
  min-height: 48px;
}
.hook-card b { font-weight: 600; font-size: .9375rem; }
.hook-card span { font-size: .8125rem; color: var(--on-var); }

.actions {
  flex: none;
  display: grid;
  grid-template-columns: 1fr 1fr 48px;
  gap: 10px;
  align-items: center;
  background: var(--c);
  padding: 12px 16px calc(16px + env(safe-area-inset-bottom, 0px));
}
.actions button {
  min-height: 48px;
  border-radius: 24px;
  font-weight: 700;
  font-size: .9375rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.actions .li { border: 0; background: var(--primary); color: var(--on-primary); }
.actions .x { border: 1px solid var(--outline); background: transparent; color: var(--on); }
.actions .ib { border-radius: 24px; }

/* ---------- card ---------- */
.card {
  aspect-ratio: 4/5;
  max-width: 100%;
  border-radius: 12px;
  background: var(--cbg);
  color: var(--cink);
  padding: 10% 8% 8%;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  overflow: hidden;
  --cbg: #F4F6F9;
  --cink: #121722;
  --cacc: #2340E0;
  --cmut: #5A6476;
  --cpen: #C7E6F0;
  box-shadow: 0 0 0 1px var(--outline-var);
}
.card.dark {
  --cbg: #121722;
  --cink: #EEF1F6;
  --cacc: #9DACFF;
  --cmut: #97A1B3;
  --cpen: #1D4A58;
}
.card h2 { font: 700 clamp(1.75rem, 8.6vw, 2.2rem)/1.03 var(--display); letter-spacing: -.03em; margin: 0; text-wrap: balance; }
.card h2 .u { background: linear-gradient(transparent 58%, var(--cpen) 58%); padding: 0 .04em; }
.card .stat { display: grid; gap: 4px; }
.card .stat b { font: 500 2.6rem/1 var(--mono); letter-spacing: -.04em; color: var(--cacc); }
.card .stat span { font-size: .8125rem; color: var(--cmut); max-width: 26ch; }
.card .ft {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: .75rem;
  font-weight: 600;
  color: var(--cmut);
  border-top: 1px solid color-mix(in srgb, var(--cink) 16%, transparent);
  padding-top: 12px;
}

.card-preview { display: grid; justify-items: center; }
.card-preview canvas {
  width: 100%;
  max-width: 420px;
  height: auto;
  aspect-ratio: 4/5;
  border-radius: 12px;
  box-shadow: 0 0 0 1px var(--outline-var);
  display: block;
}

.styles { display: flex; gap: 4px; align-items: center; }
.sw {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 0;
  background: transparent;
  display: grid;
  place-items: center;
  cursor: pointer;
}
.sw i { width: 30px; height: 30px; border-radius: 50%; box-shadow: 0 0 0 1px var(--outline-var); }
.sw.on i { box-shadow: 0 0 0 2px var(--ground), 0 0 0 4px var(--primary); }
.sw .l { background: #F4F6F9; }
.sw .d { background: #121722; }

.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* ---------- settings ---------- */
.group { display: grid; gap: 2px; }
.group h3 { font: 600 .875rem var(--body); color: var(--primary); margin: 8px 4px 6px; }
.li-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 2px 12px;
  align-items: center;
  padding: 12px 16px;
  background: var(--c-low);
  min-height: 64px;
}
.li-row:first-of-type { border-radius: 16px 16px 4px 4px; }
.li-row:last-of-type { border-radius: 4px 4px 16px 16px; }
.li-row b { font-weight: 600; font-size: 1rem; }
.li-row span { font-size: .8125rem; color: var(--on-var); grid-column: 1; }
.li-row .end { grid-row: 1 / span 2; grid-column: 2; }

.ok-dot { display: inline-flex; align-items: center; gap: 6px; color: var(--good); font-weight: 600; font-size: .8125rem; }
.ok-dot::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }

.sw-toggle {
  width: 52px;
  height: 32px;
  border-radius: 16px;
  background: var(--primary);
  position: relative;
  border: 0;
  padding: 0;
  cursor: pointer;
  flex: none;
}
.sw-toggle::after {
  content: "";
  position: absolute;
  right: 4px;
  top: 4px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--on-primary);
}
.sw-toggle.off { background: var(--c-high); box-shadow: inset 0 0 0 2px var(--outline); }
.sw-toggle.off::after { left: 8px; right: auto; top: 8px; width: 16px; height: 16px; background: var(--outline); }

.ex { font-size: .75rem; color: var(--on-var); text-align: center; margin: 0; }

/* ---------- snackbar ---------- */
.snack {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: calc(96px + env(safe-area-inset-bottom, 0px));
  z-index: 70;
  max-width: calc(var(--shell) - 24px);
  margin: 0 auto;
  background: var(--on);
  color: var(--ground);
  border-radius: 8px;
  padding: 6px 6px 6px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: .875rem;
  box-shadow: 0 6px 18px rgba(0, 0, 0, .25);
}
.snack button {
  border: 0;
  background: transparent;
  color: color-mix(in srgb, var(--primary) 55%, var(--ground));
  font-weight: 700;
  min-height: 40px;
  padding: 0 12px;
  border-radius: 20px;
  cursor: pointer;
}
:root[data-theme="dark"] .snack button { color: var(--on-primary); }

/* ---------- bottom sheet ---------- */
.sheet {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.sheet-scrim { position: absolute; inset: 0; background: var(--scrim); }

.sheet-panel {
  position: relative;
  width: 100%;
  max-width: var(--shell);
  max-height: 80vh;
  max-height: 80dvh;
  overflow: auto;
  background: var(--c-low);
  border-radius: 20px 20px 0 0;
  padding: 8px 12px calc(16px + env(safe-area-inset-bottom, 0px));
  display: grid;
  gap: 8px;
  box-shadow: 0 -8px 32px rgba(0, 0, 0, .25);
}

.sheet-grip { width: 36px; height: 4px; border-radius: 2px; background: var(--outline-var); margin: 4px auto 8px; }
.sheet-title { font: 600 1rem var(--body); padding: 4px 12px 0; }

.sheet-item {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 48px;
  padding: 0 12px;
  border-radius: 12px;
  border: 0;
  background: transparent;
  width: 100%;
  text-align: left;
  font-weight: 600;
  cursor: pointer;
}
.sheet-item:hover { background: var(--c); }
.sheet-item.danger { color: var(--error); }

/* ---------- login ---------- */
.login { display: grid; gap: 14px; padding: 32px 0; text-align: center; }
.login-mark { font: 700 1.75rem/1 var(--display); letter-spacing: -.02em; }
.login-h { font: 700 1.25rem/1.2 var(--display); margin: 0; }
.login-p { margin: 0; color: var(--on-var); font-size: .9375rem; }
.login-form { display: grid; gap: 12px; text-align: left; }
.login-err { margin: 0; color: var(--error); font-size: .875rem; }

/* ---------- history ---------- */
.hist { display: grid; gap: 8px; }
.hist-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 2px 12px;
  align-items: center;
  padding: 14px 16px;
  border-radius: 16px;
  background: var(--c-low);
  cursor: pointer;
  min-height: 64px;
  text-align: left;
  width: 100%;
}
.hist-row b { font-weight: 600; font-size: 1rem; }
.hist-row span { font-size: .8125rem; color: var(--on-var); grid-column: 1; }
.hist-row .end { grid-row: 1 / span 2; grid-column: 2; display: flex; align-items: center; gap: 8px; }

.status-label { font-size: .75rem; font-weight: 600; color: var(--on-var); }
.score-chip {
  font: 500 .75rem var(--mono);
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid var(--outline-var);
  color: var(--on-var);
}
.score-chip.good { color: var(--good); border-color: color-mix(in srgb, var(--good) 40%, transparent); background: color-mix(in srgb, var(--good) 12%, transparent); }
.score-chip.warn { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 40%, transparent); background: color-mix(in srgb, var(--warn) 12%, transparent); }

.empty { margin: 0; padding: 40px 16px; text-align: center; color: var(--on-var); font-size: .9375rem; }

/* ---------- motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
  .run { animation: none; }
}

/* ---------- T10 additions ---------- */
/* The source card in the writing view has no separator above the author. */
.src .detected { border-top: 0; padding-top: 0; }

/* A failed step keeps the tick shape but turns red. */
.steps li.err .ck,
.ck.err {
  background: color-mix(in srgb, var(--error) 16%, transparent);
  color: var(--error);
}

/* The error line under the step list. */
.err-msg {
  margin: 0;
  padding: 12px 16px;
  border-radius: 16px;
  background: color-mix(in srgb, var(--error) 12%, var(--c-low));
  color: var(--error);
  font-size: .875rem;
}

/* The textarea used by the clipboard fallback never shows. */
.copy-fallback {
  position: fixed;
  left: -9999px;
  top: 0;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

/* The hook cards are buttons, so they need the reset. */
button.hook-card { font: inherit; color: inherit; }

/* ---------- T11 additions ---------- */
/* The card view, the history rows and the settings rows need a few classes
   that the shell does not use.

   New ids used by card.js, history.js and settings.js:
     #settings-hashtags-stepper  the stepper around #settings-hashtags
     #settings-hashtags         the number of allowed hashtags
   The appearance row is built in settings.js and carries no id. */

/* The score chip keeps its own size inside a history row. */
.hist-row .end .score-chip {
  font: 500 .75rem var(--mono);
  grid-column: auto;
}

/* A row that spans the whole width, used by the theme chips. */
.li-row .full { grid-column: 1 / -1; }

/* The warning colour inside a settings row. */
.li-row .warn { color: var(--warn); }

/* The hashtag stepper. */
.stepper { display: flex; align-items: center; gap: 4px; }
.st-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--c-high);
  color: var(--on);
  font-weight: 700;
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
}
.st-btn[disabled] { opacity: .4; cursor: not-allowed; }
.li-row .st-count {
  font: 500 1rem var(--mono);
  color: var(--on);
  min-width: 24px;
  text-align: center;
  grid-column: auto;
}

/* The attach switch on the card view turns the button blue when it is on. */
.tonal.on { background: var(--primary); color: var(--on-primary); }

/* A link that is clicked but never seen, for the image download. */
.temp-link {
  position: fixed;
  left: -9999px;
  top: 0;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

/* The sheets of the settings view hold a textarea and a button. */
.sheet .editor { min-height: 220px; }
.sheet .filled { margin-top: 4px; }
.sheet .text-btn { justify-self: start; margin-left: -12px; }
