/* ChainleSolver: Apple-style grouped input, Fitness-style link rings, a steel chain. */

:root {
  --bg: #f2f2f7;
  --card: #fff;
  --card2: #f2f2f7;
  --label: #000;
  --label2: rgba(60, 60, 67, .64);
  --label3: rgba(60, 60, 67, .32);
  --sep: rgba(60, 60, 67, .2);
  --fill: rgba(120, 120, 128, .12);
  --fill2: rgba(120, 120, 128, .2);
  --tint: #007aff;
  --tint-ink: #0066d6;
  --on-tint: #fff;
  --red: #d70015;
  --bar: rgba(242, 242, 247, .78);
  --shadow: 0 1px 2px rgba(0, 0, 0, .04), 0 6px 20px rgba(0, 0, 0, .06);
  /* One colour per clue: ring colour and a text-safe variant. */
  --c1: #ff2d55; --c1-text: #c8002f;
  --c2: #7ccc00; --c2-text: #3d7a00;
  --c3: #00b8d9; --c3-text: #00728a;
  --sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", system-ui, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --display: -apple-system, BlinkMacSystemFont, "SF Pro Display", system-ui, "Segoe UI", Roboto, sans-serif;
  --rounded: ui-rounded, "SF Pro Rounded", -apple-system, system-ui, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #000; --card: #1c1c1e; --card2: #2c2c2e; --label: #fff;
    --label2: rgba(235, 235, 245, .64); --label3: rgba(235, 235, 245, .32);
    --sep: rgba(84, 84, 88, .65); --fill: rgba(118, 118, 128, .24); --fill2: rgba(118, 118, 128, .36);
    --tint: #0a84ff; --tint-ink: #4ba3ff; --red: #ff6961; --bar: rgba(0, 0, 0, .66); --shadow: none;
    --c1: #ff375f; --c1-text: #ff6b88; --c2: #a6f20b; --c2-text: #b8f53c; --c3: #3fdcff; --c3-text: #6fe5ff;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #000; --card: #1c1c1e; --card2: #2c2c2e; --label: #fff;
  --label2: rgba(235, 235, 245, .64); --label3: rgba(235, 235, 245, .32);
  --sep: rgba(84, 84, 88, .65); --fill: rgba(118, 118, 128, .24); --fill2: rgba(118, 118, 128, .36);
  --tint: #0a84ff; --tint-ink: #4ba3ff; --red: #ff6961; --bar: rgba(0, 0, 0, .66); --shadow: none;
  --c1: #ff375f; --c1-text: #ff6b88; --c2: #a6f20b; --c2-text: #b8f53c; --c3: #3fdcff; --c3-text: #6fe5ff;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--label); font: 17px/1.35 var(--sans); -webkit-font-smoothing: antialiased; }
h1, h2, p { margin: 0; }
a { color: var(--tint-ink); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select { font: inherit; color: inherit; }
button, select, summary, label:has(input[type=radio]) { cursor: pointer; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--tint); outline-offset: 2px; }
fieldset { margin: 0; padding: 0; border: 0; min-width: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }
.skip { position: absolute; left: 12px; top: -80px; z-index: 30; padding: 10px 14px; border-radius: 10px; background: var(--card); color: var(--tint-ink); }
.skip:focus { top: 12px; }

/* Navigation bar */
.bar { position: sticky; top: 0; z-index: 10; background: var(--bar); border-bottom: .5px solid var(--sep);
  -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px); }
