/* ═══════════════════════════════════════════════════
   NUN — main.css
   Design tokens, reset, global components, layout
═══════════════════════════════════════════════════ */

/* ─── Fonts ──────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Syne:wght@400;500;600;700;800&family=Geist:wght@300;400;500;600;700&display=swap');

/* ─── Variables ──────────────────────────────────── */
:root {
  /* Layout */
  --sidebar-w:  232px;
  --queue-w:    320px;
  --header-h:    52px;
  /* T5: player más compacto (el waveform integra progreso, sobra una fila) */
  --player-h:    76px;

  /* Border radius */
  --radius:      8px;
  --radius-sm:   4px;
  --radius-md:   8px;
  --radius-lg:  14px;
  --radius-full: 9999px;

  /* Backgrounds */
  --bg-primary:   #12111A;
  --bg-secondary: #1E1C2E;
  --bg-card:      #1E1C2E;
  --bg-hover:     #252240;
  --bg-elevated:  #2E2A4A;

  /* Accents */
  --accent:        #7F77DD;
  --accent-2:      #534AB7;
  --accent-3:      #AFA9EC;
  --accent-strong: #534AB7;
  --accent-soft:   #AFA9EC;
  /* T7: tripletes RGB — permiten tematizar todos los rgba(acento, alpha) */
  --accent-rgb:  127,119,221;
  --accent2-rgb: 83,74,183;
  --glass-rgb:   18,17,26;
  color-scheme: dark;

  /* Text */
  --text-primary:   #F1EFE8;
  --text-secondary: #AFA9EC;
  /* #6B658C daba 3.06:1 sobre --bg-secondary (WCAG AA pide 4.5:1); #8E88B0 da ~5:1 */
  --text-muted:     #8E88B0;

  /* Borders — very subtle, Notion-style */
  --border:       rgba(255,255,255,.07);
  --border-light: rgba(255,255,255,.13);

  /* Status */
  --danger:  #E05252;
  --success: #4CAF7D;
  --warning: #D4853A;

  /* Shadows */
  --shadow: 0 4px 20px rgba(12,11,20,.7);
  --shadow-lg: 0 12px 48px rgba(12,11,20,.85);

  /* Transitions */
  --transition-fast: .1s ease;
  --transition-base: .18s ease;
}

/* ═══════════════════════════════════════════════════
   T7 — Modo claro "Studio Light" (Propuesta F)
   El lila se recalibra para fondos claros: #7F77DD no
   cumple contraste sobre blanco — relleno #6F61E8,
   texto tintado #5B4BD6 (AA verificado).
═══════════════════════════════════════════════════ */
[data-theme="light"] {
  color-scheme: light;

  --bg-primary:   #F7F6FA;
  --bg-secondary: #EFEDF5;
  --bg-card:      #FFFFFF;
  --bg-hover:     #F1EFF7;
  --bg-elevated:  #FFFFFF;

  --accent:        #6F61E8;
  --accent-2:      #5B4BD6;
  --accent-3:      #5B4BD6;
  --accent-strong: #5B4BD6;
  --accent-soft:   #5B4BD6;
  --accent-rgb:    111,97,232;
  --accent2-rgb:   91,75,214;
  --glass-rgb:     247,246,250;

  --text-primary:   #1B1826;
  --text-secondary: #56506B;
  --text-muted:     #8079A0;

  --border:       #E8E5F0;
  --border-light: #DDD9E8;

  --shadow:    0 4px 20px rgba(27,24,38,.10);
  --shadow-lg: 0 12px 48px rgba(27,24,38,.16);
}

