/* ============================================================
   Tools · shared.css
   Porcelain workbench: cool porcelain canvas, green-black ink,
   hairline borders, one pine accent, green "local" LEDs.
   Flat surfaces. No gradients, no shadows, no accent bars.
   ============================================================ */

/* ---------- Font ---------- */
@font-face {
  font-family: 'Schibsted Grotesk';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url('fonts/schibsted-grotesk-var.woff2') format('woff2');
}

/* ---------- Tokens ---------- */
:root {
  color-scheme: light;
  --canvas: #f3f4ef;
  --surface: #fcfcfa;
  --surface-2: #eceee6;
  --border: #e0e2d8;
  /* Control boundaries, not decorative hairlines. 3.34:1 on surface. */
  --border-strong: #878d7b;
  --ink: #1b1d18;
  /* 5.94 on surface, 5.52 on canvas, 5.21 on surface-2, 5.15 on accent-soft */
  --muted: #5f6456;
  --accent: #1e7a55;
  --accent-down: #166042;
  --accent-ink: #f6fbf8;
  --accent-soft: #e2efe7;
  /* 4.25:1 on surface: the LED carries meaning, so it has to be seen */
  --led: #178a57;
  --danger: #b3392e;
  --danger-soft: #f7e9e7;
  --grotesk: 'Schibsted Grotesk', system-ui, sans-serif;
  --system: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --mono: ui-monospace, 'SF Mono', 'Cascadia Code', Consolas, monospace;
}

:root[data-theme='dark'] {
  color-scheme: dark;
  --canvas: #151713;
  --surface: #1c1f1a;
  --surface-2: #232722;
  /* Light enough to keep the hairline visible against --surface; the
     borders are what hold the layout together in this design. */
  --border: #33382f;
  --border-strong: #6a7066;
  --ink: #e8eae2;
  --muted: #9aa091;
  --accent: #4ecb96;
  --accent-down: #66d6a6;
  --accent-ink: #0f241a;
  --accent-soft: #26432f;
  --led: #46c584;
  --danger: #e07568;
  --danger-soft: #33231f;
}

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

/* display:flex on a class would silently beat the UA [hidden] rule */
[hidden] {
  display: none !important;
}

html {
  height: 100%;
}

body {
  height: 100%;
  background: var(--canvas);
  color: var(--ink);
  font-family: var(--system);
  font-size: 0.875rem;
  line-height: 1.5;
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
  /* The document itself must never scroll. `overflow-y: scroll` here
     also silently breaks position:sticky, because it turns body into a
     scroll container that does not actually move. */
  overflow: hidden;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  cursor: pointer;
}

a {
  color: inherit;
  text-decoration: none;
}

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

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

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

/* ---------- Shell ---------- */
/* dvh is stable here precisely because the document never scrolls, so
   mobile chrome never collapses and the value never changes mid-gesture.
   vh is the fallback for engines without dvh. */
.shell {
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.topbar {
  flex: 0 0 auto;
  background: var(--canvas);
  padding-top: env(safe-area-inset-top, 0px);
}

/* One measure for the bar and the content beneath it, so the wordmark
   lines up with the first card. */
.bar-inner {
  max-width: 1160px;
  margin: 0 auto;
  width: 100%;
  padding-left: calc(20px + env(safe-area-inset-left, 0px));
  padding-right: calc(20px + env(safe-area-inset-right, 0px));
}

main {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
}

/* The OS scrollbar is the one piece of chrome that would undo the flat,
   hairline look, and now that main is the scroller we own it. The thumb
   is a canvas-coloured border over a clipped background, which is what
   gives it the inset pill shape without a track. */
main::-webkit-scrollbar,
.t-textarea::-webkit-scrollbar {
  width: 12px;
}

main::-webkit-scrollbar-track,
.t-textarea::-webkit-scrollbar-track {
  background: transparent;
}

main::-webkit-scrollbar-thumb,
.t-textarea::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 999px;
  border: 4px solid var(--canvas);
  background-clip: padding-box;
}

main::-webkit-scrollbar-thumb:hover,
.t-textarea::-webkit-scrollbar-thumb:hover {
  background: var(--muted);
  background-clip: padding-box;
}

.t-textarea::-webkit-scrollbar-thumb {
  border-color: var(--surface);
}

/* Firefox only. Setting scrollbar-color in Chromium REPLACES the rules
   above and reverts to the OS width, so it must stay behind this gate. */
