:root {
  color-scheme: light;
  --ink: #15343a;
  --muted: #667f84;
  --line: #d8e5e6;
  --soft: #f2f8f7;
  --soft-2: #e6f3f0;
  --brand: #087f72;
  --brand-dark: #086a62;
  --brand-pale: #dff2ee;
  --warning: #925c08;
  --warning-bg: #fff4da;
  --danger: #b33a45;
  --danger-bg: #fff0f1;
  --white: #fff;
  --shadow: 0 18px 50px rgba(26, 65, 69, .09);
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
html { min-width: 320px; background: #edf4f3; }
body { min-height: 100dvh; margin: 0; color: var(--ink); background: #f7faf9; }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }

.topbar {
  height: 76px;
  padding: 0 clamp(18px, 4vw, 58px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  background: rgba(255, 255, 255, .96);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(14px);
}

.brand { display: inline-flex; align-items: center; gap: 12px; color: var(--ink); text-decoration: none; }
.brand-mark, .doctor-mark {
  width: 46px;
  height: 46px;
  display: inline-grid;
  place-items: center;
  border-radius: 15px;
  color: #fff;
  background: linear-gradient(145deg, #0d9384, #057267);
  box-shadow: 0 9px 22px rgba(8, 127, 114, .2);
  font-size: 24px;
  font-weight: 800;
}
.brand strong { display: block; font-size: 20px; letter-spacing: .01em; }
.brand small { display: block; margin-top: 2px; color: var(--muted); font-size: 12px; }
.top-actions { display: flex; align-items: center; gap: 12px; }
.secure-badge { padding: 8px 12px; border-radius: 99px; color: var(--brand-dark); background: var(--brand-pale); font-size: 13px; font-weight: 700; }
.secure-badge span { font-size: 9px; }
.quiet-button, .text-button { min-height: 42px; border: 0; color: var(--muted); background: transparent; font-weight: 700; }
.quiet-button:hover, .text-button:hover { color: var(--brand); }

.prototype-notice {
  padding: 10px clamp(18px, 4vw, 58px);
  color: var(--warning);
  background: var(--warning-bg);
  border-bottom: 1px solid #f0d99f;
  font-size: 13px;
  line-height: 1.55;
}

.app-shell {
  min-height: calc(100dvh - 120px);
  display: grid;
  grid-template-columns: 220px minmax(440px, 1fr) minmax(300px, 390px);
  max-width: 1680px;
  margin: 0 auto;
}

.progress-panel, .summary-panel { padding: 30px 24px; background: #f1f7f6; }
.progress-panel { border-right: 1px solid var(--line); }
.summary-panel { border-left: 1px solid var(--line); background: #fff; }
.progress-title-row, .summary-header, .section-heading { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.progress-title-row h2, .summary-header h2, .section-heading h2 { margin: 0; font-size: 17px; }
.progress-title-row strong { color: var(--muted); }
.progress-track { height: 8px; margin: 15px 0 25px; border-radius: 99px; overflow: hidden; background: #d9e6e5; }
.progress-track span { display: block; width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #10a493, var(--brand)); transition: width .28s ease; }
.section-progress { display: grid; gap: 9px; margin: 0; padding: 0; list-style: none; }
.section-progress li { display: grid; grid-template-columns: 34px 1fr auto; align-items: center; gap: 10px; min-height: 52px; padding: 7px 8px; border-radius: 13px; color: var(--muted); }
.section-progress li.active { color: var(--ink); background: #fff; box-shadow: 0 7px 22px rgba(40, 82, 84, .07); }
.section-progress .number { width: 32px; height: 32px; display: grid; place-items: center; border-radius: 50%; background: #dfe9e8; font-size: 13px; font-weight: 800; }
.section-progress li.active .number, .section-progress li.complete .number { color: #fff; background: var(--brand); }
.section-progress .label { font-weight: 700; }
.section-progress .count { font-size: 12px; }
.privacy-note { display: grid; gap: 5px; margin-top: 30px; padding: 16px; border: 1px solid var(--line); border-radius: 16px; background: rgba(255,255,255,.8); font-size: 12px; line-height: 1.5; }
.privacy-note span { color: var(--muted); }

.interview-panel { min-width: 0; padding: 38px clamp(24px, 4vw, 64px) 60px; background: radial-gradient(circle at 50% 2%, #edf8f5 0, #f7faf9 42%, #f7faf9 100%); }
.welcome-card, .question-card, .waiting-card, .retry-card, .complete-card {
  max-width: 820px;
  margin: 24px auto 0;
  padding: clamp(28px, 5vw, 58px);
  border: 1px solid rgba(217, 230, 229, .9);
  border-radius: 28px;
  background: rgba(255,255,255,.96);
  box-shadow: var(--shadow);
}
.welcome-card, .waiting-card, .retry-card, .complete-card { text-align: center; }
.welcome-card h1, .question-card h1, .waiting-card h1, .retry-card h1, .complete-card h1 { margin: 13px 0; font-size: clamp(26px, 3vw, 40px); line-height: 1.25; letter-spacing: -.025em; }
.welcome-card > p:not(.eyebrow), .waiting-card > p:not(.eyebrow), .retry-card > p, .complete-card > p:not(.eyebrow) { max-width: 620px; margin: 0 auto 26px; color: var(--muted); line-height: 1.8; }
.eyebrow { margin: 16px 0 0; color: var(--brand); font-size: 12px; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; }
.doctor-mark.small { width: 42px; height: 42px; border-radius: 14px; font-size: 21px; }

.primary-button, .secondary-button {
  min-height: 50px;
  padding: 0 24px;
  border: 0;
  border-radius: 14px;
  font-weight: 800;
  transition: transform .16s ease, box-shadow .16s ease, background .16s ease;
}
.primary-button { color: #fff; background: var(--brand); box-shadow: 0 10px 24px rgba(8,127,114,.2); }
.primary-button:hover { background: var(--brand-dark); transform: translateY(-1px); }
.primary-button:disabled { cursor: wait; opacity: .58; transform: none; }
.secondary-button { color: var(--brand); background: var(--brand-pale); }

.question-card { padding: clamp(24px, 4vw, 46px); }
.question-meta { display: flex; justify-content: space-between; align-items: center; gap: 14px; color: var(--muted); font-size: 13px; }
.phase-label { padding: 7px 11px; border-radius: 99px; color: var(--brand-dark); background: var(--brand-pale); font-weight: 800; }
.question-card h1 { margin-top: 24px; font-size: clamp(23px, 2.5vw, 34px); }
.question-help { margin: -2px 0 24px; color: var(--muted); line-height: 1.65; }
.acknowledgement { margin: 20px 0 -7px; padding: 11px 14px; border-radius: 12px; color: var(--brand-dark); background: var(--soft-2); font-size: 14px; }

.choice-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 11px; }
.choice-option {
  min-height: 54px;
  padding: 12px 15px;
  display: flex;
  align-items: center;
  gap: 11px;
  text-align: left;
  color: var(--ink);
  background: #fff;
  border: 1px solid #cddddd;
  border-radius: 14px;
  line-height: 1.45;
}
.choice-option::before { content: ""; flex: 0 0 auto; width: 18px; height: 18px; border: 2px solid #aac0c0; border-radius: 6px; }
.single .choice-option::before { border-radius: 50%; }
.choice-option[aria-pressed="true"] { color: var(--brand-dark); border-color: var(--brand); background: #effaf7; box-shadow: inset 0 0 0 1px var(--brand); }
.choice-option[aria-pressed="true"]::before { border: 5px solid var(--brand); background: #fff; }
.multi .choice-option[aria-pressed="true"]::before { content: "✓"; display: grid; place-items: center; color: #fff; border: 0; background: var(--brand); font-size: 12px; font-weight: 900; }

.field-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(120px, .42fr); gap: 12px; }
.field { display: grid; gap: 7px; }
.field label { color: var(--muted); font-size: 13px; font-weight: 700; }
.field input, .field textarea, .field select, .search-input {
  width: 100%;
  min-height: 52px;
  padding: 12px 14px;
  color: var(--ink);
  background: #fff;
  border: 1px solid #cbdcdd;
  border-radius: 13px;
  outline: 0;
  font-size: 16px;
}
.field textarea { min-height: 112px; resize: vertical; line-height: 1.6; }
.field input:focus, .field textarea:focus, .field select:focus, .search-input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(8,127,114,.12); }
.other-toggle { min-height: 46px; margin-top: 13px; padding: 0; border: 0; color: var(--brand); background: transparent; font-weight: 800; }
.other-box { margin-top: 4px; }
.search-input { margin-bottom: 12px; }
.severity-wrap { display: grid; gap: 14px; }
.severity-value { color: var(--brand); font-size: 30px; font-weight: 900; text-align: center; }
.severity-wrap input { width: 100%; accent-color: var(--brand); }
.severity-labels { display: flex; justify-content: space-between; color: var(--muted); font-size: 12px; }
.special-actions { display: flex; flex-wrap: wrap; gap: 9px; margin-top: 18px; }
.special-action { min-height: 44px; padding: 0 14px; color: var(--muted); background: var(--soft); border: 1px solid var(--line); border-radius: 12px; font-weight: 700; }
.special-action.active { color: var(--brand-dark); border-color: var(--brand); background: var(--brand-pale); }
.form-error { margin: 14px 0 0; padding: 11px 13px; color: var(--danger); background: var(--danger-bg); border-radius: 11px; font-size: 14px; }
.submit-row { display: flex; justify-content: flex-end; margin-top: 22px; }

.waiting-pulse { display: inline-block; width: 56px; height: 56px; border: 6px solid var(--brand-pale); border-top-color: var(--brand); border-radius: 50%; animation: spin 1s linear infinite; }
.complete-mark { display: inline-grid; place-items: center; width: 58px; height: 58px; color: #fff; background: var(--brand); border-radius: 50%; font-size: 28px; }
@keyframes spin { to { transform: rotate(360deg); } }

.recent-section { max-width: 820px; margin: 34px auto 0; }
.section-heading { margin-bottom: 12px; }
.answer-history { display: grid; gap: 10px; }
.answer-item { padding: 15px 17px; border: 1px solid var(--line); border-radius: 15px; background: rgba(255,255,255,.76); }
.answer-item p { margin: 0 0 7px; color: var(--muted); font-size: 13px; line-height: 1.5; }
.answer-item div { display: flex; justify-content: space-between; gap: 14px; align-items: flex-start; }
.answer-item strong { line-height: 1.5; }
.answer-item button { min-height: 36px; flex: 0 0 auto; padding: 0 8px; border: 0; color: var(--brand); background: transparent; font-weight: 800; }

.summary-header { margin-bottom: 18px; }
.summary-header .eyebrow { margin: 0 0 5px; }
.summary-header > span { padding: 6px 9px; color: var(--brand-dark); background: var(--brand-pale); border-radius: 99px; font-size: 11px; font-weight: 800; }
.history-summary { display: grid; gap: 12px; }
.summary-card { border: 1px solid var(--line); border-radius: 17px; overflow: hidden; background: #fbfdfd; }
.summary-card button { width: 100%; min-height: 50px; padding: 0 16px; display: flex; align-items: center; justify-content: space-between; text-align: left; color: var(--ink); background: transparent; border: 0; font-weight: 800; }
.summary-card button span { color: var(--muted); font-size: 12px; }
.summary-content { padding: 0 16px 16px; }
.summary-content ul { margin: 0; padding-left: 18px; }
.summary-content li { margin-top: 7px; color: #38565b; font-size: 13px; line-height: 1.65; }
.summary-empty { margin: 0; color: #93a4a7; font-size: 13px; }
.summary-footnote { margin: 20px 4px; color: #8a9da0; font-size: 11px; line-height: 1.5; }

.toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); z-index: 50; max-width: min(90vw, 540px); padding: 12px 17px; color: #fff; background: #173f42; border-radius: 13px; box-shadow: 0 14px 40px rgba(0,0,0,.2); transform: translateX(-50%); font-size: 14px; }
.mobile-tabs { display: none; }

@media (max-width: 1180px) {
  .app-shell { grid-template-columns: 190px minmax(430px, 1fr) 330px; }
  .progress-panel, .summary-panel { padding-left: 17px; padding-right: 17px; }
  .interview-panel { padding-left: 28px; padding-right: 28px; }
}

@media (max-width: 920px) {
  .app-shell { grid-template-columns: 160px minmax(0, 1fr); }
  .summary-panel { display: none; }
  .summary-panel.mobile-visible { display: block; grid-column: 2; border-left: 0; }
  .interview-panel.mobile-hidden { display: none; }
  .mobile-tabs { position: sticky; top: 76px; z-index: 15; display: grid; grid-template-columns: 1fr 1fr; padding: 8px 18px; background: rgba(255,255,255,.96); border-bottom: 1px solid var(--line); }
  .mobile-tabs button { min-height: 42px; color: var(--muted); border: 0; border-radius: 11px; background: transparent; font-weight: 800; }
  .mobile-tabs button.active { color: var(--brand-dark); background: var(--brand-pale); }
}

@media (max-width: 680px) {
  .topbar { height: 64px; padding: 0 15px; }
  .brand-mark { width: 40px; height: 40px; border-radius: 13px; font-size: 21px; }
  .brand strong { font-size: 17px; }
  .brand small, .secure-badge { display: none; }
  .prototype-notice { padding: 9px 15px; font-size: 12px; }
  .mobile-tabs { top: 64px; }
  .app-shell { display: block; min-height: calc(100dvh - 108px); }
  .progress-panel { padding: 13px 16px; border-right: 0; border-bottom: 1px solid var(--line); }
  .progress-title-row h2, .privacy-note, .section-progress { display: none; }
  .progress-title-row { justify-content: flex-end; }
  .progress-track { height: 6px; margin: 5px 0 0; }
  .interview-panel { min-height: calc(100dvh - 190px); padding: 16px 14px calc(34px + env(safe-area-inset-bottom)); }
  .welcome-card, .question-card, .waiting-card, .retry-card, .complete-card { margin-top: 0; padding: 25px 20px; border-radius: 21px; }
  .welcome-card h1, .waiting-card h1, .retry-card h1, .complete-card h1 { font-size: 27px; }
  .question-card h1 { font-size: 24px; }
  .choice-grid { grid-template-columns: 1fr; }
  .field-row { grid-template-columns: minmax(0, 1fr) 110px; }
  .submit-row { position: sticky; bottom: 0; margin: 22px -20px -25px; padding: 12px 20px calc(12px + env(safe-area-inset-bottom)); background: rgba(255,255,255,.96); border-top: 1px solid var(--line); backdrop-filter: blur(10px); }
  .submit-row .primary-button { width: 100%; min-height: 52px; }
  .recent-section { margin-top: 24px; }
  .summary-panel, .summary-panel.mobile-visible { padding: 20px 15px calc(40px + env(safe-area-inset-bottom)); border: 0; }
  .toast { bottom: calc(16px + env(safe-area-inset-bottom)); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
