/* All The Words - Warm Editorial & Tile Craft Stylesheet.
 *
 * Tactile ivory paper & deep forest-emerald palette in light mode, deep
 * pine-charcoal & mint-emerald in dark mode, with burnt terracotta point
 * accents and beveled letter tiles echoing the A1 brand mark.
 *
 * All foreground tokens meet WCAG AA (>= 4.5:1) against both --bg and
 * --surface-2 in both themes, and UI boundaries meet WCAG 1.4.11 (>= 3:1).
 */

:root {
    color-scheme: light;

    --bg: #f5f2ea;
    --surface: #fffdf9;
    --surface-2: #eae5d9;
    --ink: #161a18;
    --ink-2: #3d4641;
    --ink-3: #525c56;
    --line: #d7d1c3;
    --line-strong: #8c8575;

    --accent: #0f5c47;
    --accent-hover: #0a4636;
    --accent-ink: #ffffff;
    --accent-soft: #e2f1eb;

    --points: #9a3b0e;
    --points-soft: #fae8dc;
    --tile-bg: #faf5e6;
    --tile-edge: #d8ccb0;

    --danger: #a61e1a;
    --danger-soft: #fceded;

    --shadow-xs: 0 1px 2px rgb(22 26 24 / 0.05);
    --shadow-sm: 0 2px 8px rgb(22 26 24 / 0.06), 0 1px 2px rgb(22 26 24 / 0.04);
    --shadow-md: 0 8px 24px rgb(22 26 24 / 0.08), 0 2px 6px rgb(22 26 24 / 0.04);
    --topbar-bg: rgb(255 253 249 / 0.92);

    --radius: 12px;
    --radius-sm: 8px;
    --radius-pill: 999px;

    --font-ui: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
        "Helvetica Neue", Arial, sans-serif;
    --font-word: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
        "Liberation Mono", monospace;

    --topbar-h: 56px;
    --shell: 1120px;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        color-scheme: dark;

        --bg: #111513;
        --surface: #181d1a;
        --surface-2: #212824;
        --ink: #f1efe8;
        --ink-2: #c1c7c2;
        --ink-3: #959e98;
        --line: #2c3530;
        --line-strong: #64736a;

        --accent: #5cd6b0;
        --accent-hover: #7fe2c3;
        --accent-ink: #071f17;
        --accent-soft: #152d25;

        --points: #f4a46c;
        --points-soft: #312116;
        --tile-bg: #252b26;
        --tile-edge: #3d463f;

        --danger: #ff9a91;
        --danger-soft: #311917;

        --shadow-xs: 0 1px 2px rgb(0 0 0 / 0.28);
        --shadow-sm: 0 3px 10px rgb(0 0 0 / 0.34);
        --shadow-md: 0 10px 28px rgb(0 0 0 / 0.42);
        --topbar-bg: rgb(24 29 26 / 0.92);
    }
}

:root[data-theme="dark"] {
    color-scheme: dark;

    --bg: #111513;
    --surface: #181d1a;
    --surface-2: #212824;
    --ink: #f1efe8;
    --ink-2: #c1c7c2;
    --ink-3: #959e98;
    --line: #2c3530;
    --line-strong: #64736a;

    --accent: #5cd6b0;
    --accent-hover: #7fe2c3;
    --accent-ink: #071f17;
    --accent-soft: #152d25;

    --points: #f4a46c;
    --points-soft: #312116;
    --tile-bg: #252b26;
    --tile-edge: #3d463f;

    --danger: #ff9a91;
    --danger-soft: #311917;

    --shadow-xs: 0 1px 2px rgb(0 0 0 / 0.28);
    --shadow-sm: 0 3px 10px rgb(0 0 0 / 0.34);
    --shadow-md: 0 10px 28px rgb(0 0 0 / 0.42);
    --topbar-bg: rgb(24 29 26 / 0.92);
}

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

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

body {
    margin: 0;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    background: var(--bg);
    color: var(--ink);
    font-family: var(--font-ui);
    font-size: 16px;
    line-height: 1.55;
    overflow-x: clip;
    -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3,
h4 {
    line-height: 1.15;
    margin: 0 0 0.5rem;
    text-wrap: balance;
    font-weight: 750;
}

h1 {
    font-size: clamp(1.95rem, 3.6vw, 2.75rem);
    letter-spacing: -0.03em;
}

h2 {
    font-size: 1.25rem;
    letter-spacing: -0.015em;
}

h3 {
    font-size: 1rem;
}

p {
    margin: 0 0 0.75rem;
}

a {
    color: var(--accent);
    text-decoration-thickness: 1px;
    text-underline-offset: 3px;
}

a:hover {
    color: var(--accent-hover);
}

img {
    max-width: 100%;
}

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

/* Issue #176: a boxed control draws its focus ring inside its own border. An
 * outside ring paints over neighbouring content and disappears inside any
 * container that hides overflow (.segmented). Plain text links keep the outside
 * ring: an inset one would run through the glyphs. The Wordfeud board cells and
 * rack inputs keep their own tighter override further down. */
button:focus-visible,
select:focus-visible,
input:focus-visible,
textarea:focus-visible,
.btn:focus-visible,
.pill:focus-visible,
.seg:focus-visible,
.tabs a:focus-visible,
.theme-toggle:focus-visible,
.tab-button:focus-visible {
    outline-offset: -3px;
}

/* Issue #175: an in-page anchor lands below the sticky top bar instead of
 * underneath it. v2.js publishes the measured bar height as --topbar-real-h;
 * the fixed token is the no-JavaScript fallback, the same pair .grouphead uses. */
[id] {
    scroll-margin-block-start: calc(var(--topbar-real-h, var(--topbar-h)) + 0.5rem);
}

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

.skip-link {
    position: absolute;
    inset-block-start: -100px;
    inset-inline-start: 12px;
    z-index: 100;
    padding: 0.6rem 0.9rem;
    background: var(--accent);
    color: var(--accent-ink);
    border-radius: var(--radius-sm);
    font-weight: 600;
    text-decoration: none;
}

.skip-link:focus {
    inset-block-start: 12px;
    color: var(--accent-ink);
}

/* ---------- top bar ---------- */

.topbar {
    position: sticky;
    top: 0;
    z-index: 40;
    background: var(--topbar-bg);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-block-end: 1px solid var(--line);
}

.topbar-inner {
    max-width: 1200px;
    margin-inline: auto;
    min-height: var(--topbar-h);
    padding: 0.4rem clamp(0.75rem, 3vw, 1.5rem);
    display: flex;
    align-items: center;
    gap: 0.5rem 1.15rem;
    flex-wrap: wrap;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    color: var(--ink);
    text-decoration: none;
    font-weight: 750;
    letter-spacing: -0.02em;
    flex: 0 0 auto;
}

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

/* The mark is the favicon in miniature: a tile carrying "A" with the word's
 * point value as a subscript, so the logo and the tab icon read the same.
 * The inks are swapped (background is --ink, the glyph is --bg), which is what
 * makes the tile flip in dark mode without a second asset. */
.brand-mark {
    display: inline-grid;
    place-items: center;
    width: 1.95rem;
    height: 1.95rem;
    border-radius: 7px;
    background: var(--ink);
    color: var(--bg);
    font-weight: 700;
    letter-spacing: -0.03em;
    line-height: 1;
    box-shadow: 0 2px 0 rgb(0 0 0 / 0.18);
}

.brand-glyph {
    display: inline-block;
    font-size: 1.2rem;
    line-height: 1;
    transform: translateY(-0.05em);
}

.brand-mark sub {
    font-size: 0.55em;
    font-weight: 600;
    letter-spacing: 0;
    line-height: 1;
    margin-left: 0.04em;
    vertical-align: -0.2em;
}

.brand-name {
    font-size: 1.02rem;
}

.preview-chip {
    font-size: 0.62rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--ink-3);
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-pill);
    padding: 0.05rem 0.42rem;
    line-height: 1.4;
}