@supports not selector(::-webkit-scrollbar) {
  main,
  .t-textarea {
    scrollbar-width: thin;
    scrollbar-color: var(--border-strong) transparent;
  }
}

.main-inner {
  display: flex;
  flex-direction: column;
  min-height: 100%;
  padding-bottom: calc(28px + env(safe-area-inset-bottom, 0px));
}

/* ---------- Header ---------- */
header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 26px 0 20px;
  user-select: none;
  -webkit-user-select: none;
}

.brand {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.wordmark {
  font-family: var(--grotesk);
  font-weight: 700;
  font-size: 24px;
  letter-spacing: -0.02em;
  line-height: 1;
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  width: fit-content;
}

.led {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--led);
  display: inline-block;
  flex: 0 0 auto;
}

.led-inline {
  width: 6px;
  height: 6px;
  margin-right: 6px;
  vertical-align: 1px;
}

.status {
  font-size: 11px;
  color: var(--muted);
}

.status-short {
  display: none;
}

.icon-btn {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  font-size: 17px;
  color: var(--ink);
  transition: border-color 150ms ease;
}

.icon-btn:hover {
  border-color: var(--border-strong);
}

/* ---------- Search ---------- */
/* No sticky needed: the bar lives outside the scroller, so it stays put
   by construction. */
.searchbar {
  padding: 0 0 16px;
  display: flex;
  align-items: center;
  position: relative;
}

.search-ico {
  position: absolute;
  left: 16px;
  width: 17px;
  height: 17px;
  color: var(--muted);
  pointer-events: none;
}

#search {
  width: 100%;
  height: 48px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 15px;
  padding: 0 44px 0 42px;
  transition: border-color 150ms ease;
  appearance: none;
  -webkit-appearance: none;
}

#search::-webkit-search-cancel-button {
  display: none;
}

#search::placeholder {
  color: var(--muted);
}

#search:focus {
  outline: none;
  border-color: var(--accent);
}

.search-kbd {
  position: absolute;
  right: 12px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 2px 7px;
  background: var(--canvas);
}

/* ---------- Sections + grid ---------- */
#home {
  flex: 1 0 auto;
}

.section {
  margin: 0 0 32px;
}

.eyebrow {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.eyebrow h2 {
  font-family: var(--grotesk);
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--muted);
}

.eyebrow .rule {
  flex: 1;
  height: 1px;
  background: var(--border);
}

.eyebrow .count {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
}

/* Constrain the card, not the viewport: this holds 4 columns on a wide
   desktop and steps down on its own, with no half-empty rows of
   oversized cards in between. */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(232px, 1fr));
  gap: 12px;
}

/* ---------- Cards ---------- */
.card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  text-align: left;
  transition: border-color 150ms ease, transform 150ms ease;
}

a.card:hover {
  border-color: var(--border-strong);
}

a.card:active {
  transform: scale(0.985);
}

.card-ico {
  width: 26px;
  height: 26px;
  color: var(--ink);
  flex: 0 0 auto;
}

.card-body {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.card-title {
  font-family: var(--grotesk);
  font-weight: 600;
  font-size: 15px;
  letter-spacing: -0.01em;
  line-height: 1.25;
}

.card-desc {
  font-size: 13px;
  line-height: 1.45;
  color: var(--muted);
}

.card-foot {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
}

.card-foot .led {
  width: 5px;
  height: 5px;
}

/* Roadmap strip: names only, no card chrome, so it reads as a list of
   what is coming rather than a row of broken tools. */
.soon-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  list-style: none;
}

.soon-list.has-cards {
  margin-top: 10px;
}

.soon-list li {
  border: 1px dashed var(--border-strong);
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 12.5px;
  color: var(--muted);
}

.no-results {
  padding: 40px 0 60px;
  text-align: center;
  color: var(--muted);
}

.no-results .big {
  font-family: var(--grotesk);
  font-weight: 600;
  font-size: 17px;
  color: var(--ink);
  margin-bottom: 4px;
}

/* ---------- Stage (tool view) ---------- */
/* A tool reads better in a narrow measure than stretched across a wide
   desktop, but centring that measure inside the 1160px frame left the
   heading floating a couple of hundred pixels right of the wordmark with
   nothing lining up. Same measure, aligned to the same left edge as the
   header and the card grid. */
