:root {
  --bg: #0d0d10;
  --panel: #16161b;
  --panel-2: #1d1d24;
  --line: #2a2a33;
  --text: #f2f2f5;
  --muted: #8a8a97;
  --accent: #c9f24b;
  --accent-rgb: 201, 242, 75;
  --accent-ink: #12160a;
  --danger: #ff7a6b;
  --wave-dim: rgba(242, 242, 245, 0.22);
  --radius: 16px;
}

/* Light theme — the accent and its RGB triplet are set inline by settings.js. */
:root[data-theme="light"] {
  --bg: #f4f4f2;
  --panel: #ffffff;
  --panel-2: #ececef;
  --line: #d9d9e1;
  --text: #17171b;
  --muted: #6a6a78;
  --wave-dim: rgba(23, 23, 27, 0.2);
}

:root[data-theme="light"] .topbar { background: rgba(244, 244, 242, 0.82); }
:root[data-theme="light"] .dock { background: rgba(244, 244, 242, 0.86); }
:root[data-theme="light"] .dropzone {
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.02), transparent);
}
:root[data-theme="light"] .dropzone:hover,
:root[data-theme="light"] .dropzone:focus-visible {
  border-color: #b9b9c4;
  background: rgba(0, 0, 0, 0.03);
}
:root[data-theme="light"] .timeline:hover { box-shadow: inset 0 0 0 1px #c4c4d0; }
:root[data-theme="light"] .user-chip:hover { border-color: #c2c2cc; }
:root[data-theme="light"] .ghost:hover { border-color: #c2c2cc; }

* { box-sizing: border-box; }

/* Author display rules must not resurrect elements the markup hides. */
[hidden] { display: none !important; }

html { height: 100%; }

body {
  margin: 0;
  min-height: 100%;
  background-color: var(--bg);
  background-image: radial-gradient(900px 500px at 50% -10%, rgba(var(--accent-rgb), 0.10), transparent 70%);
  background-repeat: no-repeat;
  background-attachment: fixed;
  color: var(--text);
  font-family: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
}

.shell {
  width: min(760px, 100% - 2.5rem);
  margin: 0 auto;
  padding: clamp(2.5rem, 7vh, 5rem) 0 7.5rem;
}

/* ---------- header ---------- */

.eyebrow {
  margin: 0 0 0.75rem;
  font-size: 0.72rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 600;
}

h1 {
  margin: 0;
  font-size: clamp(1.75rem, 4.4vw, 2.6rem);
  line-height: 1.12;
  letter-spacing: -0.02em;
  font-weight: 700;
}

.sub {
  margin: 0.75rem 0 clamp(1.75rem, 4vh, 2.5rem);
  color: var(--muted);
  font-size: 0.98rem;
}

/* ---------- dropzone ---------- */

.dropzone {
  display: grid;
  place-items: center;
  gap: 0.35rem;
  padding: clamp(2.25rem, 6vw, 3.25rem) 1.5rem;
  border: 1.5px dashed var(--line);
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.025), transparent);
  cursor: pointer;
  text-align: center;
  transition:
    padding 0.5s cubic-bezier(0.22, 1, 0.36, 1),
    gap 0.5s cubic-bezier(0.22, 1, 0.36, 1),
    border-color 0.18s ease,
    background 0.18s ease,
    transform 0.18s ease;
}

/* Once a file is loaded the dropzone collapses into a slim strip. */
.dropzone.is-compact {
  padding: 0.85rem 1.25rem;
  gap: 0.1rem;
}

.dropzone.is-compact .drop-title { font-size: 0.92rem; }
.dropzone.is-compact .drop-icon {
  width: 0;
  height: 0;
  margin: 0;
  opacity: 0;
}

.dropzone.is-compact .drop-hint {
  max-height: 0;
  opacity: 0;
  margin: 0;
  overflow: hidden;
}

.dropzone:hover,
.dropzone:focus-visible {
  border-color: #44444f;
  background: rgba(255, 255, 255, 0.035);
  outline: none;
}

.dropzone.is-dragging {
  border-color: var(--accent);
  background: rgba(var(--accent-rgb), 0.07);
  transform: scale(1.005);
}

.drop-icon {
  width: 30px;
  height: 30px;
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
  margin-bottom: 0.35rem;
  overflow: visible;
  transition: width 0.45s cubic-bezier(0.22, 1, 0.36, 1),
              height 0.45s cubic-bezier(0.22, 1, 0.36, 1),
              margin 0.45s ease, opacity 0.25s ease;
}

.drop-title {
  margin: 0;
  font-weight: 600;
  font-size: 1.02rem;
}

.drop-hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.85rem;
  max-height: 2rem;
  transition: max-height 0.4s ease, opacity 0.25s ease, margin 0.4s ease;
}

