/* Sound Explorer — LOM aesthetic, light + dark modes */

:root {
  --bg-primary: #ffffff;
  --bg-secondary: #ececec;
  --bg-tertiary: #d8d8d8;
  --text-primary: #000000;
  --text-secondary: #555555;
  --accent: #4a90d9;
  --border: #cccccc;
  --danger: #d94444;
  --input-bg: #ffffff;
  --slider-track: #cccccc;
  --slider-thumb: #000000;
  --vu-bg: #d8d8d8;
  --vu-border: #bbbbbb;
  --info-text: #666666;
}

body.dark {
  --bg-primary: #111111;
  --bg-secondary: #1a1a1a;
  --bg-tertiary: #111111;
  --text-primary: #e0e0e0;
  --text-secondary: #888888;
  --accent: #5a9de6;
  --border: #333333;
  --danger: #d94444;
  --input-bg: #0a0a0a;
  --slider-track: #333333;
  --slider-thumb: #e0e0e0;
  --vu-bg: #0a0a0a;
  --vu-border: #333333;
  --info-text: #999999;
}

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

::selection {
  background: var(--accent);
  color: #fff;
}

html {
  height: 100%;
}

body {
  font-family: Helvetica, Arial, sans-serif;
  font-size: 13px;
  background: var(--bg-secondary);
  color: var(--text-primary);
  height: 100%;
  /* PWA safe area: push content below status bar / notch */
  padding-top: constant(safe-area-inset-top, 0px);
  padding-top: env(safe-area-inset-top, 0px);
  overflow: hidden;
  user-select: none;
  -webkit-font-smoothing: antialiased;
}

/* --- Drop zone --- */

#drop-zone {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  background: var(--bg-secondary);
}

#drop-zone.active {
  outline: 2px dashed var(--accent);
  outline-offset: -24px;
}

.drop-content {
  text-align: center;
  max-width: 560px;
  padding: 0 24px;
}

.drop-logo {
  width: 64px;
  height: 64px;
  object-fit: contain;
  margin-bottom: 16px;
  opacity: 0.5;
}

body.dark .drop-logo {
  content: url('../img/logo_white.png');
}

.drop-version {
  font-size: 13px;
  font-weight: 400;
  color: var(--text-secondary);
  opacity: 0.6;
}

.drop-content h2 {
  font-size: 32px;
  font-weight: 300;
  letter-spacing: -0.03em;
  margin-bottom: 6px;
  color: var(--text-primary);
}

.drop-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 4px;
  padding: 2px 7px;
  vertical-align: middle;
  position: relative;
  top: -2px;
  opacity: 0.7;
}

.drop-content p {
  color: var(--text-secondary);
  margin-bottom: 10px;
  font-size: 14px;
}

.drop-intro {
  max-width: 420px;
  margin: 0 auto 24px;
  font-size: 15px;
  line-height: 1.6;
  color: var(--text-secondary);
}

.drop-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-top: 0;
}

.drop-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 14px 32px;
  min-width: 150px;
  border-radius: 8px;
  height: auto;
  font-size: 15px;
  transition: transform 0.1s, box-shadow 0.15s;
}

.drop-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.drop-btn:active {
  transform: translateY(0);
}

.drop-btn-icon {
  width: 28px;
  height: 28px;
  display: none;
}

.drop-btn-label {
  font-size: 15px;
  font-weight: 600;
}

.drop-btn-sub {
  display: none;
  font-size: 11px;
  opacity: 0.8;
  font-weight: 400;
}

.drop-drag-hint {
  font-size: 13px;
  color: var(--text-secondary);
  opacity: 0.5;
  margin-top: 12px;
  margin-bottom: 0;
}

.drop-features {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  margin-top: 28px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  text-align: left;
}

.drop-feature {
  padding: 14px 16px;
  background: var(--bg-primary);
}

.drop-feature-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 3px;
}

.drop-feature-desc {
  font-size: 12px;
  line-height: 1.45;
  color: var(--text-secondary);
}

.drop-links {
  margin-top: 24px;
  font-size: 13px;
}

.drop-links a {
  color: var(--accent);
  text-decoration: none;
}

