/* noslop — web app styles
   Editorial, calm, trustworthy. A writing tool, not a dashboard.
   System fonts only — no network requests, ever. */

/* ---------- design tokens ---------- */

:root {
  color-scheme: light;

  /* type */
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
    Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
  --font-serif: Georgia, "Iowan Old Style", "Palatino Linotype", Palatino, "Times New Roman", serif;
  --font-mono: ui-monospace, "Cascadia Code", "Segoe UI Mono", Consolas, "Liberation Mono",
    Menlo, monospace;

  --measure: 68ch;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;

  --dur-fast: 120ms;
  --dur-med: 220ms;
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);

  /* Paper — warm near-white paper, deep ink, one burnt-orange accent.
     This is the un-attributed default: no data-theme means this block. */
  --paper: #f4efe6;
  --paper-raised: #fbf8f2;
  --ink: #20211f;
  --ink-soft: #4a4944;
  --ink-faint: #635f59;
  --line: #ddd6c8;
  --line-soft: #e9e3d6;
  --accent: #a85725;
  --accent-ink: #7a3f1a;
  --accent-tint: #f1e2d3;
  --accent-on: #fff8f0;

  --good: #376b45;
  --good-tint: #e3efe3;
  --warn: #83560f;
  --warn-tint: #f5ecd9;
  --bad: #b23b2f;
  --bad-tint: #f6e3df;

  --focus-ring: #2f6fb0;

  /* category marks — every pair below is verified >=4.5:1 text-on-chip and
     the chip itself >=3:1 against --paper-raised (see CONTRIBUTING.md) */
  --mark-phrase: #aa8c31;
  --mark-phrase-ink: #31280e;
  --mark-buzzword: #c67b39;
  --mark-buzzword-ink: #362110;
  --mark-construction: #bf4075;
  --mark-construction-ink: #faf1f5;
  --mark-hedge: #769b43;
  --mark-hedge-ink: #222d13;
  --mark-emoji: #419caa;
  --mark-emoji-ink: #132d32;
  --mark-emdash: #465db9;
  --mark-emdash-ink: #dce0f2;
  --mark-bold-bullet: #9346b9;
  --mark-bold-bullet-ink: #f0e5f5;

  --shadow-card: 0 1px 2px rgba(32, 33, 31, 0.06), 0 4px 16px rgba(32, 33, 31, 0.06);
}

/* Auto (no stored choice) follows the OS: Paper by day, Ink by night. */
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --paper: #1c1c1a;
    --paper-raised: #242422;
    --ink: #ece7dc;
    --ink-soft: #c3beb2;
    --ink-faint: #8f8b80;
    --line: #38372f;
    --line-soft: #2b2a25;
    --accent: #e08a52;
    --accent-ink: #f2b587;
    --accent-tint: #3a2a1c;
    --accent-on: #0d0702;

    --good: #7fc491;
    --good-tint: #223226;
    --warn: #e0b85a;
    --warn-tint: #362c17;
    --bad: #e6867a;
    --bad-tint: #3a2320;

    --focus-ring: #7db3e8;

    --mark-phrase: #cca633;
    --mark-phrase-ink: #4d3e13;
    --mark-buzzword: #cc7a33;
    --mark-buzzword-ink: #39220e;
    --mark-construction: #c63974;
    --mark-construction-ink: #fbf2f6;
    --mark-hedge: #89b946;
    --mark-hedge-ink: #33451a;
    --mark-emoji: #40aebf;
    --mark-emoji-ink: #163d43;
    --mark-emdash: #4f67c4;
    --mark-emdash-ink: #edeff9;
    --mark-bold-bullet: #9a49c2;
    --mark-bold-bullet-ink: #f6eef9;

    --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.25), 0 6px 20px rgba(0, 0, 0, 0.3);
  }
}

/* An explicit data-theme always wins over the media query, either direction. */

/* ----- Paper (light) — the default, explicit ----- */
:root[data-theme="light"] {
  color-scheme: light;
  --paper: #f4efe6;
  --paper-raised: #fbf8f2;
  --ink: #20211f;
  --ink-soft: #4a4944;
  --ink-faint: #635f59;
  --line: #ddd6c8;
  --line-soft: #e9e3d6;
  --accent: #a85725;
  --accent-ink: #7a3f1a;
  --accent-tint: #f1e2d3;
  --accent-on: #fff8f0;
  --good: #376b45;
  --good-tint: #e3efe3;
  --warn: #83560f;
  --warn-tint: #f5ecd9;
  --bad: #b23b2f;
  --bad-tint: #f6e3df;
  --focus-ring: #2f6fb0;
  --mark-phrase: #aa8c31;
  --mark-phrase-ink: #31280e;
  --mark-buzzword: #c67b39;
  --mark-buzzword-ink: #362110;
  --mark-construction: #bf4075;
  --mark-construction-ink: #faf1f5;
  --mark-hedge: #769b43;
  --mark-hedge-ink: #222d13;
  --mark-emoji: #419caa;
  --mark-emoji-ink: #132d32;
  --mark-emdash: #465db9;
  --mark-emdash-ink: #dce0f2;
  --mark-bold-bullet: #9346b9;
  --mark-bold-bullet-ink: #f0e5f5;
  --shadow-card: 0 1px 2px rgba(32, 33, 31, 0.06), 0 4px 16px rgba(32, 33, 31, 0.06);
}

