:root {
  --bg: #f4efe6;
  --panel: rgba(255, 252, 246, 0.92);
  --panel-strong: #fff8ef;
  --line: #d3c4b1;
  --text: #2d261f;
  --muted: #7b6d5c;
  --accent: #c65d2e;
  --accent-strong: #9f3f16;
  --shadow: 0 18px 50px rgba(93, 70, 40, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(198, 93, 46, 0.16), transparent 28%),
    radial-gradient(circle at right 10% bottom 20%, rgba(41, 119, 90, 0.12), transparent 24%),
    linear-gradient(180deg, #f8f1e7 0%, #efe4d4 100%);
}

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

.topbar,
.panel,
.graph-card,
.lesson-panel {
  background: var(--panel);
  backdrop-filter: blur(18px);
  border: 1px solid rgba(211, 196, 177, 0.8);
  border-radius: 24px;
  box-shadow: var(--shadow);
}

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

.brand h1,
.panel h2,
.lesson-panel h2 {
  margin: 0;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 12px;
  font-weight: 700;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: end;
  justify-content: flex-end;
}

.toolbar-field,
.parameter-group label,
.toggle-list label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 14px;
  color: var(--muted);
}

.toolbar-field-wide {
  min-width: 360px;
}

.template-select-wrap {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto;
  gap: 10px;
  align-items: stretch;
  padding: 10px;
  border-radius: 18px;
  border: 1px solid rgba(198, 93, 46, 0.18);
  background: linear-gradient(135deg, rgba(255, 252, 246, 0.96), rgba(245, 234, 218, 0.9));
}

.template-select-wrap select {
  min-width: 0;
  border-radius: 16px;
  border-color: rgba(198, 93, 46, 0.35);
  font-weight: 700;
}

.template-select-meta {
  min-width: 164px;
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(255, 248, 239, 0.92);
  border: 1px solid rgba(211, 196, 177, 0.8);
}

.template-select-meta strong,
.template-select-meta small {
  display: block;
}

.template-select-meta strong {
  color: var(--text);
  font-size: 13px;
}

.template-select-meta small {
  color: var(--accent-strong);
  margin-top: 4px;
}

button,
select,
input[type="number"] {
  border-radius: 14px;
  border: 1px solid var(--line);
  background: #fffdf8;
  color: var(--text);
  font: inherit;
}

button {
  padding: 10px 14px;
  cursor: pointer;
  transition: transform 160ms ease, background 160ms ease, border-color 160ms ease;
}

button:hover {
  transform: translateY(-1px);
  border-color: var(--accent);
}

button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff7f1;
}

button.primary:hover {
  background: var(--accent-strong);
}

select,
input[type="number"] {
  padding: 10px 12px;
}

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

.sidebar,
.workspace {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.panel {
  padding: 18px;
}

.expression-panel {
  padding: 14px 16px;
}

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

.pill {
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(198, 93, 46, 0.12);
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 700;
}

.parameter-panel,
.lesson-content {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.parameter-group {
  padding: 14px;
  border-radius: 18px;
  background: var(--panel-strong);
  border: 1px solid rgba(211, 196, 177, 0.65);
  transition: box-shadow 120ms ease;
}

.parameter-group header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.parameter-row {
  display: grid;
  grid-template-columns: 1fr 96px;
  gap: 10px;
  align-items: center;
}

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

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

.toggle-list label {
  flex-direction: row;
  align-items: center;
  font-size: 14px;
}

.zoom-controls {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-top: 14px;
}

.lesson-content p,
.lesson-content li {
  color: var(--muted);
}

.workspace {
  min-width: 0;
}

.expression-bar {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: center;
  padding: 4px 2px;
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(255, 248, 239, 0.92), rgba(250, 242, 230, 0.86));
  border: 0;
}

.expression-caption {
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 0.08em;
}

.current-expression {
  text-align: center;
  font-size: clamp(20px, 2.2vw, 30px);
  line-height: 1.1;
  font-weight: 800;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.expr-symbol {
  font-weight: 900;
}

.expr-warm {
  color: #d1495b;
}

.expr-cool {
  color: #2f855a;
}

.expr-value {
  font-weight: 900;
}

.graph-card {
  padding: 14px;
  min-height: 720px;
}

#graphSvg {
  width: 100%;
  height: 100%;
  min-height: 690px;
  display: block;
  border-radius: 18px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.5), rgba(249, 241, 229, 0.7)),
    radial-gradient(circle at top, rgba(198, 93, 46, 0.08), transparent 40%);
}

.lesson-panel {
  margin-top: 18px;
  padding: 18px 22px;
}

.lesson-hero {
  display: grid;
  grid-template-columns: 1.3fr 0.9fr;
  gap: 16px;
}

.lesson-summary,
.lesson-focus,
.lesson-list-card {
  padding: 16px 18px;
  border-radius: 18px;
  border: 1px solid rgba(211, 196, 177, 0.72);
  background: linear-gradient(180deg, rgba(255, 252, 246, 0.98), rgba(250, 242, 230, 0.92));
}

.lesson-summary strong,
.lesson-focus strong,
.lesson-list-card strong {
  display: block;
  margin-bottom: 8px;
}

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

.lesson-content ul {
  margin: 0;
  padding-left: 20px;
}

.lesson-tag {
  display: inline-flex;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(198, 93, 46, 0.12);
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 10px;
}

.graph-label {
  font-size: 12px;
  fill: #66594c;
}

.formula-chip {
  font-size: 12px;
  font-weight: 700;
}

.drag-handle {
  cursor: grab;
  touch-action: none;
}

.drag-handle:active {
  cursor: grabbing;
}

#graphSvg {
  touch-action: none;
}

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

  .graph-card {
    min-height: 560px;
  }

  #graphSvg {
    min-height: 530px;
  }

  .lesson-hero,
  .lesson-grid {
    grid-template-columns: 1fr;
  }
}

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

  .topbar {
    padding: 16px;
  }

  .toolbar {
    justify-content: stretch;
  }

  .toolbar > * {
    width: 100%;
  }

  .template-select-wrap {
    grid-template-columns: 1fr;
  }

  .toggle-list {
    grid-template-columns: 1fr;
  }
}
