/* AnkiGen page styles. Light and dark follow prefers-color-scheme. The card faces in the preview use
   css/card.css inside their own frames, as in Anki. */

:root {
  color-scheme: light dark;
  --bg: #f6f6f4;
  --surface: #ffffff;
  --text: #1d1f23;
  --muted: #5d636d;
  --line: #e2e3e0;
  --line-strong: #c4c7c2;
  --accent: #2c6db0;
  --accent-text: #ffffff;
  --accent-soft: #e7eff8;
  --accent-ink: #1f5592;
  --card-bg: #ffffff;
  --danger: #b3261e;
  --support: #e07a24;
  --support-ink: #a94f0c;
  --support-soft: #fdf1e6;
  --radius: 10px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", "Hiragino Sans",
    "PingFang SC", "Microsoft YaHei", "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans CJK JP", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #151618;
    --surface: #1d1e21;
    --text: #e6e7ea;
    --muted: #a2a8b2;
    --line: #2d2f34;
    --line-strong: #464a52;
    --accent: #82b8f0;
    --accent-text: #0f1a26;
    --accent-soft: #1d2d40;
    --accent-ink: #a9cff6;
    --card-bg: #1e1f22;
    --danger: #e46962;
    --support: #ec9346;
    --support-ink: #f4b072;
    --support-soft: #35251a;
  }
}

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

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 var(--font);
}

:lang(ja) { font-family: "Hiragino Kaku Gothic ProN", "Hiragino Sans", "Yu Gothic", Meiryo, "Noto Sans JP", "Noto Sans CJK JP", var(--font); }
:lang(zh) { font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans SC", "Noto Sans CJK SC", var(--font); }
:lang(ko) { font-family: "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", "Noto Sans CJK KR", var(--font); }

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

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

[hidden] {
  display: none !important;
}

input[type="checkbox"],
input[type="radio"],
input[type="range"] {
  accent-color: var(--accent);
}

input[type="checkbox"] {
  flex: none;
  width: 1.1rem;
  height: 1.1rem;
  margin: 0;
}

/* ------------------------------------------------------------------ header */

.site-head,
.layout {
  max-width: 86rem;
  margin: 0 auto;
  padding-inline: 1.5rem;
}

.site-head {
  padding-block: 2rem 1.25rem;
}

/* The app's header: the title and lede; the support links; the interface language. */
.app-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  grid-template-areas: "main support language";
  align-items: start;
  gap: 0.75rem 1.25rem;
}

.head-main {
  grid-area: main;
}

.head-support-slot {
  grid-area: support;
}

/* Keeps the button's place while the page loads. */
.locale-slot {
  display: flex;
  grid-area: language;
  justify-content: flex-end;
  min-width: 5rem;
  min-height: 2.5rem;
}

.logo {
  margin: 0;
  font-size: 1.75rem;
  letter-spacing: -0.015em;
}

.lede {
  margin: 0.2rem 0 0;
  font-size: 1.1rem;
}

/* Where a "?" button will be, so the line doesn't grow when it arrives. */
.help-slot {
  display: inline-block;
  width: 1.5rem;
  height: 1.5rem;
}