.tabs {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.15rem 0.25rem;
    flex: 1 1 320px;
    min-width: 0;
}

.tabs a {
    /* WCAG 2.2 SC 2.5.8: 24px minimum target (issue #148). */
    position: relative;
    display: inline-flex;
    align-items: center;
    min-height: 1.9rem;
    color: var(--ink-2);
    text-decoration: none;
    font-size: 0.89rem;
    font-weight: 500;
    padding: 0.35rem 0.65rem;
    border-radius: var(--radius-sm);
    white-space: nowrap;
    transition: background-color 0.14s ease, color 0.14s ease;
}

.tabs a:hover {
    background: var(--surface-2);
    color: var(--ink);
}

/* Active page uses bold weight + soft fill + crisp bottom accent indicator so
 * state never depends on color alone (WCAG 1.4.1). */
.tabs a[aria-current="page"] {
    color: var(--accent);
    background: var(--accent-soft);
    font-weight: 700;
    box-shadow: inset 0 -2px 0 var(--accent);
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    margin-inline-start: auto;
}

.langform {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    margin: 0;
}

.langform select {
    max-width: 11rem;
    min-height: 2.1rem;
    font-family: inherit;
    font-size: 0.84rem;
    font-weight: 500;
    color: var(--ink);
    background: var(--surface);
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    padding: 0.28rem 0.5rem;
    box-shadow: var(--shadow-xs);
}

html.js .langform .btn {
    display: none;
}

.theme-toggle {
    display: inline-grid;
    place-items: center;
    width: 2.1rem;
    height: 2.1rem;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--ink-2);
    font-size: 0.98rem;
    cursor: pointer;
    line-height: 1;
    box-shadow: var(--shadow-xs);
    transition: background-color 0.14s ease, color 0.14s ease, border-color 0.14s ease;
}

.theme-toggle:hover {
    color: var(--ink);
    background: var(--surface-2);
    border-color: var(--ink-3);
}

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

.shell {
    flex: 1 0 auto;
    width: 100%;
    max-width: var(--shell);
    margin-inline: auto;
    padding: clamp(1rem, 2.8vw, 2rem) clamp(0.75rem, 3vw, 1.5rem) 3.5rem;
}

.page {
    max-width: 100%;
}

.page--narrow {
    max-width: 640px;
    margin-inline: auto;
}

.page--tool {
    max-width: 760px;
    margin-inline: auto;
}

.page-head {
    margin-block-end: 1.4rem;
}

.eyebrow {
    margin: 0 0 0.4rem;
    font-size: 0.76rem;
    font-weight: 700;
    letter-spacing: 0.09em;
    text-transform: uppercase;
    color: var(--ink-3);
}

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

.eyebrow a:hover {
    color: var(--accent);
    text-decoration: underline;
}

.lede {
    font-size: 1.06rem;
    color: var(--ink-2);
    max-width: 60ch;
}

.meta {
    color: var(--ink-2);
    font-variant-numeric: tabular-nums;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.4rem 0.6rem;
}

.note {
    color: var(--ink-3);
    font-size: 0.86rem;
}

.note-inline {
    color: var(--danger);
    font-size: 0.85rem;
}

.muted {
    color: var(--ink-3);
    font-weight: 500;
}

.sectiontitle {
    margin-block-start: 0.75rem;
    color: var(--ink-2);
    font-weight: 600;
    font-size: 1.05rem;
}

/* ---------- buttons ---------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    min-height: 2.45rem;
    padding: 0.5rem 1rem;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--ink);
    font: inherit;
    font-size: 0.92rem;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    box-shadow: var(--shadow-xs);
    transition: background-color 0.14s ease, border-color 0.14s ease,
        color 0.14s ease, transform 0.1s ease, box-shadow 0.14s ease;
}

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

.btn:active {
    transform: translateY(1px);
}

.btn--primary {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--accent-ink);
    box-shadow: 0 2px 0 rgb(0 0 0 / 0.18), var(--shadow-xs);
}

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

.btn--quiet {
    background: transparent;
    border-color: transparent;
    color: var(--accent);
    box-shadow: none;
    padding-inline: 0.6rem;
}

.btn--quiet:hover {
    background: var(--accent-soft);
    border-color: transparent;
    color: var(--accent);
}

.linkrow {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem 0.5rem;
    margin-block: 0.5rem 1.25rem;
}

/* ---------- panels, disclosures, forms ---------- */

.panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: clamp(1rem, 2.5vw, 1.5rem);
    box-shadow: var(--shadow-sm);
}

.panel + .panel {
    margin-block-start: 0.85rem;
}

/* Native <details> disclosure styling with custom animated chevron placed right
 * before the label text (RTL-safe, progressive slide via ::details-content). */
details.panel > summary,
details.refine-more > summary,
details.code-example > summary,
details.secondary-section > summary {
    list-style: none;
    display: flex;
    align-items: center;
    gap: 0.55rem;
    cursor: pointer;
    font-weight: 650;
}

details.panel > summary::-webkit-details-marker,
details.refine-more > summary::-webkit-details-marker,
details.code-example > summary::-webkit-details-marker,
details.secondary-section > summary::-webkit-details-marker {
    display: none;
}

details.panel > summary::before,
details.refine-more > summary::before,
details.code-example > summary::before,
details.secondary-section > summary::before {
    content: "";
    inline-size: 0.52rem;
    block-size: 0.52rem;
    flex-shrink: 0;
    border-inline-end: 2px solid var(--ink-3);
    border-block-end: 2px solid var(--ink-3);
    transform: rotate(-45deg);
    transition: transform 0.18s ease, border-color 0.14s ease;
}

details.panel > summary:dir(rtl)::before,
details.refine-more > summary:dir(rtl)::before,
details.code-example > summary:dir(rtl)::before,
details.secondary-section > summary:dir(rtl)::before {
    transform: rotate(135deg);
}

details.panel[open] > summary::before,
details.refine-more[open] > summary::before,
details.code-example[open] > summary::before,
details.secondary-section[open] > summary::before {
    transform: rotate(45deg);
    border-color: var(--accent);
}

details.panel[open] > summary {
    margin-block-end: 0.85rem;
}

details::details-content {
    interpolate-size: allow-keywords;
    overflow: clip;
    contain: layout;
}

details:not([open])::details-content {
    block-size: 0;
}

@media (prefers-reduced-motion: no-preference) {
    details::details-content {
        transition: block-size 0.22s ease, content-visibility 0.22s ease;
        transition-behavior: allow-discrete;
    }
}

.panel-title {
    font-size: 0.76rem;
    font-weight: 750;
    text-transform: uppercase;
    letter-spacing: 0.09em;
    color: var(--ink-3);
    margin-block-end: 0.9rem;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    margin-block-end: 0.95rem;
}

.field:last-child {
    margin-block-end: 0;
}

.field > label {
    font-size: 0.84rem;
    font-weight: 650;
    color: var(--ink-2);
}

