:root {
  color-scheme: light;
  --bg: #f5f7f8;
  --surface: #ffffff;
  --text: #17202a;
  --muted: #5d6875;
  --line: #d9e0e6;
  --primary: #0b6f70;
  --primary-dark: #075657;
  --accent: #8a3ffc;
  --danger: #b42318;
  --focus: #f6c343;
  --success-bg: #edf8f2;
  --success: #17633a;
  --warning-bg: #fff8e6;
  --warning: #8a5a13;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
}

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

.app-shell {
  width: min(100%, 760px);
  margin: 0 auto;
  padding: 18px;
}

.screen {
  display: none;
}

.screen.active {
  display: block;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 2px 18px;
}

.topbar.compact {
  align-items: center;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--primary);
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  overflow-wrap: anywhere;
}

h1 {
  margin: 0;
  font-size: clamp(1.75rem, 2.2rem, 2.2rem);
  line-height: 1.08;
}

h2 {
  margin: 0 0 16px;
  font-size: 1.35rem;
  line-height: 1.25;
}

.panel,
.score-card,
.tile {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(23, 32, 42, 0.08);
}

.panel {
  padding: 18px;
}

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

.landing-grid {
  display: grid;
  gap: 12px;
}

.tile {
  display: grid;
  gap: 6px;
  width: 100%;
  min-height: 84px;
  padding: 18px;
  text-align: left;
  color: var(--text);
  background: #fff;
}

.tool-link {
  text-decoration: none;
}

.tool-link:hover {
  border-color: var(--primary);
  background: #f8fcfc;
}

.tile strong {
  font-size: 1.12rem;
}

.tile span {
  color: var(--muted);
  font-weight: 600;
}

.field {
  display: grid;
  gap: 7px;
  margin-bottom: 16px;
  color: var(--muted);
  font-weight: 650;
}

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

select:focus,
input:focus,
button:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

button {
  min-height: 48px;
  border: 0;
  border-radius: 6px;
  padding: 11px 16px;
  cursor: pointer;
  font-weight: 750;
}

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

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

.primary:not(:disabled):hover {
  background: var(--primary-dark);
}

.copy-confirmed {
  background: #17633a;
  color: #fff;
}

.copy-confirmed:not(:disabled):hover {
  background: #17633a;
}

.secondary {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
}

.ghost {
  display: inline-grid;
  place-items: center;
  min-height: 40px;
  background: transparent;
  color: var(--primary);
  padding-inline: 8px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.action-full {
  width: 100%;
}

.question-panel {
  display: grid;
  gap: 20px;
}

.instruction,
.helper {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.language-row {
  display: grid;
  gap: 7px;
  margin-bottom: 14px;
}

.language-row label {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}

.segmented-control {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.segment {
  min-height: 44px;
  border-radius: 0;
  background: #fff;
  color: var(--muted);
}

.segment + .segment {
  border-left: 1px solid var(--line);
}

.segment.selected {
  background: var(--primary);
  color: #fff;
}

.input-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.input-grid[hidden],
.results-block[hidden] {
  display: none;
}

.answers {
  display: grid;
  gap: 10px;
}

.answer {
  display: grid;
  grid-template-columns: 42px 1fr;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 62px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  text-align: left;
}

.answer .number {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 50%;
  background: #e8f2f2;
  color: var(--primary-dark);
  font-weight: 800;
}

.answer.selected {
  border-color: var(--primary);
  background: #eaf7f7;
}

.nav-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 14px;
}

.score-card {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  margin-bottom: 14px;
  overflow: hidden;
}

.score-card.item-nine-positive {
  border-color: #c53030;
  box-shadow: 0 0 0 3px rgba(197, 48, 48, 0.16), 0 1px 3px rgba(23, 32, 42, 0.08);
}

.score-card > div {
  padding: 18px;
  background: #fff;
}

.score-card > div:last-child {
  border-left: 6px solid var(--primary);
  background: #eaf7f7;
}

.score-card.score-normal > div:last-child {
  background: #edf8f2;
  border-left-color: #228b52;
}

.score-card.score-mild > div:last-child {
  background: #fff8e6;
  border-left-color: #b7791f;
}

.score-card.score-moderate > div:last-child {
  background: #fff1e8;
  border-left-color: #c05621;
}

.score-card.score-moderately-severe > div:last-child,
.score-card.score-severe > div:last-child {
  background: #fff0f0;
  border-left-color: #c53030;
}

.score-card.item-nine-positive > div:last-child {
  background: #fff0f0;
  border-left-color: #c53030;
}

.score-card.score-normal .interpretation-value {
  color: #17633a;
}

.score-card.score-mild .interpretation-value {
  color: #8a5a13;
}

.score-card.score-moderate .interpretation-value {
  color: #9a3412;
}

.score-card.score-moderately-severe .interpretation-value,
.score-card.score-severe .interpretation-value {
  color: #9b1c1c;
}

.score-card.item-nine-positive .interpretation-value {
  color: #9b1c1c;
}

.alert-card {
  margin: 0 0 14px;
  border: 1px solid #c53030;
  border-left: 6px solid #c53030;
  border-radius: 8px;
  padding: 16px;
  background: #fff0f0;
  color: #9b1c1c;
  box-shadow: 0 0 0 3px rgba(197, 48, 48, 0.14), 0 1px 3px rgba(23, 32, 42, 0.08);
}

.alert-card strong {
  display: block;
  margin-bottom: 6px;
  font-size: 1.12rem;
}

.alert-card p {
  margin: 0;
  color: #681515;
  line-height: 1.4;
}

.support-result {
  display: grid;
  gap: 14px;
  margin-top: 14px;
}

.support-result[hidden] {
  display: none;
}

.support-summary,
.support-block,
.support-metric-card,
.support-details-card,
.support-category-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 1px 3px rgba(23, 32, 42, 0.08);
}

.support-summary {
  padding: 18px;
  border-left: 8px solid var(--primary);
}

.support-summary.support-low {
  border-left-color: #228b52;
  background: #edf8f2;
}

.support-summary.support-watch {
  border-left-color: #b7791f;
  background: #fff8e6;
}

.support-summary.support-high {
  border-color: #c53030;
  border-left-color: #c53030;
  background: #fff0f0;
  box-shadow: 0 0 0 3px rgba(197, 48, 48, 0.14), 0 1px 3px rgba(23, 32, 42, 0.08);
}

.support-level {
  display: inline-grid;
  margin-bottom: 10px;
  border-radius: 999px;
  padding: 5px 10px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--text);
  font-size: 0.82rem;
  font-weight: 850;
  text-transform: uppercase;
}

