:root {
  color-scheme: light;
  --ink: #1c1917;
  --muted: #6b625b;
  --line: #ded8d0;
  --surface: #ffffff;
  --canvas: #f7f4ef;
  --paper: #fffcf7;
  --red: #b42318;
  --red-soft: #fff0ed;
  --yellow: #b56a08;
  --yellow-soft: #fff6df;
  --green: #2f6f4e;
  --green-soft: #eaf7ee;
  --teal: #0f766e;
  --teal-soft: #e7f6f4;
  --focus: #2f6f4e;
  --shadow: 0 18px 42px rgba(48, 36, 26, 0.12);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.76), rgba(247, 244, 239, 0.92)),
    var(--canvas);
  color: var(--ink);
  font-family: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", system-ui, -apple-system, sans-serif;
  line-height: 1.5;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 3px solid rgba(47, 111, 78, 0.25);
  outline-offset: 2px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px clamp(16px, 4vw, 40px);
  border-bottom: 1px solid rgba(222, 216, 208, 0.92);
  background: rgba(255, 252, 247, 0.94);
  backdrop-filter: blur(16px);
}

.topbar h1 {
  margin: 2px 0 0;
  font-size: clamp(1.15rem, 2vw, 1.7rem);
  line-height: 1.2;
}

.eyebrow,
.section-kicker,
.mini-label {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

.primary-button,
.ghost-button {
  min-height: 42px;
  border-radius: 8px;
  padding: 10px 14px;
  border: 1px solid transparent;
  font-weight: 800;
  white-space: nowrap;
}

.primary-button {
  background: var(--ink);
  color: #fff;
  box-shadow: 0 10px 22px rgba(28, 25, 23, 0.16);
}

.primary-button:hover {
  background: #382f2a;
}

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

.ghost-button:hover {
  border-color: #bfb5aa;
  background: var(--paper);
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(310px, 390px);
  gap: 20px;
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 20px clamp(12px, 3vw, 34px) 34px;
}

.assessment-panel,
.score-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
}

.assessment-panel {
  min-width: 0;
  align-self: start;
  overflow: hidden;
}

.step-nav {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  border-bottom: 1px solid var(--line);
  background: #fffaf2;
}

.step-chip {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 54px;
  border: 0;
  border-right: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  font-size: 0.95rem;
  font-weight: 800;
}

.step-chip:last-child {
  border-right: 0;
}

.step-chip span {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  background: #efe8dd;
  color: var(--ink);
  font-size: 0.78rem;
}

.step-chip.active {
  background: var(--surface);
  color: var(--ink);
}

.step-chip.active span {
  background: var(--ink);
  color: #fff;
}

.progress-wrap {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 14px 22px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.progress-track {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #efe8dd;
}

.progress-fill {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--red), var(--yellow), var(--green));
  transition: width 220ms ease;
}

#progress-label {
  min-width: 58px;
  color: var(--muted);
  font-weight: 800;
  text-align: right;
}

.step-page {
  display: none;
  padding: clamp(18px, 3vw, 34px);
}

.step-page.active {
  display: block;
}

.section-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.section-head h2 {
  margin: 4px 0 0;
  font-size: clamp(1.25rem, 2vw, 1.8rem);
  line-height: 1.28;
}

.section-kicker.red {
  color: var(--red);
}

.section-kicker.yellow {
  color: var(--yellow);
}

.section-kicker.green {
  color: var(--green);
}

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

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

.field span {
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 800;
}

.field em {
  margin-left: 4px;
  color: var(--red);
  font-size: 0.76rem;
  font-style: normal;
  font-weight: 900;
}

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

.field input:invalid:not(:placeholder-shown) {
  border-color: rgba(180, 35, 24, 0.65);
  background: var(--red-soft);
}

.method-band {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(140px, 190px);
  gap: 18px;
  align-items: center;
  margin-top: 20px;
  padding: 18px;
  border: 1px solid #d8c6a9;
  border-radius: 8px;
  background: #fff8e8;
}

.method-band h3 {
  margin: 5px 0 8px;
  font-size: 1.05rem;
  overflow-wrap: anywhere;
}

.source-checks {
  white-space: nowrap;
}

.source-chapter {
  white-space: nowrap;
}

