:root {
  --navy: #0d2244;
  --navy-soft: #34425a;
  --forest: #0b5138;
  --forest-dark: #073d2b;
  --mint: #eef5f1;
  --rust: #ad4d32;
  --rust-soft: #ca765d;
  --paper: #fffdf8;
  --canvas: #f2f5f3;
  --line: #cbd2d0;
  --line-warm: #dfd5c2;
  --muted: #667079;
  --white: #ffffff;
  --danger: #8f2f27;
  --serif: Georgia, "Times New Roman", serif;
  --sans: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --shadow: 0 18px 55px rgba(20, 39, 50, 0.09);
}

* { box-sizing: border-box; }

html { color-scheme: light; scroll-behavior: smooth; }

body {
  min-width: 320px;
  margin: 0;
  color: var(--navy);
  background: var(--canvas);
  font-family: var(--sans);
  line-height: 1.5;
}

button, textarea, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }

.skip-link {
  position: fixed;
  z-index: 100;
  top: 8px;
  left: 8px;
  padding: 10px 14px;
  color: white;
  background: var(--forest);
  opacity: 0;
  pointer-events: none;
  transform: translateY(-150%);
}
.skip-link:focus { opacity: 1; pointer-events: auto; transform: translateY(0); }

.site-header {
  min-height: 92px;
  padding: 18px clamp(22px, 3vw, 52px);
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.76);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.brand { color: var(--navy); text-decoration: none; display: flex; align-items: baseline; gap: 36px; }
.brand-primary { font: 34px/1 var(--serif); letter-spacing: 0.025em; }
.brand-primary strong { font-weight: 700; }
.brand-context { color: var(--navy-soft); font-size: 16px; }
.brand-context i, .direct-test i { display: inline-block; width: 4px; height: 4px; margin: 0 7px 3px; border-radius: 50%; background: currentColor; }

.header-link, .site-footer button {
  padding: 4px;
  border: 0;
  background: transparent;
  cursor: pointer;
  font: 17px var(--serif);
}
.header-link:hover, .site-footer button:hover, .site-footer a:hover { color: var(--rust); }

main { min-height: calc(100vh - 166px); }

.start-screen {
  width: min(1420px, 100%);
  min-height: calc(100vh - 166px);
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(360px, 0.9fr);
  background: rgba(255, 255, 255, 0.68);
}

.start-input { padding: clamp(42px, 5vw, 74px) clamp(30px, 6vw, 96px); }
.start-guide { position: relative; padding: clamp(42px, 5vw, 74px) clamp(30px, 5vw, 74px); border-left: 1px solid var(--line); overflow: hidden; }

