/* =========================================================
   Sonogram — Japanese Aesthetic Design System
   Washi paper · Lacquer red · Indigo · Sumi-e ink
   ========================================================= */

:root {
  /* ── Colour palette ── */
  --bg:           #f4f0e6;      /* 和紙 washi paper */
  --bg-card:      #ffffff;      /* 白 shiro white */
  --bg-input:     #ece8de;      /* slightly darker paper */
  --border:       #d5cfc3;      /* warm light grey */
  --accent:       #b5292b;      /* 紅 beni / lacquer vermilion */
  --accent-glow:  #b5292b18;    /* soft red wash */
  --navy:         #1c2b5e;      /* 紺 kon-iro deep indigo */
  --gold:         #c4921a;      /* 金 kin brushed gold */
  --text:         #1a1814;      /* 墨 sumi-e ink */
  --text-muted:   #7a7265;      /* warm mid-grey */
  --success:      #2a6e4a;      /* 松 matsu pine green */
  --error:        #b5292b;      /* same as accent */

  /* ── Shape ── */
  --radius:       3px;

  /* ── Typography ── */
  --font-display: "Cormorant Garamond", Georgia, serif;
  --font:         "Inter", system-ui, sans-serif;
  --mono:         "JetBrains Mono", "Fira Code", monospace;

  /* ── Shadow ── */
  --shadow-sm:    0 1px 3px rgba(26,24,20,.07), 0 4px 12px rgba(26,24,20,.05);
  --shadow-md:    0 2px 8px rgba(26,24,20,.09), 0 8px 24px rgba(26,24,20,.07);
  --shadow-lg:    0 4px 16px rgba(26,24,20,.12), 0 16px 40px rgba(26,24,20,.09);
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.65;
  min-height: 100vh;
}

/* =========================================================
   Navigation
   ========================================================= */
.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 2rem;
  height: 60px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-card);
  position: sticky;
  top: 0;
  z-index: 100;
}
.nav-brand {
  font-family: var(--font-display);
  font-size: 1.45rem;
  font-weight: 600;
  color: var(--navy);
  text-decoration: none;
  letter-spacing: 0.02em;
}
.nav-links { display: flex; gap: 2rem; }
.nav-link {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 500;
  letter-spacing: 0.03em;
  padding-bottom: 2px;
  border-bottom: 2px solid transparent;
  transition: color 0.2s, border-color 0.2s;
}
.nav-link:hover { color: var(--text); }
.nav-link.active { color: var(--navy); border-bottom-color: var(--accent); }

/* =========================================================
   Layout
   ========================================================= */
.container {
  max-width: 1140px;
  margin: 0 auto;
  padding: 3rem 1.5rem 5rem;
}

/* =========================================================
   Page header
   ========================================================= */
.page-header { margin-bottom: 2.5rem; }
.page-header h1 {
  font-family: var(--font-display);
  font-size: 3rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text);
  line-height: 1.15;
  padding-left: 1rem;
  border-left: 3px solid var(--accent);
}
.subtitle { color: var(--text-muted); margin-top: 0.4rem; padding-left: 1rem; }

/* =========================================================
   Cards
   ========================================================= */
.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 2.2rem;
  margin-bottom: 1.5rem;
}
.card h2 {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--navy);
  margin-bottom: 1rem;
  letter-spacing: 0.01em;
}