.method-band p:last-child {
  margin: 0;
  color: #5f5147;
  overflow-wrap: anywhere;
}

.method-band img {
  display: block;
  justify-self: center;
  width: min(100%, 172px);
  height: auto;
  object-fit: contain;
  border-radius: 8px;
  border: 1px solid rgba(181, 106, 8, 0.28);
  box-shadow: 0 18px 34px rgba(49, 38, 28, 0.16);
}

.question-list {
  display: grid;
  gap: 12px;
}

.question-row {
  display: grid;
  grid-template-columns: 74px minmax(0, 1fr) 176px;
  gap: 16px;
  align-items: center;
  min-height: 96px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.question-code {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  border-radius: 8px;
  color: #fff;
  font-weight: 900;
}

.zone-red .question-code {
  background: var(--red);
}

.zone-yellow .question-code {
  background: var(--yellow);
}

.zone-green .question-code {
  background: var(--green);
}

.question-main {
  min-width: 0;
}

.question-main p {
  margin: 0;
  color: var(--ink);
  font-size: clamp(0.96rem, 1.35vw, 1.06rem);
  font-weight: 750;
  line-height: 1.55;
}

.question-main small {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 0.82rem;
}

.answer-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  width: 176px;
  min-height: 46px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f5f1eb;
}

.answer-toggle button {
  border: 0;
  border-right: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  font-weight: 900;
}

.answer-toggle button:last-child {
  border-right: 0;
}

.answer-toggle button.active {
  background: var(--ink);
  color: #fff;
}

.answer-toggle button.triggered {
  background: #fff4d9;
  color: #6f4000;
}

.panel-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px clamp(18px, 3vw, 34px);
  border-top: 1px solid var(--line);
  background: #fffaf2;
}

.score-panel {
  position: sticky;
  top: 94px;
  display: grid;
  align-self: start;
  gap: 14px;
}

.score-card {
  padding: 18px;
  box-shadow: 0 12px 28px rgba(48, 36, 26, 0.09);
}

.level-card {
  background: var(--ink);
  color: #fff;
  border-color: var(--ink);
}

.level-card .mini-label,
.level-card .score-note {
  color: rgba(255, 255, 255, 0.72);
}

.score-number {
  margin: 6px 0;
  font-size: clamp(3rem, 7vw, 5.4rem);
  font-weight: 950;
  line-height: 0.98;
  font-variant-numeric: tabular-nums;
}

.level-pill {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 6px 11px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  font-size: 0.95rem;
  font-weight: 900;
}

.score-note {
  margin: 12px 0 0;
  font-size: 0.9rem;
}

.score-bars {
  display: grid;
  gap: 12px;
}

.bar-row {
  display: grid;
  gap: 7px;
}

.bar-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-weight: 850;
}

.bar-track {
  height: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: #efe8dd;
}

.bar-fill {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  transition: width 220ms ease;
}

.bar-fill.red {
  background: var(--red);
}

.bar-fill.yellow {
  background: var(--yellow);
}

.bar-fill.green {
  background: var(--green);
}

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

.matrix-head span {
  color: var(--muted);
  font-weight: 850;
}

.radar {
  position: relative;
  width: min(100%, 250px);
  aspect-ratio: 1;
  margin: 16px auto 10px;
  border-radius: 50%;
  background:
    radial-gradient(circle, rgba(255,255,255,0.98) 0 16%, transparent 17%),
    conic-gradient(from -90deg, rgba(180, 35, 24, 0.15), rgba(181, 106, 8, 0.14), rgba(47, 111, 78, 0.15), rgba(180, 35, 24, 0.15));
  border: 1px solid var(--line);
}

.radar-ring {
  position: absolute;
  inset: 18%;
  border: 1px dashed rgba(107, 98, 91, 0.35);
  border-radius: 50%;
}

.radar-ring.ring-2 {
  inset: 34%;
}

.radar-axis {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 1px;
  height: 45%;
  transform-origin: top;
  background: rgba(107, 98, 91, 0.32);
}

.axis-red {
  transform: rotate(-90deg);
}

.axis-yellow {
  transform: rotate(30deg);
}

.axis-green {
  transform: rotate(150deg);
}