.link {
  color: var(--text);
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: var(--line);
}

.error {
  margin: 1rem 0 0;
  padding: 0.7rem 0.9rem;
  border-radius: 10px;
  background: rgba(255, 122, 107, 0.1);
  border: 1px solid rgba(255, 122, 107, 0.3);
  color: var(--danger);
  font-size: 0.88rem;
}

/* ---------- player ---------- */

.player {
  margin-top: 1rem;
  padding: clamp(1.25rem, 3vw, 1.75rem);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  display: grid;
  gap: 1.5rem;
  animation: rise 0.5s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.player > * {
  animation: slideIn 0.55s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.player > *:nth-child(1) { animation-delay: 0.06s; }
.player > *:nth-child(2) { animation-delay: 0.12s; }
.player > *:nth-child(3) { animation-delay: 0.18s; }

@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: none; }
}

@keyframes slideIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: none; }
}

.track-meta {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.6rem;
}

.track-titles {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

/* The original file name sits above the (editable) new one and only shows
   while the track has actually been renamed. */
.track-orig {
  display: block;
  font-size: 0.76rem;
  line-height: 1.3;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  opacity: 0;
  max-height: 0;
  margin-bottom: 0;
  transition: opacity 0.4s ease, max-height 0.4s ease, margin 0.4s ease;
}

.track-orig.is-shown {
  opacity: 0.7;
  max-height: 1.4rem;
  margin-bottom: 1px;
}

.track-name {
  display: block;
  font-weight: 600;
  font-size: 0.95rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: text;
  border-radius: 5px;
}

.track-name:hover,
.track-name:focus-visible {
  color: var(--accent);
  outline: none;
}

.track-time {
  flex: none;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  font-size: 0.82rem;
}

/* Duration once the speed change is applied. It expands from zero width while
   it fades in, which pushes the original length to the left; on the way back
   it collapses and fades out, so the original slides back into place. */
.time-speed {
  display: inline-block;
  width: 0;
  white-space: nowrap;
  /* clip-path hides the text instead of overflow: hidden — a clipped
     inline-block sits on the baseline by its bottom edge, which stands it
     proud of the text and grows the row. */
  clip-path: inset(0);
  color: var(--accent);
  font-weight: 600;
  opacity: 0;
  transition:
    width 0.42s cubic-bezier(0.22, 1, 0.36, 1),
    margin-left 0.42s cubic-bezier(0.22, 1, 0.36, 1),
    opacity 0.28s ease;
}

.time-speed.is-on {
  margin-left: 0.45rem;
  opacity: 1;
}

.rename-input {
  width: 100%;
  min-width: 0;
  display: block;
  font: inherit;
  font-weight: 600;
  font-size: 0.92rem;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--accent);
  border-radius: 6px;
  padding: 1px 6px;
  margin: -2px 0;
  outline: none;
}

/* waveform timeline */

.timeline {
  position: relative;
  height: 78px;
  border-radius: 12px;
  background: var(--panel-2);
  overflow: hidden;
  cursor: pointer;
  touch-action: none;
  outline: none;
  transition: box-shadow 0.15s ease;
}