input[type="text"],
input[type="number"],
select {
    font: inherit;
    color: var(--ink);
    background: var(--surface);
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    padding: 0.55rem 0.75rem;
    width: 100%;
    max-width: 100%;
    min-height: 2.65rem;
    font-size: 1rem; /* 16px stops iOS from zooming the page on focus */
    transition: border-color 0.14s ease, box-shadow 0.14s ease, background-color 0.14s ease;
}

input[type="text"]:hover,
input[type="number"]:hover {
    border-color: var(--ink-2);
}

input[type="text"]:focus,
input[type="number"]:focus {
    border-color: var(--accent);
}

.input--lg {
    font-size: 1.12rem;
    min-height: 2.95rem;
}

.input--hero {
    font-family: var(--font-word);
    font-size: 1.4rem;
    font-weight: 650;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    min-height: 3.45rem;
    padding-inline: 0.85rem;
    background: var(--tile-bg);
    border-color: var(--line-strong);
    box-shadow: inset 0 1px 2px rgb(0 0 0 / 0.06);
}

.input--hero::placeholder {
    letter-spacing: 0.14em;
    color: var(--ink-3);
    opacity: 0.75;
    font-weight: 500;
}

.hint {
    margin: 0;
    font-size: 0.82rem;
    color: var(--ink-3);
}

.filters {
    border: 0;
    padding: 0;
    margin: 1rem 0 0;
    min-width: 0;
}

.filters--box {
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    padding: 0.9rem 1rem 1rem;
    margin-block: 1.1rem 0.25rem;
}

.filters > legend {
    padding: 0;
    margin-block-end: 0.65rem;
    font-size: 0.78rem;
    font-weight: 750;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--ink-3);
}

.filters--box > legend {
    float: left;
    width: 100%;
}

.filtergrid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(165px, 1fr));
    gap: 0.65rem 0.85rem;
    clear: both;
}

.filtergrid .field {
    margin-block-end: 0;
}

.formactions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.55rem;
    margin-block-start: 1.35rem;
}

.alert {
    background: var(--danger-soft);
    border: 1px solid var(--danger);
    color: var(--danger);
    border-radius: var(--radius-sm);
    padding: 0.75rem 0.95rem;
    margin-block-end: 1rem;
}

.empty {
    background: var(--surface);
    border: 1px dashed var(--line-strong);
    border-radius: var(--radius);
    padding: 2.25rem 1.25rem;
    text-align: center;
    color: var(--ink-2);
}

.empty h2 {
    color: var(--ink);
}

.empty .formactions {
    justify-content: center;
    margin-block-start: 1rem;
}

/* ---------- home ---------- */

.hero {
    display: grid;
    grid-template-columns: minmax(0, 0.86fr) minmax(0, 1.14fr);
    gap: clamp(1.25rem, 3.5vw, 2.75rem);
    align-items: center;
    padding-block: clamp(0.75rem, 2.5vw, 1.75rem) 2rem;
}

.hero h1 {
    font-size: clamp(2.45rem, 5.4vw, 3.7rem);
    letter-spacing: -0.04em;
    line-height: 1.05;
}

.hero .lede {
    font-size: 1.12rem;
    max-width: 30ch;
    margin-block-end: 1.25rem;
}

/* Decorative letter-tile strip echoing the A1 brand mark. */
.hero-tiles {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}

.hero-tile {
    display: inline-flex;
    align-items: baseline;
    justify-content: center;
    min-width: 2.15rem;
    height: 2.25rem;
    padding: 0.25rem 0.3rem;
    border-radius: 7px;
    border: 1px solid var(--tile-edge);
    background: var(--tile-bg);
    color: var(--ink);
    font-family: var(--font-word);
    font-size: 1.02rem;
    font-weight: 750;
    box-shadow: 0 2px 0 var(--tile-edge);
    user-select: none;
}

.hero-tile sub {
    font-size: 0.56em;
    font-weight: 700;
    color: var(--points);
    margin-inline-start: 0.06em;
    vertical-align: -0.18em;
}

.hero-tile--accent {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--accent-ink);
    box-shadow: 0 2px 0 var(--accent-hover);
}

.hero-tile--accent sub {
    color: var(--accent-ink);
    opacity: 0.85;
}

.workbench {
    box-shadow: var(--shadow-md);
    border-color: var(--line);
}

.workbench-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.65rem 1rem;
    margin-block-end: 1rem;
}

.workbench-head .panel-title {
    margin: 0;
}

/* Without JS, hide the tab bar and show the stacked Pattern & Anagram forms. */
.workbench-tabs {
    display: none;
}

html.js .workbench-tabs {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 0.2rem;
    padding: 0.2rem;
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    border: 1px solid var(--line);
}

.tab-button {
    appearance: none;
    border: 0;
    background: transparent;
    color: var(--ink-2);
    font: inherit;
    font-size: 0.84rem;
    font-weight: 600;
    padding: 0.38rem 0.72rem;
    min-height: 2rem;
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 0.14s ease, color 0.14s ease, box-shadow 0.14s ease;
}

.tab-button:hover {
    color: var(--ink);
}

.tab-button.is-active {
    background: var(--surface);
    color: var(--accent);
    font-weight: 700;
    box-shadow: var(--shadow-xs);
}

html:not(.js) .workbench-panel + .workbench-panel {
    margin-block-start: 1.1rem;
    padding-block-start: 1.1rem;
    border-block-start: 1px solid var(--line);
}

html:not(.js) .workbench-panel--wf {
    display: none;
}

.workbench-panel[hidden] {
    display: none;
}

.workbench-foot {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem 0.65rem;
    margin-block-start: 0.75rem;
}

.quickrow + .quickrow {
    margin-block-start: 1.1rem;
    padding-block-start: 1.1rem;
    border-block-start: 1px solid var(--line);
}

.quicklabel {
    display: block;
    font-size: 0.76rem;
    font-weight: 750;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--ink-3);
    margin-block-end: 0.4rem;
}

.quickfield {
    display: flex;
    gap: 0.5rem;
    align-items: stretch;
}

.quickfield .input {
    flex: 1 1 auto;
    min-width: 0;
}

.quickfield .btn {
    flex: 0 0 auto;
    padding-inline: 1.25rem;
}

.quickrow .hint {
    margin-block-start: 0.45rem;
}

.toollist {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 0.85rem;
    margin-block: 0.25rem 2.25rem;
}

.toolcard {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    padding: 1.25rem;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    color: var(--ink);
    text-decoration: none;
    box-shadow: var(--shadow-xs);
    transition: border-color 0.14s ease, background-color 0.14s ease,
        transform 0.14s ease, box-shadow 0.14s ease;
}