.radar-dot {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 16px;
  height: 16px;
  border: 3px solid #fff;
  border-radius: 50%;
  box-shadow: 0 6px 14px rgba(28, 25, 23, 0.24);
  transform: translate(-50%, -50%);
  transition: transform 220ms ease;
}

.dot-red {
  background: var(--red);
}

.dot-yellow {
  background: var(--yellow);
}

.dot-green {
  background: var(--green);
}

.legend {
  display: flex;
  justify-content: center;
  gap: 16px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 850;
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.legend i {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.red-bg {
  background: var(--red);
}

.yellow-bg {
  background: var(--yellow);
}

.green-bg {
  background: var(--green);
}

.formula {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 10px 0 14px;
  color: var(--ink);
  font-size: 1.55rem;
  font-weight: 950;
  font-variant-numeric: tabular-nums;
}

.formula span {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 8px;
  background: var(--paper);
  border: 1px solid var(--line);
}

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

.thresholds li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
  border-top: 1px solid var(--line);
}

.thresholds span {
  color: var(--muted);
  font-weight: 850;
}

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

.report-profile {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 14px;
}

.report-profile > div {
  min-width: 0;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff8e8;
}

.report-profile strong {
  display: block;
  margin-top: 4px;
  overflow-wrap: anywhere;
  color: var(--ink);
}

.report-block,
.recommendation-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.report-block {
  padding: 18px;
}

.report-block strong {
  display: block;
  margin: 5px 0;
  font-size: 1.45rem;
}

.report-block p {
  margin: 0;
  color: var(--muted);
}

.recommendation-list {
  display: grid;
  gap: 12px;
  margin-top: 14px;
}

.recommendation-card {
  display: grid;
  grid-template-columns: 8px minmax(0, 1fr);
  overflow: hidden;
}

.recommendation-stripe.red {
  background: var(--red);
}

.recommendation-stripe.yellow {
  background: var(--yellow);
}

.recommendation-stripe.green {
  background: var(--green);
}

.recommendation-body {
  padding: 16px;
}

.recommendation-body h3 {
  margin: 0 0 8px;
  font-size: 1.05rem;
}

.recommendation-body p {
  margin: 0;
  color: var(--muted);
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 30;
  max-width: min(360px, calc(100vw - 36px));
  padding: 12px 14px;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  font-weight: 850;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 1080px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .score-panel {
    position: static;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .level-card {
    grid-column: 1 / -1;
  }
}

@media (max-width: 760px) {
  body {
    overflow-x: hidden;
  }

  .topbar,
  .panel-footer {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar,
  .app-shell {
    max-width: 100vw;
  }

  .app-shell {
    padding-inline: 14px;
    overflow-x: hidden;
  }

  .topbar-actions {
    display: grid;
    grid-template-columns: 1fr;
    align-self: stretch;
    min-width: 0;
    max-width: calc(100vw - 40px);
  }

  .footer-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    width: 100%;
  }

  .primary-button,
  .ghost-button {
    min-width: 0;
    width: 100%;
  }

  .step-nav {
    grid-template-columns: 1fr;
  }

  .step-chip {
    justify-content: flex-start;
    padding: 0 18px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .profile-grid,
  .method-band,
  .report-profile,
  .report-grid,
  .score-panel {
    grid-template-columns: 1fr;
  }

  .method-band img {
    width: min(180px, 58vw);
  }

  .source-checks {
    display: block;
    margin-top: 2px;
  }

  .source-chapter {
    display: block;
    white-space: normal;
  }

  .method-band p:last-child {
    word-break: break-word;
  }

  .question-row {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .answer-toggle {
    width: 100%;
  }

  .section-head {
    display: block;
  }

  .progress-wrap {
    padding-inline: 16px;
  }
}

@media (max-width: 420px) {
  .topbar-actions {
    align-self: flex-start;
    width: calc(100vw - 48px);
    max-width: calc(100vw - 48px);
  }
}

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

  .topbar,
  .step-nav,
  .progress-wrap,
  .panel-footer,
  .toast {
    display: none !important;
  }

  .app-shell {
    display: block;
    padding: 0;
  }

  .assessment-panel,
  .score-card,
  .report-block,
  .recommendation-card {
    box-shadow: none;
  }

  .score-panel {
    margin-top: 14px;
  }

  .step-page {
    display: none !important;
  }

  #step-result {
    display: block !important;
  }
}