.drop-links a:hover {
  text-decoration: underline;
}

.drop-links-sep {
  color: var(--text-secondary);
  opacity: 0.3;
  margin: 0 8px;
}

.drop-privacy {
  font-size: 11px;
  color: var(--text-secondary);
  opacity: 0.4;
  margin-top: 12px;
}

@media (max-width: 600px) {
  .drop-hint-desktop { display: none !important; }

  .drop-actions {
    flex-direction: column;
    align-items: stretch;
    gap: 14px;
    width: 100%;
    max-width: 280px;
    margin: 20px auto 0;
  }

  .drop-btn {
    padding: 20px 24px;
    min-width: 0;
    width: 100%;
    min-height: 80px;
  }

  .drop-btn-icon {
    display: block;
    width: 32px;
    height: 32px;
  }

  .drop-btn-label {
    font-size: 16px;
  }

  .drop-btn-sub {
    display: block;
  }

  .drop-logo {
    width: 60px;
    height: 60px;
  }

  .drop-content h2 {
    font-size: 20px;
    margin-bottom: 4px;
  }
}

/* --- Main layout --- */

#main-ui {
  display: flex;
  flex-direction: column;
  height: 100%;
}

/* --- Toolbar --- */

#toolbar {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  padding-left: calc(10px + env(safe-area-inset-left, 0px));
  padding-right: calc(10px + env(safe-area-inset-right, 0px));
  background: var(--bg-secondary);
  border-bottom: 2px solid var(--border);
  flex-wrap: wrap;
  min-height: 36px;
}

.toolbar-logo {
  width: 24px;
  height: 24px;
  object-fit: contain;
}

body.dark .toolbar-logo {
  content: url('../img/logo_white.png');
}

.toolbar-title {
  font-size: 13px;
  font-weight: 500;
  letter-spacing: -0.01em;
  color: var(--text-primary);
}

.toolbar-version {
  font-size: 10px;
  font-weight: 400;
  color: var(--text-secondary);
}

.toolbar-btn {
  height: 28px;
  padding: 0 10px;
  font-size: 12px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
}

.btn-play-pause {
  min-width: 72px;
}

/* Selects in toolbar should match button height */
#toolbar .select {
  height: 28px;
  box-sizing: border-box;
}

.toolbar-sep {
  width: 1px;
  height: 20px;
  background: var(--border);
  margin: 0 4px;
}

.toolbar-spacer {
  flex: 1;
}

.toolbar-label {
  color: var(--text-secondary);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-right: 2px;
  line-height: 26px;
}

/* --- Info strip --- */

#info-strip {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 5px 10px;
  padding-left: calc(10px + constant(safe-area-inset-left, 0px));
  padding-right: calc(10px + constant(safe-area-inset-right, 0px));
  padding-left: calc(10px + env(safe-area-inset-left, 0px));
  padding-right: calc(10px + env(safe-area-inset-right, 0px));
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  font-family: 'SF Mono', 'Menlo', 'Consolas', 'Liberation Mono', monospace;
  font-size: 12px;
  min-height: 28px;
  letter-spacing: 0.02em;
}

.info-cell {
  white-space: nowrap;
  color: var(--info-text);
}

.info-cell:first-child {
  color: var(--accent);
}

/* --- Canvas --- */

#spec-area {
  flex: 1;
  display: flex;
  flex-direction: row;
  overflow: hidden;
}

#canvas-container {
  flex: 1;
  position: relative;
  overflow: hidden;
  background: var(--bg-primary);
}

/* ── Tabbed sidebar ──────────────────────────────────────────────── */
.app-sidebar {
  width: 0;
  min-width: 0;
  background: var(--bg-secondary);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: width 0.2s ease, min-width 0.2s ease;
  flex-shrink: 0;
}

.app-sidebar.open {
  width: 340px;
  min-width: 340px;
}

.sidebar-tabs {
  display: flex;
  align-items: stretch;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  white-space: nowrap;
}

.sidebar-tab {
  flex: 1;
  padding: 7px 8px;
  font-size: 11px;
  font-weight: 600;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-secondary);
  cursor: pointer;
}

.sidebar-tab.active {
  color: var(--text-primary);
  border-bottom-color: var(--accent);
}