.toolcard:hover {
    border-color: var(--accent);
    background: var(--surface);
    color: var(--ink);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.toolcard--featured {
    border-color: var(--line-strong);
    background: var(--surface);
}

.toolcard-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.toolcard-kicker {
    font-family: var(--font-word);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    color: var(--ink-3);
}

.mini-board {
    display: inline-grid;
    grid-template-columns: repeat(4, 1.35rem);
    gap: 2px;
}

.mb {
    display: grid;
    place-items: center;
    height: 1.25rem;
    border-radius: 3px;
    font-family: var(--font-word);
    font-size: 0.56rem;
    font-weight: 800;
    color: #ffffff;
    letter-spacing: 0.02em;
}

.mb--tw { background: var(--wf-tw); }
.mb--dl { background: var(--wf-dl); }
.mb--dw { background: var(--wf-dw); }
.mb--tl { background: var(--wf-tl); }

.toolcard h2 {
    font-size: 1.12rem;
    margin: 0;
}

.toolcard p {
    margin: 0;
    color: var(--ink-2);
    font-size: 0.92rem;
}

.toolcard-cta {
    margin-block-start: auto;
    padding-block-start: 0.75rem;
    font-size: 0.86rem;
    font-weight: 700;
    color: var(--accent);
}

.browse {
    border-block-start: 1px solid var(--line);
    padding-block-start: 1.4rem;
}

.browse h2 {
    font-size: 0.76rem;
    font-weight: 750;
    text-transform: uppercase;
    letter-spacing: 0.09em;
    color: var(--ink-3);
    margin-block-end: 0.85rem;
}

.browsegrid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 0.6rem;
}

.browsecard {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.85rem 1rem;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--ink);
    text-decoration: none;
    font-size: 0.93rem;
    font-weight: 600;
    box-shadow: var(--shadow-xs);
    transition: border-color 0.14s ease, background-color 0.14s ease, transform 0.12s ease;
}

.browsecard:hover {
    border-color: var(--accent);
    background: var(--accent-soft);
    color: var(--ink);
    transform: translateY(-1px);
}

.browsecard-meta {
    color: var(--ink-3);
    font-size: 0.8rem;
    font-weight: 500;
    white-space: nowrap;
}

/* ---------- results ---------- */

.query {
    font-family: var(--font-word);
    letter-spacing: 0.08em;
    overflow-wrap: anywhere;
}

.refineform {
    padding: 0.9rem 1.05rem;
    margin-block-end: 1.25rem;
}

.refine-more {
    margin-block-start: 0.7rem;
    padding-block-start: 0.65rem;
    border-block-start: 1px solid var(--line);
}

.refine-more > summary {
    font-size: 0.82rem;
    color: var(--ink-2);
}

.refine-more[open] > summary {
    margin-block-end: 0.7rem;
}

.resultbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem 1rem;
    padding-block-end: 0.75rem;
    border-block-end: 1px solid var(--line);
    margin-block-end: 0.6rem;
}

.resultbar .note {
    margin: 0;
    max-width: 70ch;
}

.jumpbar {
    margin-block: 0.75rem 0.5rem;
}

.pill-count {
    font-size: 0.74rem;
    color: var(--ink-3);
    margin-inline-start: 0.28rem;
}

.pill.is-active .pill-count {
    color: var(--accent-ink);
    opacity: 0.85;
}

.wordgroup {
    margin-block-start: 0.85rem;
}

/* Defer rendering only for strictly below-the-fold word groups on long lists;
 * paired with contain-intrinsic-size so scrollbars never jump. */
.wordgroup:nth-of-type(n + 5) {
    content-visibility: auto;
    contain-intrinsic-size: auto none auto 260px;
}

.grouphead {
    position: sticky;
    /* The top bar grows when the tabs wrap (issue #144); v2.js publishes its
     * measured height, and the fixed token stays the no-JS fallback. */
    top: calc(var(--topbar-real-h, var(--topbar-h)) - 1px);
    z-index: 5;
    margin: 0 0 0.35rem;
    padding: 0.5rem 0;
    background: var(--bg);
    border-block-end: 1px solid var(--line);
    font-size: 0.78rem;
    font-weight: 750;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--ink-3);
}

.grouphead-count {
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.grouphead a {
    /* WCAG 2.2 SC 2.5.8: 24px minimum target (issue #148). */
    display: inline-flex;
    align-items: center;
    min-height: 1.5rem;
    color: inherit;
    text-decoration: none;
}

.grouphead a:hover {
    color: var(--accent);
}

.subhead {
    margin: 0.95rem 0 0.45rem;
    font-size: 0.76rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--ink-3);
}

.words {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
    list-style: none;
    padding: 0;
    margin: 0 0 1.1rem;
}

.word {
    display: inline-flex;
    align-items: baseline;
    gap: 0.45rem;
    padding: 0.36rem 0.65rem;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--ink);
    text-decoration: none;
    font-family: var(--font-word);
    font-size: 0.96rem;
    font-weight: 550;
    line-height: 1.25;
    box-shadow: 0 1px 0 var(--line);
    transition: background-color 0.12s ease, border-color 0.12s ease,
        transform 0.1s ease, box-shadow 0.12s ease;
}

.word:hover {
    background: var(--accent-soft);
    border-color: var(--accent);
    color: var(--ink);
    transform: translateY(-1px);
    box-shadow: 0 2px 0 var(--accent);
}

.word-text {
    overflow-wrap: anywhere;
}

.word-pts {
    font-size: 0.72rem;
    font-weight: 750;
    color: var(--points);
    background: var(--points-soft);
    padding: 0.06rem 0.34rem;
    border-radius: 4px;
    font-variant-numeric: tabular-nums;
}

/* ---------- word detail ---------- */

.wordhead {
    text-align: center;
    padding-block: 1.35rem 1.6rem;
}

.wordhero {
    margin-block-end: 1.35rem;
    background: var(--surface);
    box-shadow: var(--shadow-sm);
}

.wordbig {
    font-family: var(--font-word);
    font-size: clamp(2.2rem, 6.8vw, 3.5rem);
    letter-spacing: 0.04em;
    overflow-wrap: anywhere;
    margin-block: 0.25rem 0.65rem;
}

.wordmeta {
    display: flex;
    justify-content: center;
    gap: 0.55rem;
    flex-wrap: wrap;
    align-items: center;
    color: var(--ink-2);
}

.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.65rem;
    border-radius: var(--radius-pill);
    background: var(--surface-2);
    border: 1px solid var(--line);
    font-size: 0.8rem;
    font-weight: 650;
    color: var(--ink-2);
    font-variant-numeric: tabular-nums;
}

.badge--points {
    background: var(--points-soft);
    border-color: transparent;
    color: var(--points);
}

/* Tactile Scrabble/Wordfeud-inspired letter tiles */
.tiles {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.38rem;
    list-style: none;
    padding: 0;
    margin: 1.15rem 0 0;
}

.tile {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2.65rem;
    min-height: 2.75rem;
    padding: 0.3rem 0.5rem 0.45rem;
    border: 1px solid var(--tile-edge);
    border-radius: 8px;
    background: var(--tile-bg);
    box-shadow: 0 3px 0 var(--tile-edge), var(--shadow-xs);
}

.tile-letter {
    font-family: var(--font-word);
    font-weight: 800;
    font-size: 1.18rem;
    line-height: 1;
    color: var(--ink);
}

.tile-points {
    position: absolute;
    inset-block-end: 0.2rem;
    inset-inline-end: 0.3rem;
    font-size: 0.65rem;
    font-weight: 750;
    line-height: 1;
    color: var(--points);
    font-variant-numeric: tabular-nums;
}

.phonetic {
    margin-block-start: 0.85rem;
    margin-block-end: 0;
    font-family: var(--font-word);
    font-size: 0.95rem;
    color: var(--ink-3);
}

.wordaudio {
    margin-block-start: 0.7rem;
    max-width: 100%;
}

.word-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 1.15rem;
    align-items: start;
}

@media (min-width: 880px) {
    .word-layout {
        grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr);
        gap: 1.4rem;
    }
}

.word-main,
.word-rail {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    min-width: 0;
}

