/* Components: the small, reusable pieces. */

/* ---------- Site header and footer ---------- */
.site-header { position: sticky; top: 0; z-index: 40; background: color-mix(in srgb, var(--paper) 86%, transparent); backdrop-filter: saturate(1.4) blur(14px); -webkit-backdrop-filter: saturate(1.4) blur(14px); border-bottom: 1px solid var(--line); }
.header-in { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: var(--header-h); }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; font-weight: 750; letter-spacing: 0.12em; font-size: 0.95rem; }
.brand:hover { color: var(--ink); }
.brand .mark { width: 28px; height: 28px; flex: none; }
.half-a { fill: var(--warm); }
.half-b { fill: var(--brand); }
.primary-nav { display: flex; align-items: center; gap: 4px; }
.nav-link { display: inline-flex; align-items: center; min-height: 40px; padding: 0 14px; border-radius: 999px; color: var(--ink-2); text-decoration: none; font-weight: 600; font-size: var(--fs-sm); }
.nav-link:hover { background: var(--paper-2); color: var(--ink); }
.nav-link[aria-current="page"] { color: var(--ink); background: var(--paper-2); }
.account { position: relative; }
.account summary { list-style: none; display: inline-flex; align-items: center; gap: 8px; cursor: pointer; min-height: 40px; padding: 0 6px 0 4px; border-radius: 999px; }
.account summary::-webkit-details-marker { display: none; }
.account summary:hover { background: var(--paper-2); }
.account-menu { position: absolute; right: 0; top: calc(100% + 8px); min-width: 250px; background: var(--card); border: 1px solid var(--line); border-radius: var(--r-md); box-shadow: var(--shadow-3); padding: 8px; z-index: 50; }
.account-menu .who { padding: 10px 12px 12px; border-bottom: 1px solid var(--line); margin-bottom: 6px; }
.account-menu a, .account-menu button { display: flex; width: 100%; align-items: center; gap: 10px; padding: 10px 12px; border: 0; background: none; border-radius: var(--r-sm); color: var(--ink); text-decoration: none; font-size: var(--fs-sm); font-weight: 600; text-align: left; }
.account-menu a:hover, .account-menu button:hover { background: var(--paper-2); }
@media (max-width: 560px) { .nav-link.hide-sm { display: none; } .brand span.word { letter-spacing: 0.08em; } }

.site-footer { border-top: 1px solid var(--line); background: var(--paper-2); margin-top: auto; }
.footer-in { padding-block: 36px 44px; display: grid; gap: 28px; grid-template-columns: 1.4fr 1fr 1fr; }
.footer-in h4 { font-size: var(--fs-xs); letter-spacing: 0.09em; text-transform: uppercase; color: var(--ink-3); margin-bottom: 10px; }
.footer-in ul { list-style: none; padding: 0; }
.footer-in li + li { margin-top: 6px; }
.footer-in a { color: var(--ink-2); text-decoration: none; font-size: var(--fs-sm); }
.footer-in a:hover { color: var(--ink); text-decoration: underline; }
.footer-note { grid-column: 1 / -1; padding-top: 20px; border-top: 1px solid var(--line); color: var(--ink-3); font-size: var(--fs-xs); display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; }
@media (max-width: 760px) { .footer-in { grid-template-columns: 1fr 1fr; } .footer-in > :first-child { grid-column: 1 / -1; } }

.offline { background: var(--warn-soft); color: var(--warn); text-align: center; padding: 10px 16px; font-size: var(--fs-sm); font-weight: 600; border-bottom: 1px solid var(--line); }