.sidebar-tab:hover:not(.active) {
  color: var(--text-primary);
}

.sidebar-close {
  padding: 4px 10px;
  font-size: 14px;
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  flex-shrink: 0;
}

.sidebar-pane {
  display: none;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
}

.sidebar-pane.active {
  display: flex;
}

.sidebar-body {
  overflow-y: auto;
  flex: 1;
  padding: 6px;
}

.annotation-add {
  display: flex;
  gap: 4px;
  padding: 6px 10px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.annotation-add .input {
  flex: 1;
  min-width: 0;
}

.annotation-actions {
  display: flex;
  gap: 4px;
  padding: 6px 10px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

/* Metadata tab */
.sidebar-meta-status {
  padding: 4px 10px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.meta-status {
  font-size: 10px;
  color: var(--text-secondary);
}

.meta-body {
  padding: 6px 8px;
}

.sidebar-meta-footer {
  display: flex;
  gap: 6px;
  padding: 6px 10px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  align-items: center;
}

.meta-apply-label {
  font-size: 10px;
  color: var(--text-secondary);
  white-space: nowrap;
}

/* FRM form styling */
.frm-section {
  margin-bottom: 4px;
  border: 1px solid var(--border);
  border-radius: 4px;
  overflow: hidden;
}

.frm-section summary {
  padding: 5px 8px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  background: var(--bg-primary);
  user-select: none;
  color: var(--text-primary);
}

.frm-section > label,
.frm-section > .frm-row,
.frm-section > textarea,
.frm-section > div {
  padding: 2px 8px;
}

.frm-section label {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  color: var(--text-secondary);
  white-space: nowrap;
}

.frm-section label input[type="text"],
.frm-section label textarea,
.frm-section label select {
  flex: 1;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 2px 4px;
  font-size: 10px;
  font-family: inherit;
  border-radius: 3px;
  min-width: 0;
}

.frm-section textarea {
  width: 100%;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 4px;
  font-size: 10px;
  font-family: inherit;
  border-radius: 3px;
  resize: vertical;
}

.frm-section label input[type="text"]:focus,
.frm-section textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.frm-section label input[readonly] {
  opacity: 0.5;
}

.frm-row {
  display: flex;
  gap: 6px;
}

.frm-checkboxes label {
  font-size: 10px;
}

.frm-narrow {
  max-width: 70px;
}

.frm-wide {
  min-width: 120px;
}

.frm-subsection-header {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-secondary);
  padding: 4px 0 2px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.frm-mic-row {
  display: flex;
  gap: 4px;
  padding: 2px 0;
  align-items: center;
}

.frm-mic-row input {
  flex: 1;
  min-width: 0;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 2px 4px;
  font-size: 10px;
  border-radius: 3px;
}

.frm-channel-row {
  display: flex;
  gap: 4px;
  padding: 2px 0;
  font-size: 10px;
  color: var(--text-secondary);
  align-items: center;
}

#spectrogram-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  touch-action: none;
}

.cursor-line {
  position: absolute;
  top: 0;
  left: 0;
  width: 2px;
  background: #f15656;
  pointer-events: none;
  z-index: 2;
  opacity: 0;
}

.computing-indicator {
  position: absolute;
  top: 8px;
  right: 12px;
  background: rgba(0, 0, 0, 0.6);
  color: var(--accent);
  font-size: 11px;
  font-family: 'SF Mono', 'Menlo', 'Consolas', 'Liberation Mono', monospace;
  padding: 3px 10px;
  border-radius: 3px;
  pointer-events: none;
  z-index: 10;
}

.canvas-hint {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.75);
  color: #e0e0e0;
  font-size: 12px;
  padding: 8px 16px;
  border-radius: 6px;
  pointer-events: none;
  z-index: 10;
  white-space: nowrap;
  transition: opacity 0.8s ease;
}

/* --- Bottom bar --- */

.bottom-toggle {
  display: none;
  width: 100%;
  height: 24px;
  border: none;
  border-top: 1px solid var(--border);
  background: var(--bg-secondary);
  color: var(--text-secondary);
  font-size: 10px;
  cursor: pointer;
  flex-shrink: 0;
}

#bottom-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 10px;
  padding-left: calc(10px + constant(safe-area-inset-left, 0px));
  padding-right: calc(10px + constant(safe-area-inset-right, 0px));
  padding-left: calc(10px + env(safe-area-inset-left, 0px));
  padding-right: calc(10px + env(safe-area-inset-right, 0px));
  background: var(--bg-secondary);
  border-top: 2px solid var(--border);
  flex-wrap: wrap;
  min-height: 38px;
  transition: max-height 0.2s ease, padding 0.2s ease, min-height 0.2s ease;
  overflow: hidden;
}