/* The "?" follows the last word, also when the line wraps (translations run longer). */
.draft {
  margin: 0.6rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

/* Smaller than the other "?" buttons, so the line keeps its height, and centred on the capitals:
   vertical-align: middle alone centres it on the lower-case letters, which looks low. */
.draft .help,
.draft .help-slot {
  position: relative;
  top: -0.09rem;
  width: 1.15rem;
  height: 1.15rem;
  margin-left: 0.35rem;
  vertical-align: middle;
}

.draft .help {
  font-size: 0.65rem;
}

.dev-banner {
  margin: 0;
  padding: 0.35rem 1rem;
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-size: 0.85rem;
  text-align: center;
}

.fatal {
  margin: 0;
  padding: 1rem 1.25rem;
  border: 1px solid var(--danger);
  border-radius: 14px;
  background: var(--surface);
}

.noscript {
  max-width: 86rem;
  margin: 0 auto 1rem;
  padding: 0 1.5rem;
}

/* Without scripts the steps would stay empty: the noscript text describes the tool instead. */
html:not(.js) .layout {
  display: none;
}

.noscript p {
  max-width: 40rem;
}

/* ------------------------------------------------------------------ footer */

.site-foot {
  max-width: 86rem;
  margin: 0 auto;
  padding: 1.5rem 1.5rem 4.5rem;
  color: var(--muted);
  font-size: 0.9rem;
}

/* Until the page has rendered (index.html adds .js, src/main.js .ready): it would jump as the steps appear. */
.js:not(.ready) .site-foot {
  display: none;
}

.site-foot a {
  color: inherit;
  text-underline-offset: 3px;
}

/* The support links, in the header and the footer: the label, then the two buttons; on a narrow screen the
   buttons wrap together, below the label. */
.support,
.support > span {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.support {
  margin: 0;
}

.site-foot .support {
  margin: 0 0 0.9rem;
}

.support .button {
  border-color: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
  text-decoration: none;
}

.head-support {
  justify-content: flex-end;
  color: var(--muted);
  font-size: 0.9rem;
}

/* At the top, in orange: they stand apart from the steps' blue. */
.head-support .button {
  border-color: var(--support);
  color: var(--support-ink);
}

.head-support .button:hover {
  border-color: var(--support);
  background: var(--support-soft);
}

/* After the first download (ui/support.js), while its place in the header is out of view: pinned to the top of
   the window, sliding down from its edge. */
.head-support.is-pinned {
  position: fixed;
  top: 0;
  right: var(--pin-right, 1.5rem);
  z-index: 8;
  padding: 0.55rem 0.85rem;
  border: 1px solid var(--line);
  border-top: 0;
  border-radius: 0 0 12px 12px;
  background: var(--surface);
  box-shadow: 0 6px 20px rgb(0 0 0 / 0.12);
  animation: pin-in 0.45s cubic-bezier(0.2, 0.8, 0.2, 1);
}

@keyframes pin-in {
  from {
    transform: translateY(-100%);
  }
}

/* Clear of the pinned links: what scrolls into view, and the sticky column beside the steps. */
html:has(.is-pinned) {
  scroll-padding-top: 4rem;
}

.foot-line {
  margin: 0.3rem 0 0;
}

/* The interface language menu (ui/locale.js). */
.loc-button {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  height: 2.5rem;
  padding: 0 0.7rem;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  cursor: pointer;
}

.loc-button::after {
  content: "";
  width: 0.4rem;
  height: 0.4rem;
  margin-left: 0.1rem;
  border-right: 1.5px solid var(--muted);
  border-bottom: 1.5px solid var(--muted);
  transform: translateY(-2px) rotate(45deg);
}

.loc-button:hover {
  border-color: var(--accent);
}

.loc-button[aria-busy="true"] {
  opacity: 0.6;
  cursor: progress;
}

.flag {
  display: block;
  flex: none;
  width: 20px;
  height: 15px;
  border-radius: 2px;
  box-shadow: 0 0 0 1px rgb(0 0 0 / 0.14);
}

/* Two columns, read down: arrow keys follow the same order. */
.loc-menu {
  position: fixed;
  inset: auto;
  width: max-content;
  max-height: calc(100vh - 1rem);
  margin: 0;
  padding: 0.35rem;
  overflow-y: auto;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 10px 30px rgb(0 0 0 / 0.18);
}

.loc-menu:popover-open {
  display: grid;
  grid-template-rows: repeat(8, auto);
  grid-auto-flow: column;
  gap: 0.1rem 0.25rem;
}

.loc-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-width: 9.5rem;
  padding: 0.45rem 0.7rem 0.45rem 0.55rem;
  border: 0;
  border-radius: 6px;
  background: none;
  color: inherit;
  font: inherit;
  font-size: 0.95rem;
  text-align: start;
  cursor: pointer;
}

.loc-item:hover,
.loc-item:focus-visible {
  background: var(--accent-soft);
}

.loc-item:focus-visible {
  outline-offset: -2px;
}

.loc-item[aria-checked="true"] {
  color: var(--accent-ink);
  font-weight: 600;
}

.loc-item[aria-checked="true"]::after {
  content: "✓";
  margin-left: auto;
  padding-left: 0.75rem;
}

/* A translation is on its way (see index.html): the page's texts wait for it, the English stays hidden. */
.i18n-pending:not(.ready) [data-t],
.i18n-pending:not(.ready) [data-plural] {
  visibility: hidden;
}

/* ------------------------------------------------------------------ layout */

.layout {
  display: grid;
  grid-template-columns: minmax(0, 36rem) minmax(0, 1fr);
  gap: 1.5rem 2rem;
  align-items: start;
  padding-bottom: 3rem;
}

.steps {
  display: grid;
  gap: 1rem;
}

.step,
.preview-panel,
.cards-panel {
  padding: 1.1rem 1.25rem 1.25rem;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
}

.step h2,
.preview-panel > h2,
.cards-panel > h2,
.sheet-head h2 {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin: 0 0 0.85rem;
  font-size: 1.05rem;
}

.step-num {
  display: inline-grid;
  place-items: center;
  width: 1.6rem;
  height: 1.6rem;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-size: 0.85rem;
  font-weight: 600;
}

.step-note {
  margin: -0.35rem 0 0.85rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.status {
  min-height: 1.35em; /* keeps its line while empty, so "Loading … words" doesn't push the steps below */
  margin: 0.6rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

/* ------------------------------------------------------------------ controls */

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.45rem 0.9rem;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  cursor: pointer;
}

.button:hover:not(:disabled) {
  border-color: var(--accent);
}

.button.primary {
  padding: 0.65rem 1.35rem;
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-text);
  font-weight: 600;
}

.button.danger {
  border-color: var(--danger);
  background: var(--danger);
  color: var(--surface);
  font-weight: 600;
}

.button.danger:hover:not(:disabled) {
  border-color: var(--danger);
}

.button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Chips: radio buttons dressed as pills. The invisible input covers the chip, so it stays the click
   and focus target; the outline goes on the chip. */
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.chip {
  position: relative;
  display: inline-flex;
  align-items: center;
  padding: 0.4rem 0.85rem;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--surface);
  line-height: 1.3;
  cursor: pointer;
  user-select: none;
}