/* Relaciones que no salen solas de los tokens */
[data-theme="light"] .track-card {
  background: var(--bg-card); /* también en móvil (pisa el bg-secondary del boardless) */
  border-color: #E5E2EF;
  box-shadow: 0 1px 3px rgba(27,24,38,.06);
}
[data-theme="light"] .track-card:hover { box-shadow: 0 3px 10px rgba(27,24,38,.10); }
[data-theme="light"] ::-webkit-scrollbar-thumb { background: #D5D1E8; }
[data-theme="light"] .btn-primary:hover { background: var(--accent-2); }
[data-theme="light"] .btn-ghost:hover { border-color: #CFCADF; }
[data-theme="light"] .color-dot.selected { border-color: rgba(27,24,38,.55); }

/* ─── Reset ──────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 15px; }

body {
  font-family: 'Geist', 'Inter', system-ui, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ─── Scrollbar ──────────────────────────────────── */
::-webkit-scrollbar       { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--bg-elevated); border-radius: var(--radius-full); }
::-webkit-scrollbar-thumb:hover { background: var(--accent-strong); }

::selection { background: rgba(var(--accent-rgb),.35); color: var(--text-primary); }

/* ─── Utility ────────────────────────────────────── */
.hidden { display: none !important; }
.mobile-only { display: none !important; }

/* ─── Buttons ────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 13px;
  border: none;
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast), opacity var(--transition-fast);
  white-space: nowrap;
  line-height: 1;
  letter-spacing: -.01em;
}
.btn:active { opacity: .85; }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-primary:hover { background: #9590E8; }

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border-light);
}
.btn-ghost:hover { background: var(--bg-hover); color: var(--text-primary); border-color: rgba(255,255,255,.18); }

.btn-danger {
  background: var(--danger);
  color: #fff;
}
.btn-danger:hover { background: #e86b6b; }

.btn-icon {
  padding: 6px;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text-muted);
  border: none;
}
.btn-icon:hover { background: var(--bg-hover); color: var(--text-primary); }

.btn-full { width: 100%; justify-content: center; }
.btn-sm   { padding: 5px 10px; font-size: 12px; }

.btn-link {
  background: none;
  border: none;
  color: var(--accent-soft);
  font-family: inherit;
  font-size: inherit;
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: rgba(175,169,236,.4);
}
.btn-link:hover { color: var(--accent); text-decoration-color: var(--accent); }

/* ─── Badge / tag ────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 500;
  background: var(--bg-elevated);
  color: var(--text-secondary);
  border: 1px solid var(--border-light);
}

/* ─── Form fields ────────────────────────────────── */
.field { display: flex; flex-direction: column; gap: 5px; }
.field label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .06em;
}

.field input,
.field textarea,
.field select {
  background: var(--bg-elevated);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 14px;
  padding: 9px 12px;
  transition: border-color var(--transition-fast);
  resize: none;
}
.field input:focus,
.field textarea:focus,
.field select:focus { outline: none; border-color: var(--accent); }
.field input::placeholder,
.field textarea::placeholder { color: var(--text-muted); }

.field-row { flex-direction: row; gap: 12px; }
.field-row > div { display: flex; flex-direction: column; gap: 5px; }
.field-row input { width: 100%; }

/* ─── Tags input ─────────────────────────────────── */
.tags-input-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 6px 10px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  min-height: 38px;
  cursor: text;
  transition: border-color var(--transition-fast);
}
.tags-input-wrap:focus-within { border-color: var(--accent); }
.tags-input-wrap input {
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-size: 13px;
  padding: 0;
  flex: 1;
  min-width: 80px;
  font-family: inherit;
}
.tags-input-wrap input:focus { outline: none; }

.tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  background: rgba(var(--accent-rgb),.15);
  border: 1px solid rgba(var(--accent-rgb),.3);
  border-radius: var(--radius-full);
  font-size: 11px;
  color: var(--accent-soft);
}
.tag-chip button {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  padding: 0;
  font-size: 13px;
  line-height: 1;
  display: flex;
}
.tag-chip button:hover { color: var(--danger); }

/* ─── Color picker row ───────────────────────────── */
.color-row { display: flex; align-items: center; gap: 12px; }
.color-row input[type="color"] {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-light);
  cursor: pointer;
  background: none;
  padding: 2px;
}
.color-presets { display: flex; gap: 6px; }
.color-dot {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform var(--transition-fast), border-color var(--transition-fast);
}
.color-dot:hover { transform: scale(1.2); }
.color-dot.selected { border-color: rgba(255,255,255,.8); }

