:root {
  color-scheme: light;
  --ink: #08192e;
  --muted: #64748b;
  --soft: #e8eef5;
  --surface: rgba(255, 255, 255, 0.92);
  --surface-strong: #ffffff;
  --bg: #edf4fa;
  --navy: #071b32;
  --blue: #1769e0;
  --cyan: #2ec5ce;
  --danger: #be394d;
  --shadow: 0 28px 80px rgba(10, 42, 76, 0.14);
  --radius: 22px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --ink: #edf6ff;
  --muted: #9eb1c6;
  --soft: #243a51;
  --surface: rgba(11, 32, 54, 0.94);
  --surface-strong: #0c243d;
  --bg: #061524;
  --navy: #02101e;
  --blue: #5e9bff;
  --cyan: #4cd7d5;
  --danger: #ff8290;
  --shadow: 0 28px 80px rgba(0, 0, 0, 0.34);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 8% 8%, rgba(46, 197, 206, 0.18), transparent 26rem),
    radial-gradient(circle at 94% 92%, rgba(23, 105, 224, 0.15), transparent 30rem),
    var(--bg);
  font-size: 16px;
  line-height: 1.65;
}

button, input, select, textarea { font: inherit; }
button { color: inherit; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.page-grid {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.42;
  background-image:
    linear-gradient(rgba(38, 92, 143, 0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(38, 92, 143, 0.06) 1px, transparent 1px);
  background-size: 32px 32px;
  mask-image: linear-gradient(to bottom, black, transparent 92%);
}

.topbar {
  position: relative;
  z-index: 3;
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
  min-height: 88px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.brand { display: inline-flex; align-items: center; gap: 12px; color: var(--ink); text-decoration: none; }
.brand-mark {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: var(--navy);
  color: white;
  font-weight: 800;
  letter-spacing: -0.04em;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.12);
}
.brand-copy { display: grid; line-height: 1.25; }
.brand-copy strong { font-size: .98rem; }
.brand-copy small { color: var(--muted); margin-top: 3px; font-size: .76rem; letter-spacing: .04em; }
.top-actions { display: flex; align-items: center; gap: 10px; }
.text-button, .icon-button {
  border: 1px solid color-mix(in srgb, var(--soft) 82%, var(--ink));
  background: color-mix(in srgb, var(--surface-strong) 82%, transparent);
  cursor: pointer;
  transition: .2s ease;
}
.text-button { border-radius: 999px; padding: 9px 16px; font-weight: 700; font-size: .88rem; }
.icon-button { width: 40px; height: 40px; border-radius: 50%; font-size: 1.15rem; }
.text-button:hover, .icon-button:hover { transform: translateY(-1px); border-color: var(--blue); }

.shell {
  position: relative;
  z-index: 1;
  width: min(1180px, calc(100% - 40px));
  margin: 18px auto 72px;
  display: grid;
  grid-template-columns: minmax(280px, .72fr) minmax(520px, 1.28fr);
  min-height: 690px;
  background: var(--surface);
  border: 1px solid color-mix(in srgb, var(--soft) 88%, var(--ink));
  border-radius: 30px;
  overflow: hidden;
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.context-panel {
  position: relative;
  padding: 50px 42px;
  background:
    linear-gradient(160deg, rgba(46,197,206,.14), transparent 35%),
    linear-gradient(145deg, var(--navy), #0c3156 72%, #0d4f6d);
  color: white;
  overflow: hidden;
}
.context-panel::after {
  content: "";
  position: absolute;
  width: 300px; height: 300px;
  border: 1px solid rgba(255,255,255,.13);
  border-radius: 50%;
  right: -150px; bottom: -110px;
  box-shadow: 0 0 0 38px rgba(255,255,255,.035), 0 0 0 76px rgba(255,255,255,.025);
}
.eyebrow { font-size: .76rem; letter-spacing: .13em; text-transform: uppercase; font-weight: 800; color: var(--cyan); }
.context-panel h1 { margin: 14px 0 18px; font-size: clamp(2rem, 3.1vw, 3.4rem); line-height: 1.08; letter-spacing: -.045em; }
.context-panel > p { color: rgba(232,243,255,.76); margin: 0; font-size: 1rem; }
.meta-list { margin: 36px 0 0; display: grid; gap: 0; }
.meta-list div { padding: 15px 0; border-top: 1px solid rgba(255,255,255,.13); display: flex; justify-content: space-between; gap: 18px; }
.meta-list dt { color: rgba(232,243,255,.57); }
.meta-list dd { margin: 0; text-align: right; font-weight: 700; }
.research-note { position: absolute; left: 42px; right: 42px; bottom: 40px; z-index: 1; display: flex; gap: 13px; align-items: flex-start; color: rgba(232,243,255,.7); font-size: .87rem; }
.note-index { color: var(--cyan); font: 700 .78rem/1 ui-monospace, monospace; padding-top: 6px; }

.survey-panel { padding: 46px 52px 40px; min-width: 0; }
.progress-labels { display: flex; justify-content: space-between; gap: 12px; color: var(--muted); font-size: .82rem; font-weight: 700; }
.progress-track { margin-top: 10px; height: 5px; border-radius: 99px; background: var(--soft); overflow: hidden; }
.progress-track span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--blue), var(--cyan)); transition: width .35s ease; }

.step { animation: rise .34s ease both; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.step-kicker { margin-top: 34px; color: var(--blue); font-size: .8rem; font-weight: 800; letter-spacing: .08em; }
.step h2 { margin: 6px 0 5px; font-size: clamp(1.55rem, 2.4vw, 2.25rem); line-height: 1.24; letter-spacing: -.03em; }
.step-intro { color: var(--muted); margin: 0 0 26px; }
.required-mark { color: var(--danger); margin-left: 4px; }

.question { margin: 0 0 30px; padding: 0; border: 0; }
.question legend, .question-label { display: block; width: 100%; margin-bottom: 11px; font-weight: 760; line-height: 1.45; }
.question-code { color: var(--blue); font: 800 .75rem/1.2 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .04em; }
.question-help { display: block; margin-top: -6px; margin-bottom: 12px; color: var(--muted); font-size: .84rem; }
.option-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.option-card { position: relative; display: flex; align-items: center; min-height: 58px; padding: 13px 15px; gap: 11px; border: 1px solid var(--soft); background: var(--surface-strong); border-radius: 14px; cursor: pointer; transition: .18s ease; }
.option-card:hover { border-color: color-mix(in srgb, var(--blue) 50%, var(--soft)); transform: translateY(-1px); }
.option-card:has(input:checked) { border-color: var(--blue); background: color-mix(in srgb, var(--blue) 7%, var(--surface-strong)); box-shadow: inset 0 0 0 1px var(--blue); }
.option-card input { inline-size: 18px; block-size: 18px; accent-color: var(--blue); flex: 0 0 auto; }
.option-card span { font-size: .93rem; line-height: 1.4; }
.option-card small { display: block; color: var(--muted); font-size: .78rem; margin-top: 2px; }
.other-field {
  display: none;
  width: 100%;
  margin-top: 8px;
  padding: 8px 10px;
  border: 1px solid var(--soft);
  border-radius: 9px;
  background: var(--surface-strong);
  color: var(--ink);
}
.option-card:has(> input:checked) .other-field { display: block; }

.form-control { width: 100%; min-height: 48px; border: 1px solid var(--soft); border-radius: 12px; background: var(--surface-strong); color: var(--ink); padding: 11px 13px; outline: none; }
.form-control:focus { border-color: var(--blue); box-shadow: 0 0 0 3px color-mix(in srgb, var(--blue) 16%, transparent); }
textarea.form-control { min-height: 94px; resize: vertical; }
.matrix-wrap { overflow-x: auto; border: 1px solid var(--soft); border-radius: 14px; }
.matrix { width: 100%; border-collapse: collapse; min-width: 600px; background: var(--surface-strong); }
.matrix th, .matrix td { padding: 12px 10px; border-bottom: 1px solid var(--soft); text-align: center; font-size: .82rem; }
.matrix th small { display: block; color: rgba(255,255,255,.68); font-weight: 500; margin-top: 3px; white-space: nowrap; }
.matrix thead th { background: var(--navy); color: white; }
.matrix thead th:first-child { background: var(--navy); color: white; z-index: 2; }
.matrix th:first-child, .matrix td:first-child { text-align: left; min-width: 210px; position: sticky; left: 0; background: var(--surface-strong); z-index: 1; }
.matrix tr:last-child td { border-bottom: 0; }
.matrix input { inline-size: 18px; block-size: 18px; accent-color: var(--blue); }
.likert-scale { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.likert-scale .option-card { min-height: 68px; padding: 8px; justify-content: center; text-align: center; flex-direction: column; gap: 2px; }

.error-box { display: none; color: var(--danger); background: color-mix(in srgb, var(--danger) 8%, transparent); border-left: 3px solid var(--danger); border-radius: 6px; padding: 10px 12px; margin: 0 0 18px; font-size: .88rem; }
.error-box.show { display: block; }
.form-actions { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 34px; padding-top: 22px; border-top: 1px solid var(--soft); }
.button { border: 0; border-radius: 12px; padding: 12px 20px; cursor: pointer; font-weight: 800; transition: .2s ease; }
.button:hover { transform: translateY(-1px); }
.button-primary { background: linear-gradient(135deg, var(--blue), #2c82eb); color: white; box-shadow: 0 10px 24px rgba(23,105,224,.22); }
.button-secondary { background: transparent; color: var(--muted); border: 1px solid var(--soft); }
.button-quiet { background: color-mix(in srgb, var(--blue) 9%, var(--surface-strong)); color: var(--blue); }
.button[disabled] { cursor: not-allowed; opacity: .45; transform: none; }

.summary-card { border: 1px solid var(--soft); background: var(--surface-strong); border-radius: 15px; padding: 18px; margin: 14px 0; }
.summary-card h3 { margin: 0 0 10px; font-size: 1rem; }
.summary-list { display: grid; grid-template-columns: 150px 1fr; gap: 7px 16px; margin: 0; font-size: .88rem; }
.summary-list dt { color: var(--muted); }
.summary-list dd { margin: 0; overflow-wrap: anywhere; }
.success-mark { width: 68px; height: 68px; display: grid; place-items: center; border-radius: 22px; background: linear-gradient(135deg, var(--blue), var(--cyan)); color: white; font-size: 2rem; box-shadow: 0 18px 38px rgba(23,105,224,.24); }
.success-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 24px; }

.research-dialog { width: min(1080px, calc(100% - 28px)); max-height: min(88vh, 900px); border: 0; border-radius: 24px; color: var(--ink); background: var(--surface-strong); box-shadow: 0 30px 100px rgba(0,0,0,.35); padding: 0; }
.research-dialog::backdrop { background: rgba(1,13,26,.62); backdrop-filter: blur(6px); }
.dialog-head { position: sticky; top: 0; z-index: 4; display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; padding: 24px 28px; border-bottom: 1px solid var(--soft); background: var(--surface-strong); }
.dialog-head h2 { margin: 4px 0 0; line-height: 1.25; }
.research-tabs { display: flex; gap: 8px; padding: 20px 28px 0; flex-wrap: wrap; }
.research-tab { border: 1px solid var(--soft); border-radius: 999px; padding: 8px 14px; background: transparent; cursor: pointer; font-weight: 750; color: var(--muted); }
.research-tab.active { background: var(--navy); color: white; border-color: var(--navy); }
.research-body { padding: 22px 28px 32px; }
.logic-flow { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin: 16px 0 28px; }
.logic-node { border: 1px solid var(--soft); border-radius: 14px; padding: 14px; background: color-mix(in srgb, var(--blue) 4%, var(--surface-strong)); }
.logic-node strong { display: block; font-size: .88rem; }
.logic-node small { color: var(--muted); }
.table-wrap { overflow: auto; border: 1px solid var(--soft); border-radius: 14px; }
.data-table { width: 100%; border-collapse: collapse; min-width: 900px; font-size: .82rem; }
.data-table th, .data-table td { padding: 11px 12px; border-bottom: 1px solid var(--soft); text-align: left; vertical-align: top; }
.data-table th { position: sticky; top: 0; background: var(--navy); color: white; white-space: nowrap; }
.data-table tr:last-child td { border-bottom: 0; }
.tool-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 0 0 18px; }
.tool-row .form-control { flex: 1 1 220px; }

.toast { position: fixed; z-index: 20; left: 50%; bottom: 26px; transform: translate(-50%, 18px); opacity: 0; pointer-events: none; color: white; background: var(--navy); border: 1px solid rgba(255,255,255,.14); border-radius: 12px; padding: 10px 15px; box-shadow: 0 14px 40px rgba(0,0,0,.22); transition: .25s ease; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 880px) {
  .shell { grid-template-columns: 1fr; }
  .context-panel { padding: 34px; min-height: 330px; }
  .context-panel h1 { max-width: 620px; }
  .meta-list { grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 26px; }
  .meta-list div { display: block; border: 1px solid rgba(255,255,255,.13); border-radius: 12px; padding: 10px 12px; }
  .meta-list dd { text-align: left; margin-top: 3px; }
  .research-note { position: static; margin-top: 28px; }
  .survey-panel { padding: 36px 34px; }
}

@media (max-width: 620px) {
  .topbar, .shell { width: min(100% - 24px, 1180px); }
  .topbar { min-height: 76px; }
  .brand-copy { display: none; }
  .shell { margin-top: 6px; border-radius: 22px; }
  .context-panel { padding: 28px 24px; min-height: auto; }
  .context-panel h1 { font-size: 2rem; }
  .context-panel > p { font-size: .93rem; }
  .meta-list { grid-template-columns: 1fr; }
  .meta-list div { display: flex; }
  .research-note { display: none; }
  .survey-panel { padding: 28px 22px 26px; }
  .option-grid { grid-template-columns: 1fr; }
  .likert-scale { grid-template-columns: 1fr; }
  .likert-scale .option-card { min-height: 52px; flex-direction: row; justify-content: flex-start; padding: 10px 13px; }
  .form-actions { align-items: stretch; }
  .form-actions .button { flex: 1; }
  .summary-list { grid-template-columns: 1fr; gap: 2px; }
  .summary-list dd { margin-bottom: 8px; }
  .logic-flow { grid-template-columns: 1fr; }
  .dialog-head, .research-body { padding-left: 18px; padding-right: 18px; }
  .research-tabs { padding-left: 18px; padding-right: 18px; }
}

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