:root {
  --bg: #0a0a0a;
  --panel: #141414;
  --panel-2: #1b1b1b;
  --line: #262626;
  --text: #ffffff;
  --muted: #7a7a7a;
  --accent: #00F5A0;
  --pink: #FF2D85;
  --radius: 12px;
}

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

html, body {
  height: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 14px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

button, input {
  font: inherit;
  color: inherit;
}

/* Views and buttons set their own display, so make `hidden` win everywhere. */
[hidden] { display: none !important; }

.muted { color: var(--muted); }
.small-text { font-size: 12px; line-height: 1.5; margin: 8px 0 12px; }
.gas-trademark { font-weight: 900; letter-spacing: 0.05em; }

/* ---------- Top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 60px; /* same height with or without the editor buttons */
  padding: 12px 20px;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.brand-home {
  background: none;
  border: none;
  font-weight: 600;
  letter-spacing: 0.01em;
  cursor: pointer;
  white-space: nowrap;
}

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

.crumb {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.crumb-sep { color: var(--muted); font-weight: 400; }

.crumb-name {
  cursor: text;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  border-bottom: 1px dashed transparent;
}

.crumb-name:hover { border-bottom-color: var(--muted); }

.rename-input {
  min-width: 0;
  width: 240px;
  padding: 3px 6px;
  background: #0f0f0f;
  border: 1px solid var(--accent);
  border-radius: 6px;
  color: var(--text);
  font-weight: 600;
  outline: none;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 16px;
  min-width: 0;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Signed-in user: name (click to change it) + Sign out */
.account {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding-left: 16px;
  border-left: 1px solid var(--line);
}

.account-name {
  color: var(--muted);
  font-size: 12px;
  max-width: 200px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: text;
  border-bottom: 1px dashed transparent;
}

.account-name:hover { color: var(--text); border-bottom-color: var(--muted); }
.account .rename-input { width: 180px; font-size: 12px; font-weight: 400; }

/* With no editor buttons beside it (the picker), no divider is needed */
.topbar-actions[hidden] + .account { padding-left: 0; border-left: none; }

.hint {
  color: var(--muted);
  font-size: 12px;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 14px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  white-space: nowrap;
}

.btn:hover { border-color: var(--accent); }
.btn.small { padding: 6px 10px; font-size: 12px; }

.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #000;
  font-weight: 600;
}

.btn.primary:hover { background: #33f7b3; }

.key {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.08);
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
}

/* ---------- Sign in ---------- */
.login {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 12vh 16px 40px;
}

.login-card {
  width: 100%;
  max-width: 360px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 28px 24px 22px;
}

.login-card h1 {
  font-size: 22px;
  font-weight: 700;
}

.login-lead {
  font-size: 13px;
  line-height: 1.5;
  margin: 8px 0 20px;
}

.login-lead:empty { display: none; }

.login-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.login-form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
}

.login-form input {
  padding: 9px 10px;
  background: #0f0f0f;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  font-size: 14px;
  min-width: 0;
}

.login-form input:focus { outline: none; border-color: var(--accent); }
.login-form input[readonly] { color: var(--muted); }
.login-form .btn { justify-content: center; margin-top: 4px; }

.login-links {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.link {
  background: none;
  border: none;
  padding: 0;
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
}

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

.login-msg {
  font-size: 12px;
  line-height: 1.5;
  margin-top: 16px;
}

.login-msg:empty { display: none; }
.login-msg.error { color: var(--pink); }
.login-msg.ok { color: var(--accent); }

/* ---------- Project picker ---------- */
.picker {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}

.picker-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 28px 20px 40px;
}

.picker-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.picker-head h1 {
  font-size: 22px;
  font-weight: 700;
}

.picker .empty {
  max-width: 440px;
  margin: 40px auto 0;
}

.project-grid {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
}

.project-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: border-color 0.15s;
}

.project-card:hover,
.project-card:focus-visible {
  border-color: var(--accent);
  outline: none;
}

.project-thumb {
  position: relative;
  aspect-ratio: 16 / 9;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
}

.project-thumb svg { width: 40px; height: 40px; opacity: 0.4; }

.project-thumb img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.project-info { padding: 12px 14px 14px; }

.project-name-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
}

.project-name {
  flex: 1;
  min-width: 0;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.project-name-row .rename-input { flex: 1; width: auto; }

.card-action {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  background: none;
  border: none;
  border-radius: 6px;
  color: var(--muted);
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s;
}

.card-action svg { width: 14px; height: 14px; fill: currentColor; }
.card-action:hover { color: var(--text); background: var(--panel-2); }
.card-action.remove { margin-left: 0; font-size: 18px; }
.card-action.remove:hover { color: var(--pink); }

.project-card:hover .card-action,
.project-card:focus-within .card-action { opacity: 1; }

@media (hover: none) {
  .card-action { opacity: 1; }
}

.project-sub {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.5;
}

/* ---------- Layout ---------- */
.app {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 400px;
  gap: 16px;
  padding: 16px 20px 20px;
  min-height: 0;
}

/* ---------- Stage ---------- */
.stage {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
  min-height: 0;
}

.video-frame {
  flex: 1;
  position: relative;
  background: #000;
  border-radius: var(--radius);
  overflow: hidden;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.video-frame video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: none;
}

.video-frame.has-video video { display: block; }
.video-frame.has-video .dropzone { display: none; }

.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  max-width: 360px;
  padding: 40px;
  text-align: center;
  color: var(--muted);
  cursor: pointer;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  transition: border-color 0.15s, color 0.15s;
}

