/* components.css — the reusable building blocks.
   Screens (css/views/*.css) combine these; they never restyle them.
   Order: layout → app bar → buttons → surfaces → small parts → overlays. */

/* ── Layout containers ─────────────────────────────────────────── */
.page {
  width: 100%;
  max-width: var(--content-max);
  margin-inline: auto;
  padding: var(--s-6) var(--gutter) var(--s-6);
}
@media (max-width: 640px) {
  .page { padding-top: var(--s-4); padding-bottom: var(--s-6); }
  .page-head h1 { font-size: var(--text-2xl); }
  .page-head { gap: var(--s-3); }
}
.activity {
  width: 100%;
  max-width: var(--activity-max);
  margin-inline: auto;
  min-height: calc(100dvh - var(--bar-h) - env(safe-area-inset-top));
  display: flex; flex-direction: column;
  padding: var(--s-5) var(--gutter) var(--s-6);
}
/* The stage holds one task. It starts just below the header, so a growing
   answer panel (quiz feedback, spelling diff) opens downward instead of
   shifting the question around. */
.activity-stage { flex: 1; display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--s-4); align-content: start; min-width: 0; }
@media (max-width: 1023px) {
  /* Study and recall are one card with no feedback below: on a tall phone
     it sits in the middle of the paper instead of clinging to the header. */
  .activity-stage.stage-center { align-content: safe center; }
}
@media (max-width: 1023px) {
  body[data-mode="activity"] .activity {
    min-height: 100dvh;
    padding-top: calc(var(--s-3) + env(safe-area-inset-top));
    padding-bottom: calc(96px + env(safe-area-inset-bottom));
  }
}
.row     { display: flex; align-items: center; gap: var(--s-3); flex-wrap: wrap; }
.muted   { color: var(--ink-2); }
.hint    { color: var(--ink-3); font-size: var(--text-sm); }
.section-title {
  display: flex; align-items: baseline; justify-content: space-between; gap: var(--s-3);
  margin: var(--s-7) 0 var(--s-4);
}
.section-title h2 { font-size: var(--text-lg); }
/* Inside a card the section title is the card's heading, not a new page
   section: it starts at the card's padding, not 48px below it. */
.card > .section-title:first-child { margin-top: 0; }
.card > .section-title { margin-bottom: var(--s-3); }
@media (max-width: 560px) {
  .section-title { flex-wrap: wrap; margin: var(--s-5) 0 var(--s-3); }
  .section-title > .row { width: 100%; justify-content: space-between; }
}

/* ── App bar ─────────────────────────────────────────────────────
   Opaque paper, one hairline. Translucent chrome let scrolled headings
   ghost through the bar, which read as a rendering fault. */
.app-bar {
  position: sticky; top: 0; z-index: 20;
  height: calc(var(--bar-h) + env(safe-area-inset-top));
  padding-top: env(safe-area-inset-top);   /* installed iPhone: keep the bar under the clock */
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}
.app-bar-inner {
  height: 100%;
  max-width: var(--content-max);
  margin-inline: auto;
  padding-inline: var(--gutter);
  display: flex; align-items: center; gap: var(--s-3);
}
.brand {
  display: inline-flex; align-items: center; gap: var(--s-2);
  font-family: var(--font-display); font-weight: 700; font-size: 1.1rem;
  color: var(--ink); text-decoration: none; white-space: nowrap; letter-spacing: -.015em;
}
.brand-mark { width: 30px; height: 30px; flex: none; }
.crumbs {
  display: flex; align-items: center; gap: var(--s-2); min-width: 0;
  color: var(--ink-3); font-size: var(--text-sm);
}
.crumbs a { color: var(--ink-2); text-decoration: none; font-weight: 500; }
.crumbs a:hover { color: var(--brand); }
.crumbs span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 640px) {
  :root { --bar-h: 56px; }
  .app-bar-inner { gap: var(--s-2); padding-inline: var(--gutter); }
  .brand { font-size: 1rem; gap: 8px; }
  .brand-mark { width: 28px; height: 28px; }
  /* The page headline already names the screen; the bar stays brand chrome. */
  .crumbs { display: none; }
  .bar-actions { gap: 0; }
}
/* An activity is a focused task, not a place to browse: the phone shows its
   own header with one exit, so the app bar would only repeat it. */
