:root {
  --bg: #f6f4ee;
  --surface: #fffefa;
  --surface-2: #eef6f3;
  --surface-3: #f4efe7;
  --ink: #18201f;
  --muted: #62716e;
  --line: #d9dfda;
  --line-strong: #b8c3bd;
  --accent: #176b5f;
  --accent-strong: #0f4c45;
  --accent-soft: #dceee9;
  --blue: #295f8f;
  --gold: #946b1f;
  --danger: #9b3f35;
  --shadow: 0 18px 48px rgba(31, 42, 39, 0.11);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(246, 244, 238, 0.86), rgba(246, 244, 238, 0.98)),
    repeating-linear-gradient(90deg, rgba(23, 107, 95, 0.08) 0 1px, transparent 1px 76px),
    repeating-linear-gradient(0deg, rgba(41, 95, 143, 0.06) 0 1px, transparent 1px 76px);
}

button,
textarea,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(1440px, calc(100% - 32px));
  margin: 16px auto;
}

.topbar {
  min-height: 86px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 16px 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 254, 250, 0.88);
  box-shadow: 0 10px 28px rgba(31, 42, 39, 0.06);
  backdrop-filter: blur(8px);
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent-strong);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 0;
  font-size: clamp(1.6rem, 3.5vw, 2.5rem);
  line-height: 1.05;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 8px;
  font-size: 1.12rem;
  line-height: 1.2;
  letter-spacing: 0;
}

h3 {
  margin-bottom: 8px;
  font-size: 1rem;
  line-height: 1.25;
  letter-spacing: 0;
}

.top-actions {
  display: flex;
  gap: 8px;
}

.icon-button {
  width: 44px;
  height: 44px;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  color: var(--ink);
  background: var(--surface);
}

.icon-button:hover,
.icon-button:focus-visible {
  outline: 2px solid var(--accent-soft);
  border-color: var(--accent);
}

.icon-button svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.workspace {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  gap: 16px;
  margin-top: 16px;
}

.sidebar,
.form-surface {
  min-height: calc(100vh - 118px);
}

.sidebar {
  display: grid;
  align-content: start;
  gap: 16px;
}

.status-panel,
.area-panel,
.note-panel,
.form-surface,
.summary-card,
.digest-card,
.case-study-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 254, 250, 0.92);
  box-shadow: 0 10px 28px rgba(31, 42, 39, 0.06);
}

.status-panel {
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr);
  gap: 18px;
  align-items: center;
  padding: 18px;
}

.status-panel p,
.form-header p,
.summary-note,
.note-panel li,
.field-help p,
.example-list,
.digest-card p {
  color: var(--muted);
  line-height: 1.55;
}

.status-ring {
  position: relative;
  width: 96px;
  height: 96px;
}

.status-ring svg {
  width: 96px;
  height: 96px;
  transform: rotate(-90deg);
}

.status-ring circle {
  fill: none;
  stroke-width: 10;
}

.status-ring circle:first-child {
  stroke: var(--surface-3);
}

#progressArc {
  stroke: var(--accent);
  stroke-linecap: round;
  stroke-dasharray: 301.59;
  stroke-dashoffset: 301.59;
  transition: stroke-dashoffset 180ms ease;
}

.status-ring strong {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 1.25rem;
}

.area-panel,
.note-panel {
  padding: 18px;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.section-heading h2 {
  margin: 0;
}

.pill {
  padding: 5px 8px;
  border-radius: 999px;
  color: var(--accent-strong);
  background: var(--accent-soft);
  font-size: 0.75rem;
  font-weight: 800;
}

.area-options {
  display: grid;
  gap: 8px;
}

.area-option {
  width: 100%;
  min-height: 62px;
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: var(--surface);
  text-align: left;
}

.area-option:hover,
.area-option:focus-visible,
.area-option.is-selected {
  outline: none;
  border-color: var(--accent);
  background: var(--surface-2);
}

.area-icon {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--accent-strong);
  background: #ffffff;
}

.area-icon svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.area-name {
  display: block;
  font-weight: 850;
}

.area-caption {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.35;
}

.note-panel ul {
  margin: 0;
  padding-left: 18px;
}

.note-panel li + li {
  margin-top: 8px;
}

.form-surface {
  padding: 20px;
}

.form-header {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  padding: 4px 0 18px;
  border-bottom: 1px solid var(--line);
}

.form-header p {
  max-width: 72ch;
  margin-bottom: 0;
}

.mode-tabs {
  display: inline-flex;
  align-self: start;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-3);
}

.tab {
  min-width: 84px;
  border: 0;
  border-radius: 6px;
  padding: 9px 12px;
  color: var(--muted);
  background: transparent;
  font-weight: 800;
}

.tab.is-active {
  color: var(--ink);
  background: var(--surface);
  box-shadow: 0 4px 12px rgba(31, 42, 39, 0.08);
}

.question-list {
  display: grid;
  gap: 14px;
  margin-top: 18px;
}

.case-study-card {
  padding: 18px;
  border-color: rgba(41, 95, 143, 0.24);
  background: linear-gradient(135deg, #f7fbff, #fffefa);
}

.case-study-card h3 {
  margin: 10px 0 6px;
  font-size: 1.08rem;
}

.case-study-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.case-study-summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: start;
}

.case-study-toggle {
  white-space: nowrap;
}

.case-study-details[hidden] {
  display: none;
}

.case-study-details {
  display: grid;
  gap: 10px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid rgba(41, 95, 143, 0.18);
}

.case-study-details-heading {
  padding: 14px;
  border: 1px solid rgba(41, 95, 143, 0.2);
  border-radius: 8px;
  background: #eef6fb;
}

.case-study-details-heading h4 {
  margin: 0 0 5px;
  font-size: 1rem;
}

