/* 90-foot Stone Decoder: the tool on /90-foot-stone-decoder.
   Scoped to .sd; uses the site variables with fallbacks.
   Layout (Oct 2026, third round): questions left and options right, both always visible; below
   them the Run button, then the results in a fixed place. Nothing is fixed to the screen.
   Motion: only opacity and transform, and none under prefers-reduced-motion. */
.sd {
    --sd-card: var(--bg-card, #111318);
    --sd-raised: var(--bg-elevated, #1a1d23);
    --sd-text: var(--text-primary, #e8e6e3);
    --sd-muted: var(--text-muted, #9a958f);
    --sd-accent: var(--accent, #c9a962);
    --sd-border: var(--border, rgba(255, 255, 255, 0.08));
    --sd-paper: #f1ece2;
    --sd-ink: #1d1a16;
    --sd-clear: #7cc47f;
    --sd-weak: #d9b45a;
    --sd-noise: #a39e97;
    display: grid;
    gap: 22px;
    color: var(--sd-text);
}
.sd [hidden] { display: none !important; }
.sd-visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.sd-muted { color: var(--sd-muted); }
.sd-note { color: var(--sd-muted); font-size: 0.85rem; line-height: 1.55; margin: 8px 0 0; }
.sd-plain { border: 0; margin: 0; padding: 0; min-width: 0; }
.sd h4 { font-size: 0.8rem; letter-spacing: 1px; text-transform: uppercase; color: var(--sd-muted); margin: 0 0 8px; font-weight: 600; }
.sd-kicker { display: block; margin: 0 0 12px; font-family: var(--font-display, 'Cinzel', serif); font-size: 0.78rem; letter-spacing: 2.5px; text-transform: uppercase; color: var(--sd-accent); font-weight: 600; }
.sd-kicker:focus { outline: none; }
.sd-lab { display: block; margin: 0 0 6px; padding: 0; color: var(--sd-muted); font-size: 0.8rem; }
.sd-lab--gold { color: var(--sd-accent); }

/* options: one box, three lines (Corjan's layout, Oct 2026) */
.sd-box { background: var(--sd-card); border: 1px solid var(--sd-border); border-radius: 12px; padding: 16px 20px; min-width: 0; }
.sd-opts { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; }
.sd-opts > * { min-width: 0; }
.sd-line { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; }
.sd-opts #sd-variant { max-width: 248px; }
.sd-opts #sd-method { max-width: 208px; }
.sd-check { display: inline-flex; align-items: center; gap: 8px; min-height: 36px; font-size: 0.86rem; color: var(--sd-text); cursor: pointer; white-space: nowrap; }
.sd-check input { width: 17px; height: 17px; margin: 0; accent-color: var(--sd-accent); }
.sd-check:has(input:disabled) { opacity: 0.5; cursor: not-allowed; }
.sd-inl { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0; min-width: 0; }
.sd-inl .sd-lab { margin: 0; white-space: nowrap; font-size: 0.82rem; }
.sd-opts .sd-chips { gap: 6px; }
.sd-opts .sd-chip span { min-height: 34px; padding: 4px 12px; font-size: 0.85rem; }
.sd-method-opts:empty { display: none; }
.sd-opts .sd-method-opts { margin: 0; }
.sd-method-desc { margin: 0 0 10px; }
.sd-line--run { justify-content: space-between; border-top: 1px solid var(--sd-border); padding-top: 14px; }
.sd-seg { display: inline-flex; border: 1px solid rgba(255, 255, 255, 0.14); border-radius: 6px; overflow: hidden; }
.sd-seg__o { position: relative; display: inline-flex; }
.sd-seg__o input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.sd-seg__o span { display: inline-flex; align-items: center; min-height: 36px; padding: 0 14px; font-size: 0.85rem; color: var(--sd-muted); cursor: pointer; }
.sd-seg__o + .sd-seg__o span { border-left: 1px solid rgba(255, 255, 255, 0.1); }
.sd-seg__o input:checked + span { background: rgba(201, 169, 98, 0.18); color: #fff; }
.sd-seg__o input:focus-visible + span { outline: 2px solid var(--sd-accent); outline-offset: -2px; }
.sd-seg__o input:disabled + span { opacity: 0.45; cursor: not-allowed; }
.sd-opts select:disabled { opacity: 0.55; }
.sd-opts .sd-input--sm { max-width: 260px; padding-left: 10px !important; padding-right: 8px !important; text-overflow: ellipsis; }

/* run: the button and the progress bar share one slot of the same size */
.sd-runwrap { flex: 0 0 240px; }
.sd .sd-run, .sd-runbar { width: 100%; min-height: 44px; box-sizing: border-box; }
.sd .sd-run { background: var(--sd-accent); border: 1px solid var(--sd-accent); color: #000; font-weight: 700; cursor: pointer; padding-top: 0; padding-bottom: 0; }
.sd .sd-run:hover:not(:disabled) { background: var(--accent-hover, #d4b978); border-color: var(--accent-hover, #d4b978); color: #000; }
.sd .sd-run:disabled { opacity: 0.6; cursor: not-allowed; }
.sd-runbar { position: relative; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 14px; border: 1px solid var(--sd-accent); overflow: hidden; }
.sd-runbar__fill { position: absolute; left: 0; top: 0; bottom: 0; width: 100%; transform: scaleX(0); transform-origin: left center; background: rgba(201, 169, 98, 0.22); will-change: transform; }
.sd-runbar__t { position: relative; font-family: var(--font-display, 'Cinzel', serif); letter-spacing: 1.5px; text-transform: uppercase; font-size: 0.8rem; color: #fff; }
.sd.is-running .sd-line--run > .sd-inl { display: none; }
.sd.is-running .sd-runwrap { flex: 1 1 100%; }
.sd-runwrap { min-width: 0; }
.sd-runbar__t { white-space: nowrap; }
.sd-tape { position: relative; flex: 1 1 auto; display: flex; justify-content: center; align-items: center; gap: 2px; min-width: 0; overflow: hidden; }
.sd-tape__c { flex: none; width: 16px; height: 22px; display: inline-flex; align-items: center; justify-content: center; color: rgba(232, 230, 227, 0.35); }
.sd-tape__c.is-end { margin-right: 7px; }
.sd-tape__c .sd-glyph { width: 15px; height: 15px; stroke-width: 2.2; }
.sd-tape__c.is-read { color: #fff; }
.sd-runbar__stop { position: relative; min-height: 40px; padding: 0 4px; background: none; border: 0; color: var(--sd-accent); font: inherit; font-size: 0.88rem; text-decoration: underline; cursor: pointer; }
.sd-runbar__stop:focus-visible { outline: 2px solid var(--sd-accent); outline-offset: 2px; }
.sd-msg { margin: 0; color: var(--sd-muted); font-size: 0.88rem; }
.sd-opts .sd-stone { margin: -2px 0 2px; }
.sd-opts .sd-strip__glyphs { padding: 10px 14px; gap: 6px 18px; }
.sd-gl.is-skipped { opacity: 0.28; }
.sd-out > .sd-cite { margin: 0; font-size: 0.8rem; }

/* results */
.sd-results { min-width: 0; }
.sd-empty {
    min-height: 140px; display: flex; align-items: center; justify-content: center; padding: 20px; text-align: center;
    border: 1px dashed rgba(255, 255, 255, 0.15); border-radius: 10px; color: var(--sd-muted);
}
.sd-out { display: grid; gap: 14px; }
.sd-answer {
    margin: 0; font-size: clamp(1.05rem, 2.4vw, 1.25rem); line-height: 1.55; color: #fff;
    border-left: 3px solid var(--sd-accent); padding: 2px 0 2px 16px;
}
.sd-answer.is-waiting { color: var(--sd-muted); border-left-color: rgba(201, 169, 98, 0.4); font-size: 1rem; }
.sd-stale { margin: 0; font-size: 0.88rem; line-height: 1.5; padding: 8px 12px; border-radius: 6px; color: var(--sd-weak); border: 1px solid rgba(217, 180, 90, 0.4); }
.sd-stone__head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 6px 16px; margin-bottom: 8px; }
.sd-stone__head .sd-lab { margin: 0; }
.sd-gl { display: inline-flex; flex-direction: column; align-items: center; }
.sd-gl__l { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.95rem; line-height: 1.3; color: var(--sd-ink); }
.sd-input--sm { width: auto !important; min-height: 40px !important; padding: 6px 10px !important; font-size: 0.88rem !important; }
.sd-inline { display: inline-flex; gap: 8px; align-items: center; color: var(--sd-muted); font-size: 0.88rem; padding: 0; }
.sd-warn { color: #ff9b8f; border: 1px solid rgba(231, 76, 60, 0.4); background: rgba(231, 76, 60, 0.1); border-radius: 6px; padding: 10px 12px; font-size: 0.85rem; }
.sd-cards { display: grid; gap: 8px; overflow-anchor: none; }
.sd-card { background: var(--sd-card); border: 1px solid var(--sd-border); border-radius: 10px; min-width: 0; }
.sd-card--live { border-style: dashed; }
.sd-card.is-open { border-color: rgba(201, 169, 98, 0.35); }
.sd-row {
    width: 100%; display: grid; grid-template-columns: 140px minmax(150px, 190px) minmax(0, 1fr) 16px; gap: 14px; align-items: center;
    min-height: 56px; padding: 12px 18px; background: none; border: 0; color: inherit; font: inherit; text-align: left;
}
button.sd-row { cursor: pointer; }
button.sd-row:focus-visible { outline: 2px solid var(--sd-accent); outline-offset: -2px; border-radius: 10px; }
.sd-row__name { font-family: var(--font-display, 'Cinzel', serif); font-size: 0.92rem; color: #fff; }
.sd-row__text { min-width: 0; }
.sd-row__chev { width: 8px; height: 8px; border-right: 2px solid var(--sd-accent); border-bottom: 2px solid var(--sd-accent); transform: rotate(45deg); justify-self: center; margin-top: -4px; }
.sd-card.is-open .sd-row__chev { transform: rotate(-135deg); margin-top: 4px; }
.sd-badge { justify-self: start; font-size: 0.72rem; letter-spacing: 1px; text-transform: uppercase; padding: 3px 10px; border-radius: 999px; border: 1px solid currentColor; white-space: nowrap; }
.sd-badge--live { color: var(--sd-muted); font-variant-numeric: tabular-nums; }
/* While a shuffled stone is searched, its attempts show in grey: the control, not the stone */
.sd-card--live.is-shuffled .sd-row__text .sd-reading { color: var(--sd-muted); }
.sd-card--live.is-ghost .sd-row__text .sd-reading { color: rgba(255, 255, 255, 0.18); }
.sd-v--clear { color: var(--sd-clear); }
.sd-v--weak { color: var(--sd-weak); }
.sd-v--noise { color: var(--sd-noise); }
.sd-reading { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; letter-spacing: 0.04em; overflow-wrap: anywhere; color: #fff; font-size: 0.92rem; line-height: 1.45; }
.sd-reading--muted { color: var(--sd-muted); }
.sd-order { display: block; color: var(--sd-muted); font-size: 0.75rem; margin-top: 2px; }
.sd-card__body { padding: 4px 18px 16px; border-top: 1px solid var(--sd-border); }

/* head to head: the inscription against the most readable shuffled version */
.sd-h2h { display: grid; gap: 14px; padding: 14px 0 6px; }
.sd-h2h__line { display: grid; gap: 4px; }
.sd-h2h__line .sd-lab { margin: 0; }
.sd-h2h__text { margin: 0; }
.sd-bar { display: block; height: 8px; border-radius: 4px; background: var(--sd-raised); overflow: hidden; margin-top: 4px; }
.sd-bar__fill { display: block; height: 100%; border-radius: 4px; background: #8f8a84; }
.sd-bar__fill--gold { background: var(--sd-accent); }
.sd-scale { display: flex; justify-content: space-between; font-size: 0.75rem; color: var(--sd-muted); margin-top: -8px; }
.sd-h2h__say { margin: 2px 0 0; color: #fff; line-height: 1.55; }
.sd-card__more { background: none; border: 0; padding: 8px 0; min-height: 44px; cursor: pointer; color: var(--sd-accent); font: inherit; font-size: 0.88rem; margin-right: 18px; }
.sd-card__more:focus-visible { outline: 2px solid var(--sd-accent); outline-offset: 2px; }
.sd-card__detail { border-top: 1px solid var(--sd-border); padding-top: 12px; margin-top: 4px; }
.sd-winkey { margin: 14px 0 2px; padding-top: 12px; border-top: 1px solid var(--sd-border); }
.sd-winkey h4 { color: var(--sd-accent); }
.sd-single { margin-top: 10px; }
.sd-single .sd-reading { font-size: 0.85rem; }
.sd-caveat { color: var(--sd-muted); font-size: 0.85rem; font-style: italic; margin: 4px 0 0; line-height: 1.5; }

/* interlinear: each word with its first meaning underneath; the meaning never widens the word box */
.sd-il__words { display: flex; flex-wrap: wrap; gap: 6px 14px; }
.sd-il__w { display: inline-grid; min-width: 7ch; max-width: 100%; }
.sd-il__m {
    width: 0; min-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    color: var(--sd-muted); font-size: 0.74rem; line-height: 1.4; font-style: italic;
}
.sd-il__m--none { font-style: normal; opacity: 0.6; }
/* version */
.sd select, .sd-input {
    width: 100%; max-width: 100%;
    background: var(--sd-raised); color: var(--sd-text);
    border: 1px solid var(--sd-border); border-radius: 6px;
    padding: 10px 12px; font: inherit; font-size: 0.95rem; min-height: 46px;
}
.sd-strip { margin: 0; }
.sd-strip__glyphs {
    display: flex; flex-wrap: wrap; gap: 8px 22px; padding: 16px;
    border-radius: 8px; background: var(--sd-paper); color: var(--sd-ink);
}
.sd-word { display: inline-flex; flex-wrap: wrap; gap: 3px; align-items: center; max-width: 100%; }
.sd-glyph { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.sd-glyph .f { fill: currentColor; stroke: none; }
.sd-glyph--unknown { display: inline-block; width: 22px; text-align: center; color: #b23b2e; font-weight: 700; }
.sd-cite { color: var(--sd-muted); font-size: 0.85rem; margin: 10px 0 0; line-height: 1.5; }
.sd-cite strong { color: var(--sd-weak); font-weight: 600; }

.sd-method-opts:empty { display: none; }
.sd-method-opts { margin-top: 14px; }
.sd-presets { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.sd-keygrid { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.sd-keycell {
    display: inline-flex; flex-direction: column; align-items: center; gap: 4px; padding: 6px;
    border-radius: 6px; background: var(--sd-paper); color: var(--sd-ink);
}
.sd-keycell select { width: 56px; min-height: 40px; padding: 4px; background: #fff; color: var(--sd-ink); border-color: #cfc6b6; font-size: 0.9rem; }

/* settings */
.sd-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.sd-grid--two { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.sd-field { border: 1px solid var(--sd-border); border-radius: 8px; padding: 10px 14px 12px; margin: 0; min-width: 0; }
.sd-field legend { padding: 0 6px; color: var(--sd-muted); font-size: 0.78rem; letter-spacing: 1px; text-transform: uppercase; }
.sd-opt { display: flex; gap: 10px; align-items: flex-start; padding: 7px 0; min-height: 40px; font-size: 0.92rem; cursor: pointer; }
.sd-opt input { margin-top: 4px; accent-color: var(--sd-accent); }
.sd-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.sd-chip { position: relative; }
.sd-chip input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.sd-chip span {
    display: inline-flex; align-items: center; min-height: 44px; padding: 8px 14px;
    border: 1px solid var(--sd-border); border-radius: 999px; font-size: 0.88rem; cursor: pointer;
}
.sd-chip input:checked + span { border-color: var(--sd-accent); color: var(--sd-accent); background: rgba(201, 169, 98, 0.08); }
.sd-chip input:focus-visible + span { outline: 2px solid var(--sd-accent); outline-offset: 2px; }
.sd-more { margin-top: 14px; border-top: 1px solid var(--sd-border); padding-top: 10px; }
.sd-more summary { cursor: pointer; color: var(--sd-accent); min-height: 44px; display: flex; align-items: center; font-size: 0.92rem; }
.sd-more summary:focus-visible { outline: 2px solid var(--sd-accent); outline-offset: 2px; }
.sd-more[open] summary { margin-bottom: 10px; }
/* word meanings */
.sd-card__gloss { margin-right: 18px; }
.sd-gloss { border-top: 1px solid var(--sd-border); padding: 10px 0 4px; }
.sd-gloss__intro { margin: 0 0 8px; }
.sd-gloss__list { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.sd-gloss__list li { display: grid; grid-template-columns: minmax(84px, max-content) 1fr auto; gap: 4px 12px; align-items: baseline; font-size: 0.88rem; }
.sd-gloss__w { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; color: #fff; letter-spacing: 0.04em; }
.sd-gloss__m { color: var(--sd-text); }
.sd-gloss__pos { color: var(--sd-muted); font-size: 0.75rem; }
.sd-gloss__none { color: var(--sd-muted); font-style: italic; grid-column: 2 / 4; }

/* a complete key: one card, one line per language */
.sd-fit__intro { margin: 0 0 12px; }
.sd-fit { list-style: none; margin: 0 0 6px; padding: 0; display: grid; gap: 0; }
.sd-fit__row { padding: 10px 0; border-top: 1px solid var(--sd-border); }
.sd-fit__head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.sd-fit__lang { font-family: var(--font-display, 'Cinzel', serif); color: #fff; font-size: 0.95rem; }
.sd-fit__text { margin: 6px 0 0; font-size: 0.88rem; line-height: 1.5; }
.sd-fit__best { margin: 4px 0 0; }
.sd-fit__best .sd-reading { color: var(--sd-muted); font-size: 0.85rem; }
.sd-fit__row--wait .sd-fit__lang { color: var(--sd-muted); }


.sd-nums { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 8px 16px; margin: 0 0 14px; }
.sd-nums div { min-width: 0; }
.sd-nums dt { color: var(--sd-muted); font-size: 0.75rem; }
.sd-nums dd { margin: 0; font-variant-numeric: tabular-nums; }
.sd-detail__grid { display: grid; gap: 18px; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.sd-key { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.sd-key__pair {
    display: inline-flex; flex-direction: column; align-items: center; gap: 2px; padding: 4px 6px; min-width: 32px;
    border: 1px solid transparent; border-radius: 4px; background: var(--sd-paper); color: var(--sd-ink);
}
.sd-key__pair b { font-size: 0.8rem; }
.sd-key__pair--same { border-color: var(--sd-accent); box-shadow: 0 0 0 1px var(--sd-accent); }
.sd-alts { margin: 0 0 10px; padding-left: 18px; }
.sd-alts li { margin: 4px 0; }
.sd-how { font-size: 0.88rem; color: var(--sd-muted); }
.sd-how summary { cursor: pointer; color: var(--sd-accent); min-height: 44px; display: flex; align-items: center; }
.sd-how p { line-height: 1.6; margin: 8px 0; }
.sd-how strong { color: var(--sd-text); }
.sd-card[data-model="key"] { padding: 14px 18px; }
.sd-card__head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.sd-card__title { margin: 0; font-family: var(--font-display, 'Cinzel', serif); font-size: 1rem; color: #fff; }
.sd-card__reading { margin: 0 0 10px; }

@media (max-width: 760px) {
    .sd-box { padding: 14px; }
    .sd-line { gap: 12px; }
    .sd-inl { width: 100%; flex-direction: column; align-items: stretch; gap: 6px; }
    .sd-inl > .sd-chips { width: 100%; }
    /* Phones: labels sit above full-width dropdowns. flex: none, because the label column is a
       vertical flex box and a zero flex-basis there squashed the dropdown's height on iOS Safari,
       clipping its text. 16px text also stops iOS zooming in when a dropdown is tapped. */
    .sd-inl .sd-input--sm, .sd-opts .sd-input--sm, .sd-opts #sd-variant, .sd-opts #sd-method {
        flex: none; width: 100% !important; max-width: 100%; min-width: 0;
        height: auto; min-height: 50px !important; padding: 12px 14px !important;
        font-size: 16px !important; line-height: 1.3;
    }
    .sd-opts .sd-chip span, .sd-seg__o span { min-height: 44px; }
    .sd-check { min-height: 44px; }
    .sd-runwrap { flex: 1 1 100%; }
    .sd .sd-run, .sd-runbar { min-height: 48px; }
    .sd-tape { display: none; }
    .sd-runbar { padding: 0 10px; gap: 10px; }
    .sd-runbar__t { font-size: 0.7rem; letter-spacing: 1px; }
    .sd-row { grid-template-columns: auto minmax(0, 1fr) 16px; gap: 6px 12px; padding: 12px 14px; }
    .sd-row .sd-badge { grid-column: 1; grid-row: 1; }
    .sd-row__name { grid-column: 2; grid-row: 1; }
    .sd-row__chev { grid-column: 3; grid-row: 1; }
    .sd-row__text { grid-column: 1 / -1; grid-row: 2; }
    .sd-card__body { padding: 4px 14px 14px; }
    .sd-strip__glyphs { gap: 6px 14px; padding: 12px; }
    .sd-strip .sd-glyph { width: 24px; height: 24px; }
    .sd-gl__l { font-size: 0.8rem; }
    .sd-detail__grid { grid-template-columns: minmax(0, 1fr); }
    .sd-reading { font-size: 0.86rem; }
}
@media (prefers-reduced-motion: reduce) {
    .sd-runbar__fill { transition: none; }
}