@media (max-width: 1023px) {
  body[data-mode="activity"] .app-bar { display: none; }
}
/* Top-bar navigation: icon + label + count, all in flow (no overlap). */
.bar-nav { display: flex; align-items: center; gap: 2px; }
.bar-link {
  display: inline-flex; align-items: center; gap: 7px; height: 40px; padding: 0 var(--s-3);
  border-radius: var(--r-md); color: var(--ink-2); text-decoration: none; font-size: var(--text-sm); font-weight: 500;
  transition: background var(--fast), color var(--fast);
}
.bar-link:hover { background: var(--surface-2); color: var(--ink); }
.bar-link[aria-current="page"] { color: var(--brand); background: var(--brand-soft); }
.bar-ico { position: relative; display: inline-grid; }
.bar-link .count {
  min-width: 19px; height: 19px; padding: 0 6px; border-radius: var(--r-pill);
  background: var(--mark); color: var(--on-mark); font: 700 .72rem/19px var(--font-body); text-align: center;
}

/* Bottom tab bar: phones and tablets only, hidden during activities */
.tab-bar { display: none; }
@media (max-width: 1023px) {
  .bar-nav { display: none; }
  .tab-bar {
    position: fixed; z-index: 18; left: 0; right: 0; bottom: 0;
    display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;          /* as many columns as links */
    padding: 3px 6px calc(3px + env(safe-area-inset-bottom));
    background: var(--surface);
    border-top: 1px solid var(--line);
    box-shadow: 0 -6px 18px -18px rgb(20 27 45 / .35);
  }
  body[data-mode="activity"] .tab-bar { display: none; }
  body[data-mode="browse"] main { padding-bottom: calc(56px + env(safe-area-inset-bottom)); }
  .tab-link {
    display: grid; justify-items: center; align-content: center; gap: 1px;
    min-height: 54px; padding: 3px 2px; border-radius: var(--r-md);
    color: var(--ink-3); text-decoration: none; font-size: var(--text-2xs); font-weight: 600;
    letter-spacing: .005em; transition: color var(--fast);
  }
  .tab-link .icon { width: 22px; height: 22px; }
  .tab-link[aria-current="page"] { color: var(--brand); }
  .tab-link[aria-current="page"] .tab-ico { background: var(--brand-soft); }
  .tab-ico { position: relative; display: grid; place-items: center; width: 48px; height: 27px; border-radius: var(--r-pill); }
  .tab-ico .count {
    position: absolute; z-index: 1;
    top: -5px; inset-inline-end: -9px; min-width: 18px; height: 18px; padding: 0 5px;
    background: var(--mark); color: var(--on-mark);
    border: 2px solid var(--surface); font-size: .68rem; line-height: 14px;
  }
  .toast { bottom: calc(72px + env(safe-area-inset-bottom)); }
  .break-card { bottom: calc(72px + env(safe-area-inset-bottom)); }
}
.bar-actions { margin-inline-start: auto; display: flex; align-items: center; gap: var(--s-1); }