.word-main .panel + .panel,
.word-rail .panel + .panel {
    margin-block-start: 0;
}

.word-action-stack {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.word-browse-links {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.2rem;
    margin-block-start: 0.95rem;
    padding-block-start: 0.85rem;
    border-block-start: 1px solid var(--line);
}

.prose {
    max-width: 100%;
}

.prose h2,
.wordsection h2 {
    font-size: 0.78rem;
    font-weight: 750;
    text-transform: uppercase;
    letter-spacing: 0.09em;
    color: var(--ink-3);
    margin-block: 0 0.85rem;
}

.meaning + .meaning {
    margin-block-start: 1.25rem;
    padding-block-start: 1.1rem;
    border-block-start: 1px solid var(--line);
}

.pos {
    display: inline-block;
    font-style: normal;
    font-size: 0.76rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--accent);
    background: var(--accent-soft);
    padding: 0.14rem 0.52rem;
    border-radius: var(--radius-pill);
    margin-block-end: 0.55rem;
}

.deflist {
    margin: 0;
    padding-inline-start: 1.35rem;
}

.deflist > li {
    margin-block-end: 0.7rem;
}

.deflist > li:last-child {
    margin-block-end: 0;
}

.example {
    margin: 0.35rem 0 0;
    padding-inline-start: 0.75rem;
    border-inline-start: 2px solid var(--line-strong);
    color: var(--ink-2);
    font-style: italic;
}

.complement {
    color: var(--ink-3);
}

.source {
    margin-block: 1.25rem 0;
    padding-block-start: 0.85rem;
    border-block-start: 1px solid var(--line);
    color: var(--ink-3);
}

/* ---------- word lists ---------- */

.filterbar {
    padding: 0.9rem 1.05rem;
    margin-block-end: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}

.filterbar--inline {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
}

.filterbar .segmented,
.filterbar .pills,
.filterbar .alphabet,
.filterbar .linkrow {
    margin-block: 0;
}

.lengthgrid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 0.65rem;
}

.lengthcard {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    padding: 0.95rem 1rem;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--ink);
    text-decoration: none;
    box-shadow: var(--shadow-xs);
    transition: border-color 0.14s ease, background-color 0.14s ease,
        transform 0.12s ease, box-shadow 0.14s ease;
}

.lengthcard:hover {
    border-color: var(--accent);
    background: var(--accent-soft);
    color: var(--ink);
    transform: translateY(-2px);
    box-shadow: var(--shadow-sm);
}

.lengthcard-num {
    font-family: var(--font-word);
    font-size: 1.75rem;
    font-weight: 800;
    line-height: 1;
    letter-spacing: -0.02em;
    color: var(--accent);
    font-variant-numeric: tabular-nums;
}

.lengthcard-label {
    font-size: 0.78rem;
    color: var(--ink-3);
}

.lengthcard-count {
    font-size: 0.84rem;
    color: var(--ink-2);
    font-variant-numeric: tabular-nums;
}

.alphabet {
    display: flex;
    flex-wrap: wrap;
    gap: 0.28rem;
    margin-block: 1rem 1.25rem;
}

.alphabet a {
    min-width: 2.05rem;
    min-height: 2.05rem;
    display: inline-grid;
    place-items: center;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--tile-bg);
    color: var(--ink);
    text-decoration: none;
    font-family: var(--font-word);
    font-size: 0.9rem;
    font-weight: 700;
    transition: border-color 0.12s ease, background-color 0.12s ease, color 0.12s ease;
}

.alphabet a:hover {
    border-color: var(--accent);
    background: var(--accent-soft);
    color: var(--accent);
}

.pills {
    display: flex;
    flex-wrap: wrap;
    gap: 0.32rem;
    margin-block: 0.75rem 1rem;
}

.pill {
    min-width: 2.15rem;
    min-height: 2.15rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding-inline: 0.62rem;
    border: 1px solid var(--line);
    border-radius: var(--radius-pill);
    background: var(--surface);
    color: var(--ink-2);
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    transition: border-color 0.12s ease, background-color 0.12s ease, color 0.12s ease;
}

.pill:hover {
    border-color: var(--accent);
    background: var(--accent-soft);
    color: var(--accent);
}

.pill.is-active {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--accent-ink);
    font-weight: 750;
}

.segmented {
    display: inline-flex;
    flex-wrap: wrap;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    overflow: hidden;
    margin-block: 0.5rem 0.75rem;
    width: fit-content;
    max-width: 100%;
}

.seg {
    padding: 0.45rem 0.95rem;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--ink-2);
    text-decoration: none;
    background: var(--surface);
    transition: background-color 0.12s ease, color 0.12s ease;
}

.seg + .seg {
    border-inline-start: 1px solid var(--line-strong);
}

.seg:hover {
    color: var(--ink);
    background: var(--surface-2);
}

.seg.is-active {
    background: var(--accent);
    color: var(--accent-ink);
    font-weight: 700;
}

.stats-line {
    color: var(--ink-2);
    font-size: 0.9rem;
    font-variant-numeric: tabular-nums;
}

.lettergrid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(92px, 1fr));
    gap: 0.55rem;
    margin-block-start: 1rem;
}

.lettercard {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.2rem;
    padding: 0.9rem 0.55rem;
    border: 1px solid var(--tile-edge);
    border-radius: var(--radius);
    background: var(--tile-bg);
    color: var(--ink);
    text-decoration: none;
    box-shadow: 0 2px 0 var(--tile-edge);
    transition: border-color 0.12s ease, background-color 0.12s ease,
        transform 0.12s ease, box-shadow 0.12s ease;
}

.lettercard:hover {
    border-color: var(--accent);
    background: var(--accent-soft);
    color: var(--ink);
    transform: translateY(-2px);
    box-shadow: 0 3px 0 var(--accent);
}

.lettercard-letter {
    font-family: var(--font-word);
    font-size: 1.55rem;
    font-weight: 800;
    line-height: 1;
}

.lettercard-count {
    font-size: 0.76rem;
    color: var(--ink-3);
    font-variant-numeric: tabular-nums;
}

.faq {
    margin-block-start: 2.25rem;
}

.faq .panel + .panel {
    margin-block-start: 0.55rem;
}

/* ---------- stats ---------- */

.kpigroups {
    display: flex;
    flex-direction: column;
    gap: 1.35rem;
}

.kpigroup > .eyebrow {
    margin-block-end: 0.55rem;
}

.kpigrid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(175px, 1fr));
    gap: 0.65rem;
}

.kpi {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    padding: 0.9rem 1rem;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow-xs);
}

.kpi--featured {
    border-inline-start: 3px solid var(--accent);
}

.kpi-label {
    font-size: 0.76rem;
    font-weight: 600;
    color: var(--ink-3);
}

.kpi-value {
    font-size: 1.25rem;
    font-weight: 750;
    letter-spacing: -0.02em;
    font-variant-numeric: tabular-nums;
    overflow-wrap: anywhere;
}

.statsblock {
    margin-block-start: 2.2rem;
}

.statsblock > h2,
.panel > summary {
    font-size: 0.98rem;
}

.tablewrap {
    overflow-x: auto;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    margin-block-start: 0.65rem;
    box-shadow: var(--shadow-xs);
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
    font-variant-numeric: tabular-nums;
}

th,
td {
    text-align: start;
    padding: 0.58rem 0.8rem;
    border-block-end: 1px solid var(--line);
}