.timeline:hover { box-shadow: inset 0 0 0 1px #3b3b47; }

.timeline:focus-visible { box-shadow: 0 0 0 2px rgba(var(--accent-rgb), 0.55); }

.timeline canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.transport {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
  /* Its own stacking context (the entry animation) sits above the controls,
     so the download menu opened here is never painted under the sliders. */
  position: relative;
  z-index: 5;
}

.play {
  width: 52px;
  height: 52px;
  flex: none;
  display: grid;
  place-items: center;
  border: none;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-ink);
  cursor: pointer;
  transition: transform 0.12s ease, filter 0.15s ease;
}

.play:hover { filter: brightness(1.06); }
.play:active { transform: scale(0.96); }

.play svg {
  width: 22px;
  height: 22px;
  fill: currentColor;
}

.play .icon-stop { display: none; }
.player.is-playing .play .icon-play { display: none; }
.player.is-playing .play .icon-stop { display: block; }

.ghost {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  padding: 0.5rem 0.9rem;
  border-radius: 99px;
  font-size: 0.82rem;
  font-family: inherit;
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.ghost:hover {
  color: var(--text);
  border-color: #3d3d48;
}

.ghost.accent {
  color: var(--accent);
  border-color: rgba(var(--accent-rgb), 0.35);
}

.ghost.accent:hover {
  border-color: rgba(var(--accent-rgb), 0.7);
  background: rgba(var(--accent-rgb), 0.08);
}

.ghost[disabled] {
  opacity: 0.55;
  cursor: default;
}

.ghost[disabled]:hover {
  color: var(--accent);
  border-color: rgba(var(--accent-rgb), 0.35);
  background: transparent;
}

/* ---------- sliders ---------- */

.controls {
  display: grid;
  gap: 1.4rem;
  padding-top: 1.35rem;
  border-top: 1px solid var(--line);
}

.control-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 0.55rem;
}

.control-head label {
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.control-head output {
  font-size: 0.9rem;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
  font-weight: 600;
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 22px;
  background: transparent;
  cursor: pointer;
  margin: 0;
  display: block;
}

input[type="range"]::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: 99px;
  background: var(--panel-2);
}

input[type="range"]::-moz-range-track {
  height: 6px;
  border-radius: 99px;
  background: var(--panel-2);
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  margin-top: -6px;
  border-radius: 50%;
  background: var(--text);
  border: 3px solid var(--accent);
  box-shadow: 0 0 0 4px rgba(var(--accent-rgb), 0.12);
  transition: box-shadow 0.15s ease;
}

input[type="range"]::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--text);
  border: 3px solid var(--accent);
  box-shadow: 0 0 0 4px rgba(var(--accent-rgb), 0.12);
}

input[type="range"]:hover::-webkit-slider-thumb { box-shadow: 0 0 0 6px rgba(var(--accent-rgb), 0.18); }
input[type="range"]:hover::-moz-range-thumb { box-shadow: 0 0 0 6px rgba(var(--accent-rgb), 0.18); }

input[type="range"]:focus-visible { outline: none; }
input[type="range"]:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 6px rgba(var(--accent-rgb), 0.3); }
input[type="range"]:focus-visible::-moz-range-thumb { box-shadow: 0 0 0 6px rgba(var(--accent-rgb), 0.3); }

/* Slider thumbs travel from half a thumb-width inside each end, so every
   scale label and tick sits on that same inset and lines up with the knob. */
.scale {
  position: relative;
  display: block;
  height: 17px;
  margin: 0.35rem 9px 0;
  font-size: 0.72rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.scale > span {
  position: absolute;
  top: 0;
  transform: translateX(-50%);
  white-space: nowrap;
}

/* lighter dots marking every increment of a stepped slider */
.rail { position: relative; }

.dots {
  position: absolute;
  left: 9px;
  right: 9px;
  top: 0;
  height: 22px;
  pointer-events: none;
}

.dots .dot {
  position: absolute;
  top: 50%;
  width: 3px;
  height: 3px;
  margin: -1.5px 0 0 -1.5px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.34);
}