.chip-input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.chip:hover {
  border-color: var(--accent);
}

.chip:has(.chip-input:checked) {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-text);
}

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

.chip:has(.chip-input:disabled) {
  opacity: 0.4;
}

.chip:has(.chip-input:disabled),
.chip-input:disabled {
  cursor: not-allowed;
}

/* Step 2: "Same language" on a row of its own, set apart from the languages. */
.same-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.6rem;
  margin-bottom: 0.85rem;
  padding-bottom: 0.85rem;
  border-bottom: 1px solid var(--line);
}

.same-note {
  color: var(--muted);
  font-size: 0.9rem;
}

/* "?" buttons and their popovers */
.help {
  display: inline-grid;
  flex: none;
  place-items: center;
  width: 1.5rem;
  height: 1.5rem;
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  font: 600 0.75rem/1 var(--font);
  cursor: pointer;
}

.help:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.help-pop {
  position: fixed;
  inset: auto;
  margin: 0;
  padding: 0.75rem 0.9rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 10px 30px rgb(0 0 0 / 0.18);
  font-size: 0.9rem;
  line-height: 1.45;
}

/* Browsers without the Popover API would show every popover inline: keep them hidden there. */
@supports not selector(:popover-open) {
  .help-pop,
  .loc-menu {
    display: none;
  }
}

.help-pop p {
  margin: 0 0 0.5rem;
}

.help-pop > :last-child,
.help-pop > div > :last-child {
  margin-bottom: 0;
}

.help-pop ul {
  margin: 0.25rem 0 0;
  padding-left: 1.1rem;
}

.help-pop li + li {
  margin-top: 0.35rem;
}

/* Segmented controls: radio groups shown as joined buttons */
.seg {
  display: inline-flex;
  flex: none;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  overflow: hidden;
}

.seg label {
  position: relative;
}