#bottom-bar.collapsed {
  max-height: 0;
  padding-top: 0;
  padding-bottom: 0;
  min-height: 0;
  border-top: none;
}

.control-section {
  display: flex;
  align-items: center;
  gap: 8px;
}

.control-section + .control-section {
  padding-left: 8px;
  border-left: 1px solid var(--border);
}

.section-label {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent);
  font-weight: 600;
  white-space: nowrap;
}

.control-group {
  display: flex;
  align-items: center;
  gap: 4px;
}

.ctrl-label {
  color: var(--text-secondary);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.ctrl-value {
  color: var(--text-secondary);
  font-size: 11px;
  min-width: 48px;
  text-align: right;
  font-family: 'SF Mono', 'Menlo', 'Consolas', 'Liberation Mono', monospace;
}

/* --- Status bar --- */

/* Big VU Meter */
.vu-meter-big {
  width: 100%;
  background: var(--vu-bg);
  border-bottom: 1px solid var(--border);
  padding: 6px 10px;
  display: none;
  flex-direction: column;
  gap: 3px;
}

.vu-channel-row {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 20px;
}

.vu-channel-label {
  font-size: 10px;
  font-family: 'SF Mono', 'Menlo', 'Consolas', 'Liberation Mono', monospace;
  color: var(--text-secondary);
  width: 16px;
  text-align: right;
  flex-shrink: 0;
}

.vu-channel-track-wrap {
  flex: 1;
  height: 16px;
  position: relative;
  background: var(--vu-bg);
}

.vu-channel-track {
  position: absolute;
  inset: 0;
  background: linear-gradient(to right, #2d8a4e, #4fc353 60%, #e8c840 85%, #f15656 95%);
  clip-path: inset(0 100% 0 0);
}

.vu-channel-peak {
  position: absolute;
  top: 0;
  width: 2px;
  height: 100%;
  background: var(--text-primary);
}

.vu-channel-db {
  font-size: 11px;
  font-family: 'SF Mono', 'Menlo', 'Consolas', 'Liberation Mono', monospace;
  color: var(--text-secondary);
  width: 120px;
  text-align: right;
  flex-shrink: 0;
  white-space: nowrap;
}

.vu-channel-db .vu-db-peak {
  color: var(--text-primary);
  font-weight: 500;
}

.vu-channel-db .vu-db-rms {
  color: var(--text-secondary);
}

.vu-scale {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 14px;
  margin-top: 1px;
}

.vu-scale-spacer {
  width: 16px;
  flex-shrink: 0;
}

.vu-scale-track {
  flex: 1;
  position: relative;
  height: 14px;
}

.vu-scale-mark {
  position: absolute;
  top: 0;
  font-size: 9px;
  font-family: 'SF Mono', 'Menlo', 'Consolas', 'Liberation Mono', monospace;
  color: var(--text-secondary);
  transform: translateX(-50%);
}

.vu-scale-db-spacer {
  width: 120px;
  flex-shrink: 0;
  font-size: 9px;
  font-family: 'SF Mono', 'Menlo', 'Consolas', 'Liberation Mono', monospace;
  color: var(--text-secondary);
  text-align: right;
}

#status-bar {
  padding: 3px 10px;
  /* iOS 11.0-11.1 */
  padding-bottom: calc(3px + constant(safe-area-inset-bottom, 0px));
  padding-left: calc(10px + constant(safe-area-inset-left, 0px));
  padding-right: calc(10px + constant(safe-area-inset-right, 0px));
  /* iOS 11.2+ */
  padding-bottom: calc(3px + env(safe-area-inset-bottom, 0px));
  padding-left: calc(10px + env(safe-area-inset-left, 0px));
  padding-right: calc(10px + env(safe-area-inset-right, 0px));
  background: var(--bg-tertiary);
  border-top: 1px solid var(--border);
  font-size: 11px;
  color: var(--text-secondary);
  min-height: 22px;
}

/* --- Update banner --- */

.update-banner {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px));
  background: var(--bg-secondary);
  border: 2px solid var(--accent);
  border-radius: 6px;
  font-size: 13px;
  color: var(--text-primary);
  z-index: 200;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
}

