:root {
  --page: var(--uis-bg);
  --paper: var(--uis-surface);
  --ink: var(--uis-text);
  --muted: var(--uis-text-muted);
  --line: var(--uis-border);
  --accent: var(--uis-accent);
  --on-accent: var(--uis-on-accent);
  --soft: var(--uis-accent-soft);
  --warn: var(--uis-warning);
  --warn-bg: color-mix(in srgb, var(--uis-warning) 9%, var(--paper));
  --bad: var(--uis-danger);
  --bad-bg: color-mix(in srgb, var(--uis-danger) 9%, var(--paper));
  --shadow: 0 1px 4px #11131a0b;
  font: var(--uis-font-base)/var(--uis-line-height) var(--uis-font);
  color: var(--ink);
  background: var(--page);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: var(--uis-font-h1); line-height: 1.08; letter-spacing: -.04em; }
h2 { font-size: 1.22rem; line-height: 1.25; letter-spacing: -.02em; }
h3 { font-size: 1rem; line-height: 1.35; }
a { color: var(--accent); text-underline-offset: .17em; }
button, input, select { font: inherit; color: inherit; }
button, select, summary { cursor: pointer; }
button, select, input { min-width: 0; min-height: var(--uis-target); border: 1px solid var(--uis-control-border); border-radius: var(--uis-radius-sm); background: var(--paper); padding: .45rem .68rem; }
button:hover, select:hover, input:hover { border-color: var(--accent); }
:focus-visible { outline: 2px solid var(--uis-focus); outline-offset: 3px; }
label { min-width: 0; display: grid; align-content: start; gap: .27rem; font-size: .88rem; font-weight: 650; }
label > :is(input, select) { width: 100%; font-size: 1rem; font-weight: 400; }
input::placeholder { color: var(--muted); opacity: 1; }
button { font-weight: 650; }
.wrap { width: min(100%, 1240px); margin-inline: auto; padding-inline: clamp(14px, 3.3vw, 40px); }
.skip { position: fixed; top: .5rem; left: .5rem; clip-path: inset(50%); z-index: 4; background: var(--paper); padding: .7rem; }
.skip:focus { clip-path: none; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }

