/* ───────────── GLOBAL ───────────── */
body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #f3f3f3;
  color: #222;
}

a:link,
a:visited {
  color: #ffd684;
}

.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

/* ───────────── TOP BAR ───────────── */
.top-bar {
  padding: 16px 24px;
  background: #ffffff;
  border-bottom: 1px solid #ddd;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.top-left,
.top-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

button {
  font-size: 18px;
  padding: 10px 16px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  background: #3178c6;
  color: #fff;
}

button.secondary {
  background: #666;
}

button.icon-button.record {
  background-color: #ff0000;
}

button:disabled {
  opacity: 0.6;
  cursor: default;
}

/* Ensures ALL icon-only buttons center their SVGs */
.icon-button {
  display: flex;
  align-items: center;     /* vertical center */
  justify-content: center; /* horizontal center */
  padding: 8px 10px;
  gap: 0;
}

/* For the mic / record button */
.icon-button.record {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background-color: #d50000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

/* Pulse animation when recording */
.icon-button.record.recording {
  animation: recordPulse 1.3s ease-in-out infinite;
}

@keyframes recordPulse {
  0% {
    transform: scale(1);
    box-shadow: 0 0 0px rgba(255, 0, 0, 0.6);
  }
  50% {
    transform: scale(1.12);
    box-shadow: 0 0 14px rgba(255, 0, 0, 0.8);
  }
  100% {
    transform: scale(1);
    box-shadow: 0 0 0px rgba(255, 0, 0, 0.6);
  }
}

.icon-svg {
  width: 24px;
  height: 24px;
  fill: #ffffff;
}

.master-volume {
  display: flex;
  align-items: center;
  gap: 8px;
}

.master-section {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
}

/* duplicate but harmless */
.master-volume {
  display: flex;
  align-items: center;
  gap: 8px;
}

.master-vu {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: 2px;
}

.vu-channel {
  display: flex;
  align-items: center;
  gap: 4px;
}

.vu-label {
  font-size: 11px;
  color: #666;
}

/* Horizontal VU bar */
.vu-bar {
  width: 285px;
  height: 8px;
  border-radius: 4px;
  background: #333;
  overflow: hidden;
  position: relative;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}

.vu-fill {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 100%;
  transform-origin: left center;
  transform: scaleX(0);
  background: linear-gradient(to right, #2ecc71, #f1c40f, #e74c3c);
}

/* Dark mode tweaks */
body.dark .vu-bar {
  background: #111;
}

body.dark .vu-label {
  color: #ccc;
}

input[type="range"] {
  width: 180px;
}

.time-display {
  font-size: 20px;
  font-weight: bold;
  min-width: 120px;
}

/* Dark mode toggle */
.darkmode-button {
  padding: 6px 10px;
  border-radius: 6px;
  background: #444;
  color: #fff;
  cursor: pointer;
  border: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.darkmode-button:hover {
  background: #555;
}

.darkmode-button .darkmode-icon {
  width: 20px;
  height: 20px;
}

/* ───────────── KEBAB DROPDOWN ───────────── */
.kebab-dropdown {
  position: relative;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}

.kebab-toggle {
  background: transparent;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  color: #666;
}

.kebab-toggle:hover {
  color: #333;
}

.kebab-icon {
  width: 30px;
  height: 30px;
}

.kebab-icon rect {
  fill: currentColor;
}

/* Hidden by default */
.kebab-menu {
  position: absolute;
  right: 0;
  top: 110%;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 4px 10px rgba(0,0,0,0.15);
  padding: 6px 0;
  width: max-content;     /* grow to fit content */
  min-width: 180px;       /* but don't get too skinny */
  display: none;
  z-index: 50;
  overflow: hidden;       /* keeps hover background neatly clipped */
}

/* OPEN STATE */
.kebab-dropdown.open .kebab-menu {
  display: flex;
  flex-direction: column;
}

/* Items (used by both hamburger + Add Sound menu) */
.kebab-item {
  display: flex;              /* icon + text in a row */
  align-items: center;
  gap: 8px;
  white-space: nowrap;        /* no wrapping */
  padding: 6px 10px;
  text-align: left;
  border: none;
  background: none;
  font-size: 15px;
  cursor: pointer;
  width: 100%;                /* full clickable width */
  box-sizing: border-box;
}

.kebab-item i {
  font-size: 18px;
}

.kebab-item:hover {
  background: #f0f0f0;
  text-decoration: underline;
}

/* Disabled kebab items (we keep pointer events so the title tooltip can show;
   JS blocks the actual action on click) */
.kebab-item[aria-disabled="true"] {
  opacity: 0.45;
  cursor: not-allowed;
}

.kebab-item[aria-disabled="true"]:hover {
  background: none;
  text-decoration: none;
}

/* ───────────── MAIN LAYOUT ───────────── */
.content {
  flex: 1;
  display: flex;
  overflow: hidden;
  min-height: 0;
}

.tracks-panel {
  flex: 1;
  padding: 0 24px;
  overflow-y: auto;
  background: #f3f3f3;
  min-height: 0;
}

.tracks-toolbar {
  position: sticky;
  top: 74px;          /* adjust if needed based on your sticky header/timeline */
  z-index: 45;
  margin: 6px 0 10px;
  display: none; /* hidden until tracks exist */
  justify-content: flex-end;
  align-items: center;
}

/* compact button */
.btn-mini{
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 10px;
  line-height: 1.2;
  opacity: 0.9;
}

.btn-mini:hover{
  opacity: 1;
}

/* Right-side panels (Help + Library) */
.help-panel,
.library-panel {
  width: 320px;
  max-width: 35%;
  border-left: 1px solid #ddd;
  background: #ffffff;
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
}

.help-header,
.library-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.help-title,
.library-title {
  font-size: 18px;
  font-weight: 600;
}

.help-close-btn,
.library-close-btn {
  background: transparent;
  color: #666;
  font-size: 20px;
  padding: 0 6px;
  border-radius: 4px;
}

.help-close-btn:hover,
.library-close-btn:hover {
  background: #eee;
}

.help-body {
  font-size: 14px;
  line-height: 1.5;
  overflow-y: auto;
  max-height: calc(100vh - 150px);
}

.help-body h3 {
  margin-top: 0;
  font-size: 16px;
}

.help-body ul,
.help-body ol {
  padding-left: 20px;
}

/* ───────────── EFFECTS PANEL (match Help/Library panels) ───────────── */

.effects-panel {
  width: 320px;
  max-width: 35%;
  border-left: 1px solid #ddd;
  background: #ffffff;
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
}

/* Header row – same structure as help/library header */
.effects-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.effects-title {
  font-size: 18px;
  font-weight: 600;
}

.effects-close-btn {
  background: transparent;
  color: #666;
  font-size: 20px;
  padding: 0 6px;
  border-radius: 4px;
  border: none;
  cursor: pointer;
}

.effects-close-btn:hover {
  background: #eee;
}

/* Scrollable body area, same feel as help body */
.effects-body {
  font-size: 14px;
  line-height: 1.5;
  overflow-y: auto;
  max-height: calc(100vh - 150px);
}

/* Inner container that renderEffectsPanelBody() injects */
.effects-panel-inner {
  display: flex;
  flex-direction: column;
  gap: 10px;
  font-size: 13px;
  color: #222;
}

/* List + rows */
.effects-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.effects-row {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(0, 1.2fr) auto;
  gap: 8px;
  align-items: center;
  padding: 8px 10px;
  border-radius: 8px;
  background: #f7f7f7;
  border: 1px solid #ddd;
}

.effects-name {
  font-weight: 500;
  font-size: 13px;
}

/* Start/end inputs */
.effects-timing {
  display: flex;
  align-items: center;
  gap: 4px;
  justify-content: flex-start;
}

.effects-time-input {
  width: 70px;
  padding: 4px 6px;
  font-size: 12px;
  border-radius: 6px;
  border: 1px solid #ccc;
  background: #fff;
  color: #222;
  box-sizing: border-box;
}

.effects-time-sep {
  opacity: 0.8;
  font-size: 12px;
}

/* Remove button on each effect */
.effects-row-right {
  display: flex;
  justify-content: flex-end;
}

.effects-remove-btn {
  padding: 4px 10px;
  font-size: 12px;
  border-radius: 6px;
  border: 1px solid #d9534f;
  background: #f8d7da;
  color: #721c24;
  cursor: pointer;
}

.effects-remove-btn:hover {
  background: #f1b0b7;
}

/* Add-effect row + buttons */
.effects-add-row {
  margin-top: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.effects-add-btn {
  background: #3178c6;
  color: #fff;
  border: none;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
}

.effects-add-btn:hover {
  background: #275f9a;
}

/* Empty-state text */
.effects-empty {
  font-size: 13px;
  opacity: 0.85;
  line-height: 1.4;
}

/* Dark mode (mirror Help/Library dark styles) */
body.dark .effects-panel {
  background: #272727;
  border-left: 1px solid #333;
}

body.dark .effects-close-btn {
  color: #ccc;
}

body.dark .effects-close-btn:hover {
  background: #333;
}

body.dark .effects-panel-inner {
  color: #e4e4e4;
}

body.dark .effects-row {
  background: #333;
  border-color: #444;
}

body.dark .effects-time-input {
  background: #222;
  border-color: #555;
  color: #e4e4e4;
}

body.dark .effects-remove-btn {
  background: #7c1f28;
  border-color: #e57373;
  color: #ffe6e6;
}

body.dark .effects-remove-btn:hover {
  background: #a3323c;
}

body.dark .effects-add-btn {
  background: #3c6eb4;
}

body.dark .effects-add-btn:hover {
  background: #2a568e;
}

/* Library iframe content */
.library-frame {
  border: none;
  width: 100%;
  flex: 1;
}

/* Sticky tracks header */
.tracks-header {
  font-size: 20px;
  font-weight: bold;
  position: sticky;
  top: 0;
  background: #f3f3f3;
  padding: 4px 0;
  z-index: 30;
}

/* ───────────── GLOBAL TIMELINE ───────────── */
.global-timeline {
  position: sticky;
  top: 36px;
  background: #f3f3f3;
  padding: 10px 0 12px 0;
  margin-bottom: 14px;
  z-index: 40;
}

.global-timeline-bar {
  height: 24px;
  border-radius: 7px;
  position: relative;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  background:
    repeating-linear-gradient(
      to right,
      #d0d0d0 0px,
      #d0d0d0 1px,
      transparent 1px,
      transparent 10px
    ),
    #e3e3e3;
  overflow: visible;
  z-index: 30;
}

/* Moving playhead line */
.global-playhead {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--accent-color, #1e90ff);
  pointer-events: auto;
  cursor: ew-resize;
  transform: translateX(-50%);
  z-index: 3;
}

.global-timeline-bar-middle {
  position: absolute;
  top: 0;
  left: 50%;
  width: 2px;
  height: 24px;
  background: #bbb;
  transform: translateX(-50%);
}

.global-timeline-labels {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: #666;
}

.global-timeline-dot {
  position: absolute;
  top: 50%;
  width: 10px;
  height: 10px;

  background-color: var(--accent-color, #3178c6);

  /* Diamond shape */
  border-radius: 0;
  transform: translate(-50%, -50%) rotate(45deg);

  pointer-events: none;
}

/* Time bubble above playhead */
.timeline-tooltip {
  position: absolute;
  bottom: 100%;
  transform: translateX(-50%) translateY(-6px);
  padding: 2px 8px;
  font-size: 11px;
  line-height: 1.2;
  background: #111;
  color: #fff;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.4);
  white-space: nowrap;
  pointer-events: none;
  z-index: 999;
  box-shadow: 0 2px 6px rgba(0,0,0,0.6);
  opacity: 0.85;
}

body.dark .timeline-tooltip {
  background: #f5f5f5;
  color: #111;
}

/* FX region visuals */
.timeline-effect-region {
  position: absolute;
  top: 3px;
  bottom: 3px;
  border-radius: 6px;
  pointer-events: auto;
  cursor: grab;
}

/* Fade in: greenish */
.timeline-effect-region.fx-type-fade-in {
  background: rgba(46, 204, 113, 0.35);
  border: 1px solid rgba(46, 204, 113, 0.9);
}

/* Fade out: reddish */
.timeline-effect-region.fx-type-fade-out {
  background: rgba(231, 76, 60, 0.35);
  border: 1px solid rgba(231, 76, 60, 0.9);
}

/* Premium overlay */
.timeline-effect-region.premium {
  box-shadow: 0 0 6px rgba(241, 196, 15, 0.9);
}

/* FX handles inherit color where possible */
.timeline-effect-handle {
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  position: absolute;
  top: 50%;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  background: #3178c6;
  border: 2px solid #fff;
  cursor: ew-resize;
  box-shadow: 0 0 3px rgba(0,0,0,0.5);
}

.timeline-effect-handle.fx-type-fade-in {
  background: #27ae60;
}

.timeline-effect-handle.fx-type-fade-out {
  background: #c0392b;
}

/* Dark mode tweaks */
body.dark .timeline-effect-region.fx-type-fade-in {
  background: rgba(46, 204, 113, 0.45);
  border-color: rgba(46, 204, 113, 1);
}

body.dark .timeline-effect-region.fx-type-fade-out {
  background: rgba(231, 76, 60, 0.45);
  border-color: rgba(231, 76, 60, 1);
}

body.dark .timeline-effect-handle {
  border-color: #111;
}

/* ───────────── TRACK CARD ───────────── */
.track-card {
  background: #ffffff;
  border-radius: 12px;
  padding: 12px 16px;
  margin-bottom: 12px;
  border: 1px solid #ddd;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: box-shadow 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}

/* selected track glow */
.track-card.selected {
  box-shadow: none;
  outline: 1px solid var(--accent-color, #3fa9f5);
  outline-offset: 0;
}

body.dark .track-card.selected {
  border-color: #7bb0ff;
  box-shadow: none;
  transform: translateY(-1px);
}

.track-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}

/* left side: name + plugin button */
.track-top-left {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Right side of header (chip + minimize button) */
.track-top-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.track-name {
  font-size: 18px;
  font-weight: 600;
}

.track-name {
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.track-duration {
  font-size: 12px;
  opacity: 0.6;
  white-space: nowrap;
  font-weight: normal;
}

.chip {
  background: #ececec;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  color: #555;
}

.chip-collapse {
  background: #555;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
}

.track-controls {
  display: flex;
  align-items: flex-start;
  gap: 16px;
}

.track-main-controls {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.track-slider-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.slider-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.slider-row input[type="range"] {
  flex: 1;
}

.slider-value {
  min-width: 60px;
  text-align: right;
}

.track-button-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* plugin button reuses icon-button styling but a bit tighter */
.track-plugin-button {
  padding: 4px;
  min-width: auto;
}

.track-plugin-button .icon-svg {
  width: 18px;
  height: 18px;
}

/* Minimize / expand button */
button.track-minimize-btn {
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 999px;
  background: #666;
  color: #f5f5f5;
  border: 1px solid transparent;
  cursor: pointer;
}

button.track-minimize-btn:hover {
  background: #f5f5f5;
  border-color: #ccc;
}

/* When collapsed, hide everything but the header */
.track-card.collapsed {
  padding-bottom: 8px;
}

.track-card.collapsed .waveform-wrapper,
.track-card.collapsed .track-controls,
.track-card.collapsed .timeline-container {
  display: none;
}

/* Waveform */
.waveform-wrapper {
  margin-top: 6px;
}

.waveform-label {
  font-size: 12px;
  color: #666;
}

.waveform-canvas {
  width: 100%;
  height: 48px;
  background: #fafafa;
  border: 1px solid #ddd;
  border-radius: 6px;
}

/* Per-track timeline */
.timeline-container {
  margin-top: 8px;
}

.timeline-label-row {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  margin-bottom: 4px;
}

#globalTimelineBar {
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}

.timeline-track {
  height: 18px;
  border-radius: 9px;
  position: relative;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  background:
    repeating-linear-gradient(
      to right,
      #dcdcdc 0px,
      #dcdcdc 1px,
      transparent 1px,
      transparent 10px
    ),
    #eee;
}

.timeline-handle {
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  position: absolute;
  top: 50%;
  width: 14px;
  height: 14px;

  background: #3fa9f5;
  /*border: 2px solid #0b5ed7;*/

  /* Diamond shape */
  border-radius: 0;
  transform: translate(-50%, -50%) rotate(45deg);

  cursor: grab;
}

.timeline-handle:active {
  cursor: grabbing;
}

.timeline-handle:hover {
  box-shadow: 0 0 0 3px rgba(63, 169, 245, 0.25);
}

.timeline-track-scale {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  margin-top: 2px;
  color: #666;
}

/* Status bar */
.status-bar {
  padding: 8px 24px;
  background: #fafafa;
  border-top: 1px solid #ddd;
}

/* Loading overlay */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(255,255,255,0.75);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.hidden {
  display: none !important;
}

.spinner {
  border: 6px solid #ddd;
  border-top: 6px solid #3178c6;
  width: 45px;
  height: 45px;
  border-radius: 50%;
  animation: spin .9s linear infinite;
}

.loading-text {
  margin-top: 12px;
  font-size: 20px;
  font-weight: 600;
  color: #333;
  white-space: pre-line; /* turns \n into line breaks */
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.app-logo {
  width: auto;
  height: 50px;
  cursor: pointer;
}

/* Splash screen */
.splash-screen {
  position: fixed;
  inset: 0;
  background: #ffffff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  opacity: 0;
  animation: splashFadeIn 0.6s ease forwards;
}

.splash-logo {
  width: 240px;
  height: auto;
  margin-bottom: 20px;
  opacity: 0;
  animation:
    logoIntro 0.9s ease-out forwards,
    logoPulse 3.5s ease-in-out 1s infinite;
  transform-origin: center center;
}

.splash-loading {
  font-size: 22px;
  font-weight: 600;
  color: #333;
}

.splash-progress-wrap {
  width: 260px;
  height: 8px;
  border-radius: 999px;
  background: #e0e0e0;
  overflow: hidden;
  margin-top: 16px;
}

.splash-progress-bar {
  height: 100%;
  width: 0;
  background: #f2b632;
  animation: splashProgressFill 2.2s ease-out forwards;
}

.splash-tip {
  margin-top: 18px;
  max-width: 360px;
  text-align: center;
  font-size: 16px;
  color: #555;
}

.splash-fade-out {
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.6s ease;
}

@keyframes splashFadeIn {
  from { opacity: 0; transform: scale(0.98); }
  to   { opacity: 1; transform: scale(1); }
}

@keyframes splashProgressFill {
  from { width: 0; }
  to   { width: 100%; }
}

@keyframes logoIntro {
  0% {
    opacity: 0;
    transform: scale(0.7) rotate(-4deg);
  }
  60% {
    opacity: 1;
    transform: scale(1.05) rotate(1deg);
  }
  100% {
    opacity: 1;
    transform: scale(1) rotate(0deg);
  }
}

@keyframes logoPulse {
  0% {
    transform: scale(1) rotate(0deg);
  }
  50% {
    transform: scale(1.025) rotate(0.5deg);
  }
  100% {
    transform: scale(1) rotate(0deg);
  }
}

/* ───────────── DARK MODE ───────────── */
body.dark {
  background: #1c1c1c;
  color: #e4e4e4;
}

body.dark .top-bar {
  background: #222;
  border-bottom: 1px solid #333;
}

body.dark .tracks-panel {
  background: #1c1c1c;
}

body.dark .tracks-header {
  background: #1f1f1f;
  color: #e4e4e4;
  border-bottom: 1px solid #333;
  z-index: 30;
}

body.dark .global-timeline {
  background: #1c1c1c;
}

body.dark .global-timeline-bar {
  background:
    repeating-linear-gradient(
      to right,
      #555 0px,
      #555 1px,
      transparent 1px,
      transparent 10px
    ),
    #333;
}

body.dark .global-timeline-bar-middle {
  background: #777;
}

body.dark .global-playhead {
  background: #ffcc66;
}

body.dark .timeline-track {
  background:
    repeating-linear-gradient(
      to right,
      #555 0px,
      #555 1px,
      transparent 1px,
      transparent 10px
    ),
    #444;
}

body.dark .track-card {
  background: #2a2a2a;
  border-color: #444;
}

body.dark .track-minimize-btn {
  background: transparent;
  color: #ddd;
  border-color: transparent;
}

body.dark .track-minimize-btn:hover {
  background: #333;
  border-color: #555;
}

body.dark input[type="range"] {
  filter: brightness(0.8);
}

body.dark .timeline-handle {
  background: #4c8be8;
}

body.dark button {
  background: #3c6eb4;
}

body.dark button.secondary {
  background: #555;
}

body.dark .darkmode-button {
  background: #555;
}

body.dark .darkmode-button:hover {
  background: #666;
}

body.dark .kebab-toggle {
  color: #fff;
}

body.dark .kebab-menu {
  background: #333;
  color: #e4e4e4;
}

body.dark .kebab-item:hover {
  background: #444;
}

body.dark .status-bar {
  background: #242424;
  border-top: 1px solid #333;
}

body.dark .loading-overlay {
  background: rgba(0,0,0,0.65);
}

body.dark .loading-text {
  color: #eaeaea;
}

/* Help + Library panel dark mode */
body.dark .help-panel,
body.dark .library-panel {
  background: #272727;
  border-left: 1px solid #333;
}

body.dark .help-close-btn,
body.dark .library-close-btn {
  color: #ccc;
}

body.dark .help-close-btn:hover,
body.dark .library-close-btn:hover {
  background: #333;
}

body.dark .help-body {
  color: #e4e4e4;
}

/* Splash dark overrides */
body.dark .splash-screen {
  background: #1c1c1c;
}

body.dark .splash-loading {
  color: #f5f5f5;
}

body.dark .splash-tip {
  color: #cfcfcf;
}

body.dark .splash-progress-wrap {
  background: #333;
}

#helpBody a {
  color: #ffd684 !important;
  text-decoration: underline;
}

/* (track-top and track-top-left already defined above; keeping here
   in case of earlier duplication in your original file) */
.track-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* left side: name + plugin button */
.track-top-left {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* plugin button reuses icon-button styling but a bit tighter */
.track-plugin-button {
  padding: 4px;
  min-width: auto;
}

.track-plugin-button .icon-svg {
  width: 18px;
  height: 18px;
}

/* ───────────── FLOATING HELP BUTTON ───────────── */
.floating-help-btn {
  position: fixed;
  bottom: 22px;
  right: 22px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: #3178c6;
  color: #fff;
  font-size: 28px;
  border: none;
  box-shadow: 0 4px 14px rgba(0,0,0,0.25);
  cursor: pointer;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: 0.15s ease;
}

.floating-help-btn:hover {
  background: #1f5fa0;
  transform: scale(1.07);
}

body.dark .floating-help-btn {
  background: #1f5fa0;
}

body.dark .floating-help-btn:hover {
  background: #174a7c;
}

.help-search-container {
  padding: 8px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.help-search-input {
  width: 100%;
  padding: 6px 8px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: #111;
  color: #fff;
  font-size: 13px;
  box-sizing: border-box;
}

.help-search-status {
  margin-top: 4px;
  font-size: 11px;
  opacity: 0.7;
}

.help-search-results {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.help-search-result {
  width: 100%;
  text-align: left;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(0, 0, 0, 0.3);
  cursor: pointer;
}

.help-search-result:hover {
  background: rgba(255, 255, 255, 0.05);
}

.help-search-result-title {
  font-weight: 600;
  margin-bottom: 2px;
}

.help-search-result-snippet {
  font-size: 12px;
  opacity: 0.85;
}

.top-title {
  font-size: 24px;
  font-weight: bold;
}

.top-subtitle {
  font-size: 14px;
  color: #555;
}

/* ───────────── ADD SOUND DROPDOWN ───────────── */
/* Reuse kebab menu look, but with its own toggle/open logic */

.add-sound-wrapper {
  position: relative;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  display: inline-flex;
  align-items: stretch;
}

/* Make the Add Sound button visually similar to the kebab toggle */
.add-sound-toggle {
  background: #2ecc71 !important; /*transparent*/
  border: none;
  border-radius: 6px;
  cursor: pointer;
  color: #666;
  font-size: 16px;
  padding: 6px 12px;
  display: flex;               /* align icon + text horizontally */
  align-items: center;         /* vertical center */
  gap: 6px;                    /* spacing between text and icon */
}

.add-sound-toggle:hover {
  color: #333;
}

.add-sound-toggle i {
  font-size: 28px;
  line-height: 1;
}

/* Use kebab-menu for the card style; just position it under the button */
.add-sound-menu {
  top: 110%;
  right: 0;
  left: auto;
}

/* When wrapper has .open (set by JS), show the dropdown */
.add-sound-wrapper.open .kebab-menu {
  display: flex;
  flex-direction: column;
}

/* Items already use .kebab-item; this just ensures full width */
.add-sound-menu-item {
  width: 100%;
  background: none;
}

/* Dark mode dropdown tweaks */
body.dark .add-sound-toggle {
  color: #fff;
}

/* ───────────── ABOUT MODAL ───────────── */

.modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10050;
}

.modal.hidden {
  display: none !important;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(3px);
}

.modal-content {
  position: relative;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  width: 400px;
  max-width: 90%;
  height: 520px;
  background: transparent;
  border-radius: 12px;
  overflow: hidden;
  z-index: 2;
  display: flex;
  flex-direction: column;
}

.modal-iframe {
  border: none;
  width: 100%;
  height: 100%;
  background: transparent;
}

.modal-close-btn {
  position: absolute;
  top: 6px;
  right: 10px;
  z-index: 3;
  font-size: 20px;
  color: #fff;
  background: transparent;
  border: none;
  cursor: pointer;
}

.modal-close-btn:hover {
  color: #ffd684;
}

/* Play/Pause Button Visual States */
#btnPlay.play-mode {
  background: #3c6eb4 !important;   /* Green (Play) */
}

#btnPlay.pause-mode {
  background: #f2b632 !important;   /* Blue (Pause) */
}

button:disabled {
  opacity: 0.6;
  cursor: default;
}

.sounds-list li {
  display: flex;
  align-items: center;
  padding: 6px 10px;
  font-size: 13px;
  border-bottom: 1px solid #262626;
  position: relative;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  /* NEW – row layout */
  justify-content: flex-start;
}

/* Name stays left but allows meta to center */
.sound-name {
  flex: 1;
}

/* NEW — meta block becomes centered region */
.sound-meta {
  flex: 1;
  display: flex;
  justify-content: center;   /* centers inside its column */
  align-items: center;
  gap: 6px;
  font-size: 12px;
}

/* Load button stays on right */
.load-btn {
  margin-left: auto;  /* push it to far right */
}

.premium-star {
  font-size: 14px;
  color: gold;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* Premium star placed at top-right */
.premium-star-badge {
  position: absolute;
  top: 4px;
  right: 6px;
  font-size: 15px;
  color: gold;
  pointer-events: none;
  opacity: 0.95;
}

/* Plain FX icon next to track name */
.track-fx-icon {
  /*width: 26px;*/
  height: 26px;
  margin-left: 4px;
  cursor: pointer;
  display: block;
  background: none;
}

body.dark .track-fx-icon {
  filter: brightness(1.1);
}

/* Ensure name + FX are on one row */
.track-top-left {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* FX wrapper sits inline next to the name, menu anchored to it */
.track-fx-wrap {
  position: relative;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  display: flex;
  align-items: center;
}

/* Plain FX icon */
.track-fx-icon {
  /*width: 22px;*/
  height: 20px;
  display: block;
  cursor: pointer;
}

/* Small dropdown under the icon */
.track-fx-menu {
  position: absolute;
  top: 120%;
  right: 0;
  background: #ffffff;
  border-radius: 6px;
  box-shadow: 0 4px 10px rgba(0,0,0,0.2);
  padding: 4px 0;
  display: flex;
  flex-direction: column;
  z-index: 60;
}

.track-fx-menu-item {
  padding: 6px 12px;
  font-size: 13px;
  background: transparent;
  border: none;
  text-align: left;
  cursor: pointer;
  white-space: nowrap;
}

.track-fx-menu-item:hover {
  background: #f0f0f0;
}

/* Dark mode for FX dropdown */
body.dark .track-fx-menu {
  background: #333;
  color: #eee;
}

body.dark .track-fx-menu-item:hover {
  background: #444;
}

/* ────────────────────────────────────────────── */
/* MOBILE-FIRST LAYOUT OVERRIDES (phones/tablets) */
/* ────────────────────────────────────────────── */
@media (max-width: 768px) {

  /* App container – let it scroll naturally */
  .app {
    height: auto;
    min-height: 100vh;
  }

  /* Top bar stacks, but we visually keep the hamburger beside the title */
  .top-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    padding: 12px 12px 10px;
    position: relative; /* anchor for absolute-positioned hamburger */
  }

  /* First row: logo + title/subtitle (with room for hamburger on right) */
  .top-left {
    width: 100%;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    padding-right: 52px; /* avoid title under the hamburger */
  }

  .app-logo {
    order: 0;
    height: 40px;
  }

  /* Title/subtitle container flexes in the middle */
  .top-left > div {
    order: 1;
    flex: 1 1 auto;
    min-width: 0;
  }

  .top-title {
    font-size: 20px;
  }

  .top-subtitle {
    font-size: 12px;
  }

  /* Second row inside top-left: Add Sound + transport controls (inline row) */
  .top-left > .add-sound-wrapper,
  .top-left > #btnPlay,
  .top-left > #btnStop,
  .top-left > #btnRecord,
  .top-left > .time-display {
    order: 2;          /* below the title row, but all together */
    flex-basis: auto;  /* don't stretch to full width */
  }

  /* Hamburger: visually beside the title at the top-right */
  .kebab-dropdown {
    position: absolute;
    top: 12px;
    right: 12px;
  }

  /* Slightly smaller controls on mobile */
  button {
    font-size: 16px;
    padding: 8px 12px;
  }

  .icon-button.record {
    width: 38px;
    height: 38px;
  }

  .time-display {
    font-size: 16px;
    min-width: auto;
  }

  /* Master section row under the header */
  .top-right {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: nowrap;
    gap: 8px;
  }

  .master-section {
    width: auto;
    flex: 1 1 auto;
    min-width: 0;
  }

  .master-volume {
    width: 100%;
    justify-content: space-between;
  }

  .master-volume input[type="range"] {
    flex: 1;
    max-width: none;
  }

  .master-vu .vu-bar {
    width: 100%;
    max-width: 220px;
  }

  /* Main content: stack everything vertically */
  .content {
    flex-direction: column;
  }

  .tracks-panel {
    padding: 8px 12px 88px; /* extra bottom space for status bar */
  }

  .tracks-header {
    top: 0;
  }

  .global-timeline {
    top: 32px;
  }

  /* Track cards a bit tighter */
  .track-card {
    padding: 10px 12px;
    margin-bottom: 10px;
  }

  .track-name {
    font-size: 16px;
  }

  .track-top {
    gap: 6px;
  }

  .track-controls {
    flex-direction: column;
    gap: 10px;
  }

  .track-button-group {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 6px;
  }

  .waveform-canvas {
    height: 40px;
  }

  /* Help / Library / Effects: full-screen offcanvas on mobile */
  .help-panel,
  .library-panel,
  .effects-panel {
    position: fixed;
    inset: 0;                     /* top:0 right:0 bottom:0 left:0 */
    box-sizing: border-box;       /* padding stays inside viewport width */
    width: auto;
    max-width: none;
    height: auto;
    max-height: none;

    border: none;
    box-shadow: none;

    padding: 10px 12px 12px;      /* safe inner padding */
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;

    transform: translateY(100%);  /* slide up from bottom */
    transition: transform 0.25s ease-out, opacity 0.25s ease-out;
    opacity: 0;
    pointer-events: none;
    z-index: 9998;
  }

  /* When JS removes .hidden, panels slide fully up into view */
  .help-panel:not(.hidden),
  .library-panel:not(.hidden),
  .effects-panel:not(.hidden) {
    transform: translateY(0);
    opacity: 1;
    pointer-events: auto;
  }



  .help-header,
  .library-header,
  .effects-header {
    margin-bottom: 6px;
  }

  .help-title,
  .library-title,
  .effects-title {
    font-size: 16px;
  }

  .help-body,
  .effects-body {
    max-height: none;
    flex: 1;
  }

  .library-frame {
    flex: 1;
    height: 100%;
  }

  /* Status bar sticks to bottom, like a mini transport hint */
  .status-bar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 6px 10px;
    font-size: 12px;
    z-index: 9000;
  }

  /* Floating help button moves up so it doesn’t overlap the status bar */
  .floating-help-btn {
    bottom: 76px; /* just above the status bar */
    right: 16px;
    width: 48px;
    height: 48px;
    font-size: 24px;
  }
}

/* Dark-mode tweaks for mobile bottom sheets */
@media (max-width: 768px) {
  body.dark .help-panel,
  body.dark .library-panel,
  body.dark .effects-panel {
    border-top-color: #333;
    box-shadow: 0 -8px 24px rgba(0,0,0,0.7);
  }
}

.global-timeline-dots-host { pointer-events: none; }

/* ================== GLOBAL TIMELINE MARKERS ================== */
.global-timeline-dots-host {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  bottom: 0;
  pointer-events: none;
  z-index: 4;
}

.global-dot {
  --dot-color: #ccc;
  position: absolute;
  left: 0;
  pointer-events: none;
  box-sizing: border-box;
}

/* Start marker – solid diamond */
.global-dot-start {
  top: 50%;
  width: 10px;
  height: 10px;
  background: var(--dot-color);
  transform: translate(-50%, -50%) rotate(45deg);
  opacity: 0.95;
}

/* End marker – hollow diamond */
.global-dot-end {
  top: 50%;
  width: 10px;
  height: 10px;
  background: transparent;
  border: 2px solid var(--dot-color);
  transform: translate(-50%, -50%) rotate(45deg);
  opacity: 0.75;
}

/* FX markers */
.global-dot-fx {
  width: 8px;
  height: 8px;
  background: var(--dot-color);
  transform: translate(-50%, -50%);
}

.global-dot-fx-start {
  top: 15%;
  opacity: 0.55;
}

.global-dot-fx-end {
  top: 85%;
  opacity: 0.35;
}


/* Undo/Redo buttons (toolbar) */
button.icon-button.secondary {
  padding: 8px 10px;
}
body.dark button.secondary.icon-button {
  background: #3a3a3a;
}
body.dark button.secondary.icon-button:hover:not(:disabled) {
  background: #4a4a4a;
}


/* Track-level Undo/Redo buttons */
.track-undo-redo {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  margin-right: 8px;
}

.track-undo-redo .btn-mini {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 8px;
}

.track-undo-redo .btn-mini svg {
  width: 16px;
  height: 16px;
  fill: #fff;
}

button.btn-mini.secondary {
  background: #666;
}

body.dark button.btn-mini.secondary {
  background: #3a3a3a;
}

body.dark button.btn-mini.secondary:hover:not(:disabled) {
  background: #4a4a4a;
}


/* Tablet/touch: allow precise drag selection on waveforms without page scrolling */
.track-waveform-canvas,
.waveform-canvas,
canvas.track-waveform,
canvas[data-waveform],
canvas.waveform {
  touch-action: none;
}

/* Per-track Zoom + View Window Bar */
.track-zoom-wrap {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-left: 10px;
}

.track-zoom-label {
  font-size: 12px;
  opacity: 0.85;
}

.track-zoom-slider {
  width: 140px;
}

.track-zoom-value {
  font-size: 12px;
  opacity: 0.9;
  min-width: 34px;
  text-align: right;
}

.track-viewbar {
  position: relative;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  height: 10px;
  margin-top: 8px;
  background: rgba(255,255,255,0.12);
  border-radius: 6px;
  overflow: hidden;
}

.track-viewhandle {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 100%;
  background: rgba(255,255,255,0.35);
  border: 1px solid rgba(255,255,255,0.55);
  border-radius: 6px;
  cursor: grab;
  box-sizing: border-box;
}

.track-viewhandle:active {
  cursor: grabbing;
}

body.dark .track-viewbar {
  background: rgba(255,255,255,0.10);
}
body.dark .track-viewhandle {
  background: rgba(255,255,255,0.28);
  border-color: rgba(255,255,255,0.45);
}

/* Zoom reset button */
.track-zoom-reset {
  padding: 4px 8px;
  font-size: 12px;
  border-radius: 8px;
}

.waveform-canvas { cursor: crosshair; }

/* ---------- Zoom toggle button (all screen sizes) ---------- */
.track-zoom-toggle-btn {
  display: inline-flex;
  align-items: center;
}

/* Hide full zoom controls when zoom is collapsed */
.track-card:not(.zoom-open) .track-zoom-wrap {
  display: none !important;
}

/* When zoom is open, show controls.
   On small screens they should drop below; on larger screens they can stay inline. */
.track-card.zoom-open .track-zoom-wrap {
  display: flex !important;
}

@media (max-width: 640px) {
  /* Allow zoom controls to drop below the header row on phones */
  .track-top-right { flex-wrap: wrap; }

  .track-card.zoom-open .track-zoom-wrap {
    flex-basis: 100%;
    width: 100%;
    margin-top: 8px;
  }
}

.track-zoom-wrap input[type="range"] {
  width: 150px; /* 50px shorter */
}

/* iOS-friendly hidden file input */
.file-input-hidden {
  position: fixed;
  left: -9999px;
  top: 0;
  width: 1px;
  height: 1px;
  opacity: 0;
}

/* ===== FORCE EFFECT LAYOUT FIX ===== */

.effect-row {
  display: block !important;
}

.effect-main {
  display: block !important;
}

.effect-actions {
  display: block !important;
  margin-top: 6px;
  text-align: right;
}

/* Prevent inline layout conflicts */
.effect-row * {
  box-sizing: border-box;
}

/* Stack inputs cleanly */
.fade-times,
.fade-db {
  display: flex;
  gap: 6px;
  margin-top: 4px;
  flex-wrap: wrap;
}

/* Remove button styling */
.remove-effect {
  background: #8b1e1e;
  color: #fff;
  border: none;
  padding: 4px 10px;
  border-radius: 4px;
  cursor: pointer;
}

.remove-effect:hover {
  background: #a83232;
}

.effects-row {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 10px;
  align-items: start;
}

.effects-middle-cell {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.effects-timing,
.effects-params {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.effects-remove-wrap {
  display: flex;
  justify-content: flex-end;
  margin-top: 4px;
}

.effects-remove-btn {
  align-self: flex-end;
}

@media (max-width: 640px) {
  .effects-row {
    grid-template-columns: 1fr;
  }

  .effects-remove-wrap {
    justify-content: flex-start;
  }
}

/* Effects panel track timeline hint */
.effects-track-hint {
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 6px;
  background: #eef4ff;
  border: 1px solid #c9d8ff;
  color: #1f3a75;
}

body.dark .effects-track-hint {
  background: #1f2a44;
  border-color: #3c4f7a;
  color: #dbe6ff;
}

.track-zoom-reset.active {
  background: #1e90ff;   /* blue */
  color: #fff;
}

/* Hide track Effects + Zoom controls on mobile only */
@media (max-width: 768px) {
  .track-fx-wrap,
  .track-fx-icon,
  .track-zoom-wrap,
  .track-zoom-toggle-btn {
    display: none !important;
  }
}