:root {
  --bg: #f7f9fc;
  --surface: #ffffff;
  --surface-soft: #f8fbff;
  --ink: #1f2937;
  --muted: #64748b;
  --line: #dfe6ef;
  --line-strong: #c7d2e0;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-soft: #eff6ff;
  --success: #15803d;
  --success-soft: #eefbf3;
  --warning: #a15c08;
  --warning-soft: #fff8e8;
  --danger: #b42318;
  --danger-soft: #fff1f0;
  --shadow: 0 12px 32px rgba(15, 23, 42, 0.07);
  --radius: 14px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background: var(--bg);
}

* { box-sizing: border-box; }
html { min-width: 0; scroll-behavior: smooth; }
body { margin: 0; min-height: 100vh; background: var(--bg); color: var(--ink); line-height: 1.65; }
button, input, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: 0.52; }
a { color: var(--primary); }

.skip-link {
  position: fixed;
  left: 12px;
  top: 8px;
  z-index: 100;
  padding: 8px 12px;
  border-radius: 8px;
  color: white;
  background: var(--primary-dark);
  transform: translateY(-160%);
}
.skip-link:focus { transform: none; }

.site-header {
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
}
.header-inner {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  width: min(100% - 40px, 920px);
  margin: 0 auto;
  padding: 22px 0 20px;
}
.brand-mark {
  display: grid;
  flex: 0 0 44px;
  place-items: center;
  height: 44px;
  border-radius: 12px;
  color: white;
  background: var(--primary);
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.05em;
}
h1 { margin: 0; font-size: clamp(1.25rem, 3vw, 1.78rem); line-height: 1.32; letter-spacing: -0.02em; }
.english-title { margin: 4px 0 0; color: var(--muted); font-size: 0.92rem; line-height: 1.45; }
.research-only { margin: 5px 0 0; color: var(--primary-dark); font-size: 0.76rem; font-weight: 750; letter-spacing: 0.08em; text-transform: uppercase; }

#app { width: min(100% - 40px, 820px); min-height: 58vh; margin: 32px auto 48px; outline: none; }
.wide-app { width: min(100% - 40px, 1180px) !important; }

