:root {
  --bg: #0f172a;
  --panel: #111827;
  --card: #1e293b;
  --border: #334155;
  --text: #e5e7eb;
  --muted: #9ca3af;
  --accent: #60a5fa;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.hidden {
  display: none !important;
}

.shell {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}

.topbar-left,
.topbar-center,
.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar-center {
  flex: 1;
  justify-content: center;
}

.topbar-right {
  justify-content: flex-end;
}

.logo-mark {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: #f8fafc;
  color: #0f172a;
  font-weight: 700;
  display: grid;
  place-items: center;
  font-size: 13px;
}

.brand-name {
  font-size: 20px;
  font-weight: 700;
  line-height: 1;
}

.save-status {
  font-size: 12px;
  color: var(--muted);
  margin-right: 8px;
  white-space: nowrap;
}

.workspace-select,
select,
input,
textarea {
  background: #0b1730;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.workspace-select,
select,
input {
  height: 40px;
  padding: 0 12px;
}

textarea {
  width: 100%;
  min-height: 120px;
  padding: 12px;
  resize: vertical;
  font: inherit;
}

input::placeholder,
textarea::placeholder {
  color: #7b8798;
}

.workspace-select {
  min-width: 220px;
}

.pill-btn,
.icon-btn,
.secondary-btn,
.rail-action,
.quick-add,
.mini-btn {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  border-radius: 999px;
  cursor: pointer;
  font: inherit;
}

.pill-btn {
  padding: 9px 14px;
}

.pill-btn.primary {
  background: #f8fafc;
  color: #0f172a;
  border-color: #f8fafc;
  font-weight: 600;
}

.icon-btn {
  width: 40px;
  height: 40px;
}

.quick-add {
  width: 100%;
  padding: 12px 16px;
  background: var(--accent);
  border-color: var(--accent);
  color: white;
  font-weight: 600;
}

.secondary-btn,
.rail-action,
.mini-btn {
  padding: 8px 12px;
}

.layout {
  display: grid;
  grid-template-columns: 180px 1fr 180px;
  gap: 14px;
  min-height: calc(100vh - 59px);
  padding: 12px;
}

.left-rail,
.right-rail {
  min-width: 0;
}

.panel,
.main-panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.main-header h1,
.panel-header h2,
.card h3 {
  margin: 0;
}

.main-header p,
.muted {
  color: var(--muted);
}

.left-rail .panel,
.right-rail .panel,
.main-panel {
  background: rgba(17, 24, 39, 0.55);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 14px;
}

.center-work {
  min-width: 0;
}

.card-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.card {
  background: rgba(30, 41, 59, 0.72);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
  min-width: 0;
}

.card.wide {
  grid-column: 1 / -1;
}

.form-grid,
.lyrics-grid,
.version-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.field-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.field-group label,
.switch-label {
  font-size: 14px;
  font-weight: 500;
  color: var(--muted);
  line-height: 1.2;
}

.placeholder-box {
  min-height: 140px;
  border: 1px dashed var(--border);
  border-radius: 12px;
  display: grid;
  place-items: center;
  color: var(--muted);
  margin-bottom: 10px;
}

.placeholder-box.small {
  min-height: 72px;
  margin-bottom: 0;
}

.version-card {
  background: #16233a;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
}

.version-card.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(96, 165, 250, 0.2) inset;
}

.version-top {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
  font-size: 14px;
}

.wave {
  height: 18px;
  border-radius: 999px;
  background: linear-gradient(90deg, #334155, #475569, #334155);
  margin-bottom: 8px;
}

.version-file {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 8px;
}

.upload-row input[type="file"] {
  width: 100%;
  padding: 8px;
  border: 1px dashed var(--border);
  border-radius: 10px;
  background: transparent;
}

.audio-player {
  width: 100%;
  margin-top: 10px;
}

.version-actions {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-width: 220px;
}

.status-card {
  background: rgba(30, 41, 59, 0.72);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px;
}

.status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.progress {
  height: 8px;
  background: #020617;
  border-radius: 999px;
  overflow: hidden;
  margin-top: 8px;
}

.bar {
  height: 100%;
  width: 0%;
  background: var(--accent);
  border-radius: 999px;
}

.rail-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.rail-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.rail-list {
  margin: 0;
  padding-left: 18px;
  color: var(--text);
}

.song-item {
  cursor: pointer;
  padding: 4px 0;
}

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

.toggle-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 16px;
  margin-bottom: 14px;
}

.switch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
}

.switch input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.slider {
  position: relative;
  width: 40px;
  height: 22px;
  flex: 0 0 40px;
  background: #475569;
  border: 1px solid var(--border);
  border-radius: 999px;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.slider::before {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: white;
  transition: transform 0.2s ease;
}

.switch input[type="checkbox"]:checked + .slider {
  background: var(--accent);
  border-color: var(--accent);
}

.switch input[type="checkbox"]:checked + .slider::before {
  transform: translateX(18px);
}

.optional {
  display: none;
}

.optional.is-visible {
  display: flex;
}

.lyrics-grid textarea {
  min-height: 96px;
}

#songPrompt,
#songNotes {
  min-height: 140px;
}

@media (max-width: 1200px) {
  .layout {
    grid-template-columns: 220px 1fr;
  }

  .right-rail {
    grid-column: 1 / -1;
  }
}

