:root {
  --bg: #f7f3ea;
  --panel: #fffdf7;
  --ink: #252321;
  --muted: #6f6a5f;
  --line: #dfd7c8;
  --olive: #6f7d3e;
  --olive-soft: #edf1dd;
  --copper: #c66b42;
  --copper-soft: #faeadf;
  --blue: #607887;
  --shadow: 0 18px 48px rgba(37, 35, 33, .08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(111, 125, 62, .14), transparent 34rem),
    radial-gradient(circle at 100% 10%, rgba(198, 107, 66, .12), transparent 25rem),
    var(--bg);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

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

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 390px minmax(0, 1fr);
}

.brand-panel {
  position: sticky;
  top: 0;
  height: 100vh;
  display: grid;
  align-content: space-between;
  gap: 28px;
  padding: 34px;
  border-right: 1px solid var(--line);
  background: rgba(255, 253, 247, .72);
  backdrop-filter: blur(10px);
}

.brand img {
  width: min(100%, 300px);
  display: block;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--olive);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .12em;
  text-transform: uppercase;
}

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

h1 {
  max-width: 330px;
  margin-bottom: 14px;
  font-size: 38px;
  line-height: 1.03;
  letter-spacing: 0;
}

h2 {
  max-width: 760px;
  margin-bottom: 0;
  font-size: 34px;
  line-height: 1.08;
  letter-spacing: 0;
}

h3 {
  margin-bottom: 0;
  font-size: 24px;
  line-height: 1.16;
  letter-spacing: 0;
}

h4 {
  margin-bottom: 8px;
  font-size: 17px;
}

p {
  color: var(--muted);
  line-height: 1.55;
}

.mini-report {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #26231f;
  box-shadow: var(--shadow);
}

.mini-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
  color: #f7f3ea;
}

.mini-head span,
.mini-report small {
  color: #c6bea9;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.mini-head strong {
  color: #d4df94;
  font-size: 42px;
}

.mini-bars {
  height: 110px;
  display: flex;
  align-items: end;
  gap: 10px;
  margin: 18px 0;
  padding-top: 16px;
  border-top: 1px solid rgba(255, 255, 255, .12);
}

.mini-bars span {
  flex: 1;
  height: var(--h);
  min-height: 18px;
  border-radius: 7px 7px 3px 3px;
  background: linear-gradient(180deg, #c66b42, #7d8c45);
}

.diagnostic {
  width: min(100%, 1180px);
  padding: 34px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: start;
  margin-bottom: 24px;
}

.pill {
  display: inline-flex;
  min-height: 34px;
  align-items: center;
  padding: 7px 12px;
  border-radius: 999px;
  background: var(--olive-soft);
  color: #52602b;
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 330px;
  gap: 18px;
  align-items: start;
}

.form-card,
.result-card,
.plan-card,
.final-report,
.ai-report {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 247, .84);
  box-shadow: var(--shadow);
}

.form-card {
  padding: 20px;
}

.stepper {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 22px;
}

.step {
  min-height: 58px;
  display: grid;
  place-items: center;
  gap: 2px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--muted);
  cursor: pointer;
  font-weight: 900;
}

.step span {
  font-size: 12px;
  font-weight: 800;
}

.step.is-active {
  border-color: #26231f;
  background: #26231f;
  color: #fffdf7;
}

.section-head {
  margin-bottom: 18px;
}

.form-step { display: none; }
.form-step.is-active { display: grid; gap: 18px; }

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

label,
fieldset {
  display: grid;
  gap: 8px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 900;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf7;
  color: var(--ink);
  font-weight: 700;
}

input { min-height: 45px; padding: 0 12px; }
select { min-height: 45px; padding: 0 12px; }
textarea { resize: vertical; padding: 12px; line-height: 1.45; }

fieldset {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 252, 246, .58);
}

legend {
  padding: 0 7px;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

fieldset label {
  min-height: 42px;
  grid-template-columns: 18px 1fr;
  align-items: center;
  gap: 9px;
  padding: 9px;
  border-radius: 7px;
  background: #fffdf7;
}

input[type="checkbox"],
input[type="radio"] {
  accent-color: var(--olive);
}

.pain-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 22px;
}

.button {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 15px;
  background: #fffdf7;
  color: var(--ink);
  font-weight: 900;
  cursor: pointer;
}

.button-primary {
  border-color: #26231f;
  background: #26231f;
  color: #fffdf7;
}

.is-hidden { display: none; }

.result-card {
  position: sticky;
  top: 24px;
  display: grid;
  gap: 18px;
  padding: 20px;
}

