/* ==========================================================================
   Glyph — Word Counter
   Design language: an editorial proof desk. Hairline rules, manuscript
   margins, engraved tick marks and tabular mono figures. One accent colour
   (proof red) carries every action and live reading.

   1. Fonts            5. Header & navigation     9.  Content sections
   2. Tokens           6. Hero                    10. Utility
   3. Base             7. Tool: editor            11. Motion & responsive
   4. Layout           8. Tool: dashboard
   ========================================================================== */

/* 1. Fonts ================================================================ */

@font-face {
  font-family: 'Fraunces';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url('../fonts/fraunces-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
    U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193,
    U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: 'Fraunces';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url('../fonts/fraunces-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF,
    U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020,
    U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
  font-family: 'Plex Sans';
  font-style: normal;
  font-weight: 400 600;
  font-display: swap;
  src: url('../fonts/plex-sans-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
    U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193,
    U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: 'Plex Sans';
  font-style: normal;
  font-weight: 400 600;
  font-display: swap;
  src: url('../fonts/plex-sans-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF,
    U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020,
    U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
  font-family: 'Plex Mono';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('../fonts/plex-mono-400-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
    U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193,
    U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: 'Plex Mono';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('../fonts/plex-mono-400-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF,
    U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020,
    U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
  font-family: 'Plex Mono';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('../fonts/plex-mono-500-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
    U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193,
    U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: 'Plex Mono';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('../fonts/plex-mono-500-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF,
    U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020,
    U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* 2. Tokens ============================================================== */

:root {
  /* Colour */
  --canvas: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #fafbfc;
  --surface-3: #f0f2f5;
  --ink: #12161c;
  --ink-2: #3c4654;
  --ink-3: #6b7684;
  --rule: #e2e6eb;
  --rule-strong: #cbd2da;
  --accent: #c8102e;
  --accent-hover: #a90d26;
  --accent-ink: #ffffff;
  --accent-soft: rgba(200, 16, 46, 0.09);
  --ok: #157347;
  --ok-soft: rgba(21, 115, 71, 0.1);
  --shadow-sm: 0 1px 2px rgba(18, 22, 28, 0.05);
  --shadow-md: 0 6px 18px -8px rgba(18, 22, 28, 0.18);
  --shadow-lg: 0 24px 48px -24px rgba(18, 22, 28, 0.28);

  /* Type */
  --font-display: 'Fraunces', 'Iowan Old Style', 'Palatino Linotype', Georgia, serif;
  --font-body: 'Plex Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --font-mono: 'Plex Mono', ui-monospace, 'SFMono-Regular', 'Cascadia Mono', Consolas, monospace;

  /* Space & shape */
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 16px;
  --shell: 1200px;
  --gutter: clamp(1.25rem, 4vw, 2.5rem);

  color-scheme: light;
}

[data-theme='dark'] {
  --canvas: #0d1014;
  --surface: #14181d;
  --surface-2: #191e24;
  --surface-3: #1f252c;
  --ink: #e9ecf0;
  --ink-2: #b7c0cb;
  --ink-3: #8a94a1;
  --rule: #242b33;
  --rule-strong: #333c46;
  --accent: #ff5a6e;
  --accent-hover: #ff7b8b;
  --accent-ink: #1a0409;
  --accent-soft: rgba(255, 90, 110, 0.12);
  --ok: #4bbd87;
  --ok-soft: rgba(75, 189, 135, 0.12);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 6px 18px -8px rgba(0, 0, 0, 0.6);
  --shadow-lg: 0 24px 48px -24px rgba(0, 0, 0, 0.8);

  color-scheme: dark;
}

/* 3. Base ================================================================= */

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

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

body {
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.65;
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body.nav-open {
  overflow: hidden;
}

h1,
h2,
h3,
h4 {
  font-family: var(--font-display);
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: -0.015em;
  margin: 0 0 0.6em;
  font-variation-settings: 'SOFT' 0, 'WONK' 0;
}

h1 {
  font-size: clamp(2.25rem, 6vw, 3.75rem);
  font-weight: 600;
}

h2 {
  font-size: clamp(1.65rem, 3.4vw, 2.35rem);
}

h3 {
  font-size: clamp(1.15rem, 2vw, 1.35rem);
}

p {
  margin: 0 0 1.1em;
}

a {
  color: inherit;
  text-decoration-color: var(--rule-strong);
  text-underline-offset: 3px;
  transition: color 160ms ease, text-decoration-color 160ms ease;
}

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

ul,
ol {
  padding-left: 1.2em;
}

button,
input,
select {
  font: inherit;
  color: inherit;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 3px;
}

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

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  left: 1rem;
  top: -100px;
  z-index: 100;
  background: var(--accent);
  color: var(--accent-ink);
  padding: 0.6rem 1rem;
  border-radius: var(--radius-sm);
  font-weight: 600;
  transition: top 160ms ease;
}

.skip-link:focus {
  top: 1rem;
  color: var(--accent-ink);
}

/* 4. Layout primitives =================================================== */

.shell {
  width: 100%;
  max-width: var(--shell);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.section {
  padding-block: clamp(3rem, 7vw, 5.5rem);
}

.section + .section {
  border-top: 1px solid var(--rule);
}

.eyebrow {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin: 0 0 0.9rem;
  display: block;
}

.lede {
  font-size: clamp(1.05rem, 1.6vw, 1.2rem);
  color: var(--ink-2);
  max-width: 62ch;
}

.section__head {
  max-width: 70ch;
  margin-bottom: clamp(2rem, 4vw, 3rem);
}

.muted {
  color: var(--ink-3);
}

.text-xs {
  font-size: 0.78rem;
}

.shell--narrow {
  max-width: 720px;
}

.footer-base--flush {
  margin-top: 0;
  padding-top: 0;
  border-top: 0;
}

.mono {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  border: 1px solid var(--rule-strong);
  background: var(--surface);
  color: var(--ink);
  border-radius: var(--radius-sm);
  padding: 0.6rem 1rem;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: background-color 150ms ease, border-color 150ms ease, color 150ms ease,
    transform 150ms ease, box-shadow 150ms ease;
}

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

.btn:active {
  transform: translateY(1px);
}

.btn--primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}

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

.btn--ghost {
  background: transparent;
  border-color: transparent;
  color: var(--ink-2);
}

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

.btn--sm {
  padding: 0.4rem 0.7rem;
  font-size: 0.82rem;
}

.btn__icon {
  width: 16px;
  height: 16px;
  flex: none;
}

/* 5. Header & navigation ================================================= */

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--canvas) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--rule);
}

.site-header__inner {
  display: flex;
  align-items: center;
  gap: 1rem;
  min-height: 64px;
}

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

.brand:hover {
  color: var(--ink);
}

.brand__mark {
  width: 30px;
  height: 30px;
  flex: none;
  color: var(--ink);
}

.brand__bowl {
  fill: currentColor;
}

.brand__tick {
  stroke: var(--accent);
}

.brand__text small {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.58rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-3);
  font-weight: 500;
  line-height: 1.2;
}

.site-nav {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.site-nav a {
  padding: 0.45rem 0.7rem;
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: var(--ink-2);
  font-size: 0.92rem;
  font-weight: 500;
}

.site-nav a:hover {
  color: var(--ink);
  background: var(--surface-3);
}

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

.icon-btn {
  width: 38px;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--rule);
  background: var(--surface);
  color: var(--ink-2);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background-color 150ms ease, color 150ms ease, border-color 150ms ease;
}

.icon-btn:hover {
  color: var(--ink);
  border-color: var(--rule-strong);
  background: var(--surface-2);
}

.icon-btn svg {
  width: 18px;
  height: 18px;
}

.theme-toggle .icon-moon,
[data-theme='dark'] .theme-toggle .icon-sun {
  display: none;
}

[data-theme='dark'] .theme-toggle .icon-moon {
  display: block;
}

.nav-toggle {
  display: none;
}

/* 6. Hero ================================================================= */

.hero {
  padding-block: clamp(3rem, 7vw, 5.5rem) clamp(2rem, 4vw, 3rem);
  border-bottom: 1px solid var(--rule);
  background:
    radial-gradient(120% 120% at 12% 0%, var(--accent-soft) 0%, transparent 55%),
    var(--canvas);
}

.hero__grid {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr);
  gap: clamp(2rem, 5vw, 4rem);
  align-items: start;
}

.hero h1 {
  margin-bottom: 0.5rem;
}

.hero h1 em {
  font-style: normal;
  color: var(--accent);
}

.hero__lede {
  font-size: clamp(1.05rem, 1.7vw, 1.25rem);
  color: var(--ink-2);
  max-width: 56ch;
}

.hero__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin: 1.75rem 0 1.25rem;
}

.hero__note {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--ink-3);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.hero__note::before {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ok);
  flex: none;
}

.spec-card {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  overflow: hidden;
}

.spec-card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem 1.15rem;
  border-bottom: 1px solid var(--rule);
  background: var(--surface-2);
}

.spec-card__head span {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-3);
}