.bar-in { max-width: 1080px; margin: auto; padding: 10px 20px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.brand { display: inline-flex; align-items: center; gap: 9px; color: var(--label); font: 600 17px/1 var(--display); letter-spacing: -.01em; }
.brand:hover { text-decoration: none; }
.mark { width: 30px; height: 20px; }
.byline { font-size: 15px; color: var(--label2); }

.page { max-width: 1080px; margin: auto; padding: 0 20px 48px; }
.large { font: 700 34px/1.12 var(--display); letter-spacing: .01em; margin-top: 18px; }
.sub { color: var(--label2); font-size: 17px; margin: 2px 0 18px; }

/* Grouped lists */
.group { background: var(--card); border-radius: 12px; overflow: hidden; }
.footnote { font-size: 13px; color: var(--label2); margin: 7px 16px 0; }

.clue-row { position: relative; display: flex; align-items: center; gap: 12px; min-height: 50px; padding: 0 16px; }
.clue-row + .clue-row::after, .clue-row + .add-row::after { content: ""; position: absolute; top: 0; left: 40px; right: 0; border-top: .5px solid var(--sep); }
.clue-row label { flex: 0 0 auto; width: 4.2em; font-size: 17px; }
.clue-input, .reference input { flex: 1; min-width: 0; border: 0; background: none; padding: 13px 0; font-size: 17px; outline: none; }
.clue-input::placeholder, .reference input::placeholder { color: var(--label3); }
.clue-row:focus-within { background: var(--fill); }
.clue-input[aria-invalid="true"] { color: var(--red); }
.clue-row:has([aria-invalid="true"]) label { color: var(--red); }
.dot { width: 12px; height: 12px; border-radius: 50%; flex: 0 0 auto; position: relative; z-index: 1; box-shadow: 0 0 0 2px var(--card); }
.c1 .dot { background: var(--c1); } .c2 .dot { background: var(--c2); } .c3 .dot { background: var(--c3); }
/* A steel chain joins each clue to the one above it. */
.clue-row + .clue-row::before {
  content: ""; position: absolute; left: 13px; top: -24px; width: 18px; height: 48px; z-index: 0;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 18 48'%3E%3Cdefs%3E%3ClinearGradient id='s' x1='0' x2='1'%3E%3Cstop offset='0' stop-color='%23e9eaee'/%3E%3Cstop offset='.42' stop-color='%23989ba2'/%3E%3Cstop offset='.6' stop-color='%23404247'/%3E%3Cstop offset='1' stop-color='%23b9bbc0'/%3E%3C/linearGradient%3E%3C/defs%3E%3Crect x='3' y='2' width='12' height='20' rx='6' fill='none' stroke='url(%23s)' stroke-width='3.4'/%3E%3Crect x='7' y='15' width='4' height='18' rx='2' fill='url(%23s)' stroke='%23404247' stroke-width='.5'/%3E%3Crect x='3' y='26' width='12' height='20' rx='6' fill='none' stroke='url(%23s)' stroke-width='3.4'/%3E%3C/svg%3E") center / contain no-repeat;
}
.dot { box-shadow: 0 0 0 2.5px var(--card); }
.reference .clue-row label { width: 4.2em; }
.remove, .add-row svg { width: 22px; height: 22px; }
.remove { flex: 0 0 auto; display: grid; place-items: center; width: 44px; height: 44px; margin-right: -11px; border: 0; background: none; padding: 0; }
.remove svg { width: 22px; height: 22px; fill: var(--red); }
.remove svg path, .add-row svg path { stroke: #fff; stroke-width: 2.2; stroke-linecap: round; }
.add-row { position: relative; display: flex; align-items: center; gap: 12px; width: 100%; min-height: 48px; padding: 0 16px 0 11px; border: 0; background: none; color: var(--tint-ink); font-size: 17px; text-align: left; }
.add-row svg { fill: var(--tint); flex: 0 0 auto; }
.add-row:hover { background: var(--fill); }

.error { margin: 10px 16px 0; color: var(--red); font-size: 15px; }
.cta { display: block; width: 100%; min-height: 50px; margin-top: 16px; border: 0; border-radius: 999px; background: var(--tint); color: var(--on-tint); font-size: 17px; font-weight: 600; }
.cta:hover { filter: brightness(1.06); }
.cta[aria-busy="true"] { cursor: progress; opacity: .85; }
.search-actions { display: flex; gap: 12px; margin-top: 16px; }
.search-actions .cta { flex: 1; min-width: 0; margin-top: 0; }
.reset-button { min-height: 50px; padding: 0 20px; border: 0; border-radius: 999px; background: var(--fill); color: var(--tint-ink); font-size: 17px; font-weight: 600; }
.reset-button:hover { background: var(--fill2); }

.model { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 6px 12px; margin: 10px 8px 0; font-size: 13px; color: var(--label2); text-align: center; }
.model p { flex: 1 1 100%; }
.model[data-state="failed"] p { color: var(--red); }
.model[data-state="ready"] p::before { content: ""; display: inline-block; width: 7px; height: 7px; margin-right: 7px; border-radius: 50%; background: #34c759; vertical-align: 1px; }
.progress { flex: 1 0 100%; height: 4px; border-radius: 2px; background: var(--fill2); overflow: hidden; }
.progress span { display: block; height: 100%; width: 0; border-radius: 2px; background: var(--tint); }
.link-button { min-height: 36px; border: 0; background: none; color: var(--tint-ink); font-size: 15px; font-weight: 500; padding: 0 6px; }

/* Results controls */
.results { min-width: 0; }
.controls { display: flex; align-items: center; gap: 10px; margin: 18px 0 8px; }
.segmented { flex: 1 1 auto; display: flex; padding: 2px; border-radius: 9px; background: var(--fill); }
.segmented label { position: relative; flex: 1 1 0; min-width: 0; }
.segmented input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.segmented span { display: block; padding: 6px 4px; border-radius: 7px; text-align: center; font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.segmented input:checked + span { background: var(--card); font-weight: 600; box-shadow: 0 3px 8px rgba(0, 0, 0, .12), 0 0 0 .5px rgba(0, 0, 0, .04); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .segmented input:checked + span { background: #636366; } }
:root[data-theme="dark"] .segmented input:checked + span { background: #636366; }
.segmented input:focus-visible + span { outline: 3px solid var(--tint); outline-offset: 1px; }
.segmented sup { font-size: 9px; font-weight: 700; color: #ff9500; }
.list-foot { display: flex; justify-content: flex-end; margin: 10px 4px 0; }
.menu { flex: 0 0 auto; display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--label2); }
.menu select { height: 32px; padding: 0 8px; border: 0; border-radius: 9px; background: var(--fill); font-size: 13px; font-weight: 600; color: var(--label); }
.reference { margin-top: 8px; }
.explain { margin-bottom: 10px; }
.stale-note { margin: 4px 16px 10px; font-size: 15px; }
.results.stale .result-list, .results.stale .hidden-words { opacity: .38; }
.results[aria-busy="true"] .result-list { opacity: .6; }

/* Rings */
.rings { flex: 0 0 auto; display: block; }
.rings .track { stroke-opacity: .2; }
.k1 { stroke: var(--c1); } .k2 { stroke: var(--c2); } .k3 { stroke: var(--c3); }
.t1 { color: var(--c1-text); } .t2 { color: var(--c2-text); } .t3 { color: var(--c3-text); }

/* Result rows: the first is a feature card, the rest a grouped list. */
.result-list { list-style: none; margin: 0; padding: 0; }
.row {
  position: relative; display: grid; align-items: center; column-gap: 12px;
  grid-template-columns: 1.4em 40px minmax(0, 1fr) auto auto;
  grid-template-areas: "rank rings word score acts" "rank rings links score acts";
  padding: 10px 16px; background: var(--card);
}
.row + .row::after { content: ""; position: absolute; top: 0; left: 88px; right: 0; border-top: .5px solid var(--sep); }
.row:nth-child(2) { border-radius: 12px 12px 0 0; margin-top: 16px; }
.row:nth-child(2)::after { display: none; }
.row:last-child { border-radius: 0 0 12px 12px; }
.row:nth-child(2):last-child { border-radius: 12px; }
.rank { grid-area: rank; font: 15px var(--rounded); color: var(--label2); text-align: right; font-variant-numeric: tabular-nums; }
.row .rings { grid-area: rings; width: 40px; height: 40px; }
.word { grid-area: word; font-size: 17px; font-weight: 600; overflow-wrap: anywhere; }
.links { grid-area: links; display: flex; flex-wrap: wrap; gap: 0 10px; font-size: 13px; font-weight: 500; font-variant-numeric: tabular-nums; }
.score { grid-area: score; font: 600 17px var(--rounded); font-variant-numeric: tabular-nums; text-align: right; }
.score small { font-size: 12px; font-weight: 500; color: var(--label2); margin-left: 2px; }
.acts { grid-area: acts; display: flex; gap: 8px; }
.act { display: grid; place-items: center; width: 34px; height: 34px; padding: 0; border: 0; border-radius: 50%; background: var(--fill); color: var(--tint-ink); }
.act svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.act:hover { background: var(--fill2); }
.act .txt { display: none; }

.row.top {
  grid-template-columns: auto minmax(0, 1fr);
  grid-template-areas: "rings eyebrow" "rings word" "rings links" "rings score" "rings acts";
  column-gap: 22px; row-gap: 4px; padding: 20px; border-radius: 22px; box-shadow: var(--shadow);
}
.row.top .rank { display: none; }
.row.top .eyebrow { grid-area: eyebrow; font-size: 13px; font-weight: 600; color: var(--label2); text-transform: uppercase; letter-spacing: .03em; }
.row.top .rings { width: 132px; height: 132px; }
.row.top .word { font: 700 36px/1.1 var(--display); letter-spacing: -.02em; }
.row.top .links { flex-direction: column; gap: 2px; font-size: 15px; margin-top: 4px; }
.row.top .links .link b { font: 600 20px var(--rounded); margin-right: 6px; }
.row.top .links .link span { color: var(--label2); font-weight: 400; }
.row.top .score { text-align: left; font-size: 15px; font-weight: 500; color: var(--label2); font-family: var(--sans); }
.row.top .score b { font: 600 20px var(--rounded); color: var(--label); margin-right: 6px; }
.row.top .acts { margin-top: 10px; }
.row.top .act { width: auto; height: 36px; padding: 0 16px; border-radius: 999px; background: var(--fill); color: var(--label); font-size: 15px; font-weight: 500; display: inline-flex; gap: 6px; }
.row.top .act .txt { display: inline; }
.row-empty { padding: 16px; background: var(--card); border-radius: 12px; color: var(--label2); }

.hidden-words { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 14px 4px 0; font-size: 15px; }
.hidden-words .label { font-size: 13px; color: var(--label2); text-transform: uppercase; letter-spacing: .03em; }
.hidden-list { display: contents; }
.restore-one { min-height: 32px; padding: 0 12px; border: 0; border-radius: 999px; background: var(--fill); color: var(--label2); font-size: 15px; text-decoration: line-through; }
.restore-one:hover { text-decoration: none; color: var(--label); }

/* Empty state */
.empty { margin-top: 18px; padding: 22px 16px 18px; text-align: center; color: var(--label2); font-size: 15px; }
.empty-chain { width: 120px; height: 32px; margin: 0 auto 10px; display: block; }
.empty-title { font: 600 20px var(--display); color: var(--label); margin-bottom: 4px; }
.examples { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 12px; }
.example { min-height: 40px; padding: 0 16px; border: 0; border-radius: 999px; background: var(--fill); color: var(--tint-ink); font-size: 15px; font-weight: 500; }
.example:hover { background: var(--fill2); }

/* About and footer */
.about { margin-top: 26px; }
.about summary { padding: 13px 16px; font-size: 17px; list-style-position: inside; }
.about > div { padding: 0 16px 14px; font-size: 15px; color: var(--label2); }
.about p + p { margin-top: 8px; }
.about strong { color: var(--label); font-weight: 600; }
.foot { margin: 18px 16px 0; font-size: 13px; color: var(--label2); display: grid; gap: 12px; }
.segmented.small { max-width: 240px; }

.toast { position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 20;
  max-width: calc(100% - 32px); padding: 11px 18px; border-radius: 999px; background: rgba(30, 30, 32, .92); color: #fff;
  font-size: 15px; font-weight: 500; box-shadow: 0 8px 30px rgba(0, 0, 0, .25); -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px); }
.noscript { margin: 20px; }

/* Credits page */
.prose { max-width: 680px; margin: auto; padding: 8px 20px 48px; }
.prose h1 { font: 700 34px/1.12 var(--display); margin: 18px 0 14px; }
.prose h2 { font: 600 20px/1.3 var(--display); margin-top: 26px; }
.prose p { margin-top: 10px; color: var(--label2); font-size: 15px; }

@media (prefers-reduced-motion: no-preference) {
  .progress span { transition: width .2s ease-out; }
  .result-list { transition: opacity .15s; }
  .segmented span { transition: background-color .2s; }
}

/* Two columns on wide screens: clues stay in view beside the results. */
@media (min-width: 900px) {
  .page { display: grid; grid-template-columns: 360px minmax(0, 1fr); gap: 32px; align-items: start; }
  .input-col { position: sticky; top: 60px; }
  .controls { margin-top: 26px; }
  .row.top .rings { width: 150px; height: 150px; }
}

/* Phones */
@media (max-width: 560px) {
  .page { padding: 0 16px 40px; }
  .bar-in { padding: 10px 16px; }
  .large { font-size: 30px; margin-top: 12px; }
  .sub { margin-bottom: 14px; }
  .controls { flex-wrap: wrap; margin-top: 16px; }
  .segmented:not(.small) { flex: 1 0 100%; }
  .row { grid-template-columns: 1.2em 36px minmax(0, 1fr) auto; grid-template-areas: "rank rings word score" "rank rings links acts"; padding: 9px 12px; column-gap: 10px; row-gap: 2px; }
  .row .rings { width: 36px; height: 36px; }
  .row + .row::after { left: 70px; }
  .acts { gap: 6px; }
  .act { width: 30px; height: 30px; }
  .row.top { column-gap: 16px; padding: 16px; grid-template-areas: "rings eyebrow" "rings word" "rings links" "rings score" "acts acts"; }
  .row.top .rings { width: 96px; height: 96px; }
  .row.top .word { font-size: 30px; }
  .row.top .acts { margin-top: 12px; }
}