/* Volume runs 1–300% with no snapping. 100% sits dead centre: the left half
   is linear, the right half is logarithmic, so the labels bunch up as the
   boost climbs. */
.scale-vol {
  position: relative;
  display: block;
  height: 18px;
}

.scale-vol .tick {
  position: absolute;
  top: 0;
  transform: translateX(-50%);
  white-space: nowrap;
  font-size: 0.72rem;
  color: var(--muted);
}

.scale-vol .t-0 { left: 0; transform: none; }
.scale-vol .t-50 { left: 50%; }
.scale-vol .t-68 { left: 68.5%; }
.scale-vol .t-82 { left: 81.6%; }
.scale-vol .t-100 { left: 100%; transform: translateX(-100%); }

.scale-vol .tick::before {
  content: "";
  display: block;
  width: 1px;
  height: 5px;
  margin: 0 auto 3px;
  background: var(--line);
}

/* ---------- fixed dock ---------- */

.dock {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  padding: 0.7rem clamp(0.85rem, 3vw, 1.5rem) calc(0.7rem + env(safe-area-inset-bottom));
  background: rgba(13, 13, 16, 0.86);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
  opacity: 0;
  transform: translateY(105%);
  pointer-events: none;
  transition: opacity 0.4s ease, transform 0.55s cubic-bezier(0.22, 1, 0.36, 1);
}

.dock.is-visible {
  opacity: 1;
  transform: none;
  pointer-events: auto;
}

.dock-inner {
  width: min(760px, 100%);
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 0.8rem;
  min-width: 0;
}

.dock-play {
  width: 40px;
  height: 40px;
  flex: none;
  display: grid;
  place-items: center;
  border: none;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-ink);
  cursor: pointer;
  transition: transform 0.12s ease, filter 0.15s ease;
}

.dock-play:hover { filter: brightness(1.06); }
.dock-play:active { transform: scale(0.95); }

.dock-play svg { width: 17px; height: 17px; fill: currentColor; }
.dock-play .icon-pause { display: none; }
.dock.is-playing .dock-play .icon-play { display: none; }
.dock.is-playing .dock-play .icon-pause { display: block; }

.dock-title {
  flex: 1 1 auto;
  font-weight: 600;
  font-size: 0.92rem;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: text;
}

.dock-title:hover,
.dock-title:focus-visible {
  color: var(--accent);
  outline: none;
}

/* Listening volume — affects the speakers only, never the exported file. */
.dock-vol {
  flex: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: min(150px, 34vw);
  margin-left: auto;
  cursor: pointer;
}

.dock-vol svg {
  width: 15px;
  height: 15px;
  flex: none;
  fill: none;
  stroke: var(--muted);
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.dock-vol input[type="range"] { height: 18px; flex: 1 1 auto; }

/* ---------- download split button + format menu ---------- */

.download {
  position: relative;
  display: flex;
  align-items: stretch;
}

.download .dl-main {
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
}

.download .dl-more {
  border-left: 0;
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
  padding: 0.5rem 0.55rem;
  display: grid;
  place-items: center;
}

.dot-row {
  display: flex;
  gap: 3px;
}

.dot-row i {
  width: 3.5px;
  height: 3.5px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.9;
}

.download.is-open .dl-more,
.download .dl-more:hover { background: rgba(var(--accent-rgb), 0.12); }

.menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 30;
  min-width: 196px;
  padding: 0.3rem;
  display: grid;
  gap: 2px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.5);
  animation: menuIn 0.16s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes menuIn {
  from { opacity: 0; transform: translateY(-5px) scale(0.98); }
  to   { opacity: 1; transform: none; }
}