/* Canvas and preview tools opt in with `wide: true` on their module, so
   a drawing surface gets the room a form does not need. */
#stage.wide {
  max-width: 1160px;
}

#stage {
  flex: 1 0 auto;
  max-width: 860px;
  width: 100%;
  margin: 0;
  padding: 0 0 40px;
}

/* Wide screens get the preview and its controls side by side rather
   than a tall single column with dead space either side. */
@media (min-width: 1000px) {
  .tool-2col {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 300px;
    gap: 16px;
    align-items: start;
  }

  .tool-2col > * {
    min-width: 0;
  }

  /* Equal halves, for before-and-after tools like Clean up text */
  .tool-2col.even {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }
}

.tool-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 24px;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--grotesk);
  font-weight: 600;
  font-size: 14px;
  color: var(--muted);
  transition: color 150ms ease;
}

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

.local-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 10px;
}

.local-tag .led {
  width: 5px;
  height: 5px;
}

.tool-head {
  margin-bottom: 24px;
}

.tool-head h1 {
  font-family: var(--grotesk);
  font-weight: 700;
  font-size: 24px;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

/* The heading is only ever focused by the router, to move a screen
   reader into the new view. Nobody tabbed here, so no ring. */
.tool-head h1:focus,
.tool-head h1:focus-visible {
  outline: none;
}

.tool-head p {
  margin-top: 4px;
  font-size: 14px;
  color: var(--muted);
}

/* ---------- Shared tool primitives ---------- */
/* The one spacing primitive. Every stacked group in a tool uses this
   rather than inline flex styles, so vertical rhythm is set in one
   place instead of drifting per file. */
.t-stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* A button in a stack sizes to its label; only fields fill the width */
.t-stack > .t-btn {
  align-self: flex-start;
}

.t-panel {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  padding: 16px;
}

.t-panel.t-stack {
  gap: 16px;
}

.t-drop {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 152px;
  width: 100%;
  border: 1px dashed var(--border-strong);
  border-radius: 12px;
  background: var(--surface);
  color: var(--muted);
  font-size: 13px;
  padding: 24px;
  text-align: center;
  transition: border-color 150ms ease, background-color 150ms ease;
}

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

/* The accent fill is reserved for a file actually being over the target,
   so it stays a signal rather than a hover flourish. */
.t-drop.is-over {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--ink);
}

.t-drop .big {
  font-family: var(--grotesk);
  font-weight: 600;
  font-size: 16px;
  color: var(--ink);
}

.t-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 40px;
  padding: 0 18px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: var(--surface);
  font-family: var(--grotesk);
  font-weight: 600;
  font-size: 14px;
  color: var(--ink);
  transition: border-color 150ms ease, background-color 150ms ease, transform 120ms ease;
}

.t-btn:hover {
  border-color: var(--border-strong);
}

.t-btn:active {
  transform: scale(0.98);
}

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

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

.t-btn:disabled {
  opacity: 0.45;
  cursor: default;
  transform: none;
}

.t-btn-sm {
  height: 32px;
  padding: 0 12px;
  font-size: 13px;
}

.t-btn-icon {
  width: 32px;
  padding: 0;
  flex: 0 0 auto;
}

.t-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.t-label {
  font-family: var(--grotesk);
  font-weight: 600;
  font-size: 12px;
  letter-spacing: 0.02em;
  color: var(--muted);
}

.t-input,
.t-select,
.t-textarea {
  width: 100%;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  padding: 9px 12px;
  transition: border-color 150ms ease;
}

.t-textarea {
  min-height: 140px;
  resize: vertical;
  line-height: 1.55;
}

.t-input:focus,
.t-select:focus,
.t-textarea:focus {
  outline: none;
  border-color: var(--accent);
}

/* The accent border is the resting affordance; keyboard users still get
   a real ring, which the :focus rule above would otherwise suppress. */
.t-input:focus-visible,
.t-select:focus-visible,
.t-textarea:focus-visible,
#search:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

/* Drawn inside, or .t-seg's own overflow clips the ring */
.t-seg button:focus-visible {
  outline-offset: -2px;
}

.t-row {
  display: flex;
  gap: 10px;
  align-items: end;
  flex-wrap: wrap;
}

.t-row > .t-field {
  flex: 1;
}

/* Labelled columns of related controls. Top-aligned, unlike .t-row's
   end alignment, so groups of different heights hang from one line. */
