:root {
  color-scheme: light;
  --ink: #1f2933;
  --muted: #65727f;
  --line: #d9e0e7;
  --paper: #ffffff;
  --wash: #f5f7f2;
  --soft: #eef4f7;
  --accent: #2f6f73;
  --accent-dark: #20555a;
  --gold: #b88a2f;
  --red: #b9563b;
  --green: #547a4a;
  --shadow: 0 14px 34px rgba(31, 41, 51, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--wash);
  color: var(--ink);
  font-family: "Pretendard", "Noto Sans KR", "Malgun Gothic", Arial, sans-serif;
  line-height: 1.55;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 18px 28px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(12px);
}

.topbar h1,
.section-heading h2,
.result-toolbar h2 {
  margin: 0;
  font-size: 24px;
  letter-spacing: 0;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.topbar-status,
.toolbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

#saveState {
  color: var(--muted);
  font-size: 14px;
  white-space: nowrap;
}

.workspace {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 24px;
  width: min(1480px, 100%);
  margin: 0 auto;
  padding: 24px;
}

.sidebar {
  position: sticky;
  top: 92px;
  align-self: start;
  display: grid;
  gap: 16px;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  box-shadow: var(--shadow);
  padding: 18px;
}

.panel h2 {
  margin: 0 0 14px;
  font-size: 16px;
}

label {
  display: grid;
  gap: 6px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

input[type="text"],
input[type="date"],
input[type="tel"],
select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfd;
  color: var(--ink);
  padding: 8px 10px;
}

.intro-view {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 420px;
  gap: 42px;
  align-items: center;
  width: min(1180px, calc(100% - 40px));
  min-height: calc(100vh - 90px);
  margin: 0 auto;
  padding: 42px 0;
}

.intro-copy h2 {
  max-width: 720px;
  margin: 0 0 18px;
  font-size: clamp(32px, 5vw, 58px);
  line-height: 1.12;
  letter-spacing: 0;
}

.intro-copy p:last-child {
  max-width: 620px;
  margin: 0;
  color: var(--muted);
  font-size: 18px;
}

.intro-form {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  box-shadow: var(--shadow);
  padding: 24px;
}

.intro-form h2 {
  margin: 0 0 14px;
  font-size: 22px;
}

.intro-actions {
  display: grid;
  gap: 10px;
  margin-top: 18px;
}

.intro-actions .primary-button,
.intro-actions .ghost-button {
  width: 100%;
}

.test-view,
.result-view {
  width: min(980px, calc(100% - 40px));
  margin: 0 auto;
  padding: 34px 0;
}

.test-shell {
  display: grid;
  gap: 20px;
}

.test-progress {
  display: grid;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  box-shadow: var(--shadow);
  padding: 18px;
}

.test-progress > div:first-child {
  display: flex;
  justify-content: space-between;
  gap: 16px;
}

.question-card {
  display: grid;
  gap: 28px;
  min-height: 430px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  box-shadow: var(--shadow);
  padding: 42px;
}

.question-count {
  display: flex;
  align-items: center;
  gap: 12px;
}

.question-count span {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: #eaf2f2;
  color: var(--accent-dark);
  font-size: 18px;
  font-weight: 900;
}

.question-count em {
  color: var(--muted);
  font-style: normal;
  font-weight: 800;
}

.question-card h2 {
  align-self: center;
  margin: 0;
  font-size: clamp(25px, 3vw, 38px);
  line-height: 1.35;
  letter-spacing: 0;
}

.single-rating {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
}

.single-rating-option {
  margin: 0;
  cursor: pointer;
}

.single-rating-option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.single-rating-option span,
.single-rating-option strong {
  display: grid;
  place-items: center;
  text-align: center;
}

.single-rating-option span {
  height: 58px;
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: 8px 8px 0 0;
  background: #ffffff;
  color: var(--accent-dark);
  font-size: 22px;
  font-weight: 900;
}

