:root {
  color-scheme: light;
  --ink: #17222f;
  --muted: #5b6672;
  --line: #dce1e6;
  --paper: #f6f7f8;
  --white: #ffffff;
  --accent: #f7b21b;
  --accent-dark: #9a6200;
  --soft-accent: #fff4d5;
  --danger: #9a3412;
  --danger-soft: #fff1eb;
  --radius: 8px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--paper); color: var(--ink); min-height: 100vh; }
button, select, input { font: inherit; }

.topbar {
  min-height: 82px;
  padding: 16px clamp(18px, 4vw, 56px);
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--ink);
  color: white;
}

.brand-mark {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: var(--accent);
  color: var(--ink);
  font-weight: 900;
}

.topbar h1 { margin: 2px 0 0; font-size: 1.18rem; }
.eyebrow { margin: 0; font-size: .74rem; text-transform: uppercase; letter-spacing: .1em; font-weight: 800; color: #c9d1d9; }
.source-pill { margin-left: auto; border: 1px solid #3c4855; border-radius: 999px; padding: 8px 12px; font-size: .78rem; color: #dbe2e8; }

main { width: min(1240px, calc(100% - 40px)); margin: 0 auto; padding: 30px 0 60px; }
.intro { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(260px, .7fr); gap: 28px; align-items: end; margin-bottom: 24px; }
.intro h2 { font-size: clamp(1.8rem, 4vw, 3.6rem); max-width: 760px; margin: 8px 0 12px; line-height: 1; }
.intro > div > p:last-child { max-width: 690px; color: var(--muted); font-size: 1rem; line-height: 1.55; }
.kicker { color: var(--accent-dark); text-transform: uppercase; letter-spacing: .1em; font-weight: 800; font-size: .76rem; }
.principle { border-top: 3px solid var(--accent); padding-top: 14px; display: flex; gap: 16px; color: var(--muted); line-height: 1.45; }
.principle-number { color: var(--ink); font-weight: 900; font-size: 1.6rem; }

.workspace { display: grid; grid-template-columns: minmax(280px, 350px) minmax(0, 1fr); gap: 18px; align-items: start; }
.control-panel, .result-panel { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 12px 32px rgba(23,34,47,.06); }
.control-panel { padding: 22px; position: sticky; top: 16px; }
.panel-heading { display: flex; justify-content: space-between; align-items: center; font-weight: 850; margin-bottom: 24px; }
.step { font-size: .75rem; color: var(--muted); background: #eef1f3; padding: 6px 10px; border-radius: 999px; }
fieldset { border: 0; padding: 0; margin: 0 0 22px; }
legend, .field > span { display: block; margin-bottom: 9px; font-size: .88rem; font-weight: 800; }
.segmented { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented span { min-height: 44px; border: 1px solid var(--line); border-radius: 8px; display: grid; place-items: center; cursor: pointer; font-weight: 700; color: var(--muted); }
.segmented input:checked + span { background: var(--ink); color: white; border-color: var(--ink); }
.segmented input:focus-visible + span { outline: 3px solid rgba(247,178,27,.5); outline-offset: 2px; }
.field { display: block; margin-bottom: 22px; }
select { width: 100%; min-height: 46px; border: 1px solid var(--line); border-radius: 8px; background: white; padding: 0 42px 0 13px; color: var(--ink); }
.control-panel button[type="submit"] { width: 100%; min-height: 48px; border: 0; border-radius: 8px; background: var(--accent); color: var(--ink); font-weight: 900; cursor: pointer; box-shadow: 0 8px 18px rgba(247,178,27,.22); }
.control-panel button[type="submit"]:hover { background: #ffc037; }
.form-note { font-size: .78rem; color: var(--muted); line-height: 1.5; margin: 14px 0 0; }

.result-panel { min-height: 540px; overflow: hidden; }
.result-head { padding: 24px 28px 22px; border-bottom: 1px solid var(--line); background: linear-gradient(125deg, #fff 50%, var(--soft-accent)); }
.result-meta { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.badge { display: inline-flex; align-items: center; min-height: 28px; border-radius: 999px; padding: 5px 10px; font-size: .72rem; font-weight: 850; text-transform: uppercase; letter-spacing: .04em; background: var(--ink); color: white; }
.badge.derived { background: var(--accent); color: var(--ink); }
.badge.review { background: var(--danger-soft); color: var(--danger); }
.result-head h2 { margin: 0 0 8px; font-size: clamp(1.5rem, 3vw, 2.3rem); }
.result-head p { margin: 0; color: var(--muted); line-height: 1.5; }
.result-body { padding: 24px 28px 32px; }
.decision-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 22px; }
.decision-cell { background: #f3f5f6; border-radius: 8px; padding: 13px; }
.decision-cell small { display: block; color: var(--muted); margin-bottom: 5px; }
.decision-cell strong { font-size: .93rem; }
.notice { border-left: 4px solid var(--accent); background: var(--soft-accent); padding: 14px 16px; margin-bottom: 22px; line-height: 1.5; }
.notice.review { border-color: var(--danger); background: var(--danger-soft); }
.base-review { display: grid; grid-template-columns: 1fr auto; gap: 4px 18px; padding: 16px 18px; margin-bottom: 14px; border: 1px solid var(--line); border-radius: 8px; }
.base-review span { color: var(--muted); font-size: .82rem; font-weight: 750; }
.base-review strong { grid-row: span 2; align-self: center; font-size: 1.05rem; }
.base-review p { margin: 0; color: var(--muted); font-size: .82rem; line-height: 1.45; }
.section-title { margin: 0; font-size: 1rem; }
.exercise-heading { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin: 24px 0 12px; }
.status-legend { display: flex; flex-wrap: wrap; gap: 12px; color: var(--muted); font-size: .76rem; }
.status-legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend-swatch { width: 9px; height: 9px; border-radius: 50%; background: #d9dee3; }
.legend-swatch.changed { background: var(--accent); }
.exercise-list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.exercise-list li { min-height: 58px; display: grid; grid-template-columns: 38px minmax(0, 1fr) auto auto; gap: 10px; align-items: center; border-bottom: 1px solid var(--line); }
.exercise-list li.is-changed { background: linear-gradient(90deg, rgba(247,178,27,.10), transparent 55%); }
.index { color: #8b949e; font-variant-numeric: tabular-nums; font-size: .8rem; }
.exercise-copy { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.exercise-name { font-weight: 650; line-height: 1.35; }
.exercise-copy small { color: var(--muted); font-size: .74rem; line-height: 1.35; }
.exercise-status { white-space: nowrap; border-radius: 999px; padding: 5px 8px; font-size: .68rem; font-weight: 850; letter-spacing: .025em; }
.exercise-status.existing { background: #eef1f3; color: #59636e; }
.exercise-status.changed { background: var(--accent); color: var(--ink); }
.manual-button { border: 0; background: transparent; color: var(--accent-dark); padding: 8px; font-size: .78rem; font-weight: 800; cursor: pointer; }
.change-log { margin: 24px 0 0; padding: 18px; border-radius: 8px; background: #f3f5f6; }
.change-log h3 { margin: 0 0 10px; font-size: .95rem; }
.change-log p { margin: 0; color: var(--muted); line-height: 1.55; font-size: .88rem; }
.change-log ul { margin: 0; padding: 0; list-style: none; color: var(--muted); font-size: .88rem; }
.change-log li { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); gap: 10px; padding: 8px 0; border-top: 1px solid #dce1e6; align-items: center; }
.change-log li:first-child { border-top: 0; }
.change-log li strong { color: var(--accent-dark); }

.modal-backdrop { position: fixed; inset: 0; background: rgba(12,18,24,.66); backdrop-filter: blur(3px); z-index: 20; }
.manual-dialog { position: fixed; z-index: 21; inset: 9vh 0 auto; margin: 0 auto; width: min(680px, calc(100% - 32px)); max-height: 82vh; overflow: auto; border: 0; border-radius: 8px; padding: 28px; background: white; color: var(--ink); box-shadow: 0 30px 90px rgba(0,0,0,.3); }
.dialog-close { position: absolute; top: 14px; right: 16px; width: 38px; height: 38px; border-radius: 50%; border: 1px solid var(--line); background: white; font-size: 1.35rem; cursor: pointer; }
.manual-dialog h2 { margin: 10px 42px 18px 0; line-height: 1.15; }
.manual-dialog p:not(.eyebrow) { color: var(--muted); line-height: 1.6; }
.empty { padding: 46px 30px; color: var(--muted); }

@media (max-width: 850px) {
  .source-pill { display: none; }
  main { width: min(100% - 24px, 700px); padding-top: 24px; }
  .intro { grid-template-columns: 1fr; }
  .principle { display: none; }
  .workspace { grid-template-columns: 1fr; }
  .control-panel { position: static; }
  .decision-row { grid-template-columns: 1fr; }
  .result-head, .result-body { padding-left: 20px; padding-right: 20px; }
  .exercise-heading { align-items: flex-start; flex-direction: column; }
  .exercise-list li { grid-template-columns: 30px minmax(0, 1fr) auto; padding: 10px 0; }
  .exercise-list .manual-button { grid-column: 2; justify-self: start; padding: 2px 0 4px; }
}

@media print {
  .topbar, .intro, .control-panel, .manual-button { display: none !important; }
  body { background: white; }
  main { width: 100%; padding: 0; }
  .workspace { display: block; }
  .result-panel { box-shadow: none; border: 0; }
}