/* ----- Ink (dark) — the default's dark twin, explicit ----- */
:root[data-theme="dark"] {
  color-scheme: dark;
  --paper: #1c1c1a;
  --paper-raised: #242422;
  --ink: #ece7dc;
  --ink-soft: #c3beb2;
  --ink-faint: #8f8b80;
  --line: #38372f;
  --line-soft: #2b2a25;
  --accent: #e08a52;
  --accent-ink: #f2b587;
  --accent-tint: #3a2a1c;
  --accent-on: #0d0702;
  --good: #7fc491;
  --good-tint: #223226;
  --warn: #e0b85a;
  --warn-tint: #362c17;
  --bad: #e6867a;
  --bad-tint: #3a2320;
  --focus-ring: #7db3e8;
  --mark-phrase: #cca633;
  --mark-phrase-ink: #4d3e13;
  --mark-buzzword: #cc7a33;
  --mark-buzzword-ink: #39220e;
  --mark-construction: #c63974;
  --mark-construction-ink: #fbf2f6;
  --mark-hedge: #89b946;
  --mark-hedge-ink: #33451a;
  --mark-emoji: #40aebf;
  --mark-emoji-ink: #163d43;
  --mark-emdash: #4f67c4;
  --mark-emdash-ink: #edeff9;
  --mark-bold-bullet: #9a49c2;
  --mark-bold-bullet-ink: #f6eef9;
  --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.25), 0 6px 20px rgba(0, 0, 0, 0.3);
}

/* ----- Terminal (dark) — phosphor green on a near-black CRT ----- */
:root[data-theme="terminal"] {
  color-scheme: dark;
  --paper: #0a100c;
  --paper-raised: #10180f;
  --ink: #a6f0b6;
  --ink-soft: #7fd694;
  --ink-faint: #5c9a6c;
  --line: #1e3322;
  --line-soft: #162619;
  --accent: #4be07a;
  --accent-ink: #8ff2ab;
  --accent-tint: #123018;
  --accent-on: #020d06;
  --good: #57e07f;
  --good-tint: #14301c;
  --warn: #e0c94a;
  --warn-tint: #332c12;
  --bad: #e0645a;
  --bad-tint: #331714;
  --focus-ring: #5fd0e0;
  --mark-phrase: #d2a92d;
  --mark-phrase-ink: #504011;
  --mark-buzzword: #d97126;
  --mark-buzzword-ink: #3c1f0b;
  --mark-construction: #cc3399;
  --mark-construction-ink: #000000;
  --mark-hedge: #97c639;
  --mark-hedge-ink: #3c4e17;
  --mark-emoji: #33ccbf;
  --mark-emoji-ink: #14514c;
  --mark-emdash: #3968c6;
  --mark-emdash-ink: #e7edf8;
  --mark-bold-bullet: #8b39c6;
  --mark-bold-bullet-ink: #e9daf4;
  --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.35), 0 6px 20px rgba(0, 0, 0, 0.4);
}

/* ----- Sepia (light) — antique manuscript, oxblood accent ----- */
:root[data-theme="sepia"] {
  color-scheme: light;
  --paper: #ecdcb8;
  --paper-raised: #f6ecd6;
  --ink: #3a2a15;
  --ink-soft: #5c4a30;
  --ink-faint: #6f5f43;
  --line: #d3ba8a;
  --line-soft: #e2cca0;
  --accent: #8a4a1f;
  --accent-ink: #6b3a18;
  --accent-tint: #ecdcc4;
  --accent-on: #fdf3e4;
  --good: #4d6b2a;
  --good-tint: #e2e6ca;
  --warn: #81630f;
  --warn-tint: #f0e6c4;
  --bad: #9c2b24;
  --bad-tint: #f0d6d0;
  --focus-ring: #2f5f8a;
  --mark-phrase: #a3843e;
  --mark-phrase-ink: #28200f;
  --mark-buzzword: #b96c46;
  --mark-buzzword-ink: #22140d;
  --mark-construction: #ac5362;
  --mark-construction-ink: #f8f1f2;
  --mark-hedge: #7a8f4a;
  --mark-hedge-ink: #1d2212;
  --mark-emoji: #4f948e;
  --mark-emoji-ink: #142524;
  --mark-emdash: #5960a6;
  --mark-emdash-ink: #e2e3ef;
  --mark-bold-bullet: #9b57a8;
  --mark-bold-bullet-ink: #f9f5fa;
  --shadow-card: 0 1px 2px rgba(58, 42, 21, 0.08), 0 4px 16px rgba(58, 42, 21, 0.08);
}