/* ── Icons ─────────────────────────────────────────────────────── */
.icon { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor;
        stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.icon-sm { width: 16px; height: 16px; }
.icon-lg { width: 24px; height: 24px; }

/* ── Buttons ───────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2);
  min-height: var(--tap); padding: 0 var(--s-4);
  border-radius: var(--r-md); border: 1px solid var(--line);
  background: var(--surface); color: var(--ink);
  font-weight: 600; font-size: var(--text-sm); line-height: 1; text-decoration: none;
  transition: background var(--fast), border-color var(--fast), transform var(--fast), color var(--fast);
  user-select: none; -webkit-user-select: none;
}
.btn:hover { border-color: var(--line-strong); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; pointer-events: none; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
.btn-primary:hover { background: var(--brand-hover); border-color: var(--brand-hover); }
.btn-quiet { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn-quiet:hover { background: var(--surface-2); color: var(--ink); }
/* A second-level action: clearly clickable, never competing with the one
   primary button on the screen. Same ink, quieter fill. */
.btn-tonal { background: var(--brand-soft); border-color: transparent; color: var(--brand); }
.btn-tonal:hover { background: color-mix(in srgb, var(--brand) 14%, var(--surface)); border-color: transparent; }
.btn-good { background: var(--good-soft); border-color: transparent; color: var(--good); }
.btn-bad  { background: var(--bad-soft);  border-color: transparent; color: var(--bad); }
.btn-lg { min-height: 52px; padding: 0 var(--s-5); font-size: var(--text-md); border-radius: var(--r-md); }
.btn-block { width: 100%; }
/* Key hints take the button's own colour, so they read on every fill. */
.btn kbd {
  font: 600 .7rem/1 var(--font-body); padding: 3px 6px; border-radius: 5px; min-width: 0;
  color: inherit; border: 1px solid color-mix(in srgb, currentColor 35%, transparent);
  background: color-mix(in srgb, currentColor 12%, transparent);
}
.icon-btn {
  display: inline-grid; place-items: center; position: relative;
  width: var(--tap); height: var(--tap); border-radius: var(--r-md);
  color: var(--ink-2); transition: background var(--fast), color var(--fast);
}
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.icon-btn[aria-pressed="true"] { color: var(--brand); }
.icon-btn .count {
  position: absolute; top: 4px; inset-inline-end: 2px;
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: var(--r-pill);
  background: var(--bad); color: #fff; font: 700 .68rem/18px var(--font-body); text-align: center;
}
.speak-btn {
  display: inline-grid; place-items: center; flex: none;
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--brand-soft); color: var(--brand);
  transition: transform var(--fast), background var(--fast);
}
.speak-btn:hover { transform: scale(1.06); }
.speak-btn.is-speaking { background: var(--brand); color: var(--on-brand); }

/* ── Surfaces ──────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-1);
}

/* ── Small parts ───────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  height: 24px; padding: 0 var(--s-2); border-radius: var(--r-sm);
  font-size: .75rem; font-weight: 600; white-space: nowrap;
  background: var(--surface-2); color: var(--ink-2);
}
.badge.lvl-a { background: var(--lvl-a-soft); color: var(--lvl-a); }
.badge.lvl-b { background: var(--lvl-b-soft); color: var(--lvl-b); }
.badge.lvl-c { background: var(--lvl-c-soft); color: var(--lvl-c); }
.badge.is-known { background: var(--good-soft); color: var(--good); }
.badge.is-learning { background: var(--mark-soft); color: var(--on-mark); }

.progress {
  height: 8px; border-radius: var(--r-pill); background: var(--surface-2); overflow: hidden;
}
.progress > i {
  display: block; height: 100%; width: var(--value, 0%);
  border-radius: inherit; background: var(--brand);
  transition: width var(--slow) var(--ease);
}
.progress.is-good > i { background: var(--good); }

/* The highlighter: a marker band across the lower half of the text.
   A plain band (no feathered edges) stays aligned on short words and long
   phrases, at every font size, and wraps cleanly across lines. */
.mark {
  background: linear-gradient(transparent 55%, var(--mark) 55%, var(--mark) 92%, transparent 92%);
  padding: 0 .08em;
  border-radius: 2px;
  color: inherit;
  -webkit-box-decoration-break: clone; box-decoration-break: clone;
}

/* Progress ring (VS.ui.ring) */
.ring { position: relative; display: inline-grid; place-items: center; flex: none; width: var(--size); height: var(--size); }
.ring svg { position: absolute; inset: 0; width: 100%; height: 100%; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 4.5; }
.ring-bg { stroke: var(--surface-2); }
.ring-fill { stroke: var(--good); stroke-linecap: round; transition: stroke-dashoffset var(--slow) var(--ease); animation: ring-in 900ms var(--ease) both; }
.ring b { font-size: calc(var(--size) * .24); font-variant-numeric: tabular-nums; color: var(--ink-2); }