.t-cols {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
}

.t-cols > * {
  flex: 1 1 180px;
  min-width: 0;
}

.t-seg {
  display: inline-flex;
  align-self: flex-start;
  max-width: 100%;
  overflow-x: auto;
  scrollbar-width: none;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  padding: 3px;
  gap: 2px;
}

.t-seg::-webkit-scrollbar {
  display: none;
}

.t-seg button {
  flex: 0 0 auto;
}

.t-seg button {
  height: 32px;
  padding: 0 12px;
  border-radius: 8px;
  font-family: var(--grotesk);
  font-weight: 600;
  font-size: 13px;
  color: var(--muted);
  transition: color 150ms ease, background-color 150ms ease;
}

.t-seg button[aria-pressed='true'],
.t-seg button[aria-checked='true'] {
  background: var(--accent-soft);
  color: var(--ink);
  box-shadow: inset 0 0 0 1px var(--accent);
}

.t-check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  cursor: pointer;
  user-select: none;
}

.t-check input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

.t-range {
  width: 100%;
  accent-color: var(--accent);
}

.t-help {
  font-size: 12px;
  line-height: 1.5;
  color: var(--muted);
}

.t-error {
  border: 1px solid var(--danger);
  background: var(--danger-soft);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 13px;
  color: var(--ink);
}

.preview-canvas {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 0 auto;
  border-radius: 8px;
}

.t-file-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  font-family: var(--mono);
  font-size: 12px;
  min-width: 0;
}

.t-file-row .name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}

.t-file-row .size {
  color: var(--muted);
  flex: 0 0 auto;
}

.t-out {
  font-family: var(--mono);
  font-size: 15px;
  background: var(--surface-2);
  border-radius: 10px;
  padding: 16px;
  word-break: break-all;
  user-select: all;
}

/* The answer carries the weight; the question it answers sits under it */
.t-result {
  text-align: center;
  user-select: text;
}

.t-result .out-value {
  font-family: var(--grotesk);
  font-weight: 700;
  font-size: 22px;
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  user-select: all;
}

.t-result .out-source {
  margin-top: 4px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
}

.t-stat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.t-stat {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  padding: 12px 16px;
}

.t-stat .v {
  font-family: var(--grotesk);
  font-weight: 700;
  font-size: 20px;
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
}

.t-stat .k {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
}

/* A stat whose value is a word rather than a number. The line height
   matches the 20px numeric stats so the boxes stay one height. */
.t-stat .v.txt {
  font-size: 15px;
  line-height: 30px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Horizontal data bars (letter frequency and the like). The count is
   always printed beside the bar, so the bar is never the only signal. */
.t-bars {
  display: grid;
  grid-template-columns: auto minmax(40px, 1fr) auto;
  align-items: center;
  gap: 6px 10px;
  font-family: var(--mono);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.t-bars .ch {
  min-width: 1.5em;
  text-align: center;
}

.t-bars .track {
  height: 12px;
  min-width: 0;
  border-radius: 4px;
  background: var(--surface-2);
  overflow: hidden;
}

.t-bars .fill {
  height: 100%;
  border-radius: 4px;
  background: var(--border-strong);
}

.t-bars .num {
  color: var(--muted);
  white-space: nowrap;
}

/* Term and count rows: top words and other small rankings */
.t-pairs {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 12px;
  font-family: var(--mono);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.t-pairs .term {
  min-width: 0;
  overflow-wrap: anywhere;
}

.t-pairs .num {
  color: var(--muted);
}

/* Four stats in one row; the mobile rule below still steps it to two. */
.t-stat-grid-4 {
  grid-template-columns: repeat(4, 1fr);
}

/* Typing practice: three lines are visible, and the passage slides
   inside the clip via a transform, so the page never scrolls while
   typing. The invisible input stretched over the box is what actually
   receives the keystrokes; 16px keeps iOS from zooming on focus. */
.t-type {
  position: relative;
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  background: var(--surface);
  padding: 14px 16px;
  cursor: text;
}

.t-type:focus-within {
  border-color: var(--accent);
}

.t-type-clip {
  overflow: hidden;
  height: 6em;
  font-family: var(--mono);
  font-size: 17px;
  line-height: 2;
}

.t-type-inner {
  position: relative;
  white-space: pre-wrap;
  overflow-wrap: break-word;
  color: var(--muted);
  user-select: none;
  -webkit-user-select: none;
  transition: transform 120ms ease;
}

.t-type-inner .ok {
  color: var(--ink);
  background: var(--accent-soft);
}

/* The underline is deliberate: a mistake must read without colour. */
.t-type-inner .bad {
  color: var(--ink);
  background: var(--danger-soft);
  text-decoration: underline;
  text-decoration-color: var(--danger);
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
}

.t-type-inner .now {
  box-shadow: inset 2px 0 0 var(--accent);
}

.t-type input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  border: 0;
  padding: 0;
  background: none;
  color: transparent;
  caret-color: transparent;
  font-size: 16px;
  cursor: text;
}

/* ---------- Footer ---------- */
footer {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding-top: 32px;
  font-size: 11px;
  color: var(--muted);
}

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

/* ---------- Dropzone overlay ---------- */
#dropzone {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: var(--canvas);
  display: flex;
  align-items: center;
  justify-content: center;
}

#dropzone::before {
  content: '';
  position: absolute;
  inset: 14px;
  border: 1px dashed var(--accent);
  border-radius: 12px;
}