/* ─── Dropdown ───────────────────────────────────── */
.dropdown { position: relative; }
.dropdown-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  background: var(--bg-elevated);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 4px;
  min-width: 168px;
  z-index: 200;
  box-shadow: var(--shadow);
  display: none;
}
.dropdown.open .dropdown-menu,
.dropdown-menu.floating-menu-open { display: block; }
.dropdown-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 7px 10px;
  background: none;
  border: none;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: 13px;
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
  text-decoration: none;
}
.dropdown-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.dropdown-item.danger { color: var(--danger); }
.dropdown-item svg { flex-shrink: 0; opacity: .7; }
.dropdown-item:hover svg { opacity: 1; }

/* ─── Header ─────────────────────────────────────── */
#app-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--header-h);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 16px;
  background: rgba(var(--glass-rgb),.92);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  z-index: 100;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.logo-icon {
  font-size: 20px;
  color: var(--accent);
  display: flex;
  align-items: center;
}

.header-title {
  font-family: 'Syne', system-ui, sans-serif;
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -.02em;
}

.header-center {
  flex: 1;
  max-width: 320px;
  margin: 0 auto;
}

.search-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  padding: 6px 13px;
  transition: border-color var(--transition-fast);
}
.search-wrap:focus-within { border-color: rgba(var(--accent-rgb),.5); }
.search-wrap svg { color: var(--text-muted); flex-shrink: 0; }
.search-wrap input {
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 13px;
  font-family: inherit;
  width: 100%;
}
.search-wrap input:focus { outline: none; }
.search-wrap input::placeholder { color: var(--text-muted); }

.header-right {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.storage-indicator {
  font-size: 11px;
  color: var(--text-muted);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  padding: 3px 9px;
  cursor: default;
  font-variant-numeric: tabular-nums;
}
.storage-indicator.warn  { color: var(--warning); border-color: rgba(212,133,58,.35); }
.storage-indicator.alert { color: var(--danger);  border-color: rgba(224,82,82,.35); }

.total-badge {
  font-size: 11px;
  color: var(--text-muted);
  padding: 3px 9px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
}

/* ─── Login ──────────────────────────────────────── */
#login-section {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-primary);
}

.login-card {
  width: 100%;
  max-width: 360px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 40px 36px;
  box-shadow: var(--shadow-lg);
  animation: scaleIn .22s ease;
}

.login-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: center;
  margin-bottom: 36px;
}
.login-logo .logo-icon {
  font-size: 28px;
  color: var(--accent);
}
.login-logo h1 {
  font-family: 'Syne', system-ui, sans-serif;
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -.03em;
}

#login-form,
#forgot-form { display: flex; flex-direction: column; gap: 14px; }

.login-error {
  font-size: 13px;
  color: var(--danger);
  text-align: center;
  min-height: 20px;
}

.login-hint {
  font-size: 13px;
  color: var(--text-secondary);
  text-align: center;
  line-height: 1.6;
}

.login-forgot {
  text-align: center;
  font-size: 12px;
}

#forgot-section,
#invite-section,
#reset-section {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
}

/* ─── Toast ──────────────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: calc(var(--player-h) + 16px);
  right: 20px;
  display: flex;
  flex-direction: column-reverse;
  gap: 6px;
  z-index: 9999;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow);
  animation: slideUp .22s ease;
  max-width: 320px;
  border: 1px solid transparent;
}
.toast-success { background: #0e1f16; color: var(--success); border-color: rgba(76,175,125,.25); }
.toast-error   { background: #1f0e0e; color: var(--danger);  border-color: rgba(224,82,82,.25); }
.toast-info    { background: #13112a; color: var(--accent-soft); border-color: rgba(var(--accent-rgb),.25); }

/* ─── Session warning banner — SEC.13 ───────────────── */
.session-warning-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 10px 20px;
  background: #7c3c00;
  color: #ffd580;
  font-size: 13px;
  font-weight: 500;
  border-bottom: 1px solid #a35200;
  animation: slideDown .25s ease;
}
.session-warning-banner.hidden { display: none; }
@keyframes slideDown {
  from { opacity: 0; transform: translateY(-100%); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ─── Animations ──────────────────────────────────── */
@keyframes scaleIn {
  from { opacity: 0; transform: scale(.96); }
  to   { opacity: 1; transform: scale(1); }
}
@keyframes slideUp {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ─── Sidebar ────────────────────────────────────── */
#sidebar {
  position: fixed;
  top: var(--header-h);
  left: 0;
  bottom: 0;
  width: var(--sidebar-w);
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  overflow-x: hidden;
  padding: 16px 12px 80px;
  z-index: 50;
  display: flex;
  flex-direction: column;
  gap: 20px;
  transition: transform .22s ease;
}

.sidebar-hidden #sidebar {
  transform: translateX(calc(-1 * var(--sidebar-w)));
  pointer-events: none;
}
.sidebar-hidden #board-container { left: 0; }

body.player-visible #sidebar {
  padding-bottom: calc(var(--player-h) + 24px);
}