.menu button {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  width: 100%;
  padding: 0.45rem 0.55rem;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 0.82rem;
  text-align: left;
  cursor: pointer;
}

.menu button:hover,
.menu button:focus-visible {
  background: rgba(var(--accent-rgb), 0.12);
  color: var(--accent);
  outline: none;
}

.menu .fmt {
  color: var(--muted);
  font-size: 0.74rem;
  font-variant-numeric: tabular-nums;
}

.menu button:hover .fmt,
.menu button:focus-visible .fmt { color: inherit; }

/* ---------- top bar ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(13, 13, 16, 0.82);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}

.topbar-inner {
  position: relative;
  width: min(760px, 100% - 2.5rem);
  margin: 0 auto;
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  color: var(--text);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  white-space: nowrap;
  border-radius: 8px;
}

.brand-mark {
  width: 9px;
  height: 9px;
  flex: none;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px rgba(var(--accent-rgb), 0.15);
}

.brand:hover { color: var(--accent); }

.auth-slot {
  position: relative;
  display: flex;
  align-items: center;
  min-width: 0;
}

.signin-btn {
  display: inline-block;
  padding: 0.42rem 0.95rem;
  border-radius: 99px;
  border: 1px solid rgba(var(--accent-rgb), 0.4);
  color: var(--accent);
  font-size: 0.84rem;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.16s ease, border-color 0.16s ease;
}

.signin-btn:hover {
  background: rgba(var(--accent-rgb), 0.1);
  border-color: rgba(var(--accent-rgb), 0.7);
}

.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  max-width: 230px;
  padding: 0.2rem 0.7rem 0.2rem 0.2rem;
  border: 1px solid var(--line);
  border-radius: 99px;
  background: var(--panel);
  color: var(--text);
  font: inherit;
  font-size: 0.84rem;
  cursor: pointer;
  transition: border-color 0.16s ease, background 0.16s ease;
}

.user-chip:hover { border-color: #3d3d48; background: var(--panel-2); }

.user-name {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.avatar {
  flex: none;
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 0.82rem;
  font-weight: 700;
  line-height: 1;
  text-transform: uppercase;
}

.avatar-lg {
  width: 42px;
  height: 42px;
  font-size: 1.05rem;
}

.user-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 30;
  min-width: 196px;
  padding: 0.3rem;
  display: grid;
  gap: 2px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.5);
  animation: menuIn 0.16s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.user-menu-mail {
  margin: 0;
  padding: 0.4rem 0.55rem;
  color: var(--muted);
  font-size: 0.75rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-menu button {
  width: 100%;
  padding: 0.45rem 0.55rem;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 0.82rem;
  text-align: left;
  cursor: pointer;
}

.user-menu button:hover,
.user-menu button:focus-visible {
  background: rgba(var(--accent-rgb), 0.12);
  color: var(--accent);
  outline: none;
}

/* ---------- sign-in page ---------- */

.auth-shell {
  width: min(430px, 100% - 2.5rem);
  margin: 0 auto;
  padding: clamp(2rem, 7vh, 4rem) 0 5rem;
}

