:root {
  color-scheme: dark;
  --bg: #0d111b;
  --panel: #141a2a;
  --panel-soft: #1b2438;
  --text: #f5f7ff;
  --muted: #9aa7bf;
  --accent: #5b8cff;
  --accent-2: #8fb3ff;
  --danger: #ff6b7a;
  --border: rgba(94, 112, 156, 0.34);
  --border-strong: rgba(126, 150, 207, 0.52);
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.36);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(91, 140, 255, 0.16), transparent 30rem),
    radial-gradient(circle at bottom right, rgba(72, 94, 145, 0.18), transparent 28rem),
    var(--bg);
  color: var(--text);
}

button {
  font: inherit;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.app-shell {
  width: min(1480px, calc(100% - 32px));
  margin: 0 auto;
  padding: 20px 0 32px;
}

.panel,
.timeline-card {
  border: 1px solid var(--border);
  background: rgba(20, 26, 42, 0.9);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.panel {
  border-radius: 28px;
  padding: 18px;
}

.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.primary-button,
.secondary-button,
.icon-button,
.mini-button {
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
  cursor: pointer;
  font-weight: 800;
  transition: transform 0.16s ease, border-color 0.16s ease, background 0.16s ease;
}

.primary-button:hover:not(:disabled),
.secondary-button:hover:not(:disabled),
.icon-button:hover:not(:disabled),
.mini-button:hover:not(:disabled) {
  transform: translateY(-1px);
  border-color: var(--border-strong);
}

.primary-button {
  background: linear-gradient(135deg, #5b8cff, #3f66d8);
  border-color: transparent;
  padding: 12px 18px;
}

.secondary-button {
  padding: 12px 16px;
}

.record-toggle-button.is-recording {
  background: linear-gradient(135deg, #ff4d7e, #ff8e4d);
}


.checkbox-control {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 800;
  user-select: none;
}

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

.checkbox-control:has(input:disabled) {
  opacity: 0.45;
}


.compact-select {
  min-height: 42px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
  padding: 0 34px 0 12px;
  font: inherit;
  font-size: 0.88rem;
  font-weight: 800;
  cursor: pointer;
}

.compact-select:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.compact-select option {
  color: #11131c;
}

.icon-button {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  padding: 0;
}

.danger-icon-button:not(:disabled) {
  color: #fff;
  background: rgba(255, 125, 156, 0.14);
}

.timeline-card {
  position: relative;
  overflow: hidden;
  border-radius: 24px;
}

.timeline-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
}

h3,
p {
  margin: 0;
}

h3 {
  font-size: 1rem;
}

.timeline-toolbar p,
.status-line {
  color: var(--muted);
  line-height: 1.45;
}

.timeline-toolbar p {
  margin-top: 6px;
  font-size: 0.9rem;
}

.zoom-controls {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px;
  background: rgba(255, 255, 255, 0.05);
  white-space: nowrap;
}

.mini-button {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  padding: 0;
}

#zoomLabel {
  min-width: 48px;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 800;
  text-align: center;
}

.timeline-scroll-shell {
  position: relative;
  overflow-x: auto;
  overflow-y: hidden;
  width: 100%;
  min-height: 420px;
  background: #0a0b14;
}

.timeline-scroll-shell.is-busy {
  pointer-events: none;
}

#waveformTimeline {
  display: block;
  height: 420px;
}

.timeline-busy-overlay {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: rgba(10, 11, 20, 0.68);
  color: var(--text);
}

.timeline-busy-overlay[hidden] {
  display: none;
}

.spinner {
  width: 24px;
  height: 24px;
  border: 3px solid rgba(255, 255, 255, 0.22);
  border-top-color: var(--accent-2);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}

.area-action-menu {
  position: absolute;
  z-index: 4;
  display: grid;
  gap: 6px;
  min-width: 146px;
  padding: 7px;
  border: 1px solid var(--border-strong);
  border-radius: 16px;
  background: rgba(13, 17, 27, 0.94);
  box-shadow: 0 16px 42px rgba(0, 0, 0, 0.36);
  backdrop-filter: blur(12px);
}

.area-action-menu[hidden] {
  display: none;
}

.area-action-button {
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 9px 12px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  cursor: pointer;
  font-weight: 900;
  text-align: left;
}

.area-action-button:hover:not(:disabled) {
  border-color: var(--border-strong);
  background: rgba(91, 140, 255, 0.16);
}

.area-action-button--primary {
  background: var(--accent);
  border-color: transparent;
  color: #071021;
}

.area-action-button--danger {
  color: #ffe7ec;
  background: rgba(255, 107, 122, 0.14);
}

.area-action-button[hidden] {
  display: none;
}

.status-line {
  min-height: 22px;
  margin: 12px 6px 0;
  font-size: 0.9rem;
}

.status-line--error {
  color: var(--danger);
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@media (max-width: 760px) {
  .app-shell {
    width: min(100% - 18px, 1480px);
    padding-top: 10px;
  }

  .panel {
    padding: 12px;
    border-radius: 20px;
  }

  .topbar {
    align-items: stretch;
  }

  .primary-button,
  .secondary-button {
    flex: 1 1 auto;
  }


  .timeline-toolbar {
    flex-direction: column;
  }
}