/* =========================================================
   Buttons
   ========================================================= */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 1.3rem;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  cursor: pointer;
  border: none;
  transition: all 0.18s;
  text-decoration: none;
}
.btn-primary {
  background: var(--navy);
  color: #fff;
}
.btn-primary:hover { background: #253580; }
.btn-secondary {
  background: var(--bg-card);
  color: var(--navy);
  border: 1px solid var(--border);
}
.btn-secondary:hover { border-color: var(--accent); color: var(--accent); }
.btn-accent {
  background: var(--accent);
  color: #fff;
}
.btn-accent:hover { background: #9c2124; }
.btn:disabled { opacity: 0.35; cursor: not-allowed; pointer-events: none; }

/* =========================================================
   Form elements
   ========================================================= */
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; font-size: 0.82rem; color: var(--text-muted); margin-bottom: 0.35rem; }
.input {
  width: 100%;
  padding: 0.6rem 0.9rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 0.9rem;
  font-family: var(--font);
  outline: none;
  transition: border-color 0.2s;
}
.input:focus { border-color: var(--accent); }

/* =========================================================
   Drop zone
   ========================================================= */
.drop-zone {
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 2.8rem 1.5rem;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  margin-bottom: 1rem;
  background: var(--bg);
}
.drop-zone:hover,
.drop-zone.drag-over {
  border-color: var(--accent);
  background: var(--accent-glow);
}
.drop-zone__icon {
  font-size: 2.4rem;
  margin-bottom: 0.7rem;
  color: var(--navy);
  display: block;
}
.drop-zone p { color: var(--text-muted); font-size: 0.9rem; margin-bottom: 0.7rem; }
.drop-zone--small { padding: 1.6rem 1rem; }
.drop-zone--small .drop-zone__icon { font-size: 1.6rem; }

/* =========================================================
   Progress bar
   ========================================================= */
.progress-bar {
  height: 3px;
  background: var(--bg-input);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 0.6rem;
}
.progress-fill {
  height: 100%;
  background: var(--accent);
  width: 0%;
  transition: width 0.35s ease;
}

/* =========================================================
   Upload progress
   ========================================================= */
.upload-progress { margin-top: 1rem; }
#uploadStatus { font-size: 0.85rem; color: var(--text-muted); }

/* =========================================================
   Library list
   ========================================================= */
.library-list { display: flex; flex-direction: column; gap: 0.7rem; margin-top: 0.5rem; }
.track-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.9rem 1.1rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  gap: 1rem;
  flex-wrap: wrap;
}
.track-item__info { flex: 1; min-width: 0; }
.track-item__name {
  font-size: 0.95rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.track-item__meta { font-size: 0.78rem; color: var(--text-muted); font-family: var(--mono); }
.track-item__actions { display: flex; gap: 0.5rem; flex-shrink: 0; }

/* =========================================================
   Studio grid
   ========================================================= */
.studio-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}
@media (max-width: 750px) { .studio-grid { grid-template-columns: 1fr; } }
.studio-panel { display: flex; flex-direction: column; gap: 1rem; }

/* =========================================================
   Canvas wrapper
   ========================================================= */
.canvas-wrapper {
  margin-top: 1rem;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  background: #05050a;
  position: relative;
  aspect-ratio: 1;
}
.canvas-wrapper canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}
.canvas-controls {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.7rem 1rem;
  background: rgba(5,5,10,0.85);
  border-top: 1px solid rgba(255,255,255,0.06);
}
.hint { font-size: 0.78rem; color: rgba(255,255,255,0.45); }

/* =========================================================
   Status messages
   ========================================================= */
.status-msg {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.88rem;
  color: var(--text-muted);
}
.error-msg {
  background: rgba(181,41,43,.07);
  border: 1px solid var(--error);
  border-radius: var(--radius);
  padding: 0.7rem 1rem;
  font-size: 0.88rem;
  color: var(--error);
}

/* =========================================================
   Retrieve result
   ========================================================= */
.retrieve-result h3 { font-size: 1rem; margin-bottom: 0.7rem; color: var(--success); font-family: var(--font-display); letter-spacing: 0.02em; }
.track-info { display: grid; grid-template-columns: auto 1fr; gap: 0.3rem 1rem; font-size: 0.88rem; }
.track-info dt { color: var(--text-muted); }
.track-info dd { font-family: var(--mono); }

/* =========================================================
   Spinner
   ========================================================= */
.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* =========================================================
   Utility
   ========================================================= */
.hidden  { display: none !important; }
.muted   { color: var(--text-muted); font-size: 0.88rem; }

/* =========================================================
   Gallery page
   ========================================================= */
.gallery-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
}
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.4rem;
}
@media (max-width: 900px) { .gallery-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 560px) { .gallery-grid { grid-template-columns: 1fr; } }