.seg input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.seg span {
  display: block;
  padding: 0.3rem 0.75rem;
  font-size: 0.9rem;
  white-space: nowrap;
}

.seg label + label span {
  border-left: 1px solid var(--line-strong);
}

.seg input:checked + span {
  background: var(--accent);
  color: var(--accent-text);
}

/* In a radio group the focused option is the checked one, so the ring goes around the group. */
.seg:has(input:focus-visible) {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.seg input:disabled,
.seg input:disabled + span {
  cursor: not-allowed;
  opacity: 0.45;
}

/* Switches: checkboxes with role="switch" */
.switch {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  cursor: pointer;
}

.switch input {
  position: relative;
  flex: none;
  width: 2.4rem;
  height: 1.4rem;
  margin: 0;
  border-radius: 999px;
  background: var(--line-strong);
  appearance: none;
  cursor: pointer;
  transition: background 0.15s;
}

.switch input::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: calc(1.4rem - 4px);
  height: calc(1.4rem - 4px);
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.3);
  transition: transform 0.15s;
}

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

.switch input:checked::after {
  transform: translateX(1rem);
}

.switch input:disabled {
  cursor: not-allowed;
}

/* ------------------------------------------------------------------ modules */

.cat + .cat {
  border-top: 1px solid var(--line);
}

.cat-head {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding-block: 0.45rem;
}

.cat-toggle {
  display: grid;
  flex: none;
  place-items: center;
  width: 1.75rem;
  height: 1.75rem;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.cat-toggle::before {
  content: "";
  width: 0.45rem;
  height: 0.45rem;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: translateX(-1px) rotate(-45deg);
  transition: transform 0.15s;
}

.cat-toggle[aria-expanded="true"]::before {
  transform: translateY(-2px) rotate(45deg);
}

.cat-toggle:hover {
  background: var(--accent-soft);
}

.cat-label,
.mod-label {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  cursor: pointer;
}

.cat-name {
  font-weight: 600;
}

.cat-tally {
  margin-left: auto;
  color: var(--muted);
  font-size: 0.85rem;
}

.mod-list {
  display: grid;
  gap: 0.55rem;
  margin: 0 0 0.6rem;
  padding: 0 0 0 2.15rem;
  list-style: none;
}

.mod-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
}

.mod-words {
  margin-left: auto;
  color: var(--muted);
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
}

.mod-desc {
  margin: 0.05rem 0 0 1.65rem;
  color: var(--muted);
  font-size: 0.85rem;
}

.mod-help {
  display: inline-flex;
}

.badge {
  padding: 0.05rem 0.4rem;
  border-radius: 6px;
  background: var(--danger);
  color: var(--surface);
  font-size: 0.75rem;
  font-weight: 700;
}

/* ------------------------------------------------------------------ fields */

.f-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.5rem 1rem;
  padding-block: 0.55rem;
}

.f-row + .f-row {
  border-top: 1px solid var(--line);
}