.case-study-details-heading p {
  margin: 0;
}

.case-study-response {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.case-study-response h4 {
  margin: 0 0 8px;
  font-size: 0.96rem;
  line-height: 1.3;
}

.case-study-response p + p {
  margin-top: 6px;
}

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

.question-section > h3 {
  margin: 8px 0 0;
  padding: 10px 0 2px;
  color: var(--accent-strong);
  font-size: 0.9rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.question-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  overflow: hidden;
}

.question-card.has-yes {
  border-color: rgba(23, 107, 95, 0.42);
}

.question-main {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  padding: 18px;
}

.question-main label {
  display: block;
  font-weight: 850;
  line-height: 1.32;
}

.question-subtitle {
  margin: 6px 0 0;
  color: var(--muted);
  line-height: 1.5;
}

.info-button {
  width: 34px;
  height: 34px;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  color: var(--accent-strong);
  background: var(--surface-2);
  font-weight: 900;
}

.info-button:hover,
.info-button:focus-visible {
  outline: 2px solid var(--accent-soft);
}

.field-help {
  display: none;
  padding: 0 18px 18px;
}

.question-card.is-open .field-help {
  display: block;
}

.field-help-inner {
  padding: 14px;
  border-radius: 8px;
  background: var(--surface-2);
}

.field-help p {
  margin-bottom: 0;
}

.example-list {
  margin: 0;
  padding-left: 18px;
}

.example-list li + li {
  margin-top: 6px;
}

.choice-group,
.follow-up-group {
  margin: 0 18px 18px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.choice-group legend,
.follow-up-group legend {
  padding: 0 6px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 850;
}

.choice-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.choice-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 8px 11px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  color: var(--ink);
  background: var(--surface);
  font-weight: 800;
}

.choice-pill:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.choice-pill input,
.check-row input {
  accent-color: var(--accent);
}

.follow-up-group {
  display: grid;
  gap: 10px;
  background: var(--surface-2);
}

.check-row {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  color: var(--ink);
  line-height: 1.42;
}

.answer-area {
  display: grid;
  gap: 8px;
  padding: 0 18px 18px;
}

.note-label {
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 850;
}

.answer-area textarea {
  width: 100%;
  min-height: 78px;
  resize: vertical;
  padding: 12px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  color: var(--ink);
  background: #fff;
  line-height: 1.48;
}

.answer-area textarea:focus {
  outline: 3px solid var(--accent-soft);
  border-color: var(--accent);
}

.meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 0.82rem;
}

.summary-view {
  display: grid;
  gap: 16px;
  margin-top: 18px;
}

.summary-card {
  padding: 18px;
}

.report-card {
  border-color: rgba(41, 95, 143, 0.26);
}

.report-preview {
  display: grid;
  gap: 16px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.report-header {
  padding-bottom: 16px;
  border-bottom: 2px solid var(--accent);
}

.report-header h1 {
  margin-bottom: 10px;
  font-size: 1.7rem;
}

.report-meta {
  margin: 0 0 4px;
  color: var(--muted);
}

.report-section {
  display: grid;
  gap: 10px;
}

.report-section h2 {
  color: var(--accent-strong);
}

.report-summary {
  white-space: pre-wrap;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
}

.report-question {
  break-inside: avoid;
  padding: 12px 0;
  border-top: 1px solid var(--line);
}

.report-question p {
  margin-bottom: 7px;
  color: var(--muted);
}

.text-button {
  min-height: 38px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  padding: 8px 12px;
  color: #fff;
  background: var(--accent);
  font-weight: 850;
}

.text-button:hover,
.text-button:focus-visible {
  outline: 3px solid var(--accent-soft);
  background: var(--accent-strong);
}

#summaryText {
  width: 100%;
  resize: vertical;
  padding: 14px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  color: var(--ink);
  background: #fff;
  line-height: 1.55;
}

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

.digest-card {
  padding: 16px;
}

.digest-card p {
  margin-bottom: 8px;
  white-space: pre-wrap;
}

.digest-card p:last-child {
  margin-bottom: 0;
}

.empty-state {
  padding: 32px;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  color: var(--muted);
  background: rgba(255, 254, 250, 0.74);
  text-align: center;
}

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

  .sidebar,
  .form-surface {
    min-height: auto;
  }

  .form-header {
    flex-direction: column;
  }

  .case-study-summary {
    grid-template-columns: 1fr;
  }

  .case-study-toggle {
    justify-self: start;
  }
}

@media (max-width: 620px) {
  .app-shell {
    width: min(100% - 18px, 1440px);
    margin: 9px auto;
  }

  .topbar,
  .status-panel {
    grid-template-columns: 1fr;
  }

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

  .top-actions {
    width: 100%;
    justify-content: flex-end;
  }

  .form-surface {
    padding: 14px;
  }

  .mode-tabs {
    width: 100%;
  }

  .tab {
    flex: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition: none !important;
    scroll-behavior: auto !important;
  }
}

@media print {
  body.printing-report {
    background: #fff;
  }

  body.printing-report .topbar,
  body.printing-report .sidebar,
  body.printing-report .form-header,
  body.printing-report .summary-card:not(.report-card),
  body.printing-report .summary-grid,
  body.printing-report .report-card > .section-heading,
  body.printing-report .report-card > .summary-note {
    display: none !important;
  }

  body.printing-report .app-shell,
  body.printing-report .workspace,
  body.printing-report .form-surface,
  body.printing-report .summary-view,
  body.printing-report .report-card {
    display: block !important;
    width: auto;
    min-height: auto;
    margin: 0;
    padding: 0;
    border: 0;
    box-shadow: none;
    background: #fff;
  }

  body.printing-report .report-preview {
    border: 0;
    padding: 0;
  }
}