.spec-card__body {
  padding: 1.15rem;
}

.spec-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.7rem 0;
  border-bottom: 1px dashed var(--rule);
}

.spec-row:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.spec-row dt {
  color: var(--ink-2);
  font-size: 0.92rem;
}

.spec-row dd {
  margin: 0;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 0.95rem;
  color: var(--ink);
}

.spec-card__foot {
  padding: 0.9rem 1.15rem;
  border-top: 1px solid var(--rule);
  background: var(--surface-2);
  font-size: 0.85rem;
  color: var(--ink-3);
}

/* 7. Tool: editor ======================================================== */

.tool {
  padding-block: clamp(2.5rem, 6vw, 4rem);
}

.tool__grid {
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(0, 0.92fr);
  gap: 1.25rem;
  align-items: start;
}

.card {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.85rem 1.1rem;
  border-bottom: 1px solid var(--rule);
}

.card__title {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin: 0;
  font-weight: 500;
}

.card__body {
  padding: 1.1rem;
}

.card__body--row {
  border-top: 1px solid var(--rule);
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
}

.field-label {
  display: block;
  font-size: 0.76rem;
  color: var(--ink-3);
  margin-bottom: 0.3rem;
}

.number-input {
  width: 96px;
  padding: 0.35rem 0.5rem;
  border: 1px solid var(--rule);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

.editor {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 520px;
}

.editor__toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  padding: 0.7rem 0.85rem;
  border-bottom: 1px solid var(--rule);
  background: var(--surface-2);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.editor__spacer {
  flex: 1 1 auto;
}

.file-badge {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--ink-3);
  border: 1px solid var(--rule);
  border-radius: 999px;
  padding: 0.15rem 0.6rem;
  max-width: 190px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.editor__field {
  position: relative;
  flex: 1 1 auto;
  display: flex;
  background: var(--surface);
}

/* The manuscript margin rule — the one place the accent line appears in the
   editing surface. */
.editor__field::before {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  left: 58px;
  width: 1px;
  background: var(--accent);
  opacity: 0.28;
  pointer-events: none;
}

.editor__input {
  width: 100%;
  border: 0;
  resize: vertical;
  background: transparent;
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 1.02rem;
  line-height: 1.85;
  padding: 1.25rem 1.25rem 1.25rem 76px;
  min-height: 460px;
  tab-size: 4;
}

.editor__input:focus {
  outline: none;
}

.editor__input::placeholder {
  color: var(--ink-3);
}

.editor__foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.6rem 1.1rem;
  border-top: 1px solid var(--rule);
  background: var(--surface-2);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

.editor__status {
  font-family: var(--font-mono);
  font-size: 0.76rem;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}

.empty-state {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  text-align: center;
  gap: 0.75rem;
  padding: 2rem;
  background: var(--surface);
  z-index: 2;
}

.empty-state[hidden] {
  display: none;
}

.empty-state__title {
  font-family: var(--font-display);
  font-size: 1.3rem;
  margin: 0;
}

.empty-state p {
  color: var(--ink-3);
  max-width: 42ch;
  margin: 0;
}

.drop-overlay {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: grid;
  place-content: center;
  text-align: center;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  border: 2px dashed var(--accent);
  border-radius: var(--radius-lg);
  color: var(--accent);
  font-weight: 600;
  pointer-events: none;
}

.drop-overlay[hidden] {
  display: none;
}

/* 8. Tool: dashboard ====================================================== */

.dashboard {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.readout {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.35rem;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}

.readout__label {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin: 0 0 0.15rem;
}

.readout__value {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: clamp(3rem, 9vw, 4.25rem);
  line-height: 1;
  font-weight: 500;
  letter-spacing: -0.03em;
  color: var(--ink);
  display: block;
}

.readout__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 1.25rem;
  margin-top: 0.65rem;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--ink-3);
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(132px, 1fr));
  border-top: 1px solid var(--rule);
}