.gallery-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  cursor: pointer;
  transition: box-shadow 0.22s, transform 0.22s;
}
.gallery-card:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-3px);
}
.gallery-card:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.gallery-card__img-link { display: block; aspect-ratio: 1; overflow: hidden; }
.gallery-card__img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.35s;
}
.gallery-card:hover .gallery-card__img { transform: scale(1.04); }
.gallery-card__body { padding: 0.95rem 1.1rem 1rem; }
.gallery-card__title {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text);
}
.gallery-card__artist {
  font-size: 0.8rem;
  color: var(--accent);
  margin-top: 0.18rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.gallery-card__album {
  font-size: 0.78rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.gallery-card__meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-family: var(--mono);
  margin-top: 0.35rem;
}
.gallery-empty {
  text-align: center;
  padding: 5rem 2rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
}
.gallery-empty__msg {
  font-family: var(--font-display);
  font-size: 1.15rem;
  color: var(--text-muted);
}
.gallery-loading {
  display: flex;
  justify-content: center;
  padding: 5rem;
}

/* =========================================================
   Studio workspace
   ========================================================= */
.workspace-grid {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 1.8rem;
  align-items: start;
  margin-top: 1rem;
}
@media (max-width: 750px) { .workspace-grid { grid-template-columns: 1fr; } }

.workspace-left { display: flex; flex-direction: column; gap: 1.4rem; }

/* Track metadata definition list */
.track-meta {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.28rem 0.9rem;
  font-size: 0.85rem;
}
.track-meta dt { color: var(--text-muted); white-space: nowrap; }
.track-meta dd { font-family: var(--mono); word-break: break-word; }

.workspace-actions { display: flex; flex-direction: column; gap: 0.65rem; }

/* Share toggle */
.share-toggle {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  font-size: 0.88rem;
  color: var(--text);
  user-select: none;
}
.share-toggle input[type="checkbox"] {
  accent-color: var(--accent);
  width: 15px;
  height: 15px;
  cursor: pointer;
}

/* Canvas with rendering overlay */
.canvas-rendering {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(5,5,10,0.75);
  border-radius: var(--radius);
  z-index: 2;
}

/* =========================================================
   3D Viewer Modal
   ========================================================= */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(26,24,20,0.58);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  backdrop-filter: blur(3px);
}
.modal {
  background: var(--bg-card);
  border-radius: 6px;
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 820px;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
}
.modal-close {
  position: absolute;
  top: 0.8rem; right: 0.8rem;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: 50%;
  width: 32px; height: 32px;
  font-size: 0.85rem;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: color 0.2s, border-color 0.2s;
  z-index: 2;
}
.modal-close:hover { color: var(--accent); border-color: var(--accent); }
.modal-sphere-wrap {
  position: relative;
  background: #05050a;
  border-radius: 6px 6px 0 0;
  overflow: hidden;
  aspect-ratio: 16/9;
}
.modal-canvas {
  display: block; width: 100%; height: 100%;
}
.modal-fallback {
  display: block; width: 100%; height: 100%; object-fit: contain;
}
.modal-body {
  padding: 1.3rem 1.6rem 1.6rem;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  border-top: 1px solid var(--border);
}
.modal-info { flex: 1; min-width: 0; }
.modal-title {
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text);
}
.modal-artist {
  font-size: 0.88rem;
  color: var(--accent);
  margin-top: 0.18rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.modal-details {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-family: var(--mono);
  margin-top: 0.3rem;
}
.modal-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.5rem;
  flex-shrink: 0;
}


/* =========================================================
   Gallery filters
   ========================================================= */
.gallery-filters {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.4rem;
  flex-wrap: wrap;
}
.gallery-search { flex: 1; min-width: 180px; max-width: 320px; }
.gallery-genre  { min-width: 130px; }
.bpm-filter     { display: flex; align-items: center; gap: 0.4rem; font-size: 0.82rem; }
.bpm-input      { width: 5.2rem; }
.gallery-count  { font-size: 0.80rem; margin-left: auto; }
.gallery-card__views {
  display: inline-block;
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-left: 0.5rem;
}

/* =========================================================
   Mode switcher (studio canvas controls)
   ========================================================= */
.mode-switcher {
  display: flex;
  gap: 0.35rem;
  margin-top: 0.5rem;
  justify-content: center;
}
.mode-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.9rem;
  padding: 0.25rem 0.55rem;
  line-height: 1;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.mode-btn:hover { border-color: var(--navy); color: var(--navy); }
.mode-btn.active {
  background: var(--navy);
  border-color: var(--navy);
  color: #fff;
}

