:root {
  --bg: #f7f9fc;
  --surface: #ffffff;
  --surface-2: #eef4ff;
  --ink: #172033;
  --muted: #667085;
  --line: #dbe3ef;
  --blue: #2563eb;
  --teal: #0f9f8f;
  --rose: #e45675;
  --amber: #e9a324;
  --green: #22a06b;
  --shadow: 0 18px 45px rgba(20, 34, 58, .10);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.45;
}
button, input, select { font: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible, .lab-card:focus-visible, .experiment-card:focus-visible {
  outline: 3px solid rgba(37, 99, 235, .28);
  outline-offset: 2px;
}
.app-shell { display: grid; grid-template-columns: 292px 1fr; min-height: 100vh; }
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
  padding: 24px;
  border-right: 1px solid var(--line);
  background: rgba(255,255,255,.92);
}
.brand { display: flex; gap: 13px; align-items: center; margin-bottom: 24px; }
.brand-mark {
  width: 48px;
  height: 48px;
  padding: 10px;
  border-radius: 14px;
  color: #fff;
  background: linear-gradient(135deg, var(--blue), var(--teal));
  box-shadow: var(--shadow);
}
.brand h1, .workspace-title h2, .hero-band h2, .section-head h2 { margin: 0; letter-spacing: 0; }
.brand h1 { font-size: 1.05rem; }
.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: .74rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  font-weight: 800;
}
.nav-stack { display: grid; gap: 8px; margin-bottom: 18px; }
.nav-item, .ghost-button, .primary-button, .icon-button, .preset-chip {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  border-radius: 8px;
  transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease, background .16s ease;
}
.nav-item {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  text-align: left;
}
.nav-item:hover, .ghost-button:hover, .icon-button:hover, .preset-chip:hover, .lab-card:hover, .experiment-card:hover {
  transform: translateY(-1px);
  border-color: #b7c5d8;
  box-shadow: 0 10px 26px rgba(31, 45, 74, .08);
}
.nav-item.active { border-color: var(--blue); background: #eef4ff; color: var(--blue); }
.sidebar-card {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 8px;
  padding: 14px;
  margin: 18px 0;
}
.progress-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: .9rem; }
.progress-track { height: 9px; border-radius: 999px; background: #e8edf5; overflow: hidden; margin-top: 12px; }
.progress-track span { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--teal), var(--blue)); }
.main { min-width: 0; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 18px 28px;
  border-bottom: 1px solid var(--line);
  background: rgba(247, 249, 252, .88);
  backdrop-filter: blur(14px);
}
.search-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 220px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}
.search-wrap svg { width: 20px; color: var(--muted); }
.search-wrap input { width: 100%; border: 0; outline: 0; padding: 13px 0; background: transparent; }
.top-actions, .button-row, .filter-row, .preset-row { display: flex; gap: 9px; align-items: center; }
.button-row.wrap, .filter-row, .preset-row { flex-wrap: wrap; }
.icon-button {
  display: inline-grid;
  place-items: center;
  width: 42px;
  height: 42px;
  padding: 0;
}
.icon-button svg, .ghost-button svg { width: 19px; height: 19px; }
.ghost-button, .primary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 0 14px;
  font-weight: 800;
}
.ghost-button.small { min-height: 34px; padding: 0 10px; font-size: .88rem; }
.ghost-button.full { width: 100%; }
.primary-button { border-color: var(--blue); background: var(--blue); color: #fff; }
.primary-button:hover { background: #1d4ed8; }
.view { padding: 28px; }
.hidden { display: none !important; }
.hero-band {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 22px;
  align-items: stretch;
  padding: 30px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    radial-gradient(circle at 96% 8%, rgba(37,99,235,.16), transparent 28%),
    linear-gradient(135deg, #fff, #f2fbf8);
  box-shadow: var(--shadow);
}
.hero-band h2 { max-width: 840px; font-size: clamp(2rem, 4vw, 4.4rem); line-height: .98; }
.hero-band p { max-width: 760px; color: var(--muted); font-size: 1.05rem; }
.hero-panel {
  display: grid;
  align-content: center;
  gap: 10px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255,255,255,.75);
}
.hero-panel span { color: var(--muted); font-weight: 800; }
.hero-panel strong { font-size: 1.45rem; line-height: 1.1; }
.compact-hidden { display: none !important; }
.compact-intro {
  display: none;
  margin-bottom: 22px;
  padding: 13px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font-weight: 850;
}
.compact-intro.active {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 14px;
}
.compact-intro strong { color: var(--blue); }
.compact-intro span {
  flex: 1;
  color: var(--muted);
  font-weight: 650;
}
.compact-intro em {
  color: var(--muted);
  font-size: .88rem;
  font-style: normal;
  white-space: nowrap;
}
.section-head { display: flex; justify-content: space-between; align-items: end; gap: 14px; margin: 30px 0 14px; }
.section-head p { margin: 0; color: var(--muted); }
.lab-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.experiment-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.lab-card, .experiment-card, .empty-state {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 16px;
}
.empty-state {
  grid-column: 1 / -1;
  display: grid;
  gap: 6px;
  color: var(--muted);
}
.empty-state strong { color: var(--ink); }
.lab-card { min-height: 160px; display: grid; align-content: space-between; }
.lab-icon { width: 46px; height: 46px; display: grid; place-items: center; border-radius: 8px; font-size: 1.55rem; background: var(--surface-2); }
.lab-card h3, .experiment-card h3 { margin: 10px 0 7px; }
.lab-card p, .experiment-card p { margin: 0; color: var(--muted); }
.card-meta { display: flex; justify-content: space-between; gap: 8px; margin-top: 14px; color: var(--muted); font-size: .86rem; }
.chip, .preset-chip {
  padding: 8px 11px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #fff;
  font-weight: 800;
  color: var(--muted);
}
.chip.active, .preset-chip.active { color: var(--blue); border-color: var(--blue); background: #eef4ff; }
.workspace-head {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 16px;
  align-items: start;
  margin-bottom: 18px;
}
.workspace-title h2 { font-size: clamp(1.7rem, 3vw, 3.2rem); line-height: 1.05; }
.workspace-title p:last-child { max-width: 900px; color: var(--muted); }
.workspace-grid {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr) 300px;
  gap: 18px;
  align-items: start;
}
.control-panel, .visual-panel, .learning-panel section, dialog {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 8px;
  box-shadow: 0 12px 35px rgba(31,45,74,.06);
}
.control-panel, .visual-panel { padding: 16px; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 12px; }
.panel-head h3, .learning-panel h3 { margin: 0; }
.control { padding: 13px 0; border-top: 1px solid var(--line); }
.control:first-of-type { border-top: 0; }
.control-label { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; font-weight: 850; }
.control-value { color: var(--blue); }
.control input[type="range"] { width: 100%; accent-color: var(--blue); }
.control input[type="number"] {
  width: 100%;
  margin-top: 6px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
}
.compare-box {
  display: grid;
  gap: 10px;
  margin: 14px 0;
  padding: 13px;
  border-radius: 8px;
  background: #f8fbff;
  border: 1px solid var(--line);
}
.compare-box p { margin: 0; color: var(--muted); }
.compare-status {
  display: grid;
  gap: 6px;
  font-size: .86rem;
}
.compare-status span {
  display: block;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
}
.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-bottom: 14px; }
.metric-card {
  min-height: 92px;
  display: grid;
  align-content: center;
  gap: 5px;
  padding: 13px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, #fff, #f8fbff);
}
.metric-card span { color: var(--muted); font-size: .82rem; font-weight: 800; }
.metric-card strong { font-size: clamp(1.12rem, 2vw, 1.7rem); }
canvas {
  display: block;
  width: 100%;
  min-height: 380px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}
.insight-card {
  margin-top: 14px;
  padding: 15px;
  border-radius: 8px;
  border: 1px solid #bde5db;
  background: #f0fbf7;
  color: #0b5f55;
  font-weight: 800;
}
.learning-panel { display: grid; gap: 14px; }
.learning-panel section { padding: 15px; }
.learning-panel p { color: var(--muted); margin: 8px 0 0; }
.glossary-list { display: grid; gap: 10px; }
.glossary-term { border-top: 1px solid var(--line); padding-top: 9px; }
.glossary-term:first-child { border-top: 0; }
.glossary-term strong { display: block; }
.glossary-term span { color: var(--muted); font-size: .9rem; }
dialog {
  width: min(760px, calc(100vw - 28px));
  max-height: min(760px, calc(100vh - 32px));
  padding: 0;
}
dialog::backdrop { background: rgba(23,32,51,.30); backdrop-filter: blur(4px); }
.dialog-head { display: flex; align-items: center; justify-content: space-between; padding: 16px; border-bottom: 1px solid var(--line); }
.dialog-head h2 { margin: 0; }
#dialogBody { padding: 16px; display: grid; gap: 10px; overflow: auto; }
.saved-item { border: 1px solid var(--line); border-radius: 8px; padding: 12px; background: #fff; }
.saved-item p { margin: 4px 0; color: var(--muted); }
.export-box { width: 100%; min-height: 260px; border: 1px solid var(--line); border-radius: 8px; padding: 12px; }

@media (max-width: 1180px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; }
  .nav-stack { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .workspace-grid { grid-template-columns: 1fr; }
  .learning-panel { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 840px) {
  .topbar, .workspace-head, .section-head { align-items: stretch; flex-direction: column; display: flex; }
  .hero-band { grid-template-columns: 1fr; padding: 22px; }
  .compact-intro em { white-space: normal; }
  .lab-grid, .experiment-grid, .metric-grid, .learning-panel, .nav-stack { grid-template-columns: 1fr; }
  .view { padding: 18px; }
  .top-actions { flex-wrap: wrap; }
}
