:root {
  color-scheme: light;
  --bg: #f5f1e8;
  --paper: #fffdf8;
  --panel: #ffffff;
  --ink: #191714;
  --muted: #696257;
  --line: #d8d0c2;
  --accent: #b5252a;
  --accent-2: #145c52;
  --accent-ink: #ffffff;
  --shadow: 0 18px 50px rgba(36, 30, 18, 0.12);
  --radius: 8px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body.theme-graph {
  --bg: #eef5f7;
  --paper: #fbfdff;
  --panel: #ffffff;
  --ink: #17212b;
  --muted: #5a6672;
  --line: #c9dbe4;
  --accent: #0d6794;
  --accent-2: #8b3d2f;
  background-image:
    linear-gradient(rgba(13, 103, 148, 0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(13, 103, 148, 0.08) 1px, transparent 1px);
  background-size: 28px 28px;
}

body.theme-contrast {
  color-scheme: dark;
  --bg: #080808;
  --paper: #111111;
  --panel: #171717;
  --ink: #f8f8f2;
  --muted: #c8c8c0;
  --line: #464646;
  --accent: #ffcc00;
  --accent-2: #58d6ff;
  --accent-ink: #111111;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
}

* {
  box-sizing: border-box;
}

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

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

button {
  cursor: pointer;
}

button:disabled,
input:disabled {
  cursor: not-allowed;
}

.app-shell {
  width: min(1180px, calc(100% - 48px));
  margin: 0 auto;
  padding: 40px 0;
}

.hidden {
  display: none !important;
}

.setup-view {
  min-height: calc(100vh - 80px);
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) 420px;
  gap: 28px;
  align-items: center;
}

.brand-panel {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 56px;
}

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

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

h1 {
  font-size: clamp(3.4rem, 7vw, 6.8rem);
  line-height: 0.92;
  margin-bottom: 24px;
}

.lede {
  color: var(--muted);
  font-size: 1.18rem;
  line-height: 1.65;
  max-width: 700px;
}

.principles {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 34px;
}

.principles span,
.stat,
.topic-line span {
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 7px 12px;
  background: color-mix(in srgb, var(--panel) 80%, transparent);
  font-size: 0.88rem;
  font-weight: 700;
}

.setup-card,
.question-card,
.tool-card,
.feedback-panel,
.result-card,
.analysis-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.setup-card {
  padding: 28px;
}

.field {
  display: grid;
  gap: 10px;
  margin-bottom: 20px;
}

label,
.toggle-row {
  color: var(--ink);
  font-weight: 800;
}

select,
input[type="text"],
input[type="range"],
textarea,
.calc-display {
  width: 100%;
}

select,
input[type="text"],
.calc-display {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
  color: var(--ink);
  min-height: 48px;
  padding: 0 14px;
}

input[type="range"] {
  accent-color: var(--accent);
}

.range-scale,
.topic-line,
.stat-row,
.tool-title,
.feedback-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.range-scale {
  color: var(--muted);
  font-size: 0.82rem;
}

.toggle-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 24px;
}

.toggle-row input {
  width: 22px;
  height: 22px;
  accent-color: var(--accent);
}

.primary-action,
.secondary-action,
.small-button,
.choice-button,
.calc-key {
  border: 1px solid transparent;
  border-radius: var(--radius);
  min-height: 44px;
  font-weight: 900;
}

.primary-action {
  background: var(--accent);
  color: var(--accent-ink);
  padding: 0 20px;
}

.secondary-action,
.small-button,
.choice-button,
.calc-key {
  background: var(--paper);
  border-color: var(--line);
  color: var(--ink);
}

.primary-action:hover,
.secondary-action:hover,
.small-button:hover,
.choice-button:hover,
.calc-key:hover {
  transform: translateY(-1px);
}

.primary-action:disabled,
.secondary-action:disabled,
.small-button:disabled,
.choice-button:disabled,
.calc-key:disabled {
  background: #d1d5db;
  border-color: #c4c9d2;
  color: #6b7280;
  box-shadow: none;
  opacity: 1;
  transform: none;
}

.choice-button:disabled.selected {
  border-color: #9ca3af;
  box-shadow: inset 0 0 0 2px #9ca3af;
}

.quiz-header,
.results-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 22px;
}

.quiz-header h2,
.results-header h2 {
  font-size: clamp(2rem, 4vw, 3.4rem);
  margin: 0;
}

.quiz-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 22px;
  align-items: start;
}

.question-card {
  min-height: 420px;
  padding: 28px;
}

