:root {
  color-scheme: light;
  --bg: #f4f7f6;
  --surface: #ffffff;
  --surface-soft: #eef5f2;
  --text: #1d2a2b;
  --muted: #60706f;
  --line: #d7e2df;
  --green: #126f64;
  --green-dark: #0f504a;
  --coral: #c7603f;
  --gold: #b47b18;
  --red: #a33b35;
  --shadow: 0 18px 48px rgba(25, 52, 47, 0.12);
  font-family:
    "Inter", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui,
    sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 8% 12%, rgba(18, 111, 100, 0.08), transparent 26rem),
    linear-gradient(135deg, #f5f8f7 0%, #eef5f2 48%, #f8f6f1 100%);
  color: var(--text);
  letter-spacing: 0;
}

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

button {
  cursor: pointer;
}

.app-shell {
  width: min(1240px, calc(100% - 32px));
  margin: 0 auto;
  padding: 22px 0 36px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 12px 0 22px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--text);
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 46px;
  height: 46px;
  place-items: center;
  border: 1px solid rgba(18, 111, 100, 0.26);
  border-radius: 8px;
  color: var(--green);
  background: #fff;
  box-shadow: 0 8px 20px rgba(18, 111, 100, 0.1);
}

.brand-mark svg {
  width: 30px;
  height: 30px;
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-size: 18px;
  line-height: 1.2;
}

.brand small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.privacy-note {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--green-dark);
  font-size: 14px;
  white-space: nowrap;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 5px rgba(18, 111, 100, 0.12);
}

.assessment-layout {
  display: grid;
  grid-template-columns: 330px minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}

.progress-panel {
  position: sticky;
  top: 18px;
  display: grid;
  gap: 20px;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: var(--shadow);
}

.score-gauge {
  display: flex;
}

.gauge-ring {
  --progress: 0deg;
  display: grid;
  width: 108px;
  height: 108px;
  place-items: center;
  border-radius: 50%;
  background:
    radial-gradient(circle, #fff 57%, transparent 58%),
    conic-gradient(var(--green) var(--progress), #dfe9e6 0deg);
}

.gauge-ring span {
  color: var(--green-dark);
  font-size: 24px;
  font-weight: 760;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--coral);
  font-size: 12px;
  font-weight: 760;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 10px;
  font-size: clamp(30px, 4vw, 44px);
  line-height: 1.08;
}

h2 {
  margin-bottom: 0;
  font-size: clamp(24px, 3vw, 34px);
  line-height: 1.16;
}

h3 {
  margin-bottom: 8px;
  font-size: 18px;
  line-height: 1.35;
}

.lede {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.75;
}

.step-list {
  display: grid;
  gap: 8px;
}

.step-link {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  text-align: left;
  transition:
    border-color 160ms ease,
    background 160ms ease,
    color 160ms ease;
}

.step-link:hover,
.step-link:focus-visible {
  border-color: rgba(18, 111, 100, 0.6);
  outline: none;
}

.step-link.is-active {
  border-color: var(--green);
  background: var(--green);
  color: #fff;
}

.mini-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.mini-stats div {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.mini-stats span,
.mini-stats small {
  display: block;
}

.mini-stats span {
  color: var(--green-dark);
  font-size: 28px;
  font-weight: 780;
}

.mini-stats small {
  margin-top: 4px;
  color: var(--muted);
}

.form-surface {
  min-width: 0;
  padding: 30px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
}

.form-section {
  display: none;
}

.form-section.is-current {
  display: block;
}

.section-heading {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: end;
  margin-bottom: 24px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.sleep-time-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-bottom: 20px;
}

.field {
  display: grid;
  gap: 8px;
}

.field span,
.question-label,
legend {
  color: var(--text);
  font-weight: 700;
}

.field input,
.field select,
.text-field {
  width: 100%;
  min-height: 46px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
}

.field input:focus,
.field select:focus,
.text-field:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 4px rgba(18, 111, 100, 0.12);
  outline: none;
}

.option-fieldset {
  margin: 20px 0 0;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.alert-fieldset {
  border-color: rgba(163, 59, 53, 0.28);
  background: #fff9f7;
}

.option-fieldset legend {
  padding: 0 6px;
}

.checkbox-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.checkbox-grid label {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  min-height: 44px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  line-height: 1.45;
}

input[type="checkbox"],
input[type="radio"] {
  width: 18px;
  height: 18px;
  accent-color: var(--green);
}

.question-stack {
  display: grid;
  gap: 14px;
}

.subgroup-title {
  margin: 24px 0 2px;
  padding-left: 12px;
  border-left: 4px solid var(--coral);
  color: var(--green-dark);
  font-size: 17px;
  font-weight: 780;
}

.question-card {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.question-label {
  display: block;
  margin-bottom: 14px;
  line-height: 1.65;
}

.question-meta {
  margin-right: 8px;
  color: var(--green);
  font-weight: 800;
}

.option-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(132px, 1fr));
  gap: 10px;
}

.option-row.compact-options {
  grid-template-columns: repeat(auto-fit, minmax(118px, 1fr));
}

.radio-tile {
  position: relative;
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 46px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfc;
  color: var(--text);
  line-height: 1.35;
}

.radio-tile:hover {
  border-color: rgba(18, 111, 100, 0.55);
}

.radio-tile input {
  flex: 0 0 auto;
}

.radio-tile:has(input:checked) {
  border-color: var(--green);
  background: #edf7f4;
  box-shadow: inset 0 0 0 1px rgba(18, 111, 100, 0.18);
}

.extra-field {
  margin-top: 12px;
}

.empty-result {
  display: grid;
  gap: 8px;
  min-height: 280px;
  align-content: center;
  justify-items: center;
  padding: 32px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--muted);
  text-align: center;
}