/* ---------- Buttons ---------- */
.btn { --b-bg: var(--brand); --b-fg: var(--brand-ink); --b-bd: var(--brand); display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px; padding: 0 22px; border-radius: 999px; border: 1.5px solid var(--b-bd); background: var(--b-bg); color: var(--b-fg); font-weight: 650; font-size: var(--fs-md); text-decoration: none; line-height: 1; white-space: nowrap; transition: background 0.15s, transform 0.15s var(--ease), box-shadow 0.15s, border-color 0.15s; position: relative; }
.btn:hover { --b-bg: var(--brand-hover); --b-bd: var(--brand-hover); color: var(--b-fg); box-shadow: var(--shadow-2); transform: translateY(-1px); }
.btn:active { transform: none; box-shadow: none; }
.btn:focus-visible { outline: none; box-shadow: var(--ring); }
.btn-secondary { --b-bg: transparent; --b-fg: var(--ink); --b-bd: var(--line-2); }
.btn-secondary:hover { --b-bg: var(--card); --b-fg: var(--ink); --b-bd: var(--ink-3); }
.btn-quiet { --b-bg: transparent; --b-fg: var(--brand); --b-bd: transparent; padding: 0 12px; }
.btn-quiet:hover { --b-bg: var(--brand-soft); --b-fg: var(--brand-hover); --b-bd: transparent; box-shadow: none; transform: none; }
.btn-danger { --b-bg: var(--bad); --b-fg: #fff; --b-bd: var(--bad); }
.btn-danger:hover { --b-bg: color-mix(in srgb, var(--bad) 85%, #000); --b-bd: color-mix(in srgb, var(--bad) 85%, #000); }
.btn-danger-quiet { --b-bg: transparent; --b-fg: var(--bad); --b-bd: transparent; padding: 0 12px; }
.btn-danger-quiet:hover { --b-bg: var(--bad-soft); --b-fg: var(--bad); box-shadow: none; transform: none; }
.btn-sm { min-height: 36px; padding: 0 16px; font-size: var(--fs-sm); }
.btn-lg { min-height: 54px; padding: 0 26px; font-size: var(--fs-md); }
.btn-block { width: 100%; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: 0.5; cursor: not-allowed; transform: none; box-shadow: none; pointer-events: none; }
.btn[aria-busy="true"] { color: transparent; pointer-events: none; }
.btn[aria-busy="true"]::after { content: ""; position: absolute; width: 18px; height: 18px; border-radius: 50%; border: 2.5px solid var(--b-fg); border-right-color: transparent; animation: spin 0.7s linear infinite; }
.btn-secondary[aria-busy="true"]::after, .btn-quiet[aria-busy="true"]::after { border-color: var(--ink-3); border-right-color: transparent; }
.link-btn { background: none; border: 0; padding: 0; color: var(--brand); text-decoration: underline; text-underline-offset: 3px; font-weight: 600; }
.icon { display: inline-block; vertical-align: -0.22em; width: 1.25em; height: 1.25em; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- Cards and panels ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r-lg); padding: clamp(20px, 3vw, 30px); box-shadow: var(--shadow-1); }
.card.flat { box-shadow: none; }
.card.soft { background: var(--paper-2); box-shadow: none; }
.card.brand { background: var(--brand-soft); border-color: var(--brand-line); box-shadow: none; }
.card.link { display: block; color: inherit; text-decoration: none; transition: transform 0.2s var(--ease), box-shadow 0.2s, border-color 0.2s; }
.card.link:hover { transform: translateY(-3px); box-shadow: var(--shadow-2); border-color: var(--line-2); color: inherit; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 14px; flex-wrap: wrap; }
.card-head h2, .card-head h3 { font-family: var(--font-sans); }
.card h2 { font-size: var(--fs-lg); font-family: var(--font-sans); letter-spacing: -0.01em; font-weight: 700; }
.card > h2 + p, .card > h3 + p { margin-top: 6px; }

/* ---------- Chips, badges, notes ---------- */
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 11px; border-radius: 999px; border: 1px solid var(--line-2); background: var(--card); color: var(--ink-2); font-size: var(--fs-xs); font-weight: 650; line-height: 1.5; white-space: nowrap; }
.chip .icon { width: 14px; height: 14px; stroke-width: 2.2; }
.chip.ok { color: var(--ok); background: var(--ok-soft); border-color: transparent; }
.chip.warn { color: var(--warn); background: var(--warn-soft); border-color: transparent; }
.chip.bad { color: var(--bad); background: var(--bad-soft); border-color: transparent; }
.chip.info { color: var(--info); background: var(--info-soft); border-color: transparent; }
.chip.brand { color: var(--brand); background: var(--brand-soft); border-color: transparent; }
.chip.plain { background: var(--paper-2); border-color: transparent; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.note { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: var(--r-md); background: var(--info-soft); color: var(--ink); font-size: var(--fs-sm); border: 1px solid transparent; }
.note .icon { margin-top: 2px; color: var(--info); }
.note.warn { background: var(--warn-soft); } .note.warn .icon { color: var(--warn); }
.note.ok { background: var(--ok-soft); } .note.ok .icon { color: var(--ok); }
.note.bad { background: var(--bad-soft); } .note.bad .icon { color: var(--bad); }
.note.demo { background: transparent; border: 1.5px dashed var(--line-2); }
.note.demo .icon { color: var(--ink-2); }
.note p + p { margin-top: 6px; }
.msg { font-size: var(--fs-sm); font-weight: 600; margin-top: 10px; }
.msg.err { color: var(--bad); } .msg.good { color: var(--ok); }
.msg:empty { display: none; }

/* ---------- Forms ---------- */
.field { display: block; }
.field + .field, .field + .choice-group, .choice-group + .field { margin-top: 18px; }
.field > label, .field > .label, .label { display: block; font-weight: 650; font-size: var(--fs-sm); margin-bottom: 6px; }
.hint { color: var(--ink-3); font-size: var(--fs-sm); margin-top: 6px; }
.field > label + .hint { margin-top: -2px; margin-bottom: 8px; }
.input, .select, .textarea { width: 100%; min-height: 46px; padding: 10px 14px; border: 1.5px solid var(--line-2); border-radius: var(--r-md); background: var(--card); color: var(--ink); font-size: var(--fs-md); transition: border-color 0.15s, box-shadow 0.15s; }
.textarea { min-height: 120px; resize: vertical; line-height: 1.55; }
.input:hover, .select:hover, .textarea:hover { border-color: var(--ink-3); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand) 18%, transparent); }
.input::placeholder, .textarea::placeholder { color: var(--ink-3); opacity: 0.85; }
.input[aria-invalid="true"], .textarea[aria-invalid="true"] { border-color: var(--bad); }
.select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--ink-3) 50%), linear-gradient(135deg, var(--ink-3) 50%, transparent 50%); background-position: calc(100% - 20px) 55%, calc(100% - 14px) 55%; background-size: 6px 6px; background-repeat: no-repeat; padding-right: 40px; }
.input-code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: 0.06em; font-size: var(--fs-md); }
fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
legend { padding: 0; font-weight: 650; font-size: var(--fs-sm); margin-bottom: 8px; }
.choice-group { display: grid; gap: 10px; }
.choice { display: flex; gap: 14px; align-items: flex-start; padding: 14px 16px; border: 1.5px solid var(--line-2); border-radius: var(--r-md); background: var(--card); cursor: pointer; transition: border-color 0.15s, background 0.15s, box-shadow 0.15s; }
.choice:hover { border-color: var(--ink-3); }
.choice:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); }
.choice:has(input:focus-visible) { box-shadow: var(--ring); }
.choice input { appearance: none; -webkit-appearance: none; width: 22px; height: 22px; margin: 2px 0 0; flex: none; border: 2px solid var(--line-2); background: var(--card); display: grid; place-content: center; cursor: pointer; }
.choice input[type="radio"] { border-radius: 50%; }
.choice input[type="checkbox"] { border-radius: 7px; }
.choice input::after { content: ""; transition: transform 0.12s var(--ease); }
.choice input[type="checkbox"]::after { width: 6px; height: 11px; border: solid var(--brand-ink); border-width: 0 2.5px 2.5px 0; transform: translateY(-1px) rotate(45deg) scale(0); }
.choice input[type="checkbox"]:checked::after { transform: translateY(-1px) rotate(45deg) scale(1); }
.choice input[type="radio"]::after { width: 10px; height: 10px; border-radius: 50%; background: var(--brand-ink); transform: scale(0); }
.choice input[type="radio"]:checked::after { transform: scale(1); }
.choice input:checked { background: var(--brand); border-color: var(--brand); }
.choice input:focus-visible { outline: none; }
.choice .t { font-weight: 650; }
.choice .d { display: block; color: var(--ink-2); font-size: var(--fs-sm); margin-top: 2px; }
.choice.check-only { padding: 12px 14px; }
.switch { position: relative; display: inline-flex; align-items: center; }
.switch input { appearance: none; -webkit-appearance: none; width: 50px; height: 30px; margin: 0; border-radius: 999px; background: var(--line-2); border: 0; cursor: pointer; transition: background 0.2s; position: relative; flex: none; }
.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgb(0 0 0 / 30%); transition: transform 0.2s var(--ease); }
.switch input:checked { background: var(--brand); }
.switch input:checked::after { transform: translateX(20px); }
.switch input:focus-visible { outline: none; box-shadow: var(--ring); }
.switch input:disabled { opacity: 0.5; cursor: not-allowed; }
input[type="range"] { width: 100%; height: 34px; accent-color: var(--brand); margin: 0; }
.range-out { font-variant-numeric: tabular-nums; font-weight: 750; font-size: var(--fs-lg); min-width: 4ch; text-align: right; }
.actions { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 28px; flex-wrap: wrap; }
.actions.end { justify-content: flex-end; }
.tag-input { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.tag { display: inline-flex; align-items: center; gap: 4px; padding: 4px 6px 4px 12px; background: var(--brand-soft); color: var(--brand); border-radius: 999px; font-size: var(--fs-sm); font-weight: 600; }
.tag button { border: 0; background: none; width: 22px; height: 22px; border-radius: 50%; color: inherit; display: grid; place-items: center; }
.tag button:hover { background: var(--card); }

/* ---------- Stepper ---------- */
.stepper { display: flex; align-items: center; gap: 6px; list-style: none; padding: 0; margin: 0; }
.stepper li { flex: 1; height: 6px; border-radius: 999px; background: var(--line); margin: 0; position: relative; overflow: hidden; }
.stepper li.done, .stepper li.now { background: var(--brand); }
.stepper li.now { background: linear-gradient(90deg, var(--brand) 50%, var(--brand-line) 50%); }
.step-label { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin: 12px 0 28px; font-size: var(--fs-sm); color: var(--ink-3); font-weight: 600; }
.step-label b { color: var(--ink); }

/* ---------- Score ring, bars, radar ---------- */
.ring { position: relative; width: var(--size, 132px); height: var(--size, 132px); flex: none; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring .track { stroke: var(--line); } .ring .arc { stroke: var(--brand); transition: stroke-dashoffset 1s var(--ease); }
.ring .val { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; line-height: 1; }
.ring .val b { font-family: var(--font-serif); font-size: calc(var(--size, 132px) * 0.3); font-weight: 600; }
.ring .val span { font-size: var(--fs-xs); color: var(--ink-3); margin-top: 4px; }
.bar-row { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; align-items: center; }
.bar-row + .bar-row { margin-top: 14px; }
.bar-row .n { font-weight: 650; font-size: var(--fs-sm); }
.bar-row .v { font-variant-numeric: tabular-nums; font-weight: 700; font-size: var(--fs-sm); }
.bar-row .b { grid-column: 1 / -1; height: 8px; background: var(--line); border-radius: 999px; overflow: hidden; }
.bar-row .b i { display: block; height: 100%; background: var(--brand); border-radius: 999px; }
.bar-row .b.none { background: repeating-linear-gradient(45deg, var(--line), var(--line) 6px, transparent 6px, transparent 12px); }
.bar-row .w { grid-column: 1 / -1; color: var(--ink-3); font-size: var(--fs-xs); margin-top: -2px; }
.radar { width: 100%; max-width: 380px; margin-inline: auto; }
.radar text { fill: var(--ink-2); font-size: 11.5px; font-weight: 600; font-family: var(--font-sans); }
.radar .grid-line { fill: none; stroke: var(--line-2); stroke-width: 1; }
.radar .shape { fill: color-mix(in srgb, var(--brand) 20%, transparent); stroke: var(--brand); stroke-width: 2.2; stroke-linejoin: round; }
.radar .dot { fill: var(--brand); stroke: var(--card); stroke-width: 2; }
.radar .dot.none { fill: var(--card); stroke: var(--brand); stroke-width: 2; }

/* ---------- Checklist ---------- */
.checks { list-style: none; padding: 0; }
.checks li { display: flex; gap: 12px; align-items: flex-start; padding: 12px 0; border-bottom: 1px solid var(--line); margin: 0; }
.checks li:last-child { border-bottom: 0; }
.tick { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; flex: none; margin-top: 1px; background: var(--paper-2); color: var(--ink-3); border: 1.5px solid var(--line-2); }
.tick.done { background: var(--ok); color: #fff; border-color: var(--ok); }
.tick .icon { width: 14px; height: 14px; stroke-width: 3; }
.checks .t { font-weight: 600; } .checks .d { color: var(--ink-3); font-size: var(--fs-sm); }

/* ---------- Tabs and segmented control ---------- */
.segmented { display: inline-flex; padding: 4px; background: var(--paper-2); border-radius: 999px; gap: 2px; max-width: 100%; overflow-x: auto; }
.segmented button { border: 0; background: none; padding: 8px 16px; border-radius: 999px; font-weight: 650; font-size: var(--fs-sm); color: var(--ink-2); white-space: nowrap; display: inline-flex; gap: 8px; align-items: center; }
.segmented button[aria-pressed="true"], .segmented button[aria-selected="true"] { background: var(--card); color: var(--ink); box-shadow: var(--shadow-1); }
.count-dot { position: relative; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--warm); color: #fff; font-size: 11.5px; font-weight: 750; display: inline-grid; place-items: center; }

/* ---------- Avatar and glyph ---------- */
.avatar { width: var(--size, 40px); height: var(--size, 40px); border-radius: 50%; display: grid; place-items: center; flex: none; background: linear-gradient(135deg, var(--warm), color-mix(in srgb, var(--warm) 60%, var(--brand))); color: #fff; font-weight: 750; font-size: calc(var(--size, 40px) * 0.4); letter-spacing: 0.02em; }
.avatar.twin { background: linear-gradient(135deg, var(--brand), color-mix(in srgb, var(--brand) 70%, #4f6bff)); }
.avatar.sm { --size: 30px; }
.avatar.lg { --size: 64px; }
.avatar.plain { background: var(--paper-2); color: var(--ink); border: 1px solid var(--line); }
.kind-glyph { color: var(--ink-2); }

/* ---------- Tables and lists ---------- */
.rows > * { padding: 16px 0; border-bottom: 1px solid var(--line); }
.rows > *:first-child { padding-top: 0; }
.rows > *:last-child { border-bottom: 0; padding-bottom: 0; }
.table-wrap { overflow-x: auto; margin-inline: calc(var(--gutter) * -0.4); padding-inline: calc(var(--gutter) * 0.4); }
table.simple { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
table.simple th { text-align: left; font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: 0.07em; color: var(--ink-3); padding: 8px 12px 8px 0; border-bottom: 1px solid var(--line-2); }
table.simple td { padding: 14px 12px 14px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
dl.facts { margin: 0; display: grid; grid-template-columns: max-content 1fr; gap: 10px 20px; font-size: var(--fs-sm); }
dl.facts dt { color: var(--ink-3); font-weight: 600; } dl.facts dd { margin: 0; font-weight: 550; }
.empty { text-align: center; padding: clamp(28px, 6vw, 56px) 20px; color: var(--ink-2); }
.empty .art { width: 64px; height: 64px; margin: 0 auto 16px; border-radius: 50%; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand); }
.empty .art .icon { width: 28px; height: 28px; }
.empty h3 { margin-bottom: 6px; color: var(--ink); }

/* ---------- Details / FAQ ---------- */
details.faq { border-bottom: 1px solid var(--line); }
details.faq summary { list-style: none; cursor: pointer; padding: 20px 4px; font-weight: 650; font-size: var(--fs-lg); display: flex; justify-content: space-between; gap: 16px; align-items: center; }
details.faq summary::-webkit-details-marker { display: none; }
details.faq summary::after { content: "+"; font-size: 1.5rem; font-weight: 400; color: var(--ink-3); transition: transform 0.2s; }
details.faq[open] summary::after { transform: rotate(45deg); }
details.faq .a { padding: 0 4px 22px; color: var(--ink-2); max-width: 70ch; }
details.plain summary { cursor: pointer; font-weight: 650; }

/* ---------- Dialog, toast, skeleton ---------- */
dialog { border: 0; padding: 0; border-radius: var(--r-xl); background: var(--card); color: var(--ink); box-shadow: var(--shadow-3); width: min(520px, calc(100vw - 32px)); max-height: calc(100vh - 32px); }
dialog::backdrop { background: rgb(15 18 22 / 55%); backdrop-filter: blur(3px); }
dialog[open] { animation: rise 0.25s var(--ease); }
.dialog-in { padding: clamp(22px, 4vw, 32px); }
.dialog-in h2 { font-size: var(--fs-xl); margin-bottom: 10px; }
.toasts { position: fixed; z-index: 90; bottom: 20px; left: 50%; transform: translateX(-50%); display: grid; gap: 10px; width: min(440px, calc(100vw - 32px)); pointer-events: none; }
.toast { pointer-events: auto; background: var(--ink); color: var(--paper); border-radius: var(--r-md); padding: 14px 18px; box-shadow: var(--shadow-3); font-weight: 600; font-size: var(--fs-sm); animation: rise 0.3s var(--ease); display: flex; gap: 10px; align-items: center; }
.toast.err { background: var(--bad); color: #fff; }
.skeleton { background: linear-gradient(90deg, var(--paper-2) 25%, var(--line) 37%, var(--paper-2) 63%); background-size: 200% 100%; animation: shimmer 1.4s linear infinite; border-radius: var(--r-md); }
.sk-line { height: 14px; margin: 10px 0; } .sk-title { height: 34px; width: 55%; } .sk-block { height: 160px; }
.spinner { width: 22px; height: 22px; border-radius: 50%; border: 3px solid var(--line-2); border-top-color: var(--brand); animation: spin 0.8s linear infinite; display: inline-block; vertical-align: middle; }

input[type="range"][data-untouched] { opacity: 0.55; }
details.plain-inline summary { cursor: pointer; font-weight: 650; font-size: var(--fs-sm); color: var(--brand); margin-top: 10px; }