/* ----- Newsprint (light) — grayscale broadsheet, one masthead red ----- */
:root[data-theme="newsprint"] {
  color-scheme: light;
  --paper: #e9e6de;
  --paper-raised: #f4f2ea;
  --ink: #1a1a1a;
  --ink-soft: #45443f;
  --ink-faint: #696760;
  --line: #c7c3b6;
  --line-soft: #dcd8cb;
  --accent: #a52822;
  --accent-ink: #7c1e19;
  --accent-tint: #ecd9d6;
  --accent-on: #fbf1ee;
  --good: #3f6b3f;
  --good-tint: #dde6da;
  --warn: #7a5c12;
  --warn-tint: #ede4cc;
  --bad: #a52822;
  --bad-tint: #ecd9d6;
  --focus-ring: #2b5c86;
  --mark-phrase: #9e8a59;
  --mark-phrase-ink: #2b2518;
  --mark-buzzword: #a67359;
  --mark-buzzword-ink: #1d140f;
  --mark-construction: #9f606a;
  --mark-construction-ink: #faf7f7;
  --mark-hedge: #82925d;
  --mark-hedge-ink: #232719;
  --mark-emoji: #63929c;
  --mark-emoji-ink: #1a2628;
  --mark-emdash: #606a9f;
  --mark-emdash-ink: #eeeff5;
  --mark-bold-bullet: #8f609f;
  --mark-bold-bullet-ink: #f9f6fa;
  --shadow-card: 0 1px 2px rgba(26, 26, 26, 0.07), 0 4px 16px rgba(26, 26, 26, 0.07);
}

/* ----- Midnight (dark) — cool slate-blue, code-editor-at-night ----- */
:root[data-theme="midnight"] {
  color-scheme: dark;
  --paper: #0f1420;
  --paper-raised: #161d2c;
  --ink: #e2e6f0;
  --ink-soft: #a7b0c5;
  --ink-faint: #7a83a6;
  --line: #29324a;
  --line-soft: #1d2436;
  --accent: #5b9df0;
  --accent-ink: #8fc4f5;
  --accent-tint: #172a42;
  --accent-on: #01070e;
  --good: #6fd694;
  --good-tint: #16302a;
  --warn: #e8c15a;
  --warn-tint: #362c14;
  --bad: #f28080;
  --bad-tint: #3a2020;
  --focus-ring: #f0b34a;
  --mark-phrase: #cca633;
  --mark-phrase-ink: #4d3e13;
  --mark-buzzword: #d2852d;
  --mark-buzzword-ink: #422a0e;
  --mark-construction: #c63980;
  --mark-construction-ink: #fcf4f8;
  --mark-hedge: #46b976;
  --mark-hedge-ink: #19432a;
  --mark-emoji: #39aec6;
  --mark-emoji-ink: #143d46;
  --mark-emdash: #7f4dc4;
  --mark-emdash-ink: #ece4f6;
  --mark-bold-bullet: #bf40aa;
  --mark-bold-bullet-ink: #010001;
  --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.35), 0 6px 20px rgba(0, 0, 0, 0.4);
}

/* ----- Solarized Light — Ethan Schoonover's palette, retuned a shade
   darker on the muted tokens where the canonical hex fell short of AA ----- */
