/* The fonts are served from this app (static/fonts, SIL Open Font License; licences alongside), so no internet is needed.
   Each file is a variable font, latin subset, covering every weight used. Text falls back to system fonts meanwhile. */
@font-face { font-family: "Work Sans"; font-style: normal; font-weight: 100 900; font-display: swap; src: url("fonts/work-sans-latin-wght-normal.woff2") format("woff2"); }
@font-face { font-family: "Cascadia Code"; font-style: normal; font-weight: 200 700; font-display: swap; src: url("fonts/cascadia-code-latin-wght-normal.woff2") format("woff2"); }
@font-face { font-family: "Fira Mono"; font-style: normal; font-weight: 400; font-display: swap; src: url("fonts/fira-mono-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Fira Mono"; font-style: normal; font-weight: 500; font-display: swap; src: url("fonts/fira-mono-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "Fira Mono"; font-style: normal; font-weight: 700; font-display: swap; src: url("fonts/fira-mono-latin-700-normal.woff2") format("woff2"); }
@font-face { font-family: "Inter"; font-style: normal; font-weight: 100 900; font-display: swap; src: url("fonts/inter-latin-wght-normal.woff2") format("woff2"); }
:root {
  color-scheme: dark; /* dark browser chrome: scrollbars, form controls, the menu lists */
  --bg: #1c1c1c;
  --fg: #f0f0f0;
  --muted: #8a8a8a;
  --cotton: #f4efe4; /* off-white for the answers and the values in the status line */
  --hint: #9e9e9e; /* the ? button: a quiet grey, lighter than its button, well below the white of the buttons beside it */
  --new: #7bdff2;
  --ext: #a6a6e8;
  --again: #ffa8a8;
  --hard: #ffe065;
  --good: #8ce999;
  --easy: #d1a3ff;
  /* Dark-mode shades of the four rating colours: the button backgrounds. The light shades above are the labels. */
  --activate: #ffb870;
  --activate-dark: #43301c;
  --again-dark: #421c26;
  --hard-dark: #3c301f;
  --good-dark: #243425;
  --easy-dark: #2f2539;
  /* Show Answers: a grey pair like the rating shades (light label on a dark shade), about 8.5:1, between Easy (7.2) and Hard (9.9) */
  --reveal: #d4d4d4;
  --reveal-dark: #333333;
  /* Hook chips: metadata about the word, so quiet: a neutral grey a little lighter than the answers card (--card-bg), a faint border, grey text */
  --chip-bg: #353535;
  --chip-border: #444444;
  --chip-fg: #a8a8a8;
  --stats-h: 2.6rem; /* the stats block above the rating buttons */
  --rate-h: 64px; /* the row of four rating buttons, and Show Answers, which takes its place */
  --card-bg: #2c2c2c; /* the question and answers panel, and the Settings sample: the same as --panel */
  --panel: #2c2c2c; /* a lift over the background (#1c1c1c) of about 1.22:1 */
  /* Tile colour: a setting later; for now yellow, so the hint colours below leave yellow out */
  /* Stats charts: one blue ramp for ordered series (length 3 to 8, difficulty easy to hard), light to dark, checked with the dataviz validator */
  --ord-1: #cde2fb; --ord-2: #9ec5f4; --ord-3: #6da7ec; --ord-4: #3987e5; --ord-5: #256abf; --ord-6: #184f95;
  --tile-bg: #ffd23f;
  --tile-fg: #4a3010;
  --font: "Work Sans", -apple-system, system-ui, sans-serif;
  --ui-font: -apple-system, system-ui, sans-serif; /* the system font: the header and every menu, and the answers section */
  --tile-font: "Work Sans", -apple-system, system-ui, sans-serif;
  --answer-font: var(--tile-font); /* the answers (words, hooks, definitions) follow the font setting, like the tiles */
  --tile-weight: 800;
  --ans-add: 0px; /* added to the size of the answers' words, hooks and definitions (the words and definitions size setting) */
}
/* The question size setting (Settings view): small (3.6rem, the original) is the default. It raises the cap on a tile's room, so it
   only shows where the row has space: a laptop, or a phone with a short word. The query results keep the small size. */
:root[data-tile-size="medium"] #front, :root[data-tile-size="medium"] #sample-front, :root[data-tile-size="medium"] #hooks-front, :root[data-tile-size="medium"] #cg-front { --slot-max: 4.2rem; }
:root[data-tile-size="large"] #front, :root[data-tile-size="large"] #sample-front, :root[data-tile-size="large"] #hooks-front, :root[data-tile-size="large"] #cg-front { --slot-max: 4.8rem; }
/* The words and definitions size setting (Settings view): small is the original; medium adds 2 pt (2.67px) to the answers and the
   query results, large 4 pt */
:root[data-answer-size="medium"] { --ans-add: 2.67px; }
:root[data-answer-size="large"] { --ans-add: 5.33px; }
/* The font setting (Settings view): it sets the question tiles and the answers (words, hooks, definitions). Work Sans extra bold is
   the default; Menlo is the system's, so it is not served. The header, menus and "Words: n" keep the system font. */
:root[data-tile-font="cascadia"] { --tile-font: "Cascadia Code", ui-monospace, Menlo, monospace; --tile-weight: 700; }
:root[data-tile-font="fira-mono"] { --tile-font: "Fira Mono", ui-monospace, Menlo, monospace; --tile-weight: 700; }
:root[data-tile-font="menlo"] { --tile-font: Menlo, Monaco, Consolas, "Courier New", monospace; --tile-weight: 700; }
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 18px/1.4 var(--font);
  display: flex;
  flex-direction: column;
  padding: env(safe-area-inset-top) 16px env(safe-area-inset-bottom);
}
header { font-family: var(--ui-font); display: flex; gap: 8px; align-items: center; padding: 12px 0; color: var(--muted); font-size: 15px; }
#counts { margin-left: auto; text-align: right; }
/* On a narrow screen the counts drop to their own row under the menus, right-aligned; wider, they share the menus' row */
header { flex-wrap: wrap; }
#counts { white-space: nowrap; display: flex; gap: 1rem; justify-content: flex-end; }
.counter { font-size: 13px; font-variant-numeric: tabular-nums; }
.counter-label { font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; opacity: 0.8; } /* small caps labels, same grey as the numbers: a counter, not a sentence */
#clear-repeats:not([hidden]) { margin-left: auto; } /* a chip just left of the counts, which then follow it */
#clear-repeats:not([hidden]) + #counts { margin-left: 0; }
body:not([data-view="study"]) #clear-repeats { display: none; }
/* The same 12px above the counts row (under the menus: 6px row gap and 6px margin) as below it (above the NEW/REPEAT label) */
@media (max-width: 520px) {
  header { row-gap: 6px; }
  #counts { flex-basis: 100%; margin-top: 6px; }
  body[data-view="study"] header { padding-bottom: 12px; }
  body[data-view="study"] main { padding-top: 0; }
}
select { font-family: var(--ui-font); background: var(--panel); color: var(--fg); border: 0; border-radius: 8px; padding: 6px 10px; font-size: 15px; }
/* The two menus at the top left are a little smaller than other dropdowns (the "Last:" panel's rating menu keeps the full size) */
header select { border-radius: 7px; padding: 5px 8px; font-size: 14px; }
/* The last answer, one row, four items with room between them: "Last: AEINRST", Good, 1y, Repeat; the rating is the only thing in it you can change */
#previous { display: flex; align-items: center; justify-content: center; gap: 1rem; background: var(--panel); border-radius: 10px; padding: 6px 12px; margin-top: 1.2rem; font-size: 14px; color: var(--muted); white-space: nowrap; }
#hooks-last { display: flex; align-items: center; justify-content: center; gap: 1rem; background: var(--panel); border-radius: 10px; padding: 6px 12px; margin-top: 1.2rem; font-size: 14px; color: var(--muted); white-space: nowrap; }
#previous-card { color: var(--fg); letter-spacing: 0.05em; }
.prev-what { white-space: nowrap; }
#previous-rating { background: var(--card-bg); border: 1px solid #3a3a3a; border-radius: 6px; padding: 3px 6px; font-size: 14px; font-weight: 600; cursor: pointer; }
#previous-rating[data-rating="1"] { color: var(--again); }
#previous-rating[data-rating="2"] { color: var(--hard); }
#previous-rating[data-rating="3"] { color: var(--good); }
#previous-rating[data-rating="4"] { color: var(--easy); }
#previous-interval.error { color: var(--again); }
/* The Repeat chip: the card is coming back soon. Grey when it is not, red when it is, dimmed red for a miss (always repeated).
   Its tap area is larger than it looks (the ::before), as it sits close to the rating buttons. */
.rchip { position: relative; font: 600 12px var(--ui-font); padding: 4px 10px; border-radius: 999px; border: 1px solid #4a4a4a; color: var(--muted); background: transparent; white-space: nowrap; cursor: pointer; }
.rchip::before { content: ""; position: absolute; inset: -8px -4px; }
.rchip.on { background: var(--again-dark); border-color: var(--again); color: var(--again); }
.rchip.locked { background: var(--again-dark); border-color: var(--again); color: var(--again); opacity: 0.55; cursor: default; }
main { flex: 1; overflow-y: auto; padding: 16px 0; }
#front { text-align: center; padding: 2.5vh 12px; background: var(--card-bg); border-radius: 12px; } /* the same space above the tiles (under the NEW/REPEAT label) as below them (above the rule) */
/* The question: [sort] tiles [shuffle], then the count on a line of its own. --n (the letter count) comes from its data-n, below.
   On a narrow screen (see the media query below) the buttons move down beside the count, so the tiles can use the full width. */
/* data-n is the letter count; the server sends it as an attribute, not a style, so a CSP can forbid inline styles. */
.alphagram[data-n="1"] { --n: 1; }
.alphagram[data-n="2"] { --n: 2; }
.alphagram[data-n="3"] { --n: 3; }
.alphagram[data-n="4"] { --n: 4; }
.alphagram[data-n="5"] { --n: 5; }
.alphagram[data-n="6"] { --n: 6; }
.alphagram[data-n="7"] { --n: 7; }
.alphagram[data-n="8"] { --n: 8; }
.alphagram[data-n="9"] { --n: 9; }
.alphagram[data-n="10"] { --n: 10; }
.alphagram[data-n="11"] { --n: 11; }
.alphagram[data-n="12"] { --n: 12; }
.alphagram[data-n="13"] { --n: 13; }
.alphagram[data-n="14"] { --n: 14; }
.alphagram[data-n="15"] { --n: 15; }
.alphagram[data-n="16"] { --n: 16; }
.alphagram[data-n="17"] { --n: 17; }
.alphagram[data-n="18"] { --n: 18; }
.alphagram[data-n="19"] { --n: 19; }
.alphagram[data-n="20"] { --n: 20; }
.alphagram[data-n="21"] { --n: 21; }
.alphagram[data-n="22"] { --n: 22; }
.alphagram[data-n="23"] { --n: 23; }
.alphagram[data-n="24"] { --n: 24; }
.alphagram {
  --gap: 0.3rem;
  --ctl: 44px; /* width of each button beside the tiles: a 44px touch target around a 32px icon */
  --ctl-gap: 0.75rem; /* space between each button and the tiles (the tiles are --gap apart; the icon adds 6px of its own) */
  --reserve: calc(2 * (var(--ctl) + var(--ctl-gap))); /* the width kept free for the two buttons beside the tiles */
  /* The room each letter gets: as large as fits the row, up to a maximum. The tile is 0.66 of it plus 2px (see .tile),
     and the row keeps room for both buttons even when they are not shown, so the tiles never change size. */
  --slot: min(var(--slot-max, 3.6rem), calc((100vw - var(--side, 32px) - var(--reserve) - (var(--n) - 1) * var(--gap) - var(--extra, 0px) - 2px * var(--n)) / (0.66 * var(--n))));
  display: flex;
  flex-wrap: wrap; /* the count takes a whole line (and, on a narrow screen, so do the tiles) */
  justify-content: center;
  align-items: center;
  column-gap: var(--ctl-gap);
}
#front .alphagram { --side: calc(20vw + 24px); } /* what the tiles do not get: the 20vw beside the 80vw panel plus its own padding (on a phone the panel is full width: below) */
#front, #back { width: 80vw; max-width: 100%; margin-left: auto; margin-right: auto; box-sizing: border-box; } /* the same column as the header and the buttons below */
.tiles { display: flex; gap: var(--gap); justify-content: center; }
/* Sort and shuffle: flat grey silhouettes, no border or background (the SVG takes the button's text colour) */
.ctl {
  width: var(--ctl);
  height: var(--ctl);
  padding: 0;
  border: 0;
  background: none;
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
}
.ctl svg { width: 32px; height: 32px; fill: currentColor; display: block; pointer-events: none; }
@media (hover: hover) { .ctl:hover { color: var(--fg); } } /* not on touch screens, where :hover sticks after a tap */
.ctl:focus-visible { color: var(--fg); outline: 2px solid var(--muted); outline-offset: 2px; border-radius: 6px; }
.tile {
  /* Width : height is 9 : 10. The width is chosen so the widest capital (W) still clears the edges: in Work Sans
     W is about 0.6 of a slot wide at this font size, so the 0.66 slot tile plus 2px leaves it about 2.6px each side
     at the largest size. The extra 2px (and the 2.2px it adds to the height) is the final adjustment to the size. */
  width: calc(var(--slot) * 0.66 + 2px);
  aspect-ratio: 9 / 10;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: calc(var(--slot) * 0.14);
  background: var(--tile-bg);
  color: var(--tile-fg);
  font-family: var(--tile-font);
  font-size: calc(var(--slot) * 0.60); /* Work Sans: capitals sit centred in the tile and W keeps a margin */
  font-weight: var(--tile-weight);
  line-height: 1;
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.35), 0 0 0 1px var(--tile-edge, transparent);
}
.count { font-family: var(--ui-font); display: block; flex-basis: 100%; margin-top: 1.2rem; color: var(--muted); font-size: 1.15rem; }
.hcount { font-family: var(--ui-font); display: block; flex-basis: 100%; margin-top: 1.2rem; color: var(--muted); font-size: 1.15rem; } /* the hooks quiz's own, same look */
/* Narrow screens: the tiles get the whole width and the buttons sit under them either side of the count: [sort] Words: 3 [shuffle].
   (The buttons are only there before the answers show, and so is the count. Only the question; the Query results have no buttons.) */
@media (max-width: 600px) {
  #front .alphagram { --reserve: 0px; row-gap: 1.6rem; column-gap: 1.5rem; } /* more room between [sort] Words: 3 [shuffle] */
  #front .tiles { order: 1; flex-basis: 100%; }
  .ctl svg { width: 28px; height: 28px; } /* a little smaller under the tiles; the button stays 44px */
  #front .ctl[data-action="sort"] { order: 2; }
  #front .count { order: 3; flex: none; margin-top: 0; }
  #front .ctl[data-action="shuffle"] { order: 4; }
}
/* Tablets and desktops (601px and wider): room for bigger tiles, 1.5 times the sizes of the Tile size setting (small, medium,
   large). They are still capped by the width, so a long word shrinks to fit as before. Same selectors as the setting's, and after them. */
@media (min-width: 601px) {
  #front, #sample-front, #hooks-front { --slot-max: 5.4rem; }
  :root[data-tile-size="medium"] #front, :root[data-tile-size="medium"] #sample-front, :root[data-tile-size="medium"] #hooks-front { --slot-max: 6.3rem; }
  :root[data-tile-size="large"] #front, :root[data-tile-size="large"] #sample-front, :root[data-tile-size="large"] #hooks-front { --slot-max: 7.2rem; }
}
/* The count is only a prompt for the question; it goes once the answers are shown */
#card.revealed .count, #hooks-quiz.revealed .hcount { display: none; }
/* ... and the "Show the Words count" setting turns it off for good */
:root[data-show-count="no"] .count { display: none; }
:root[data-show-hooks-count="no"] .hcount { display: none; }
/* A hinted tile takes one of five colours, in this order: blue, green, red, lilac, orange (no yellow: that is the tile colour).
   Another question colour (Settings) takes its place in the list: app.js sets --hl0..4 to the six colours minus the tile's own. */
.tile.hl { background: var(--hl-bg); color: var(--hl-fg); }
.c0 { --hl-bg: var(--hl0-bg, #3b82f6); --hl-fg: var(--hl0-fg, #fff); }    /* blue */
.c1 { --hl-bg: var(--hl1-bg, #3fa34d); --hl-fg: var(--hl1-fg, #fff); }    /* green */
.c2 { --hl-bg: var(--hl2-bg, #e5484d); --hl-fg: var(--hl2-fg, #fff); }    /* red */
.c3 { --hl-bg: var(--hl3-bg, #b996ec); --hl-fg: var(--hl3-fg, #1b1030); } /* lilac */
.c4 { --hl-bg: var(--hl4-bg, #f08a24); --hl-fg: var(--hl4-fg, #1b1000); } /* orange */
/* Once the answers show, the question stays put and only the answers (words, definitions, neighbours) scroll: the panel is a column
   whose back takes the height that is left and scrolls when it does not fit (it still ends at its content when it does) */
#card.revealed { display: flex; flex-direction: column; overflow: hidden; }
#card.revealed #front { flex: none; }
#card.revealed #back { flex: 0 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
#card.revealed #front { border-radius: 12px 12px 0 0; } /* the question and the answers are one rounded panel, split by a rule */
#back { position: relative; background: var(--card-bg); border-radius: 0 0 12px 12px; border-top: 1px solid var(--bg); padding: max(2.5vh, 40px) 12px 2.5vh; } /* the same space under the rule as above the tiles and between the tiles and the rule */
.entry { margin-bottom: 16px; } /* twice the 8px between a word and its definition */
/* The word is the middle column, so it is centred on the page whichever hooks it has. */
.line { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; column-gap: 0.7rem; font-size: calc(1.7rem + var(--ans-add)); font-weight: 600; }
.hooks { display: flex; flex-wrap: nowrap; align-items: center; gap: 0.7rem; } /* the word, the dots and the hook chips share one centre line */
.hooks.front { justify-content: flex-end; }
.hooks.back { justify-content: flex-start; }
.dot { color: #8a8a88; font-size: 1.1rem; font-weight: 400; letter-spacing: 0.04em; } /* the inner-hook marker: a quiet grey */
/* A hook is plain small text beside the word, not part of its headline (no chip, card or border): medium weight, two thirds the size of the word, as the hooks quiz's are */
.hook { color: var(--chip-fg); font-size: 0.66em; line-height: 1.1; font-weight: 500; letter-spacing: 0.06em; }
/* The dot is set at the word's size (the hooks are smaller) so its midline is the word's, not lower */
/* More than seven hooks: the chip holds them as two groups (the first seven, then the rest) that share one row while they fit and
   wrap onto two lines only when the side of the word is too narrow for both (app.js `fitHooks` then shrinks the chip to its widest line) */
.hook.split { display: flex; flex-wrap: wrap; min-width: 0; max-width: 100%; }
.hook.split.left { justify-content: flex-end; } /* front hooks: each line against the word, right-aligned */
.hook.split.right { justify-content: flex-start; } /* back hooks: left-aligned */
.hooks .dot { flex: none; }
.hook.fit { display: flex; flex-direction: column; flex: none; min-width: 0; } /* fitHooks: the letters are shared out in rows of their own */
.hook.fit > span { white-space: nowrap; }
.hooks.front .hook.fit { align-items: flex-end; } /* each row against the word */
.hooks.back .hook.fit { align-items: flex-start; }
.dot { font-size: calc(1.7rem + var(--ans-add)); line-height: 1; transform: scale(0.8); margin: 0 -0.2em; } /* a smaller mark, scaled about its own centre so it keeps the word's midline; the negative side margins take a little of the room either side of it away */
.dot.off { visibility: hidden; } /* no inner hook: keep the space, show nothing */
.word { color: #c7c5bd; font-weight: 700; line-height: 1; } /* a dimmer off-white than cotton (#f4efe4) */
#stats, .stats { font-family: var(--ui-font); }
.word, .hook, .dot, .definition { font-family: var(--answer-font); } /* the answers; a word new in this lexicon keeps its own colour below */
.hook .new { color: var(--new); }
.word.new { color: var(--new); } /* a word new in this lexicon keeps its own colour */
.word.nw { color: #c7c5bd; } /* the word is a link to its Query lookup: .nw would otherwise make it inherit */
.word.new.nw { color: var(--new); }
#words { text-align: center; }
/* The card's probability ranking: separate information from the answers, so it sits in their top-right corner as a small
   outlined label and value (the stats row has the card's own figures) */
.prob { position: absolute; top: 7px; right: 12px; display: flex; align-items: baseline; gap: 5px; padding: 1px 9px; border: 1px solid #3f3f3f; border-radius: 999px; font-family: var(--ui-font); white-space: nowrap; }
.prob .label { color: #707070; font-size: 0.6rem; letter-spacing: 0.12em; text-transform: uppercase; }
.prob .value { color: #aaa8a4; font-size: 0.8rem; font-variant-numeric: tabular-nums; }
.definition {
  /* Centred text in a centred box that is 80% of the screen wide, so a long definition wraps inside it */
  width: 80vw;
  max-width: 100%;
  margin: 8px auto 0; /* room under the word tiles */
  text-align: center;
  color: var(--muted);
  font-size: calc(0.93rem + var(--ans-add)); /* 1pt (1.33px) over the old 0.85rem */
  line-height: 1.3; /* a little tighter than the page's 1.4 between the lines of a long definition */
}
/* The words one letter away: a quiet line under the definition, set like it but smaller */
.neighbours { width: 80vw; max-width: 100%; margin: 9px auto 0; text-align: center; color: var(--ext); font-family: var(--answer-font); font-size: calc(0.85rem + var(--ans-add)); letter-spacing: 0.04em; }
.ext { color: inherit; } /* extensions take the definition's colour */
/* The card's stats: a row of small captions in capitals over a row of values (each pair is a column) */
#stats, .stats { display: flex; justify-content: center; gap: 1.6rem; text-align: center; }
#stats { height: var(--stats-h); align-items: center; }
#stats:empty { display: none; } /* a repeat has no stats: give the space (and the gap above the buttons) back to the answers */
.stats { margin-top: 1.4rem; }
.stat { display: flex; flex-direction: column; align-items: center; gap: 2px; white-space: nowrap; }
.stat .label { color: #707070; font-size: 0.62rem; letter-spacing: 0.12em; text-transform: uppercase; line-height: 1.2; }
.stat .value { color: #aaa8a4; font-size: 0.92rem; line-height: 1.2; }
/* Toasts: a stack at the top right, floating over everything so showing one never moves the page. Each dismisses itself, or with its x */
#notices { position: fixed; top: calc(16px + env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); z-index: 50; display: flex; flex-direction: column; align-items: stretch; gap: 8px; width: min(380px, calc(100vw - 32px)); pointer-events: none; }
.notice { --accent: var(--new); pointer-events: auto; box-sizing: border-box; display: flex; align-items: center; gap: 10px; width: 100%; min-height: 56px; padding: 14px 16px; border-radius: 0; background: var(--panel); color: var(--fg); border: 1px solid var(--chip-border); border-left: 5px solid var(--accent); box-shadow: 0 6px 20px rgba(0, 0, 0, 0.45); font: 15px/1.35 var(--ui-font); }
.notice.success { --accent: var(--good); }
.notice.error { --accent: var(--again); }
.notice-message { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.notice-close { flex: none; width: 36px; height: 36px; margin: -9px -8px -9px 0; display: grid; place-items: center; background: none; color: inherit; opacity: 0.7; font-size: 22px; line-height: 1; padding: 0; border-radius: 0; }
.notice-close:hover { opacity: 1; background: rgba(255, 255, 255, 0.1); }
#message { flex: 1; text-align: center; color: var(--muted); padding-top: 20vh; }
#message .add-links { display: block; margin-top: 0.8rem; font-size: 0.95rem; }
.linklike { font: inherit; color: var(--cotton); background: none; border: 0; padding: 0; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
footer { padding: 8px 0 12px; }
/* The last-answer panel and the buttons use the same centred container, 80% of the screen wide, as the definitions */
header, #previous, #reveal-row, #ratings { width: 80vw; max-width: 100%; margin-left: auto; margin-right: auto; }
button { font: inherit; font-family: "Work Sans", -apple-system, system-ui, sans-serif; border: 0; border-radius: 12px; color: #111; padding: 14px 4px; cursor: pointer; }
button:disabled { opacity: 0.4; cursor: not-allowed; }
.wide { flex: 1; background: var(--reveal-dark); color: var(--reveal); padding: 20px; font-size: 1.1rem; font-weight: 700; }
/* Same height as the row of rating buttons it gives way to (the stats above them are not covered) */
#reveal-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; height: var(--rate-h); } /* the same four columns as the rating buttons: Show Answers over Again-Good, ? over Easy */
#reveal { grid-column: span 3; min-width: 0; }
#hint-button { min-width: 0; background: var(--panel); color: var(--hint); font-size: 1.4rem; font-weight: 700; }
#ratings { display: flex; flex-direction: column; gap: 12px; } /* between the stats and the row of buttons */
#ratings .row { display: flex; gap: 8px; } /* four equal buttons side by side: Again, Hard, Good, Easy */
#ratings .row button { flex: 1; min-width: 0; }
/* Each button stacks the name over its interval, "Hard" over "3d", both centred */
#ratings button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; height: var(--rate-h); padding: 0 2px; }
#ratings small { font-size: 0.95rem; font-weight: 400; opacity: 0.9; } /* the interval: lighter than the name, not black (unreadable on the dark shades) */
#ratings small:empty { display: none; } /* a repeat card has no intervals: keep the name exactly centred */
/* Always takes its line (hidden or not), so the question sits in the same row with or without the REPEAT label */
#badge[hidden] { display: block !important; visibility: hidden; }
#badge { min-height: 1.2em; text-align: center; color: var(--muted); font-size: 0.8rem; letter-spacing: 0.15em; text-transform: uppercase; }
/* Each rating button: a dark shade of its colour behind the lighter shade (name, shortcut and interval inherit it) */
.again { background: var(--again-dark); color: var(--again); }
.hard { background: var(--hard-dark); color: var(--hard); }
.good { background: var(--good-dark); color: var(--good); }
.easy { background: var(--easy-dark); color: var(--easy); }
[hidden] { display: none !important; }

/* The Query view replaces the whole study screen (the study state underneath is left as it was) */
#query-view { display: none; }
body[data-view="query"] #query-view { display: flex; flex-direction: column; flex: 1; gap: 1.2rem; padding: 16px 0; overflow-y: auto; }
body[data-view="query"] main,
body[data-view="query"] #message,
body[data-view="query"] footer,
body[data-view="query"] #length,
body[data-view="query"] #counts { display: none !important; }

/* The Stats view, the same way; unlike the others it keeps the length menu, which limits it */
#stats-view { display: none; }
body[data-view="stats"] #stats-view { display: flex; flex-direction: column; flex: 1; gap: 1.2rem; padding: 16px 0; overflow-y: auto; }
body[data-view="stats"] main,
body[data-view="stats"] #message,
body[data-view="stats"] footer,
body[data-view="stats"] #counts { display: none !important; }
#stats-view h2 { margin: 0; text-align: center; font-size: 1.3rem; color: var(--cotton); }
#stats-view h3 { margin: 0 0 10px; font-size: 0.8rem; font-weight: 600; letter-spacing: 0.15em; text-transform: uppercase; color: var(--muted); }
#stats-view h3.table-title { margin-top: 1.4rem; }
#stats-view .note { margin: 0 0 10px; text-align: center; color: var(--muted); }
#stats-view .note.left { text-align: left; }
#stats-status:empty { display: none; } /* the empty status line would otherwise leave a gap above the first section */
#stats-body .note { font-size: 14px; } /* the velocity summary */
#stats-body { width: 80vw; max-width: 100%; margin: 0 auto; display: flex; flex-direction: column; gap: 1.4rem; }
#stats-body table { margin-top: -4px; /* the header cells' own padding, so a table sits as far under its heading as a box does */ width: 100%; border-collapse: collapse; font-family: var(--ui-font); font-size: 15px; font-variant-numeric: tabular-nums; }
#stats-body th { font-weight: 500; color: var(--muted); text-align: right; padding: 4px 8px; }
#stats-body td { text-align: right; padding: 4px 8px; border-top: 1px solid var(--panel); color: var(--cotton); }
#stats-body th:first-child, #stats-body td:first-child { text-align: left; }
/* Workload: label, figure, then the change or rate quietly. A fall in the overdue count is good, a rise bad. */
/* Velocity: one cell per kind (count, then the share passed smaller and quieter), so it fits a phone */
.verdict { display: flex; flex-direction: column; gap: 2px; background: var(--panel); border-radius: 12px; padding: 12px 14px; font-family: var(--ui-font); }
.verdict b { font-size: 1.1rem; }
.verdict { gap: 10px; }
.verdict .metrics { display: flex; align-items: flex-end; gap: 1.4rem; }
.verdict .metric { display: flex; flex-direction: column; gap: 1px; }
.verdict .metric .value { color: var(--cotton); font-size: 1.4rem; font-weight: 600; line-height: 1.1; font-variant-numeric: tabular-nums; }
.verdict .metric.lead { flex: 1; }
.verdict .metric.lead .value { color: #fff; font-size: 2.2rem; font-weight: 700; }
.verdict .metric .label { color: var(--muted); font-size: 0.7rem; letter-spacing: 0.1em; text-transform: uppercase; }
.verdict .basis { color: var(--muted); font-size: 12px; }
.verdict.shrinking b { color: var(--good); }
.verdict.holding b { color: var(--hard); }
.verdict.growing b { color: var(--again); }
.verdict.idle b { color: var(--muted); }

/* The Settings view, the same way: it replaces the study screen, which is left as it was */
#leaderboard-view { display: none; }
body[data-view="leaderboard"] #leaderboard-view { display: flex; flex-direction: column; flex: 1; gap: 1.2rem; padding: 16px 0; overflow-y: auto; }
body[data-view="leaderboard"] main,
body[data-view="leaderboard"] #message,
body[data-view="leaderboard"] footer,
body[data-view="leaderboard"] #length,
body[data-view="leaderboard"] #counts { display: none !important; }
#leaderboard-bar, #leaderboard-body { width: 80vw; max-width: 100%; margin: 0 auto; }
#leaderboard-bar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
#leaderboard-periods { display: flex; gap: 6px; }
#leaderboard-periods button { font-weight: 600; font-size: 14px; padding: 6px 14px; border-radius: 8px; background: var(--panel); color: var(--muted); }
#leaderboard-periods button.on { color: var(--fg); outline: 1px solid var(--muted); }
#leaderboard-view .note { margin: 0; color: var(--muted); font-size: 14px; }
#leaderboard-body { display: flex; flex-direction: column; gap: 1.4rem; }
#leaderboard-view h3 { margin: 0 0 6px; font-size: 0.8rem; font-weight: 600; letter-spacing: 0.15em; text-transform: uppercase; color: var(--muted); }
.lb-list { list-style: none; margin: 0; padding: 0; max-height: calc(10 * 40px); overflow-y: auto; font-family: var(--ui-font); font-size: 15px; font-variant-numeric: tabular-nums; }
.lb-list li { display: grid; grid-template-columns: 1.6em 1fr auto; column-gap: 10px; align-items: baseline; margin-bottom: 10px; padding-right: 6px; }
.lb-track { grid-column: 2 / 4; height: 5px; margin-top: 4px; } /* from the left of the name to the right of the value */
.lb-bar { display: block; height: 100%; border-radius: 3px; background: var(--good); }
.lb-bar.lead { background: var(--ord-4); }
.lb-rank { color: var(--muted); }
.lb-rank.gold { color: #ffd23f; line-height: 0; align-self: center; }
.lb-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--cotton); }
.lb-list li.you .lb-name { font-weight: 600; }
.lb-value { font-weight: 600; color: var(--cotton); }
#activity-view { display: none; }
body[data-view="activity"] #activity-view { display: flex; flex-direction: column; flex: 1; gap: 1.2rem; padding: 16px 0; overflow-y: auto; }
body[data-view="activity"] main,
body[data-view="activity"] #message,
body[data-view="activity"] footer,
body[data-view="activity"] #length,
body[data-view="activity"] #counts { display: none !important; }
#activity-view h3 { margin: 0 0 6px; font-size: 0.8rem; font-weight: 600; letter-spacing: 0.15em; text-transform: uppercase; color: var(--muted); }
#activity-view .note { margin: 0; color: var(--muted); }
#activity-bar { width: 80vw; max-width: 100%; margin: 0 auto; display: flex; align-items: center; justify-content: flex-end; gap: 12px; }
#activity-bar .note { flex: 1; font-size: 14px; }
#activity-refresh { flex: none; font-weight: 600; font-size: 14px; padding: 6px 14px; border-radius: 8px; background: var(--panel); color: var(--fg); }
#activity-body { width: 80vw; max-width: 100%; margin: 0 auto; display: flex; flex-direction: column; gap: 1.4rem; }
#activity-body table { width: 100%; border-collapse: collapse; font-family: var(--ui-font); font-size: 15px; font-variant-numeric: tabular-nums; }
#activity-body th { font-weight: 500; color: var(--muted); text-align: right; padding: 4px 8px; }
#activity-body td { text-align: right; padding: 4px 8px; border-top: 1px solid var(--panel); color: var(--cotton); }
/* Users and invitations: one block each, so it fits a phone: the name (or email) first, the figures under it with caps labels */
.user-row { padding: 8px 0; border-top: 1px solid var(--panel); font-family: var(--ui-font); }
.user-top { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.user-name { color: var(--cotton); font-size: 15px; }
.user-last { color: var(--muted); font-size: 13px; text-align: right; }
.user-figures { display: flex; flex-wrap: wrap; gap: 2px 1.4rem; margin-top: 4px; color: var(--cotton); font-size: 14px; font-variant-numeric: tabular-nums; }
.user-label { margin-right: 6px; color: #707070; font-size: 0.62rem; letter-spacing: 0.12em; text-transform: uppercase; }
#activity-body th:first-child, #activity-body td:first-child { text-align: left; }
.invite-form { display: flex; gap: 8px; margin: 0 0 10px; }
.invite-form input { flex: 1; min-width: 0; font: 16px var(--ui-font); background: var(--bg); color: var(--fg); border: 1px solid #3a3a3a; border-radius: 8px; padding: 8px 12px; }
.invite-form input:focus { outline: 2px solid var(--muted); outline-offset: 1px; }
.invite-form button { flex: none; font: 600 14px var(--ui-font); padding: 8px 16px; border-radius: 8px; background: var(--panel); color: var(--fg); border: 0; cursor: pointer; }
#activity-body .expired { color: var(--again); } /* an invite that has run out */
#settings-view { display: none; }
body[data-view="settings"] #settings-view { display: flex; flex-direction: column; flex: 1; gap: 1.2rem; padding: 16px 0; overflow-y: auto; }
body[data-view="settings"] main,
body[data-view="settings"] #message,
body[data-view="settings"] footer,
body[data-view="settings"] #length,
body[data-view="settings"] #counts { display: none !important; }
#settings-view h2 { margin: 0; text-align: center; font-size: 1.3rem; color: var(--cotton); }
#settings-view .note { margin: 0; text-align: center; color: var(--muted); }
/* The sample (a real question and its answers, from the lookup) so a font, size or colour change shows without leaving Settings */
#sample { width: 80vw; max-width: 100%; margin: 0 auto; background: var(--card-bg); border-radius: 12px; padding: 16px 12px; text-align: center; }
#sample-front { padding: 0 0 2.5vh; }
#sample-back { border-top: 1px solid var(--bg); padding-top: 2.5vh; }
#settings-list { list-style: none; margin: 0 auto; padding: 0; width: 80vw; max-width: 100%; display: flex; flex-direction: column; gap: 8px; }
#settings-list li { display: flex; align-items: center; justify-content: space-between; gap: 12px; background: var(--panel); border-radius: 12px; padding: 12px 14px; }
/* Section titles of the Settings page: small capitals, left-aligned over the column they head */
.settings-title { width: 80vw; max-width: 100%; margin: 0.4rem auto -4px; font: 600 0.8rem var(--ui-font); letter-spacing: 0.15em; text-transform: uppercase; color: var(--muted); }
#manage, #schedule, #repeats, #offline-study, #account { width: 80vw; max-width: 100%; margin: 0 auto; display: flex; flex-direction: column; gap: 12px; }
#repeats .settings-box li.off { opacity: 0.45; }
#repeats .settings-box input:disabled { cursor: default; }
#repeats .note { margin: 0; text-align: left; font-size: 12px; color: var(--muted); }
#manage .settings-title, #schedule .settings-title, #repeats .settings-title, #offline-study .settings-title, #account .settings-title { width: auto; margin: 0.4rem 0 0; }
.settings-box { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.settings-box li { display: flex; align-items: center; justify-content: space-between; gap: 12px; background: var(--panel); border-radius: 12px; padding: 12px 14px; font: 15px var(--ui-font); color: var(--fg); }
.settings-box select { flex: none; font: 600 14px var(--ui-font); padding: 6px 10px; border-radius: 8px; background: var(--bg); color: var(--fg); border: 0; cursor: pointer; }
.settings-box small { display: block; margin-top: 2px; font-size: 12px; color: var(--muted); }
.settings-box button { flex: none; font-weight: 600; font-size: 14px; padding: 6px 14px; border-radius: 8px; background: var(--bg); color: var(--fg); border: 0; cursor: pointer; }
.settings-box li.warning { display: block; background: var(--again-dark); color: var(--again); }
.settings-box li.warning[hidden] { display: none; }
.settings-box li.warning p { margin: 0 0 10px; }
.settings-box li.warning .row { display: flex; gap: 8px; }
.settings-box li.warning #import-go { background: var(--again); color: #000; }
#reschedule-message { background: var(--panel); color: var(--fg); }
#reschedule-message p { color: var(--muted); }
#import-mode { margin-left: auto; } /* the mode select sits with the Choose file button at the right, not in the middle of the row */
.settings-box #import-message { font-size: 13px; color: var(--muted); }
.settings-box #import-message[hidden] { display: none; }
.settings-box a.button { flex: none; font-weight: 600; font-size: 14px; padding: 6px 14px; border-radius: 8px; background: var(--bg); color: var(--fg); text-decoration: none; }
#settings-list small { display: block; margin-top: 2px; font: 12px var(--ui-font); color: var(--muted); } /* a note under a setting's name, as in the boxes below */
#settings-list label { color: var(--fg); font-family: var(--ui-font); font-size: 15px; } /* the same size as the drop-downs beside them */
/* The three drop-downs share one width and show their choice against the arrow, so the arrows line up down the page */
#settings-list select { width: 11rem; text-align: right; text-align-last: right; }
/* The on/off setting is drawn as a switch: a pill with a knob, dark with a dim knob when off, mid grey with a light knob when on */
#settings-list input[type="checkbox"], .settings-box input[type="checkbox"] { appearance: none; -webkit-appearance: none; flex: none; width: 46px; height: 28px; border-radius: 14px; background: var(--bg); position: relative; cursor: pointer; margin: 0; }
#settings-list input[type="checkbox"]::after, .settings-box input[type="checkbox"]::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: var(--muted); transition: transform 0.15s; }
#settings-list input[type="checkbox"]:checked, .settings-box input[type="checkbox"]:checked { background: #4d4d4d; }
#settings-list input[type="checkbox"]:checked::after, .settings-box input[type="checkbox"]:checked::after { background: var(--reveal); transform: translateX(18px); }
#settings-list input[type="checkbox"]:focus-visible, .settings-box input[type="checkbox"]:focus-visible { outline: 2px solid var(--muted); outline-offset: 2px; }
#query-form { display: flex; gap: 0; width: 80vw; max-width: 100%; margin: 0 auto; }
#query-input { flex: 1; min-width: 0; background: var(--panel); color: var(--cotton); border: 0; border-radius: 4px 0 0 4px; padding: 14px; font: inherit; font-size: 1rem; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; }
#query-input:focus { outline: none; } /* no ring round the box when it has the cursor */
#query-input::placeholder { color: var(--muted); font-weight: 400; letter-spacing: 0; text-transform: none; }
#query-form button { background: var(--panel); color: var(--fg); padding: 0 18px; font-size: 0.85rem; border-radius: 0 4px 4px 0; border-left: 1px solid var(--bg); } /* the box and Clear are one nearly square control, split by a thin line */
#query-form #query-clear { padding: 0 14px; } /* greyed by :disabled while the box is empty, normal once there is text */
/* The Query results, left aligned and read top to bottom: the card's figures, its probability, then the words the letters
   make (word, hooks and definition in one size, the word in cotton white and the rest grey, long definitions wrapping) */
#query-result { width: 80vw; max-width: 100%; margin: 0 auto; text-align: left; }
#query-result .note { color: var(--muted); margin: 0 0 1.2rem; }
/* The first line: the letters as an alphagram and what was found. Plain weight, not a headline. */
.qsummary { margin: 0 0 1.2rem; color: #b4b2ac; font-size: 1rem; font-weight: 400; } /* a lighter grey than the muted text: it is read first, on a phone */
.qsummary .qalpha { color: var(--cotton); font-size: 1.1rem; font-weight: 700; letter-spacing: 0.08em; } /* the letters stand out; the rest of the line stays plain */
/* The figures, in one bordered box: the card's record and the probability use the same small-capital captions over values, so
   they read as a block apart from the text above and below */
.figures { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 0.7rem 1.2rem; padding: 10px 14px; margin: 0 0 1.5rem; border: 1px solid #3f3f3f; border-radius: 10px; font-family: var(--ui-font); }
.figures .stat { align-items: flex-start; }
.figures + .qprobrow { margin-top: -1rem; }
.qprobrow { display: flex; justify-content: flex-end; margin-bottom: 1.2rem; }
.qprobrow .prob { position: static; }
.figures .history { flex: 1 0 100%; display: flex; flex-direction: column; align-items: flex-start; gap: 4px; padding-top: 0.7rem; border-top: 1px solid #3f3f3f; }
.figures .hrow { display: flex; flex-wrap: nowrap; align-items: center; gap: 6px; max-width: 100%; overflow-x: auto; }
.figures .harrow { color: #707070; font: 12px var(--ui-font); }
.figures .history .label { color: #707070; font-size: 0.62rem; letter-spacing: 0.12em; text-transform: uppercase; line-height: 1.2; }
.hchip { font: 600 12px var(--ui-font); padding: 3px 10px; border-radius: 999px; border: 1px solid; white-space: nowrap; font-variant-numeric: tabular-nums; }
.hchip.again { background: var(--again-dark); border-color: var(--again); color: var(--again); }
.hchip.hard { background: var(--hard-dark); border-color: var(--hard); color: var(--hard); }
.hchip.good { background: var(--good-dark); border-color: var(--good); color: var(--good); }
.hchip.easy { background: var(--easy-dark); border-color: var(--easy); color: var(--easy); }
.figures .value { font-variant-numeric: tabular-nums; }
.stat .value.late { color: var(--hard); } /* a review that is overdue */
.qa { margin: 0 0 0.9rem; font-family: var(--answer-font); font-size: calc(1rem + var(--ans-add)); line-height: 1.5; color: var(--muted); }
.qa .qword { color: var(--cotton); font-weight: 600; }
.qa .qword.new { color: var(--new); } /* a word new in this lexicon keeps its own colour */
.qnear { display: block; margin-top: 5px; color: var(--ext); font-size: calc(0.85rem + var(--ans-add)); letter-spacing: 0.04em; } /* the words one letter away, as in the study answers */
.nw { color: inherit; text-decoration: none; cursor: pointer; } /* a neighbour word links to its Query lookup: it looks like the line until pointed at */
.nw:hover, .nw:focus-visible { color: var(--cotton); text-decoration: underline; }
.nn { white-space: nowrap; } /* a neighbour word and the dash after it never part: a line breaks after a dash, not before one */
.nn.eol .sep { visibility: hidden; } /* the dash that ends a line (app.js): hidden, but it keeps its room so the lines break where they were measured */
.neighbours .sep, .qnear .sep { color: #6f6f6c; } /* the dash between neighbour words is quiet grey */
.qhooks { overflow-wrap: anywhere; }
.qhooks .new { color: var(--new); }

/* One action button, which says what applies to the word looked up: Add (green), Activate (orange), Mark missed (red) */
#query-return { margin-left: auto; padding: 0; font: 500 0.9rem var(--ui-font); color: var(--muted); background: none; border: 0; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; } /* a plain link in the header row, on the right where the counts go: back to the quiz a neighbour link was followed from */
#query-return:hover, #query-return:focus-visible { color: var(--cotton); }
#query-return[hidden], body:not([data-view="query"]) #query-return { display: none; }
#query-actions { display: flex; gap: 12px; width: 80vw; max-width: 100%; margin: 0 auto; }
#query-actions button { flex: 1; padding: 14px 4px; font-weight: 700; }
#query-actions .miss { background: var(--again-dark); color: var(--again); }
#query-actions .add { background: var(--good-dark); color: var(--good); }
/* A message about the word looked up or an action: yellow on a tinted plate, so it is not missed */
#query-status { width: 80vw; max-width: 100%; margin: 0 auto; padding: 8px 12px; text-align: left; color: var(--hard); background: var(--hard-dark); border-left: 3px solid var(--hard); border-radius: 6px; font-size: 0.95rem; }
#query-status:empty { display: none; } /* no line is kept for a message that is not there: the results sit close under the buttons */

/* Dragging a tile (question only). The tile left in the row is an empty dashed outline, a copy follows the pointer. */
#card:not(.revealed) #front .tile { cursor: grab; touch-action: none; user-select: none; -webkit-user-select: none; }
body.dragging, body.dragging #front .tile { cursor: grabbing; user-select: none; -webkit-user-select: none; }
#front .tile.ghost { background: transparent; color: transparent; box-shadow: none; outline: 2px dashed var(--muted); outline-offset: -2px; }
.tile.drag-copy { position: fixed; margin: 0; z-index: 1000; pointer-events: none; box-shadow: 0 10px 22px rgba(0, 0, 0, 0.55); transform: scale(1.08); }

/* Phones and the iPad mini (744 to 768px wide in portrait): the 80vw columns use the whole width inside the page's 16px side padding, the same edge as the header */
@media (max-width: 800px) {
  #front, #back, #stats-body, .settings-title, #manage, #schedule, #repeats, #offline-study, #account { width: 100%; }
  #front .alphagram { --side: 56px; } /* the page padding plus the question panel's own */
  header, #previous, #reveal-row, #ratings, .definition, #sample, #settings-list, #query-form, #query-result, #query-actions, #query-status { width: 100%; }
}

/* Narrow screens: the figures box in a tidy grid instead of a ragged wrap, three to a row, with the probability on its own row
   under a rule (wider than this they sit in one row with a vertical divider) */
@media (max-width: 640px) {
  .figures { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.8rem 0.6rem; padding: 10px 12px; }
  .figures .history { grid-column: 1 / -1; }
}


/* Stats: the due forecast */
#stats-body .chips { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 0 0 10px; font-family: var(--ui-font); }
#stats-body .chips .sep { width: 10px; }
.chip { font: 600 12px var(--ui-font); padding: 4px 10px; border-radius: 999px; border: 1px solid #4a4a4a; color: var(--muted); background: transparent; cursor: pointer; }
.chip.on { background: #4a4a4a; border-color: #8a8a8a; color: #fff; font-weight: 700; text-decoration: underline; text-underline-offset: 3px; }
.forecast { background: var(--panel); border-radius: 12px; padding: 12px 10px 10px; margin-bottom: 10px; font-family: var(--ui-font); }
.forecast-legend { display: flex; flex-wrap: wrap; gap: 4px 12px; padding: 0 4px 6px; font-size: 12px; color: var(--muted); }
.forecast-legend .key { display: inline-flex; align-items: center; gap: 5px; }
.forecast-legend .swatch { flex: none; }
.forecast-svg { width: 100%; height: auto; display: block; touch-action: pan-y; }
.forecast-svg .grid { stroke: #3a3a3a; stroke-width: 1; }
.forecast-svg .axis { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.forecast-svg .hit { fill: transparent; outline: none; }
.forecast-svg .hit.on { fill: rgba(255, 255, 255, 0.07); }
.forecast-readout { margin: 6px 4px 0; min-height: 2.6em; font-size: 13px; color: var(--cotton); text-align: left; }
#stats-body table.forecast-table small { margin-left: 0.4em; font-size: 0.8em; color: var(--muted); }
#stats-body table.forecast-table th, #stats-body table.forecast-table td { padding: 4px 6px; }
#stats-body table.forecast-table tr.total td { font-weight: 600; }
#stats-body table.forecast-table strong { font-weight: 700; color: #fff; }

/* Login and signup: one card in the middle of the page */
body.auth { align-items: center; justify-content: center; }
.auth-card { width: min(92vw, 22rem); background: var(--panel); border-radius: 14px; padding: 22px 20px; display: flex; flex-direction: column; gap: 10px; }
.auth-card h1 { margin: 0 0 4px; text-align: center; font-size: 1.5rem; color: var(--cotton); }
/* The title is tiles in the Balsa question colour, as on the question: the size is chosen so all nine fit the card (tile = 0.66 slot + 2px, 4px gaps) */
.auth-title { margin: 4px 0 10px; --gap: 4px; --tile-bg: #dcc59a; --tile-fg: #3a2810; /* the Balsa question colour */ --slot: min(2.4rem, calc((min(92vw, 22rem) - 90px) / 5.94)); }
.auth-title .tiles { gap: var(--gap); }
.auth-card form { display: flex; flex-direction: column; gap: 6px; }
.auth-card label, #account label { font-family: var(--ui-font); font-size: 14px; color: var(--muted); margin-top: 6px; }
.optional { color: #6e6e6e; }
.auth-card input, #account input { font: inherit; font-size: 16px; background: var(--bg); color: var(--fg); border: 1px solid #3a3a3a; border-radius: 8px; padding: 10px 12px; }
.auth-card input:focus, #account input:focus { outline: 2px solid var(--muted); outline-offset: 1px; } /* the grey of the other focus rings, not green */
.auth-card .submit { margin-top: 12px; background: var(--good-dark); color: var(--good); font-weight: 700; padding: 13px 4px; }
#auth-error { margin: 6px 0 0; color: var(--again); font-size: 14px; }
.auth-note { margin: 0; text-align: center; color: var(--muted); font-size: 14px; }
.auth-note a { color: inherit; text-decoration: underline; }
/* Settings > Account */
/* Settings > Account > Display name: a settings row, the input small on the right with its Save button. The input stays 16px or iOS zooms in when it is focused. */
#name-form { display: flex; flex-direction: column; gap: 6px; }
#name-form li { flex-wrap: wrap; }
#account .settings-box label { margin: 0; font-size: 15px; color: var(--fg); }
.name-row { display: flex; align-items: center; gap: 8px; margin-left: auto; }
#account .name-row input { width: 9.5em; padding: 6px 10px; border: 0; border-radius: 8px; background: var(--bg); }
#name-save:disabled { opacity: 0.45; cursor: default; }
#name-status:empty { display: none; }
#account { gap: 6px; } /* its width and column come with the other settings sections above, so the narrow-screen rule reaches it */
#account .note { margin: 0; text-align: left; font-size: 13px; }
#logout { align-self: flex-start; margin-top: 6px; font-weight: 600; font-size: 14px; padding: 6px 14px; background: var(--again-dark); color: var(--again); }
/* The Show neighbours setting (study answers only: the Query view always shows them) */
:root[data-show-neighbours="no"] #back .neighbours { display: none; }
:root[data-show-inner-hooks="no"] .dot { display: none; } /* the inner-hook dots, in the study answers, the hooks quiz and the Settings sample */

/* Stats: the velocity chart (shares the forecast's box) */
.forecast-svg .zero { stroke: #6a6a6a; stroke-width: 1; }
.forecast-svg .due-line { stroke: var(--muted); stroke-width: 1.5; stroke-dasharray: 4 3; pointer-events: none; }
.forecast-svg .trend { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; pointer-events: none; }

/* Offline study: the bar across the top while a pack is out (or being set up), and the Settings section */
#offline-bar { position: sticky; top: 0; z-index: 20; padding: 10px 16px; background: var(--panel); border-bottom: 1px solid #3a3a3a; font-family: var(--ui-font, inherit); font-size: 14px; }
#offline-bar .offline-status { margin: 4px 0; color: var(--reveal); }
#offline-bar .offline-status.error { color: var(--again); }
#offline-bar .offline-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
#offline-bar .offline-actions .offline-status { flex-basis: 100%; }
#offline-bar button { padding: 10px 12px; border-radius: 10px; background: var(--reveal-dark); color: var(--reveal); font-size: 14px; font-weight: 600; min-height: 44px; }
#offline-bar button.primary { background: var(--good-dark, #2e5d3a); }
#offline-bar button.danger { background: var(--again-dark, #6b2a2a); }
#offline-bar.busy button { opacity: 0.5; pointer-events: none; }
.offline-form input { width: 4em; font: 600 14px var(--ui-font); padding: 6px 10px; border: 0; border-radius: 8px; background: var(--bg); color: var(--fg); } /* as the display name box: 16px also keeps iOS from zooming in on focus */
.offline-form input:focus-visible { outline: 2px solid var(--muted); outline-offset: 1px; }
.offline-form select { width: 9em; font: 600 14px var(--ui-font); padding: 6px 10px; border: 0; border-radius: 8px; background: var(--bg); color: var(--fg); }
.offline-form { display: flex; flex-direction: column; gap: 8px; }
.offline-head { margin: 0; font: 600 15px var(--ui-font); color: var(--fg); }
.offline-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; } /* caption left, field right */
.offline-row label { font: 13px var(--ui-font); color: var(--muted); } /* a caption, between the 15px heading above it and the 14px controls, as the 12px notes in Manage */
.offline-row input { text-align: right; }
.offline-form input[type=number] { appearance: textfield; -moz-appearance: textfield; } /* no spin arrows: they would take a third of a box that holds four digits */
.offline-form input[type=number]::-webkit-inner-spin-button, .offline-form input[type=number]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.offline-pair { display: flex; align-items: center; gap: 8px; }
.offline-sep { border: 0; border-top: 1px solid var(--muted); opacity: 0.3; margin: 6px 0; width: 100%; }
.offline-note { font-size: 12px; color: var(--hint); }
.offline-note.error { color: var(--again); }
.offline-note.ok { color: var(--good); }
.settings-box li.stacked { flex-direction: column; align-items: stretch; } /* the text above its controls, not beside them */
#offline-feedback[hidden] { display: none; }
#offline-feedback { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; }
#offline-estimate { margin-top: 4px; }
#offline-estimate:empty { display: none; }
.settings-box li[hidden] { display: none; }
#offline-bar.thin { padding: 3px 0; text-align: center; font: 600 11px var(--ui-font); letter-spacing: 0.18em; color: var(--muted); cursor: pointer; border-bottom: 0; }
#offline-return .offline-line { margin: 0; }
#offline-return .offline-status { margin: 6px 0 0; color: var(--reveal); font-size: 13px; }
#offline-return .offline-status.error { color: var(--again); }
#offline-return .offline-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; margin-top: 10px; }
#offline-return .offline-buttons { display: flex; gap: 8px; margin-left: auto; } /* on the label's row, or right-aligned underneath when there is no room */
#offline-return .offline-actions .offline-status { flex-basis: 100%; margin: 0; }
#offline-return.busy button { opacity: 0.5; pointer-events: none; }
#offline-return button.primary { background: var(--good-dark); color: var(--good); }
#offline-return button.danger { background: var(--again-dark); color: var(--again); }
#offline-return .offline-label { margin: 0; font: 15px var(--ui-font); color: var(--fg); }
html.offline-mode .nw, html.offline-mode .word.nw { pointer-events: none; cursor: default; } /* Query needs the server: the answer and neighbour words are not links offline */
html.offline-mode .nw:hover, html.offline-mode .nw:focus-visible { text-decoration: none; }
.settings-box a.button.disabled { opacity: 0.4; cursor: not-allowed; pointer-events: none; } /* as button:disabled */
#account .name-row input:disabled { background: #3a3a3a; color: var(--muted); -webkit-text-fill-color: var(--muted); opacity: 1; cursor: not-allowed; } /* offline: a grey box, not an input to type in */
#setting-retention:disabled { background: #3a3a3a; color: var(--muted); -webkit-text-fill-color: var(--muted); opacity: 1; cursor: not-allowed; } /* offline: the target shown, not changeable */
.settings-box li.warning .row[hidden], .settings-box li.warning #offline-abandon-confirm[hidden] { display: none; }
.settings-box li.warning #offline-abandon-yes { background: var(--again); color: #000; }

/* The Hooks quiz (hooks.js; only for the users it is enabled for): its own view, with the question and answers drawn like the study
   screen's. The tiles have no buttons beside them, so no room is kept for any. */
#hooks-view { display: none; }
body[data-view="hooks"] #hooks-view { display: flex; flex-direction: column; flex: 1; gap: 1.2rem; padding: 16px 0; overflow-y: auto; }
body[data-view="hooks"] main,
body[data-view="hooks"] #message,
body[data-view="hooks"] footer,
body[data-view="hooks"] #length { display: none !important; }
#hooks-view > section { width: 80vw; max-width: 100%; margin: 0 auto; box-sizing: border-box; }
#hooks-view h3 { margin: 0 0 12px; font-size: 0.8rem; font-weight: 600; letter-spacing: 0.15em; text-transform: uppercase; color: var(--muted); }
#hooks-view .note { margin: 0; color: var(--muted); }
#hooks-view .row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
#hooks-view > #hooks-quiz { display: flex; flex-direction: column; flex: 1; min-height: 0; width: 80vw; max-width: 100%; }
#hooks-quiz[hidden] { display: none; }
/* As on the study screen: the question stays put and only the answers scroll, when there are more than fit */
#hooks-card { flex: 1; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }
#hooks-card #hooks-badge, #hooks-card #hooks-front { flex: none; }
#hooks-card #hooks-back { flex: 0 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
#hooks-foot { padding: 8px 0 12px; }
/* Always takes its line, hidden or not, so the question sits in the same row with or without the REPEAT label (as the study screen's does) */
#hooks-badge[hidden] { display: block !important; visibility: hidden; }
#hooks-badge { min-height: 1.2em; text-align: center; color: var(--muted); font-size: 0.8rem; letter-spacing: 0.15em; text-transform: uppercase; }
#hooks-front { text-align: center; padding: 2.5vh 12px; background: var(--card-bg); border-radius: 12px; }
#hooks-front .alphagram { --side: calc(20vw + 24px); --reserve: 0px; }
/* Phones and small tablets: the same full width as the study screen (see the 800px block above) */
@media (max-width: 800px) {
  #hooks-view > section, #hooks-view > #hooks-quiz { width: 100%; }
  #hooks-front .alphagram { --side: 56px; }
}
#hooks-front .tiles { justify-content: center; }
#hooks-quiz.revealed #hooks-front { border-radius: 12px 12px 0 0; }
#hooks-back { background: var(--card-bg); border-radius: 0 0 12px 12px; border-top: 1px solid var(--bg); padding: max(2.5vh, 40px) 12px 2.5vh; text-align: center; }
.tile.slot { background: transparent; box-shadow: none; border: 2px dashed var(--muted); box-sizing: border-box; }
/* The hint's guesses (hooks.js): the side being guessed has solid, lit boxes; a found hook fills its box with the letter */
#hooks-front .tile.slot[data-side] { cursor: pointer; }
#hooks-front[data-active="front"] .tile.slot[data-side="front"],
#hooks-front[data-active="back"] .tile.slot[data-side="back"] { border-style: solid; border-color: var(--fg); box-shadow: 0 0 0 3px color-mix(in srgb, var(--fg) 30%, transparent); }
#hooks-front .tile.slot.filled { background: var(--tile-bg); color: var(--tile-fg); border-color: transparent; box-shadow: 0 2px 0 rgba(0, 0, 0, 0.35); }
/* A little room between the word and its hook places, kept out of the tile size (--extra is both gaps) */
#hooks-front .alphagram:has(.tile.slot) { --sep: 0.7rem; --extra: calc(2 * var(--sep)); }
#hooks-front .tile.slot[data-side="front"] + .tile:not(.slot), #hooks-front .tile:not(.slot) + .tile.slot[data-side="back"] { margin-left: var(--sep); }
/* With "Invert hook colour" on, the hooks being entered use the inverted colours too, as they will in the answers */
:root[data-invert-hook="yes"] #hooks-front .tile.slot.filled { background: var(--tile-fg); color: var(--tile-bg); }
/* The letter grid: A to Z in order (not a keyboard), nine to a row. A wrong guess flashes red and fades; a found letter is dimmed on its side */
#hooks-grid { display: grid; grid-template-columns: repeat(9, minmax(0, 1fr)); gap: 6px; max-width: 30rem; margin: 0 auto 10px; }
#hooks-grid button { min-width: 0; height: 2.6rem; padding: 0; background: var(--panel); color: var(--fg); font: 700 1.05rem var(--ui-font); border-radius: 8px; }
#hooks-grid button.used { opacity: 0.3; }
#hooks-grid button.miss { animation: hooks-miss 0.7s ease-out; }
@keyframes hooks-miss { 0% { background: #d64545; color: #fff; } 100% { background: var(--panel); color: var(--fg); } }
@media (prefers-reduced-motion: reduce) { #hooks-grid button.miss { animation-duration: 0.01s; } }
.word .hl { color: var(--hook-letter, var(--hard)); } /* the hook letter: the lighter of the tile colour's two (app.js sets --hook-letter), yellow before it has */
/* The quiz's buttons sit at the bottom as the study screen's do: Show Answers over the first three of four columns and ? over the last, then Again and Good in two */
#hooks-reveal-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; height: var(--rate-h); }
#hooks-reveal { grid-column: span 3; min-width: 0; }
#hooks-hint { min-width: 0; background: var(--panel); color: var(--hint); font-size: 1.4rem; font-weight: 700; }
#hooks-rate-row { display: flex; gap: 8px; }
#hooks-rate-row button { flex: 1; min-width: 0; height: var(--rate-h); display: flex; align-items: center; justify-content: center; padding: 0 2px; }
#hooks-last #hooks-last-word { color: var(--fg); letter-spacing: 0.05em; }
#hooks-flip.on { color: var(--again); }
#hooks-grid-toggle:not([hidden]) { margin-left: auto; } /* the chips sit just left of the progress, which then follows them */
#hooks-grid-toggle:not([hidden]) + #hooks-menu { margin-left: 0; }
#hooks-menu:not([hidden]) { margin-left: auto; }
#hooks-menu:not([hidden]) + #counts { margin-left: 0; }
#hooks-grid-toggle[aria-pressed="true"] { color: var(--fg); border-color: var(--muted); }
body:not([data-view="hooks"]) #hooks-menu, body:not([data-view="hooks"]) #hooks-grid-toggle { display: none; }
/* The list screen and the end of a pass use the Settings page's rows: a rounded panel per option, label on the left, control on the right */
#hooks-view .fields { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: flex-end; color: var(--muted); }
#hooks-view .btns { display: flex; gap: 8px; flex: none; }
#hooks-view .settings-box li.stacked { flex-wrap: wrap; }
#hooks-view .settings-box input[type="number"] { width: 5em; background: var(--bg); color: var(--fg); border: 0; border-radius: 8px; padding: 6px 10px; font: 600 14px var(--ui-font); }
#hooks-view .settings-box button:disabled { opacity: 0.45; cursor: default; }
#hooks-count { color: var(--muted); }
#hooks-count.bad { color: var(--again); }
#hooks-view .settings-box li > span:first-child { min-width: 0; }
/* The new-list form is one panel with its options in rows, not a panel per option */
#hooks-form .settings-box { background: var(--panel); border-radius: 12px; gap: 0; padding: 4px 0; }
#hooks-form .settings-box li { background: none; border-radius: 0; }
/* The resume box: the list on the first line, where it is under it, the buttons on the right of a third */
#hooks-resume li.stacked { flex-direction: column; align-items: stretch; gap: 4px; }
#hooks-resume small { margin-top: 0; }
#hooks-resume .btns { justify-content: flex-end; margin-top: 8px; }
/* The hooks a hooks-quiz answer has itself, either side of it: plain letters (no chip), two thirds the size of the word, wrapping within their column */
.line .hk { font-family: var(--answer-font); font-size: 0.66em; font-weight: 500; letter-spacing: 0.08em; line-height: 1.1; color: var(--chip-fg); min-width: 0; overflow-wrap: anywhere; }
.line .hk.front { text-align: right; }
.line .hk.back { text-align: left; }
.line .hk .new { color: var(--new); }
/* In the hooks quiz's cycle the hook letter is the tile with its colours swapped: the question's own tile colour as the letter on the dark of its text */
:root[data-invert-hook="yes"] .tile.inv { background: var(--tile-fg); color: var(--tile-bg); } /* (Settings > Invert hook colour, off by default) */