/* =========================================================
   Modal extras — edit form, similar works
   ========================================================= */
.modal-edit-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0.8rem 0;
}
.modal-edit-form .input { flex: 1; min-width: 140px; }
.modal-edit-actions { display: flex; gap: 0.5rem; width: 100%; margin-top: 0.2rem; }

.modal-similar {
  border-top: 1px solid var(--border);
  padding: 1rem 1.6rem 1.4rem;
}
.modal-similar__label {
  font-size: 0.75rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin-bottom: 0.7rem;
}
.modal-similar__grid {
  display: flex;
  gap: 0.9rem;
}
.similar-card {
  flex: 1;
  cursor: pointer;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  transition: box-shadow 0.18s;
}
.similar-card:hover { box-shadow: var(--shadow-md); }
.similar-card__img {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
}
.similar-card__title {
  padding: 0.35rem 0.5rem 0.1rem;
  font-size: 0.78rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.similar-card__artist {
  padding: 0 0.5rem 0.4rem;
  font-size: 0.72rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Admin ─────────────────────────────────────────────────── */
.admin-login-wrap {
  max-width: 360px;
  margin: 5rem auto 0;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.admin-login-title { font-size: 1.5rem; }
.admin-login-error {
  color: #e05c5c;
  font-size: 0.875rem;
}
.admin-login-form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}
.admin-table th {
  text-align: left;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  color: var(--muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.admin-table td {
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.admin-table tr:last-child td { border-bottom: none; }

.admin-thumb {
  width: 48px;
  height: 48px;
  object-fit: cover;
  border-radius: 4px;
  display: block;
}

.badge-public {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  background: rgba(72, 199, 142, 0.15);
  color: #48c78e;
  font-size: 0.75rem;
  font-weight: 600;
}
.badge-private {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 600;
}

.admin-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.btn-sm {
  padding: 0.25rem 0.65rem;
  font-size: 0.78rem;
}
.btn-danger {
  background: rgba(224, 92, 92, 0.15);
  color: #e05c5c;
  border: 1px solid rgba(224, 92, 92, 0.35);
}
.btn-danger:hover {
  background: rgba(224, 92, 92, 0.28);
}

/* ── Sonogram individual page (/s/{id}) ────────────────────── */
.sg-page { max-width: 1100px; margin: 0 auto; }

.sg-back {
  display: inline-block;
  font-size: 0.82rem;
  color: var(--muted);
  text-decoration: none;
  margin-bottom: 1.6rem;
  letter-spacing: 0.02em;
}
.sg-back:hover { color: var(--accent); }

.sg-layout {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 2.4rem;
  align-items: start;
}
@media (max-width: 820px) {
  .sg-layout { grid-template-columns: 1fr; }
}

.sg-viewer-col {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.sg-viewer {
  position: relative;
  background: var(--bg-card);
  border-radius: var(--radius) var(--radius) 0 0;
  overflow: hidden;
  aspect-ratio: 1;
  min-height: 320px;
}
.sg-viewer #sphereCanvas,
.sg-viewer #fallbackImg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}
.sg-fallback { width: 100%; height: 100%; object-fit: cover; display: block; }

.sg-info {
  display: flex;
  flex-direction: column;
  gap: 1.8rem;
  padding-top: 0.4rem;
}

.sg-title-block { display: flex; flex-direction: column; gap: 0.4rem; }
.sg-title  { font-size: 1.6rem; font-weight: 700; line-height: 1.2; margin: 0; }
.sg-artist { font-size: 1rem; color: var(--accent); margin: 0; font-weight: 500; }
.sg-meta   { font-size: 0.82rem; margin: 0; }
.sg-key    { font-size: 0.78rem; margin: 0; }

.sg-actions { display: flex; flex-direction: column; gap: 0.75rem; }
.sg-section { display: flex; flex-direction: column; gap: 0.4rem; }
.sg-section-label {
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.sg-action-row {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.sg-btn { flex: 1; min-width: 6rem; text-align: center; }

.sg-similar {
  margin-top: 3rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border);
}
.sg-similar__heading {
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 1rem;
}
.sg-similar__grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
}
@media (max-width: 560px) {
  .sg-similar__grid { grid-template-columns: 1fr 1fr; }
}

/* ── Gallery cards as links ─────────────────────────────────── */
a.gallery-card {
  display: block;
  text-decoration: none;
  color: inherit;
}

/* ── Studio save section ────────────────────────────────────── */
.studio-save-section { display: flex; flex-direction: column; gap: 0.55rem; }
.btn-wide { width: 100%; text-align: center; justify-content: center; }
.btn-ghost {
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 0.82rem;
  cursor: pointer;
  padding: 0.3rem 0;
  text-align: left;
}
.btn-ghost:hover { color: var(--text); }

.save-success {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.6rem 0.8rem;
  background: rgba(72, 199, 142, 0.1);
  border: 1px solid rgba(72, 199, 142, 0.25);
  border-radius: var(--radius);
  font-size: 0.875rem;
}
.save-check { color: #48c78e; font-weight: 700; font-size: 1rem; }

.studio-export-row {
  display: flex;
  gap: 0.55rem;
  margin-top: 0.4rem;
}
.studio-export-row .btn { flex: 1; }

/* ── Waveform strip ──────────────────────────────────────── */
.sg-waveform {
  display: block;
  width: 100%;
  height: 48px;
  border-radius: 0 0 var(--radius) var(--radius);
  background: rgba(5,5,10,0.6);
  border: 1px solid var(--border);
  border-top: none;
}

/* ── Viewer tabs ─────────────────────────────────────── */
.viewer-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  background: var(--bg-card);
  border-radius: var(--radius) var(--radius) 0 0;
}
.viewer-tab {
  padding: 0.45rem 1.1rem;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: color 0.15s, border-color 0.15s;
  position: relative;
}
.viewer-tab:first-child { border-radius: var(--radius) 0 0 0; }
.viewer-tab.active { color: var(--text); border-bottom-color: var(--accent); }
.viewer-tab:hover:not(.active) { color: var(--text); }
.tab-badge {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  vertical-align: middle;
  margin-left: 5px;
  margin-bottom: 1px;
}
/* ── AI painting panel ───────────────────────────────── */
.sg-ai-panel {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  background: var(--bg-card);
  overflow: hidden;
}
.sg-ai-panel .ai-paint-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
/* No top radius when tabs sit above the viewer */
#sg3dView .sg-viewer { border-radius: 0; }
.ai-paint-reveal-canvas {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  cursor: pointer;
  display: none;
}

/* ── Mood / genre badges ─────────────────────────────────── */
.sg-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.4rem;
}
.sg-badge {
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  background: rgba(255,255,255,0.08);
  color: var(--muted);
  border: 1px solid rgba(255,255,255,0.06);
}
.sg-genre-tag {
  display: inline-block;
  margin-top: 0.3rem;
  padding: 0.15rem 0.6rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  background: rgba(var(--accent-rgb, 120,100,200), 0.18);
  color: var(--accent, #c0b0f0);
  border: 1px solid rgba(var(--accent-rgb, 120,100,200), 0.25);
}

/* ── Palette picker ──────────────────────────────────────── */
.palette-picker {
  display: flex;
  gap: 0.4rem;
  align-items: center;
  margin-top: 0.5rem;
}
.palette-swatch {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid transparent;
  transition: border-color 0.15s, transform 0.1s;
  padding: 0;
  flex-shrink: 0;
}
.palette-swatch:hover { transform: scale(1.15); }
.palette-swatch.active { border-color: #fff; box-shadow: 0 0 0 1px rgba(255,255,255,0.4); }

/* ── Compare section (sonogram page) ────────────────────── */
.sg-compare {
  margin-top: 1.2rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}
.sg-artist-link {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px dotted var(--muted);
}
.sg-artist-link:hover { color: var(--text); }

/* ── Three-stage pipeline layout ─────────────────────────── */
.stages-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.2rem;
  margin-bottom: 2rem;
}
@media (max-width: 900px) {
  .stages-grid { grid-template-columns: 1fr; }
}

.stage-box {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
  display: flex;
  flex-direction: column;
}

.stage-box__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  gap: 0.5rem;
}

.stage-label {
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--text-muted);
  white-space: nowrap;
}

.stage-box__btns {
  display: flex;
  gap: 0.25rem;
  align-items: center;
}

.stage-btn {
  padding: 0.2rem 0.45rem;
  font-size: 0.82rem;
  min-width: unset;
  line-height: 1.4;
}

.stage-box__canvas-wrap {
  position: relative;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  background: #111;
}

/* Stage 3 video fills the square like stage-img */
.stage-box__canvas-wrap video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  position: absolute;
  inset: 0;
}

/* Make Stage 1 canvas fill the box */
.stage-box__canvas-wrap canvas {
  width: 100% !important;
  height: 100% !important;
  display: block;
}

.stage-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  position: absolute;
  inset: 0;
}

.stage-status {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  color: var(--text-muted);
  font-size: 0.82rem;
  background: #0a0e1a;
}

.stage-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.8rem;
  padding: 1.5rem;
  background: #0a0e1a;
}

.stage-loading {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  background: rgba(10,14,26,0.85);
}

/* Controls overlay inside Stage 1 box */
#canvasControls {
  position: absolute;
  bottom: 0.5rem;
  left: 0;
  right: 0;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.4rem 0.6rem;
  background: rgba(0,0,0,0.45);
  backdrop-filter: blur(4px);
}