/* Your note on a word (VS.ui.noteBox) */
.note { display: grid; gap: var(--s-2); }
.note-label { display: inline-flex; align-items: center; gap: 6px; font-size: var(--text-sm); font-weight: 600; color: var(--ink-2); }
.note-label .icon { color: var(--on-mark); background: var(--mark-soft); border-radius: 6px; padding: 2px; width: 22px; height: 22px; }
.note textarea {
  width: 100%; min-height: 64px; max-height: 240px; resize: none; field-sizing: content;
  padding: var(--s-2) var(--s-3); border: 1px solid var(--line); border-radius: var(--r-md);
  background: var(--surface-2); color: var(--ink); font: inherit; font-size: var(--text-sm); line-height: 1.5;
  transition: border-color var(--fast), background var(--fast), box-shadow var(--fast);
}
.note textarea::placeholder { color: var(--ink-3); }
.note textarea:hover { border-color: var(--line-strong); }
.note textarea:focus { outline: none; border-color: var(--brand); background: var(--surface); box-shadow: 0 0 0 3px var(--brand-soft); }

/* Segmented filter: one row of choices, one selected. Scrolls on phones. */
.seg {
  display: flex; gap: var(--s-1); padding: 4px; border-radius: var(--r-md);
  background: var(--surface-2); overflow-x: auto; scrollbar-width: none;
}
.seg::-webkit-scrollbar { display: none; }
.seg button {
  flex: none; min-height: 36px; padding: 0 var(--s-3); border-radius: var(--r-sm);
  font-size: var(--text-sm); font-weight: 500; color: var(--ink-2); white-space: nowrap;
}
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: var(--shadow-1); }

.field {
  display: flex; align-items: center; gap: var(--s-2);
  min-height: 46px; padding: 0 var(--s-3);
  border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface);
  color: var(--ink-3);
}
.field:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.field input { flex: 1; width: 100%; min-width: 0; border: 0; outline: 0; background: none; height: 46px; color: var(--ink); }
/* A field never grows past its container, whatever the text size: an input's natural width must not widen the page. */
.field { min-width: 0; max-width: 100%; }

/* Activity header: one exit, a short title with its scope, step counter and
   a clear progress line. The title never repeats the scope with a dot. */