.eyebrow {
  margin: 0 0 12px;
  color: var(--forest);
  font-size: 12px;
  font-weight: 750;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

h1, h2, h3 { margin-top: 0; font-family: var(--serif); font-weight: 500; }
.start-input h1 { max-width: 760px; margin-bottom: 8px; font-size: clamp(40px, 4.3vw, 64px); line-height: 1.06; letter-spacing: -0.025em; }
.lead { margin: 0 0 30px; color: var(--navy-soft); font-size: 19px; }

label { display: block; margin: 20px 0 8px; font-weight: 700; }
textarea {
  width: 100%;
  padding: 14px 16px;
  resize: vertical;
  color: var(--navy);
  border: 1px solid #aeb8bc;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.78);
  outline: none;
}
textarea:focus, select:focus, button:focus-visible, a:focus-visible, input:focus-visible {
  outline: 3px solid rgba(11, 81, 56, 0.22);
  outline-offset: 2px;
  border-color: var(--forest);
}

.button {
  min-height: 50px;
  padding: 12px 20px;
  border: 1px solid transparent;
  border-radius: 5px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  cursor: pointer;
  text-decoration: none;
  font-family: var(--serif);
  font-size: 18px;
  transition: background 150ms ease, color 150ms ease, transform 150ms ease;
}
.button:hover { transform: translateY(-1px); }
.button:disabled { opacity: 0.56; cursor: wait; transform: none; }
.button-full { width: 100%; }
.button-primary { color: white; background: var(--forest); }
.button-primary:hover { background: var(--forest-dark); }
.button-secondary { color: var(--navy); border-color: var(--navy); background: white; }
.button-secondary:hover { color: white; background: var(--navy); }
.button-outline-rust { color: var(--rust); border-color: var(--rust); background: transparent; }
.button-outline-rust:hover { color: white; background: var(--rust); }

#context-form .button { margin-top: 22px; }
.or-divider { margin: 24px 0; display: flex; align-items: center; gap: 24px; color: var(--muted); font-family: var(--serif); font-size: 20px; }
.or-divider::before, .or-divider::after { height: 1px; background: var(--line); content: ""; flex: 1; }

.upload-button { min-height: 58px; margin: 0; padding: 13px 20px; border: 2px solid var(--forest); border-radius: 5px; display: flex; align-items: center; justify-content: center; gap: 14px; cursor: pointer; color: var(--forest); font: 20px var(--serif); }
.upload-button:hover { background: var(--mint); }
.upload-icon { font: 30px/1 var(--sans); }
.privacy-note { margin: 14px 0 0; text-align: center; color: var(--muted); font-size: 13px; }
.inline-status { min-height: 22px; margin-top: 8px; color: var(--forest); text-align: center; font-size: 13px; }
.inline-status.error { color: var(--danger); }
.visually-hidden { position: absolute !important; width: 1px !important; height: 1px !important; padding: 0 !important; margin: -1px !important; overflow: hidden !important; clip: rect(0,0,0,0) !important; white-space: nowrap !important; border: 0 !important; }

.start-guide h2 { margin-bottom: 26px; font-size: 28px; }
.journey-list { margin: 0; padding: 0; list-style: none; }
.journey-list li { position: relative; min-height: 74px; display: grid; grid-template-columns: 44px 1fr; gap: 18px; }
.journey-list li:not(:last-child)::after { position: absolute; top: 38px; bottom: 0; left: 20px; width: 1px; border-left: 1px dashed #99a4a6; content: ""; }
.journey-list li > span { z-index: 1; width: 40px; height: 40px; border: 1px solid #98a3a7; border-radius: 50%; display: grid; place-items: center; background: #f8faf9; font: 20px var(--serif); }
.journey-list li.active > span { color: white; border-color: var(--forest); background: var(--forest); }
.journey-list strong { color: var(--forest-dark); font: 21px var(--serif); }
.journey-list p { margin: 2px 0 18px; color: var(--navy-soft); font-size: 14px; }
.direct-test { margin-top: 28px; padding-top: 30px; border-top: 1px solid var(--line); }
.direct-test h3 { margin-bottom: 5px; color: var(--rust); font-size: 34px; }
.direct-test > p:not(.eyebrow) { color: var(--muted); }
.direct-test .button { margin-top: 12px; }
.botanical { position: absolute; right: 38px; top: 24px; color: #adb6ad; font: 90px var(--serif); opacity: 0.35; transform: rotate(-22deg); }

.learning-screen {
  min-height: calc(100vh - 92px);
  display: grid;
  grid-template-columns: 240px minmax(520px, 1fr) 340px;
  grid-template-rows: 1fr 64px;
  background: rgba(255,255,255,.72);
}
.learning-path { grid-row: 1; padding: 38px 30px; border-right: 1px solid var(--line); background: rgba(255,255,255,.54); }
.learning-path h2, .coach-panel h2 { margin-bottom: 30px; font-size: 28px; }
.learning-path ol { margin: 0; padding: 0; list-style: none; }
.learning-path li { position: relative; min-height: 96px; display: grid; grid-template-columns: 44px 1fr; gap: 14px; align-items: start; color: var(--muted); }
.learning-path li:not(:last-child)::after { position: absolute; top: 42px; bottom: 4px; left: 20px; border-left: 1px solid #aeb6b5; content: ""; }
.learning-path .path-number { z-index: 1; width: 40px; height: 40px; border: 1px solid #9aa5a7; border-radius: 50%; display: grid; place-items: center; background: #f8faf9; font: 20px var(--serif); }
.learning-path .path-label { padding-top: 7px; font-size: 16px; font-weight: 650; }
.learning-path li.active { color: var(--forest); }
.learning-path li.active .path-number { color: white; border-color: var(--forest); background: var(--forest); box-shadow: 0 0 0 6px rgba(11,81,56,.08); }
.learning-path li.done { color: var(--navy); }
.learning-path li.done .path-number { border-color: var(--forest); }
.text-button { padding: 6px 0; border: 0; border-bottom: 1px solid currentColor; color: var(--muted); background: transparent; cursor: pointer; }
.restart-button { margin-top: 18px; }

.task-shell { grid-column: 2; grid-row: 1; min-width: 0; padding: 22px 18px; background: #f6f8f7; }
.task-paper { min-height: 100%; max-width: 900px; margin: 0 auto; padding: clamp(34px, 5vw, 68px); border: 1px solid var(--line-warm); border-radius: 22px; background: var(--paper); box-shadow: inset 0 0 0 8px rgba(232,224,207,.24), var(--shadow); }
.task-paper h1 { max-width: 780px; margin-bottom: 12px; font-size: clamp(36px, 4vw, 54px); line-height: 1.08; letter-spacing: -.025em; }
.task-paper h1:focus { outline: none; }
.task-instruction { max-width: 720px; margin: 0; color: var(--navy-soft); font: 19px/1.5 var(--serif); }
.ornament-rule { margin: 26px 0 30px; display: flex; align-items: center; gap: 12px; color: #bcae8f; }
.ornament-rule::before, .ornament-rule::after { height: 1px; background: var(--line-warm); content: ""; flex: 1; }
.ornament-rule span { font-size: 13px; }

.task-actions { margin-top: 32px; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.option-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.text-option, .feature-option, .choice-option, .segment-option {
  position: relative;
  display: block;
  margin: 0;
  cursor: pointer;
}
.text-option input, .feature-option input, .choice-option input, .segment-option input { position: absolute; opacity: 0; pointer-events: none; }
.text-option > span { min-height: 152px; padding: 20px; border: 1px solid var(--line); border-radius: 8px; display: block; background: white; }
.text-option strong { display: block; margin-bottom: 10px; color: var(--rust); font: 20px var(--serif); }
.text-option input:checked + span, .feature-option input:checked + span, .choice-option input:checked + span { border-color: var(--forest); background: var(--mint); box-shadow: 0 0 0 2px rgba(11,81,56,.09); }
.feature-group { margin-top: 24px; }
.field-title { display: block; margin-bottom: 10px; color: var(--navy); font-weight: 750; }
.feature-options, .choice-options { display: flex; flex-wrap: wrap; gap: 10px; }
.feature-option > span, .choice-option > span { padding: 10px 14px; border: 1px solid var(--line); border-radius: 999px; display: block; background: white; font-weight: 600; }

.source-label { margin: 0 0 14px; color: var(--muted); font-size: 12px; letter-spacing: .06em; text-transform: uppercase; }
.segment-text { padding: 22px; border-left: 3px solid var(--line-warm); background: rgba(255,255,255,.55); font: 22px/1.9 var(--serif); }
.segment-option { display: inline; }
.segment-option > span { padding: 3px 4px; border-radius: 4px; transition: background 120ms ease, color 120ms ease; }
.segment-option:hover > span { background: #f3e5df; }
.segment-option input:checked + span { color: white; background: var(--rust-soft); box-shadow: 0 0 0 2px var(--rust-soft); }

.claim-card { margin: 0 0 22px; padding: 24px; border-left: 4px solid var(--rust); background: #f8ede8; font: 23px/1.45 var(--serif); }
.reason-field { margin-top: 22px; }
.reason-field textarea { min-height: 110px; }

.matching-grid { display: grid; gap: 14px; }
.matching-row { padding: 16px; border: 1px solid var(--line); border-radius: 7px; display: grid; grid-template-columns: minmax(150px,.65fr) minmax(220px,1.35fr); gap: 16px; align-items: center; background: white; }
.matching-row label { margin: 0; font-family: var(--serif); font-size: 19px; }
select { width: 100%; min-height: 46px; padding: 9px 36px 9px 12px; border: 1px solid #aeb8bc; border-radius: 4px; color: var(--navy); background: white; }

.writing-area { min-height: 230px; font: 20px/1.6 var(--serif); }
.word-counter { margin: 6px 0 0; color: var(--muted); text-align: right; font-size: 13px; }
.form-error { margin: 16px 0 0; padding: 10px 13px; border-left: 3px solid var(--danger); color: var(--danger); background: #fbefed; }

.feedback-card { margin-top: 28px; padding: 24px; border: 1px solid #a9c8ba; border-radius: 9px; background: var(--mint); }
.feedback-card.retry { border-color: #d6b08f; background: #fff6eb; }
.feedback-kicker { margin: 0 0 5px; color: var(--forest); font-size: 12px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.feedback-card p:not(.feedback-kicker) { margin: 0 0 18px; font-size: 17px; }

.coach-panel { grid-column: 3; grid-row: 1; padding: 38px 22px 24px; border-left: 1px solid var(--line); display: flex; flex-direction: column; justify-content: space-between; gap: 28px; background: rgba(255,255,255,.56); }
.coach-panel h2 { padding-bottom: 16px; border-bottom: 1px solid #899495; }
.coach-panel h2 span { color: #798578; }
.coach-message { padding: 22px; border: 1px solid #c9ddd4; border-radius: 10px; color: var(--navy-soft); background: var(--mint); font-size: 16px; line-height: 1.65; }
.coach-form { position: relative; }
.coach-form textarea { min-height: 118px; padding-right: 62px; border: 2px solid var(--forest); border-radius: 10px; background: white; }
.coach-form button { position: absolute; right: 12px; bottom: 13px; width: 42px; height: 42px; border: 0; border-radius: 6px; color: white; background: var(--forest); cursor: pointer; font-size: 22px; }

.progress-footer { grid-column: 1 / -1; grid-row: 2; padding: 0 18%; border-top: 1px solid var(--line); display: grid; grid-template-columns: 1fr auto 1fr; gap: 40px; align-items: center; background: rgba(255,255,255,.86); }
.progress-footer span { height: 1px; background: #aeb6b6; }
.progress-footer p { margin: 0; font-family: var(--serif); }

.result-screen { max-width: 1180px; margin: 0 auto; padding: clamp(48px, 7vw, 90px) 28px; }
.result-intro { max-width: 730px; }
.result-intro h1 { margin-bottom: 10px; font-size: clamp(44px, 6vw, 72px); letter-spacing: -.03em; }
.result-intro > p:last-child { color: var(--navy-soft); font-size: 19px; }
.result-grid { margin: 46px 0 28px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.result-card { padding: 26px; border-top: 4px solid var(--forest); background: white; box-shadow: var(--shadow); }
.result-card h2 { margin-bottom: 4px; font-size: 29px; }
.result-level { color: var(--rust); font: 21px var(--serif); }
.meter { height: 6px; margin: 18px 0; overflow: hidden; background: #e1e7e4; }
.meter span { height: 100%; display: block; background: var(--forest); }
.result-card p:last-child { color: var(--navy-soft); }
.next-step-card { padding: 28px; border: 1px solid var(--line-warm); background: var(--paper); }
.next-step-card h2 { margin-bottom: 7px; font-size: 31px; }
.next-step-card p:last-child { margin-bottom: 0; }
.result-actions { margin-top: 26px; display: flex; gap: 14px; }

.site-footer { min-height: 74px; padding: 18px clamp(22px,3vw,52px); border-top: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 24px; color: var(--muted); background: rgba(255,255,255,.82); font-family: var(--serif); }
.site-footer p { margin: 0; }
.site-footer p span { display: inline-block; width: 1px; height: 18px; margin: 0 24px -4px; background: var(--line); }
.site-footer nav { display: flex; align-items: center; gap: 22px; }
.site-footer a { color: inherit; text-decoration: none; }

dialog { width: min(620px, calc(100% - 32px)); padding: 34px; border: 1px solid var(--line); border-radius: 10px; color: var(--navy); background: var(--paper); box-shadow: 0 25px 90px rgba(13,34,68,.25); }
dialog::backdrop { background: rgba(13,34,68,.48); }
dialog h2 { font-size: 34px; }
.dialog-close { float: right; width: 38px; height: 38px; border: 1px solid var(--line); border-radius: 50%; background: white; cursor: pointer; font-size: 24px; }

[hidden] { display: none !important; }

@media (max-width: 1080px) {
  .brand { gap: 18px; }
  .brand-context { font-size: 14px; }
  .learning-screen { grid-template-columns: 180px minmax(480px,1fr); }
  .coach-panel { grid-column: 1 / -1; grid-row: 2; padding: 24px; border-top: 1px solid var(--line); border-left: 0; display: grid; grid-template-columns: 1fr 1fr; }
  .progress-footer { grid-row: 3; }
}

@media (max-width: 780px) {
  .site-header { min-height: 78px; padding: 14px 18px; }
  .brand { display: block; }
  .brand-primary { display: block; font-size: 25px; }
  .brand-context { display: block; margin-top: 4px; font-size: 11px; }
  .header-link { font-size: 15px; }
  .start-screen { display: block; }
  .start-input, .start-guide { padding: 40px 22px; }
  .start-guide { border-top: 1px solid var(--line); border-left: 0; }
  .start-input h1 { font-size: 42px; }
  .learning-screen { display: block; }
  .learning-path { padding: 14px 18px; border-right: 0; border-bottom: 1px solid var(--line); }
  .learning-path h2, .restart-button { display: none; }
  .learning-path ol { display: grid; grid-template-columns: repeat(5,1fr); }
  .learning-path li { min-height: 55px; display: block; text-align: center; }
  .learning-path li:not(:last-child)::after { top: 19px; bottom: auto; left: calc(50% + 20px); width: calc(100% - 40px); border-top: 1px solid #aeb6b5; border-left: 0; }
  .learning-path .path-number { margin: 0 auto; }
  .learning-path .path-label { display: none; }
  .task-shell { padding: 12px; }
  .task-paper { padding: 32px 20px; border-radius: 13px; }
  .task-paper h1 { font-size: 38px; }
  .option-grid, .result-grid { grid-template-columns: 1fr; }
  .text-option > span { min-height: auto; }
  .matching-row { grid-template-columns: 1fr; gap: 8px; }
  .task-actions { align-items: stretch; flex-direction: column-reverse; }
  .coach-panel { padding: 28px 20px; display: block; border-top: 1px solid var(--line); }
  .coach-form { margin-top: 18px; }
  .progress-footer { padding: 18px; display: flex; justify-content: center; }
  .progress-footer span { display: none; }
  .result-screen { padding: 48px 20px; }
  .result-actions { flex-direction: column; }
  .site-footer { align-items: flex-start; flex-direction: column; }
  .site-footer p span { display: none; }
  .site-footer p strong { display: block; }
  .site-footer nav { width: 100%; justify-content: space-between; gap: 10px; }
  .site-footer button { padding-left: 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