.empty-result strong {
  color: var(--text);
  font-size: 18px;
}

.result-content {
  display: grid;
  gap: 18px;
}

.result-header {
  display: grid;
  gap: 6px;
  padding: 18px;
  border-radius: 8px;
  background: linear-gradient(135deg, #edf7f4, #fff7ef);
  border: 1px solid var(--line);
}

.result-header strong {
  color: var(--green-dark);
  font-size: 22px;
}

.score-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.score-card {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.score-card span {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.score-card strong {
  display: block;
  margin-top: 6px;
  color: var(--green-dark);
  font-size: 30px;
  line-height: 1;
}

.score-card em {
  display: block;
  margin-top: 10px;
  color: var(--text);
  font-style: normal;
  font-weight: 700;
}

.result-block {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.result-block h3 {
  margin-bottom: 12px;
}

.result-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.result-list li {
  padding-left: 16px;
  border-left: 3px solid var(--green);
  line-height: 1.65;
}

.component-table {
  width: 100%;
  border-collapse: collapse;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.component-table th,
.component-table td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

.component-table th {
  background: var(--surface-soft);
  color: var(--green-dark);
  font-size: 13px;
}

.component-table tr:last-child td {
  border-bottom: 0;
}

.component-table td:last-child {
  width: 78px;
  color: var(--green-dark);
  font-weight: 800;
  text-align: center;
}

.warning-block {
  border-color: rgba(163, 59, 53, 0.32);
  background: #fff8f6;
}

.warning-block .result-list li {
  border-left-color: var(--red);
}

.form-actions {
  position: sticky;
  bottom: 0;
  z-index: 2;
  display: flex;
  justify-content: space-between;
  gap: 14px;
  margin: 28px -30px -30px;
  padding: 16px 30px;
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(12px);
}

.action-cluster {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.primary-button,
.secondary-button,
.ghost-button {
  min-height: 44px;
  padding: 10px 16px;
  border-radius: 8px;
  border: 1px solid transparent;
  font-weight: 760;
}

.primary-button {
  background: var(--green);
  color: #fff;
}

.primary-button:hover,
.primary-button:focus-visible {
  background: var(--green-dark);
  outline: none;
}

.secondary-button {
  border-color: var(--line);
  background: #fff;
  color: var(--green-dark);
}

.secondary-button:hover,
.secondary-button:focus-visible,
.ghost-button:hover,
.ghost-button:focus-visible {
  border-color: var(--green);
  outline: none;
}

.secondary-button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.ghost-button {
  border-color: transparent;
  background: transparent;
  color: var(--muted);
}

.form-message {
  min-height: 22px;
  margin: 14px 0 0;
  color: var(--red);
  font-weight: 700;
}

@media (max-width: 960px) {
  .assessment-layout {
    grid-template-columns: 1fr;
  }

  .progress-panel {
    position: static;
    grid-template-columns: auto 1fr;
    align-items: center;
  }

  .step-list,
  .mini-stats {
    grid-column: 1 / -1;
  }

  .step-list {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }

  .step-link {
    text-align: center;
    padding-inline: 8px;
  }
}

@media (max-width: 720px) {
  .app-shell {
    width: min(100% - 20px, 680px);
    padding-top: 12px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .progress-panel,
  .form-surface {
    padding: 18px;
  }

  .progress-panel {
    grid-template-columns: 1fr;
  }

  .score-gauge {
    display: none;
  }

  h1 {
    font-size: 32px;
  }

  .section-heading {
    display: block;
  }

  .field-grid,
  .sleep-time-grid,
  .checkbox-grid,
  .score-grid {
    grid-template-columns: 1fr;
  }

  .step-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .option-row,
  .option-row.compact-options {
    grid-template-columns: 1fr;
  }

  .form-actions {
    position: static;
    display: grid;
    margin: 24px -18px -18px;
    padding: 14px 18px;
  }

  .action-cluster {
    display: grid;
    grid-template-columns: 1fr;
  }
}

@media print {
  body {
    background: #fff;
  }

  .topbar,
  .progress-panel,
  .form-actions,
  .form-message,
  .form-section:not(.result-section),
  .empty-result {
    display: none !important;
  }

  .app-shell,
  .assessment-layout,
  .form-surface {
    width: 100%;
    display: block;
    margin: 0;
    padding: 0;
    border: 0;
    box-shadow: none;
  }

  .result-section {
    display: block !important;
  }

  .result-content {
    display: grid !important;
  }
}