thead th {
    font-size: 0.72rem;
    font-weight: 750;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--ink-3);
    background: var(--surface-2);
    white-space: nowrap;
}

tbody tr:hover {
    background: var(--surface-2);
}

.statsblock tbody tr:nth-child(-n + 3) td.rank {
    font-weight: 800;
    color: var(--accent);
}

/* Issue #177 stacked each Statistics row into a labelled card so the reader did
 * not have to drag a table sideways on a phone. Issue #300 changed the shape of
 * that card: one full-width card per row whose title is the identifying cell
 * and whose numbers each carry their column name from data-label. */
@media (max-width: 560px) {
    .statsblock .tablewrap {
        overflow: visible;
        border: 0;
        background: none;
        box-shadow: none;
    }

    .statsblock table,
    .statsblock tbody {
        display: block;
        width: auto;
    }

    .statsblock thead {
        position: absolute;
        width: 1px;
        height: 1px;
        margin: -1px;
        padding: 0;
        overflow: hidden;
        clip: rect(0, 0, 0, 0);
        clip-path: inset(50%);
        white-space: nowrap;
        border: 0;
    }

    .statsblock tr {
        display: flex;
        flex-wrap: wrap;
        align-items: baseline;
        column-gap: 0.55rem;
        row-gap: 0.25rem;
        border: 1px solid var(--line);
        border-radius: var(--radius);
        background: var(--surface);
        padding: 0.55rem 0.7rem;
        margin-block-end: 0.45rem;
        box-shadow: var(--shadow-xs);
    }

    .statsblock td {
        border: 0;
        padding: 0;
    }

    .statsblock td.rank {
        flex: 0 0 auto;
        font-size: 0.72rem;
        color: var(--ink-3);
    }

    .statsblock td.name {
        flex: 1 1 auto;
        min-width: 55%;
        font-size: 0.95rem;
        font-weight: 650;
        overflow-wrap: anywhere;
    }

    .statsblock td.name .langcell {
        gap: 0.3rem;
    }

    .statsblock td.num,
    .statsblock td.sub {
        flex: 0 0 auto;
        min-width: 0;
        font-size: 0.74rem;
        color: var(--ink-2);
        overflow-wrap: anywhere;
    }

    .statsblock td.num::before,
    .statsblock td.sub::before {
        content: attr(data-label);
        color: var(--ink-3);
        margin-inline-end: 0.25rem;
    }

    .statsblock tr.hitrow td.num {
        font-size: 0.68rem;
        overflow-wrap: anywhere;
    }

    .statsblock tr.hitrow td.name {
        flex: 1 1 100%;
    }

    .statsblock tr.hitrow td.name .langcell {
        gap: 0.25rem;
    }
}

.statsblock td.movecell .move {
    font-size: 0.92em;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.statsblock td.movecell .move-up {
    color: var(--accent);
}

.statsblock td.movecell .move-down {
    color: var(--danger);
}

.statsblock td.movecell .move-flat,
.statsblock td.movecell .move-new {
    color: var(--ink-3);
}

tbody tr:last-child td {
    border-block-end: 0;
}

th.num,
td.num {
    text-align: end;
}

.langcell {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
}

.flag {
    display: inline-block;
    width: 1.15em;
    height: 0.85em;
    object-fit: cover;
    border-radius: 2px;
    vertical-align: baseline;
}

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

.foot {
    border-block-start: 1px solid var(--line);
    background: var(--surface);
    margin-block-start: auto;
}

.foot-inner {
    max-width: var(--shell);
    margin-inline: auto;
    padding: 1.5rem clamp(0.75rem, 3vw, 1.5rem) 2.25rem;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 1rem 1.75rem;
    align-items: start;
    font-size: 0.86rem;
    color: var(--ink-3);
}

@media (min-width: 760px) {
    .foot-inner {
        grid-template-columns: auto minmax(0, 1fr) auto;
        align-items: center;
    }
}

.foot-brand {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.brand--foot .brand-mark {
    width: 1.65rem;
    height: 1.65rem;
    border-radius: 6px;
}

.brand--foot .brand-glyph {
    font-size: 1rem;
}

.foot-count {
    margin: 0;
    font-size: 0.8rem;
    color: var(--ink-3);
}

.foot-tools {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem 1.05rem;
}

.foot-tools a {
    /* WCAG 2.2 SC 2.5.8: 24px minimum target (issue #148). */
    display: inline-flex;
    align-items: center;
    min-height: 1.75rem;
    color: var(--ink-2);
    font-weight: 500;
    text-decoration: none;
}

.foot-tools a:hover {
    color: var(--accent);
    text-decoration: underline;
}

.foot-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem 1rem;
}

.foot-meta a {
    display: inline-flex;
    align-items: center;
    min-height: 1.75rem;
    color: var(--ink-2);
}

.foot-support {
    padding: 0.3rem 0.75rem;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-pill);
    background: var(--surface-2);
    font-weight: 600;
    text-decoration: none;
    transition: border-color 0.14s ease, background-color 0.14s ease, color 0.14s ease;
}

.foot-support:hover {
    border-color: var(--accent);
    background: var(--accent-soft);
    color: var(--accent);
}

.foot-preview {
    margin: 0.25rem 0 0;
    font-size: 0.78rem;
    color: var(--ink-3);
}

.foot-preview a {
    display: inline-flex;
    align-items: center;
    min-height: 1.5rem;
}

/* ---------- wordfeud solver ---------- */

:root {
    --wf-dl: #3f7a38;
    --wf-tl: #345c8a;
    --wf-dw: #a85614;
    --wf-tw: #962f35;
    --wf-empty: #242a27;
    --wf-frame: #171c19;
    --wf-tile: #f8f3e4;
    --wf-tile-ink: #161a18;
    --wf-suggested: #f4c62a;
    --wf-suggested-ink: #191507;
    --wf-letter: #161a18;
}

:root[data-theme="dark"] {
    --wf-empty: #222825;
    --wf-frame: #0c0f0e;
    --wf-tile: #ece6d5;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --wf-empty: #222825;
        --wf-frame: #0c0f0e;
        --wf-tile: #ece6d5;
    }
}

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

.uploadcard {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.45rem;
    padding: 2.75rem 1.5rem;
    border: 2px dashed var(--line-strong);
    border-radius: var(--radius);
    background: var(--surface);
    cursor: pointer;
    text-align: center;
    box-shadow: var(--shadow-sm);
    transition: border-color 0.14s ease, background-color 0.14s ease, transform 0.12s ease;
}

.uploadcard--compact {
    padding: 1.5rem 1rem;
    box-shadow: none;
}

.uploadcard:hover,
.uploadcard.is-dragover {
    border-color: var(--accent);
    background: var(--accent-soft);
}

.wordfeud-file-input:focus-visible + .uploadcard {
    outline: 3px solid var(--accent);
    outline-offset: 2px;
}

.uploadcard-icon {
    display: inline-grid;
    place-items: center;
    width: 2.85rem;
    height: 2.85rem;
    border-radius: var(--radius-pill);
    background: var(--accent-soft);
    color: var(--accent);
    font-size: 1.45rem;
    font-weight: 700;
    line-height: 1;
}

.uploadcard-title {
    font-weight: 700;
    font-size: 1.05rem;
    color: var(--ink);
}

.uploadcard-hint {
    font-size: 0.84rem;
    color: var(--ink-3);
    max-width: 44ch;
}

.boardwrap {
    width: 100%;
    overflow-x: auto;
    padding-block-end: 0.25rem;
}