/* --- Buttons --- */

.btn {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: 0.375em;
  padding: 4px 12px;
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
  font-family: Helvetica, Arial, sans-serif;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.btn:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.btn:active {
  filter: brightness(0.85);
}

/* Action buttons — blue accent for play, primary actions */
.btn-action {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.btn-action:hover {
  filter: brightness(1.15);
  background: var(--accent);
  border-color: var(--accent);
}

/* Save/export buttons — subtle accent tint */
.btn-save {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.btn-save:hover {
  filter: brightness(1.15);
  background: var(--accent);
  border-color: var(--accent);
}

/* Live toggle — green */
.btn-live-toggle {
  background: #2d8a4e;
  border-color: #2d8a4e;
  color: #fff;
}

.btn-live-toggle:hover {
  background: #36a35d;
  border-color: #36a35d;
}

/* Live active — red to signal "stop" */
.btn-live-toggle.btn-live-active {
  background: var(--danger);
  border-color: var(--danger);
}

.btn-live-toggle.btn-live-active:hover {
  background: #b53030;
  border-color: #b53030;
}

/* Record button — red outline, only fills when recording */
.btn-record {
  color: var(--danger);
  border-color: var(--danger);
  background: transparent;
}

.btn-record:hover {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}

.btn-record.recording {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
  animation: pulse-record 1s infinite;
}

@keyframes pulse-record {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

#live-controls {
  display: none;
  align-items: center;
  gap: 4px;
}

#live-controls.active {
  display: inline-flex;
}

#live-status {
  font-size: 11px;
  color: var(--text-secondary);
  margin-left: 4px;
}

.btn-small {
  padding: 2px 8px;
  font-size: 11px;
  border-width: 1.5px;
}

.btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* Dark mode toggle button */
.btn-theme {
  font-size: 14px;
}

/* Help button circular */
.btn-help {
  width: 26px;
  height: 26px;
  padding: 0;
  border-radius: 50%;
  font-weight: 600;
  font-size: 13px;
  text-align: center;
  line-height: 22px;
}

/* --- Inputs --- */

.input {
  background: var(--input-bg);
  color: var(--text-primary);
  border: 2px solid var(--border);
  border-radius: 0.375em;
  padding: 3px 6px;
  font-size: 12px;
  font-family: 'SF Mono', 'Menlo', 'Consolas', 'Liberation Mono', monospace;
}

#toolbar .input {
  height: 28px;
  box-sizing: border-box;
}

.input:focus {
  outline: none;
  border-color: var(--accent);
}

.input-time {
  width: 80px;
}

.input-freq {
  width: 70px;
}

/* --- Selects --- */

.select {
  background: var(--input-bg);
  color: var(--text-primary);
  border: 2px solid var(--border);
  border-radius: 0.375em;
  padding: 3px 6px;
  font-size: 12px;
  font-family: Helvetica, Arial, sans-serif;
}

.select:focus {
  outline: none;
  border-color: var(--accent);
}

.select-small {
  font-size: 11px;
  padding: 2px 4px;
}

/* Bottom bar theme button — only visible on mobile (toolbar one hidden in live mode) */
.btn-theme-bottom {
  display: none;
}

/* --- Sliders --- */

.slider {
  -webkit-appearance: none;
  appearance: none;
  width: 80px;
  height: 3px;
  background: var(--slider-track);
  border-radius: 0;
  outline: none;
}

.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 12px;
  height: 12px;
  background: var(--slider-thumb);
  border-radius: 50%;
  cursor: pointer;
  transition: background 0.15s;
}

