/* Touch controls share one hierarchy: accent actions, tonal alternatives,
   grouped destination rows and focused choice sheets. Puzzle keys are separate. */
:root { --control-surface: var(--ui-raised); --control-radius: 999px; }
.view .btn, .sheet .btn {
  border: 1px solid transparent; border-radius: var(--control-radius);
  background: var(--control-surface); color: var(--ink); font-weight: 700;
  box-shadow: none; letter-spacing: -.01em;
}
.view .btn.primary, .sheet .btn.primary {
  background: var(--accent); color: var(--ui-on-accent); border-color: transparent;
}
.view .btn.utility, .settings .btn:not(.danger):not(.primary), .browse .backlink {
  background: var(--ui-tint); border-color: transparent; color: var(--accent);
}
.view .btn.danger { color: var(--bad-ink); }
.view .btn:disabled, .sheet .btn:disabled {
  background: var(--control-surface); border-color: transparent; color: var(--ink-faint); opacity: .55;
}
.home.home-focus .avatar { border: 0; background: var(--control-surface); width: 44px; height: 44px; }
.home.home-focus .home-top { grid-template-columns: minmax(0, 1fr) 44px; }
.home.home-focus .home-shortcut {
  border: 0; border-radius: 16px; padding: 8px 10px; gap: 7px;
  background: var(--control-surface); font-weight: 650; justify-content: center;
}
.home.home-focus .stage-play { border-radius: var(--control-radius); }

/* Creation reads as a mobile composer, with grouped rows instead of form boxes. */
.generate.create-flow .topic-input {
  border: 0; border-radius: 18px; background: var(--control-surface); padding-inline: 16px;
}
.generate.create-flow .topic-input:focus { box-shadow: inset 0 0 0 2px var(--accent); }
.generate.create-flow .sugg {
  border: 0; border-radius: 16px; background: var(--card); color: var(--ink);
  padding-inline: 14px; font-weight: 650; text-align: center;
}
.generate.create-flow .flow-link {
  border: 0; border-radius: 18px; background: var(--control-surface); padding: 10px 14px;
  font-weight: 650; min-height: 52px;
}
.generate.create-flow .flow-link > svg:first-child { color: var(--accent); flex: none; }
.generate.create-flow .options-summary { font-weight: 500; }
.generate.create-flow .flow-panel-heading { gap: 12px; }
.generate.create-flow .flow-back {
  width: 44px; height: 44px; margin-left: 0; border-radius: 50%; background: var(--control-surface);
}
.generate.create-flow .flow-settings { border-radius: 20px; background: var(--card); padding-inline: 14px; }
.generate.create-flow .setting-field { min-width: 0; }
.generate.create-flow .setting-row {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: 54px;
  text-align: left; padding: 10px 0; font-size: 15px; line-height: 21px;
}
.generate.create-flow .flow-settings .setting-field + .setting-field { border-top: 1px solid var(--hairline); }
.generate.create-flow .setting-label { font-weight: 550; flex: 1; min-width: 0; }
.generate.create-flow .setting-value { color: var(--ink-soft); font-size: 14px; line-height: 21px; text-align: right; max-width: 50%; }
.generate.create-flow .setting-row > svg { flex: none; color: var(--ink-faint); }
.generate.create-flow .flow-guide-link {
  display: inline-flex; align-items: center; gap: 8px; min-height: 44px;
  padding: 8px 12px; border-radius: var(--control-radius); color: var(--ink-soft);
  font-size: 13px; font-weight: 600; text-decoration: none;
}
.generate.create-flow .teacher-body > .setting-field { background: var(--card); padding-inline: 14px; border-radius: 16px; }
.generate.create-flow .teacher-body .words-input { border-radius: 18px; padding: 12px 14px; background: var(--card); }
.generate.create-flow .flow-actions > .btn { border-radius: var(--control-radius); }

