:root {
  color-scheme: light;
  --bg: #f6f7f4;
  --surface: #ffffff;
  --surface-alt: #f0f5f4;
  --ink: #17211f;
  --muted: #66716d;
  --line: #d8dfdc;
  --teal: #14746f;
  --teal-dark: #0c514d;
  --rose: #c84c5d;
  --gold: #b98012;
  --blue: #3465d9;
  --shadow: 0 18px 50px rgba(22, 34, 31, 0.09);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "PingFang SC", "Microsoft YaHei", sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

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

.workspace {
  display: grid;
  grid-template-columns: minmax(300px, 360px) minmax(0, 1fr);
  gap: 18px;
  max-width: 1560px;
  margin: 0 auto;
}

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

.guide-panel {
  position: sticky;
  top: 20px;
  align-self: start;
  padding: 20px;
  display: grid;
  gap: 18px;
}

.panel-header,
.toolbar,
.section-heading,
.question-actions,
.toolbar-actions,
.question-topline {
  display: flex;
  align-items: center;
}

.panel-header,
.toolbar,
.section-heading,
.question-actions {
  justify-content: space-between;
  gap: 14px;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--teal);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 0;
  font-size: clamp(26px, 4vw, 42px);
  line-height: 1.04;
}

.toolbar h2,
.section-heading h2,
.strategy h2 {
  margin-bottom: 0;
  font-size: 20px;
}

.icon-button,
.repo-link,
.ghost-button,
.primary-button {
  min-height: 40px;
  border-radius: 8px;
  border: 1px solid var(--line);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--surface);
  color: var(--ink);
}

.repo-link {
  padding: 0 12px;
  text-decoration: none;
  font-weight: 800;
}

.icon-button {
  width: 42px;
  padding: 0;
}

.ghost-button,
.primary-button {
  padding: 0 14px;
  font-weight: 750;
}

.primary-button {
  border-color: var(--teal);
  background: var(--teal);
  color: white;
}

button svg {
  width: 18px;
  height: 18px;
  stroke-width: 2.25;
  flex: 0 0 auto;
}

.question-box {
  background: var(--surface-alt);
  border: 1px solid #d7e4e1;
  border-radius: 8px;
  padding: 16px;
}

.question-topline {
  gap: 12px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  margin-bottom: 16px;
}

.progress-track {
  flex: 1;
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #d6e2df;
}

#progressBar {
  display: block;
  height: 100%;
  width: 20%;
  border-radius: inherit;
  background: var(--teal);
  transition: width 180ms ease;
}

.question-box h2 {
  margin-bottom: 8px;
  font-size: 21px;
  line-height: 1.26;
}

.question-box p {
  min-height: 66px;
  margin-bottom: 18px;
  color: var(--muted);
  line-height: 1.6;
}

.choice-row {
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
}

.choice-button {
  width: 100%;
  min-height: 42px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--ink);
  text-align: left;
  font-weight: 800;
}

.choice-button.active {
  border-color: var(--teal);
  background: #e9f6f4;
  color: var(--teal-dark);
}

.strategy ul {
  list-style: none;
  padding: 0;
  margin: 14px 0 0;
  display: grid;
  gap: 10px;
}

.strategy li {
  padding: 12px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--gold);
  border-radius: 8px;
  color: #34413d;
  line-height: 1.5;
  background: #fffdf8;
}

.main-panel {
  min-width: 0;
  padding: 18px;
  display: grid;
  gap: 18px;
}

.toolbar {
  border-bottom: 1px solid var(--line);
  padding-bottom: 16px;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 12px;
}

.metric {
  min-height: 118px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
}

.metric span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

.metric strong {
  display: block;
  margin-top: 12px;
  font-size: clamp(22px, 3vw, 31px);
  line-height: 1;
}

.metric small {
  display: block;
  margin-top: 8px;
  color: var(--muted);
}

.editor-area {
  display: grid;
  grid-template-columns: 170px minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}

.offer-tabs {
  display: grid;
  gap: 8px;
}

.offer-tab {
  width: 100%;
  min-height: 54px;
  padding: 10px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  text-align: left;
}

.offer-tab.active {
  border-color: var(--teal);
  background: #edf7f5;
}

.offer-tab strong,
.offer-tab span {
  display: block;
}

.offer-tab span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.offer-form {
  display: grid;
  grid-template-columns: repeat(4, minmax(140px, 1fr));
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
}

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

.field label {
  color: #3d4945;
  font-size: 13px;
  font-weight: 800;
}

.field input,
.field select {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  background: white;
  color: var(--ink);
}

.field.wide {
  grid-column: span 2;
}

.form-actions {
  grid-column: 1 / -1;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding-top: 4px;
}

.charts-grid {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 14px;
}

.chart-panel {
  min-width: 0;
  padding: 16px;
  box-shadow: none;
}

.chart-panel.wide {
  grid-column: 1 / -1;
}

.chart-wrap {
  position: relative;
  height: 340px;
  margin-top: 10px;
}

.segmented {
  display: inline-grid;
  grid-template-columns: repeat(3, minmax(58px, 1fr));
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #f7f9f8;
}

.segmented button {
  min-height: 36px;
  border: 0;
  border-right: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  font-weight: 800;
}

.segmented button:last-child {
  border-right: 0;
}

.segmented button.active {
  background: var(--teal);
  color: white;
}

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

  .guide-panel {
    position: static;
  }

  .summary-grid {
    grid-template-columns: repeat(2, minmax(150px, 1fr));
  }
}

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

  .toolbar,
  .section-heading,
  .panel-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .editor-area,
  .charts-grid,
  .offer-form,
  .summary-grid {
    grid-template-columns: 1fr;
  }

  .offer-tabs {
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  }

  .field.wide {
    grid-column: auto;
  }

  .chart-wrap {
    height: 300px;
  }
}