.activity-head { display: grid; gap: 10px; margin-bottom: var(--s-5); }
.activity-head .row { flex-wrap: nowrap; gap: 10px; }
.activity-head h1 { font-size: var(--text-lg); line-height: 1.2; }
.activity-title { display: grid; gap: 1px; min-width: 0; flex: 1; }
.activity-sub {
  color: var(--ink-3); font-size: var(--text-xs); font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.activity-head .count { margin-inline-start: auto; font-weight: 600; color: var(--ink-2); font-variant-numeric: tabular-nums; white-space: nowrap; }
.activity-head .progress { height: 4px; }
@media (max-width: 1023px) {
  /* The activity header stays with you while the task scrolls: the way out,
     the count and the progress bar never leave the screen. */
  body[data-mode="activity"] .activity-head {
    position: sticky; top: 0; z-index: 12;
    background: var(--paper);
    margin-inline: calc(var(--gutter) * -1);
    padding: var(--s-2) var(--gutter) var(--s-2);
    margin-bottom: var(--s-3);
  }
}
@media (max-width: 640px) {
  .activity-head { gap: 8px; }
  .activity-head .combo-word { display: none; }
}

/* Sticky answer bar: on phones the main action sits under the thumb */
.action-bar {
  display: flex; gap: var(--s-3); margin-top: var(--s-5);
}
.action-bar > .btn { flex: 1; }
@media (max-width: 640px) {
  .action-bar {
    position: fixed; z-index: 15; left: 0; right: 0; bottom: 0; margin: 0;
    padding: 10px var(--gutter) calc(10px + env(safe-area-inset-bottom));
    background: var(--paper);
    border-top: 1px solid var(--line);
    box-shadow: 0 -8px 24px -22px rgb(20 27 45 / .5);
  }
  .action-bar .btn { padding: 0 var(--s-3); white-space: nowrap; }
  .action-bar .btn .icon { display: none; }
}

.empty {
  text-align: center; padding: var(--s-6) var(--s-5);
  border: 1px dashed var(--line-strong); border-radius: var(--r-lg); color: var(--ink-2);
}
.empty h2 { font-size: var(--text-lg); color: var(--ink); margin-bottom: var(--s-2); }
.empty .btn { margin-top: var(--s-4); }
.empty p + p { margin-top: var(--s-2); }
.empty-actions { justify-content: center; }
.empty-actions .btn { margin-top: var(--s-3); }
@media (max-width: 640px) {
  .empty { padding: var(--s-5) var(--s-4); }
  .empty-actions { gap: var(--s-2); }
  .empty-actions .btn { flex: 1 1 auto; }
}

/* ── Overlays ──────────────────────────────────────────────────── */
.toast {
  position: fixed; z-index: 50; left: 50%; bottom: calc(var(--s-5) + env(safe-area-inset-bottom));
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  padding: var(--s-3) var(--s-4); border-radius: var(--r-md);
  background: var(--ink); color: var(--paper); font-weight: 500; font-size: var(--text-sm);
  box-shadow: var(--shadow-2); transition: opacity var(--fast), transform var(--slow) var(--ease);
  max-width: calc(100vw - 32px);
}
.toast.is-on { opacity: 1; transform: translate(-50%, 0); }
@media (max-width: 640px) { .toast { bottom: calc(72px + env(safe-area-inset-bottom)); } }

.sheet {
  /* base.css zeroes every margin; a modal <dialog> needs margin:auto to centre. */
  margin: auto;
  width: min(440px, calc(100vw - 32px)); padding: 0; border: 0;
  border-radius: var(--r-lg); background: var(--surface); color: var(--ink);
  box-shadow: var(--shadow-2);
  max-height: calc(100dvh - 32px); overflow-y: auto;
}
.sheet::backdrop { background: rgb(10 14 25 / .45); }
/* On a phone a sheet rises from the thumb, where every native sheet lives. */
@media (max-width: 640px) {
  .sheet {
    width: 100%; max-width: none; max-height: 90dvh;
    margin: auto 0 0; border-radius: var(--r-lg) var(--r-lg) 0 0;
    padding-bottom: env(safe-area-inset-bottom);
  }
}
/* The header stays pinned while the settings scroll, so Close is always in reach. */
.sheet-head {
  position: sticky; top: 0; z-index: 2; display: flex; align-items: center;
  padding: var(--s-3) var(--s-3) var(--s-3) var(--s-5);
  background: var(--surface); border-bottom: 1px solid var(--line);
}
.sheet-foot {
  position: sticky; bottom: 0; z-index: 2; display: flex; justify-content: flex-end;
  padding: var(--s-3) var(--s-5); background: var(--surface); border-top: 1px solid var(--line);
}
.sheet-head h2 { font-size: var(--text-lg); }
.sheet-head .icon-btn { margin-inline-start: auto; }
.sheet-body { padding: var(--s-4) var(--s-5) var(--s-5); display: grid; gap: var(--s-5); }
@media (max-width: 640px) {
  .sheet-head { padding: var(--s-2) var(--s-2) var(--s-2) var(--s-4); }
  .sheet-body { padding: var(--s-3) var(--s-4) var(--s-5); gap: var(--s-4); }
  .sheet-foot { padding: var(--s-3) var(--s-4) calc(var(--s-3) + env(safe-area-inset-bottom)); }
  .sheet-foot .btn { flex: 1; }
}
.setting { display: grid; gap: var(--s-2); }
.setting > b { font-size: var(--text-sm); }
.setting .seg { width: fit-content; max-width: 100%; }
.shortcuts summary { cursor: pointer; }
.shortcuts dl { display: grid; gap: var(--s-2); margin-top: var(--s-2); }
.shortcuts dl div { display: grid; grid-template-columns: 96px 1fr; gap: var(--s-3); font-size: var(--text-sm); }
.shortcuts dd { color: var(--ink-2); }
kbd {
  display: inline-block; min-width: 22px; padding: 1px 6px; border-radius: 5px; text-align: center;
  border: 1px solid var(--line-strong); border-bottom-width: 2px; background: var(--surface);
  font: 600 .75rem/1.5 var(--font-body); color: var(--ink-2);
}
.sheet-group { font-size: var(--text-xs); color: var(--ink-3); font-weight: 600; letter-spacing: .02em;
  padding-top: var(--s-3); border-top: 1px solid var(--line); margin-bottom: calc(var(--s-2) * -1); }
.sheet-body > .sheet-group:first-child { border-top: 0; padding-top: 0; }
/* Six accents, all visible: a grid, not a scroller that hides the last two
   options. Two columns on a phone, three once the sheet is wide enough. */
.seg.swatches {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--s-1); overflow: visible;
}
@media (min-width: 520px) { .seg.swatches { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.swatches button { display: inline-flex; align-items: center; gap: 6px; min-width: 0; padding-inline: var(--s-2); }
.swatch { width: 12px; height: 12px; border-radius: 50%; display: inline-block; flex: none; }
.sw-blue { background: #2b48d6; } .sw-teal { background: #0a6f6a; } .sw-violet { background: #6a3fc4; } .sw-rose { background: #b8325f; }
.sw-plum { background: #8a2f6b; } .sw-cocoa { background: #7a4a2b; }
.danger-link { color: var(--bad); font-weight: 600; font-size: var(--text-sm); justify-self: start; padding: var(--s-2) 0; }

/* ── Entrance: one quiet fade when a screen changes ────────────── */
.view-enter { animation: view-in var(--slow) var(--ease) both; }

/* "A new version is ready" (app.js, after a deploy) */
.update-bar {
  position: fixed; z-index: 45; left: 50%; top: calc(var(--bar-h) + var(--s-3)); transform: translateX(-50%);
  display: flex; align-items: center; gap: var(--s-3); padding: var(--s-2) var(--s-2) var(--s-2) var(--s-4);
  background: var(--ink); color: var(--paper); border-radius: var(--r-pill); box-shadow: var(--shadow-2);
  font-size: var(--text-sm); font-weight: 500; animation: view-in var(--slow) var(--ease);
  max-width: calc(100vw - 32px);
}
/* Phones: a card above the tab bar instead of a narrow pill over the title. */
@media (max-width: 640px) {
  .update-bar {
    top: auto; bottom: calc(64px + env(safe-area-inset-bottom) + var(--s-3));
    left: var(--gutter); right: var(--gutter); transform: none; max-width: none;
    border-radius: var(--r-lg); padding: var(--s-3) var(--s-4); line-height: 1.4;
  }
  .update-bar span { flex: 1; }
  .update-bar .btn { flex: none; white-space: nowrap; }
}

/* Break reminder (core/study-time.js) — calm, never blocks the screen. */
.break-card {
  position: fixed; z-index: 40; right: var(--s-5); bottom: var(--s-5);
  width: min(360px, calc(100vw - 32px)); display: grid; gap: var(--s-2);
  padding: var(--s-4) var(--s-5); border-radius: var(--r-lg);
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-2);
  animation: view-in var(--slow) var(--ease);
}
.break-card[hidden] { display: none; }
.break-card p { color: var(--ink-2); font-size: var(--text-sm); }
.break-card .row { margin-top: var(--s-2); }
@media (max-width: 640px) { .break-card { right: 16px; bottom: calc(72px + env(safe-area-inset-bottom)); } }

/* Sound traps (core/sound-traps.js): what an Arabic speaker should listen for.
   Quiet ink, never a colour of its own — it's advice, not right/wrong. */
.traps { list-style: none; padding: 0; display: grid; gap: var(--s-1); max-width: 52ch; }
.traps li { display: flex; gap: var(--s-2); align-items: baseline; font-size: var(--text-sm); color: var(--ink-2); line-height: 1.45; text-align: start; }
.traps li .icon { flex: none; color: var(--ink-3); transform: translateY(2px); }
.traps b { color: var(--ink); font-weight: 600; }
.flash-traps { justify-self: center; padding: var(--s-2) var(--s-3); border-radius: var(--r-md); background: var(--surface-2); }

/* The Arabic-keyboard note (VS.ui.watchKeyboard): advice, not an error. */
.kb-warn {
  display: flex; align-items: center; gap: var(--s-2); margin-top: var(--s-2);
  padding: var(--s-2) var(--s-3); border-radius: var(--r-md);
  background: var(--mark-soft); color: var(--on-mark); font-size: var(--text-sm); font-weight: 500;
}
.kb-warn[hidden] { display: none; }

/* Form fields and checkboxes — used by Add words, the library filters, print and settings. */
.form-field { display: grid; gap: 6px; font-size: var(--text-sm); color: var(--ink-2); font-weight: 500; }
.form-field input, .form-field select, .form-field textarea {
  width: 100%; min-height: var(--tap); padding: var(--s-2) var(--s-3);
  border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface);
  color: var(--ink); font: inherit; font-size: var(--text-md); font-weight: 400;
}
/* Textareas never resize by hand (a dragged box breaks the layout); they grow with the text instead. */
.form-field textarea { resize: none; field-sizing: content; min-height: 72px; max-height: 240px; line-height: 1.5; }
.form-field input:focus, .form-field select:focus, .form-field textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.check { display: inline-flex; align-items: center; gap: var(--s-2); min-height: 34px; font-size: var(--text-sm); cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--brand); }

/* ── Touch screens ───────────────────────────────────────────────
   Most learning happens on a phone, one-handed, by learners of every
   age. Every control is at least 44px; small text never goes below
   ~13px; and form fields use 16px+, or iPhone zooms the page on focus. */
@media (pointer: coarse), (max-width: 640px) {
  .btn, .seg button, .icon-btn { min-height: var(--tap); }
  .speak-btn { width: var(--tap); height: var(--tap); }
  .brand { min-height: var(--tap); }
  .check { min-height: var(--tap); }
  .check input { width: 22px; height: 22px; }
  input, select, textarea, .note textarea { font-size: max(16px, 1em); }
  .speak-btn { width: 46px; height: 46px; }
  .badge { height: 26px; font-size: .8rem; }
  .hint { font-size: max(.85rem, 13.5px); }
}

/* Similar words — under a meaning, on a card back, in a hint */
.similar { font-size: var(--text-sm); color: var(--ink-2); }
.similar > span { font-weight: 700; text-transform: uppercase; letter-spacing: .06em; font-size: var(--text-xs); color: var(--ink-3); margin-inline-end: var(--s-1); }
.flash-similar { text-align: center; }

/* "Already in your library", while typing a new word */
.dup-note { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-1) var(--s-2); margin-top: var(--s-2);
  font-size: var(--text-sm); color: var(--ink-2); }