.stat {
  padding: 0.85rem 1.1rem;
  border-bottom: 1px solid var(--rule);
  border-right: 1px solid var(--rule);
}

.stat__label {
  display: block;
  font-size: 0.76rem;
  color: var(--ink-3);
  letter-spacing: 0.02em;
  margin-bottom: 0.2rem;
}

.stat__value {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 1.15rem;
  font-weight: 500;
  color: var(--ink);
  transition: color 200ms ease;
}

.stat__value.is-updated {
  animation: stat-tick 380ms ease;
}

@keyframes stat-tick {
  0% { color: var(--accent); transform: translateY(-2px); }
  100% { color: var(--ink); transform: translateY(0); }
}

/* Goal ruler ------------------------------------------------------------- */

.goal {
  display: block;
}

.goal__presets {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 1rem;
}

.goal__preset {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  padding: 0.35rem 0.65rem;
  border: 1px solid var(--rule);
  background: var(--surface);
  color: var(--ink-2);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: border-color 150ms ease, color 150ms ease, background-color 150ms ease;
}

.goal__preset:hover {
  border-color: var(--ink-3);
  color: var(--ink);
}

.goal__preset.is-active {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
}

.goal__custom {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1.1rem;
}

.goal__custom label {
  font-size: 0.85rem;
  color: var(--ink-2);
}

