@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;500&family=IBM+Plex+Sans:wght@400;500&display=swap');

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --color-bg:            #2C404E;
  --color-text:          #D8D8D8;
  --color-text-muted:    #A5A5A5;
  --color-border:        rgba(165, 165, 165, 0.2);
  --color-border-strong: rgba(165, 165, 165, 0.45);
  --color-field-bg:      rgba(0, 0, 0, 0.18);
  --color-accent:        #4E7387;
  --color-action-bg:     #C3AB99;
  --color-action-text:   #1A1A1A;
}

[data-theme="light"] {
  --color-bg:            #F6EADF;
  --color-text:          #1A1A1A;
  --color-text-muted:    #4E7387;
  --color-border:        rgba(26, 26, 26, 0.15);
  --color-border-strong: rgba(26, 26, 26, 0.35);
  --color-field-bg:      rgba(0, 0, 0, 0.05);
  --color-accent:        #2C404E;
  --color-action-bg:     #2C404E;
  --color-action-text:   #F6EADF;
}

body {
  font-family: 'IBM Plex Sans', -apple-system, 'Helvetica Neue', sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  min-height: 100vh;
  padding: 2rem 1rem 3rem;
  transition: background 0.2s, color 0.2s;
}

/* ── Page header ─────────────────────────────────────────────────────────── */

.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  max-width: 1160px;
  margin: 0 auto 2.5rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--color-border);
}

.head-brand {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.head-logo {
  height: 48px;
  width: auto;
}

.page-head h1 {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 1.1rem;
  font-weight: 500;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--color-text);
}

.page-head .subtitle {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.72rem;
  font-weight: 400;
  color: var(--color-text-muted);
  margin-top: 0.3rem;
}

.theme-btn {
  background: none;
  border: none;
  color: var(--color-text-muted);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.65rem;
  letter-spacing: 0.05em;
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
}
.theme-btn:hover { color: var(--color-text); }

/* ── Layout ──────────────────────────────────────────────────────────────── */

.layout {
  display: flex;
  gap: 2rem;
  align-items: flex-start;
  max-width: 1160px;
  margin: 0 auto;
}

.main-col {
  flex: 1;
  min-width: 0;
}

.sidebar-col {
  width: 300px;
  flex-shrink: 0;
}

.sidebar-panel {
  position: sticky;
  top: 2rem;
}

@media (max-width: 960px) {
  .layout { flex-direction: column; }
  .sidebar-col { width: 100%; }
  .sidebar-panel { position: static; }
  .page-head { flex-wrap: wrap; gap: 1rem; }
}

/* ── Canvas ──────────────────────────────────────────────────────────────── */

#canvas {
  display: block;
  width: 100%;
  border: 1px solid var(--color-border);
  border-radius: 2px;
  cursor: default;
}

/* ── Sections ────────────────────────────────────────────────────────────── */

.section {
  border-top: 1px solid var(--color-border);
  padding: 1.25rem 0;
}

.sidebar-panel .section:first-child { border-top: none; }

.sidebar-panel > .primary-btn {
  margin-top: 1.25rem;
}

.section-toggle {
  width: 100%;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.section.is-open .section-toggle {
  margin-bottom: 1rem;
}

.section-label {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.62rem;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--color-text-muted);
  transition: color 0.15s;
}

.section-toggle:hover .section-label { color: var(--color-text); }

.section-ind {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.72rem;
  color: var(--color-text-muted);
  transition: color 0.15s;
}

.section-toggle:hover .section-ind { color: var(--color-text); }

.section-body {
  display: none;
}

.section.is-open .section-body {
  display: block;
}

.section-divider {
  border: none;
  border-top: 1px solid var(--color-border);
  margin: 0.75rem 0;
}

#synthParams {
  margin-top: 0.75rem;
}

/* ── Fields ──────────────────────────────────────────────────────────────── */

.field {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-bottom: 0.9rem;
}

.field:last-of-type { margin-bottom: 0; }

.field label {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.65rem;
  color: var(--color-text-muted);
  letter-spacing: 0.02em;
}

/* Label row: name on left, live value on right */
.field-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.field-val {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.65rem;
  color: var(--color-text);
}