.slider::-webkit-slider-thumb:hover {
  background: var(--accent);
}

.slider::-moz-range-thumb {
  width: 12px;
  height: 12px;
  background: var(--slider-thumb);
  border-radius: 50%;
  cursor: pointer;
  border: none;
}

.slider::-moz-range-thumb:hover {
  background: var(--accent);
}

/* --- Selection controls --- */

#selection-controls {
  display: flex;
  align-items: center;
  gap: 4px;
}

.info-text {
  color: var(--text-secondary);
  font-size: 11px;
  font-family: 'SF Mono', 'Menlo', 'Consolas', 'Liberation Mono', monospace;
}

/* --- Dialogs --- */

dialog {
  background: var(--bg-secondary);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: 0.375em;
  padding: 24px;
  max-width: 500px;
  width: 90vw;
}

dialog::backdrop {
  background: rgba(0, 0, 0, 0.5);
}

dialog h3 {
  margin-bottom: 16px;
  font-weight: 400;
  font-size: 18px;
  letter-spacing: -0.01em;
}

dialog h4 {
  margin-top: 14px;
  margin-bottom: 8px;
  font-weight: 400;
  font-size: 13px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.shortcuts-table {
  width: 100%;
  margin-bottom: 10px;
  border-collapse: collapse;
}

.shortcuts-table td {
  padding: 4px 8px;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
}

.shortcuts-table td:first-child {
  color: var(--accent);
  font-family: 'SF Mono', 'Menlo', 'Consolas', 'Liberation Mono', monospace;
  font-size: 11px;
  width: 150px;
}

/* --- Annotations --- */

.annotations-list {
  max-height: 200px;
  overflow-y: auto;
  margin-bottom: 12px;
}

.annotation-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 0;
  border-bottom: 1px solid var(--border);
}

.annotation-time {
  color: var(--accent);
  font-family: 'SF Mono', 'Menlo', 'Consolas', 'Liberation Mono', monospace;
  font-size: 11px;
  white-space: nowrap;
}

.annotation-note {
  flex: 1;
  font-size: 12px;
}

.btn-del-annotation {
  background: none;
  border: none;
  color: var(--danger);
  cursor: pointer;
  font-size: 16px;
  padding: 0 4px;
}

.btn-del-annotation:hover {
  color: #d94444;
}

/* --- Waveform overview / minimap --- */
#overview-canvas {
  width: 100%;
  height: 30px;
  flex-shrink: 0;
  cursor: pointer;
  border-top: 1px solid var(--border);
  background: var(--bg-tertiary);
  display: none;
}

#overview-canvas.visible {
  display: block;
}

/* --- Keyboard focus indicators --- */
.btn:focus-visible,
.select:focus-visible,
.input:focus-visible,
.slider:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

/* ==========================================================================
   Mobile / touch layout (≤768px)
   ========================================================================== */

