:root {
  color-scheme: light;
  --ink: #182321;
  --muted: #65736f;
  --line: #d8e1dc;
  --panel: rgba(255, 255, 255, 0.86);
  --soft: #f5f8f5;
  --r1: #315bb7;
  --r2: #1e7f73;
  --u1: #d94f30;
  --u2: #7b4cc2;
  --q: #9b6a12;
  --shadow: 0 18px 52px rgba(22, 39, 34, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background:
    linear-gradient(125deg, rgba(217, 79, 48, 0.1), transparent 28%),
    linear-gradient(240deg, rgba(49, 91, 183, 0.12), transparent 32%),
    #eef2ed;
}

button,
input {
  font: inherit;
}

a {
  color: #1e6d65;
  font-weight: 800;
}

.shell {
  width: min(1540px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 24px 0 30px;
}

.topbar {
  min-height: 220px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 480px);
  gap: 28px;
  align-items: end;
  padding: 24px 6px 22px;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--r2);
  font-size: 0.78rem;
  line-height: 1.2;
  text-transform: uppercase;
  font-weight: 850;
}

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

h1 {
  margin-bottom: 14px;
  font-size: clamp(2.35rem, 5vw, 4.9rem);
  line-height: 0.96;
  letter-spacing: 0;
}

.lead {
  max-width: 860px;
  margin-bottom: 0;
  color: #35423f;
  font-size: clamp(1rem, 1.35vw, 1.18rem);
  line-height: 1.75;
}

.dashboard-home-link {
  display: inline-flex;
  margin-top: 14px;
  color: #1e6d65;
  font-size: 0.92rem;
  font-weight: 850;
  text-decoration: none;
}

.dashboard-home-link:hover {
  text-decoration: underline;
}

.formula-card,
.panel {
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.formula-card {
  min-height: 148px;
  display: grid;
  gap: 12px;
  align-content: center;
  padding: 24px;
}

.formula-card span {
  font-family: ui-serif, Georgia, Cambria, "Times New Roman", serif;
  font-size: clamp(1.62rem, 2.55vw, 2.75rem);
}

.formula-card small {
  color: var(--muted);
  line-height: 1.55;
}

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

.control-panel {
  position: sticky;
  top: 18px;
  display: grid;
  gap: 20px;
  padding: 18px;
}

.panel-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.panel-title h2,
.story-panel h2 {
  margin-bottom: 0;
  font-size: 1rem;
}

.panel-title span {
  padding: 7px 10px;
  border: 1px solid rgba(30, 127, 115, 0.28);
  color: #1e6d65;
  background: rgba(30, 127, 115, 0.08);
  font-size: 0.78rem;
  font-weight: 800;
  white-space: nowrap;
}

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

.preset {
  min-height: 42px;
  border: 1px solid var(--line);
  background: var(--soft);
  color: var(--ink);
  cursor: pointer;
  font-size: 0.88rem;
  font-weight: 800;
}

.preset:hover,
.preset.active {
  border-color: rgba(217, 79, 48, 0.4);
  background: rgba(217, 79, 48, 0.1);
  color: var(--u1);
}

.slider-card,
.vector-editor {
  padding: 14px;
  border: 1px solid var(--line);
  background: rgba(246, 248, 244, 0.72);
}

.slider-card h3,
.vector-editor h3,
.matrix-grid h3 {
  margin-bottom: 12px;
  color: #384541;
  font-size: 0.86rem;
}

.slider-card label,
.component-row {
  display: grid;
  gap: 8px;
  margin-bottom: 13px;
}

.slider-card label:last-child,
.component-row:last-child {
  margin-bottom: 0;
}

.slider-card span,
.component-row span {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 0.82rem;
}

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

.main-grid {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(360px, 0.8fr);
  gap: 18px;
}

.canvas-panel,
.matrix-panel,
.story-panel,
.activation-panel {
  min-width: 0;
  padding: 16px;
}

.canvas-panel {
  grid-row: span 2;
}

canvas {
  display: block;
  width: 100%;
  height: auto;
  margin-top: 12px;
  aspect-ratio: 48 / 31;
  border: 1px solid var(--line);
  background: #fbfcfa;
}

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

.bar-row {
  display: grid;
  gap: 8px;
}

.bar-label,
.bar-value {
  color: var(--muted);
  font-size: 0.82rem;
}

.bar-track {
  position: relative;
  height: 34px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: #eef3ef;
}

.bar {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 0%;
  transition: width 180ms ease;
}

.bar.alt {
  left: auto;
  right: 0;
}

.raw {
  background: rgba(49, 91, 183, 0.76);
}

.raw.alt {
  background: rgba(30, 127, 115, 0.76);
}

.dual {
  background: rgba(217, 79, 48, 0.74);
}

.dual.alt {
  background: rgba(123, 76, 194, 0.74);
}

.soft {
  background: rgba(217, 79, 48, 0.9);
}

.soft.alt {
  background: rgba(123, 76, 194, 0.9);
}

.matrix-panel {
  grid-column: 1 / -1;
}

.matrix-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.matrix-grid > div,
.note-grid > div {
  border: 1px solid var(--line);
  background: var(--soft);
  padding: 12px;
}

pre {
  min-height: 88px;
  margin: 0;
  white-space: pre-wrap;
  color: #24302d;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.8rem;
  line-height: 1.45;
}

.story-panel {
  grid-column: 1 / -1;
}

.story-panel p {
  margin: 10px 0 16px;
  color: #3b4845;
  line-height: 1.75;
}

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

.note-grid strong {
  display: block;
  margin-bottom: 6px;
}

.note-grid span {
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.55;
}

@media (max-width: 1180px) {
  .topbar,
  .dashboard,
  .main-grid,
  .matrix-grid,
  .note-grid {
    grid-template-columns: 1fr;
  }

  .control-panel {
    position: static;
  }

  .canvas-panel,
  .matrix-panel,
  .story-panel {
    grid-column: auto;
    grid-row: auto;
  }
}

@media (max-width: 640px) {
  .shell {
    width: min(100vw - 20px, 1540px);
    padding-top: 10px;
  }

  .panel-title {
    align-items: flex-start;
    flex-direction: column;
  }
}