:root[data-theme="solarized-light"] {
  color-scheme: light;
  --paper: #eee8d5;
  --paper-raised: #fdf6e3;
  --ink: #323e42;
  --ink-soft: #445359;
  --ink-faint: #566466;
  --line: #d5cdb3;
  --line-soft: #e4dec8;
  --accent: #1e6da5;
  --accent-ink: #1c6ca8;
  --accent-tint: #e3edf3;
  --accent-on: #f8fafc;
  --good: #5b7100;
  --good-tint: #e7ecd2;
  --warn: #896000;
  --warn-tint: #f0e6c8;
  --bad: #bb3026;
  --bad-tint: #f5dcd8;
  --focus-ring: #6c71c4;
  --mark-phrase: #b18914;
  --mark-phrase-ink: #322706;
  --mark-buzzword: #df5320;
  --mark-buzzword-ink: #2d1106;
  --mark-construction: #c6397d;
  --mark-construction-ink: #fcf3f7;
  --mark-hedge: #85961a;
  --mark-hedge-ink: #252a07;
  --mark-emoji: #289f95;
  --mark-emoji-ink: #0b2e2b;
  --mark-emdash: #338ccc;
  --mark-emdash-ink: #0c2130;
  --mark-bold-bullet: #6c46b9;
  --mark-bold-bullet-ink: #dbd2ee;
  --shadow-card: 0 1px 2px rgba(0, 43, 54, 0.08), 0 4px 16px rgba(0, 43, 54, 0.08);
}

/* ----- Solarized Dark — same family, retuned a shade brighter on the
   muted tokens for the same reason ----- */
:root[data-theme="solarized-dark"] {
  color-scheme: dark;
  --paper: #002b36;
  --paper-raised: #073642;
  --ink: #d2d8d8;
  --ink-soft: #afbabb;
  --ink-faint: #91a4aa;
  --line: #0f4453;
  --line-soft: #0a3a47;
  --accent: #4fa8e6;
  --accent-ink: #7dc4f0;
  --accent-tint: #0d3040;
  --accent-on: #02090d;
  --good: #8fc73e;
  --good-tint: #16281a;
  --warn: #e0b83e;
  --warn-tint: #332b14;
  --bad: #ec746a;
  --bad-tint: #3a1c18;
  --focus-ring: #a8a0e8;
  --mark-phrase: #e6b319;
  --mark-phrase-ink: #5c470a;
  --mark-buzzword: #df5320;
  --mark-buzzword-ink: #2d1106;
  --mark-construction: #cb4b89;
  --mark-construction-ink: #1b0811;
  --mark-hedge: #bcd22d;
  --mark-hedge-ink: #4b5412;
  --mark-emoji: #39c6ba;
  --mark-emoji-ink: #164d49;
  --mark-emdash: #338ccc;
  --mark-emdash-ink: #0c2130;
  --mark-bold-bullet: #8869c6;
  --mark-bold-bullet-ink: #100a1b;
  --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.35), 0 6px 20px rgba(0, 0, 0, 0.4);
}

/* ----- High Contrast (dark) — max-contrast accessibility mode: pure
   black/white, vivid saturated marks, black text on every chip ----- */
:root[data-theme="contrast"] {
  color-scheme: dark;
  --paper: #000000;
  --paper-raised: #0d0d0d;
  --ink: #ffffff;
  --ink-soft: #e6e6e6;
  --ink-faint: #bdbdbd;
  --line: #8a8a8a;
  --line-soft: #4a4a4a;
  --accent: #ffd60a;
  --accent-ink: #ffe066;
  --accent-tint: #332b00;
  --accent-on: #000000;
  --good: #4ade60;
  --good-tint: #10280f;
  --warn: #ffb020;
  --warn-tint: #332400;
  --bad: #ff5c5c;
  --bad-tint: #330d0d;
  --focus-ring: #66e0ff;
  --mark-phrase: #ffcc00;
  --mark-phrase-ink: #665200;
  --mark-buzzword: #ff7700;
  --mark-buzzword-ink: #592900;
  --mark-construction: #ff0080;
  --mark-construction-ink: #3f0020;
  --mark-hedge: #95ff00;
  --mark-hedge-ink: #3c6600;
  --mark-emoji: #00d4ff;
  --mark-emoji-ink: #005566;
  --mark-emdash: #006aff;
  --mark-emdash-ink: #000001;
  --mark-bold-bullet: #9213ec;
  --mark-bold-bullet-ink: #edd9fc;
  --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.5), 0 4px 16px rgba(0, 0, 0, 0.4);
}

/* ---------- reset-ish ---------- */

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

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background var(--dur-med) var(--ease), color var(--dur-med) var(--ease);
}

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

img, svg { display: block; max-width: 100%; }

button {
  font: inherit;
  color: inherit;
}

a { color: var(--accent-ink); }
a:hover { color: var(--accent); }

:focus-visible {
  outline: 2.5px solid var(--focus-ring);
  outline-offset: 2px;
  border-radius: 4px;
}

/* skip link */
.skip-link {
  position: absolute;
  inset-inline-start: 1rem;
  top: -3rem;
  background: var(--paper-raised);
  color: var(--ink);
  padding: 0.6rem 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  z-index: 100;
  transition: top var(--dur-fast) var(--ease);
}
.skip-link:focus {
  top: 1rem;
}

