:root {
  color-scheme: light;
  --ink: #17181c;
  --muted: #626774;
  --line: #d8dbe2;
  --paper: #f6f3ee;
  --panel: #ffffff;
  --accent: #0b6e69;
  --accent-2: #a84430;
  --accent-3: #365c9a;
  --gold: #c58b28;
  --shadow: 0 18px 50px rgba(25, 26, 31, 0.12);
}

html {
  scroll-padding-top: 112px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--paper);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  min-height: 42px;
  border: 1px solid var(--accent);
  border-radius: 6px;
  background: var(--accent);
  color: white;
  padding: 0 14px;
  cursor: pointer;
}

button.secondary {
  background: white;
  color: var(--accent);
}

button.icon-button {
  width: 42px;
  padding: 0;
  font-size: 24px;
  line-height: 1;
}

button:focus,
a:focus,
input:focus,
select:focus {
  outline: 3px solid rgba(11, 110, 105, 0.25);
  outline-offset: 2px;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: minmax(260px, 1fr) auto;
  gap: 18px;
  align-items: center;
  padding: 16px 28px;
  background: rgba(246, 243, 238, 0.94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
}

.app-header h1 {
  margin: 2px 0 0;
  font-size: 24px;
  line-height: 1.1;
}

.kicker {
  margin: 0;
  color: var(--accent-2);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.top-nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

.top-nav a {
  border-radius: 6px;
  color: var(--ink);
  padding: 8px 10px;
  text-decoration: none;
}

.top-nav a.active,
.top-nav a:hover {
  background: var(--ink);
  color: white;
}

main {
  padding: 28px;
}

.page {
  display: none;
  scroll-margin-top: 112px;
}

.page.active {
  display: block;
}

.hero {
  min-height: calc(100vh - 165px);
  display: grid;
  grid-template-columns: minmax(320px, 0.95fr) minmax(340px, 1.05fr);
  gap: 28px;
  align-items: center;
}

.hero-copy h2 {
  max-width: 980px;
  margin: 10px 0 16px;
  font-size: clamp(38px, 6vw, 78px);
  line-height: 0.98;
  letter-spacing: 0;
}

.hero-copy p {
  max-width: 760px;
  color: var(--muted);
  font-size: 18px;
  line-height: 1.55;
}

.hero-actions,
.composer-bar,
.diagram-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.hero-diagram,
.big-visualizer,
.visualizer {
  min-height: 360px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf8;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.hero-diagram svg,
.big-visualizer svg,
.visualizer svg {
  width: 100%;
  height: 100%;
  min-height: inherit;
  display: block;
}

.dashboard-grid,
.source-grid,
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px;
}

article,
.diagram-panel,
.control-stack,
.atlas-card,
.mode-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 16px;
}

article h3,
.diagram-panel h3,
.mode-card h3 {
  margin: 0 0 8px;
}

article p,
.mode-card p,
.diagram-panel p {
  color: var(--muted);
  line-height: 1.48;
}

.page-heading {
  max-width: 940px;
  margin-bottom: 20px;
}

.page-heading h2 {
  margin: 4px 0 8px;
  font-size: 42px;
  line-height: 1.05;
}

.page-heading p:last-child {
  color: var(--muted);
  font-size: 17px;
  line-height: 1.5;
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 220px 220px;
  gap: 12px;
  margin-bottom: 14px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.checkbox-control {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--ink);
}

.checkbox-control input {
  width: 18px;
  height: 18px;
  padding: 0;
  accent-color: var(--accent);
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: white;
  color: var(--ink);
  padding: 10px 11px;
}

.atlas-layout,
.workbench {
  display: grid;
  grid-template-columns: minmax(280px, 370px) 1fr;
  gap: 18px;
  align-items: start;
}

.atlas-list {
  display: grid;
  gap: 10px;
  max-height: calc(100vh - 210px);
  overflow: auto;
  padding-right: 6px;
}

.atlas-card {
  cursor: pointer;
  transition: border-color 0.15s, transform 0.15s;
}

.atlas-card:hover,
.atlas-card.active {
  border-color: var(--accent);
  transform: translateY(-1px);
}

.atlas-card h3 {
  margin: 4px 0;
  font-size: 16px;
}

.atlas-card p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.tag {
  border-radius: 999px;
  background: #edf1f4;
  color: #39404d;
  padding: 3px 8px;
  font-size: 12px;
  font-weight: 700;
}

.diagram-panel {
  position: sticky;
  top: 98px;
}

.panel-title-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: start;
}

.detail-list {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 8px 12px;
  color: var(--muted);
  font-size: 14px;
}

.detail-list dt {
  color: var(--ink);
  font-weight: 800;
}

.control-stack {
  display: grid;
  gap: 12px;
  position: sticky;
  top: 98px;
}

.status-strip,
.sequence-readout,
.export-box {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--muted);
  margin-top: 12px;
  padding: 12px;
  line-height: 1.5;
}

.path-editor {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(96px, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.path-step {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  padding: 12px;
  cursor: pointer;
}

.path-step.active {
  border-color: var(--accent-2);
  box-shadow: inset 0 0 0 2px rgba(168, 68, 48, 0.18);
}

.composer-grid {
  display: grid;
  grid-template-columns: repeat(16, minmax(56px, 1fr));
  gap: 8px;
  margin-top: 16px;
}

.step-cell {
  min-height: 92px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--ink);
  padding: 8px;
  cursor: pointer;
}

.step-cell.active {
  border-color: var(--gold);
  background: #fff6df;
}

.step-index {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.step-notes {
  margin-top: 8px;
  font-size: 13px;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.export-box {
  width: 100%;
  min-height: 160px;
  resize: vertical;
}

footer {
  position: sticky;
  bottom: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  padding: 12px 28px;
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
}

.sound-picker {
  grid-template-columns: auto minmax(150px, 190px);
  align-items: center;
  color: var(--ink);
}

.sound-picker select {
  padding: 8px 10px;
}

#nowPlaying {
  color: var(--muted);
  font-size: 14px;
}

.node circle,
.node rect {
  cursor: pointer;
  transition: transform 0.12s, fill 0.12s;
}

.node:hover circle,
.node.selected circle {
  fill: var(--accent-2);
}

.node text {
  pointer-events: none;
  font-size: 16px;
  font-weight: 800;
  fill: var(--ink);
}

.axis-line,
.edge-line {
  stroke: #a9b0bd;
  stroke-width: 2;
}

.path-line {
  stroke: var(--accent-2);
  stroke-width: 4;
  fill: none;
}

@media (max-width: 980px) {
  .app-header,
  .hero,
  .atlas-layout,
  .workbench {
    grid-template-columns: 1fr;
  }

  .toolbar {
    grid-template-columns: 1fr;
  }

  .diagram-panel,
  .control-stack {
    position: static;
  }

  .composer-grid {
    grid-template-columns: repeat(4, minmax(62px, 1fr));
  }
}

@media (max-width: 620px) {
  main,
  .app-header,
  footer {
    padding-left: 16px;
    padding-right: 16px;
  }

  .hero-copy h2 {
    font-size: 38px;
  }

  .page-heading h2 {
    font-size: 34px;
  }
}
