:root {
  --bg: #f3efe7;
  --bg-accent: radial-gradient(circle at top left, rgba(255, 181, 91, 0.35), transparent 32%);
  --panel: rgba(255, 252, 247, 0.88);
  --panel-strong: #fff8ee;
  --text: #1f1a16;
  --muted: #6c5f54;
  --line: rgba(78, 56, 30, 0.12);
  --brand: #cb5d2f;
  --brand-strong: #984122;
  --accent: #0f7b73;
  --danger: #a33f3f;
  --shadow: 0 18px 44px rgba(52, 35, 18, 0.12);
  --radius-xl: 28px;
  --radius-lg: 20px;
  --radius-md: 14px;
  --font-body: "Aptos", "Trebuchet MS", "Segoe UI", sans-serif;
  --font-display: "Georgia", "Times New Roman", serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: var(--font-body);
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(26, 93, 89, 0.12), transparent 26%),
    radial-gradient(circle at top right, rgba(173, 71, 39, 0.14), transparent 32%),
    linear-gradient(180deg, #f1e7d8, #e2d0bd);
  min-height: 100vh;
  position: relative;
  padding: 32px 20px 44px;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background:
    repeating-linear-gradient(90deg, transparent 0 64px, rgba(25, 22, 19, 0.03) 64px 65px),
    repeating-linear-gradient(180deg, transparent 0 64px, rgba(25, 22, 19, 0.022) 64px 65px);
  pointer-events: none;
  z-index: 0;
}

body::after {
  content: "";
  position: fixed;
  inset: 18px;
  border: 1px solid rgba(25, 22, 19, 0.08);
  pointer-events: none;
  z-index: 100;
}

button,
input,
audio {
  font: inherit;
}

.page-shell {
  width: 100%;
  margin: 0 auto;
  position: relative;
  z-index: 1; /* Keep content above body::before */
}

.hero {
  padding: 28px 30px 22px;
}

.eyebrow,
.kicker {
  margin: 0 0 10px;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--brand);
}

.hero h1,
.panel h2 {
  margin: 0;
  font-family: var(--font-display);
  line-height: 1;
}

.hero h1 {
  max-width: 12ch;
  font-size: clamp(2.5rem, 6vw, 5rem);
}

.hero-copy {
  max-width: 70ch;
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.7;
}

.hero-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

.hero-badges span,
.chip {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.75);
  border-radius: 999px;
  padding: 10px 14px;
  font-size: 0.9rem;
}

.editor-workspace {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 240px);
}

.layout-grid {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: flex-start;
  gap: 24px;
  width: 100%;
}

.main-panel {
  width: 100%;
  max-width: 480px;
}

.hero-footer {
  margin-top: 80px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  opacity: 0.8;
}

.hero-footer .hero-copy {
  text-align: center;
}

.hero-footer .hero-badges {
  justify-content: center;
}

.panel {
  background: var(--panel);
  backdrop-filter: blur(18px);
  border: 1px solid rgba(255, 255, 255, 0.65);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
  padding: 24px;
}

.panel-col-3 { grid-column: span 3; }
.panel-col-4 { grid-column: span 4; }
.panel-col-6 { grid-column: span 6; }
.panel-col-8 { grid-column: span 8; }
.panel-col-9 { grid-column: span 9; }
.panel-col-12 { grid-column: span 12; }
.panel-offset-2 { grid-column-start: 3; }
.panel-offset-3 { grid-column-start: 4; }

.panel-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}

.panel h2 {
  font-size: 1.8rem;
}

.field,
.slider-field,
.toggle-field {
  display: grid;
  gap: 8px;
}

.field input[type="file"] {
  border: 1px dashed var(--line);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.72);
  padding: 12px;
}

#source-player {
  width: 100%;
  margin-top: 14px;
}

.button-row,
.preset-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}

button {
  border: none;
  border-radius: 999px;
  padding: 11px 16px;
  background: var(--brand);
  color: #fff8f1;
  cursor: pointer;
  transition: transform 140ms ease, background 140ms ease;
}

button:hover {
  transform: translateY(-1px);
  background: var(--brand-strong);
}

button.secondary,
.preset-btn {
  background: rgba(23, 122, 115, 0.12);
  color: var(--accent);
}

.status-card,
.callout,
.meter-card,
.metric,
.control-group {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.68);
}

.status-card,
.callout,
.meter-card {
  margin-top: 18px;
  padding: 16px 18px;
}

.status-line,
.callout p {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.status-line + .status-line,
.callout p + p {
  margin-top: 10px;
}

.callout h3,
.control-group h3 {
  margin: 0 0 10px;
  font-size: 1rem;
}

.callout.subtle {
  background: rgba(249, 244, 236, 0.9);
}

.meter-labels,
.metrics-grid {
  display: grid;
}

.meter-labels {
  grid-template-columns: 1fr auto;
  align-items: center;
  margin-bottom: 10px;
}

.meter-track {
  height: 12px;
  border-radius: 999px;
  background: rgba(19, 28, 36, 0.11);
  overflow: hidden;
}

.meter-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #0f7b73, #f0a548, #cb5d2f);
  transition: width 60ms linear;
}