.f-name {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.f-fixed {
  color: var(--muted);
  font-size: 0.9rem;
}

.f-slider {
  display: flex;
  grid-column: 1 / -1;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
}

.f-slider input {
  width: min(12rem, 60%);
}

.f-count {
  min-width: 6.5rem;
  color: var(--muted);
  font-size: 0.9rem;
}

/* The rarely used rows (ui/fields.js), closed by default. */
.f-more {
  border-top: 1px solid var(--line);
}

.f-more > summary {
  padding-block: 0.55rem;
  color: var(--accent-ink);
  cursor: pointer;
}

.f-more > summary + .f-row {
  border-top: 1px solid var(--line);
}

/* Closed, it names the rows that are on. */
.f-more-on {
  margin-left: 0.3rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.f-more[open] .f-more-on {
  display: none;
}

/* ------------------------------------------------------------------ options, download */

.opts {
  display: grid;
  gap: 0.85rem;
}

.opt {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem;
}

.opt.is-disabled .switch {
  opacity: 0.5;
}

.opt-label {
  margin-right: 0.2rem;
}

.dl-summary {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 0.3rem 1rem;
  margin: 0 0 1.1rem;
}

.dl-summary dt {
  color: var(--muted);
}

.dl-summary dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.dl-file {
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 0.9rem;
}

.dl-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1.25rem;
}

.dl-help {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.dl-status {
  margin: 0.85rem 0 0;
}

.dl-status:empty {
  display: none;
}

/* The Share block (ui/share.js): no number, no card of its own. */
.step-plain {
  background: transparent;
}

.share-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

/* The link buttons, then the sites. */
.share-row + .share-row {
  margin-top: 0.75rem;
}

.share-copy .icon,
.share-row .button .icon {
  color: var(--accent);
}

.share-site {
  display: inline-grid;
  place-items: center;
  width: 2.5rem;
  height: 2.5rem;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  color: var(--muted);
}

.share-site:hover {
  border-color: var(--accent);
  color: var(--accent-ink);
}

.share-status {
  margin: 0.6rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.share-status:empty {
  display: none;
}

.icon {
  display: inline-flex;
  flex: none;
}

.icon svg {
  display: block;
}

/* ------------------------------------------------------------------ preview and word list */

/* The column beside the steps. With the word list it fills the window: the preview takes 60% of it
   (scrolling inside when taller) and the list the rest, so the list stays put when the sample changes. */
.side {
  position: sticky;
  top: 1rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  max-height: calc(100vh - 2rem);
}

.side:has(> .cards-panel:not([hidden])) {
  height: calc(100vh - 2rem);
}

html:has(.is-pinned) .side {
  top: 4rem;
  max-height: calc(100vh - 5rem);
}

html:has(.is-pinned) .side:has(> .cards-panel:not([hidden])) {
  height: calc(100vh - 5rem);
}

/* The faces scroll inside the panel when they don't fit, under its heading and buttons; a face itself never
   scrolls (its frame takes the face's height, ui/preview.js). */
.preview-panel {
  display: flex;
  flex: 0 1 auto;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.preview-panel > .pv,
.sheet .pv {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-height: 0;
}

.pv-faces {
  flex: 1 1 auto;
  min-height: 0;
  margin-right: -0.6rem;
  padding-right: 0.6rem;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.side:has(> .cards-panel:not([hidden])) > .preview-panel {
  flex: 0 0 60%;
}

.cards-panel {
  display: flex;
  flex: 1 1 15rem;
  flex-direction: column;
  min-height: 12rem;
}

.pv-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 0.75rem;
}

.pv-count {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  font-variant-numeric: tabular-nums;
}

.pv-actions {
  display: flex;
  gap: 0.5rem;
  margin-left: auto;
}


.pv-empty {
  margin: 0.5rem 0 0;
  color: var(--muted);
}

.pv-dir h3 {
  margin: 1.1rem 0 0.5rem;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.pv-pair {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(17rem, 1fr));
  align-items: start;
  gap: 0.75rem;
}

.pv-face {
  margin: 0;
}

.pv-face figcaption {
  margin-bottom: 0.3rem;
  color: var(--muted);
  font-size: 0.8rem;
}

.pv-frame {
  display: block;
  width: 100%;
  height: 7rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card-bg);
}

/* The word list: a search box, then a scrolling list of fixed-height rows (ui/sidebar.js). */
.cl,
.cl-body {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-height: 0;
}

.cl-search {
  width: 100%;
  padding: 0.45rem 0.7rem;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
}

.cl-tools {
  margin-bottom: 0.4rem;
}

.cl-status {
  margin: 0.45rem 0 0;
  color: var(--muted);
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
}

.cl-status:empty {
  display: none;
}

.cl-empty {
  margin: 0;
  color: var(--muted);
}

.cl-viewport {
  flex: 1;
  min-height: 0;
  margin: 0 -0.5rem;
  padding: 0 0.5rem;
  overflow-y: auto;
  overscroll-behavior: contain;
}

/* The height is set by ui/sidebar.js; the padding lets the last rows scroll clear of the Feedback button. */
.cl-list {
  position: relative;
  box-sizing: content-box;
  padding-bottom: 3.5rem;
}

.cl-row {
  position: absolute;
  right: 0;
  left: 0;
  display: flex;
  align-items: center;
  height: 2.6rem;
  box-shadow: inset 0 -1px var(--line);
}

.cl-pick {
  display: flex;
  flex: 1;
  align-items: baseline;
  gap: 0.6rem;
  min-width: 0;
  height: 100%;
  padding: 0.6rem 0.5rem 0;
  border: 0;
  border-radius: 8px;
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.cl-pick:hover,
.cl-row.is-sample .cl-pick {
  background: var(--accent-soft);
}

.cl-row.is-sample .cl-pick {
  box-shadow: inset 3px 0 var(--accent);
}

.cl-pick:focus-visible,
.cl-report:focus-visible {
  outline-offset: -2px;
}

.cl-word {
  flex: 0 1 auto;
  max-width: 60%;
  overflow: hidden;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cl-dis {
  flex: none;
  color: var(--muted);
  font-size: 0.8rem;
}

.cl-tr {
  flex: 1 1 0;
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.92rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cl-report {
  display: grid;
  flex: none;
  place-items: center;
  width: 2.2rem;
  height: 2.2rem;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: none;
  color: var(--muted);
  cursor: pointer;
  opacity: 0;
}

.cl-row:hover .cl-report,
.cl-row:focus-within .cl-report,
.cl-row.is-sample .cl-report {
  opacity: 1;
}

.cl-report:hover {
  background: var(--accent-soft);
  color: var(--accent-ink);
}

/* Touch screens have no hover: keep the flags visible. */
@media (hover: none) {
  .cl-report {
    opacity: 1;
  }
}

.mobile-bar {
  display: none;
}

.bar-cards {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.45rem 0;
  border: 0;
  background: none;
  color: var(--accent-ink);
  font: inherit;
  font-size: 0.9rem;
  font-variant-numeric: tabular-nums;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  cursor: pointer;
}

/* Phone sheets: the preview, and the word list. */
.sheet {
  width: min(40rem, 100vw);
  max-width: 100vw;
  height: 100dvh;
  max-height: 100dvh;
  margin: 0 auto;
  padding: 0;
  border: 0;
  background: var(--bg);
  color: var(--text);
}

.sheet[open] {
  display: flex;
  flex-direction: column;
}

.sheet::backdrop {
  background: rgb(0 0 0 / 0.45);
}

.sheet-head {
  display: flex;
  flex: none;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 1rem;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.sheet-head h2 {
  margin: 0;
}

.sheet .pv {
  padding: 0.85rem 1rem 0;
}

.sheet .pv-faces {
  padding-bottom: 1.5rem;
}

.sheet .cl {
  padding: 0.85rem 1rem 0;
}

/* ------------------------------------------------------------------ feedback */

.fab {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 6;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.55rem 0.95rem;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 4px 14px rgb(0 0 0 / 0.14);
  font: inherit;
  font-size: 0.9rem;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

.fab:hover {
  border-color: var(--accent);
}

.fab .icon {
  color: var(--accent);
}

.fb {
  width: min(34rem, calc(100vw - 2rem));
  max-height: calc(100dvh - 2rem);
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 20px 50px rgb(0 0 0 / 0.25);
}

.fb::backdrop,
.confirm::backdrop {
  background: rgb(0 0 0 / 0.45);
}

/* "Are you sure?" before Reset all (ui/reset.js). */
.confirm {
  width: min(25rem, calc(100vw - 2rem));
  padding: 1.1rem 1.25rem 1.25rem;
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 20px 50px rgb(0 0 0 / 0.25);
}

.confirm h2 {
  margin: 0;
  font-size: 1.15rem;
}

.confirm p {
  margin: 0.5rem 0 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.confirm-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 1.1rem;
}

.confirm-actions .button {
  white-space: nowrap;
}

.fb-form,
.fb-done {
  display: grid;
  gap: 0.85rem;
  padding: 1.1rem 1.25rem 1.25rem;
}

.fb-done {
  justify-items: start;
}

.fb-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.fb-head h2 {
  margin: 0;
  font-size: 1.15rem;
}

.fb-x {
  width: 2rem;
  height: 2rem;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: none;
  color: var(--muted);
  font: 1.4rem/1 var(--font);
  cursor: pointer;
}

.fb-x:hover {
  background: var(--accent-soft);
  color: var(--text);
}

.fb-about {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.fb-about b {
  color: var(--text);
}

.fb-field {
  display: grid;
  gap: 0.3rem;
}

.fb-field label {
  font-size: 0.9rem;
  font-weight: 600;
}

.fb-opt {
  color: var(--muted);
  font-weight: 400;
}

.fb textarea,
.fb select,
.fb input[type="email"] {
  width: 100%;
  padding: 0.5rem 0.65rem;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
}

.fb textarea {
  min-height: 6.5rem;
  resize: vertical;
}

.fb-hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.85rem;
}

/* The honeypot: off screen, out of the tab order, hidden from screen readers. */
.fb-hp {
  position: absolute;
  left: -10000px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

.fb-status {
  margin: 0;
  font-size: 0.9rem;
}

.fb-status:empty {
  display: none;
}

.fb-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.6rem;
}

.fb-keys {
  margin-right: auto;
  color: var(--muted);
  font-size: 0.85rem;
}

.fb-privacy {
  margin: 0;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.4;
}

.fb-thanks {
  margin: 0;
  font-size: 1.05rem;
}

@media (hover: none) {
  .fb-keys {
    display: none;
  }
}

/* ------------------------------------------------------------------ landing pages (tools/landing.mjs) */

/* A reading column; the header and footer line up with it. */
.lp-page .site-head,
.lp-page .site-foot,
.lp {
  max-width: 52rem;
}

.lp-page .site-head {
  padding-block: 1.25rem 0;
}

/* No bottom bar or Feedback button to clear. */
.lp-page .site-foot {
  padding-bottom: 2.5rem;
}

.crumbs ol {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 0.5rem;
  margin: 0;
  padding: 0;
  color: var(--muted);
  font-size: 0.9rem;
  list-style: none;
}

.crumbs li + li::before {
  content: "›";
  margin-right: 0.5rem;
}

.crumbs a {
  color: inherit;
  text-underline-offset: 3px;
}

.crumbs li:first-child a {
  color: var(--text);
  font-weight: 700;
  text-decoration: none;
}

.crumbs [aria-current="page"] {
  text-decoration: none;
}

.lp {
  margin: 0 auto;
  padding: 1.25rem 1.5rem 1rem;
}

.lp a {
  color: var(--accent-ink);
  text-underline-offset: 3px;
}

.lp h1 {
  margin: 0;
  font-size: 2rem;
  line-height: 1.2;
  letter-spacing: -0.015em;
}

.lp h2 {
  margin: 2.5rem 0 0.75rem;
  font-size: 1.35rem;
}

.lp h3 {
  margin: 1.5rem 0 0.6rem;
  font-size: 1.05rem;
}

.lp > p,
.lp > ol {
  max-width: 42rem;
}

.lp-facts {
  margin: 0.6rem 0 0;
  color: var(--muted);
}

.lp-cta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem 1rem;
  margin: 1.5rem 0;
}

.lp-cta .button {
  text-decoration: none;
}

.lp-cta span {
  color: var(--muted);
  font-size: 0.9rem;
}

.lp-fields {
  display: grid;
  grid-template-columns: minmax(8rem, max-content) minmax(0, 1fr);
  gap: 0.55rem 1.25rem;
  margin: 1rem 0;
}

.lp-fields dt {
  font-weight: 600;
}

.lp-fields dd {
  margin: 0;
  color: var(--muted);
}

.lp-mods {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 15rem), 1fr));
  gap: 0.75rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.lp-mod {
  padding: 0.85rem 1rem 0.95rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.lp-mod h4 {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.25rem 0.5rem;
  margin: 0;
  font-size: 1rem;
}

.lp-count {
  margin-left: auto;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 400;
  font-variant-numeric: tabular-nums;
}

.lp-mod p {
  margin: 0.3rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.lp-words {
  display: grid;
  gap: 0.2rem;
  margin: 0.6rem 0 0;
  padding: 0.6rem 0 0;
  border-top: 1px solid var(--line);
  font-size: 0.95rem;
  list-style: none;
}

.lp-dis,
.lp-tr {
  color: var(--muted);
}

.lp-pairs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.lp .lp-pairs a {
  display: inline-block;
  padding: 0.35rem 0.85rem;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
}

.lp .lp-pairs a:hover {
  border-color: var(--accent);
}

.lp-native {
  margin-left: 0.35rem;
  color: var(--muted);
  font-weight: 400;
}

/* ------------------------------------------------------------------ languages page (languages.html) */

/* The Feedback button sits in the corner here, as in the app. */
.langs-page .site-foot {
  padding-bottom: 4.5rem;
}

.lang-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 15rem), 1fr));
  gap: 0.75rem;
  margin: 1.75rem 0 0;
  padding: 0;
  list-style: none;
}

.lang {
  display: flex;
  align-items: flex-start;
  gap: 0.7rem;
  padding: 0.85rem 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.lang .flag {
  flex: none;
  margin-top: 0.3rem;
}

.lang p {
  margin: 0;
}

.lang-native {
  font-weight: 600;
}

.lang-name {
  margin-left: 0.45rem;
  color: var(--muted);
}

.lang-extras {
  margin-top: 0.15rem;
  color: var(--muted);
  font-size: 0.85rem;
}

.lp .lang-build {
  display: inline-block;
  margin-top: 0.4rem;
  font-size: 0.9rem;
}

/* Translated names wait for their translation, like the texts marked data-t. */
.i18n-pending:not(.ready) .lang-name,
.i18n-pending:not(.ready) .lang-extras {
  visibility: hidden;
}

.lang-ask {
  margin-top: 2.5rem;
}

.lang-ask h2 {
  margin-top: 0;
}

/* Without scripts there is no dialog to ask in. */
html:not(.js) .lang-ask {
  display: none;
}

/* ------------------------------------------------------------------ narrow screens */

@media (max-width: 59.99rem) {
  .layout {
    grid-template-columns: minmax(0, 1fr);
  }

  /* The language button beside the title; the support links under the lede. */
  .app-head {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: "main language" "support support";
  }

  .head-support {
    justify-content: flex-start;
  }

  /* Pinned: a bar across the top. */
  .head-support.is-pinned {
    right: 0;
    left: 0;
    justify-content: center;
    padding-inline: 1rem;
    border-width: 0 0 1px;
    border-radius: 0;
  }

  /* Clear of the bottom bar and the Feedback button above it. */
  .site-foot {
    padding-bottom: calc(9rem + env(safe-area-inset-bottom));
  }

  .side {
    display: none;
  }

  .mobile-bar {
    position: fixed;
    inset: auto 0 0;
    z-index: 5;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.6rem 1rem calc(0.6rem + env(safe-area-inset-bottom));
    border-top: 1px solid var(--line);
    background: var(--surface);
  }

  .mobile-bar .button {
    margin-left: auto;
  }

  /* Above the bar, as a round flag. */
  .fab {
    padding: 0.7rem;
  }

  .fab-label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }

  body:has(.mobile-bar:not([hidden])) .fab {
    bottom: calc(4.4rem + env(safe-area-inset-bottom));
  }
}

@media (max-width: 30rem) {
  .site-head,
  .layout,
  .site-foot,
  .noscript,
  .lp {
    padding-inline: 1rem;
  }

  .lp-fields {
    grid-template-columns: minmax(0, 1fr);
    gap: 0.15rem;
  }

  .lp-fields dd {
    margin-bottom: 0.5rem;
  }

  .step {
    padding-inline: 1rem;
  }

  /* A slim bar: the two buttons speak for themselves. */
  .head-support.is-pinned > span:first-child {
    display: none;
  }

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

  /* Segments share the row: bigger touch targets, no stretched last button. */
  .f-row .seg label {
    flex: 1;
  }

  .f-row .seg span {
    text-align: center;
  }

  .f-slider {
    justify-content: flex-start;
  }

  .mod-list {
    padding-left: 0.5rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition: none !important;
    animation: none !important;
  }
}
