:root {
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "IBM Plex Sans", "Space Grotesk", "Avenir Next", sans-serif;
  color: #1e1f1e;
  background:
    radial-gradient(circle at 14% 18%, rgba(111, 145, 124, 0.15), transparent 45%),
    radial-gradient(circle at 78% 8%, rgba(179, 122, 78, 0.14), transparent 40%),
    linear-gradient(180deg, #f7f4ee 0%, #efe9de 100%);
}

.topbar {
  padding: 6px 12px;
  border-bottom: 1px solid #cfc3b0;
  background: rgba(255, 252, 246, 0.88);
  backdrop-filter: blur(3px);
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 10px;
}

.topbar h1 {
  margin: 0;
  font-size: 15px;
  line-height: 1.1;
  white-space: nowrap;
}

.topbar-hotkeys {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 4px 8px;
  font-size: 10px;
  color: #5b564e;
  line-height: 1.15;
}

.topbar-hotkeys span {
  white-space: nowrap;
}

.topbar-hotkeys kbd {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 10px;
  background: #f2ece1;
  border: 1px solid #c8baa8;
  border-bottom-color: #b8a998;
  border-radius: 4px;
  padding: 0 4px;
  color: #3f372b;
}

.live-toggle-btn {
  width: 100%;
  min-height: 34px;
}

.live-toggle-btn.is-live {
  background: #ba442e;
  border-color: #8e2f1f;
}

.layout {
  display: grid;
  grid-template-columns: 360px minmax(700px, 1fr);
  gap: 14px;
  padding: 14px;
}

.panel {
  border: 1px solid #d4c7b5;
  border-radius: 10px;
  background: rgba(255, 251, 245, 0.92);
  box-shadow: 0 6px 22px rgba(70, 58, 35, 0.08);
}

.controls-panel {
  padding: 14px;
  position: sticky;
  top: 12px;
  align-self: start;
  max-height: calc(100vh - 84px);
  overflow: auto;
}

.controls-panel h2 {
  margin: 12px 0 8px;
  font-size: 15px;
}

.controls-panel h2:first-child {
  margin-top: 0;
}

.settings-accordion {
  margin-top: 10px;
  border: 1px solid #cfc3b0;
  border-radius: 8px;
  background: rgba(255, 252, 246, 0.72);
}

.settings-accordion > summary {
  cursor: pointer;
  user-select: none;
  font-weight: 600;
  padding: 8px 10px;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.settings-accordion > summary::-webkit-details-marker {
  display: none;
}

.settings-accordion > summary::after {
  content: "▾";
  font-size: 12px;
  line-height: 1;
  color: #4f473d;
  transform: rotate(-90deg);
  transition: transform 120ms ease;
}

.settings-accordion[open] > summary {
  border-bottom: 1px solid #d9cebf;
}

.settings-accordion[open] > summary::after {
  transform: rotate(0deg);
}

.settings-body {
  padding: 10px 10px 6px;
}

.group {
  display: grid;
  gap: 6px;
  margin-bottom: 10px;
}

.group.two-col {
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}

.sample-row {
  grid-template-columns: 1fr 42px;
}

.row.compact {
  grid-template-columns: 1fr auto;
}

.row.playback-controls-row {
  grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
  gap: 6px;
  align-items: center;
}

.speed-btn {
  width: 100%;
  padding: 6px 6px;
}

.speed-display-btn {
  width: 100%;
  border: 1px solid #bcae9a;
  background: #fffdf8;
  color: #3a301f;
  padding: 6px 8px;
}

.speed-display-btn:hover {
  background: #f6efe4;
}

.speed-display-btn.is-active {
  background: #8f6f45;
  color: #fff;
  border-color: #7f6a4c;
}

.inline {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

input,
select,
button {
  font: inherit;
}

input[type="text"],
input[type="number"],
select {
  width: 100%;
  border: 1px solid #bcae9a;
  border-radius: 8px;
  padding: 7px 8px;
  background: #fffdf8;
}

button {
  border: 1px solid #7f6a4c;
  background: #8f6f45;
  color: #fff;
  border-radius: 8px;
  padding: 7px 11px;
  cursor: pointer;
}

button:hover {
  background: #755c3a;
}

.hint {
  margin: 0 0 12px;
  font-size: 11px;
  color: #6a665f;
}

.hidden {
  display: none !important;
}

.drop-hint {
  margin: 0 0 10px;
  font-size: 12px;
  color: #5f584d;
  border: 1px dashed #bcae9a;
  background: rgba(255, 252, 245, 0.9);
  border-radius: 8px;
  padding: 8px 10px;
}

.drop-hint code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 11px;
}

.drag-reveal-load {
  display: none;
}

body.is-file-dragging .drag-reveal-load.is-visible-on-drag {
  display: grid;
}

body.is-live-mode .live-dataset {
  display: none !important;
}

body.is-live-mode .live-playback {
  display: none !important;
}

.mode-buttons {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.mode-btn {
  border: 1px solid #9a886c;
  background: #f4ede1;
  color: #3a301f;
}

.mode-btn.is-active {
  background: #8f6f45;
  color: #fff;
  border-color: #7f6a4c;
}

.viewer-panel {
  padding: 12px;
}

.status {
  font-size: 12px;
  color: #46463f;
  margin-bottom: 8px;
}

.waveform {
  position: relative;
  border: 1px solid #cfbeaa;
  border-radius: 8px;
  background: #fff;
  overflow-x: auto;
  overflow-y: hidden;
  min-height: 130px;
}

.waveform-hover-line {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 2px;
  pointer-events: none;
  z-index: 50;
  opacity: 0;
  background: rgba(30, 110, 190, 0.9);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.25);
  transform: translateX(-1px);
}

.waveform-error-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 18;
}

.waveform-time-badge {
  position: absolute;
  top: 6px;
  left: 8px;
  z-index: 60;
  pointer-events: none;
  font: 11px/1.2 "IBM Plex Sans", "Space Grotesk", "Avenir Next", sans-serif;
  color: #1f2b38;
  background: rgba(255, 255, 255, 0.86);
  border: 1px solid rgba(88, 104, 122, 0.35);
  border-radius: 6px;
  padding: 2px 6px;
}

#specCanvas {
  margin-top: 10px;
  width: 100%;
  border: 1px solid #cfbeaa;
  border-radius: 8px;
  background: #faf8f3;
  display: block;
}