.board-frame {
    display: inline-block;
    width: min(100%, 576px);
    padding: 8px;
    border-radius: var(--radius);
    background: var(--wf-frame);
    box-shadow: var(--shadow-md);
}

.wordfeud-board-grid {
    display: grid;
    grid-template-columns: repeat(15, minmax(0, 1fr));
    grid-template-rows: repeat(15, minmax(0, 1fr));
    gap: 2px;
    width: 100%;
    aspect-ratio: 1 / 1;
}

.wordfeud-slot {
    position: relative;
    aspect-ratio: 1 / 1;
    min-width: 0;
    min-height: 0;
    border-radius: 3px;
    background: var(--wf-empty);
    overflow: hidden;
}

.wordfeud-slot.bonus-dl { background: var(--wf-dl); }
.wordfeud-slot.bonus-tl { background: var(--wf-tl); }
.wordfeud-slot.bonus-dw { background: var(--wf-dw); }
.wordfeud-slot.bonus-tw { background: var(--wf-tw); }

.wordfeud-slot.has-letter {
    background: var(--wf-tile);
    box-shadow: inset 0 -2px 0 rgb(0 0 0 / 0.16);
}

.wordfeud-bonus {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    font-size: clamp(0.42rem, 0.95vw, 0.6rem);
    font-weight: 750;
    letter-spacing: 0.02em;
    color: #ffffff;
    text-transform: uppercase;
    user-select: none;
    pointer-events: none;
}

.wordfeud-bonus:empty {
    display: none;
}

.wordfeud-board-grid input.wordfeud-cell {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    min-width: 0;
    min-height: 0;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 3px;
    background: transparent;
    color: var(--wf-letter);
    text-align: center;
    text-transform: uppercase;
    font-family: var(--font-word);
    /* 16px is the floor iOS Safari uses to decide whether to zoom the page on
     * focus. A smaller cell font made every tap re-zoom (issue #146). */
    font-size: 16px;
    font-weight: 700;
    line-height: 1;
    caret-color: var(--accent);
}

.wordfeud-board-grid input.wordfeud-cell:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: -2px;
    border-radius: 3px;
}

.wordfeud-slot.has-letter input.wordfeud-cell {
    color: var(--wf-tile-ink);
}

.wordfeud-slot.is-unknown {
    box-shadow: inset 0 0 0 2px #e0483c;
}

.wordfeud-slot.is-unknown input.wordfeud-cell {
    color: #c03028;
}

.wordfeud-cell-preview {
    position: absolute;
    inset: 0;
    z-index: 3;
    display: grid;
    place-items: center;
    font-family: var(--font-word);
    font-size: clamp(0.6rem, 1.55vw, 0.95rem);
    font-weight: 800;
    text-transform: uppercase;
    color: #ffffff;
    pointer-events: none;
    border-radius: 3px;
}

.wordfeud-cell-preview.is-new {
    background: var(--wf-suggested);
    color: var(--wf-suggested-ink);
    box-shadow: inset 0 -2px 0 rgb(138 96 0 / 0.35), inset 0 1px 0 rgb(255 248 205 / 0.55);
}

.wordfeud-slot.has-letter .wordfeud-cell-preview {
    color: var(--wf-tile-ink);
}

.rackrow {
    margin-block: 1rem 0.25rem;
}

.rack-tray {
    width: min(100%, 576px);
    padding: 0.75rem 0.9rem 0.85rem;
    border-radius: var(--radius);
    background: var(--surface);
    border: 1px solid var(--line);
    box-shadow: var(--shadow-xs);
}

.wordfeud-rack {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 6px;
    width: min(100%, 340px);
}

/* An empty rack slot is tray, not tile (#166): a short rack at the end of a
 * game, once the bag is empty, otherwise reads as a row of blank joker tiles. */
.wordfeud-rack .wordfeud-slot {
    background: var(--wf-empty);
    border-radius: 6px;
}

.wordfeud-rack .wordfeud-slot.has-letter {
    background: var(--wf-tile);
    box-shadow: 0 2px 0 rgb(0 0 0 / 0.2);
}

.wordfeud-rack input.wordfeud-cell {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    min-width: 0;
    min-height: 0;
    margin: 0;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--wf-letter);
    text-align: center;
    text-transform: uppercase;
    font-family: var(--font-word);
    font-size: clamp(1rem, 3.2vw, 1.25rem);
    font-weight: 800;
    line-height: 1;
}

.wordfeud-rack input.wordfeud-cell:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: -2px;
    border-radius: 6px;
}

.wordfeud-actions-row {
    flex-wrap: nowrap;
    width: min(100%, 576px);
}

.wordfeud-actions-row .btn {
    flex: 0 0 auto;
}

.wordfeud-solve-btn {
    flex: 1 1 auto;
}

.wordfeud-nav-btn.is-disabled {
    opacity: 0.4;
    pointer-events: none;
}

.wf-grid {
    display: grid;
    gap: 1.35rem;
    align-items: start;
}

.wf-side {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    min-width: 0;
}

@media (min-width: 980px) {
    .wf-grid {
        grid-template-columns: minmax(0, 576px) minmax(0, 1fr);
        gap: 1.75rem;
    }
}

.wordfeud-solution {
    margin: 0;
}

.solution-head {
    padding-block-end: 0.85rem;
    margin-block-end: 0.9rem;
    border-block-end: 1px solid var(--line);
}

.solutionword {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    flex-wrap: wrap;
    font-family: var(--font-word);
    font-size: 1.45rem;
    margin: 0 0 0.55rem;
}

.solutionword a {
    color: var(--ink);
    text-decoration: none;
}

.solutionword a:hover {
    color: var(--accent);
    text-decoration: underline;
}

.wordfeud-results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(148px, 1fr));
    gap: 0.45rem;
    max-height: 24rem;
    overflow-y: auto;
    padding-inline-end: 2px;
}

.wordfeud-result-item {
    position: relative;
    display: flex;
    min-width: 0;
}

.wordfeud-result-item > .wordfeud-result-tile {
    flex: 1 1 auto;
    min-width: 0;
}

/* Only the signed-in owner gets this control (the page asks the console's
   session probe before adding it), so the public list keeps its old size. */
.wordfeud-result-item.has-admin-remove > .wordfeud-result-tile {
    padding-inline-end: 2rem;
}

.wordfeud-result-remove {
    position: absolute;
    top: 0.3rem;
    inset-inline-end: 0.3rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.35rem;
    height: 1.35rem;
    padding: 0;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--surface);
    color: var(--muted);
    font-size: 0.95rem;
    line-height: 1;
    cursor: pointer;
}

.wordfeud-result-remove:hover {
    border-color: var(--danger);
    color: var(--danger);
}

.wordfeud-result-remove:disabled {
    opacity: 0.5;
    cursor: progress;
}

.wordfeud-result-tile {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.55rem;
    padding: 0.52rem 0.7rem;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--ink);
    text-decoration: none;
    transition: border-color 0.12s ease, background-color 0.12s ease;
}

.wordfeud-result-tile:hover {
    border-color: var(--accent);
    background: var(--accent-soft);
    color: var(--ink);
}

.wordfeud-result-tile.is-selected {
    border-color: var(--accent);
    background: var(--accent-soft);
    box-shadow: inset 0 0 0 1px var(--accent);
}

.wordfeud-result-word {
    font-family: var(--font-word);
    font-size: 0.94rem;
    font-weight: 600;
}