.support-summary h2 {
  margin-bottom: 8px;
  font-size: 1.55rem;
}

.support-action {
  margin: 0;
  color: var(--text);
  font-size: 1.18rem;
  font-weight: 800;
  line-height: 1.32;
}

.support-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.support-block {
  padding: 15px 16px;
}

.support-block span,
.support-details-card h3,
.support-category-card h3,
.support-result > h3 {
  display: block;
  margin: 0 0 7px;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 850;
  text-transform: uppercase;
}

.support-block p {
  margin: 0;
  color: var(--text);
  font-weight: 750;
  line-height: 1.38;
}

.support-metric-card {
  border-color: #c05621;
  border-left: 8px solid #c05621;
  padding: 16px 18px;
  background: #fff1e8;
  box-shadow: 0 0 0 3px rgba(192, 86, 33, 0.14), 0 1px 3px rgba(23, 32, 42, 0.08);
}

.support-metric-card[hidden] {
  display: none;
}

.support-metric-card span {
  display: block;
  margin-bottom: 7px;
  color: #9a3412;
  font-size: 0.84rem;
  font-weight: 900;
  text-transform: uppercase;
}

.support-metric-card strong {
  display: block;
  margin-bottom: 6px;
  color: #17202a;
  font-size: 1.45rem;
  line-height: 1.12;
}

.support-metric-card p {
  margin: 0;
  color: #5f2b12;
  font-weight: 750;
  line-height: 1.35;
}

.support-details-card {
  padding: 15px 16px;
}

.support-category-card {
  padding: 15px 16px;
}

.support-category-card[hidden] {
  display: none;
}

.support-details-card ul,
.support-details-card ol {
  margin: 0;
  padding-left: 20px;
}

.support-details-card li {
  margin: 0 0 8px;
  line-height: 1.42;
}

.support-details-card li:last-child {
  margin-bottom: 0;
}

.support-caution {
  color: #8a5a13;
  font-weight: 750;
}

.support-chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.support-chip {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 10px;
  background: #f9fbfc;
  color: var(--text);
  font-size: 0.92rem;
  font-weight: 700;
  line-height: 1.2;
}

.score-breakdown {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 0 0 14px;
}

.score-breakdown[hidden] {
  display: none;
}

.score-breakdown > div {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px 16px;
  background: #fff;
  box-shadow: 0 1px 3px rgba(23, 32, 42, 0.08);
}

.score-breakdown strong {
  display: block;
  font-size: 1.6rem;
  line-height: 1.1;
}

.score-label {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}

#score-value,
#interpretation-value,
.score-value,
.interpretation-value {
  display: block;
  font-size: 2rem;
  line-height: 1.1;
}

.copy-preview {
  max-height: 280px;
  overflow: auto;
  margin: 0 0 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 12px;
  background: #f9fbfc;
  color: #26313d;
  white-space: pre-wrap;
}

.status {
  min-height: 22px;
  margin: 0 0 12px;
  color: var(--primary-dark);
  font-weight: 700;
}

.result-timestamp {
  margin: -4px 0 16px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 600;
}

.result-timestamp span {
  font-weight: 700;
}

.completion-card {
  display: grid;
  gap: 18px;
  padding: 24px 18px;
  text-align: center;
}

.completion-card h2 {
  margin-bottom: 0;
}

.version-footer {
  display: flex;
  justify-content: center;
  gap: 8px;
  width: min(100% - 32px, 900px);
  margin: 0 auto 24px;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.4;
}

@media (min-width: 680px) {
  .app-shell {
    padding-top: 34px;
  }

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

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

  .language-row {
    grid-template-columns: 160px 1fr;
    align-items: center;
  }
}
