:root {
  color-scheme: light;
  --ink: #133330;
  --ink-soft: #49615e;
  --paper: #f4f7f4;
  --white: #ffffff;
  --line: #c8d6d2;
  --sage: #dce9e4;
  --teal: #1f6b63;
  --amber: #c66b33;
  --red: #a33b3b;
  --blue: #245d75;
  --shadow: 0 18px 50px rgba(19, 51, 48, 0.08);
  font-family: Aptos, "Avenir Next", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background:
    linear-gradient(90deg, transparent 49.96%, rgba(31, 107, 99, 0.045) 50%, transparent 50.04%),
    var(--paper);
}

button, input, select, textarea { font: inherit; }
button, select { cursor: pointer; }

.masthead {
  min-height: 82px;
  padding: 18px clamp(22px, 5vw, 76px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  background: rgba(244, 247, 244, 0.94);
}

.identity { display: flex; align-items: center; gap: 12px; color: inherit; text-decoration: none; }
.identity strong { display: block; font-size: 1.05rem; letter-spacing: 0.03em; }
.identity small { display: block; margin-top: 2px; color: var(--ink-soft); font-size: 0.73rem; }
.identity-mark { position: relative; width: 36px; height: 36px; border: 1px solid var(--teal); border-radius: 50%; }
.identity-mark i { position: absolute; inset: 16px 7px auto; height: 3px; background: var(--teal); }
.identity-mark i:last-child { transform: rotate(90deg); }
.environment { display: flex; align-items: center; gap: 8px; color: var(--ink-soft); font-size: 0.78rem; }
.environment span { width: 8px; height: 8px; border-radius: 50%; background: #3d8f62; box-shadow: 0 0 0 4px #dcebdd; }

main { width: min(1420px, 100%); margin: 0 auto; padding: 0 clamp(22px, 5vw, 76px) 50px; }
.intro { min-height: 250px; padding: 48px 0 42px; display: grid; grid-template-columns: 1.15fr 0.85fr; align-items: end; gap: 8vw; }
.context, .step { margin: 0 0 12px; color: var(--teal); font-size: 0.76rem; font-weight: 700; letter-spacing: 0.045em; }
h1 { margin: 0; max-width: 740px; font-size: clamp(2.25rem, 5vw, 4.6rem); line-height: 0.98; letter-spacing: -0.055em; font-weight: 690; }
.intro-copy { margin: 0; max-width: 560px; color: var(--ink-soft); font-size: 1.02rem; line-height: 1.65; }

.workspace { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(390px, 0.95fr); border: 1px solid var(--line); background: var(--white); box-shadow: var(--shadow); }
.intake-panel, .result-panel { min-width: 0; padding: clamp(24px, 3.5vw, 48px); }
.intake-panel { border-right: 1px solid var(--line); }
.result-panel { position: relative; background: #f9fbf9; }
.section-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; margin-bottom: 28px; }
h2 { margin: 0; font-size: clamp(1.35rem, 2vw, 2rem); letter-spacing: -0.025em; }

.language-switch { display: flex; border: 1px solid var(--line); }
.language { min-width: 44px; padding: 8px 10px; border: 0; background: transparent; color: var(--ink-soft); }
.language + .language { border-left: 1px solid var(--line); }
.language.active { background: var(--ink); color: white; }

.presets { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 26px; }
.preset { padding: 14px 16px; text-align: left; color: var(--ink); border: 1px solid var(--line); background: white; }
.preset span, .preset small { display: block; }
.preset span { font-weight: 650; }
.preset small { margin-top: 4px; color: var(--ink-soft); }
.preset.active { border-color: var(--teal); box-shadow: inset 4px 0 0 var(--teal); background: #f7fbf9; }

form { display: grid; gap: 19px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
label { display: grid; gap: 7px; color: var(--ink); font-size: 0.85rem; font-weight: 650; }
label small { color: var(--ink-soft); font-weight: 400; }
input, select, textarea { width: 100%; padding: 11px 12px; color: var(--ink); border: 1px solid var(--line); border-radius: 0; background: #fbfcfb; outline: none; }
textarea { resize: vertical; line-height: 1.45; }
input:focus, select:focus, textarea:focus, button:focus-visible, summary:focus-visible, a:focus-visible { outline: 3px solid rgba(36, 93, 117, 0.25); outline-offset: 2px; border-color: var(--blue); }

details { border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 14px 0; }
summary { cursor: pointer; font-weight: 650; }
.details-grid { display: grid; gap: 16px; padding-top: 18px; }
.vitals { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.vitals label { position: relative; }
.vitals small { position: absolute; right: 10px; bottom: 12px; }
.vitals input { padding-right: 42px; }

.access-block { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: 14px; padding-top: 4px; }
#submit { min-height: 66px; padding: 0 22px; border: 0; background: var(--ink); color: white; font-weight: 700; }
#submit:hover { background: var(--teal); }
#submit[disabled] { cursor: wait; opacity: 0.72; }
.button-state { display: none; width: 13px; height: 13px; margin-left: 9px; border: 2px solid rgba(255,255,255,.4); border-top-color: white; border-radius: 50%; animation: spin .8s linear infinite; }
#submit[disabled] .button-state { display: inline-block; }
.form-error { margin: 0; padding: 12px 14px; color: #752e2e; border-left: 4px solid var(--red); background: #faecec; }

.status { padding: 7px 10px; border: 1px solid var(--line); color: var(--ink-soft); font-size: 0.76rem; font-weight: 700; }
.status.ready { color: #225a3b; border-color: #95b9a5; background: #edf6f0; }
.status.error { color: #7b2e2e; border-color: #d7a1a1; background: #faeeee; }
.empty-result { min-height: 520px; display: grid; place-content: center; justify-items: center; gap: 26px; text-align: center; color: var(--ink-soft); }
.empty-result p { max-width: 360px; line-height: 1.6; }
.pulse { display: flex; align-items: center; gap: 4px; width: 172px; height: 54px; }
.pulse::before, .pulse::after, .pulse span { content: ""; display: block; height: 2px; background: var(--teal); }
.pulse::before { width: 32px; }
.pulse::after { flex: 1; }
.pulse span:nth-child(1) { width: 18px; transform: rotate(-58deg); }
.pulse span:nth-child(2) { width: 30px; transform: rotate(68deg); }
.pulse span:nth-child(3) { width: 18px; transform: rotate(-54deg); }

.result { display: grid; gap: 25px; }
.priority { padding: 18px 20px; border-left: 8px solid var(--amber); background: #f6ede6; }
.priority.maximum { border-color: var(--red); background: #faebeb; }
.priority.deferred { border-color: var(--blue); background: #eaf2f5; }
.priority span { display: block; color: var(--ink-soft); font-size: 0.78rem; }
.priority strong { display: block; margin-top: 3px; font-size: clamp(1.6rem, 3vw, 2.5rem); letter-spacing: -0.035em; text-transform: capitalize; }
.summary { margin: 0; font-size: 1.12rem; line-height: 1.55; }
.result-section { padding-top: 20px; border-top: 1px solid var(--line); }
.result-section h3 { margin: 0 0 10px; font-size: 0.9rem; }
.result-section ul { margin: 0; padding-left: 19px; color: var(--ink-soft); line-height: 1.55; }
.result-section li + li { margin-top: 7px; }
.alert { padding: 16px; border: 1px solid #e5b5b5; background: #fff5f5; }
.alert h3 { color: var(--red); }
.trace { display: grid; grid-template-columns: 0.7fr 1.3fr 1fr; border: 1px solid var(--line); }
.trace div { min-width: 0; padding: 12px; }
.trace div + div { border-left: 1px solid var(--line); }
.trace span, .trace strong { display: block; }
.trace span { color: var(--ink-soft); font-size: 0.7rem; }
.trace strong { margin-top: 5px; overflow: hidden; text-overflow: ellipsis; font-size: 0.78rem; white-space: nowrap; }
.safety { margin: 0; padding: 15px 17px; color: #60441d; border-left: 4px solid var(--amber); background: #fff7e8; line-height: 1.5; }
.follow-up { padding-top: 22px; border-top: 1px solid var(--line); }
.follow-up-heading { display: grid; gap: 4px; margin-bottom: 16px; }
.follow-up-heading span { color: var(--teal); font-size: 0.74rem; font-weight: 700; }
.follow-up-heading strong { font-size: 1.03rem; }
#guided-questions { display: grid; gap: 15px; }
.guided-question { padding: 16px; border: 1px solid var(--line); background: white; }
.guided-question > label > span { font-size: 0.93rem; line-height: 1.45; }
.guided-actions { display: flex; gap: 14px; margin-top: 10px; color: var(--ink-soft); font-size: 0.76rem; }
.guided-actions label { display: flex; grid-template-columns: auto 1fr; align-items: center; gap: 6px; font-size: inherit; font-weight: 500; }
.guided-actions input { width: auto; }
#follow-up-submit { min-height: 48px; padding: 0 18px; border: 1px solid var(--ink); background: white; color: var(--ink); font-weight: 700; }
#follow-up-submit:hover { background: var(--ink); color: white; }
#follow-up-submit[disabled] { cursor: wait; opacity: 0.6; }

footer { width: min(1420px, 100%); margin: 0 auto; padding: 24px clamp(22px, 5vw, 76px) 44px; display: flex; justify-content: space-between; color: var(--ink-soft); font-size: 0.76rem; }
footer a { color: var(--teal); }

@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .button-state { animation: none; } }

@media (max-width: 900px) {
  body { background: var(--paper); }
  .intro { min-height: auto; grid-template-columns: 1fr; gap: 24px; }
  .workspace { grid-template-columns: 1fr; }
  .intake-panel { border-right: 0; border-bottom: 1px solid var(--line); }
  .empty-result { min-height: 300px; }
}

@media (max-width: 600px) {
  .masthead { align-items: flex-start; }
  .identity small, .environment { display: none; }
  .field-row, .presets, .access-block { grid-template-columns: 1fr; }
  .vitals { grid-template-columns: 1fr 1fr; }
  #submit { min-height: 52px; }
  .trace { grid-template-columns: 1fr; }
  .trace div + div { border-left: 0; border-top: 1px solid var(--line); }
  footer { display: grid; gap: 10px; }
}