.dropzone:hover { border-color: var(--accent); color: #aaa; }
.dropzone svg { width: 56px; height: 56px; opacity: 0.5; }
.dropzone strong { color: var(--text); font-weight: 600; }
.dropzone span { font-size: 12px; line-height: 1.5; }

.now-playing {
  position: absolute;
  left: 16px;
  bottom: 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(6px);
  border-left: 3px solid var(--track-color, var(--accent));
  font-size: 13px;
  pointer-events: none;
}

.now-playing[hidden] { display: none; }
.now-playing-key { color: var(--track-color, var(--accent)); font-weight: 700; }

/* ---------- Transport ---------- */
.transport {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: var(--panel);
  border-radius: var(--radius);
  flex-shrink: 0;
}

.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: var(--panel-2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}

.icon-btn:hover:not(:disabled) { background: #2a2a2a; }
.icon-btn:disabled { opacity: 0.35; cursor: default; }
.icon-btn svg { width: 18px; height: 18px; fill: #fff; }

.timecode {
  font-variant-numeric: tabular-nums;
  font-size: 12px;
  min-width: 52px;
  text-align: center;
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  border-radius: 2px;
  background: #333;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
}

input[type="range"]:disabled { opacity: 0.35; cursor: default; }

.scrub { flex: 1; }
.vol { width: 80px; }

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
}

.toggle input { accent-color: var(--accent); }

/* ---------- Panel ---------- */
.panel {
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border-radius: var(--radius);
  min-height: 0;
  overflow: hidden;
}

.tabs {
  display: flex;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}

.tab-btn {
  flex: 1;
  padding: 12px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  cursor: pointer;
  font-weight: 600;
  font-size: 13px;
}

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

.tab {
  display: none;
  flex: 1;
  flex-direction: column;
  padding: 14px;
  overflow-y: auto;
  min-height: 0;
}

.tab.active { display: flex; }

.panel-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.vol-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
}

.empty {
  padding: 24px 8px;
  text-align: center;
  font-size: 13px;
  line-height: 1.5;
}

.empty p + p { margin-top: 10px; }
.empty[hidden] { display: none; }

/* ---------- Track list ---------- */
.track-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.track {
  background: var(--panel-2);
  border-radius: 10px;
  border-left: 3px solid var(--track-color);
  overflow: hidden;
}

.track-main {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  background: none;
  border: none;
  text-align: left;
  cursor: pointer;
}

.track-main:hover { background: rgba(255, 255, 255, 0.03); }

.track.active .track-main .key {
  background: var(--track-color);
  color: #000;
}

.track-text {
  min-width: 0;
}

.track-name {
  font-weight: 600;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.track-artist {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.track-time {
  font-size: 11px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.track.active .track-time { color: var(--track-color); }

.track-progress {
  height: 2px;
  background: #2a2a2a;
}

.track-progress > div {
  height: 100%;
  width: 0;
  background: var(--track-color);
  transition: width 0.2s linear;
}

.track-controls {
  display: none;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  padding: 10px 12px 12px;
  border-top: 1px solid var(--line);
  font-size: 12px;
  color: var(--muted);
}

.track.active .track-controls { display: flex; }

.track-controls .label { margin-right: 2px; }

.offset-input {
  width: 70px;
  padding: 4px 6px;
  background: #0f0f0f;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.nudge {
  padding: 4px 7px;
  background: #0f0f0f;
  border: 1px solid var(--line);
  border-radius: 6px;
  cursor: pointer;
  font-size: 11px;
}

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

.remove {
  margin-left: auto;
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
}

.remove:hover { color: var(--pink); }

/* ---------- Search ---------- */
.search-form {
  display: flex;
  gap: 8px;
}

.search-form input {
  flex: 1;
  padding: 8px 10px;
  background: #0f0f0f;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  min-width: 0;
}

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

.results {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.result {
  display: grid;
  grid-template-columns: 44px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 6px;
  background: var(--panel-2);
  border-radius: 8px;
}

.result img {
  width: 44px;
  height: 44px;
  border-radius: 6px;
  object-fit: cover;
  background: #222;
}

.result .track-name, .result .track-artist { display: block; }

.result-status {
  grid-column: 1 / -1;
  padding: 10px;
  text-align: center;
  color: var(--muted);
  font-size: 12px;
}

/* ---------- Spotify lanes ---------- */
.lanes {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.lane {
  background: var(--panel-2);
  border-radius: 10px;
  padding: 12px;
  border-left: 3px solid var(--track-color);
}

.lane-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.lane-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--muted);
}

.lane-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--track-color);
  flex: 1;
}

.lane iframe {
  width: 100%;
  border: none;
  border-radius: 8px;
  display: block;
}

/* ---------- Drop overlay ---------- */
.drop-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.7);
  border: 2px dashed var(--accent);
  font-size: 20px;
  font-weight: 600;
  z-index: 10;
  pointer-events: none;
}

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

