* {
  box-sizing: border-box;
}

:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --panel: #fbfcfd;
  --text: #17202a;
  --muted: #5c6875;
  --line: #d7e0e7;
  --accent: #146c7c;
  --accent-strong: #0d5361;
  --safe: #228b5b;
  --warn: #b7791f;
  --danger: #b42318;
  --ink: #26323d;
  --focus: rgba(20, 108, 124, .16);
  --shadow: 0 18px 42px rgba(31, 43, 55, .10);
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input:not([type="radio"]):not([type="checkbox"]),
select,
textarea {
  font: inherit;
}

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

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 20px clamp(18px, 4vw, 48px);
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, .94);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-link {
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  width: 48px;
  height: 48px;
  border: 2px solid var(--accent);
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #eef4f6;
  position: relative;
  overflow: hidden;
  flex: 0 0 auto;
}

.brand-mark::before,
.brand-mark::after,
.brand-mark span {
  content: "";
  position: absolute;
  border: 1px solid rgba(20, 108, 124, .55);
  border-radius: 50%;
}

.brand-mark::before {
  width: 32px;
  height: 32px;
}

.brand-mark::after {
  width: 16px;
  height: 16px;
}

.brand-mark span {
  width: 2px;
  height: 24px;
  border: 0;
  border-radius: 0;
  background: var(--danger);
  transform-origin: bottom center;
  transform: rotate(42deg) translateY(-3px);
}

h1 {
  font-size: 1.55rem;
  line-height: 1.1;
}

h2 {
  font-size: 1.22rem;
  line-height: 1.25;
}

h3 {
  font-size: 1rem;
}

.eyebrow {
  color: var(--muted);
  font-size: .76rem;
  text-transform: uppercase;
  font-weight: 800;
  margin-bottom: 4px;
}

.header-badges,
.metric-row,
.report-actions,
.actions-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.header-badges span {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--accent-strong);
  background: #eef4f6;
  font-weight: 800;
  white-space: nowrap;
}

.workspace {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: clamp(18px, 4vw, 42px);
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(340px, .65fr);
  gap: 24px;
  align-items: start;
}

.input-panel {
  min-width: 0;
}

.result-panel,
.report-band {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.panel-heading,
.report-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 18px;
}

.beta-strip,
.validation-summary {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 16px;
  background: #ffffff;
  display: grid;
  gap: 4px;
  line-height: 1.45;
}

.beta-strip span,
.validation-summary li {
  color: var(--muted);
}

.validation-summary {
  border-color: #e7c276;
  background: #fff8e8;
}

.validation-summary ul {
  margin: 6px 0 0;
  padding-left: 20px;
}

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

.question-card,
.field,
.risk-flags,
.privacy-toggle {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.question-card,
.field {
  padding: 14px;
}

.question-card.wide,
.field.wide {
  grid-column: 1 / -1;
}

.question-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.question-top strong {
  font-size: .95rem;
  line-height: 1.3;
}

.yesno {
  display: grid;
  grid-template-columns: repeat(2, 64px);
  gap: 6px;
  flex: 0 0 auto;
}

.yesno input,
.risk-flags input,
.privacy-toggle input {
  accent-color: var(--accent);
}

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

.yesno span {
  display: grid;
  place-items: center;
  min-height: 34px;
  border: 1px solid #c9d3dc;
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
  font-weight: 900;
  cursor: pointer;
}

.yesno input:checked + span {
  background: #dcecef;
  border-color: #94bdc5;
  color: var(--accent-strong);
}

.yesno label:first-child input:checked + span {
  background: #f0f2f4;
  color: #49525c;
}

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

.conditional-field {
  margin-top: 12px;
  padding: 0;
  border: 0;
}

.field span,
.risk-flags legend,
.privacy-toggle span {
  font-size: .9rem;
  font-weight: 800;
}

input:not([type="radio"]):not([type="checkbox"]),
select,
textarea {
  width: 100%;
  min-height: 44px;
  border: 1px solid #c9d3dc;
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  padding: 10px 12px;
  outline: none;
}

textarea {
  resize: vertical;
  min-height: 130px;
}

input:focus,
select:focus,
textarea:focus,
button:focus-visible {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--focus);
}

[hidden] {
  display: none !important;
}

.risk-flags {
  margin: 16px 0 0;
  padding: 14px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 16px;
}

.risk-flags legend {
  padding: 0 8px;
}

.risk-flags label,
.privacy-toggle {
  color: var(--muted);
  line-height: 1.35;
}

.privacy-toggle {
  margin-top: 14px;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  background: #eef4f6;
}

.actions-row {
  margin-top: 18px;
}

button {
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  padding: 0 16px;
  font-weight: 900;
  cursor: pointer;
}

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

.primary-button:hover {
  background: var(--accent-strong);
}

.secondary-button {
  background: var(--ink);
  color: #fff;
}

.ghost-button {
  background: #fff;
  color: var(--accent-strong);
  border: 1px solid var(--line);
}

.result-panel {
  padding: 22px;
  position: sticky;
  top: 96px;
}

