:root {
  color-scheme: light;
  --ink: #17211f;
  --muted: #61706d;
  --panel: #ffffff;
  --panel-soft: #f6f8f4;
  --line: #d9e1da;
  --accent: #d94f30;
  --accent-2: #1e7f73;
  --accent-3: #315bb7;
  --warn: #9b6a12;
  --shadow: 0 18px 50px rgba(26, 42, 38, 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", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background:
    linear-gradient(120deg, rgba(217, 79, 48, 0.1), transparent 28%),
    linear-gradient(230deg, rgba(30, 127, 115, 0.12), transparent 30%),
    #eef2ed;
}

button,
input {
  font: inherit;
}

.app-shell {
  width: min(1500px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 22px 0 28px;
}

.hero {
  min-height: 210px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 420px);
  gap: 28px;
  align-items: end;
  padding: 28px 6px 22px;
}

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

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

h1 {
  margin-bottom: 12px;
  font-size: clamp(2.4rem, 5.6vw, 5.25rem);
  line-height: 0.95;
  letter-spacing: 0;
}

.lede {
  max-width: 780px;
  margin-bottom: 0;
  color: #33413e;
  font-size: clamp(1rem, 1.45vw, 1.24rem);
  line-height: 1.7;
}

.dashboard-home-link {
  display: inline-flex;
  margin-top: 14px;
  color: var(--accent-2);
  font-size: 0.92rem;
  font-weight: 850;
  text-decoration: none;
}

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

.hero-formula {
  min-height: 138px;
  padding: 24px;
  display: grid;
  align-content: center;
  gap: 10px;
  border: 1px solid rgba(23, 33, 31, 0.12);
  background: rgba(255, 255, 255, 0.7);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.hero-formula span {
  font-family: ui-serif, Georgia, Cambria, "Times New Roman", serif;
  font-size: clamp(2rem, 3vw, 3.4rem);
}

.hero-formula small {
  color: var(--muted);
  line-height: 1.5;
}

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

.panel,
.viz-card,
.explanation-band {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.84);
  box-shadow: var(--shadow);
}

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

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

.panel h2,
.viz-head h2,
.explanation-band h2 {
  margin-bottom: 0;
  font-size: 1rem;
}

.panel h3 {
  margin-bottom: 12px;
  color: #34413f;
  font-size: 0.86rem;
}

.rank-pill {
  min-width: 76px;
  padding: 7px 10px;
  border: 1px solid rgba(30, 127, 115, 0.28);
  color: var(--accent-2);
  background: rgba(30, 127, 115, 0.08);
  text-align: center;
  font-size: 0.82rem;
  font-weight: 800;
}

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

.icon-button {
  width: 100%;
  aspect-ratio: 1;
  border: 1px solid var(--line);
  background: var(--panel-soft);
  color: var(--ink);
  cursor: pointer;
  font-size: 1.25rem;
  font-weight: 800;
}

.icon-button:hover,
.icon-button.active {
  border-color: rgba(217, 79, 48, 0.42);
  background: rgba(217, 79, 48, 0.1);
  color: var(--accent);
}

.matrix-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  padding: 14px;
  border-left: 2px solid var(--ink);
  border-right: 2px solid var(--ink);
}

.matrix-grid input {
  width: 100%;
  min-width: 0;
  padding: 10px 8px;
  border: 1px solid var(--line);
  background: #fff;
  text-align: center;
  color: var(--ink);
}

.slider-line {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) 52px;
  gap: 10px;
  align-items: center;
  margin-bottom: 12px;
}

.slider-line label,
.slider-line output {
  color: var(--muted);
  font-size: 0.84rem;
}

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

.readout {
  padding-top: 2px;
}

.readout dl {
  display: grid;
  gap: 10px;
  margin: 0;
}

.readout dl > div {
  display: grid;
  grid-template-columns: 76px 1fr;
  gap: 10px;
  align-items: start;
  padding: 10px;
  background: var(--panel-soft);
  border: 1px solid var(--line);
}

.readout dt {
  color: var(--muted);
  font-size: 0.82rem;
}

.readout dd {
  margin: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 0.8rem;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.visual-stage {
  min-width: 0;
  display: grid;
  gap: 18px;
}

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

.viz-card {
  min-width: 0;
  display: grid;
  gap: 12px;
  padding: 16px;
}

.viz-head span {
  color: var(--muted);
  font-size: 0.82rem;
  text-align: right;
}

canvas {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 9 / 7;
  background: #fbfcfa;
  border: 1px solid var(--line);
}

.explanation-band {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 430px);
  gap: 24px;
  padding: 20px;
}

.explanation-band p {
  margin: 10px 0 0;
  color: #3b4845;
  line-height: 1.75;
}

.identity-list {
  display: grid;
  gap: 10px;
}

.identity-list div {
  padding: 12px;
  border: 1px solid var(--line);
  background: var(--panel-soft);
}

.identity-list span {
  display: block;
  margin-bottom: 4px;
  font-family: ui-serif, Georgia, Cambria, "Times New Roman", serif;
  font-size: 1.1rem;
}

.identity-list small {
  color: var(--muted);
  line-height: 1.4;
}

@media (max-width: 1100px) {
  .workspace,
  .hero,
  .canvas-grid,
  .explanation-band {
    grid-template-columns: 1fr;
  }

  .controls-panel {
    position: static;
  }
}

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

  .hero {
    min-height: unset;
    padding-top: 18px;
  }

  .panel-head,
  .viz-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .viz-head span {
    text-align: left;
  }
}