/* ---------- layout shell ---------- */

.page {
  max-width: 1120px;
  margin: 0 auto;
  /* max() with a plain rem floor: env(safe-area-inset-*) is 0 on a
     non-notched device/browser, so this only ever ADDS padding, never
     removes the usual margin. Matters mainly in landscape on a notched
     phone, where the notch sits on one side rather than the top. */
  padding-left: max(1.25rem, env(safe-area-inset-left));
  padding-right: max(1.25rem, env(safe-area-inset-right));
}

.site-header {
  padding-top: 2.5rem;
}

.header-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1rem;
  margin-bottom: 1.75rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: 1.25rem;
  letter-spacing: -0.01em;
  color: var(--ink);
  text-decoration: none;
}

.brand-mark {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  flex-shrink: 0;
}

.header-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

/* theme picker — a real <select> for native keyboard/touch/screen-reader
   behavior, dressed up to match the rest of the toolbar chrome. The chevron
   is a real SVG (not a fixed-color data-URI background) so it recolors with
   --ink-soft like everything else instead of going invisible in the darker
   themes. */
.theme-picker {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  height: 44px;
  min-width: 44px;
  padding: 0 0.7rem 0 0.65rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: var(--paper-raised);
  cursor: pointer;
  transition: border-color var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease);
}
.theme-picker:hover {
  border-color: var(--ink-faint);
  background: var(--line-soft);
}
.theme-picker:focus-within {
  border-color: var(--focus-ring);
  outline: 2.5px solid var(--focus-ring);
  outline-offset: 2px;
}

.theme-picker-icon {
  width: 17px;
  height: 17px;
  stroke: var(--ink-soft);
  flex-shrink: 0;
}

.theme-select {
  appearance: none;
  -webkit-appearance: none;
  border: 0;
  background-color: transparent;
  color: var(--ink);
  font: inherit;
  /* >=16px: below that, iOS Safari zooms the whole page in on focus. */
  font-size: 1rem;
  font-weight: 500;
  height: 100%;
  max-width: 128px;
  padding-inline-end: 1.1rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
}
/* Suppress the select's own focus-visible ring; .theme-picker:focus-within
   already draws one ring around the whole pill so it isn't drawn twice. */
.theme-select:focus-visible {
  outline: none;
}

/* Language autonyms (e.g. "Português (Brasil)", "Bahasa Indonesia") run
   longer than any theme name - both language pickers share .theme-picker's
   pill chrome but need more room before ellipsis kicks in. */
.uilang-select,
.text-lang-select {
  max-width: 172px;
}

.theme-picker-chevron {
  position: absolute;
  inset-inline-end: 0.6rem;
  top: 50%;
  transform: translateY(-50%);
  width: 13px;
  height: 13px;
  stroke: var(--ink-soft);
  pointer-events: none;
}

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

.hero {
  padding: 0.5rem 0 2rem;
}

.hero h1 {
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: clamp(1.9rem, 1.4rem + 2vw, 2.9rem);
  line-height: 1.12;
  letter-spacing: -0.015em;
  margin: 0 0 0.85rem;
  max-width: 22ch;
}

.hero p.tagline {
  font-size: clamp(1.05rem, 0.98rem + 0.3vw, 1.2rem);
  color: var(--ink-soft);
  max-width: 56ch;
  margin: 0 0 1.1rem;
}

.privacy-line {
  display: inline-flex;
  align-items: flex-start;
  gap: 0.55rem;
  background: var(--good-tint);
  color: var(--ink);
  border: 1px solid color-mix(in srgb, var(--good) 35%, var(--line));
  border-radius: var(--radius-md);
  padding: 0.6rem 0.9rem;
  font-size: 0.9rem;
  line-height: 1.45;
  max-width: 62ch;
}

.privacy-line svg {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  margin-top: 0.15rem;
  stroke: var(--good);
}

.privacy-line strong {
  font-weight: 600;
}

/* ---------- toolbar ---------- */

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem;
  margin: 1.5rem 0 0.9rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  min-height: 44px;
  padding: 0.5rem 0.9rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: var(--paper-raised);
  color: var(--ink);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: border-color var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease),
    transform var(--dur-fast) var(--ease);
  white-space: nowrap;
}
.btn:hover {
  border-color: var(--ink-faint);
  background: var(--line-soft);
}
.btn:active {
  transform: scale(0.98);
}
.btn svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  flex-shrink: 0;
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-on);
}
.btn-primary:hover {
  background: var(--accent-ink);
  border-color: var(--accent-ink);
}

.btn-ghost {
  background: transparent;
}