.stage-hint {
  font-size: 0.68rem;
  margin: 0;
  display: none; /* hide in compact stage box */
}

/* Info row below grid */
.sg-info-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.sg-meta { flex: 1; min-width: 200px; }
.sg-meta-line { font-size: 0.82rem; margin: 0.2rem 0 0; }

.sg-social {
  display: flex;
  gap: 0.5rem;
  flex-shrink: 0;
  flex-wrap: wrap;
  align-items: flex-start;
}

/* Stage 2 reveal canvas overlays the image */
#aiPaintRevealCanvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

/* ── Mic recording UI ────────────────────────────────────── */
.mic-recording {
  display: flex;
  gap: 0.8rem;
  align-items: center;
  justify-content: center;
  padding: 0.8rem 1rem;
  background: rgba(224,92,92,0.12);
  border-radius: var(--radius);
  border: 1px solid rgba(224,92,92,0.3);
  margin-top: 0.6rem;
}
.mic-timer {
  font-family: var(--mono, monospace);
  font-size: 1.1rem;
  color: #e05c5c;
  font-weight: 600;
}

/* ── Compare page ────────────────────────────────────────── */
.compare-layout {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 1.5rem;
  align-items: start;
}
@media (max-width: 640px) {
  .compare-layout { grid-template-columns: 1fr; }
  .compare-vs { padding-top: 0; text-align: center; }
}
.compare-vs {
  font-size: 1.4rem;
  color: var(--muted);
  padding-top: 8rem;
  font-weight: 700;
  text-align: center;
}
.compare-viewer {
  aspect-ratio: 1;
  background: var(--bg-card);
  border-radius: var(--radius);
  overflow: hidden;
  position: relative;
}
.compare-viewer canvas { display: block; width: 100%; height: 100%; }
.compare-sim {
  text-align: center;
  margin: 1.5rem 0 0.5rem;
  font-size: 1.05rem;
  color: var(--muted);
  font-weight: 600;
}
.compare-diff {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  margin-top: 0.8rem;
}
.compare-diff td {
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--border);
}
.compare-diff td:first-child { color: var(--muted); font-size: 0.8rem; }