/* Sheets keep a short, direct list of choices and a visible selected mark. */
.backdrop:has(> .choice-sheet) { padding: 0; }
.sheet.choice-sheet {
  max-width: 540px; max-height: calc(100dvh - 28px); padding: 24px 20px max(24px, env(safe-area-inset-bottom));
  border: 0; border-radius: 28px 28px 0 0; gap: 18px; overflow: hidden;
  background: var(--ui-bg); box-shadow: none;
}
.choice-sheet::before {
  content: ''; width: 36px; height: 4px; border-radius: 99px; background: var(--hairline);
  align-self: center; margin: -12px 0 -6px; flex: none;
}
.choice-sheet .sheet-title { flex: none; font-family: var(--ui-headline); font-size: 23px; line-height: 1.3; gap: 12px; }
.choice-sheet .sheet-x { width: 44px; height: 44px; border-radius: 50%; background: var(--control-surface); margin: 0 0 0 auto; }
.choice-sheet .sheet-body { min-height: 0; overflow-y: auto; gap: 16px; padding: 6px; margin: -6px; }
.choice-sheet .choice-help { font-size: 14px; line-height: 1.5; color: var(--ink-soft); }
.choice-list { display: flex; flex-direction: column; gap: 8px; }
.choice-option {
  display: flex; align-items: center; justify-content: space-between; gap: 16px; width: 100%;
  min-height: 56px; border-radius: 18px; padding: 14px 16px; text-align: left; background: var(--card);
}
.choice-copy { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.choice-copy strong { font-size: 16px; line-height: 1.35; font-weight: 650; color: var(--ink); }
.choice-copy small { font-size: 13px; line-height: 1.4; color: var(--ink-soft); }
.choice-mark { width: 24px; height: 24px; flex: none; border: 1.5px solid var(--hairline); border-radius: 50%; display: grid; place-items: center; }
.choice-mark > svg { visibility: hidden; }
.choice-option[aria-pressed="true"] { background: var(--ui-tint); }
.choice-option[aria-pressed="true"] .choice-mark { background: var(--accent); border-color: var(--accent); color: var(--ui-on-accent); }
.choice-option[aria-pressed="true"] .choice-mark > svg { visibility: visible; }

/* Segmented review navigation and grouped activity destinations. */
.learn.learn-focus .tabs { padding: 2px; gap: 4px; min-height: 48px; border: 0; border-radius: 999px; background: var(--control-surface); }
.learn.learn-focus .tab { border: 0; border-radius: 999px; min-height: 44px; padding: 8px; font-size: 13px; }
.learn.learn-focus .tab.on { background: var(--card); color: var(--themed); box-shadow: none; }
.profile.profile-focus .profile-destinations { border: 0; border-radius: 20px; background: var(--card); padding-inline: 14px; }
.profile-focus .profile-entry { gap: 12px; }
.profile-focus .profile-entry > .ico:first-child { width: 32px; height: 32px; padding: 7px; border-radius: 11px; background: var(--control-surface); color: var(--ink); }
.profile.profile-focus .allowance-link { background: var(--control-surface); border-radius: 16px; padding: 10px 14px; }

/* A selected tab is a touch surface, without adding height to the shell. */
.bottomnav .navicon, .bottomnav .navitem.center .navicon { width: 56px; height: 28px; border-radius: 999px; }
.bottomnav .navitem.on .navicon { background: var(--ui-tint); box-shadow: none; }
.bottomnav .navitem.on::after { display: none; }
.bottomnav .navitem.on .navlabel { font-weight: 750; }
@media (max-width: 350px) {
  .generate.create-flow .flow-link { padding-inline: 12px; gap: 6px; font-size: 14px; }
  .generate.create-flow .options-summary { font-size: 12px; }
  .generate.create-flow .setting-row { gap: 8px; font-size: 14px; }
  .generate.create-flow .setting-value { font-size: 13px; }
  .generate.create-flow .flow-panel-heading { gap: 8px; }
  .home.home-focus .home-shortcut { padding-inline: 8px; }
}
@media (prefers-reduced-motion: reduce) {
  .choice-option, .home-shortcut, .setting-row { transition: none; }
}

/* ------------------------------------------------------------ today's puzzle
   A quiet row between the stage and the two tiles: same surface as the tiles,
   small art, one line of state. The stage art gives up the row's height. */
.home.home-focus .home-daily {
  display: flex; align-items: center; gap: 12px; flex: none; min-height: 64px;
  padding: 6px 12px 6px 6px; border-radius: 16px; background: var(--control-surface);
  color: var(--ink); text-decoration: none;
}
.home.home-focus .home-daily .home-daily-art { flex: none; width: 52px; height: 52px; border-radius: 10px; }
.home-daily-art > * { width: 100%; height: 100%; }
.home-daily-copy { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.home-daily-copy strong {
  font: 900 16px/1.15 var(--ui-headline); letter-spacing: -.035em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.home-daily-copy small { font-size: 12px; line-height: 16px; color: var(--ink-soft); }
.home-daily-copy .home-daily-kicker { font-size: 11px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
.home-daily > .ico { flex: none; color: var(--ink-soft); }
.home-daily.is-solved > .ico { color: var(--good); }
:root .home.home-focus:has(.home-daily) .stage-art {
  height: clamp(120px, calc((100dvh - 420px) * .58), 440px);
}

/* -------------------------------------------------------------------- hints */
.toolbar #tb-hint { position: relative; }
.toolbar #tb-hint .hint-n {
  position: absolute; top: 1px; right: 4px; min-width: 16px; height: 16px; padding: 0 4px;
  display: grid; place-items: center; border-radius: 8px;
  font-size: 10px; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums;
  background: var(--ui-tint); color: var(--accent);
}
.toolbar #tb-hint.spent .hint-n { background: none; color: var(--ink-faint); }
.toolbar #tb-hint:disabled { opacity: .45; }
/* A hinted letter: a small dot under it, quieter than the revealed dash. */
.cell.hinted {
  background-image: radial-gradient(circle, var(--word-line) 0 1.5px, transparent 2px);
  background-size: 6px 6px; background-position: 50% calc(100% - 1px); background-repeat: no-repeat;
}

/* -------------------------------------------------------------------- share */
.btn.share-btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.share-text { user-select: all; -webkit-user-select: all; padding: 10px 12px; border-radius: 12px; background: var(--control-surface); overflow-wrap: anywhere; white-space: pre-line; }
/* No share sheet on this device: the solve's picture, with its text to copy. */
.share-sheet { max-height: calc(100dvh - 24px); overflow: hidden; }
.share-sheet .sheet-body { overflow-y: auto; min-height: 0; overscroll-behavior: contain; }
.share-preview { display: flex; flex-direction: column; gap: 12px; }
.share-preview .share-card {
  display: block; width: min(100%, 300px); height: auto; aspect-ratio: 1; margin: 0 auto;
  border-radius: 14px; box-shadow: 0 0 0 1px var(--hairline);
}
.share-preview .share-text { font-size: 13px; line-height: 1.45; color: var(--ink); }

/* ------------------------------------------------ after-solve summary sheet
   The summary rises from the bottom of the puzzle page over the finished
   grid, a tray like every other sheet, and folds away to show the grid. Only
   transform and opacity move; reduced motion zeroes them (tiles.css). */
:root .player { position: relative; }
.player .sum-scrim {
  position: absolute; inset: 0; z-index: 30; background: var(--scrim);
  opacity: 0; transition: opacity 200ms ease;
}
.player .sum-scrim.open { opacity: .7; }
:root .player .sheet.sum-sheet {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 31; margin: 0 auto;
  max-width: 540px; max-height: calc(100% - 44px);
  display: flex; flex-direction: column; gap: 10px; overflow: hidden;
  border-radius: 22px 22px 0 0; padding-top: 6px;
  opacity: 1; transform: translateY(calc(100% + 8px));
  transition: transform 200ms ease-in;
  box-shadow: inset 0 2px 0 var(--wall), 0 -6px 24px var(--contact);
}
:root .player .sheet.sum-sheet.open { transform: none; transition: transform 300ms var(--settle); }
:root .player .sheet.sum-sheet.dragging { transition: none; }
.sum-sheet .sum-grab {
  flex: none; align-self: center; display: grid; place-items: center;
  width: 72px; height: 22px; margin: 0 auto -6px; background: none; border: 0; cursor: grab;
  touch-action: none;
}
.sum-sheet .sum-grab > span { width: 40px; height: 5px; border-radius: 3px; background: var(--ui-line); }
/* the title takes focus when the sheet opens, for screen readers; it is not a
   control, so it shows no ring */
:root .sum-sheet .sum-sheet-title, :root .sum-sheet .sum-sheet-title:focus-visible { flex: none; touch-action: none; outline: none; box-shadow: none; }
.sum-sheet .sum-sheet-body {
  overflow-y: auto; min-height: 0; overscroll-behavior: contain; gap: 14px;
  margin: 0 -4px; padding: 2px 4px 4px; color: var(--ink);
}
.sum-sheet .sum-sheet-hero { display: flex; align-items: center; gap: 14px; }
.sum-sheet .sum-sheet-hero .milestone-art { width: 76px; height: 56px; color: var(--accent); }
.sum-sheet .sum-sheet-hero p { flex: 1; min-width: 0; font-size: 15px; line-height: 1.4; color: var(--ink-soft); }
.sum-sheet .sum-stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.sum-sheet .stat { padding: 12px 8px; background: var(--card); border: 0; border-radius: 14px; text-align: center; }
.sum-sheet .stat.accent { background: var(--ui-learn-tint); }
.sum-sheet .stat-v { font-size: 28px; line-height: 1.15; font-weight: 750; letter-spacing: -.03em; font-variant-numeric: tabular-nums; color: var(--ink); }
.sum-sheet .stat-l { font-size: 13px; line-height: 1.4; margin-top: 4px; color: var(--ink-soft); }
.sum-sheet .sum-detail { margin: -4px 0 0; font-size: 13px; line-height: 1.4; color: var(--ink-soft); text-align: center; }
.sum-sheet .sum-news:empty { display: none; }
.sum-sheet .sum-new {
  display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 10px 14px;
  border-radius: 12px; background: var(--card);
  font-size: 14px; line-height: 1.4; color: var(--ink-soft); text-decoration: none;
}
.sum-sheet .sum-new > svg { flex: none; color: var(--themed); }
.sum-sheet .sum-new strong { color: var(--ink); font-weight: 700; }
.sum-sheet .streak-moment { flex-direction: column; gap: 2px; padding: 10px 14px; text-align: center; border-radius: 14px; }
.sum-sheet .streak-moment-heading { display: flex; align-items: center; justify-content: center; gap: 8px; }
.sum-sheet .streak-moment strong { font-size: 14px; line-height: 20px; }
.sum-sheet .streak-moment p { margin: 0; font-size: 13px; line-height: 19px; }
.sum-sheet .sum-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding-top: 2px; }
.sum-sheet .sum-actions .btn { min-height: 48px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; font-weight: 650; }
.sum-sheet .sum-actions .btn.primary { grid-column: 1 / -1; }
@media (max-height: 700px) {
  .sum-sheet .sum-sheet-hero .milestone-art { display: none; }
  .sum-sheet .stat { padding-block: 8px; }
  .sum-sheet .stat-v { font-size: 24px; }
}
/* Phone landscape: the sheet takes the tray's side, beside the board. */
@media (orientation: landscape) and (max-height: 500px) {
  :root .player .sheet.sum-sheet { left: auto; width: 48%; max-height: 100%; border-radius: 16px 0 0 0; }
}

/* The puzzle's words, from the summary: keywords, then every other answer. */
.sum-words { display: flex; flex-direction: column; gap: 10px; }
.sum-words .sum-words-h { margin: 6px 0 0; font-size: 14px; line-height: 20px; font-weight: 700; color: var(--ink); }
.sum-word-list { display: flex; flex-direction: column; border-top: 1px solid var(--hairline); }
.sum-word {
  display: flex; flex-direction: column; gap: 8px; padding: 10px 2px;
  border-bottom: 1px solid var(--hairline);
}
.sum-word-main { display: flex; flex-direction: column; gap: 2px; min-height: 44px; justify-content: center; color: var(--ink); text-decoration: none; }
.sum-word-top { display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; }
.sum-word-top strong { font-size: 15px; line-height: 21px; font-weight: 700; }
.sum-word-enum { font-size: 12px; color: var(--ink-faint); }
.sum-word-tag { margin-left: auto; font-size: 11px; font-weight: 650; padding: 1px 8px; border-radius: 999px; background: var(--control-surface); color: var(--ink-soft); }
.sum-word-clue { font-size: 13px; line-height: 19px; color: var(--ink-soft); }
/* a keyword's Wikipedia and dictionary links, under its clue */
.sum-word .lookup-links.compact { padding-bottom: 2px; }
.sum-word.is-revealed strong { color: var(--ink-soft); }
.sum-words > .btn { align-self: flex-start; display: inline-flex; align-items: center; gap: 6px; margin-top: 4px; }

/* ------------------------------------------------- paywall extras (monetised) */
.paywall .extras-title { margin: 12px 0 0; }
.paywall .grid-theme-pick { flex-wrap: wrap; }
/* The persistent ad bar is retired; ads only ever follow a solve. */
.adbar-retired { display: none !important; }

/* -------------------------------------------------------- grid themes (paid)
   Applied only when owned and chosen (extras.js sets data-grid-extra). Each
   overrides the whole square palette, whatever Light / Dark / Auto says, and
   keeps the grid rules in tiles.css: letters 4.5:1 on every fill. */
:root[data-grid][data-grid-extra="sepia"] {
  --grid-line: #3b2f22;
  --cell: #f6ecd9; --cell-line: #d6c4a3; --cell-block: #3b2f22; --cell-theme: #eadbc4;
  --cell-ink: #2b2118; --cell-num: #5a4a38; --cell-word: #e6d2ae; --word-line: #8a6a3e;
  --theme-word: #dcc7a6; --cell-sel: #f2c46b; --theme-sel: #efc77a; --cell-flash: #dcc39b;
  --cell-wave: #e3d9b8; --cell-good: #2f5a2a; --cell-bad: #8f2a1c; --cell-shown: #5a4a38;
  --key-mark: #8a5a2b; --frame: #3b2f22;
}
:root[data-grid][data-grid-extra="slate"] {
  --grid-line: #12161c;
  --cell: #2c3440; --cell-line: #4a5566; --cell-block: #12161c; --cell-theme: #39405a;
  --cell-ink: #eef2f7; --cell-num: #c3ccd8; --cell-word: #2f4d6a; --word-line: #93bfe3;
  --theme-word: #3c4f80; --cell-sel: #6b5a1c; --theme-sel: #6d5a24; --cell-flash: #55507e;
  --cell-wave: #2e5548; --cell-good: #a8f0c8; --cell-bad: #ffc9bb; --cell-shown: #e2e7ee;
  --key-mark: #b9c6f2; --frame: #0d1015;
}
:root[data-grid][data-grid-extra="sage"] {
  --grid-line: #1f2a22;
  --cell: #eef2e8; --cell-line: #c4cfbb; --cell-block: #1f2a22; --cell-theme: #e2e6f0;
  --cell-ink: #18201a; --cell-num: #45503f; --cell-word: #cfe0cf; --word-line: #4c7a55;
  --theme-word: #cdd6ea; --cell-sel: #f2d26a; --theme-sel: #ecd27e; --cell-flash: #cfd6b8;
  --cell-wave: #d3e6cc; --cell-good: #1f5a36; --cell-bad: #93261b; --cell-shown: #45503f;
  --key-mark: #3f6a4a; --frame: #1f2a22;
}
