/* =========================================================================
   Audio Review — Liquid Glass design system
   ========================================================================= */
:root {
  --bg-0: #06060c;
  --bg-1: #0d0b1a;

  --text: #f4f3fb;
  --text-dim: #b9b7cd;
  --text-faint: #817f99;

  --accent: #8b7bff;
  --accent-2: #3ad6c5;
  --accent-3: #ff7eb6;
  --warn: #ff6b6b;

  /* Glass surface tokens */
  --glass-bg: rgba(255, 255, 255, 0.07);
  --glass-bg-strong: rgba(255, 255, 255, 0.11);
  --glass-brd: rgba(255, 255, 255, 0.16);
  --glass-hi: rgba(255, 255, 255, 0.45);
  --glass-shadow: 0 14px 40px -12px rgba(0, 0, 0, 0.55);

  --radius: 26px;
  --radius-sm: 16px;
  --radius-xs: 12px;

  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --spring: cubic-bezier(0.34, 1.56, 0.64, 1);

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* Light theme — opt-in via data-theme="light" on <html>. */
:root[data-theme="light"] {
  --bg-0: #eceef6;
  --bg-1: #dde1ef;

  --text: #1a1830;
  --text-dim: #45435c;
  --text-faint: #6d6b85;

  --accent: #6f5cff;
  --accent-2: #15a294;
  --accent-3: #e6589b;
  --warn: #d63b3b;

  --glass-bg: rgba(255, 255, 255, 0.55);
  --glass-bg-strong: rgba(255, 255, 255, 0.8);
  --glass-brd: rgba(20, 20, 50, 0.12);
  --glass-hi: rgba(255, 255, 255, 0.9);
  --glass-shadow: 0 14px 40px -12px rgba(40, 40, 80, 0.22);
}
:root[data-theme="light"] .bg {
  background:
    radial-gradient(120% 120% at 80% -10%, #d8d1ff 0%, transparent 55%),
    radial-gradient(120% 120% at -10% 100%, #cdeee8 0%, transparent 55%),
    linear-gradient(160deg, var(--bg-1), var(--bg-0));
}
:root[data-theme="light"] .blob { opacity: 0.35; }
:root[data-theme="light"] .hero h1 {
  background: linear-gradient(120deg, #3a2f8f, #6f5cff 55%, #138c80);
  -webkit-background-clip: text; background-clip: text;
}
/* dark inputs/surfaces → light translucent in light mode */
:root[data-theme="light"] .field,
:root[data-theme="light"] .slug-row,
:root[data-theme="light"] .card-share { background: rgba(255, 255, 255, 0.72); }
:root[data-theme="light"] .tabs,
:root[data-theme="light"] .seg { background: rgba(20, 18, 40, 0.06); }
/* keep the waveform panel dark so the light-coloured wave stays legible */
:root[data-theme="light"] .wave-wrap {
  background: rgba(18, 16, 38, 0.92); border-color: rgba(18, 16, 38, 0.25); }
:root[data-theme="light"] .list::-webkit-scrollbar-thumb { background: rgba(20, 18, 40, 0.22); }

* { box-sizing: border-box; }
html, body { height: 100%; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI",
    Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
  background: var(--bg-0);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
  letter-spacing: 0.1px;
}

/* ----------------------------------------------------------------- bg ---- */
.bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  background:
    radial-gradient(120% 120% at 80% -10%, #1a1340 0%, transparent 55%),
    radial-gradient(120% 120% at -10% 100%, #102a35 0%, transparent 55%),
    linear-gradient(160deg, var(--bg-1), var(--bg-0));
}
.blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(70px);
  opacity: 0.55;
  will-change: transform;
}
.blob-1 { width: 46vmax; height: 46vmax; left: -10vmax; top: -12vmax;
  background: radial-gradient(circle, #7a5cff, transparent 70%);
  animation: drift1 26s var(--ease) infinite alternate; }
.blob-2 { width: 40vmax; height: 40vmax; right: -8vmax; top: 6vmax;
  background: radial-gradient(circle, #ff5fa2, transparent 70%);
  animation: drift2 32s var(--ease) infinite alternate; }
.blob-3 { width: 42vmax; height: 42vmax; left: 12vmax; bottom: -16vmax;
  background: radial-gradient(circle, #25d8c3, transparent 70%);
  animation: drift3 30s var(--ease) infinite alternate; }
.blob-4 { width: 30vmax; height: 30vmax; right: 6vmax; bottom: -6vmax;
  background: radial-gradient(circle, #4f7bff, transparent 70%);
  animation: drift1 36s var(--ease) infinite alternate-reverse; }
.noise {
  position: absolute; inset: -50%;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.4'/%3E%3C/svg%3E");
  opacity: 0.035;
  mix-blend-mode: overlay;
}
@keyframes drift1 { to { transform: translate3d(6vmax, 5vmax, 0) scale(1.15); } }
@keyframes drift2 { to { transform: translate3d(-7vmax, 6vmax, 0) scale(1.1); } }
@keyframes drift3 { to { transform: translate3d(5vmax, -6vmax, 0) scale(1.2); } }

/* --------------------------------------------------------------- layout -- */
.app {
  max-width: 1180px;
  margin: 0 auto;
  padding: calc(20px + var(--safe-top)) 20px calc(40px + var(--safe-bottom));
  min-height: 100%;
}
.view { animation: viewIn 0.5s var(--ease) both; }
@keyframes viewIn {
  from { opacity: 0; transform: translateY(14px) scale(0.99); }
  to   { opacity: 1; transform: none; }
}

/* ---------------------------------------------------------------- glass -- */
.glass {
  position: relative;
  background: var(--glass-bg);
  border: 1px solid var(--glass-brd);
  border-radius: var(--radius);
  backdrop-filter: blur(26px) saturate(165%);
  -webkit-backdrop-filter: blur(26px) saturate(165%);
  box-shadow: var(--glass-shadow), inset 0 1px 0 0 var(--glass-hi);
  overflow: hidden;
}
/* specular sheen across the top edge */
.glass::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.14) 0%,
    rgba(255, 255, 255, 0.02) 22%,
    transparent 45%
  );
  pointer-events: none;
}

/* --------------------------------------------------------------- header -- */
.topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 26px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 700;
  font-size: 19px;
  letter-spacing: 0.2px;
  cursor: pointer;
  user-select: none;
}
.brand .logo {
  width: 38px; height: 38px;
  display: grid; place-items: center;
  border-radius: 12px;
  font-size: 20px;
  background: linear-gradient(135deg, var(--accent), var(--accent-3));
  box-shadow: 0 6px 18px -4px rgba(139, 123, 255, 0.6),
    inset 0 1px 0 rgba(255, 255, 255, 0.5);
}
.brand .sub { color: var(--text-faint); font-weight: 500; font-size: 12px; }
.spacer { flex: 1; }

/* --------------------------------------------------------------- button -- */
.btn {
  appearance: none;
  border: 1px solid var(--glass-brd);
  background: var(--glass-bg-strong);
  color: var(--text);
  border-radius: 999px;
  padding: 11px 18px;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  backdrop-filter: blur(14px) saturate(160%);
  -webkit-backdrop-filter: blur(14px) saturate(160%);
  box-shadow: inset 0 1px 0 var(--glass-hi);
  transition: transform 0.25s var(--spring), background 0.25s var(--ease),
    box-shadow 0.25s var(--ease), opacity 0.25s var(--ease);
  -webkit-tap-highlight-color: transparent;
  white-space: nowrap;
}
a.btn { text-decoration: none; }
.btn:hover { background: rgba(255, 255, 255, 0.16); transform: translateY(-1px); }
.btn:active { transform: translateY(0) scale(0.96); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }
.btn.primary {
  background: linear-gradient(135deg, var(--accent), #6f5cff);
  border-color: rgba(255, 255, 255, 0.35);
  box-shadow: 0 10px 26px -8px rgba(111, 92, 255, 0.7),
    inset 0 1px 0 rgba(255, 255, 255, 0.6);
}
.btn.primary:hover { background: linear-gradient(135deg, #9a8bff, #7a68ff); }
.btn.ghost { background: transparent; border-color: transparent; box-shadow: none; }
.btn.ghost:hover { background: var(--glass-bg); }
.btn.icon {
  padding: 10px;
  border-radius: 50%;
  line-height: 1;
  justify-content: center;
}
.btn.sm { padding: 8px 13px; font-size: 13px; }
.btn.danger { color: #ffd5d5; }
.btn.danger:hover { background: rgba(255, 107, 107, 0.18); }

/* ----------------------------------------------------------- library ----- */
.hero {
  padding: 30px;
  margin-bottom: 26px;
  display: grid;
  gap: 20px;
}
.hero h1 {
  margin: 0;
  font-size: clamp(26px, 5vw, 40px);
  line-height: 1.05;
  letter-spacing: -0.5px;
  font-weight: 800;
  background: linear-gradient(120deg, #fff, #c9c2ff 55%, #a8f0e6);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
}
.hero p { margin: 0; color: var(--text-dim); font-size: 15px; max-width: 56ch; }

/* drop / upload zone */
.drop {
  border: 1.5px dashed rgba(255, 255, 255, 0.25);
  border-radius: var(--radius-sm);
  padding: 26px;
  text-align: center;
  display: grid;
  gap: 10px;
  justify-items: center;
  transition: border-color 0.25s var(--ease), background 0.25s var(--ease),
    transform 0.25s var(--spring);
  cursor: pointer;
}
.drop:hover { border-color: var(--accent); background: rgba(139, 123, 255, 0.08); }
.drop.drag { border-color: var(--accent-2); background: rgba(58, 214, 197, 0.12);
  transform: scale(1.01); }
.drop .ico { font-size: 30px; }
.drop strong { font-size: 15px; }
.drop small { color: var(--text-faint); }
.drop input { display: none; }

/* uploading progress */
.uprow {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 16px; border-radius: var(--radius-sm);
  background: var(--glass-bg); border: 1px solid var(--glass-brd);
}
.bar { flex: 1; height: 7px; border-radius: 999px; background: rgba(255,255,255,0.12);
  overflow: hidden; }
.bar > i { display: block; height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width 0.2s linear; }

/* upload composer (single file → pick a share link) */
.up-card { padding: 18px; display: grid; gap: 10px;
  animation: itemIn 0.4s var(--ease) both; }
.up-file { display: flex; align-items: center; gap: 10px; font-size: 14px;
  padding-bottom: 4px; }
.up-file .up-name { font-weight: 600; flex: 1; min-width: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.up-file .up-size { color: var(--text-faint); font-size: 12.5px; }
.up-label { font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.8px;
  color: var(--text-faint); font-weight: 700; margin-top: 2px; }
.slug-row { display: flex; align-items: stretch;
  border: 1px solid var(--glass-brd); border-radius: var(--radius-xs);
  background: rgba(0,0,0,0.25); overflow: hidden;
  transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease); }
.slug-row:focus-within { border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(139,123,255,0.25); }
.slug-prefix { display: flex; align-items: center; padding: 0 4px 0 13px;
  color: var(--text-faint); font-size: 13.5px; white-space: nowrap;
  font-variant-numeric: tabular-nums; }
.slug-row .field { border: none; background: transparent; border-radius: 0;
  padding-left: 2px; flex: 1; min-width: 0; }
.slug-row .field:focus { box-shadow: none; }
.slug-status { font-size: 12.5px; font-weight: 600; min-height: 16px;
  color: var(--text-faint); }
.slug-status.ok { color: var(--accent-2); }
.slug-status.err { color: var(--warn); }
.slug-status.warn { color: #ffb454; }
.up-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 4px;
  flex-wrap: wrap; }
.up-success { display: flex; align-items: center; gap: 12px; }
.up-success .ok-ico { width: 38px; height: 38px; flex: none; border-radius: 50%;
  display: grid; place-items: center; font-weight: 800; color: #042;
  background: linear-gradient(135deg, var(--accent-2), #2bb6a8);
  box-shadow: 0 6px 18px -5px rgba(58,214,197,0.7); }
.up-success .muted { color: var(--text-faint); font-size: 13px; }
.link-row { display: flex; gap: 8px; flex-wrap: wrap; }
.link-row .field { flex: 1; min-width: 160px; font-size: 13px;
  color: var(--accent-2); font-weight: 600; }

/* track grid */
.section-title {
  display: flex; align-items: baseline; gap: 10px;
  margin: 4px 4px 14px;
}
.section-title h2 { margin: 0; font-size: 16px; font-weight: 700; }
.section-title span { color: var(--text-faint); font-size: 13px; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(265px, 1fr));
  gap: 16px;
}
.card {
  padding: 18px;
  cursor: pointer;
  transition: transform 0.35s var(--spring), box-shadow 0.35s var(--ease);
  display: grid; gap: 14px;
}
.card:hover { transform: translateY(-4px); }
.card .mini {
  height: 54px; display: flex; align-items: center; gap: 2px;
  border-radius: 10px; overflow: hidden;
}
.card .mini i {
  flex: 1; background: linear-gradient(180deg, var(--accent), var(--accent-2));
  border-radius: 2px; opacity: 0.85;
  transform-origin: center;
  animation: pulseBar 2.2s var(--ease) infinite;
}
@keyframes pulseBar { 0%,100% { transform: scaleY(0.55); } 50% { transform: scaleY(1); } }
.card h3 { margin: 0; font-size: 16px; font-weight: 700;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-share { display: flex; align-items: center; gap: 8px; font-size: 12.5px;
  color: var(--text-dim); padding: 8px 11px; border-radius: 9px;
  background: rgba(0,0,0,0.22); border: 1px solid var(--glass-brd);
  transition: background 0.2s var(--ease), border-color 0.2s var(--ease); }
.card-share:hover { background: rgba(139,123,255,0.16); border-color: var(--accent); }
.card-share .lnk { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden;
  text-overflow: ellipsis; font-variant-numeric: tabular-nums; }
.card-share .copyhint { color: var(--text-faint); font-weight: 600; font-size: 11.5px; }
.card-share:hover .copyhint { color: var(--accent); }
.card .meta { display: flex; gap: 14px; color: var(--text-faint); font-size: 12.5px; }
.card .meta b { color: var(--text-dim); font-weight: 600; }
.card .chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  font-size: 11.5px; padding: 4px 10px; border-radius: 999px;
  background: rgba(255,255,255,0.08); border: 1px solid var(--glass-brd);
  color: var(--text-dim); display: inline-flex; gap: 5px; align-items: center;
}

.empty {
  text-align: center; padding: 50px 20px; color: var(--text-faint);
  display: grid; gap: 8px; justify-items: center;
}
.empty .ico { font-size: 40px; opacity: 0.7; }

/* ============================================================= PLAYER ==== */
.player { display: grid; gap: 18px; min-width: 0; }
@media (min-width: 920px) {
  .player { grid-template-columns: minmax(0, 1fr) 360px; align-items: start; }
  .player .stage { grid-column: 1; }
  .player .side { grid-column: 2; grid-row: 1 / span 3; position: sticky; top: 16px; }
}

.stage { padding: 22px; display: grid; gap: 18px; min-width: 0; }
.stage > *, .side, .panel { min-width: 0; max-width: 100%; }
.track-head { display: flex; align-items: center; gap: 12px; }
.track-head h2 {
  margin: 0; font-size: clamp(18px, 3vw, 24px); font-weight: 800;
  letter-spacing: -0.3px; flex: 1; min-width: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.track-head .editbtn { opacity: 0.6; }
.track-head .editbtn:hover { opacity: 1; }
.track-head .btn.icon {
  width: 38px; height: 38px; padding: 0; flex-shrink: 0;
}
.shared-tag { font-size: 12.5px; font-weight: 700; color: var(--accent-2);
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 11px; border-radius: 999px;
  background: rgba(58,214,197,0.12); border: 1px solid rgba(58,214,197,0.4); }

/* share-link bar */
.sharebar { display: flex; align-items: center; gap: 9px; flex-wrap: wrap;
  padding: 10px 12px; border-radius: var(--radius-sm);
  background: rgba(0,0,0,0.22); border: 1px solid var(--glass-brd); }
.sharebar .lbl { font-size: 12.5px; font-weight: 700; color: var(--text-dim);
  white-space: nowrap; }
.sharebar .field { flex: 1; min-width: 150px; font-size: 13px; padding: 9px 12px;
  color: var(--accent-2); font-weight: 600; font-variant-numeric: tabular-nums; }

/* waveform + overlays */
.wave-wrap {
  position: relative;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow: hidden;
  border-radius: var(--radius-sm);
  background: rgba(0, 0, 0, 0.22);
  border: 1px solid var(--glass-brd);
  padding: 14px 12px 12px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.08);
  touch-action: pan-y;
}
.wave-wrap.selecting { cursor: crosshair; }
.wave-wrap.selecting #waveform ::part(region) { cursor: crosshair; }
/* once zoomed, the wave can be dragged to pan (grab/grabbing affordance) */
.wave-wrap.zoomed:not(.selecting) { cursor: grab; }
.wave-wrap.panning { cursor: grabbing; }

/* subtle overlay scrollbar — appears only while zoomed and never reflows the
   layout (it's absolutely positioned over the waveform's bottom edge) */
.wave-scrollbar {
  position: absolute; left: 12px; right: 12px; bottom: 4px; height: 6px;
  border-radius: 999px; background: rgba(255, 255, 255, 0.05);
  opacity: 0; pointer-events: none; z-index: 5;
  transition: opacity 0.2s var(--ease);
}
.wave-scrollbar.show { opacity: 1; pointer-events: auto; }
.wave-scrollbar-thumb {
  position: absolute; top: 0; left: 0; height: 100%; min-width: 28px;
  border-radius: 999px; background: rgba(255, 255, 255, 0.24);
  cursor: grab; transition: background 0.2s var(--ease);
}
.wave-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.38); }
.wave-scrollbar-thumb:active { background: rgba(255, 255, 255, 0.46); cursor: grabbing; }

/* marker rails: chapters ride above the wave, comment pins sit below — so the
   two kinds never overlap each other. The inner track is shifted in sync with
   the waveform's horizontal scroll so markers stay aligned when zoomed in. */
.rail {
  position: absolute; left: 12px; right: 12px; height: 22px;
  overflow: visible; pointer-events: none; z-index: 4;
}
/* once zoomed in, clip horizontally so markers don't spill past the panel */
.wave-wrap.zoomed .rail { overflow-x: clip; overflow-y: visible; }
.rail-inner { position: relative; height: 100%; width: 100%; will-change: transform; }
.rail-top { top: 10px; }
.rail-bottom { bottom: 16px; }
.rail.empty { display: none; }
.marker {
  position: absolute; top: 0; transform: translateX(-50%);
  cursor: pointer; display: flex; flex-direction: column; align-items: center;
  z-index: 4; pointer-events: auto;
}
.marker .flag {
  font-size: 10.5px; font-weight: 700; line-height: 1; white-space: nowrap;
  padding: 4px 8px; border-radius: 7px;
  background: rgba(139,123,255,0.9); color: #fff;
  box-shadow: 0 4px 12px -3px rgba(139,123,255,0.7);
  max-width: 130px; overflow: hidden; text-overflow: ellipsis;
  transition: transform 0.2s var(--spring), filter 0.2s var(--ease);
}
.marker:hover .flag { transform: translateY(-2px); filter: brightness(1.12); }
.marker.comment .flag { background: rgba(58,214,197,0.92);
  box-shadow: 0 4px 12px -3px rgba(58,214,197,0.7); }

#waveform {
  position: relative; z-index: 2;
  width: 100% !important; max-width: 100%; min-width: 0;
  overflow-x: auto; overflow-y: hidden;
}

/* playhead time tooltip */
.wave-hover {
  position: absolute; top: 36px; transform: translateX(-50%);
  pointer-events: none; z-index: 6; font-size: 11px; font-weight: 600;
  padding: 3px 7px; border-radius: 7px; background: rgba(0,0,0,0.7);
  color: #fff; opacity: 0; transition: opacity 0.15s var(--ease);
  white-space: nowrap;
}
.wave-wrap:hover .wave-hover { opacity: 1; }

/* transport */
.transport { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.transport .btn.icon { padding: 8px 12px; border-radius: 999px; }
/* download button — subtle green tint, a little wider, extra breathing room
   so it stands apart from the zoom controls (left) and speed control (right) */
.transport .btn.icon.dlbtn {
  padding: 8px 22px;
  margin: 0 6px;
  background: rgba(52, 199, 89, 0.15);
  border-color: rgba(52, 199, 89, 0.4);
  color: #c7f6d3;
}
.transport .btn.icon.dlbtn:hover { background: rgba(52, 199, 89, 0.26); }
.time { font-variant-numeric: tabular-nums; font-size: 14px; color: var(--text-dim);
  font-weight: 600; }
.time b { color: var(--text); }
.play {
  width: 58px; height: 58px; border-radius: 50%; flex: none;
  font-size: 22px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent), #6f5cff);
  border: 1px solid rgba(255,255,255,0.35);
  box-shadow: 0 12px 30px -8px rgba(111,92,255,0.75),
    inset 0 1px 0 rgba(255,255,255,0.6);
  color: #fff; cursor: pointer;
  transition: transform 0.25s var(--spring);
}
.play:hover { transform: scale(1.06); }
.play:active { transform: scale(0.94); }
.rate {
  background: var(--glass-bg-strong); border: 1px solid var(--glass-brd);
  color: var(--text); border-radius: 999px; padding: 8px 12px; font-size: 13px;
  font-weight: 600; font-family: inherit; cursor: pointer;
}
.rate option { color: #000; }

/* zoom controls */
.zoomctl { display: inline-flex; align-items: center; gap: 4px; }
.zoomctl .btn.icon { padding: 8px 11px; font-size: 16px; line-height: 1; font-weight: 700; }
.zoomctl .zoomlvl { min-width: 56px; justify-content: center; padding: 8px 8px;
  font-variant-numeric: tabular-nums; }

/* gear / settings button — subtle, sits at the widget's top-right */
.settingsbtn { font-size: 16px; opacity: 0.55; }
.settingsbtn:hover { opacity: 1; transform: translateY(-1px) rotate(35deg); }

/* action toolbar */
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; }
.toolbar .btn.active {
  background: linear-gradient(135deg, var(--accent-2), #2bb6a8);
  border-color: rgba(255,255,255,0.4); color: #042; }
.hint { color: var(--text-faint); font-size: 12.5px; flex-basis: 100%; }

/* ---------------------------------------------------------- side panel -- */
.side { display: grid; gap: 16px; }
.panel { padding: 18px; display: grid; gap: 12px; }
.panel h3 {
  margin: 0; font-size: 13px; text-transform: uppercase; letter-spacing: 1px;
  color: var(--text-faint); font-weight: 700;
  display: flex; align-items: center; gap: 8px;
}
.panel h3 .count {
  margin-left: auto; background: var(--glass-bg-strong); color: var(--text-dim);
  border-radius: 999px; padding: 2px 9px; font-size: 11px; letter-spacing: 0;
}

.identity-row {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  font-size: 13px; color: var(--text-dim);
}
.identity-lbl { font-weight: 600; color: var(--text-faint); }
.identity-name { font-weight: 700; color: var(--text); }
.identity-edit {
  appearance: none; border: none; background: none; cursor: pointer;
  color: var(--text-faint); font-size: 14px; line-height: 1; padding: 2px 4px;
  border-radius: 6px; transition: color 0.2s var(--ease), background 0.2s var(--ease);
}
.identity-edit:hover { color: var(--text); background: rgba(255,255,255,0.08); }
.identity-row.editing .identity-input {
  flex: 1; min-width: 120px; padding: 8px 11px; font-size: 13px;
}
.identity-input[hidden] { display: none !important; }

.tabs { display: flex; gap: 6px; padding: 5px; border-radius: 999px;
  background: rgba(0,0,0,0.25); }
.tabs button {
  flex: 1; border: none; background: transparent; color: var(--text-dim);
  font-family: inherit; font-weight: 600; font-size: 13px; padding: 9px;
  border-radius: 999px; cursor: pointer; transition: all 0.25s var(--ease); }
.tabs button.active { background: var(--glass-bg-strong); color: var(--text);
  box-shadow: inset 0 1px 0 var(--glass-hi); }

.list { display: grid; gap: 10px; max-height: min(58vh, 560px); overflow-y: auto;
  margin: -4px; padding: 4px; scrollbar-width: thin; }
.list::-webkit-scrollbar { width: 6px; }
.list::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 3px; }

.item {
  padding: 13px 14px; border-radius: var(--radius-xs);
  background: var(--glass-bg); border: 1px solid rgba(255,255,255,0.1);
  cursor: pointer; display: grid; gap: 6px;
  transition: transform 0.25s var(--spring), background 0.25s var(--ease),
    border-color 0.25s var(--ease);
  animation: itemIn 0.4s var(--ease) both;
}
@keyframes itemIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.item:hover { background: var(--glass-bg-strong); transform: translateX(2px); }
.item.active { border-color: var(--accent); background: rgba(139,123,255,0.14);
  box-shadow: 0 0 0 1px rgba(139,123,255,0.4); }
.item .top { display: flex; align-items: center; gap: 8px; }
.item .ts {
  font-variant-numeric: tabular-nums; font-size: 12px; font-weight: 700;
  color: #fff; background: rgba(139,123,255,0.85); padding: 3px 8px;
  border-radius: 7px; cursor: pointer; }
.item .ts.range { background: rgba(58,214,197,0.85); color: #032; }
.item .who { font-size: 13px; font-weight: 700; }
.item .who small { color: var(--text-faint); font-weight: 500; margin-left: 4px; }
.item .del { margin-left: auto; opacity: 0; color: var(--text-faint);
  background: none; border: none; cursor: pointer; font-size: 15px;
  transition: opacity 0.2s; padding: 2px 4px; }
.item:hover .del { opacity: 0.7; }
.item .del:hover { opacity: 1; color: var(--warn); }
.item p { margin: 0; font-size: 13.5px; color: var(--text-dim); line-height: 1.45;
  white-space: pre-wrap; word-break: break-word; }

/* ------------------------------------------------------- composer sheet -- */
.composer {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  padding: 16px 16px calc(16px + var(--safe-bottom));
  transform: translateY(120%); transition: transform 0.45s var(--spring);
  display: grid; justify-items: center; pointer-events: none;
}
.composer.show { transform: none; pointer-events: auto; }
.composer .sheet {
  width: min(560px, 100%); padding: 18px; display: grid; gap: 12px;
  box-shadow: 0 -10px 50px -10px rgba(0,0,0,0.6), inset 0 1px 0 var(--glass-hi);
}
.composer .sheet[hidden] { display: none !important; }
.composer .name-prompt .field { padding: 11px 14px; }
.composer .row { display: flex; align-items: center; gap: 10px; }
.composer .badge {
  font-size: 12.5px; font-weight: 700; padding: 6px 11px; border-radius: 999px;
  background: rgba(139,123,255,0.2); border: 1px solid rgba(139,123,255,0.5);
  color: #cfc7ff; font-variant-numeric: tabular-nums; }
.composer .badge.range { background: rgba(58,214,197,0.18);
  border-color: rgba(58,214,197,0.5); color: #9ef0e5; }
.field {
  width: 100%; font-family: inherit; font-size: 14px; color: var(--text);
  background: rgba(0,0,0,0.25); border: 1px solid var(--glass-brd);
  border-radius: var(--radius-xs); padding: 12px 14px; resize: none;
  transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease); }
.field:focus { outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(139,123,255,0.25); }
textarea.field { min-height: 84px; line-height: 1.5; }
.composer .actions { display: flex; gap: 10px; justify-content: flex-end; }

/* identity bubble — now an inline, optional name field (no popup) */
.whoami {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 12px 6px 6px; border-radius: 999px;
  background: var(--glass-bg-strong); border: 1px solid var(--glass-brd);
  font-size: 13px; font-weight: 600;
  transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease); }
.whoami:focus-within { border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(139,123,255,0.25); }
.whoami .av {
  width: 26px; height: 26px; flex: none; border-radius: 50%;
  display: grid; place-items: center;
  font-size: 12px; font-weight: 800; color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-3)); }
.whoami .name-input {
  border: none; background: transparent; color: var(--text);
  font-family: inherit; font-size: 13px; font-weight: 600;
  width: 9ch; min-width: 0; padding: 2px 0; }
.whoami .name-input:focus { outline: none; }
.whoami .name-input::placeholder { color: var(--text-faint); font-weight: 500; }

/* ------------------------------------------------------- settings sheet -- */
.settings-overlay {
  position: fixed; inset: 0; z-index: 90; display: grid; place-items: center;
  padding: 20px; background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
  opacity: 0; pointer-events: none; transition: opacity 0.25s var(--ease);
}
.settings-overlay.show { opacity: 1; pointer-events: auto; }
.settings-card {
  width: min(420px, 100%); padding: 22px; display: grid; gap: 12px;
  transform: translateY(10px) scale(0.98); transition: transform 0.3s var(--spring);
}
.settings-overlay.show .settings-card { transform: none; }
.settings-head { display: flex; align-items: center; gap: 10px; }
.settings-head .btn.icon { width: 38px; height: 38px; padding: 0; flex-shrink: 0; }
.settings-head h2 { margin: 0; font-size: 18px; font-weight: 800; flex: 1; }
.settings-label { font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.8px;
  color: var(--text-faint); font-weight: 700; margin-top: 6px; }
.seg { display: flex; gap: 6px; padding: 5px; border-radius: 999px; background: rgba(0,0,0,0.25); }
.seg-btn { flex: 1; border: none; background: transparent; color: var(--text-dim);
  font-family: inherit; font-weight: 600; font-size: 13px; padding: 10px; border-radius: 999px;
  cursor: pointer; transition: all 0.25s var(--ease); }
.seg-btn.active { background: var(--glass-bg-strong); color: var(--text);
  box-shadow: inset 0 1px 0 var(--glass-hi); }

/* admin passcode gate */
.gate {
  display: grid; gap: 12px; justify-items: center; text-align: center;
  padding: 26px 18px; max-width: 360px; margin: 0 auto;
}
.gate .gate-ico { font-size: 38px; }
.gate h2 { margin: 0; font-size: 20px; font-weight: 800; }
.gate p { margin: 0; font-size: 13.5px; }
.gate .field { text-align: center; }
.gate .slug-status { min-height: 16px; }
.gate .up-actions { width: 100%; justify-content: center; }
.muted.note { color: var(--text-dim); font-size: 12.5px; margin-top: 2px; }

/* --------------------------------------------------------------- toasts -- */
.toasts {
  position: fixed; top: calc(14px + var(--safe-top)); left: 50%;
  transform: translateX(-50%); z-index: 80; display: grid; gap: 8px;
  width: max-content; max-width: 92vw;
}
.toast {
  padding: 12px 18px; border-radius: 14px; font-size: 13.5px; font-weight: 600;
  background: var(--glass-bg-strong); border: 1px solid var(--glass-brd);
  backdrop-filter: blur(20px) saturate(160%);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
  box-shadow: var(--glass-shadow), inset 0 1px 0 var(--glass-hi);
  animation: toastIn 0.4s var(--spring) both; }
.toast.err { border-color: rgba(255,107,107,0.5); color: #ffd9d9; }
.toast.ok { border-color: rgba(58,214,197,0.5); }
@keyframes toastIn { from { opacity: 0; transform: translateY(-14px) scale(0.92); } }

/* skeleton loader */
.skeleton { position: relative; overflow: hidden;
  background: rgba(255,255,255,0.06); border-radius: var(--radius-sm); }
.skeleton::after { content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.1), transparent);
  animation: shimmer 1.4s infinite; }
@keyframes shimmer { to { transform: translateX(100%); } }

.back { display: inline-flex; align-items: center; gap: 7px; color: var(--text-dim);
  font-size: 14px; font-weight: 600; cursor: pointer; }
.back:hover { color: var(--text); }

/* spinner */
.spin { width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.25); border-top-color: #fff;
  animation: spin 0.8s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

/* --------------------------------------------------------------- mobile -- */
@media (max-width: 640px) {
  .app { padding: calc(14px + var(--safe-top)) 13px calc(30px + var(--safe-bottom)); }
  .hero { padding: 22px; }
  .stage { padding: 16px; gap: 14px; }
  .panel { padding: 15px; }
  .marker .flag { max-width: 92px; }

  /* tighten the waveform panel so the wave isn't floating in empty space */
  .wave-wrap { padding: 8px 10px; }
  .rail { left: 10px; right: 10px; height: 18px; }
  .rail-top { top: 8px; }
  .rail-bottom { bottom: 14px; }

  /* transport: keep it compact so it doesn't sprawl across rows */
  .transport { gap: 8px; }
  .play { width: 48px; height: 48px; font-size: 19px; }
  .transport .btn.icon { padding: 8px 11px; }
  .time { font-size: 13px; }
  .zoomctl .btn.icon { padding: 7px 9px; }
  .zoomctl .zoomlvl { min-width: 48px; }

  /* tool buttons: primary spans the row, the rest share the next row evenly,
     instead of each button stacking on its own line */
  .toolbar { gap: 8px; }
  .toolbar .btn {
    justify-content: center; padding: 11px 12px; font-size: 13px;
  }
  .toolbar .btn.primary { flex-basis: 100%; }
  .toolbar .btn:not(.primary) { flex: 1 1 0; min-width: 0; }
  .toolbar .hint { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; transition-duration: 0.05ms !important; }
  .blob { animation: none; }
}