#localWaveCanvas {
  margin-top: 10px;
  width: 100%;
  border: 1px solid #cfbeaa;
  border-radius: 8px;
  background: #f9fcff;
  display: block;
}

#localWaveLagCanvas {
  margin-top: 10px;
  width: 100%;
  border: 1px solid #cfbeaa;
  border-radius: 8px;
  background: #f8fff9;
  display: block;
}

#localWaveSynthCanvas {
  margin-top: 10px;
  width: 100%;
  border: 1px solid #cfbeaa;
  border-radius: 8px;
  background: #fbfff7;
  display: block;
}

#frameCanvas {
  margin-top: 10px;
  width: 100%;
  border: 1px solid #cfbeaa;
  border-radius: 8px;
  background: #fffefb;
  display: block;
}

.comb-module {
  margin-top: 10px;
}

.comb-controls {
  margin-bottom: 8px;
}

#combWaveCanvas {
  width: 100%;
  border: 1px solid #cfbeaa;
  border-radius: 8px;
  background: #f8fdfb;
  display: block;
}

#combAcCanvas {
  margin-top: 10px;
  width: 100%;
  border: 1px solid #cfbeaa;
  border-radius: 8px;
  background: #f7fafe;
  display: block;
}

.meta {
  margin-top: 8px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 12px;
  color: #3a3a35;
  white-space: pre-wrap;
}

@media (max-width: 550px) {
  .layout {
    grid-template-columns: 1fr;
  }
  .controls-panel {
    position: static;
    top: auto;
    max-height: none;
    overflow: visible;
  }
}