/* ── Artist page ─────────────────────────────────────────── */
.artist-header { margin-bottom: 1.5rem; }
.artist-stats {
  display: flex;
  gap: 1.5rem;
  margin-top: 0.6rem;
  font-size: 0.82rem;
  color: var(--muted);
}

/* ── Audio player ────────────────────────────────────── */
.audio-player {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.55rem 0.8rem;
  background: rgba(255,255,255,0.04);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}
.audio-btn {
  background: none;
  border: none;
  color: var(--text);
  cursor: pointer;
  font-size: 1rem;
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  flex-shrink: 0;
}
.audio-btn:hover { background: rgba(255,255,255,0.08); }
.audio-progress {
  flex: 1;
  height: 3px;
  background: rgba(0,0,0,0.12);
  border-radius: 2px;
  overflow: hidden;
}
.audio-progress__fill {
  height: 100%;
  background: var(--accent);
  width: 0%;
  transition: width 0.1s linear;
  pointer-events: none;
}
.audio-time {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

/* Studio waveform strip */
.studio-waveform {
  display: block;
  width: 100%;
  height: 48px;
  background: rgba(5,5,10,0.6);
  border: 1px solid var(--border);
  border-top: none;
  cursor: pointer;
}

/* Drop-to-listen zone */
.audio-drop {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
  padding: 0.9rem;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  text-align: center;
  cursor: pointer;
}
.audio-drop.drag-over { border-color: var(--accent); }
.audio-drop__icon { font-size: 1.4rem; opacity: 0.5; }

/* Studio viewer column (canvas + waveform + player stacked) */
.studio-viewer-col {
  display: flex;
  flex-direction: column;
}

/* ── Fullscreen button ───────────────────────────────── */
.fullscreen-btn {
  background: none;
  border: none;
  color: rgba(255,255,255,0.65);
  cursor: pointer;
  font-size: 1.05rem;
  padding: 0.15rem 0.4rem;
  border-radius: 3px;
  line-height: 1;
  flex-shrink: 0;
}
.fullscreen-btn:hover { color: #fff; background: rgba(255,255,255,0.1); }
:fullscreen .sg-viewer,
:fullscreen #canvasWrapper { border-radius: 0; }

/* ── Gallery card like button ────────────────────────── */
.gallery-card__img-link { position: relative; }

.card-like {
  position: absolute;
  bottom: 0.5rem;
  right: 0.5rem;
  background: rgba(0,0,0,0.55);
  border: 1px solid rgba(255,255,255,0.15);
  color: rgba(255,255,255,0.75);
  border-radius: 20px;
  padding: 0.2rem 0.55rem;
  font-size: 0.75rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.3rem;
  transition: background 0.15s, color 0.15s, transform 0.1s;
  backdrop-filter: blur(4px);
  z-index: 1;
}
.card-like:hover  { background: rgba(181,41,43,0.7); color: #fff; }
.card-like.liked  { background: rgba(181,41,43,0.6); color: #fff; }
.card-like.liked:hover { transform: scale(1.05); }

/* ── AI Paint viewer ─────────────────────────────────── */
.ai-paint-viewer {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-bottom: 1rem;
}
.ai-paint-img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  display: block;
}
.ai-paint-btn {
  background: linear-gradient(135deg, rgba(181,41,43,0.15), rgba(100,60,180,0.15));
  border-color: rgba(181,41,43,0.35);
}
.ai-paint-btn:hover {
  background: linear-gradient(135deg, rgba(181,41,43,0.25), rgba(100,60,180,0.25));
  border-color: var(--accent);
}

/* ── Job tracker floating widget ─────────────────────────── */
.job-tracker {
  position: fixed;
  bottom: 1.2rem;
  right: 1.2rem;
  z-index: 1000;
  background: var(--surface, #fff);
  border: 1px solid var(--border, #e5e2db);
  border-radius: var(--radius, 8px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
  min-width: 280px;
  max-width: 360px;
  font-size: 0.82rem;
  overflow: hidden;
}
.jt-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 0.8rem;
  background: var(--bg, #f5f2ec);
  border-bottom: 1px solid var(--border, #e5e2db);
}
.jt-title { font-weight: 600; font-size: 0.8rem; letter-spacing: 0.04em; }
.jt-close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted, #888);
  font-size: 0.85rem;
  padding: 0 0.2rem;
  line-height: 1;
}
.jt-close:hover { color: var(--text, #222); }
.jt-jobs { padding: 0.5rem 0.8rem 0.7rem; display: flex; flex-direction: column; gap: 0.6rem; }
.jt-row { display: flex; flex-direction: column; gap: 0.25rem; }
.jt-filename {
  font-size: 0.78rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text, #222);
  font-weight: 500;
}
.jt-bar-wrap {
  height: 4px;
  background: var(--border, #e5e2db);
  border-radius: 2px;
  overflow: hidden;
}
.jt-bar-fill {
  height: 100%;
  background: var(--accent, #b5292b);
  border-radius: 2px;
  transition: width 0.4s ease;
}
.jt-status { font-size: 0.75rem; color: var(--text-muted, #888); }
.jt-link { color: var(--accent, #b5292b); text-decoration: none; font-weight: 500; }
.jt-link:hover { text-decoration: underline; }