@media (max-width: 768px) {
  /* --- Bottom bar toggle visible on mobile --- */
  .bottom-toggle {
    display: block;
  }

  /* --- Drop zone: mobile friendly --- */
  .drop-hint-desktop {
    display: none !important;
  }

  /* --- Toolbar: single compact row --- */
  #toolbar {
    gap: 3px;
    padding: 4px 6px;
    flex-wrap: nowrap;
    overflow-x: auto;
  }

  .toolbar-btn {
    height: 36px;
    padding: 0 8px;
    font-size: 14px;
    line-height: 1;
    min-width: 36px;
    box-sizing: border-box;
  }

  /* Hide button text labels on mobile — show icons only */
  .btn-label {
    display: none;
  }

  .btn-play-pause {
    min-width: auto;
  }

  /* Constrain speed selector on mobile */
  #select-speed {
    max-width: 110px;
    font-size: 10px;
  }

  /* Hide secondary controls on mobile */
  #toolbar .toolbar-sep,
  #toolbar .toolbar-label,
  #btn-goto-mode,
  #input-goto,
  #btn-goto,
  #btn-shortcuts,
  #btn-zoom-in,
  #btn-zoom-out {
    display: none !important;
  }

  .toolbar-logo {
    width: 20px;
    height: 20px;
  }

  .toolbar-title {
    font-size: 11px;
  }

  .toolbar-version {
    display: none;
  }

  .toolbar-spacer {
    flex: 1;
    min-width: 0;
  }

  #select-speed {
    height: 36px;
    box-sizing: border-box;
  }

  #toolbar .input {
    height: 36px;
  }

  /* --- Info strip: minimal --- */
  #info-strip {
    gap: 10px;
    padding: 3px 6px;
    font-size: 11px;
    min-height: 22px;
  }

  #info-cursor,
  #info-wallclock,
  #info-file {
    display: none;
  }

  /* --- Bottom bar: vertical stack on mobile --- */
  #bottom-bar {
    flex-direction: column;
    align-items: stretch;
    overflow-x: visible;
    padding: 8px 10px;
    gap: 8px;
    min-height: auto;
    max-height: 60vh;
    overflow-y: auto;
  }

  .control-section {
    flex-shrink: 0;
    flex-wrap: wrap;
    gap: 6px 12px;
  }

  .control-section + .control-section {
    padding-left: 0;
    border-left: none;
    padding-top: 6px;
    border-top: 1px solid var(--border);
  }

  .section-label {
    font-size: 9px;
    width: 100%;
  }

  .ctrl-label {
    font-size: 11px;
  }

  /* Sliders: much larger for touch */
  .slider {
    width: 120px;
    height: 6px;
  }

  .slider::-webkit-slider-thumb {
    width: 28px;
    height: 28px;
  }

  .slider::-moz-range-thumb {
    width: 28px;
    height: 28px;
  }

  .ctrl-value {
    min-width: 36px;
    font-size: 11px;
  }

  .select-small {
    font-size: 12px;
    height: 34px;
    padding: 4px 6px;
  }

  .control-group {
    gap: 6px;
  }

  /* Number inputs: larger for touch */
  .input-freq {
    width: 65px;
    height: 34px;
    font-size: 14px;
    padding: 4px 6px;
  }

  /* VU meter button */
  #btn-vu {
    height: 34px;
    font-size: 12px;
    flex-shrink: 0;
    align-self: flex-start;
  }

  /* --- VU meter: taller bars for touch --- */
  .vu-channel-row {
    height: 26px;
  }

  .vu-channel-track {
    height: 20px;
  }

  .vu-channel-label {
    font-size: 11px;
  }

  .vu-channel-db {
    font-size: 11px;
    width: 100px;
  }

  /* --- Canvas: annotations panel fullscreen on mobile --- */
  .app-sidebar.open {
    position: fixed;
    inset: 0;
    width: 100% !important;
    min-width: 0 !important;
    z-index: 50;
    border-left: none;
  }

  /* --- Selection controls: compact --- */
  #selection-controls {
    flex-wrap: wrap;
    gap: 3px;
  }

  #selection-controls .toolbar-label {
    display: inline !important;
    font-size: 10px;
  }

  #selection-controls .input-time {
    width: 60px;
    height: 34px;
    font-size: 11px;
  }

  /* --- Dialog --- */
  dialog {
    width: 95vw;
    padding: 16px;
  }

  /* --- General touch size --- */
  .btn {
    min-height: 30px;
  }

  .btn-small {
    min-height: 26px;
  }

  /* --- Live controls: compact single row on mobile --- */
  #live-controls.active {
    display: flex;
    flex-wrap: nowrap;
    gap: 4px;
    padding: 2px 0;
    width: 100%;
    align-items: center;
  }

  #live-controls .select {
    height: 34px;
    font-size: 11px;
    flex: 1;
    min-width: 0;
  }

  #select-input-device {
    max-width: 40%;
  }

  #select-live-window {
    max-width: 60px;
  }

  #live-controls .btn {
    height: 34px;
    padding: 0 10px;
    font-size: 12px;
    min-width: 40px;
    flex-shrink: 0;
  }

  #btn-live-stop {
    font-weight: 600;
  }

  #live-status {
    display: none; /* SR in status bar, time on spectrogram axes */
  }

  .btn-theme-bottom {
    display: inline-block;
  }

  /* --- Status bar --- */
  #status-bar {
    font-size: 10px;
    padding: 2px 6px;
    min-height: 18px;
  }
}