.top { color: var(--ink); background: var(--paper); border-bottom: 1px solid var(--line); }
.top-bar { min-height: 66px; display: flex; justify-content: space-between; align-items: center; gap: .75rem; border-bottom: 1px solid var(--line); }
.brand { min-width: 0; display: flex; align-items: center; gap: .7rem; font-weight: 700; line-height: 1.26; }
.brand-mark { flex: none; width: var(--uis-icon); height: var(--uis-icon); color: var(--accent); }
.brand-subtitle { font-size: var(--uis-font-small); color: var(--muted); font-weight: 400; margin-top: .12rem; }
.theme-control { position: relative; flex: none; }
#theme { display: flex; align-items: center; gap: .42rem; padding-inline: .6rem; color: var(--accent); }
#theme-icon, .theme-menu button { display: flex; align-items: center; }
.theme-control svg { flex: none; width: 20px; height: 20px; }
.theme-chevron { display: block; width: 6px; height: 6px; border: solid currentColor; border-width: 0 1.5px 1.5px 0; transform: translateY(-2px) rotate(45deg); }
.theme-menu { position: absolute; z-index: 3; right: 0; top: calc(100% + 6px); min-width: 177px; padding: 4px; border: 1px solid var(--line); border-radius: var(--uis-radius-md); background: var(--paper); box-shadow: 0 8px 30px #11131a26; }
.theme-menu button { gap: .5rem; width: 100%; text-align: left; border-color: transparent; font-size: .88rem; }
.theme-menu button[aria-checked="true"] { color: var(--accent); background: var(--soft); }
.theme-menu button[aria-checked="true"]::after { content: "✓"; margin-left: auto; }
.hero { display: flex; justify-content: space-between; gap: 1rem; align-items: end; padding-block: clamp(1rem, 3.3vw, 2rem); }
.hero p { color: var(--muted); margin-top: .5rem; }
.order-link { flex-shrink: 0; font-size: var(--uis-font-small); padding-block: .3rem; }

.toolbar { display: flex; align-items: center; justify-content: space-between; gap: .6rem; margin-block: 1.25rem 1rem; }
.mode { display: inline-grid; grid-auto-flow: column; gap: .25rem; padding: 4px; border: 1px solid var(--line); border-radius: 12px; background: var(--soft); }
.mode button { border-color: transparent; background: transparent; font-size: .92rem; }
.mode button[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); }
.outline { color: var(--accent); white-space: nowrap; font-size: .92rem; }
.workspace { display: grid; gap: 1.1rem; grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); align-items: start; }
.work, .results, #advice { display: grid; gap: 1rem; min-width: 0; }
.card { min-width: 0; padding: clamp(.8rem, 2vw, 1.35rem); background: var(--paper); border: 1px solid var(--line); border-radius: var(--uis-radius-lg); box-shadow: var(--shadow); }
.section-heading { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .35rem .65rem; margin-bottom: .9rem; }
.group-label { color: var(--accent); font-size: .8rem; font-weight: 650; border-radius: 6px; background: var(--soft); padding: .18rem .48rem; }
.fields { display: grid; gap: .6rem; grid-template-columns: 1fr .8fr 1.65fr; }
.hint { color: var(--muted); font-size: var(--uis-font-small); font-weight: 400; }
.profile .hint, .exercises-heading .hint { margin-top: .4rem; }
.check-controls { display: grid; gap: .65rem; }
details > summary { font-weight: 650; font-size: .88rem; padding-block: .3rem; color: var(--accent); }
details > label { margin-top: .45rem; }
.exercises-heading { padding-top: .9rem; border-top: 1px solid var(--line); margin-top: .9rem; }
#exercises { display: grid; margin-top: .25rem; }
.exercise { padding-block: .72rem; border-bottom: 1px solid var(--line); }
.exercise:last-child { border-bottom: 0; padding-bottom: 0; }
.exercise-fields { display: grid; gap: .55rem; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); align-items: start; }
.exercise-fields > label:first-child { grid-column: 1 / -1; }
.exercise-fields:has([data-entry-status][hidden]) { grid-template-columns: minmax(0, 1fr); }
.entry-note { margin-top: .37rem; color: var(--muted); font-size: .81rem; }
.entry-note[data-tone="warn"] { color: var(--warn); }
#weight-wrap { margin-top: .85rem; }
#weight { max-width: 12rem; }
.text-button { color: var(--accent); font-weight: 550; border: 0; min-height: 0; border-radius: 4px; background: transparent; text-decoration: underline; text-underline-offset: .17em; padding: .25rem 0; font-size: .86rem; }

.verdict { background: var(--soft); border-color: var(--line); }
.verdict[data-tone="warn"] { background: var(--warn-bg); }
.verdict[data-tone="bad"] { background: var(--bad-bg); }
.verdict-label { font-size: .78rem; font-weight: 700; color: var(--muted); margin-bottom: .53rem; }
#verdict-title { font-size: clamp(1.4rem, 2.5vw, 2rem); line-height: 1.12; overflow-wrap: anywhere; }
#verdict-detail { margin-top: .55rem; font-size: .94rem; }
.metrics { display: flex; flex-wrap: wrap; gap: .5rem 1.2rem; margin-top: 1rem; }
.metric { display: grid; gap: .03rem; font-size: .77rem; color: var(--muted); }
.metric strong { color: var(--ink); font-variant-numeric: tabular-nums; font-size: 1.05rem; }
.basis { font-size: .85rem; padding-top: .75rem; margin-top: .82rem; border-top: 1px solid var(--line); }
.basis p + p { margin-top: .4rem; }
.advice-card h2 { margin-bottom: .6rem; }
.advice-card h3, .advice-card label { margin-block: .65rem .35rem; }
.advice-card p + p { margin-top: .4rem; }
.choice-row { display: flex; gap: .4rem; flex-wrap: wrap; margin-block: .6rem; }
.choice-row button { font-size: .8rem; min-height: var(--uis-target); }
.choice-row button[aria-pressed="true"] { background: var(--soft); color: var(--accent); border-color: var(--accent); }
.target-list { list-style: none; padding: 0; margin: .6rem 0; display: grid; gap: .36rem; }
.target-list li { padding: .44rem .56rem; border-radius: 7px; background: var(--page); font-size: .88rem; overflow-wrap: anywhere; }
.target-list strong { color: var(--accent); }
.single-targets { padding-top: .2rem; }
.single-targets p { display: flex; justify-content: space-between; gap: .6rem; margin-top: .42rem; font-size: .88rem; }
.local-status { margin-block: .85rem 1.4rem; color: var(--muted); font-size: .8rem; }