.goal__custom input {
  width: 110px;
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--rule);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

.goal__scale {
  position: relative;
  height: 40px;
  border-block: 1px solid var(--rule-strong);
  background-image:
    repeating-linear-gradient(to right, var(--rule-strong) 0 1px, transparent 1px 56px),
    repeating-linear-gradient(to right, var(--rule) 0 1px, transparent 1px 14px);
  background-size: 100% 14px, 100% 8px;
  background-position: left top, left bottom;
  background-repeat: repeat-x;
  margin-bottom: 0.85rem;
}

.goal__fill {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  background: var(--accent-soft);
  border-right: 2px solid var(--accent);
  transition: width 240ms cubic-bezier(0.4, 0, 0.2, 1);
}

.goal__marker {
  position: absolute;
  top: -5px;
  bottom: -5px;
  width: 2px;
  background: var(--accent);
  transform: translateX(-1px);
  transition: left 240ms cubic-bezier(0.4, 0, 0.2, 1);
}

.goal__marker::before {
  content: '';
  position: absolute;
  top: -6px;
  left: 50%;
  transform: translateX(-50%);
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 6px solid var(--accent);
}

.goal__readout {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 0.85rem;
  color: var(--ink-2);
}

.goal__percent {
  font-size: 1.05rem;
  color: var(--ink);
}

.goal__remaining {
  font-size: 0.82rem;
  margin: 0.35rem 0 0;
}

.goal__status {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--ink-3);
  padding: 0.15rem 0.5rem;
  border: 1px solid var(--rule);
  border-radius: 999px;
}

.goal__status[data-state='reached'] {
  color: var(--ok);
  border-color: var(--ok);
  background: var(--ok-soft);
}

.goal__status[data-state='active'] {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-soft);
}

/* Keyword table ---------------------------------------------------------- */

.switch {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
  color: var(--ink-2);
  cursor: pointer;
  user-select: none;
}