.toolbar-spacer { flex: 1 1 auto; }

.word-count {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 0.85rem;
  color: var(--ink-faint);
  white-space: nowrap;
}

/* ---------- text-language bar ----------
   Forces what the pasted TEXT is scored as (separate from the UI-language
   picker in the header). .text-lang-picker reuses .theme-picker's pill
   chrome (same class applied in index.html) so it needs no chrome of its
   own here - just the row layout and the honest fallback-hint line, shown
   only when auto-detect couldn't match a pack. */

.text-lang-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem 0.9rem;
  margin: 0 0 0.9rem;
}

/* --warn-tint's own contrast against --paper-raised (a card surface) was
   verified for the existing verdict pill/stat-tile uses, but this bar sits
   directly on bare --paper (outside any card) - the tint alone reads as
   near-invisible there (same luminance-vs-hue trap as the mark-highlight
   chips, see CONTRIBUTING.md), so a full-strength --warn border does the
   job a color-mix border can't quite reach against every theme's --paper. */
.text-lang-fallback-hint {
  flex-basis: 100%;
  margin: 0;
  padding: 0.35rem 0.65rem;
  border-radius: var(--radius-sm);
  background: var(--warn-tint);
  border: 1px solid var(--warn);
  color: var(--warn);
  font-size: 0.82rem;
}

/* ---------- editor + backdrop overlay ---------- */

.editor-shell {
  position: relative;
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  background: var(--paper-raised);
  box-shadow: var(--shadow-card);
  overflow: hidden;
  transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}

.editor-shell:focus-within {
  border-color: var(--focus-ring);
  box-shadow: var(--shadow-card), 0 0 0 3px color-mix(in srgb, var(--focus-ring) 25%, transparent);
}

/* Shared box metrics — these two rules MUST match exactly, character for
   character, for the highlight overlay to align with the live textarea. */
.editor-surface {
  margin: 0;
  padding: 1.5rem 1.6rem;
  font-family: var(--font-serif);
  font-size: 1.14rem;
  line-height: 1.75;
  letter-spacing: 0;
  white-space: pre-wrap;
  overflow-wrap: break-word;
  word-break: normal;
  tab-size: 2;
}

.editor-backdrop {
  position: absolute;
  inset: 0;
  overflow: auto;
  pointer-events: none;
  color: var(--ink-faint);
  z-index: 1;
}

.editor-backdrop mark {
  border-radius: 3px;
  padding: 0.05em 0;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
  cursor: help;
  pointer-events: auto;
}
.editor-backdrop mark:hover {
  outline: 2px solid currentColor;
  outline-offset: 1px;
}
/* currentColor is tuned for contrast *inside* the chip, not against the page
   behind it — a near-black mark ink on a near-black theme would draw a
   near-invisible ring. --focus-ring is verified against every surface, so
   keyboard focus always gets a real, visible ring regardless of the mark's
   own color. */
.editor-backdrop mark:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 1px;
}

/* Chat-UI residue reuses the construction pair (already contrast-verified
   on every theme) and adds a double underline so the smoking gun reads as
   its own class of finding, not just another construction. No font-weight
   change: the backdrop must match the textarea's glyph metrics character
   for character, and bold glyphs are wider. */
mark.m-artifact {
  background: var(--mark-construction);
  color: var(--mark-construction-ink);
  text-decoration: underline double;
}
mark.m-phrase { background: var(--mark-phrase); color: var(--mark-phrase-ink); }
mark.m-buzzword { background: var(--mark-buzzword); color: var(--mark-buzzword-ink); }
mark.m-construction { background: var(--mark-construction); color: var(--mark-construction-ink); }
mark.m-hedge { background: var(--mark-hedge); color: var(--mark-hedge-ink); }
mark.m-emoji { background: var(--mark-emoji); color: var(--mark-emoji-ink); }
mark.m-emdash { background: var(--mark-emdash); color: var(--mark-emdash-ink); }
mark.m-bold-bullet { background: var(--mark-bold-bullet); color: var(--mark-bold-bullet-ink); }

.editor-textarea {
  position: relative;
  z-index: 2;
  width: 100%;
  height: 100%;
  resize: none;
  overflow: auto;
  border: 0;
  background: transparent;
  color: transparent;
  caret-color: var(--ink);
  /* Must match .editor-surface (the backdrop) exactly, not inherit the body
     sans stack - otherwise a serif backdrop over a sans textarea drift apart
     and the highlight marks slide out of alignment as the text grows. */
  font-family: var(--font-serif);
  outline: none;
}
.editor-textarea::selection {
  background: color-mix(in srgb, var(--focus-ring) 35%, transparent);
  color: transparent;
}
.editor-textarea::placeholder {
  color: var(--ink-faint);
  opacity: 1;
}