/* Two equal columns for paired fields (planets/moons, root/scale) */
.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-bottom: 0.9rem;
}

/* Number input — same style as select */
.field input[type=number] {
  background: var(--color-field-bg);
  border: 1px solid var(--color-border-strong);
  border-radius: 2px;
  color: var(--color-text);
  padding: 0.3rem 0.5rem;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.72rem;
  width: 100%;
  outline: none;
  -moz-appearance: textfield;
}
.field input[type=number]::-webkit-inner-spin-button,
.field input[type=number]::-webkit-outer-spin-button { opacity: 0.4; }
.field input[type=number]:focus { border-color: var(--color-accent); }
.field input[type=number]::placeholder { color: var(--color-text-muted); opacity: 0.7; }

/* Range slider */
.field input[type=range] {
  -webkit-appearance: none;
  width: 100%;
  height: 2px;
  background: var(--color-border-strong);
  border-radius: 1px;
  outline: none;
  cursor: pointer;
}
.field input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 11px;
  height: 11px;
  background: var(--color-accent);
  border-radius: 50%;
  cursor: pointer;
}
.field input[type=range]::-moz-range-thumb {
  width: 11px;
  height: 11px;
  background: var(--color-accent);
  border-radius: 50%;
  cursor: pointer;
  border: none;
}

/* ── Select ──────────────────────────────────────────────────────────────── */

.select-wrap { position: relative; }
.select-wrap::after {
  content: '▾';
  position: absolute;
  right: 0.5rem;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
  font-size: 0.6rem;
  color: var(--color-text-muted);
}

.field select {
  -webkit-appearance: none;
  appearance: none;
  background: var(--color-field-bg);
  border: 1px solid var(--color-border-strong);
  border-radius: 2px;
  color: var(--color-text);
  padding: 0.3rem 1.5rem 0.3rem 0.5rem;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.72rem;
  width: 100%;
  outline: none;
  cursor: pointer;
}
.field select:focus { border-color: var(--color-accent); }
.field select option { background: #2C404E; color: #D8D8D8; }
[data-theme="light"] .field select option { background: #F6EADF; color: #1A1A1A; }

/* ── Segmented control ───────────────────────────────────────────────────── */

.seg-row {
  display: flex;
  background: var(--color-field-bg);
  border: 1px solid var(--color-border-strong);
  border-radius: 2px;
  overflow: hidden;
}

.seg-btn {
  flex: 1;
  background: none;
  border: none;
  border-right: 1px solid var(--color-border-strong);
  color: var(--color-text-muted);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.72rem;
  padding: 0.3rem 0;
  cursor: pointer;
  text-align: center;
  transition: background 0.1s, color 0.1s;
}
.seg-btn:last-child { border-right: none; }
.seg-btn.active { background: var(--color-accent); color: var(--color-bg); }
.seg-btn:hover:not(.active) { color: var(--color-text); }

/* ── Primary button ──────────────────────────────────────────────────────── */

.primary-btn {
  width: 100%;
  padding: 0.8rem;
  background: var(--color-action-bg);
  color: var(--color-action-text);
  border: none;
  border-radius: 2px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
  transition: opacity 0.15s;
  margin-top: 1rem;
}
.primary-btn:hover { opacity: 0.85; }

.secondary-btn {
  width: 100%;
  padding: 0.6rem;
  background: transparent;
  color: var(--color-text-muted);
  border: 1px solid var(--color-border-strong);
  border-radius: 2px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
  margin-top: 0.5rem;
}
.secondary-btn:hover { color: var(--color-text); border-color: var(--color-text-muted); }

/* ── Toggle switch ───────────────────────────────────────────────────────── */

.toggle {
  position: relative;
  display: inline-block;
  width: 30px;
  height: 16px;
  flex-shrink: 0;
}
.toggle input { opacity: 0; width: 0; height: 0; position: absolute; }

.toggle-slider {
  position: absolute;
  inset: 0;
  background: transparent;
  border: 1px solid var(--color-border-strong);
  border-radius: 2px;
  cursor: pointer;
  transition: border-color 0.15s;
}
.toggle-slider::before {
  content: '';
  position: absolute;
  width: 10px;
  height: 10px;
  left: 2px;
  top: 2px;
  background: var(--color-text-muted);
  border-radius: 1px;
  transition: transform 0.15s, background 0.15s;
}
.toggle input:checked + .toggle-slider { border-color: var(--color-accent); }
.toggle input:checked + .toggle-slider::before {
  transform: translateX(14px);
  background: var(--color-accent);
}

.toggle-row {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  margin-bottom: 0.65rem;
}

.toggle-label {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.72rem;
  color: var(--color-text-muted);
  cursor: pointer;
  user-select: none;
}
.toggle-label:hover { color: var(--color-text); }

/* ── Caveat / status text ────────────────────────────────────────────────── */

.midi-caveat {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.62rem;
  color: var(--color-text-muted);
  line-height: 1.6;
  margin-top: 0.65rem;
}

/* ── About copy ──────────────────────────────────────────────────────────── */

.about-copy {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  line-height: 1.65;
}

.about-copy + .about-copy {
  margin-top: 0.65rem;
}

a.ui-link {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.65rem;
  color: var(--color-accent);
  text-decoration: none;
  border-bottom: 1px solid var(--color-accent);
  padding-bottom: 0.1rem;
}
a.ui-link:hover { opacity: 0.7; }

.about-links {
  display: flex;
  gap: 1rem;
  margin-top: 0.85rem;
  flex-wrap: wrap;
}

/* ── Header actions group ────────────────────────────────────────────────── */

.head-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-shrink: 0;
}

/* ── Canvas wrap ─────────────────────────────────────────────────────────── */

.canvas-wrap {
  position: relative;
}

/* ── Fullscreen exit button (overlay) ───────────────────────────────────── */

.fs-exit-btn {
  display: none;
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.35);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.65rem;
  letter-spacing: 0.05em;
  cursor: pointer;
  padding: 0;
  transition: color 0.15s;
}
.fs-exit-btn:hover { color: rgba(255, 255, 255, 0.8); }
.fs-regen-btn { top: 2.5rem; }
.fs-rand-btn  { top: 4rem; }