.wordfeud-result-points {
    font-size: 0.76rem;
    font-weight: 750;
    color: var(--points);
    background: var(--points-soft);
    padding: 0.08rem 0.35rem;
    border-radius: 4px;
    font-variant-numeric: tabular-nums;
}

.processing {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.85rem;
    padding-block: 5rem;
    text-align: center;
}

.spinner {
    width: 2.35rem;
    height: 2.35rem;
    border: 3px solid var(--line);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: v2-spin 0.8s linear infinite;
}

@keyframes v2-spin {
    to {
        transform: rotate(360deg);
    }
}

/* Strategy pick: the one-line note and the "why" dialog. */
.strategy-note {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    margin: 0.25rem 0 0;
    padding: 0.55rem 0.7rem;
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    font-size: 0.86rem;
    line-height: 1.4;
    color: var(--ink-2);
}

.why-btn {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.9rem;
    height: 1.9rem;
    padding: 0;
    border: 2px solid var(--accent);
    border-radius: var(--radius-pill);
    background: var(--accent);
    color: var(--accent-ink);
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 750;
    line-height: 1;
    cursor: pointer;
    box-shadow: var(--shadow-xs);
    transition: background-color 0.14s ease, border-color 0.14s ease, transform 0.14s ease;
}

.why-btn:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
    color: var(--accent-ink);
    transform: translateY(-1px);
}

.why-btn:focus-visible {
    outline: 3px solid var(--accent);
    outline-offset: -3px;
}

.why-dialog {
    width: calc(100% - 2rem);
    max-width: 35rem;
    padding: 1.35rem;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--ink);
    box-shadow: var(--shadow-md);
}

.why-dialog:modal {
    overscroll-behavior: contain;
}

.why-dialog::backdrop {
    background: rgb(0 0 0 / 0.55);
    backdrop-filter: blur(2px);
    overflow: hidden;
    overscroll-behavior: contain;
}

.why-phase {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--ink-2);
}

.why-dialog h2 {
    margin: 0 0 0.65rem;
    font-size: 1.15rem;
}

.why-dialog p {
    margin: 0.45rem 0;
}

.why-dialog ul {
    margin: 0.3rem 0 0.65rem;
    padding-inline-start: 1.25rem;
}

.why-dialog form {
    margin: 0;
}

.why-dialog .btn {
    margin-top: 0.75rem;
}

.wf-strategy-guide {
    margin-top: 1.25rem;
    max-width: 72ch;
}

.wf-strategy-guide summary {
    cursor: pointer;
    font-weight: 700;
    color: var(--ink);
}

.wf-strategy-guide-intro {
    margin: 0.65rem 0 0.5rem;
    color: var(--ink-2);
}

.wf-strategy-guide-list {
    margin: 0;
    padding-inline-start: 1.2rem;
    display: grid;
    gap: 0.45rem;
    color: var(--ink-2);
    font-size: 0.94rem;
    line-height: 1.5;
}

/* ---------- reference pages (API docs, Wordfeud rules) ---------- */

.shell > article:not([class]),
.shell > article.rules-page {
    max-width: 82ch;
}

@media (min-width: 1060px) {
    .shell > article:not([class]),
    .shell > article.rules-page {
        max-width: 100%;
        display: grid;
        grid-template-columns: minmax(0, 72ch) minmax(13rem, 17rem);
        column-gap: 2.5rem;
        align-items: start;
    }

    .shell > article:not([class]) > *:not(.toc),
    .shell > article.rules-page > *:not(.toc) {
        grid-column: 1;
    }

    .shell > article:not([class]) > .toc,
    .shell > article.rules-page > .toc {
        grid-column: 2;
        grid-row: 1 / span 40;
        position: sticky;
        top: calc(var(--topbar-real-h, var(--topbar-h)) + 1rem);
        max-height: calc(100dvh - var(--topbar-real-h, var(--topbar-h)) - 2rem);
        overflow-y: auto;
        margin-block: 0;
    }

    .shell > article:not([class]) > .toc ul,
    .shell > article.rules-page > .toc ul {
        flex-direction: column;
        gap: 0.3rem;
    }
}

.shell > article:not([class]) section,
.shell > article.rules-page section {
    margin-block-start: 1.85rem;
}

.shell > article:not([class]) section > h2,
.shell > article.rules-page section > h2 {
    padding-block-end: 0.4rem;
    border-block-end: 1px solid var(--line);
}

.shell > article:not([class]) h3,
.shell > article.rules-page h3 {
    margin-block-start: 1.4rem;
}

.rules-page .subtitle {
    color: var(--ink-3);
}

.toc {
    margin-block: 1.25rem 1.5rem;
    padding: 0.95rem 1.1rem;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow-xs);
}

.toc h2 {
    font-size: 0.76rem;
    font-weight: 750;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--ink-3);
    margin-block-end: 0.65rem;
}

.toc ul {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem 1rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

.toc li {
    margin: 0;
    font-size: 0.88rem;
}

.toc a {
    text-decoration: none;
    color: var(--ink-2);
}

.toc a:hover {
    color: var(--accent);
    text-decoration: underline;
}

.code-example,
.secondary-section {
    margin-block: 0.75rem;
    padding: 0.7rem 1rem;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow-xs);
}

.code-example[open] > summary,
.secondary-section[open] > summary {
    margin-block-end: 0.65rem;
}

pre {
    overflow-x: auto;
    margin: 0.5rem 0 0;
    padding: 0.9rem 1.05rem;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    font-size: 0.83rem;
    line-height: 1.55;
}

code {
    font-family: var(--font-word);
    font-size: 0.9em;
}

p code,
li code,
td code {
    padding: 0.1rem 0.34rem;
    border-radius: 4px;
    background: var(--surface-2);
    overflow-wrap: anywhere;
}

pre code {
    padding: 0;
    background: none;
    font-size: inherit;
}

/* ---------- responsive ---------- */

@media (max-width: 1130px) {
    .tabs {
        order: 3;
        flex-basis: 100%;
        border-block-start: 1px solid var(--line);
        margin-block-start: 0.15rem;
        padding-block-start: 0.25rem;
    }

    .grouphead {
        position: static;
    }

    html.js .grouphead {
        position: sticky;
    }
}

@media (max-width: 860px) {
    .hero {
        grid-template-columns: minmax(0, 1fr);
        padding-block-start: 0.5rem;
    }

    .hero .lede {
        max-width: none;
    }

    .topbar-inner {
        gap: 0.35rem 0.65rem;
    }
}

@media (max-width: 520px) {
    .quickfield {
        flex-direction: column;
    }

    .quickfield .btn {
        width: 100%;
    }

    .preview-chip {
        display: none;
    }

    .langform select {
        max-width: 8.5rem;
    }

    .tiles {
        gap: 0.28rem;
    }

    .tile {
        min-width: 2.3rem;
        min-height: 2.45rem;
    }
}

/* ---------- Forced Colors Mode (Windows High Contrast) ---------- */

@media (forced-colors: active) {
    .tabs a[aria-current="page"],
    .tab-button.is-active,
    .pill.is-active,
    .seg.is-active,
    .wordfeud-result-tile.is-selected {
        border: 2px solid Highlight;
    }

    .kpi--featured {
        border-inline-start: 3px solid Highlight;
    }

    .word:hover,
    .toolcard:hover,
    .browsecard:hover {
        outline: 2px solid Highlight;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}
