:root {
  --bg: #f5f2ea;
  --ink: #18211f;
  --muted: #66706c;
  --panel: #ffffff;
  --line: #d9d3c6;
  --accent: #0f766e;
  --accent-dark: #0a554f;
  --warn: #b45309;
  --danger: #a93535;
  --soft: #e5f2ee;
  --shadow: 0 18px 60px rgba(24, 33, 31, 0.12);
}

* {
  box-sizing: border-box;
}

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

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

.app-shell {
  min-height: 100vh;
  padding: 28px;
}

.workspace {
  width: min(1180px, 100%);
  margin: 0 auto;
}

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

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

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

h1 {
  max-width: 780px;
  margin-bottom: 0;
  font-size: clamp(2rem, 5vw, 4.4rem);
  line-height: 1;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 10px;
  font-size: 1.05rem;
  letter-spacing: 0;
}

.mode-label {
  min-width: 116px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  color: var(--accent-dark);
  font-weight: 800;
  text-align: center;
}

.hero-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--line);
  margin-bottom: 18px;
}

.hero-strip div {
  min-width: 0;
  background: rgba(255, 255, 255, 0.74);
  padding: 16px;
}

.hero-strip strong,
.hero-strip span {
  display: block;
}

.hero-strip strong {
  margin-bottom: 4px;
  color: var(--accent-dark);
}

.hero-strip span {
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.45;
}

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

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

.controls {
  display: grid;
  gap: 18px;
  padding: 20px;
}

fieldset {
  display: grid;
  gap: 14px;
  min-width: 0;
  margin: 0;
  padding: 0 0 18px;
  border: 0;
  border-bottom: 1px solid var(--line);
}

fieldset:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

legend {
  margin-bottom: 2px;
  color: var(--accent-dark);
  font-size: 0.9rem;
  font-weight: 900;
}

label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 750;
}

input[type="text"],
select,
textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: 0;
  background: #fbfaf6;
  color: var(--ink);
  font-weight: 750;
}

input[type="text"],
select {
  min-height: 44px;
  padding: 0 12px;
}

textarea {
  padding: 12px;
  resize: vertical;
  line-height: 1.5;
}

.range-row {
  display: grid;
  gap: 14px;
}

.range-row label span {
  justify-self: end;
  color: var(--ink);
  font-weight: 900;
}

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

.check-grid {
  display: grid;
  gap: 8px;
}

.check-grid label {
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  min-height: 40px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfaf6;
  color: var(--ink);
  line-height: 1.35;
}

input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.risk-grid input[type="checkbox"] {
  accent-color: var(--warn);
}

.results {
  display: grid;
  gap: 14px;
  padding: 20px;
}

.score-band {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-width: 0;
  padding: 18px;
  border-radius: 8px;
  background: var(--soft);
}

.score-band span,
.metric span {
  display: block;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 800;
}

.score-band strong {
  display: block;
  margin-top: 6px;
  font-size: clamp(1.5rem, 4vw, 2.5rem);
  line-height: 1.05;
  letter-spacing: 0;
}

.score-ring {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 102px;
  height: 102px;
  border: 8px solid rgba(15, 118, 110, 0.24);
  border-radius: 999px;
  background: #fff;
}

.score-ring output {
  color: var(--accent-dark);
  font-size: 2rem;
  font-weight: 950;
  line-height: 1;
}

.score-ring span {
  font-size: 0.75rem;
}

.result-copy,
.next-steps,
.prompt-box,
.metric,
.cta-row {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.result-copy,
.next-steps,
.prompt-box {
  padding: 18px;
}

.result-copy p,
.next-steps li,
.prompt-head p {
  color: var(--muted);
  line-height: 1.65;
}

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

.metric {
  min-width: 0;
  padding: 16px;
}

.metric strong {
  display: block;
  margin-top: 8px;
  font-size: 1.22rem;
  line-height: 1.2;
}

.next-steps ol {
  display: grid;
  gap: 8px;
  margin: 0;
  padding-left: 22px;
}

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

.prompt-head p {
  margin-bottom: 0;
}

button,
.cta {
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 900;
  text-decoration: none;
}

button {
  min-height: 42px;
  padding: 0 16px;
  background: var(--accent);
  color: #fff;
}

#promptOutput {
  background: #f7f6f1;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.9rem;
}

.copy-status {
  min-height: 22px;
  margin: 8px 0 0;
  color: var(--accent-dark);
  font-size: 0.9rem;
  font-weight: 800;
}

.cta-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  padding: 12px;
}

.cta {
  display: flex;
  min-height: 48px;
  align-items: center;
  justify-content: center;
  padding: 0 14px;
  text-align: center;
}

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

.cta.secondary {
  background: #f7f6f1;
  color: var(--accent-dark);
  border: 1px solid var(--line);
}

.is-caution .score-band {
  background: #fff4dc;
}

.is-caution .score-ring {
  border-color: rgba(180, 83, 9, 0.26);
}

.is-caution .score-ring output {
  color: var(--warn);
}

.is-stop .score-band {
  background: #f9e8e8;
}

.is-stop .score-ring {
  border-color: rgba(169, 53, 53, 0.28);
}

.is-stop .score-ring output {
  color: var(--danger);
}

@media (max-width: 860px) {
  .app-shell {
    padding: 18px;
  }

  .topbar,
  .score-band,
  .prompt-head {
    align-items: stretch;
    flex-direction: column;
  }

  .mode-label {
    width: fit-content;
  }

  .hero-strip,
  .layout,
  .metric-grid,
  .cta-row {
    grid-template-columns: 1fr;
  }

  .score-ring {
    width: 92px;
    height: 92px;
  }
}