.site-footer { border-top: 1px solid var(--line); background: var(--paper); color: var(--muted); font-size: var(--uis-font-small); }
.footer-inner { padding-block: 1rem 1.25rem; display: grid; gap: .15rem; }
.footer-title { font-size: 1rem; font-weight: 700; color: var(--ink); }
.footer-inner nav { display: flex; gap: .15rem 1.05rem; flex-wrap: wrap; }
.footer-inner nav :is(a, button) { display: inline-flex; align-items: center; min-height: var(--uis-target); padding: 0; width: fit-content; }
.news-entry + .news-entry { border-top: 1px solid var(--line); padding-top: .8rem; }
.news-entry h3 { color: var(--ink); margin-bottom: .4rem; }
.news-entry ul { margin: 0; padding-left: 1.15rem; }
#erase-confirm > p { margin-block: .3rem .55rem; }
#erase { color: var(--bad); border-color: var(--bad); }
dialog { width: min(calc(100% - 24px), 660px); max-height: 88dvh; padding: 0; border: 1px solid var(--line); border-radius: var(--uis-radius-lg); background: var(--paper); color: var(--ink); }
dialog::backdrop { background: #11131aa8; }
.dialog-head { position: sticky; top: 0; z-index: 1; background: var(--paper); border-bottom: 1px solid var(--line); padding: .7rem 1rem; display: flex; justify-content: space-between; align-items: center; gap: .5rem; }
.dialog-content { padding: 1rem; display: grid; gap: .8rem; }
.document { overflow-wrap: anywhere; }
.norm-thresholds { display: grid; grid-template-columns: repeat(auto-fit, minmax(135px, 1fr)); gap: .4rem; margin: 0; }
.norm-thresholds div { border-radius: 8px; background: var(--soft); padding: .55rem; }
.norm-thresholds dt { color: var(--muted); font-size: .8rem; }
.norm-thresholds dd { margin: 0; font-weight: 700; }
.exercise-rules { margin-block: .65rem; color: var(--muted); font-size: var(--uis-font-small); }
.table-scroll { max-height: 260px; overflow: auto; margin-top: .5rem; border-radius: 8px; border: 1px solid var(--line); }
table { width: 100%; border-collapse: collapse; text-align: left; font-variant-numeric: tabular-nums; }
th:first-child, td:first-child { text-align: right; }
th, td { padding: .25rem .55rem; border-bottom: 1px solid var(--line); }
thead { position: sticky; top: 0; background: var(--soft); }
tr[data-conflict] { background: var(--warn-bg); }

@media (max-width: 840px) {
  .workspace { grid-template-columns: 1fr; }
  .work { display: contents; }
  .profile { grid-row: 1; }
  .exercise-section { grid-row: 2; }
  .results { display: contents; }
  .verdict { grid-row: 3; }
}
@media (max-width: 520px) {
  .hero { flex-direction: column; align-items: start; gap: .55rem; }
  .footer-inner nav { flex-direction: column; align-items: start; }
  .toolbar { align-items: stretch; flex-direction: column; }
  .mode { width: 100%; grid-template-columns: 1fr 1fr; }
  .mode button { padding: .4rem; }
  .outline { align-self: start; min-height: var(--uis-target); }
  .fields { grid-template-columns: 1fr 1fr; }
  .fields label:last-child { grid-column: 1 / -1; }
  .exercise-fields { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
}


@media print {
  .top-bar, .order-link, .toolbar, .site-footer, button, .local-status, dialog { display: none !important; }
  .workspace { display: block; }
  .card { background: white; break-inside: avoid; box-shadow: none; margin-bottom: 12px; }
}