.editor-frame {
  position: relative;
  height: 340px;
}

@media (max-width: 480px) {
  .editor-frame { height: 300px; }
}

/* empty state hint painted by the backdrop text color itself; placeholder
   text lives in the actual textarea placeholder attribute */

.editor-footer-hint {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.35rem 0.75rem;
  padding: 0.6rem 1.1rem;
  border-top: 1px solid var(--line-soft);
  background: var(--paper);
  font-size: 0.78rem;
  color: var(--ink-faint);
}

kbd {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  background: var(--line-soft);
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 4px;
  padding: 0.05rem 0.4rem;
}

/* ---------- score panel ---------- */

.results-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1.1rem;
  margin: 1.75rem 0 3rem;
}

@media (min-width: 860px) {
  .results-grid {
    grid-template-columns: 280px minmax(0, 1fr);
    align-items: start;
  }
}

.score-card {
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  background: var(--paper-raised);
  box-shadow: var(--shadow-card);
  padding: 1.5rem;
  position: sticky;
  top: 1rem;
}

.score-card[data-verdict="good"] { border-color: color-mix(in srgb, var(--good) 45%, var(--line)); }
.score-card[data-verdict="warn"] { border-color: color-mix(in srgb, var(--warn) 45%, var(--line)); }
.score-card[data-verdict="bad"] { border-color: color-mix(in srgb, var(--bad) 45%, var(--line)); }

.score-eyebrow {
  font-size: 0.75rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin: 0 0 0.5rem;
  font-weight: 600;
}

.score-number {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: clamp(2.6rem, 2.2rem + 2vw, 3.4rem);
  font-weight: 600;
  line-height: 1;
  margin: 0;
  letter-spacing: -0.02em;
  transition: color var(--dur-med) var(--ease);
}
.score-number .unit {
  font-size: 1.15rem;
  font-weight: 500;
  color: var(--ink-faint);
  margin-inline-start: 0.3rem;
  letter-spacing: normal;
}

.score-card[data-verdict="good"] .score-number { color: var(--good); }
.score-card[data-verdict="warn"] .score-number { color: var(--warn); }
.score-card[data-verdict="bad"] .score-number { color: var(--bad); }

.score-verdict {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  margin-top: 0.85rem;
  padding: 0.4rem 0.75rem;
  border-radius: 999px;
  font-size: 0.88rem;
  font-weight: 600;
}
.score-card[data-verdict="good"] .score-verdict { background: var(--good-tint); color: var(--good); }
.score-card[data-verdict="warn"] .score-verdict { background: var(--warn-tint); color: var(--warn); }
.score-card[data-verdict="bad"] .score-verdict { background: var(--bad-tint); color: var(--bad); }

.score-verdict svg { width: 16px; height: 16px; flex-shrink: 0; }

.score-meta {
  margin-top: 1.1rem;
  padding-top: 1.1rem;
  border-top: 1px solid var(--line-soft);
  font-size: 0.85rem;
  color: var(--ink-soft);
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.score-meta-row {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
}
.score-meta-row span:last-child {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}

/* ---------- breakdown panel ---------- */

.breakdown {
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  background: var(--paper-raised);
  box-shadow: var(--shadow-card);
  padding: 1.5rem 1.6rem;
}

.breakdown h2 {
  font-size: 1.05rem;
  margin: 0 0 1rem;
  font-weight: 600;
}

.clean-state {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 0.25rem;
  color: var(--ink-soft);
}
.clean-state svg {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  stroke: var(--good);
}
.clean-state strong {
  display: block;
  color: var(--ink);
  font-size: 1rem;
  margin-bottom: 0.15rem;
}

.breakdown-section {
  margin-bottom: 1.4rem;
}
.breakdown-section:last-child { margin-bottom: 0; }

.breakdown-section-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.82rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-soft);
  margin: 0 0 0.65rem;
}

.swatch {
  width: 11px;
  height: 11px;
  border-radius: 3px;
  flex-shrink: 0;
}
/* Double border echoes the mark's double underline, so the artifact
   swatch doesn't read as just another construction square. */
.swatch-artifact { background: transparent; border: 3px double var(--mark-construction); }
.swatch-phrase { background: var(--mark-phrase); }
.swatch-buzzword { background: var(--mark-buzzword); }
.swatch-construction { background: var(--mark-construction); }
.swatch-hedge { background: var(--mark-hedge); }
.swatch-emoji { background: var(--mark-emoji); }
.swatch-emdash { background: var(--mark-emdash); }
.swatch-bold-bullet { background: var(--mark-bold-bullet); }