.switch input {
  appearance: none;
  width: 34px;
  height: 19px;
  border-radius: 999px;
  background: var(--surface-3);
  border: 1px solid var(--rule-strong);
  position: relative;
  cursor: pointer;
  transition: background-color 150ms ease, border-color 150ms ease;
  margin: 0;
  flex: none;
}

.switch input::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  transition: transform 160ms ease;
}

.switch input:checked {
  background: var(--accent);
  border-color: var(--accent);
}

.switch input:checked::after {
  transform: translateX(15px);
}

.keyword-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.86rem;
}

.keyword-table th {
  text-align: left;
  font-family: var(--font-mono);
  font-size: 0.66rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-3);
  font-weight: 500;
  padding: 0 0.5rem 0.5rem;
  border-bottom: 1px solid var(--rule);
}

.keyword-table td {
  padding: 0.4rem 0.5rem;
  border-bottom: 1px solid var(--rule);
  vertical-align: middle;
}

.keyword-table tr:last-child td {
  border-bottom: 0;
}

.keyword__word {
  font-weight: 500;
  max-width: 130px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.keyword__bar-cell {
  width: 34%;
}

.keyword__bar {
  display: block;
  height: 6px;
  background: var(--surface-3);
  border-radius: 999px;
  overflow: hidden;
}

.keyword__bar-fill {
  display: block;
  height: 100%;
  background: var(--accent);
  opacity: 0.75;
  border-radius: 999px;
  transition: width 200ms ease;
}

.keyword__count,
.keyword__density {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  text-align: right;
  color: var(--ink-2);
  white-space: nowrap;
}

.keyword-empty {
  color: var(--ink-3);
  font-size: 0.88rem;
  margin: 0.5rem 0 0;
}

.density-note {
  margin: 0.9rem 0 0;
}

/* 9. Content sections ==================================================== */

.feature-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1rem;
}

.feature {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 1.35rem;
  transition: border-color 180ms ease, transform 180ms ease, box-shadow 180ms ease;
}

.feature:hover {
  border-color: var(--rule-strong);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.feature__icon {
  width: 34px;
  height: 34px;
  display: grid;
  place-content: center;
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  color: var(--accent);
  margin-bottom: 0.9rem;
}

.feature__icon svg {
  width: 18px;
  height: 18px;
}

.feature h3 {
  font-size: 1.08rem;
  margin-bottom: 0.35rem;
}

.feature p {
  color: var(--ink-2);
  font-size: 0.93rem;
  margin: 0;
}

.steps {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.25rem;
}

.step {
  border-top: 2px solid var(--ink);
  padding-top: 1rem;
}

.step__number {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.16em;
  color: var(--accent);
  display: block;
  margin-bottom: 0.5rem;
}

.step h3 {
  font-size: 1.05rem;
  margin-bottom: 0.3rem;
}

.step p {
  color: var(--ink-2);
  font-size: 0.93rem;
  margin: 0;
}

.editorial {
  display: grid;
  grid-template-columns: minmax(0, 0.42fr) minmax(0, 0.58fr);
  gap: clamp(1.5rem, 5vw, 4rem);
  align-items: start;
}

.editorial + .editorial {
  margin-top: clamp(2.5rem, 5vw, 3.5rem);
  padding-top: clamp(2.5rem, 5vw, 3.5rem);
  border-top: 1px solid var(--rule);
}

.editorial h2 {
  position: sticky;
  top: 96px;
}

.editorial p {
  color: var(--ink-2);
  max-width: 68ch;
}

.editorial p:last-child {
  margin-bottom: 0;
}

.editorial strong {
  color: var(--ink);
  font-weight: 600;
}

.editorial code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  background: var(--surface-3);
  border: 1px solid var(--rule);
  border-radius: 4px;
  padding: 0.05em 0.35em;
}

.usecase-list {
  list-style: none;
  padding: 0;
  margin: 1.25rem 0 0;
  border-top: 1px solid var(--rule);
}

.usecase-list li {
  display: grid;
  grid-template-columns: minmax(0, 9rem) minmax(0, 1fr);
  gap: 1rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--rule);
  font-size: 0.93rem;
}