.single-rating-option strong {
  min-height: 54px;
  border: 1px solid var(--line);
  border-radius: 0 0 8px 8px;
  background: #f8fafb;
  color: var(--muted);
  font-size: 13px;
  padding: 6px;
}

.single-rating-option input:checked ~ span,
.single-rating-option input:checked ~ strong {
  border-color: var(--accent);
  background: var(--accent);
  color: #ffffff;
}

.single-rating.need-answer {
  animation: answerShake 420ms ease;
}

@keyframes answerShake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-8px); }
  75% { transform: translateX(8px); }
}

.test-actions {
  display: grid;
  grid-template-columns: 160px minmax(180px, 1fr);
  gap: 12px;
}

.test-actions .primary-button,
.test-actions .ghost-button,
.toolbar-actions .primary-button {
  width: auto;
}

.test-actions button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.progress-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.progress-track {
  height: 10px;
  margin: 10px 0 16px;
  overflow: hidden;
  border-radius: 999px;
  background: #e6ecef;
}

.progress-bar {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width 180ms ease;
}

.domain-progress {
  display: grid;
  gap: 8px;
}

.domain-chip {
  display: grid;
  grid-template-columns: 34px 1fr auto;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  text-decoration: none;
  padding: 8px 10px;
}

.domain-chip span {
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 900;
}

.domain-chip strong {
  font-size: 13px;
}

.domain-chip em {
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
}

.domain-chip.complete {
  border-color: rgba(47, 111, 115, 0.5);
  background: #eef8f6;
}

.primary-button,
.ghost-button {
  min-height: 42px;
  border-radius: 8px;
  border: 1px solid transparent;
  padding: 0 16px;
  font-weight: 800;
}

.primary-button {
  width: 100%;
  background: var(--accent);
  color: #ffffff;
}

.primary-button:disabled {
  cursor: not-allowed;
  background: #aeb9bf;
}

.ghost-button {
  background: #ffffff;
  border-color: var(--line);
  color: var(--ink);
}

.content {
  min-width: 0;
}

.section-heading,
.result-toolbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
}

.scale-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.scale-legend span {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #ffffff;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  padding: 5px 10px;
}

.question-groups {
  display: grid;
  gap: 18px;
}

.domain-section {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.domain-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
  background: var(--soft);
}

.domain-section-header h3 {
  margin: 0;
  font-size: 20px;
}

.domain-section-header span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.questions {
  display: grid;
}

.question {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 244px;
  gap: 18px;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid #edf1f4;
}

.question:last-child {
  border-bottom: 0;
}

.question-text {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
}

.question-text span {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 999px;
  background: #eaf2f2;
  color: var(--accent-dark);
  font-size: 13px;
  font-weight: 900;
}

.question-text p {
  margin: 4px 0 0;
}

.rating {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}

.rating-option {
  margin: 0;
}

.rating-option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.rating-option span {
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  min-width: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--muted);
  font-weight: 900;
}

.rating-option input:checked + span {
  border-color: var(--accent);
  background: var(--accent);
  color: #ffffff;
}

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

.hidden {
  display: none !important;
}

.result-summary,
.profile-card,
.result-card,
.mini-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  box-shadow: var(--shadow);
}

.result-summary {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr);
  gap: 24px;
  align-items: center;
  padding: 24px;
}

.score-dial {
  display: grid;
  place-items: center;
  width: 132px;
  height: 132px;
  border: 10px solid #dce9e8;
  border-radius: 50%;
  background: #ffffff;
}

.score-dial span {
  font-size: 34px;
  font-weight: 900;
}

.score-dial small,
.result-label,
.card-label {
  color: var(--muted);
  font-weight: 800;
}

.result-summary h3 {
  margin: 0 0 8px;
  font-size: 22px;
}

.result-summary p {
  margin: 0;
}

.tabs {
  display: flex;
  gap: 8px;
  border-bottom: 1px solid var(--line);
}