.dup-note .icon { color: var(--good); }
.dup-note a { font-weight: 600; }
.dup-note[hidden] { display: none; }

/* A text-style button: a small secondary action inside running content */
.link-btn { justify-self: start; padding: var(--s-2) 0; min-height: var(--tap); border: 0; background: none; font: inherit;
  font-size: var(--text-sm); font-weight: 600; color: var(--brand); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.link-btn:hover { color: var(--brand-hover); }

/* ── The teacher's margin: what Arab learners get wrong (core/usage-traps.js) ──
   A correction, not an alarm: the mistake in muted red and struck through,
   the fix in ink with a green tick, one quiet line on why. */
.usage { display: grid; gap: var(--s-2); width: 100%; max-width: 56ch; text-align: start; }
.usage-trap { display: grid; gap: 2px; padding: var(--s-3) var(--s-4); border-radius: var(--r-md); background: var(--surface-2); }
.usage-kind { font-size: var(--text-xs); font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3); }
.usage-wrong, .usage-right { display: flex; gap: var(--s-2); align-items: baseline; font-size: var(--text-sm); line-height: 1.45; }
.usage-wrong .icon, .usage-right .icon { flex: none; transform: translateY(2px); }
.usage-wrong { color: var(--ink-2); }
.usage-wrong span { text-decoration: line-through; text-decoration-color: color-mix(in srgb, var(--bad) 70%, transparent); text-decoration-thickness: 1.5px; }
.usage-wrong .icon { color: var(--bad); }
.usage-right { color: var(--ink); font-weight: 600; }
.usage-right .icon { color: var(--good); }
.usage-why { font-size: var(--text-sm); color: var(--ink-2); margin-top: 2px; }
/* Arabic quoted inside an English line: isolated, in the Arabic face, on a soft chip instead of «» */
.ar-chip { font-family: var(--font-arabic); font-size: calc(1em * var(--arabic-scale)); padding: 0 .3em; border-radius: 4px; background: color-mix(in srgb, var(--mark-soft) 70%, transparent); color: var(--ink); }