.usecase-list b {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--accent);
  letter-spacing: 0.02em;
}

.usecase-list span {
  color: var(--ink-2);
}

.faq {
  display: grid;
  gap: 0.5rem;
  max-width: 860px;
}

.faq details {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  overflow: hidden;
}

.faq summary {
  cursor: pointer;
  padding: 1rem 1.15rem;
  font-weight: 500;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  transition: background-color 150ms ease;
}

.faq summary::-webkit-details-marker {
  display: none;
}

.faq summary:hover {
  background: var(--surface-2);
}

.faq summary::after {
  content: '+';
  font-family: var(--font-mono);
  font-size: 1.15rem;
  color: var(--accent);
  flex: none;
  line-height: 1;
}

.faq details[open] summary::after {
  content: '\2212';
}

.faq__body {
  padding: 0 1.15rem 1.15rem;
  color: var(--ink-2);
  font-size: 0.95rem;
}

.faq__body p:last-child {
  margin-bottom: 0;
}

.privacy-note {
  display: flex;
  gap: 0.9rem;
  align-items: flex-start;
  background: var(--ok-soft);
  border: 1px solid color-mix(in srgb, var(--ok) 40%, transparent);
  border-radius: var(--radius);
  padding: 1.15rem 1.25rem;
  max-width: 760px;
}

.privacy-note svg {
  width: 22px;
  height: 22px;
  color: var(--ok);
  flex: none;
  margin-top: 2px;
}

.privacy-note p {
  margin: 0;
  color: var(--ink-2);
  font-size: 0.95rem;
}

.privacy-note strong {
  color: var(--ink);
}

/* Advertising slots ----------------------------------------------------- */

/* Sidebar banner unit. It sits at the top of the right-hand column, above
   the readings. The slot reserves its height so that serving a creative
   later cannot shift the layout. */
.ad-banner {
  background: transparent;
  padding: 0;
}

.ad-banner__inner {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.3rem;
}

.ad-banner__label {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 0.6rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ink-3);
}

.ad-banner__slot {
  width: 100%;
  max-width: 728px;
  min-height: 90px;
  display: grid;
  place-content: center;
  border: 1px dashed var(--rule-strong);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
}

.ad-banner__placeholder {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--ink-3);
  padding: 0 1rem;
  text-align: center;
}

/* Once a provider has filled the slot, the placeholder and the dashed frame
   disappear so only the creative is visible. */
.ad-banner__slot[data-ad-state='filled'] {
  border-style: solid;
  border-color: transparent;
  background: transparent;
}

.ad-banner__slot[data-ad-state='filled'] .ad-banner__placeholder {
  display: none;
}

.ad-slot {
  border: 1px dashed var(--rule-strong);
  border-radius: var(--radius);
  background: var(--surface-2);
  min-height: 96px;
  display: grid;
  place-content: center;
  text-align: center;
  padding: 1rem;
  color: var(--ink-3);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.ad-slot--inline {
  margin-block: clamp(2rem, 5vw, 3rem);
}

/* Small screens: a compact 320x100 unit. */
@media (max-width: 480px) {
  .ad-banner__slot {
    max-width: 320px;
    min-height: 100px;
  }
}

/* Two-column layout: the unit lives in the narrow right-hand rail, so it
   takes the medium leaderboard instead of a full-width banner. */
@media (min-width: 1041px) {
  .ad-banner__slot {
    max-width: 468px;
    min-height: 60px;
  }
}

/* Footer ---------------------------------------------------------------- */

.site-footer-band {
  border-top: 1px solid var(--rule);
  background: var(--surface-2);
}

.site-footer {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) repeat(2, minmax(0, 0.6fr));
  gap: 2rem;
}

.site-footer ul {
  list-style: none;
  padding: 0;
  margin: 0.85rem 0 0;
}

.site-footer li {
  margin-bottom: 0.45rem;
}

.site-footer li a {
  color: var(--ink-2);
  text-decoration: none;
  font-size: 0.9rem;
}

.site-footer li a:hover {
  color: var(--accent);
  text-decoration: underline;
}