.risk-visual {
  position: relative;
  min-height: 206px;
  display: grid;
  place-items: center;
  margin-bottom: 18px;
  background: #f1f5f6;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

#radarCanvas {
  width: 100%;
  max-width: 380px;
  height: 190px;
}

.score-ring {
  position: absolute;
  right: 18px;
  bottom: 14px;
  width: 98px;
  height: 98px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: conic-gradient(var(--safe) 0deg, #d9e3e8 0deg 360deg);
}

.score-ring::before {
  content: "";
  position: absolute;
  inset: 9px;
  border-radius: 50%;
  background: #fff;
}

.score-ring strong,
.score-ring span {
  position: relative;
  z-index: 1;
}

.score-ring strong {
  font-size: 1.6rem;
  line-height: 1;
}

.score-ring span {
  color: var(--muted);
  font-size: .75rem;
  font-weight: 900;
}

.result-summary {
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
}

#resultLead {
  color: var(--muted);
  line-height: 1.45;
}

.metric-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 16px;
}

.metric-row div {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: var(--panel);
  display: grid;
  gap: 2px;
}

.metric-row strong {
  font-size: 1.1rem;
}

.metric-row span {
  color: var(--muted);
  font-size: .78rem;
  font-weight: 800;
}

.signal-list {
  display: grid;
  gap: 10px;
  margin: 14px 0 20px;
}

.signal-item {
  border: 1px solid var(--line);
  border-left: 5px solid var(--warn);
  border-radius: 8px;
  padding: 10px 12px;
  background: var(--panel);
  position: relative;
}

.signal-item.high {
  border-left-color: var(--danger);
}

.signal-item.low,
.signal-item.positive {
  border-left-color: var(--safe);
}

.signal-item strong {
  display: block;
  margin-bottom: 3px;
  padding-right: 44px;
}

.signal-item p,
.empty-state,
.next-steps li {
  color: var(--muted);
  line-height: 1.45;
}

.signal-weight {
  position: absolute;
  top: 9px;
  right: 10px;
  font-size: .72rem;
  font-weight: 900;
  color: var(--muted);
}

.next-steps {
  border-top: 1px solid var(--line);
  padding-top: 16px;
}

.next-steps ul {
  padding-left: 20px;
  margin: 10px 0 0;
}

.report-band {
  width: min(1440px, calc(100% - 2 * clamp(18px, 4vw, 42px)));
  margin: 0 auto 24px;
  padding: clamp(18px, 3vw, 24px);
}

.print-report {
  display: none;
}

.report-band textarea {
  margin-top: 14px;
  min-height: 250px;
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: .9rem;
  line-height: 1.45;
}

.app-footer {
  width: min(1440px, calc(100% - 2 * clamp(18px, 4vw, 42px)));
  margin: 0 auto 42px;
  color: var(--muted);
  line-height: 1.45;
}

.footer-links,
.legal-nav {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.footer-links {
  margin-top: 12px;
}

.footer-links a,
.legal-nav a {
  color: var(--accent-strong);
  font-weight: 900;
  text-decoration: none;
}

.footer-links a:hover,
.legal-nav a:hover,
.brand-link:hover h1 {
  text-decoration: underline;
}

.legal-page {
  background: var(--bg);
}

.legal-main {
  width: min(880px, calc(100% - 2 * clamp(18px, 4vw, 42px)));
  margin: clamp(20px, 5vw, 48px) auto 56px;
  display: grid;
  gap: 18px;
}

.legal-section {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: clamp(18px, 3vw, 26px);
  display: grid;
  gap: 12px;
}

.legal-section p,
.legal-list {
  color: var(--muted);
  line-height: 1.6;
}

.legal-list {
  margin: 0;
  padding-left: 20px;
}

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

  .result-panel {
    position: static;
  }
}

@media (max-width: 760px) {
  .app-header,
  .panel-heading,
  .report-heading,
  .question-top,
  .actions-row,
  .report-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .legal-nav,
  .footer-links {
    align-items: flex-start;
  }

  .intake-grid,
  .risk-flags {
    grid-template-columns: 1fr;
  }

  .header-badges,
  button {
    width: 100%;
    justify-content: center;
  }

  .yesno {
    width: 100%;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .metric-row {
    grid-template-columns: 1fr;
  }
}

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

  .app-header,
  .workspace,
  .report-actions,
  .app-footer {
    display: none !important;
  }

  .report-band {
    width: 100%;
    margin: 0;
    border: 0;
    box-shadow: none;
  }

  .report-band textarea {
    display: none;
  }

  .print-report {
    display: block;
    white-space: pre-wrap;
    font-family: Consolas, monospace;
    line-height: 1.45;
    color: #000;
  }
}


input[type="radio"],
input[type="checkbox"] {
  width: auto;
  min-height: 0;
}

.yesno input[type="radio"],
.risk-flags input[type="checkbox"],
.privacy-toggle input[type="checkbox"] {
  width: auto;
  min-width: 0;
  max-width: none;
  min-height: 0;
}