.metrics-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 18px;
}

.metric {
  padding: 16px;
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 0.85rem;
}

.metric strong {
  display: block;
  margin-top: 8px;
  font-size: 1.1rem;
}

.controls-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 16px;
  align-items: start;
}

.control-group {
  padding: 18px;
  display: grid;
  gap: 14px;
}

.slider-field {
  grid-template-columns: 1fr auto;
  align-items: center;
}

.slider-field input[type="range"] {
  grid-column: 1 / -1;
  width: 100%;
  accent-color: var(--brand);
}

.toggle-field {
  grid-template-columns: auto 1fr;
  align-items: center;
}

.toggle-field input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

/* --- Menu Bar --- */
.menubar {
  display: flex;
  align-items: center;
  padding: 0 20px;
  height: 54px;
  background: var(--panel);
  border-bottom: 1px solid rgba(255, 255, 255, 0.4);
  position: relative;
  z-index: 200;
  backdrop-filter: blur(10px);
  margin-bottom: 24px;
}
.menubar-brand {
  font-weight: 800;
  margin-right: 32px;
  color: var(--brand);
  font-family: var(--font-display);
  font-size: 1.2rem;
}
.menubar-nav, .dropdown, .submenu {
  list-style: none;
  margin: 0;
  padding: 0;
}
.menubar-nav {
  display: flex;
  height: 100%;
  overflow: visible;
}
.menu-item {
  position: relative;
  display: flex;
  align-items: center;
  overflow: visible;
}
.menu-item > a, .dropdown a, .submenu a {
  padding: 0 16px;
  color: var(--text);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.95rem;
  display: block;
}
.menu-item > a {
  height: 100%;
  display: flex;
  align-items: center;
}
.menu-item:hover > a { background: rgba(0,0,0,0.05); }
.dropdown, .submenu {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  border-radius: 0 0 8px 8px;
  min-width: 180px;
  padding: 8px 0;
  backdrop-filter: blur(18px);
  overflow: visible;
  z-index: 260;
}
.menu-item:hover > .dropdown { display: block; }
.dropdown {
  min-width: 220px;
}
.has-submenu {
  position: relative;
  overflow: visible;
}
.has-submenu > a {
  padding: 10px 16px;
  display: flex;
  justify-content: space-between;
}
.has-submenu > a::after {
  content: "▸";
  margin-left: 8px;
  color: var(--muted);
}
.has-submenu:hover > a { background: rgba(0,0,0,0.05); }
.submenu {
  top: -8px;
  left: calc(100% - 6px);
  border-radius: 8px;
  min-width: 280px;
  max-height: min(72vh, 34rem);
  overflow-y: auto;
  overflow-x: hidden;
}
.has-submenu:hover > .submenu { display: block; }
.submenu a { padding: 8px 16px; font-weight: 400; }
.submenu a::after { display: none; }
.submenu a:hover { background: rgba(0,0,0,0.05); }

/* --- Modals --- */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(25, 22, 19, 0.4);
  backdrop-filter: blur(4px);
  z-index: 300;
}
.modal-overlay.active { display: block; }
.modal {
  display: none;
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: var(--panel);
  border: 1px solid rgba(255, 255, 255, 0.65);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  z-index: 301;
  width: 96%;
  max-width: 480px;
  backdrop-filter: blur(18px);
}
.modal.active { display: block; }
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
}
.modal-header h3 { margin: 0; font-size: 1.2rem; font-family: var(--font-display); }
.modal-close {
  background: transparent;
  border: none;
  font-size: 1.8rem;
  line-height: 1;
  color: var(--muted);
  cursor: pointer;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
}
.modal-close:hover { 
  color: var(--danger); 
  transform: none; 
  background: rgba(0,0,0,0.05); 
}
.modal-body {
  padding: 20px;
  max-height: calc(100vh - 120px);
  overflow-y: auto;
}
.modal-body .control-group {
  border: none;
  background: transparent;
  padding: 0;
}
.modal-body .control-group h3 { display: none; }

code {
  font-family: "Consolas", "Courier New", monospace;
  font-size: 0.95em;
}

@media (max-width: 1080px) {
  .panel,
  .panel-col-3,
  .panel-col-4,
  .panel-col-6,
  .panel-col-8,
  .panel-col-9,
  .panel-col-12 {
    grid-column: span 12;
  }
}

@media (max-width: 720px) {
  body {
    padding: 20px 14px 32px;
  }

  .hero {
    padding: 12px 2px 20px;
  }

  .controls-grid,
  .metrics-grid {
    grid-template-columns: 1fr;
  }

  .panel {
    padding: 20px;
  }
}