.sidebar-section {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.sidebar-section-title {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .1em;
  padding: 0 2px 6px;
  border-bottom: 1px solid var(--border);
}

.sidebar-filter-item {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 3px 2px;
  border-radius: var(--radius-sm);
  transition: color var(--transition-fast);
  user-select: none;
}
.sidebar-filter-item:hover { color: var(--text-primary); }

.sidebar-checkbox {
  width: 13px;
  height: 13px;
  accent-color: var(--accent);
  cursor: pointer;
  flex-shrink: 0;
}

.sidebar-tag {
  display: inline-block;
  padding: 1px 7px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 500;
  border: 1px solid;
}

.bpm-range {
  display: flex;
  align-items: center;
  gap: 6px;
}
.bpm-range input {
  width: 64px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 12px;
  padding: 5px 8px;
  text-align: center;
}
.bpm-range input:focus { outline: none; border-color: var(--accent); }
.bpm-range span { color: var(--text-muted); font-size: 12px; }

#btn-clear-filters {
  width: 100%;
  padding: 7px;
  background: transparent;
  border: 1px dashed var(--border-light);
  border-radius: var(--radius-md);
  color: var(--text-muted);
  font-size: 11px;
  font-family: inherit;
  cursor: pointer;
  transition: border-color var(--transition-fast), color var(--transition-fast);
  margin-top: auto;
}
#btn-clear-filters:hover { border-color: var(--accent); color: var(--accent); }

.tags-count {
  font-size: 10px;
  color: var(--text-muted);
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
}

/* ─── Space selector ─────────────────────────────── */
#space-selector-section {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-primary);
}

.space-selector-card {
  width: 100%;
  max-width: 440px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 40px 36px;
  box-shadow: var(--shadow-lg);
  animation: scaleIn .22s ease;
}

.space-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.space-card {
  width: 100%;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 18px;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  transition: border-color var(--transition-fast), background var(--transition-fast);
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.space-card:hover {
  border-color: rgba(var(--accent-rgb),.5);
  background: var(--bg-hover);
}
.space-card-name {
  font-family: 'Syne', system-ui, sans-serif;
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -.02em;
}
.space-card-meta {
  display: flex;
  align-items: center;
  gap: 10px;
}
.space-role-badge {
  font-size: 11px;
  font-weight: 500;
  color: var(--accent-soft);
  background: rgba(var(--accent-rgb),.12);
  border: 1px solid rgba(var(--accent-rgb),.25);
  border-radius: var(--radius-full);
  padding: 2px 8px;
}
.space-storage {
  font-size: 11px;
  color: var(--text-muted);
}

/* ─── Space name badge in header ─────────────────── */
/* T6: sin chrome propio — el pill lo pone su contenedor .space-switch */
.space-name-badge {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.space-name-input {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-primary);
  background: var(--bg-elevated);
  border: 1px solid var(--accent);
  border-radius: var(--radius-full);
  padding: 3px 10px;
  width: 160px;
  outline: none;
  font-family: inherit;
}

/* ─── Visibility button on card ──────────────────── */
.card-visibility-btn {
  background: none;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  padding: 2px 3px;
  border-radius: var(--radius-sm);
  opacity: .45;
  transition: opacity var(--transition-fast);
  line-height: 1;
  color: var(--text-secondary);
}
.card-visibility-btn:hover { opacity: 1; }
.card-visibility-btn.vis-private { opacity: .9; color: var(--warning); }
.card-visibility-btn.vis-custom  { opacity: .9; color: var(--accent-soft); }

/* ─── Project label on card ──────────────────────── */
.project-label {
  display: inline-block;
  padding: 2px 7px;
  border-radius: var(--radius-full);
  font-size: 10px;
  font-weight: 600;
  border: 1px solid;
  letter-spacing: .01em;
}

.project-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ─── Radio labels (visibility modal) ────────────── */
.radio-label {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 7px 10px;
  border-radius: var(--radius-md);
  transition: background var(--transition-fast), color var(--transition-fast);
}
.radio-label:hover { background: var(--bg-hover); color: var(--text-primary); }
.radio-label input[type="radio"] {
  accent-color: var(--accent);
  width: 14px;
  height: 14px;
  cursor: pointer;
}
.radio-label svg { flex-shrink: 0; opacity: .7; }

/* ─── Projects manage panel in sidebar ───────────── */
.sidebar-section--manage {
  border-top: 1px solid var(--border);
  padding-top: 14px;
}

.project-manage-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 0;
  font-size: 12px;
  color: var(--text-secondary);
}
.project-manage-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.btn-project-edit, .btn-project-delete {
  padding: 3px 5px;
  font-size: 11px;
  border-radius: var(--radius-sm);
  opacity: .5;
}
.btn-project-edit:hover, .btn-project-delete:hover { opacity: 1; }