.panel, .question-card, .dashboard-card, .detail-section {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.03);
}
.panel { padding: clamp(22px, 5vw, 42px); box-shadow: var(--shadow); animation: enter 180ms ease-out; }
.intro-panel { position: relative; overflow: hidden; }
.intro-panel::before { content: ""; position: absolute; inset: 0 0 auto; height: 5px; background: linear-gradient(90deg, var(--primary), #60a5fa); }
.eyebrow { margin: 0 0 8px; color: var(--primary-dark); font-size: 0.82rem; font-weight: 800; letter-spacing: 0.08em; }
h2 { margin: 0 0 12px; font-size: clamp(1.45rem, 3vw, 2rem); line-height: 1.35; }
h3 { margin: 0 0 10px; font-size: 1.13rem; line-height: 1.45; }
p { margin: 0 0 12px; }
.lead { max-width: 650px; font-size: 1.05rem; color: #334155; }
.notice {
  margin: 22px 0;
  padding: 15px 17px;
  border-left: 4px solid var(--primary);
  border-radius: 8px;
  background: var(--primary-soft);
  color: #254162;
}
.notice.warning { border-left-color: var(--warning); background: var(--warning-soft); color: #6f4614; }
.notice.danger { border-left-color: var(--danger); background: var(--danger-soft); color: #7a271a; }
.notice.success { border-left-color: var(--success); background: var(--success-soft); color: #166534; }

.consent-row, .check-row { display: flex; align-items: flex-start; gap: 11px; margin: 22px 0; }
.consent-row input, .check-row input { flex: 0 0 auto; width: 20px; height: 20px; margin-top: 3px; accent-color: var(--primary); }

.stepper { margin: 0 0 20px; }
.stepper-track { display: grid; grid-template-columns: repeat(5, 1fr); gap: 5px; }
.step-item { min-width: 0; }
.step-line { display: block; height: 5px; border-radius: 999px; background: #dbe4ef; transition: background 200ms ease; }
.step-item.complete .step-line, .step-item.current .step-line { background: var(--primary); }
.step-label { display: block; margin-top: 7px; color: var(--muted); font-size: 0.75rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.step-item.current .step-label { color: var(--primary-dark); font-weight: 750; }
.mobile-step { display: none; color: var(--primary-dark); font-weight: 700; }

.section-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 22px; }
.section-head p { margin: 0; color: var(--muted); }
.side-badge, .status-chip {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 4px 10px;
  border: 1px solid #bfdbfe;
  border-radius: 999px;
  color: var(--primary-dark);
  background: var(--primary-soft);
  font-size: 0.82rem;
  font-weight: 750;
  white-space: nowrap;
}

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.field { min-width: 0; }
.field.full { grid-column: 1 / -1; }
.field label, .field legend { display: block; margin-bottom: 7px; font-size: 0.95rem; font-weight: 700; }
.required { color: var(--danger); }
.field input[type="number"], .field input[type="password"], .field input[type="search"], .field select {
  width: 100%;
  min-height: 46px;
  padding: 9px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  color: var(--ink);
  background: white;
}
fieldset { min-width: 0; margin: 0; padding: 0; border: 0; }
.hint { margin: 5px 0 0; color: var(--muted); font-size: 0.88rem; }
.error-text { min-height: 1.3em; margin: 5px 0 0; color: var(--danger); font-size: 0.86rem; font-weight: 650; }
[aria-invalid="true"] { border-color: var(--danger) !important; background: #fffafa !important; }

.question-list { display: grid; gap: 18px; }
.question-card { padding: 20px; }
.question-number { margin-right: 4px; color: var(--primary-dark); font-weight: 800; }
.option-list { display: grid; gap: 9px; margin-top: 14px; }
.option-row { position: relative; display: flex; align-items: flex-start; gap: 11px; min-height: 46px; padding: 11px 13px; border: 1px solid var(--line); border-radius: 10px; background: white; transition: border-color 170ms ease, background 170ms ease; cursor: pointer; }
.option-row:hover { border-color: #93b5ec; }
.option-row:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); box-shadow: 0 0 0 1px rgba(37, 99, 235, 0.08); }
.option-row input { width: 18px; height: 18px; margin: 2px 0 0; accent-color: var(--primary); }
.option-row span { min-width: 0; overflow-wrap: anywhere; }
details.help { margin-top: 10px; border-radius: 9px; background: #f8fafc; }
details.help summary { padding: 9px 12px; color: var(--primary-dark); font-size: 0.9rem; font-weight: 700; cursor: pointer; }
details.help p { padding: 0 12px 12px; color: var(--muted); font-size: 0.9rem; }

.button-row { display: flex; align-items: center; justify-content: flex-end; gap: 10px; margin-top: 26px; }
.button-row.split { justify-content: space-between; }
.btn { min-height: 46px; padding: 10px 19px; border: 1px solid transparent; border-radius: 9px; font-weight: 750; transition: background 170ms ease, border-color 170ms ease, transform 170ms ease; }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { cursor: wait; opacity: 0.62; }
.btn-primary { color: white; background: var(--primary); }
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); }
.btn-secondary { border-color: var(--line-strong); color: #334155; background: white; }
.btn-secondary:hover:not(:disabled) { border-color: #94a3b8; background: #f8fafc; }
.btn-danger { border-color: #fecaca; color: var(--danger); background: #fff7f7; }
.btn-small { min-height: 36px; padding: 6px 11px; font-size: 0.86rem; }

.confirmation-list { display: grid; gap: 10px; margin: 20px 0; padding: 0; list-style: none; }
.confirmation-list li { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border: 1px solid #d8eadf; border-radius: 10px; background: #f7fcf9; }
.check-icon { display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; color: white; background: var(--success); font-size: 0.82rem; font-weight: 800; }
.success-panel { text-align: center; }
.success-icon { display: grid; place-items: center; width: 68px; height: 68px; margin: 0 auto 18px; border-radius: 50%; color: white; background: var(--success); font-size: 2rem; }
.success-panel p { max-width: 520px; margin-left: auto; margin-right: auto; color: #475569; }
.participant-code { padding: 10px 14px; border: 1px solid var(--line); border-radius: 10px; background: #f8fafc; }

.research-login { max-width: 480px; margin: 0 auto; }
.dashboard-toolbar { display: grid; grid-template-columns: minmax(180px, 1.3fr) repeat(4, minmax(120px, 0.8fr)) auto; gap: 10px; align-items: end; margin: 20px 0; }
.dashboard-stats { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; }
.dashboard-card { padding: 15px; }
.dashboard-card span { display: block; color: var(--muted); font-size: 0.82rem; }
.dashboard-card strong { display: block; margin-top: 4px; font-size: 1.55rem; line-height: 1.1; }
.table-wrap { overflow-x: auto; margin-top: 18px; border: 1px solid var(--line); border-radius: 12px; background: white; }
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th, td { padding: 12px 13px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; white-space: nowrap; }
th { color: #475569; background: #f8fafc; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fbfdff; }
.group-healthy { border-color: #bbdec8; color: #166534; background: #effaf3; }
.group-coper { border-color: #bfdbfe; color: #1d4ed8; background: #eff6ff; }
.group-cai { border-color: #c7d2fe; color: #4338ca; background: #eef2ff; }
.group-review { border-color: #f5d69d; color: #92400e; background: #fff8e8; }
.empty-state { padding: 44px 20px; text-align: center; color: var(--muted); }
.pagination { display: flex; align-items: center; justify-content: flex-end; gap: 12px; margin-top: 14px; color: var(--muted); font-size: 0.9rem; }

.modal-backdrop { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 20px; background: rgba(15, 23, 42, 0.46); }
.modal { width: min(100%, 840px); max-height: calc(100vh - 40px); overflow-y: auto; padding: 24px; border-radius: 16px; background: white; box-shadow: 0 24px 80px rgba(15, 23, 42, 0.24); }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.detail-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; margin-top: 18px; }
.detail-section { padding: 15px; box-shadow: none; }
.detail-section.full { grid-column: 1 / -1; }
.detail-section dl { display: grid; grid-template-columns: minmax(110px, 0.7fr) 1.3fr; gap: 6px 12px; margin: 0; font-size: 0.9rem; }
.detail-section dt { color: var(--muted); }
.detail-section dd { margin: 0; overflow-wrap: anywhere; }
.evidence-list { margin: 8px 0 0; padding-left: 21px; }

.site-footer { width: min(100% - 40px, 820px); margin: 0 auto; padding: 24px 0 34px; border-top: 1px solid var(--line); color: #8793a5; text-align: center; font-size: 0.8rem; }
.site-footer p { margin: 2px 0; }
.researcher-link { margin-top: 7px; padding: 5px 8px; border: 0; color: #768399; background: transparent; font-size: 0.78rem; text-decoration: underline; text-underline-offset: 3px; }
.noscript { margin: 20px; padding: 15px; color: var(--danger); background: var(--danger-soft); text-align: center; }
.sr-only { 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; }

:focus-visible { outline: 3px solid rgba(37, 99, 235, 0.36); outline-offset: 2px; }
@keyframes enter { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; } }

@media (max-width: 760px) {
  .header-inner, #app, .site-footer { width: min(100% - 32px, 820px); }
  .header-inner { padding: 17px 0; }
  .brand-mark { width: 40px; height: 40px; flex-basis: 40px; }
  #app { margin-top: 22px; }
  .panel { padding: 22px 18px; }
  .stepper-track { display: none; }
  .mobile-step { display: block; }
  .section-head { display: block; }
  .section-head .side-badge { margin-top: 10px; }
  .form-grid, .detail-grid { grid-template-columns: 1fr; }
  .detail-section.full { grid-column: auto; }
  .dashboard-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dashboard-toolbar { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
  .header-inner { gap: 11px; }
  h1 { font-size: 1.13rem; }
  .english-title { font-size: 0.78rem; }
  .panel { border-radius: 12px; }
  .question-card { padding: 16px 14px; }
  .button-row, .button-row.split { flex-direction: column-reverse; align-items: stretch; }
  .button-row .btn { width: 100%; }
  .dashboard-stats { grid-template-columns: 1fr 1fr; }
  .modal-backdrop { padding: 8px; }
  .modal { max-height: calc(100vh - 16px); padding: 18px 14px; border-radius: 12px; }
}