.drop-title {
  font-family: var(--grotesk);
  font-weight: 700;
  font-size: 30px;
  letter-spacing: -0.02em;
  text-align: center;
}

.drop-sub {
  margin-top: 6px;
  font-size: 12px;
  color: var(--muted);
  text-align: center;
}

/* ---------- Toast ---------- */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

#toast[data-empty] {
  opacity: 0;
  pointer-events: none;
}

#toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  z-index: 60;
  background: var(--ink);
  color: var(--canvas);
  font-size: 12px;
  border-radius: 999px;
  padding: 9px 16px;
  max-width: min(90vw, 480px);
  text-align: center;
}

/* ---------- Motion ---------- */
@media (prefers-reduced-motion: no-preference) {
  #home.enter,
  #stage.enter {
    animation: rise 190ms ease-out;
  }

  @keyframes rise {
    from {
      opacity: 0;
      transform: translateY(7px);
    }
    to {
      opacity: 1;
      transform: none;
    }
  }
}

/* ---------- Responsive ---------- */
@media (max-width: 620px) {
  header {
    padding-top: 18px;
    padding-bottom: 14px;
  }

  .wordmark {
    font-size: 21px;
  }

  .status-full {
    display: none;
  }

  .status-short {
    display: inline;
  }

  .grid {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .card {
    flex-direction: row;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
  }

  .card-ico {
    width: 23px;
    height: 23px;
  }

  .card-body {
    flex: 1;
  }

  .card-foot {
    margin-top: 0;
    flex: 0 0 auto;
  }

  .card-foot .local-word {
    display: none;
  }

  .search-kbd {
    display: none;
  }

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

/* ---------- Touch and motion ---------- */
@media (pointer: coarse) {
  /* Under 16px, iOS Safari zooms the viewport on focus and never zooms back */
  .t-input,
  .t-select,
  .t-textarea,
  #search {
    font-size: 16px;
  }

  .t-btn {
    height: 44px;
  }

  .t-check {
    min-height: 44px;
  }

  .t-check input {
    width: 20px;
    height: 20px;
  }

  /* Grow the hit area to 44px without changing how the control looks */
  .t-btn-sm,
  .t-seg button,
  .icon-btn {
    position: relative;
  }

  .t-btn-sm::after,
  .t-seg button::after,
  .icon-btn::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: max(100%, 44px);
    height: 44px;
  }
}

@media (prefers-reduced-motion: reduce) {
  a.card:active,
  .t-btn:active {
    transform: none;
  }

  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}

/* ---------- Handwriting font picker ---------- */
/* A scrolling grid rather than a segmented control, because 42 faces do
   not fit in a row. Each tile previews its own face, loaded only once the
   tile scrolls into view. */
.hw-font-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(112px, 1fr));
  gap: 8px;
  max-height: 260px;
  overflow-y: auto;
  padding: 4px;
  margin-top: 8px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--canvas);
}

.hw-font-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 12px 8px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  transition: border-color 150ms ease;
}

.hw-font-tile:hover {
  border-color: var(--border-strong);
}

.hw-font-tile[aria-checked='true'] {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
}

.hw-font-sample {
  font-size: 26px;
  line-height: 1.1;
  color: var(--ink);
}

.hw-font-name {
  font-size: 11px;
  color: var(--muted);
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}