/* ─── Activity panel ─────────────────────────────── */
.activity-panel {
  position: fixed;
  top: var(--header-h);
  right: 0;
  bottom: 0;
  width: 460px;
  max-width: 100vw;
  background: var(--bg-secondary);
  border-left: 1px solid var(--border);
  z-index: 90;
  display: flex;
  flex-direction: column;
  animation: slideIn .18s ease;
}

@keyframes slideIn {
  from { transform: translateX(100%); }
  to   { transform: translateX(0); }
}

.activity-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  flex-wrap: wrap;
}
.activity-header h2 {
  font-family: 'Syne', system-ui, sans-serif;
  font-size: 15px;
  font-weight: 600;
  flex: 1;
  letter-spacing: -.02em;
}

.activity-filters {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.activity-filters select {
  background: var(--bg-elevated);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 12px;
  padding: 4px 8px;
  cursor: pointer;
}

.activity-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px 16px;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.activity-entry {
  display: grid;
  grid-template-columns: 110px 76px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 7px 8px;
  border-radius: var(--radius-md);
  font-size: 12px;
  transition: background var(--transition-fast);
}
.activity-entry:hover { background: var(--bg-hover); }

.activity-time   { color: var(--text-muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.activity-user   { color: var(--accent-soft); font-weight: 500; }
.activity-action { color: var(--text-secondary); }
.activity-track  { color: var(--text-primary); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.activity-detail { color: var(--text-muted); font-size: 11px; }

.activity-loading,
.activity-empty {
  color: var(--text-muted);
  font-size: 13px;
  padding: 24px 0;
  text-align: center;
}

/* ─── Loading text ───────────────────────────────── */
.loading-text {
  font-size: 12px;
  color: var(--text-muted);
  padding: 8px 0;
}

/* ─── Comment panel (NC.C) ───────────────────────── */
.comment-panel {
  position: fixed;
  top: var(--header-h);
  right: 0;
  bottom: 0;
  width: 420px;
  max-width: 100vw;
  background: var(--bg-secondary);
  border-left: 1px solid var(--border);
  z-index: 91;
  display: flex;
  flex-direction: column;
  animation: slideIn .18s ease;
  transition: bottom .28s cubic-bezier(.4,0,.2,1);
}
/* Cuando el player está visible, subir el panel para no quedar tapado */
body.player-visible .comment-panel {
  bottom: var(--player-h);
}

.comment-panel-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.comment-panel-title {
  font-family: 'Syne', system-ui, sans-serif;
  font-size: 14px;
  font-weight: 600;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.comment-list {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.comment-loading,
.comment-empty,
.comment-error {
  color: var(--text-muted);
  font-size: 13px;
  padding: 24px 0;
  text-align: center;
}
.comment-error { color: #f87171; }

.comment-item {
  padding: 8px 10px;
  border-radius: var(--radius-md);
  transition: background var(--transition-fast);
}
.comment-item:hover { background: var(--bg-hover); }
.comment-item.depth-1 { margin-left: 18px; border-left: 2px solid var(--border-light); padding-left: 12px; }
.comment-item.depth-2 { margin-left: 32px; border-left: 2px solid var(--border-light); padding-left: 12px; }
.comment-item.depth-3 { margin-left: 44px; border-left: 2px solid var(--border-light); padding-left: 12px; }

.comment-header {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}
.comment-author {
  font-size: 12px;
  font-weight: 600;
  color: var(--accent-soft);
}
.comment-date {
  font-size: 11px;
  color: var(--text-muted);
}
.comment-edited {
  font-size: 11px;
  color: var(--text-muted);
  font-style: italic;
}
.comment-actions {
  margin-left: auto;
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: opacity .12s;
}
.comment-item:hover .comment-actions { opacity: 1; }

.comment-action-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  padding: 2px 4px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  font-size: 11px;
  transition: color .12s, background .12s;
}
.comment-action-btn:hover { color: var(--text-primary); background: var(--bg-elevated); }
.comment-action-btn.danger:hover { color: #f87171; }

.comment-body {
  font-size: 13px;
  color: var(--text-primary);
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}
.comment-deleted { color: var(--text-muted); font-style: italic; }

.comment-ts-chip {
  background: var(--bg-elevated);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-full);
  color: var(--accent-soft);
  font-size: 11px;
  padding: 1px 7px;
  cursor: pointer;
  transition: background .12s;
}
.comment-ts-chip:hover { background: var(--accent); color: #fff; }

.comment-edit-form {
  margin-top: 6px;
}
.comment-edit-input {
  width: 100%;
  background: var(--bg-elevated);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 13px;
  padding: 7px 10px;
  resize: vertical;
  min-height: 60px;
  box-sizing: border-box;
}
.comment-edit-ts-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 4px 0;
}
.comment-edit-ts {
  background: var(--bg-elevated);
  border: 1px solid var(--border-light);
  border-radius: 6px;
  color: var(--text-primary);
  font-size: 12px;
  padding: 3px 7px;
}
.comment-edit-actions {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  margin-top: 6px;
}

.comment-replies { margin-top: 2px; }

.comment-compose {
  border-top: 1px solid var(--border);
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex-shrink: 0;
}

.comment-reply-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-elevated);
  border-radius: var(--radius-sm);
  padding: 4px 10px;
  font-size: 12px;
  color: var(--text-secondary);
}

.comment-ts-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.comment-input-row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}
.comment-input {
  flex: 1;
  background: var(--bg-elevated);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 13px;
  padding: 8px 10px;
  resize: none;
  box-sizing: border-box;
}
.comment-input:focus {
  outline: none;
  border-color: var(--accent);
}

/* ─── Track card badges (New + unread) ───────────── */
/* Punto discreto en vez del antiguo badge "NEW": señala lo mismo sin competir
   con el título cuando media columna es nueva */
.badge-new-track {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  display: inline-block;
  flex-shrink: 0;
}

.badge-unread-comment {
  display: flex;
  align-items: center;
  color: var(--accent-soft);
  opacity: .85;
}

/* ─── Comment history modal ──────────────────────── */
.comment-history-entry {
  background: var(--bg-elevated);
  border-radius: var(--radius-md);
  padding: 8px 12px;
}
.comment-history-meta {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.comment-history-content {
  font-size: 13px;
  color: var(--text-primary);
  white-space: pre-wrap;
  word-break: break-word;
}

/* ═══════════════════════════════════════════════════
   Studio Dark Pro T3 — header, sidebar chips, key select
═══════════════════════════════════════════════════ */

/* Pill de espacio (nombre + cambio combinados) */
.space-switch {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  cursor: pointer;
  transition: border-color var(--transition-fast), background var(--transition-fast);
  max-width: 220px;
}
.space-switch:hover { border-color: rgba(var(--accent-rgb),.45); background: var(--bg-hover); }
.space-switch.single { cursor: default; }
.space-switch.single:hover { border-color: var(--border); background: var(--bg-elevated); }
.space-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); flex-shrink: 0; }
.space-chev { font-size: 9px; color: var(--text-muted); }
.space-switch .space-name-badge { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Hint de atajo en la búsqueda */
.search-kbd {
  flex-shrink: 0;
  font-size: 10px;
  padding: 2px 6px;
  border: 1px solid var(--border-light);
  border-radius: 4px;
  color: var(--text-muted);
}

/* Almacenamiento como micro-barra */
.storage-indicator {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-width: 92px;
}
.storage-pct { font-size: 10px; }
.storage-bar {
  flex: 1;
  height: 3px;
  background: var(--bg-hover);
  border-radius: 2px;
  overflow: hidden;
}
.storage-bar i { display: block; height: 100%; background: var(--accent); border-radius: 2px; }
.storage-indicator.warn  .storage-bar i { background: var(--warning); }
.storage-indicator.alert .storage-bar i { background: var(--danger); }

/* Chips de filtro en la sidebar (mismo lenguaje que los tags de card) */
.chip-row { display: flex; flex-wrap: wrap; gap: 5px; }
.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 11.5px;
  font-weight: 500;
  font-family: inherit;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  cursor: pointer;
  transition: border-color var(--transition-fast), background var(--transition-fast), color var(--transition-fast);
}
.filter-chip:hover { border-color: rgba(var(--accent-rgb),.4); color: var(--text-primary); }
.filter-chip.on {
  background: rgba(var(--accent-rgb),.14);
  border-color: rgba(var(--accent-rgb),.45);
  color: var(--accent-3);
}
.chip-n { font-size: 10px; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.filter-chip.on .chip-n { color: var(--accent-3); opacity: .8; }

/* Proyectos como lista navegable */
.project-row {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 7px 9px;
  background: none;
  border: none;
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
  text-align: left;
  transition: background var(--transition-fast), color var(--transition-fast);
}
.project-row:hover { background: var(--bg-hover); color: var(--text-primary); }
.project-row.on { background: var(--bg-hover); color: var(--text-primary); }
.project-row-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.project-row .chip-n { flex-shrink: 0; }

/* Selector de escala con buscador (modal de edición) */
.key-select { position: relative; }
.key-select input { width: 100%; }
.key-select-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  max-height: 210px;
  overflow-y: auto;
  background: var(--bg-elevated);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow);
  z-index: 600;
  padding: 4px;
}
.key-option {
  display: block;
  width: 100%;
  padding: 6px 10px;
  background: none;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 13px;
  text-align: left;
  cursor: pointer;
}
.key-option:hover { background: var(--bg-hover); color: var(--text-primary); }
.key-option.on { color: var(--accent-3); background: rgba(var(--accent-rgb),.12); }
.key-option-empty { color: var(--text-muted); font-style: italic; }

/* ═══════════════════════════════════════════════════
   Studio Dark Pro T4 — navegación móvil
═══════════════════════════════════════════════════ */

/* Tabs de columnas: solo móvil (CSS), construidos siempre (JS) */
.column-tabs { display: none; }

/* FAB de subida: solo móvil */
.fab-upload { display: none; }

/* Backdrop del drawer: solo móvil con sidebar abierta */
#sidebar-backdrop { display: none; }

/* ═══════════════════════════════════════════════════
   Mobile responsive — Studio Dark Pro T1
   main.css no tenía NINGUNA media query: la sidebar fija
   de 232px se comía el 62% de un viewport de 375px.
═══════════════════════════════════════════════════ */
@media (max-width: 700px) {
  :root { --player-h: 80px; } /* pill flotante de 60px + márgenes */

  .column-tabs {
    display: flex;
    position: fixed;
    top: var(--header-h);
    left: 0; right: 0;
    z-index: 95;
    gap: 7px;
    padding: 8px 12px;
    overflow-x: auto;
    background: rgba(var(--glass-rgb),.92);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border);
    scrollbar-width: none;
  }
  .column-tabs::-webkit-scrollbar { display: none; }
  .column-tab {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 13px;
    border-radius: var(--radius-full);
    font-family: inherit;
    font-size: 12.5px;
    font-weight: 600;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    color: var(--text-muted);
    white-space: nowrap;
    flex-shrink: 0;
    cursor: pointer;
  }
  .column-tab.on {
    background: rgba(var(--accent-rgb),.14);
    border-color: rgba(var(--accent-rgb),.45);
    color: var(--accent-3);
  }
  .column-tab-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }

  .fab-upload {
    display: flex;
    align-items: center;
    justify-content: center;
    position: fixed;
    right: 18px;
    bottom: 22px;
    width: 56px;
    height: 56px;
    border: none;
    border-radius: 18px;
    background: var(--accent);
    color: #fff;
    box-shadow: 0 10px 30px rgba(var(--accent2-rgb),.55);
    z-index: 380;
    cursor: pointer;
    transition: bottom .28s cubic-bezier(.4,0,.2,1), transform var(--transition-fast);
  }
  .fab-upload:active { transform: scale(.94); }
  body.player-visible .fab-upload { bottom: calc(var(--player-h) + 12px); }

  #sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(9,8,14,.5);
    z-index: 140;
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
  }
  #app-section:not(.sidebar-hidden) #sidebar-backdrop { display: block; }
  /* Sidebar como overlay: flota sobre el board en vez de empujarlo.
     app.js la inicia oculta en móvil; el hamburger la muestra. */
  #sidebar {
    width: min(280px, 84vw);
    z-index: 150;
    border-right: 1px solid var(--border-light);
    box-shadow: var(--shadow-lg);
  }
  /* La sidebar móvil (280px) es más ancha que --sidebar-w (232px):
     el transform debe ser relativo a su propio ancho o deja una franja visible */
  .sidebar-hidden #sidebar { transform: translateX(-105%); }
  #board-container { left: 0 !important; }

  /* Header móvil (mockup): ☰ y ⋯ como botones encajados de 42px, el espacio
     como texto Syne (sin pill — ES el título de la vista), búsqueda como icono
     que expande overlay, y las acciones secundarias viven en el menú ⋯ */
  #app-header { padding: 0 12px; gap: 10px; position: fixed; }
  .logo-icon, .header-title { display: none; }
  .storage-indicator, .total-badge, .search-kbd { display: none; }
  .btn-label { display: none; }
  #btn-edit-space-name, #btn-activity, #btn-select-mode, #btn-add-column { display: none !important; }
  .mobile-only { display: flex !important; }
  .mobile-only.perm-hidden { display: none !important; }

  #app-header .btn-icon, #btn-search-mobile {
    min-width: 42px;
    min-height: 42px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    justify-content: center;
  }

  .space-switch {
    background: none;
    border: none;
    padding: 4px 2px;
    gap: 8px;
    max-width: 48vw;
  }
  .space-switch .space-name-badge {
    font-family: 'Syne', system-ui, sans-serif;
    font-size: 16px;
    font-weight: 700;
    letter-spacing: -.01em;
  }
  .header-right { margin-left: auto; }

  /* Búsqueda: oculta hasta tocar el icono; al abrir cubre el header */
  .header-center { display: none; }
  #app-header.search-open .header-center {
    display: flex;
    align-items: center;
    gap: 4px;
    position: absolute;
    inset: 0;
    padding: 7px 10px;
    background: var(--bg-primary);
    z-index: 10;
    max-width: none;
    margin: 0;
  }
  #app-header.search-open .search-wrap { flex: 1; }
  .btn-search-close {
    background: none;
    border: none;
    color: var(--accent-3);
    font-family: inherit;
    font-size: 13px;
    font-weight: 500;
    padding: 8px 10px;
    cursor: pointer;
    flex-shrink: 0;
  }

  /* iOS hace zoom automático en inputs con font-size < 16px */
  .search-wrap input, .field input, .field textarea, .field select { font-size: 16px; }

  /* Touch targets: sin hover en táctil, los botones deben verse y ser pulsables */
  .btn-icon { min-width: 38px; min-height: 38px; justify-content: center; }
}