.question-card h3 {
  font-size: clamp(1.7rem, 3vw, 3rem);
  line-height: 1.15;
  margin: 30px 0;
}

.answer-area {
  display: grid;
  gap: 12px;
}

.choice-button {
  text-align: left;
  min-height: 54px;
  padding: 12px 16px;
}

.choice-button.selected {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 2px var(--accent);
}

.free-response {
  font-size: 1.1rem;
}

.input-error {
  min-height: 24px;
  color: var(--accent);
  font-weight: 800;
  margin: 12px 0 0;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 24px;
}

.workbench {
  display: grid;
  gap: 18px;
}

.tool-card {
  padding: 18px;
}

.tool-title h3 {
  margin: 0;
  font-size: 1rem;
}

.small-button {
  min-height: 34px;
  padding: 0 10px;
  font-size: 0.82rem;
}

.calc-display {
  margin: 14px 0;
  text-align: right;
  font-size: 1.2rem;
  font-weight: 800;
}

.calc-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.calc-key {
  min-height: 42px;
}

.scratch-surface {
  min-height: 220px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background-color: var(--paper);
  background-image:
    linear-gradient(rgba(13, 103, 148, 0.12) 1px, transparent 1px),
    linear-gradient(90deg, rgba(13, 103, 148, 0.12) 1px, transparent 1px),
    linear-gradient(rgba(13, 103, 148, 0.2) 1px, transparent 1px),
    linear-gradient(90deg, rgba(13, 103, 148, 0.2) 1px, transparent 1px);
  background-size: 16px 16px, 16px 16px, 80px 80px, 80px 80px;
  margin-top: 14px;
  overflow: hidden;
  touch-action: none;
}

.scratch-surface canvas {
  display: block;
  width: 100%;
  height: 220px;
  cursor: crosshair;
}

.feedback-panel {
  margin-top: 22px;
  padding: 24px;
}

.feedback-heading h3 {
  margin: 0;
  font-size: 1.3rem;
}

#feedbackStatus {
  color: var(--accent);
  font-weight: 900;
}

#feedbackSummary {
  color: var(--muted);
  line-height: 1.6;
  margin: 16px 0;
}

#feedbackSteps {
  display: grid;
  gap: 10px;
  margin: 0;
  padding-left: 22px;
}

#feedbackSteps li {
  line-height: 1.5;
}

.results-view {
  padding-top: 28px;
}

.results-header {
  align-items: flex-start;
  flex-direction: column;
}

.results-header p:last-child {
  color: var(--muted);
  font-size: 1.08rem;
  max-width: 760px;
}

.results-grid,
.analysis-grid {
  display: grid;
  gap: 18px;
}

.results-grid {
  grid-template-columns: repeat(3, 1fr);
  margin-bottom: 18px;
}

.result-card {
  padding: 22px;
}

.result-card span {
  color: var(--muted);
  font-weight: 800;
}

.result-card strong {
  display: block;
  font-size: 2rem;
  margin-top: 10px;
}

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

.analysis-card {
  padding: 22px;
}

.analysis-card h3 {
  margin-bottom: 16px;
}

.analysis-card ul {
  margin: 0;
  padding-left: 20px;
  display: grid;
  gap: 8px;
}

.recommendations {
  grid-column: 1 / -1;
}

.recommendation-item {
  border-top: 1px solid var(--line);
  padding: 16px 0 0;
  margin-top: 16px;
}

.recommendation-item:first-child {
  border-top: 0;
  padding-top: 0;
  margin-top: 0;
}

.recommendation-item strong {
  display: block;
  margin-bottom: 6px;
}

.recommendation-item p {
  color: var(--muted);
  line-height: 1.55;
  margin-bottom: 0;
}

@media (max-width: 900px) {
  .app-shell {
    width: min(100% - 28px, 760px);
    padding: 22px 0;
  }

  .setup-view,
  .quiz-grid,
  .results-grid,
  .analysis-grid {
    grid-template-columns: 1fr;
  }

  .brand-panel {
    padding: 34px;
  }

  .quiz-header {
    align-items: flex-start;
    flex-direction: column;
  }
}

@media (max-width: 560px) {
  .brand-panel,
  .setup-card,
  .question-card,
  .feedback-panel,
  .analysis-card,
  .result-card {
    padding: 18px;
  }

  .stat-row,
  .topic-line {
    align-items: flex-start;
    flex-direction: column;
  }

  .actions {
    flex-direction: column;
  }

  .primary-action,
  .secondary-action {
    width: 100%;
  }
}