.tab {
  min-height: 42px;
  border: 0;
  border-bottom: 3px solid transparent;
  background: transparent;
  color: var(--muted);
  padding: 0 14px;
  font-weight: 900;
}

.tab.active {
  border-color: var(--accent);
  color: var(--accent-dark);
}

.tab-panel,
.prescription-list {
  display: grid;
  gap: 14px;
}

.result-card {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr);
  gap: 18px;
  padding: 18px;
}

.card-score {
  display: grid;
  place-items: center;
  align-self: start;
  min-height: 88px;
  border-radius: 8px;
  background: #eaf2f2;
  color: var(--accent-dark);
}

.card-score strong {
  font-size: 28px;
}

.card-score span {
  font-size: 12px;
  font-weight: 900;
}

.card-score.compact {
  min-height: 54px;
}

.result-card h3,
.profile-card h3,
.mini-card strong {
  margin: 0 0 6px;
  font-size: 18px;
}

.result-card p,
.profile-card p,
.mini-card p {
  margin: 0;
}

.result-card ul {
  margin: 8px 0 0;
  padding-left: 20px;
}

.profile-card {
  padding: 18px;
}

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

.mini-card {
  display: grid;
  gap: 10px;
  padding: 16px;
  border-left: 5px solid var(--gold);
}

.mini-card.low {
  border-left-color: var(--red);
}

.mini-card.high {
  border-left-color: var(--green);
}

.mini-card span,
.mini-card em {
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
  font-weight: 800;
}

.mini-card em {
  justify-self: start;
  border-radius: 999px;
  background: #f0f3f4;
  padding: 4px 9px;
}

@media (max-width: 980px) {
  .topbar,
  .section-heading,
  .result-toolbar {
    align-items: start;
    flex-direction: column;
  }

  .workspace {
    grid-template-columns: 1fr;
    padding: 16px;
  }

  .sidebar {
    position: static;
  }

  .question {
    grid-template-columns: 1fr;
  }

  .rating {
    max-width: 360px;
  }

  .subdomain-grid {
    grid-template-columns: 1fr;
  }

  .intro-view {
    grid-template-columns: 1fr;
    min-height: auto;
  }

  .intro-copy h2 {
    font-size: 36px;
  }
}

@media (max-width: 620px) {
  .topbar {
    padding: 16px;
  }

  .topbar h1,
  .section-heading h2,
  .result-toolbar h2 {
    font-size: 20px;
  }

  .question,
  .domain-section-header,
  .result-card,
  .result-summary {
    padding: 14px;
  }

  .result-summary,
  .result-card {
    grid-template-columns: 1fr;
  }

  .score-dial {
    width: 116px;
    height: 116px;
  }

  .intro-view,
  .test-view,
  .result-view {
    width: min(100% - 28px, 980px);
    padding: 20px 0;
  }

  .intro-copy h2 {
    font-size: 30px;
  }

  .question-card {
    min-height: 0;
    padding: 24px 18px;
  }

  .single-rating {
    grid-template-columns: 1fr;
  }

  .single-rating-option {
    display: grid;
    grid-template-columns: 58px 1fr;
  }

  .single-rating-option span {
    height: 54px;
    border: 1px solid var(--line);
    border-right: 0;
    border-radius: 8px 0 0 8px;
  }

  .single-rating-option strong {
    min-height: 54px;
    border-radius: 0 8px 8px 0;
  }

  .test-actions {
    grid-template-columns: 1fr 1fr;
  }
}

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

  .topbar,
  .sidebar,
  .tabs,
  .toolbar-actions {
    display: none !important;
  }

  .workspace {
    display: block;
    padding: 0;
  }

  .content,
  .result-view {
    display: block;
  }

  #testView {
    display: none !important;
  }

  .hidden {
    display: block !important;
  }

  .result-summary,
  .profile-card,
  .result-card,
  .mini-card {
    break-inside: avoid;
    box-shadow: none;
  }
}