.start-hint {
  position: absolute;
  bottom: 1.25rem;
  left: 50%;
  transform: translateX(-50%);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.6rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.3);
  pointer-events: none;
  white-space: nowrap;
}

/* ── Fullscreen mode ─────────────────────────────────────────────────────── */

body.is-fullscreen {
  padding: 0;
  overflow: hidden;
}

body.is-fullscreen .page-head  { display: none; }
body.is-fullscreen .sidebar-col { display: none; }

body.is-fullscreen .layout {
  display: block;
  max-width: 100%;
  margin: 0;
}

/* Canvas wrap becomes a centred black stage */
body.is-fullscreen .canvas-wrap {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: #050505;
  display: flex;
  align-items: center;
  justify-content: center;
}

body.is-fullscreen .fs-exit-btn { display: block; }

/* ── Privacy link (button styled as link) ────────────────────────────────── */

.privacy-link {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.65rem;
  color: var(--color-text-muted);
  background: none;
  border: none;
  border-bottom: 1px solid var(--color-border-strong);
  padding: 0 0 0.1rem;
  cursor: pointer;
  display: block;
  margin-top: 0.65rem;
}
.privacy-link:hover { color: var(--color-text); }

/* ── Privacy modal ───────────────────────────────────────────────────────── */

.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0, 0, 0, 0.55);
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.modal-overlay.is-open {
  display: flex;
}

.modal-card {
  background: var(--color-bg);
  border: 1px solid var(--color-border-strong);
  border-radius: 3px;
  width: 100%;
  max-width: 420px;
  padding: 1.5rem;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.1rem;
}

.modal-title {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.62rem;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--color-text-muted);
}

.modal-close {
  background: none;
  border: none;
  color: var(--color-text-muted);
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  transition: color 0.15s;
}
.modal-close:hover { color: var(--color-text); }

.modal-body {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  line-height: 1.65;
  margin-bottom: 0.65rem;
}

.modal-copy {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.65rem;
  color: var(--color-text-muted);
  margin-top: 1.1rem;
}