/* ── Where you met it: personal memory, so it wears the highlighter's soft yellow ── */
.met { display: grid; gap: var(--s-1); margin: 0; padding: var(--s-3) var(--s-4); border-radius: var(--r-md); background: var(--mark-soft); text-align: start; width: 100%; max-width: 56ch; }
.met figcaption { display: flex; align-items: center; gap: var(--s-1); font-size: var(--text-xs); font-weight: 700; letter-spacing: .04em; color: var(--on-mark); }
.met-source { font-weight: 500; letter-spacing: 0; }
.met blockquote { margin: 0; font-size: var(--text-md); line-height: 1.5; color: var(--ink); }
.met .mark { background-color: transparent; }

/* ── Your sentences (Use it) ── */
.mine { display: grid; gap: var(--s-1); }
.mine-head { display: flex; align-items: center; gap: var(--s-1); font-size: var(--text-xs); font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3); }
.mine ul { list-style: none; padding: 0; margin: 0; display: grid; gap: var(--s-1); }
.mine li { display: flex; align-items: center; gap: var(--s-2); justify-content: space-between; line-height: 1.5; }
.mine-del { flex: none; color: var(--ink-3); }

/* ── Word stress drawn the way teachers do: o O o o ── */
.stress { display: inline-flex; align-items: center; gap: 4px; margin-inline-start: var(--s-2); vertical-align: middle; }
.stress i { width: 7px; height: 7px; border-radius: 50%; border: 1.5px solid var(--ink-3); }
.stress i.is-on { width: 12px; height: 12px; border: 0; background: var(--brand); }