/* ---------- Narrow screens ---------- */
@media (max-width: 900px) {
  body { overflow: auto; }
  .app { grid-template-columns: 1fr; }
  .video-frame { aspect-ratio: 16 / 9; flex: none; }
  .panel { min-height: 420px; }
  .hint { display: none; }
  .topbar { flex-wrap: wrap; }
}

/* ---------- Remove music (server/) ---------- */
.mix-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 4px;
  flex-shrink: 0;
  min-width: 0;
}

.mix-status {
  font-size: 12px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.mix-status.error { color: var(--pink); }

.mix-note { margin: 0 0 0 auto; white-space: nowrap; }

/* ---------- Account: save dot, sync line, picker footer ---------- */
.save-state {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--muted);
  opacity: 0.6;
}

.save-state[data-state=""] { visibility: hidden; }
.save-state[data-state="saving"] { background: #ffb347; opacity: 1; }
.save-state[data-state="error"] { background: var(--pink); opacity: 1; }

.sync-bar {
  display: flex;
  align-items: center;
  padding: 0 4px;
  flex-shrink: 0;
  min-width: 0;
}

.sync-text {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sync-text.warn, .warn-text { color: #ffb347; }

.picker-error {
  color: var(--pink);
  margin: 0 0 16px;
}

.account-footer {
  margin-top: 28px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.import-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 12px 14px;
  margin-bottom: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: 13px;
}
.btn:disabled { opacity: 0.5; cursor: default; border-color: var(--line); }

/* Two-state segmented control: Original | No music */
.seg {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  flex-shrink: 0;
}

.seg button {
  background: var(--panel-2);
  border: none;
  color: var(--muted);
  font: inherit;
  font-size: 12px;
  padding: 5px 9px;
  cursor: pointer;
  white-space: nowrap;
}

.seg button + button { border-left: 1px solid var(--line); }
.seg button.active { background: var(--accent); color: #000; font-weight: 600; }
.seg button:disabled { opacity: 0.4; cursor: default; }

/* ---------- View only: a project opened from a view-only link ----------
   Hidden here, and also refused in app.js (state.readOnly): the CSS is what
   the viewer sees, the code is what keeps their session from writing. */

.crumb-note {
  color: var(--muted);
  font-size: 12px;
  font-weight: 400;
  white-space: nowrap;
}

.stage-note {
  max-width: 360px;
  padding: 40px;
  text-align: center;
  color: var(--muted);
  line-height: 1.5;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
}

.offset-text { color: var(--text); font-variant-numeric: tabular-nums; }

body.read-only #editorActions,
body.read-only #saveState,
body.read-only #mixBar,
body.read-only .dropzone,
body.read-only .tab-btn[data-tab="search"],
body.read-only #spotifyForm,
body.read-only .lane-header .remove,
body.read-only #tracksEmpty .muted,
body.read-only #lanesEmpty .muted { display: none !important; }

body.read-only .crumb-name { cursor: default; }
body.read-only .crumb-name:hover { border-bottom-color: transparent; }

/* ---------- Share dialog (the owner's) ---------- */

.share-dialog {
  width: min(520px, calc(100vw - 32px));
  max-height: calc(100vh - 64px);
  margin: auto;
  padding: 24px;
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.share-dialog::backdrop { background: rgba(0, 0, 0, 0.6); }
.share-dialog h2 { font-size: 18px; font-weight: 700; margin-bottom: 18px; padding-right: 36px; overflow-wrap: anywhere; }
.share-dialog h3 { font-size: 14px; font-weight: 600; }
.share-close { position: absolute; top: 14px; right: 14px; }
.share-section + .share-section { margin-top: 20px; padding-top: 20px; border-top: 1px solid var(--line); }

.share-row { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.share-row input {
  flex: 1;
  min-width: 0;
  padding: 7px 10px;
  background: #0f0f0f;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  font: inherit;
  font-size: 13px;
}
.share-row input:focus { outline: none; border-color: var(--accent); }

.share-handoff { margin-top: 12px; padding: 10px 12px; border: 1px solid rgba(255, 179, 71, 0.4); border-radius: 8px; }
.share-handoff .small-text { margin: 0; }
.share-msg { font-size: 12px; line-height: 1.5; margin-top: 8px; }
.share-msg:empty { display: none; }
.share-msg.error { color: var(--pink); }
.share-msg.ok { color: var(--accent); }

.people { list-style: none; margin-top: 12px; }
.people li { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-top: 1px solid var(--line); }
.people .who { flex: 1; min-width: 0; }
.people .who span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.people .sub { color: var(--muted); font-size: 12px; }

/* ---------- Picker: your projects, and projects shared with you ---------- */

.picker-subhead {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin: 4px 0 12px;
}

.shared-projects { margin-top: 28px; }
.card-action.leave { font-size: 12px; margin-left: 0; padding: 2px 6px; }
.card-action.leave:hover { color: var(--pink); }