.auth-card {
  display: grid;
  gap: 0.95rem;
  padding: clamp(1.4rem, 4.5vw, 2rem);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  animation: rise 0.45s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.auth-card .eyebrow { margin: 0 0 -0.55rem; }

.auth-title {
  margin: 0;
  font-size: clamp(1.4rem, 3.6vw, 1.8rem);
  line-height: 1.15;
  letter-spacing: -0.02em;
}

.auth-sub {
  margin: -0.4rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.auth-code { display: grid; gap: 0.95rem; }

.auth-form { display: grid; gap: 0.85rem; margin: 0; }

.field { display: grid; gap: 0.35rem; }

.field label {
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--muted);
}

.field input {
  width: 100%;
  font: inherit;
  font-size: 0.92rem;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.62rem 0.75rem;
  outline: none;
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

.field input:focus {
  border-color: rgba(var(--accent-rgb), 0.6);
  box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.12);
}

.btn-primary {
  display: block;
  width: 100%;
  padding: 0.7rem 1rem;
  border: 0;
  border-radius: 12px;
  background: var(--accent);
  color: var(--accent-ink);
  font: inherit;
  font-size: 0.9rem;
  font-weight: 700;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  transition: filter 0.16s ease, transform 0.12s ease;
}

.btn-primary:hover { filter: brightness(1.06); }
.btn-primary:active { transform: scale(0.99); }
.btn-primary[disabled] { opacity: 0.6; cursor: default; }

.auth-error {
  margin: 0;
  padding: 0.55rem 0.7rem;
  border-radius: 9px;
  background: rgba(255, 122, 107, 0.1);
  border: 1px solid rgba(255, 122, 107, 0.3);
  color: var(--danger);
  font-size: 0.82rem;
}

.auth-note {
  margin: 0;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.45;
}

.auth-setup {
  display: grid;
  gap: 0.55rem;
  padding: 0.8rem 0.9rem;
  border: 1px dashed var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.02);
}

.auth-setup-title {
  margin: 0;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.auth-setup-steps {
  display: grid;
  gap: 0.45rem;
  margin: 0;
  padding-left: 1.1rem;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.45;
}

.auth-setup-steps strong { color: var(--text); font-weight: 600; }

.auth-setup a {
  color: var(--text);
  text-decoration-color: var(--line);
  text-underline-offset: 3px;
}

.auth-setup a:hover { color: var(--accent); }

.auth-setup code {
  padding: 0.1rem 0.3rem;
  border-radius: 5px;
  background: var(--panel-2);
  color: var(--text);
  font-size: 0.74rem;
  word-break: break-all;
}

.auth-setup-origin {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.35rem;
}

.auth-switch {
  margin: 0;
  text-align: center;
  color: var(--muted);
  font-size: 0.84rem;
}

.link-btn {
  border: 0;
  padding: 0;
  background: none;
  color: var(--text);
  font: inherit;
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: var(--line);
  cursor: pointer;
}

.link-btn:hover { color: var(--accent); }

.auth-done { display: grid; gap: 0.75rem; }

.auth-user {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.7rem;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 12px;
}

.auth-user-name {
  margin: 0;
  font-weight: 600;
  font-size: 0.95rem;
}

.auth-user-mail {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
  word-break: break-all;
}

@media (max-width: 520px) {
  .shell { width: calc(100% - 1.75rem); }
  .topbar-inner { width: calc(100% - 1.75rem); }
  .auth-shell { width: calc(100% - 1.75rem); }
  .track-meta { flex-direction: column; gap: 0.15rem; }
  .scale-vol .tick { font-size: 0.66rem; }
}

/* ---------- settings menu ---------- */

.settings-wrap {
  position: relative;
  display: flex;
  align-items: center;
  /* Sits tight against the sign-in slot even with the bar's space-between. */
  margin-left: auto;
}

.gear-btn {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  text-decoration: none;
  transition: color 0.16s ease, background 0.16s ease, border-color 0.16s ease;
}

.gear-btn svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.gear-btn:hover,
.gear-btn.is-open {
  color: var(--accent);
  background: rgba(var(--accent-rgb), 0.1);
  border-color: rgba(var(--accent-rgb), 0.3);
}

.gear-btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.25);
}

/* ---------- settings page ---------- */

.settings-card { gap: 0.9rem; }

.settings-block {
  display: grid;
  gap: 0.6rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
}

.settings-block-title {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 700;
}

.settings-hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.45;
}

.settings-row { display: grid; gap: 0.4rem; }

.custom-preset {
  display: grid;
  gap: 0.9rem;
  padding: 0.85rem;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 12px;
}

.custom-slider { display: grid; gap: 0.3rem; }

.custom-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  font-size: 0.84rem;
  font-weight: 600;
}