.score-ring {
  --score: 0;
  width: 190px;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  justify-self: center;
  border-radius: 50%;
  background:
    radial-gradient(circle at center, var(--panel) 0 58%, transparent 59%),
    conic-gradient(var(--olive) calc(var(--score) * 1%), #e7dfcf 0);
}

.score-ring strong {
  font-size: 48px;
  line-height: .9;
}

.score-ring span {
  margin-top: 52px;
  position: absolute;
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

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

.module-list span {
  padding: 8px 10px;
  border-radius: 999px;
  background: var(--olive-soft);
  color: #52602b;
  font-size: 12px;
  font-weight: 900;
}

.score-help {
  display: block;
  margin-top: 8px;
  color: var(--olive);
  font-size: 12px;
  font-weight: 900;
}

.plan-card {
  margin-top: 18px;
  padding: 20px;
}

.final-report {
  margin-top: 18px;
  padding: 20px;
  border-color: rgba(111, 125, 62, .38);
  background:
    linear-gradient(135deg, rgba(237, 241, 221, .72), rgba(255, 253, 247, .92)),
    var(--panel);
}

.ai-report {
  margin-top: 18px;
  padding: 20px;
  border-color: rgba(198, 107, 66, .35);
  background:
    linear-gradient(135deg, rgba(250, 234, 223, .76), rgba(255, 253, 247, .92)),
    var(--panel);
}

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

.report-head span {
  display: inline-flex;
  min-height: 32px;
  align-items: center;
  padding: 7px 10px;
  border-radius: 999px;
  background: #26231f;
  color: #fffdf7;
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

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

.report-grid article {
  min-height: 150px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 247, .82);
}

.report-grid span {
  display: block;
  margin-bottom: 12px;
  color: var(--olive);
  font-size: 11px;
  font-weight: 950;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.report-grid p {
  margin-bottom: 0;
}

.report-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}

.ai-body {
  display: grid;
  grid-template-columns: 1.1fr .9fr 1fr;
  gap: 12px;
}

.ai-loading-panel {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 14px;
  align-items: center;
  margin-bottom: 14px;
  padding: 14px;
  border: 1px solid rgba(198, 107, 66, .28);
  border-radius: 8px;
  background: rgba(255, 253, 247, .78);
}

.ai-loading-panel.is-hidden {
  display: none;
}

.ai-loading-panel strong {
  display: block;
  margin-bottom: 3px;
  font-size: 15px;
}

.ai-loading-panel p {
  margin-bottom: 0;
  font-size: 13px;
}

.ai-body article {
  min-height: 190px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 247, .84);
}

.ai-body span {
  display: block;
  margin-bottom: 12px;
  color: var(--copper);
  font-size: 11px;
  font-weight: 950;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.thinking-indicator {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 28px;
  margin: 0 0 10px;
}

.thinking-indicator.is-hidden {
  display: none;
}

.thinking-indicator i {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--copper);
  opacity: .36;
  animation: thinkingPulse 1.15s ease-in-out infinite;
}

.thinking-indicator i:nth-child(2) {
  animation-delay: .16s;
}

.thinking-indicator i:nth-child(3) {
  animation-delay: .32s;
}

@keyframes thinkingPulse {
  0%, 80%, 100% {
    transform: translateY(0) scale(.85);
    opacity: .34;
  }
  35% {
    transform: translateY(-5px) scale(1);
    opacity: .95;
  }
}

.ai-body p,
.ai-body ul {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.ai-body ul {
  padding-left: 18px;
}

.ai-body li + li {
  margin-top: 8px;
}

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

.plan-grid article {
  min-height: 190px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.plan-grid span {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  margin-bottom: 28px;
  border-radius: 8px;
  background: var(--copper-soft);
  color: var(--copper);
  font-weight: 950;
}

@media (max-width: 1040px) {
  .app-shell { grid-template-columns: 1fr; }
  .brand-panel {
    position: static;
    height: auto;
    grid-template-columns: minmax(0, .8fr) minmax(0, 1fr);
    align-items: center;
  }
  .mini-report { grid-column: 1 / -1; }
  .workspace { grid-template-columns: 1fr; }
  .result-card { position: static; }
}

@media (max-width: 720px) {
  .brand-panel,
  .diagnostic { padding: 20px; }
  .brand-panel,
  .field-grid,
  fieldset,
  .pain-grid,
  .plan-grid,
  .report-grid,
  .ai-body { grid-template-columns: 1fr; }
  .topbar { display: grid; }
  h1 { font-size: 32px; }
  h2 { font-size: 28px; }
  .stepper { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-actions { justify-content: stretch; flex-wrap: wrap; }
  .button { flex: 1; }
}