.finding-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.finding-item {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.15rem 0.6rem;
  padding: 0.55rem 0.75rem;
  border-radius: var(--radius-sm);
  background: var(--paper);
  border: 1px solid var(--line-soft);
}

.finding-term {
  font-weight: 600;
  font-size: 0.94rem;
}

.finding-count {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 0.8rem;
  color: var(--ink-faint);
}

.finding-lines {
  font-size: 0.78rem;
  color: var(--ink-faint);
}

.finding-hint {
  flex-basis: 100%;
  font-size: 0.85rem;
  color: var(--accent-ink);
  display: flex;
  gap: 0.4rem;
}
.finding-hint svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  margin-top: 0.15rem;
  stroke: currentColor;
}

.surface-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.6rem;
}

.stat-tile {
  border: 1px solid var(--line-soft);
  background: var(--paper);
  border-radius: var(--radius-sm);
  padding: 0.65rem 0.8rem;
}
.stat-tile[data-flag="true"] {
  border-color: color-mix(in srgb, var(--warn) 45%, var(--line));
  background: var(--warn-tint);
}
.stat-tile-value {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 1.25rem;
  font-weight: 600;
  line-height: 1.2;
}
.stat-tile-label {
  font-size: 0.78rem;
  color: var(--ink-faint);
  margin-top: 0.1rem;
}

/* ---------- explainer (collapsible) ---------- */

.explainer {
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  background: var(--paper-raised);
  margin-bottom: 3rem;
  overflow: hidden;
}

.explainer summary {
  cursor: pointer;
  list-style: none;
  padding: 1.1rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-weight: 600;
  font-size: 0.98rem;
  user-select: none;
}
.explainer summary::-webkit-details-marker { display: none; }

.explainer summary .chevron {
  width: 16px;
  height: 16px;
  stroke: var(--ink-soft);
  transition: transform var(--dur-fast) var(--ease);
  margin-inline-start: auto;
  flex-shrink: 0;
}
.explainer[open] summary .chevron { transform: rotate(180deg); }

.explainer-body {
  padding: 0 1.5rem 1.4rem;
  color: var(--ink-soft);
}

.explainer-body dl {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.5rem 1rem;
  margin: 0;
}
.explainer-body dt {
  font-weight: 600;
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  white-space: nowrap;
}
.explainer-body dd {
  margin: 0;
  font-size: 0.94rem;
}

@media (max-width: 640px) {
  .explainer-body dl {
    grid-template-columns: 1fr;
  }
  .explainer-body dd {
    margin-bottom: 0.6rem;
  }
}

/* ---------- footer ---------- */

.site-footer {
  border-top: 1px solid var(--line);
  padding: 1.75rem 0 max(3rem, env(safe-area-inset-bottom));
  color: var(--ink-faint);
  font-size: 0.88rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.5rem;
  justify-content: space-between;
}

.site-footer code {
  font-family: var(--font-mono);
  background: var(--line-soft);
  border-radius: 4px;
  padding: 0.1rem 0.35rem;
  font-size: 0.85em;
  color: var(--ink-soft);
}

.footer-links {
  display: flex;
  gap: 1.25rem;
  flex-wrap: wrap;
}

/* ---------- visually-hidden utility ---------- */

.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;
}

/* ---------- small screens ---------- */

@media (max-width: 480px) {
  .page {
    padding-left: max(1rem, env(safe-area-inset-left));
    padding-right: max(1rem, env(safe-area-inset-right));
  }
  .editor-surface { padding: 1.1rem 1.1rem; font-size: 1.05rem; }
  .toolbar { gap: 0.45rem; }
  .btn { padding: 0.45rem 0.7rem; font-size: 0.85rem; }
  .score-card { position: static; }
  .site-footer { flex-direction: column; }
}

/* ---------- tooltip (native title-like, but styled) ---------- */

.mark-tooltip {
  position: fixed;
  z-index: 50;
  max-width: 280px;
  background: var(--ink);
  color: var(--paper);
  font-size: 0.8rem;
  line-height: 1.4;
  padding: 0.5rem 0.65rem;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-card);
  pointer-events: none;
  opacity: 0;
  transform: translateY(2px);
  transition: opacity var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
}
.mark-tooltip.visible {
  opacity: 1;
  transform: translateY(0);
}
.mark-tooltip .tt-label {
  font-weight: 600;
  display: block;
}
.mark-tooltip .tt-hint {
  color: color-mix(in srgb, var(--paper) 80%, transparent);
  display: block;
  margin-top: 0.15rem;
}