.custom-head output {
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.settings-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.settings-back {
  justify-self: start;
  font-size: 0.82rem;
  color: var(--muted);
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: var(--line);
}

.settings-back:hover { color: var(--accent); }

.settings-label {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.theme-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.theme-pick {
  padding: 0.42rem 0.5rem;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--panel);
  color: var(--muted);
  font: inherit;
  font-size: 0.8rem;
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.theme-pick:hover { color: var(--text); }

.theme-pick[aria-pressed="true"] {
  border-color: rgba(var(--accent-rgb), 0.7);
  background: rgba(var(--accent-rgb), 0.1);
  color: var(--accent);
}

.swatch-row {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.swatch {
  width: 26px;
  height: 26px;
  padding: 0;
  border: 2px solid transparent;
  border-radius: 50%;
  background: var(--swatch);
  cursor: pointer;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.25);
  transition: transform 0.12s ease, box-shadow 0.15s ease;
}

.swatch:hover { transform: scale(1.08); }

.swatch[aria-pressed="true"] {
  box-shadow: 0 0 0 2px var(--panel-2), 0 0 0 4px var(--swatch);
}

.settings-select {
  width: 100%;
  font: inherit;
  font-size: 0.82rem;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 0.42rem 0.5rem;
  outline: none;
  cursor: pointer;
}

.settings-select:focus { border-color: rgba(var(--accent-rgb), 0.6); }

.settings-note {
  margin: 0;
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1.4;
}

/* ---------- dock waveform ---------- */

.dock-wave {
  flex: none;
  width: 64px;
  height: 26px;
  display: block;
  opacity: 0.95;
  pointer-events: none;
}

@media (max-width: 520px) {
  .dock-wave { width: 46px; height: 22px; }
}

/* ---------- fine-adjustment dot ---------- */

.control-head label {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
}

.fine-dot {
  width: 10px;
  height: 10px;
  flex: none;
  padding: 0;
  border: 1.5px solid var(--muted);
  border-radius: 50%;
  background: transparent;
  opacity: 0.55;
  cursor: pointer;
  transition: opacity 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}

.fine-dot:hover {
  opacity: 1;
  border-color: var(--accent);
}

.fine-dot[aria-pressed="true"] {
  opacity: 1;
  background: var(--accent);
  border-color: var(--accent);
}

.fine-dot:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.3);
}

/* At 1% the increment dots would be a solid line, so they step aside. */
.control.is-fine .dots { display: none; }

.control-hint {
  margin: 0.4rem 0 0;
  color: var(--muted);
  font-size: 0.74rem;
}

/* ---------- pitch switch ---------- */

.pitch-toggle {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-top: -0.65rem;
}

.pitch-toggle-label {
  font-size: 0.88rem;
  font-weight: 600;
}

.switch {
  display: inline-flex;
  cursor: pointer;
}

.switch input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.switch-track {
  position: relative;
  display: block;
  width: 38px;
  height: 22px;
  border-radius: 99px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  transition: background 0.18s ease, border-color 0.18s ease;
}

.switch-knob {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--muted);
  transition: transform 0.18s ease, background 0.18s ease;
}

.switch input:checked + .switch-track {
  background: rgba(var(--accent-rgb), 0.24);
  border-color: rgba(var(--accent-rgb), 0.7);
}

.switch input:checked + .switch-track .switch-knob {
  transform: translateX(16px);
  background: var(--accent);
}

.switch input:focus-visible + .switch-track {
  box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.25);
}

/* ---------- preset picker beside the transport ---------- */

.deck-preset { margin-left: auto; }

.deck-select {
  font: inherit;
  font-size: 0.82rem;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 99px;
  padding: 0.45rem 0.7rem;
  max-width: 46vw;
  cursor: pointer;
  outline: none;
}

.deck-select:hover { border-color: rgba(var(--accent-rgb), 0.45); }
.deck-select:focus { border-color: rgba(var(--accent-rgb), 0.65); }