/* A milestone reached (100, 500, 1000… mastered): shown once, on the results screen */
.milestone-hit { display: flex; gap: var(--s-3); align-items: center; padding: var(--s-4); margin-bottom: var(--s-4);
  border-radius: var(--r-lg); background: var(--mark); color: var(--on-mark); text-align: start; }
.milestone-hit .icon { flex: none; }
.milestone-hit p { display: grid; gap: 2px; }
.milestone-hit b { font-family: var(--font-display); font-size: var(--text-xl); }

/* ── How common a word is (core/frequency.js): five rising bars, like signal strength ── */
.freq { display: inline-flex; align-items: center; gap: 6px; font-size: var(--text-xs); font-weight: 600; color: var(--ink-2); white-space: nowrap; }
.freq-bars { display: inline-flex; align-items: flex-end; gap: 2px; height: 12px; }
.freq-bars i { width: 3px; border-radius: 1px; background: var(--line); }
.freq-bars i:nth-child(1) { height: 4px; }
.freq-bars i:nth-child(2) { height: 6px; }
.freq-bars i:nth-child(3) { height: 8px; }
.freq-bars i:nth-child(4) { height: 10px; }
.freq-bars i:nth-child(5) { height: 12px; }
.freq-bars i.is-on { background: var(--brand); }
.freq[data-level="0"] .freq-label { color: var(--ink-3); }
.freq-row { display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--s-1) var(--s-3); }
.freq-row .hint { font-size: var(--text-sm); }
.flash-badges { align-items: center; }

/* More examples (Tatoeba), on request */
.more-ex { display: grid; gap: var(--s-1); }
.more-ex-list:empty { display: none; }
.more-ex-items { list-style: none; padding: 0; margin: 0; display: grid; gap: var(--s-2); }
.more-ex-items li { display: flex; align-items: center; gap: var(--s-2); justify-content: space-between; font-style: italic; color: var(--ink-2); line-height: 1.5; }
.more-ex-items .speak-btn { flex: none; }
.more-ex-credit { font-size: var(--text-xs); }
.goes > span { color: var(--ink-3); }