@media (max-width: 900px) {
  .layout,
  .card-grid,
  .form-grid,
  .lyrics-grid,
  .version-grid {
    grid-template-columns: 1fr;
  }

  .topbar {
    flex-wrap: wrap;
  }

  .topbar-center {
    order: 3;
    width: 100%;
    justify-content: flex-start;
  }

  .save-status {
    width: 100%;
    margin-right: 0;
  }
}
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.section-save-status {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}

/* ── Badges ──────────────────────────────────────────────── */
.badge { display: inline-block; font-size: 11px; padding: 2px 8px; border-radius: 99px; }
.badge-success { background: rgba(34,197,94,0.15);  color: #4ade80; }
.badge-info    { background: rgba(96,165,250,0.15);  color: #60a5fa; }
.badge-warning { background: rgba(251,191,36,0.15);  color: #fbbf24; }
.badge-default { background: rgba(148,163,184,0.15); color: #94a3b8; }
.badge-danger  { background: rgba(239,68,68,0.15);   color: #f87171; }

/* ── List items ──────────────────────────────────────────── */
.list-item { display: flex; align-items: center; gap: 8px; cursor: pointer; padding: 6px 0; width: 100%; }
.list-item:hover strong { color: var(--accent); }

/* ── Detail view ─────────────────────────────────────────── */
.detail-grid  { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 14px 0; }
.detail-field { display: flex; flex-direction: column; gap: 2px; }
.detail-label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.detail-section { margin-top: 16px; }
.detail-section h4 { margin: 0 0 6px; font-size: 13px; color: var(--muted); }

/* ── Workspace block ─────────────────────────────────────── */
.workspace-block-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 16px; }
.workspace-label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; margin: 0 0 4px; }
.workspace-actions { display: flex; gap: 8px; }

/* ── Lyrics ──────────────────────────────────────────────── */
.lyric-grid    { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.lyric-section h5  { margin: 0 0 4px; font-size: 12px; color: var(--muted); }
.lyric-section pre { margin: 0; font-family: inherit; font-size: 14px; white-space: pre-wrap; }

/* ── Drive links ─────────────────────────────────────────── */
.drive-link-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px,1fr)); gap: 12px; margin-top: 12px; }
.drive-card      { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 12px; }
.drive-card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.drive-link      { color: var(--accent); font-size: 13px; text-decoration: none; }
.drive-link:hover { text-decoration: underline; }

/* ── Buttons ─────────────────────────────────────────────── */
.primary-btn   { background: var(--accent); color: #fff; border: none; border-radius: 8px; padding: 9px 16px; cursor: pointer; font: inherit; font-weight: 600; }
.danger-btn    { background: transparent; color: #f87171; border: 1px solid rgba(239,68,68,0.3); border-radius: 8px; padding: 8px 14px; cursor: pointer; font: inherit; }
.danger-btn.small { padding: 4px 10px; font-size: 12px; }

/* ── Modals ──────────────────────────────────────────────── */
.modal-overlay   { position: fixed; inset: 0; background: rgba(0,0,0,0.6); display: flex; align-items: center; justify-content: center; z-index: 100; }
.modal-card      { background: var(--panel); border: 1px solid var(--border); border-radius: 16px; padding: 24px; width: 100%; max-width: 480px; }
.modal-header    { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.modal-close-btn { background: none; border: none; color: var(--muted); font-size: 20px; cursor: pointer; }
.modal-actions   { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
.song-form .form-group { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.song-form label { font-size: 13px; color: var(--muted); }

/* ── Sidebar pages (songs, albums, etc) ──────────────────── */
.app      { display: grid; grid-template-columns: 200px 1fr 200px; min-height: 100vh; }
.sidebar  { background: var(--panel); border-right: 1px solid var(--border); padding: 20px 16px; display: flex; flex-direction: column; gap: 8px; }
.sidebar .brand { font-weight: 700; font-size: 16px; margin-bottom: 12px; }
.nav      { display: flex; flex-direction: column; gap: 4px; }
.nav a    { color: var(--muted); text-decoration: none; padding: 7px 10px; border-radius: 8px; font-size: 14px; }
.nav a:hover, .nav a.active { background: var(--card); color: var(--text); }
.sidebar-footer { margin-top: auto; }
.sidebar-footer a { color: var(--muted); font-size: 13px; text-decoration: none; }
.workspace-stack { display: grid; grid-template-columns: 1fr 220px; gap: 14px; padding: 14px; align-items: start; }
.workspace-main  { min-width: 0; }
.workspace-header { margin-bottom: 16px; }
.section-subtext  { color: var(--muted); font-size: 13px; margin: 4px 0 0; }
.workspace-content { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.workspace-block.wide { grid-column: 1 / -1; }
.workspace-block h3 { margin: 0 0 4px; font-size: 11px; color: var(--muted); letter-spacing: 0.08em; }
.workspace-title { font-size: 18px; font-weight: 600; margin: 0 0 4px; }
.workspace-text  { color: var(--muted); font-size: 14px; margin: 0; }
.recent-panel    { min-width: 0; }
.simple-list     { list-style: none; padding: 0; margin: 8px 0 0; display: flex; flex-direction: column; gap: 2px; }
.empty-message   { color: var(--muted); font-size: 13px; }
.studio-panel    { background: var(--panel); border-left: 1px solid var(--border); padding: 20px 16px; }
.studio-grid     { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }
.studio-card     { background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 10px; font-size: 13px; color: var(--muted); }