.footer-note {
  font-size: 0.88rem;
  max-width: 34ch;
  margin: 0.9rem 0 0;
}

.footer-base {
  font-size: 0.82rem;
  margin: 2rem 0 0;
  padding-top: 1.25rem;
  border-top: 1px solid var(--rule);
}

/* 10. Utility: toasts, dialog, overlays ================================== */

.toast-region {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 80;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-width: min(380px, calc(100vw - 2rem));
}

.toast {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--surface);
  border: 1px solid var(--rule-strong);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  padding: 0.75rem 0.85rem;
  font-size: 0.9rem;
  animation: toast-in 220ms ease;
}

.toast--success {
  border-left-color: var(--ok);
}

.toast--error {
  border-left-color: var(--accent);
}

.toast.is-leaving {
  animation: toast-out 220ms ease forwards;
}

.toast__label {
  flex: 1 1 auto;
}

.toast__close {
  border: 0;
  background: transparent;
  color: var(--ink-3);
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
  padding: 0 0.2rem;
}

.toast__close:hover {
  color: var(--ink);
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes toast-out {
  to { opacity: 0; transform: translateY(6px); }
}

dialog {
  border: 1px solid var(--rule);
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--ink);
  padding: 1.5rem;
  max-width: 420px;
  width: calc(100% - 2rem);
  box-shadow: var(--shadow-lg);
}

dialog::backdrop {
  background: rgba(9, 12, 16, 0.55);
}

dialog h2 {
  font-size: 1.25rem;
  margin-bottom: 0.4rem;
}

dialog p {
  color: var(--ink-2);
  font-size: 0.94rem;
}

.dialog__actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 1.25rem;
}

/* 11. Motion & responsive ================================================ */

[data-reveal] {
  opacity: 0;
  transform: translateY(14px);
  transition: opacity 520ms ease, transform 520ms ease;
}

[data-reveal].is-visible {
  opacity: 1;
  transform: none;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }

  [data-reveal] {
    opacity: 1;
    transform: none;
  }
}

@media (max-width: 1040px) {
  .hero__grid,
  .tool__grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .editorial {
    grid-template-columns: minmax(0, 1fr);
  }

  .editorial h2 {
    position: static;
  }
}

@media (max-width: 860px) {
  .nav-toggle {
    display: inline-flex;
  }

  .site-nav {
    position: fixed;
    inset: 64px 0 auto 0;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    background: var(--surface);
    border-bottom: 1px solid var(--rule);
    padding: 0.5rem var(--gutter) 1rem;
    box-shadow: var(--shadow-lg);
    transform: translateY(-120%);
    transition: transform 220ms ease;
    visibility: hidden;
  }

  .site-nav.is-open {
    transform: translateY(0);
    visibility: visible;
  }

  .site-nav a {
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--rule);
    border-radius: 0;
  }

  .site-nav a:last-child {
    border-bottom: 0;
  }

  .header-actions {
    margin-left: auto;
  }
}

@media (max-width: 640px) {
  body {
    font-size: 0.97rem;
  }

  .editor__field::before {
    left: 40px;
  }

  .editor__input {
    padding: 1.1rem 1rem 1.1rem 56px;
    font-size: 1rem;
    line-height: 1.75;
  }

  .editor {
    min-height: 420px;
  }

  .editor__input {
    min-height: 340px;
  }

  .hero__actions .btn {
    flex: 1 1 100%;
  }

  .stat-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .stat {
    padding: 0.7rem 0.85rem;
  }

  .usecase-list li {
    grid-template-columns: minmax(0, 1fr);
    gap: 0.15rem;
  }

  .keyword__bar-cell {
    display: none;
  }

  .toast-region {
    left: 1rem;
    right: 1rem;
    max-width: none;
  }

  .site-footer {
    grid-template-columns: minmax(0, 1fr);
    gap: 1.5rem;
  }
}

@media print {
  .site-header,
  .hero__actions,
  .editor__toolbar,
  .toast-region,
  .ad-slot,
  .dashboard {
    display: none !important;
  }

  body {
    background: #fff;
  }
}
