/* ============================================
   TrackBranch — Music Collaboration App
   Destiny-inspired visual language, tuned for
   a music-production / studio-warmth register.
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Rajdhani:wght@400;500;600;700&family=Inter:wght@400;500;600&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
    /* Surfaces — dark-first, layered by elevation */
    --tb-bg:            #0A0A0F;
    --tb-bg-deep:       #070709;
    --tb-surface:       #12121A;
    --tb-surface-2:     #1A1A26;
    --tb-surface-hover: #222230;
    --tb-glass:         rgba(255, 255, 255, 0.03);
    --tb-glass-hover:   rgba(255, 255, 255, 0.06);

    /* Borders — thin, structural */
    --tb-border:         rgba(255, 255, 255, 0.08);
    --tb-border-strong:  rgba(255, 255, 255, 0.15);
    --tb-border-subtle:  rgba(255, 255, 255, 0.04);

    /* Type */
    --tb-text:           #E8E6E3;
    --tb-text-muted:     #8A8A8F;
    --tb-text-dim:       #55555A;
    --tb-text-inverse:   #0A0A0F;

    /* Accents
       primary  — cool engineering blue (commits, branches, selection)
       gold     — warm master-tape brass (current/approved, timecode)
       signal   — muted violet, used sparingly (merges, highlights) */
    --tb-primary:        #78B4FF;
    --tb-primary-hover:  #9AC6FF;
    --tb-primary-glow:   rgba(120, 180, 255, 0.15);
    --tb-accent:         #C4A24E;
    --tb-accent-hover:   #D7B868;
    --tb-signal:         #9B7FD4;

    /* Status — muted so the UI doesn't shout */
    --tb-success:        #4ADE80;
    --tb-warning:        #FBBF24;
    --tb-danger:         #F87171;
    --tb-info:           var(--tb-primary);

    /* Typography */
    --tb-font-display:   'Rajdhani', 'Exo 2', system-ui, sans-serif;
    --tb-font-body:      'Inter', 'Segoe UI', system-ui, sans-serif;
    --tb-font-mono:      'JetBrains Mono', 'SF Mono', 'Menlo', monospace;

    /* Shape */
    --tb-radius-sm: 2px;
    --tb-radius:    4px;
    --tb-radius-lg: 6px;

    /* Layout */
    --tb-sidebar-width: 248px;
    --tb-nav-height:    52px;
    --tb-content-max:   1200px;

    /* Motion */
    --tb-t-fast: 150ms ease;
    --tb-t-base: 220ms ease;
}

/* ---------- Base ---------- */
html, body {
    background: var(--tb-bg);
    color: var(--tb-text);
    font-family: var(--tb-font-body);
    font-size: 15px;
    font-feature-settings: "ss01", "cv11";
    margin: 0;
    min-height: 100vh;
}

body {
    background:
        radial-gradient(ellipse 80% 60% at 75% -10%, rgba(120, 180, 255, 0.05), transparent 60%),
        radial-gradient(ellipse 60% 60% at 15% 110%, rgba(196, 162, 78, 0.03), transparent 60%),
        var(--tb-bg);
}

a { color: var(--tb-primary); text-decoration: none; transition: color var(--tb-t-fast); }
a:hover { color: var(--tb-primary-hover); }

::selection { background: rgba(120, 180, 255, 0.25); color: var(--tb-text); }

/* Headings — display family, a bit tight */
h1, h2, h3, h4, h5, h6 {
    font-family: var(--tb-font-display);
    font-weight: 600;
    color: var(--tb-text);
    letter-spacing: 0.01em;
    margin: 0 0 0.5em;
}
h1 { font-size: 2rem; letter-spacing: 0.03em; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.2rem; }
h4 { font-size: 1.05rem; }
h5 { font-size: 0.95rem; }

p, span, div, li, td, th { font-family: inherit; }
strong, b { color: var(--tb-text); font-weight: 600; }
small { color: var(--tb-text-muted); }
.text-muted { color: var(--tb-text-muted) !important; }

/* ---------- App shell ---------- */
.tb-app {
    display: flex;
    min-height: 100vh;
}

.tb-main {
    flex: 1;
    margin-left: var(--tb-sidebar-width);
    min-width: 0;
}

.tb-toolbar {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 12px;
    height: var(--tb-nav-height);
    padding: 0 24px;
    border-bottom: 1px solid var(--tb-border);
    background: rgba(10, 10, 15, 0.75);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    position: sticky;
    top: 0;
    z-index: 40;
}

.tb-content {
    padding: 28px 32px 48px;
    max-width: var(--tb-content-max);
}

/* ---------- Sidebar ---------- */
.tb-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--tb-sidebar-width);
    height: 100vh;
    background: linear-gradient(180deg, var(--tb-surface) 0%, var(--tb-bg-deep) 100%);
    border-right: 1px solid var(--tb-border);
    overflow-y: auto;
    z-index: 100;
}

.tb-sidebar::before {
    content: '';
    position: absolute;
    top: 0; right: 0;
    width: 1px; height: 100%;
    background: linear-gradient(180deg,
        transparent,
        var(--tb-border-strong) 15%,
        var(--tb-border-strong) 85%,
        transparent);
    pointer-events: none;
}

.tb-sidebar-brand {
    padding: 18px 20px 16px;
    border-bottom: 1px solid var(--tb-border);
}

.tb-sidebar-brand a {
    color: var(--tb-text);
    display: flex;
    align-items: center;
    gap: 10px;
    font-family: var(--tb-font-display);
    font-size: 1.05rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}
.tb-sidebar-brand a:hover { color: var(--tb-primary); }

.tb-brand-sub {
    display: block;
    padding-left: 42px;
    margin-top: 2px;
    font-family: var(--tb-font-mono);
    font-size: 0.65rem;
    letter-spacing: 0.2em;
    color: var(--tb-text-dim);
    text-transform: uppercase;
}

.tb-logo-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, var(--tb-primary), var(--tb-signal));
    border-radius: var(--tb-radius);
    color: var(--tb-text-inverse);
    font-family: var(--tb-font-display);
    font-weight: 700;
    font-size: 0.75rem;
    letter-spacing: 0.08em;
    position: relative;
}
.tb-logo-icon::after {
    content: '';
    position: absolute;
    inset: 3px;
    border: 1px solid rgba(10, 10, 15, 0.35);
    border-radius: 2px;
    pointer-events: none;
}

.tb-sidebar-section {
    padding: 14px 0;
    border-bottom: 1px solid var(--tb-border-subtle);
}
.tb-sidebar-section:last-child { border-bottom: none; }

.tb-sidebar-heading {
    padding: 4px 20px 8px;
    font-family: var(--tb-font-display);
    font-size: 0.68rem;
    font-weight: 600;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--tb-text-dim);
}
.tb-sidebar-heading::before {
    content: '// ';
    color: var(--tb-primary);
    opacity: 0.55;
}

.tb-nav-link {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 7px 20px 7px 24px;
    color: var(--tb-text-muted);
    font-size: 0.9rem;
    font-weight: 500;
    transition: color var(--tb-t-fast), background-color var(--tb-t-fast);
}
.tb-nav-link:hover { color: var(--tb-text); background: var(--tb-glass-hover); }

.tb-nav-link::before {
    content: '';
    position: absolute;
    left: 0;
    top: 6px; bottom: 6px;
    width: 2px;
    background: transparent;
    transition: background-color var(--tb-t-fast);
}
.tb-nav-link.active {
    color: var(--tb-primary);
    background: var(--tb-glass);
}
.tb-nav-link.active::before {
    background: var(--tb-primary);
    box-shadow: 0 0 10px var(--tb-primary-glow);
}

/* ---------- Sidebar toggle (hamburger in toolbar) ---------- */
.tb-sidebar-toggle {
    display: inline-flex;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
    width: 32px;
    height: 32px;
    padding: 7px 8px;
    margin-right: 8px;
    border: 1px solid var(--tb-border);
    border-radius: var(--tb-radius-sm);
    background: var(--tb-glass);
    cursor: pointer;
    transition: background-color var(--tb-t-fast), border-color var(--tb-t-fast);
}
.tb-sidebar-toggle:hover {
    background: var(--tb-glass-hover);
    border-color: var(--tb-primary);
}
.tb-sidebar-toggle-bar {
    display: block;
    height: 2px;
    background: var(--tb-text-muted);
    border-radius: 1px;
    transition: background-color var(--tb-t-fast);
}
.tb-sidebar-toggle:hover .tb-sidebar-toggle-bar { background: var(--tb-text); }

/* Collapsed sidebar — applied to <html> so the early-paint script can
   set it before Blazor hydrates and avoid a flash of the expanded state.
   Strategy: shrink to a 56px rail showing only the brand mark; hide all
   nav sections. The toolbar toggle re-expands when the user needs to
   navigate. (No nav icons exist yet — empty colored rows would be worse
   than hiding.) */
html.tb-sidebar-collapsed {
    --tb-sidebar-width: 56px;
}
html.tb-sidebar-collapsed .tb-sidebar-brand {
    padding: 18px 12px 16px;
    text-align: center;
}
html.tb-sidebar-collapsed .tb-sidebar-brand a {
    gap: 0;
    font-size: 0;
    justify-content: center;
}
html.tb-sidebar-collapsed .tb-sidebar-brand a .tb-logo-icon { font-size: 0.75rem; }
html.tb-sidebar-collapsed .tb-brand-sub { display: none; }
html.tb-sidebar-collapsed .tb-sidebar-section { display: none; }

/* ---------- Toolbar badges ---------- */
.tb-user-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border: 1px solid var(--tb-border);
    border-radius: var(--tb-radius-sm);
    background: var(--tb-glass);
    font-family: var(--tb-font-display);
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--tb-text);
}
.tb-user-badge::before {
    content: '';
    width: 6px; height: 6px;
    background: var(--tb-success);
    border-radius: 50%;
    box-shadow: 0 0 8px rgba(74, 222, 128, 0.6);
}

/* ---------- Section label (// LABEL) ---------- */
.tb-section-label {
    font-family: var(--tb-font-display);
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--tb-primary);
    margin: 0 0 8px;
}
.tb-section-label::before {
    content: '// ';
    opacity: 0.5;
}

.tb-section-label--gold { color: var(--tb-accent); }

/* ---------- Dashboard / Page headers ---------- */
.tb-page-head {
    margin-bottom: 28px;
}
.tb-page-head h2 {
    font-size: 2rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    margin: 2px 0 6px;
}
.tb-page-sub {
    color: var(--tb-text-muted);
    font-size: 0.92rem;
    max-width: 44rem;
    line-height: 1.6;
    margin: 0;
}

.tb-dashboard h2 {
    font-size: 1.75rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

/* KPI row */
.tb-kpi-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-bottom: 8px;
}
.tb-kpi {
    background: var(--tb-surface);
    border: 1px solid var(--tb-border);
    border-radius: var(--tb-radius);
    padding: 14px 16px;
    position: relative;
}
.tb-kpi::before {
    content: '';
    position: absolute;
    top: 0; left: 0; bottom: 0;
    width: 2px;
    background: var(--tb-border-strong);
}
.tb-kpi:nth-child(3)::before { background: var(--tb-primary); box-shadow: 0 0 8px var(--tb-primary-glow); }
.tb-kpi:nth-child(4)::before { background: var(--tb-accent); }

.tb-kpi-label {
    font-family: var(--tb-font-display);
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--tb-text-muted);
    margin-bottom: 6px;
}
.tb-kpi-value {
    font-family: var(--tb-font-display);
    font-weight: 700;
    font-size: 1.8rem;
    color: var(--tb-text);
    letter-spacing: 0.02em;
    line-height: 1;
}
.tb-kpi-value--primary { color: var(--tb-primary); }
.tb-kpi-value--gold { color: var(--tb-accent); }

/* Album link card */
.tb-album-link {
    display: block;
    color: inherit;
    text-decoration: none;
}
.tb-album-link:hover { color: inherit; }

.tb-album-count {
    font-family: var(--tb-font-mono);
    font-size: 0.75rem;
    color: var(--tb-text-muted);
    padding: 2px 8px;
    border: 1px solid var(--tb-border);
    border-radius: var(--tb-radius-sm);
    background: var(--tb-glass);
    white-space: nowrap;
}

@media (max-width: 900px) {
    .tb-kpi-row { grid-template-columns: repeat(2, 1fr); }
}

/* ---------- Cards ---------- */
.tb-card, .card.tb-card {
    background: var(--tb-surface);
    border: 1px solid var(--tb-border);
    border-radius: var(--tb-radius);
    box-shadow: none;
    transition: border-color var(--tb-t-base), background-color var(--tb-t-base);
}

.tb-card .card-header, .card.tb-card .card-header {
    background: transparent;
    border-bottom: 1px solid var(--tb-border);
    padding: 12px 18px;
}
.tb-card .card-header h5 {
    font-family: var(--tb-font-display);
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--tb-text);
    margin: 0;
}
.tb-card .card-header h5::before {
    content: '// ';
    color: var(--tb-primary);
    opacity: 0.5;
}

.tb-card .card-body, .card.tb-card .card-body { padding: 18px; }

.tb-card .card-title {
    font-family: var(--tb-font-display);
    font-weight: 600;
    letter-spacing: 0.02em;
}

.tb-card-hover { cursor: pointer; }
.tb-card-hover:hover {
    border-color: var(--tb-border-strong);
    background: var(--tb-surface-2);
}
.tb-card-hover:hover .card-title { color: var(--tb-primary); }

/* ---------- Status badges (song states) ---------- */
.tb-status-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    border: 1px solid var(--tb-border);
    border-radius: var(--tb-radius-sm);
    font-family: var(--tb-font-display);
    font-size: 0.68rem;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    background: var(--tb-glass);
    color: var(--tb-text-muted);
}
.tb-status-badge::before {
    content: '';
    width: 5px; height: 5px;
    border-radius: 50%;
    background: currentColor;
    opacity: 0.85;
}

.tb-status-idea        { color: #8A8A8F; }
.tb-status-demo        { color: var(--tb-primary); border-color: rgba(120,180,255,0.25); }
.tb-status-recording   { color: var(--tb-signal); border-color: rgba(155,127,212,0.25); }
.tb-status-mixing      { color: var(--tb-warning); border-color: rgba(251,191,36,0.25); }
.tb-status-mastering   { color: var(--tb-accent); border-color: rgba(196,162,78,0.3); }
.tb-status-final       { color: var(--tb-success); border-color: rgba(74,222,128,0.3); }
.tb-status-archived    { color: var(--tb-text-dim); opacity: 0.7; }

/* ---------- Track table ---------- */
.tb-track-table {
    color: var(--tb-text);
    border-collapse: separate;
    border-spacing: 0;
    width: 100%;
}

.tb-track-table thead th {
    border-bottom: 1px solid var(--tb-border);
    color: var(--tb-text-dim);
    font-family: var(--tb-font-display);
    font-size: 0.68rem;
    font-weight: 600;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    padding: 10px 12px;
    background: transparent;
}

.tb-track-row { cursor: pointer; transition: background-color var(--tb-t-fast); }
.tb-track-row:hover { background: var(--tb-glass-hover); }

.tb-track-row td {
    border-bottom: 1px solid var(--tb-border-subtle);
    vertical-align: middle;
    padding: 12px;
}

.tb-track-row td:first-child {
    font-family: var(--tb-font-mono);
    color: var(--tb-accent);
    font-size: 0.82rem;
}

.tb-track-row td strong {
    font-family: var(--tb-font-display);
    font-weight: 600;
    letter-spacing: 0.01em;
}

/* ---------- Presence ---------- */
.tb-presence {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 12px;
    padding: 8px 12px;
    border: 1px solid var(--tb-border);
    border-radius: var(--tb-radius);
    background: var(--tb-glass);
}

.tb-presence-chips {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.tb-presence-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 10px;
    border: 1px solid var(--tb-border);
    border-radius: var(--tb-radius-full);
    background: var(--tb-surface);
    font-family: var(--tb-font-display);
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--tb-text);
}

.tb-presence-dot {
    width: 6px;
    height: 6px;
    background: var(--tb-success);
    border-radius: 50%;
    box-shadow: 0 0 8px rgba(74, 222, 128, 0.55);
    animation: tb-pulse 2.4s ease-in-out infinite;
}

@keyframes tb-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* ---------- Song header ---------- */
.tb-song-header {
    margin-bottom: 18px;
    padding-bottom: 18px;
    border-bottom: 1px solid var(--tb-border);
}
.tb-song-header h2 {
    font-size: 2rem;
    letter-spacing: 0.02em;
    margin: 2px 0 10px;
}
.tb-song-header small a { color: var(--tb-text-muted); }
.tb-song-header small a:hover { color: var(--tb-primary); }

.tb-status-select {
    width: auto;
    background: var(--tb-surface);
    color: var(--tb-text);
    border-color: var(--tb-border);
}

/* ---------- Branch bar / Upload bar ---------- */
.tb-branch-bar {
    padding: 12px 14px;
    margin-bottom: 14px;
    border: 1px solid var(--tb-border);
    border-radius: var(--tb-radius);
    background: var(--tb-glass);
}
.tb-branch-bar .form-label { font-weight: 600; }

.tb-upload-bar {
    padding: 10px 0;
    margin: 10px 0 14px;
}

/* ---------- Action row (branch + resume pill + file upload on one line) ---------- */
.tb-action-row {
    padding: 10px 14px;
    margin-bottom: 14px;
    border: 1px solid var(--tb-border);
    border-radius: var(--tb-radius);
    background: var(--tb-glass);
}
.tb-action-row-main {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}
.tb-action-row-label {
    font-weight: 600;
    margin-bottom: 0 !important;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    font-size: 0.7rem;
    color: var(--tb-text-muted);
}
.tb-action-row-spacer { flex: 1; min-width: 0; }
.tb-action-row-file {
    width: auto !important;
    max-width: 260px;
}

/* ---------- Resume pill (compact "since you last visited") ---------- */
.tb-resume-pill-wrap {
    position: relative;
    display: inline-block;
}
.tb-resume-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 999px;
    border: 1px solid var(--tb-border-strong, var(--tb-border));
    background: rgba(255, 213, 79, 0.08);
    color: var(--tb-text);
    font-size: 0.8rem;
    line-height: 1.2;
    cursor: pointer;
    transition: background-color var(--tb-t-fast), border-color var(--tb-t-fast);
}
.tb-resume-pill:hover {
    background: rgba(255, 213, 79, 0.16);
    border-color: var(--tb-accent, var(--tb-primary));
}
.tb-resume-pill-dot {
    width: 6px; height: 6px;
    border-radius: 50%;
    background: var(--tb-accent, var(--tb-primary));
    box-shadow: 0 0 6px var(--tb-accent, var(--tb-primary));
}
.tb-resume-pill-ago {
    color: var(--tb-text-muted);
    font-size: 0.72rem;
}
.tb-resume-pop {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    z-index: 20;
    min-width: 260px;
    padding: 10px 12px;
    border: 1px solid var(--tb-border);
    border-radius: var(--tb-radius);
    background: var(--tb-surface);
    box-shadow: var(--tb-shadow-md, 0 6px 24px rgba(0,0,0,0.4));
}

/* ---------- Audio player ---------- */
.tb-audio-player {
    margin: 14px 0;
    background: linear-gradient(180deg, var(--tb-surface-2), var(--tb-surface));
    border: 1px solid var(--tb-border);
    border-radius: var(--tb-radius);
    overflow: hidden;
    position: relative;
}
.tb-audio-player::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--tb-primary) 50%, transparent);
    opacity: 0.35;
}

.tb-waveform-container {
    width: 100%;
    height: 128px;
    cursor: crosshair;
    background:
        linear-gradient(90deg,
            transparent 0 calc(10% - 1px),
            var(--tb-border-subtle) calc(10% - 1px) 10%,
            transparent 10% calc(20% - 1px),
            var(--tb-border-subtle) calc(20% - 1px) 20%,
            transparent 20% calc(30% - 1px),
            var(--tb-border-subtle) calc(30% - 1px) 30%,
            transparent 30% calc(40% - 1px),
            var(--tb-border-subtle) calc(40% - 1px) 40%,
            transparent 40% calc(50% - 1px),
            var(--tb-border-subtle) calc(50% - 1px) 50%,
            transparent 50% calc(60% - 1px),
            var(--tb-border-subtle) calc(60% - 1px) 60%,
            transparent 60% calc(70% - 1px),
            var(--tb-border-subtle) calc(70% - 1px) 70%,
            transparent 70% calc(80% - 1px),
            var(--tb-border-subtle) calc(80% - 1px) 80%,
            transparent 80% calc(90% - 1px),
            var(--tb-border-subtle) calc(90% - 1px) 90%,
            transparent 90% 100%);
}

.tb-waveform-canvas {
    width: 100%;
    height: 100%;
    display: block;
}

.tb-transport {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    background: rgba(0, 0, 0, 0.35);
    border-top: 1px solid var(--tb-border);
}

.tb-transport-controls {
    display: flex;
    gap: 8px;
    align-items: center;
}

.tb-play-btn {
    width: 36px; height: 36px;
    border-radius: var(--tb-radius-sm);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-family: var(--tb-font-display);
    font-weight: 700;
    font-size: 0.72rem;
    letter-spacing: 0.1em;
}

.tb-transport-time {
    font-family: var(--tb-font-mono);
    font-size: 0.95rem;
    font-weight: 500;
    letter-spacing: 0.04em;
    color: var(--tb-accent);
}

.tb-rate-select {
    width: 72px;
    background: var(--tb-surface);
    color: var(--tb-text);
    border-color: var(--tb-border);
    font-family: var(--tb-font-mono);
    font-size: 0.82rem;
}

/* ---------- Tabs ---------- */
.tb-tabs {
    border-bottom: 1px solid var(--tb-border) !important;
    margin-top: 18px;
    gap: 0;
}

.tb-tabs .nav-link {
    position: relative;
    color: var(--tb-text-muted);
    background: transparent;
    border: none;
    padding: 10px 18px;
    font-family: var(--tb-font-display);
    font-size: 0.82rem;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    transition: color var(--tb-t-fast);
}

.tb-tabs .nav-link::after {
    content: '';
    position: absolute;
    left: 14px; right: 14px; bottom: -1px;
    height: 2px;
    background: var(--tb-primary);
    transform: scaleX(0);
    transform-origin: center;
    transition: transform var(--tb-t-base);
}

.tb-tabs .nav-link:hover:not(.active) { color: var(--tb-text); }
.tb-tabs .nav-link:hover::after { transform: scaleX(0.4); }

.tb-tabs .nav-link.active {
    color: var(--tb-primary);
    background: transparent;
    border: none;
}
.tb-tabs .nav-link.active::after { transform: scaleX(1); }

.tb-tabs .nav-link .badge {
    margin-left: 6px;
    font-size: 0.65rem;
}

.tb-tab-content { padding: 18px 0; }

/* ---------- Annotations ---------- */
.tb-annotation-create {
    border-color: var(--tb-primary) !important;
    box-shadow: 0 0 0 1px var(--tb-primary-glow);
}

.tb-annotation-item {
    padding: 12px 14px;
    border-left: 2px solid transparent;
    border-bottom: 1px solid var(--tb-border-subtle);
    transition: background-color var(--tb-t-fast), border-left-color var(--tb-t-fast);
}
.tb-annotation-item:hover {
    background: var(--tb-glass-hover);
    border-left-color: var(--tb-primary);
}

.tb-annotation-item.tb-resolved { opacity: 0.55; }

.tb-annotation-time {
    font-family: var(--tb-font-mono);
    font-weight: 500;
    font-size: 0.85rem;
    letter-spacing: 0.03em;
    color: var(--tb-accent);
}

.tb-annotation-mini {
    padding: 6px 0;
    font-size: 0.85rem;
    border-bottom: 1px solid var(--tb-border-subtle);
}

/* Filter chip strip */
.tb-annotation-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}

/* Annotation categories — flat, bordered, uppercase */
[class*="tb-cat-"] {
    display: inline-flex;
    align-items: center;
    padding: 3px 8px;
    font-family: var(--tb-font-display);
    font-size: 0.68rem;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    border: 1px solid var(--tb-border);
    border-radius: var(--tb-radius-sm);
    background: var(--tb-glass);
    color: var(--tb-text-muted);
    cursor: pointer;
    transition: color var(--tb-t-fast), border-color var(--tb-t-fast), background-color var(--tb-t-fast);
}

.tb-cat-general         { color: #9CA3AF; }
.tb-cat-mixnote         { color: var(--tb-warning); }
.tb-cat-arrangement     { color: var(--tb-success); }
.tb-cat-lyricidea       { color: var(--tb-signal); }
.tb-cat-performancenote { color: var(--tb-danger); }
.tb-cat-editnote        { color: #5EEAD4; }
.tb-cat-sounddesign     { color: var(--tb-primary); }
.tb-cat-bugorglitch     { color: #FCA5A5; }

.tb-cat-active {
    border-color: currentColor !important;
    background: rgba(255, 255, 255, 0.04);
    box-shadow: inset 0 0 0 1px currentColor;
}

/* ---------- Comments ---------- */
.tb-comment {
    padding: 12px 0;
    border-bottom: 1px solid var(--tb-border-subtle);
}
.tb-comment:last-child { border-bottom: none; }

.tb-reply {
    padding: 8px 0 8px 14px;
    border-bottom: none;
    border-left: 2px solid var(--tb-border);
    margin-top: 6px;
}

/* ---------- Versions ---------- */
.tb-version-item {
    padding: 12px 14px;
    border-bottom: 1px solid var(--tb-border-subtle);
    transition: background-color var(--tb-t-fast);
}
.tb-version-item:hover { background: var(--tb-glass-hover); }
.tb-version-item:last-child { border-bottom: none; }

/* ---------- Branch graph ---------- */
.tb-graph-svg {
    width: 100%;
    max-height: 600px;
    background: var(--tb-surface);
    border: 1px solid var(--tb-border);
    border-radius: var(--tb-radius);
}

.tb-graph-node {
    cursor: pointer;
    transition: r 0.15s, filter 0.15s;
}
.tb-graph-node:hover {
    r: 10;
    filter: drop-shadow(0 0 6px var(--tb-primary-glow));
}

.tb-graph-label {
    fill: var(--tb-text);
    font-family: var(--tb-font-mono);
    font-size: 12px;
}
.tb-graph-branch-label {
    font-family: var(--tb-font-display);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.tb-branch-item { padding: 10px 0; border-bottom: 1px solid var(--tb-border-subtle); }
.tb-branch-item:last-child { border-bottom: none; }

/* ---------- Releases ---------- */
.tb-releases {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-top: 12px;
    padding: 8px 12px;
    border: 1px solid rgba(196, 162, 78, 0.25);
    border-radius: var(--tb-radius);
    background: rgba(196, 162, 78, 0.04);
}

.tb-release-strip {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.tb-release-chip {
    display: inline-flex;
    flex-direction: column;
    padding: 4px 12px;
    border: 1px solid rgba(196, 162, 78, 0.35);
    border-radius: var(--tb-radius-sm);
    background: rgba(196, 162, 78, 0.08);
    text-decoration: none;
}
.tb-release-chip:hover {
    background: rgba(196, 162, 78, 0.15);
    border-color: rgba(196, 162, 78, 0.55);
}

.tb-release-name {
    font-family: var(--tb-font-display);
    font-weight: 700;
    font-size: 0.75rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--tb-accent);
}
.tb-release-meta {
    font-family: var(--tb-font-mono);
    font-size: 0.7rem;
    color: var(--tb-text-muted);
}

.tb-release-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border: 1px solid rgba(196, 162, 78, 0.4);
    border-radius: var(--tb-radius-sm);
    background: rgba(196, 162, 78, 0.1);
    font-family: var(--tb-font-display);
    font-size: 0.65rem;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--tb-accent);
}

/* ---------- Compare / Diff ---------- */
.tb-compare-warning {
    padding: 10px 14px;
    margin-bottom: 14px;
    border: 1px solid rgba(251, 191, 36, 0.35);
    background: rgba(251, 191, 36, 0.08);
    color: var(--tb-warning);
    border-radius: var(--tb-radius);
    font-size: 0.9rem;
}

.tb-compare-summary {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    font-family: var(--tb-font-display);
    font-size: 0.78rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--tb-text-muted);
}
.tb-compare-summary > span { display: inline-flex; align-items: center; gap: 6px; }

.tb-diff-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
}
.tb-diff-dot--common    { background: var(--tb-text-muted); }
.tb-diff-dot--onlyA     { background: var(--tb-primary); }
.tb-diff-dot--onlyB     { background: var(--tb-accent); }
.tb-diff-dot--resolved  { background: var(--tb-warning); }

.tb-diff-row--a { border-left: 2px solid var(--tb-primary); padding-left: 10px; }
.tb-diff-row--b { border-left: 2px solid var(--tb-accent); padding-left: 10px; }

.tb-diff-hint {
    margin-left: 6px;
    font-family: var(--tb-font-display);
    font-size: 0.68rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--tb-warning);
}


.tb-compare-header-a {
    background: rgba(120, 180, 255, 0.08);
    border-bottom: 2px solid var(--tb-primary);
}
.tb-compare-header-b {
    background: rgba(196, 162, 78, 0.08);
    border-bottom: 2px solid var(--tb-accent);
}

/* ---------- Checklist ---------- */
.tb-checklist-item {
    padding: 8px 0;
    border-bottom: 1px solid var(--tb-border-subtle);
}
.tb-checklist-item:last-child { border-bottom: none; }

/* ---------- Idea memos ---------- */
.tb-memo {
    background: var(--tb-surface);
    border: 1px solid var(--tb-border);
    border-radius: var(--tb-radius);
    padding: 14px 16px;
    margin-bottom: 10px;
}

.tb-memo-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.tb-memo-index {
    font-family: var(--tb-font-display);
    font-weight: 700;
    font-size: 0.78rem;
    letter-spacing: 0.08em;
    color: var(--tb-primary);
    margin-right: 10px;
}

.tb-memo-duration {
    font-family: var(--tb-font-mono);
    color: var(--tb-accent);
    font-size: 0.88rem;
}

.tb-memo-time {
    color: var(--tb-text-muted);
    font-size: 0.8rem;
    margin-left: 6px;
}

.tb-memo-transcript {
    margin: 8px 0 0;
    padding: 6px 10px;
    border-left: 2px solid var(--tb-border-strong);
    color: var(--tb-text);
    font-size: 0.9rem;
    line-height: 1.5;
}

/* Make the native <audio> element fit the dark theme approximately. Chromium's
   shadow DOM limits what we can style, but inversion gets us a dark bar that
   isn't jarring. */
.tb-memo audio {
    filter: invert(0.85) hue-rotate(180deg);
}

/* ---------- Lyrics sync ---------- */
.tb-lyrics-modes {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 10px;
}

.tb-lyrics-view {
    padding: 16px 20px;
    background: var(--tb-surface);
    border: 1px solid var(--tb-border);
    border-radius: var(--tb-radius);
    font-family: 'Georgia', 'Cambria', serif;
    font-size: 1rem;
    line-height: 1.9;
    max-height: 540px;
    overflow-y: auto;
}

.tb-lyrics-line {
    display: grid;
    grid-template-columns: 72px 1fr;
    gap: 12px;
    padding: 2px 4px;
    border-left: 2px solid transparent;
    color: var(--tb-text-muted);
    transition: color var(--tb-t-fast), background var(--tb-t-fast), border-left-color var(--tb-t-fast);
}

.tb-lyrics-line--active {
    color: var(--tb-text);
    background: rgba(120, 180, 255, 0.06);
    border-left-color: var(--tb-primary);
}

.tb-lyrics-line--seekable {
    cursor: pointer;
}
.tb-lyrics-line--seekable:hover {
    background: rgba(120, 180, 255, 0.04);
}
.tb-lyrics-line--seekable:focus-visible {
    outline: 2px solid var(--tb-primary);
    outline-offset: -2px;
}

.tb-lyrics-line .tb-lyrics-time {
    font-family: var(--tb-font-mono);
    font-size: 0.75rem;
    color: var(--tb-text-dim);
    padding-top: 6px;
    align-self: start;
}
.tb-lyrics-line--active .tb-lyrics-time { color: var(--tb-accent); }

/* ---------- Lyrics ---------- */
.tb-lyrics-textarea {
    background: var(--tb-surface);
    color: var(--tb-text);
    border: 1px solid var(--tb-border);
    border-radius: var(--tb-radius);
    font-family: 'Georgia', 'Cambria', serif;
    font-size: 1.05rem;
    line-height: 1.9;
    padding: 18px 20px;
}
.tb-lyrics-textarea:focus {
    border-color: var(--tb-border-strong);
    box-shadow: none;
}

/* ---------- Progress row / Stats ---------- */
.tb-progress-row {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin: 10px 0 8px;
}

.tb-stat-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid var(--tb-border-subtle);
}
.tb-stat-row:last-child { border-bottom: none; }
.tb-stat-row span:first-child {
    font-family: var(--tb-font-display);
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--tb-text-muted);
}
.tb-stat-row strong {
    font-family: var(--tb-font-mono);
    font-size: 1rem;
    color: var(--tb-text);
}

/* ---------- Activity feed ---------- */
.tb-activity-item {
    padding: 10px 0;
    border-bottom: 1px solid var(--tb-border-subtle);
    font-size: 0.9rem;
    line-height: 1.55;
    position: relative;
    padding-left: 16px;
}
.tb-activity-item:last-child { border-bottom: none; }
.tb-activity-item::before {
    content: '';
    position: absolute;
    left: 0; top: 16px;
    width: 6px; height: 6px;
    background: var(--tb-primary);
    transform: rotate(45deg);
    opacity: 0.7;
}

/* ---------- Login ---------- */
.tb-login-page {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background:
        radial-gradient(ellipse at 50% 0%, rgba(120, 180, 255, 0.08), transparent 60%),
        var(--tb-bg);
}

.tb-login-card {
    background: var(--tb-surface);
    border: 1px solid var(--tb-border);
    border-radius: var(--tb-radius-lg);
    padding: 40px;
    width: 400px;
    max-width: 90vw;
}

/* ---------- Forms ---------- */
.form-control, .form-select, .form-control-sm, .form-select-sm {
    background-color: var(--tb-bg-deep);
    color: var(--tb-text);
    border: 1px solid var(--tb-border);
    border-radius: var(--tb-radius);
    font-family: var(--tb-font-body);
    transition: border-color var(--tb-t-fast), box-shadow var(--tb-t-fast), background-color var(--tb-t-fast);
}

.form-control:focus, .form-select:focus {
    background-color: var(--tb-bg-deep);
    color: var(--tb-text);
    border-color: var(--tb-primary);
    box-shadow: 0 0 0 2px var(--tb-primary-glow);
    outline: none;
}

.form-control::placeholder { color: var(--tb-text-dim); }

.form-check-input {
    background-color: var(--tb-bg-deep);
    border-color: var(--tb-border-strong);
}
.form-check-input:checked {
    background-color: var(--tb-primary);
    border-color: var(--tb-primary);
}

.form-label {
    font-family: var(--tb-font-display);
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--tb-text-muted);
    margin-bottom: 6px;
}

/* ---------- Buttons ---------- */
.btn {
    font-family: var(--tb-font-display);
    font-weight: 600;
    font-size: 0.8rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    border-radius: var(--tb-radius-sm);
    padding: 7px 16px;
    transition: background-color var(--tb-t-fast), border-color var(--tb-t-fast), color var(--tb-t-fast);
}

.btn-sm { font-size: 0.72rem; padding: 5px 12px; letter-spacing: 0.12em; }

.btn-primary {
    background: var(--tb-primary);
    border-color: var(--tb-primary);
    color: var(--tb-text-inverse);
}
.btn-primary:hover, .btn-primary:focus {
    background: var(--tb-primary-hover);
    border-color: var(--tb-primary-hover);
    color: var(--tb-text-inverse);
}

.btn-secondary {
    background: transparent;
    border-color: var(--tb-border-strong);
    color: var(--tb-text);
}
.btn-secondary:hover {
    background: var(--tb-glass-hover);
    border-color: var(--tb-text-muted);
    color: var(--tb-text);
}

.btn-outline-primary {
    color: var(--tb-primary);
    border-color: var(--tb-primary);
    background: transparent;
}
.btn-outline-primary:hover {
    background: rgba(120, 180, 255, 0.08);
    color: var(--tb-primary);
    border-color: var(--tb-primary);
}

.btn-outline-secondary {
    color: var(--tb-text-muted);
    border-color: var(--tb-border);
    background: transparent;
}
.btn-outline-secondary:hover {
    background: var(--tb-glass-hover);
    color: var(--tb-text);
    border-color: var(--tb-border-strong);
}

/* ---------- Tables / badges ---------- */
.table {
    --bs-table-bg: transparent;
    --bs-table-color: var(--tb-text);
    --bs-table-border-color: var(--tb-border);
}

.badge {
    font-family: var(--tb-font-display);
    font-weight: 600;
    font-size: 0.65rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    border-radius: var(--tb-radius-sm);
    padding: 3px 7px;
}

.badge.bg-secondary {
    background-color: var(--tb-glass) !important;
    border: 1px solid var(--tb-border);
    color: var(--tb-text-muted);
}
.badge.bg-info {
    background-color: rgba(120, 180, 255, 0.12) !important;
    color: var(--tb-primary);
    border: 1px solid var(--tb-border-strong);
}

/* ---------- Scrollbar polish ---------- */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--tb-bg); }
::-webkit-scrollbar-thumb {
    background: var(--tb-surface-hover);
    border: 2px solid var(--tb-bg);
    border-radius: var(--tb-radius);
}
::-webkit-scrollbar-thumb:hover { background: var(--tb-text-dim); }

/* ---------- Notification bell ---------- */
.tb-bell-wrapper { position: relative; }

.tb-bell-btn {
    background: transparent;
    border: 1px solid var(--tb-border);
    color: var(--tb-text-muted);
    padding: 4px 10px;
    border-radius: var(--tb-radius-sm);
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
    position: relative;
    transition: all var(--tb-t-fast);
}
.tb-bell-btn:hover { color: var(--tb-text); border-color: var(--tb-border-strong); }

.tb-bell-count {
    position: absolute;
    top: -4px; right: -4px;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    background: var(--tb-accent);
    color: var(--tb-text-inverse);
    border-radius: 8px;
    font-family: var(--tb-font-display);
    font-weight: 700;
    font-size: 0.65rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.tb-bell-panel {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 360px;
    max-height: 440px;
    overflow-y: auto;
    background: var(--tb-surface);
    border: 1px solid var(--tb-border-strong);
    border-radius: var(--tb-radius);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.6);
    z-index: 200;
}

.tb-bell-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    border-bottom: 1px solid var(--tb-border);
}

.tb-bell-empty {
    padding: 20px;
    text-align: center;
    color: var(--tb-text-muted);
    font-size: 0.9rem;
}

.tb-bell-item {
    display: block;
    width: 100%;
    text-align: left;
    background: transparent;
    border: none;
    padding: 10px 14px;
    border-bottom: 1px solid var(--tb-border-subtle);
    cursor: pointer;
    color: var(--tb-text-muted);
    transition: background var(--tb-t-fast);
}
.tb-bell-item:hover { background: var(--tb-glass-hover); }
.tb-bell-item:last-child { border-bottom: none; }

.tb-bell-item--unread {
    background: rgba(120, 180, 255, 0.04);
    color: var(--tb-text);
}
.tb-bell-item--unread:hover { background: rgba(120, 180, 255, 0.08); }

.tb-bell-item .tb-bell-actor {
    font-family: var(--tb-font-display);
    font-weight: 600;
    font-size: 0.75rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--tb-primary);
    margin-right: 6px;
}
.tb-bell-item .tb-bell-msg { font-size: 0.88rem; }
.tb-bell-item .tb-bell-when {
    display: block;
    font-family: var(--tb-font-mono);
    font-size: 0.7rem;
    color: var(--tb-text-dim);
    margin-top: 2px;
}

.tb-annotation-assignee {
    margin-left: 6px;
    color: var(--tb-primary);
    font-weight: 600;
}

/* ---------- Toasts ---------- */
.tb-toast-region {
    position: fixed;
    bottom: 20px;
    right: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 9000;
    max-width: 360px;
    pointer-events: none;
}

.tb-toast {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border: 1px solid var(--tb-border-strong);
    border-radius: var(--tb-radius);
    background: rgba(18, 18, 26, 0.96);
    backdrop-filter: blur(8px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
    pointer-events: all;
    animation: tb-toast-in 160ms ease-out;
}

@keyframes tb-toast-in {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.tb-toast--info    { border-left: 3px solid var(--tb-primary); }
.tb-toast--success { border-left: 3px solid var(--tb-success); }
.tb-toast--warning { border-left: 3px solid var(--tb-warning); }
.tb-toast--error   { border-left: 3px solid var(--tb-danger); }

.tb-toast-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px; height: 20px;
    border-radius: 50%;
    font-family: var(--tb-font-display);
    font-weight: 700;
    font-size: 0.75rem;
}
.tb-toast--info    .tb-toast-icon { background: rgba(120,180,255,0.18); color: var(--tb-primary); }
.tb-toast--success .tb-toast-icon { background: rgba(74,222,128,0.18);  color: var(--tb-success); }
.tb-toast--warning .tb-toast-icon { background: rgba(251,191,36,0.18);  color: var(--tb-warning); }
.tb-toast--error   .tb-toast-icon { background: rgba(248,113,113,0.18); color: var(--tb-danger); }

.tb-toast-msg { flex: 1; font-size: 0.9rem; color: var(--tb-text); line-height: 1.4; }

.tb-toast-close {
    background: transparent;
    border: 0;
    color: var(--tb-text-muted);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
}
.tb-toast-close:hover { color: var(--tb-text); }

/* ---------- Confirm dialog ---------- */
.tb-confirm-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(10, 10, 15, 0.65);
    backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 8000;
    animation: tb-toast-in 120ms ease-out;
}

.tb-confirm-dialog {
    background: var(--tb-surface);
    border: 1px solid var(--tb-border-strong);
    border-radius: var(--tb-radius-lg);
    padding: 28px;
    width: 440px;
    max-width: 92vw;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.6);
}

.tb-confirm-dialog h3 {
    margin: 6px 0 10px;
    font-size: 1.15rem;
    text-transform: none;
    letter-spacing: 0.01em;
}

.tb-confirm-dialog p {
    color: var(--tb-text-muted);
    font-size: 0.92rem;
    line-height: 1.55;
    margin: 0 0 18px;
}

.tb-confirm-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.tb-confirm-destructive {
    background: var(--tb-danger) !important;
    border-color: var(--tb-danger) !important;
}
.tb-confirm-destructive:hover {
    background: #FCA5A5 !important;
    border-color: #FCA5A5 !important;
}

/* ---------- Error boundary ---------- */
.tb-error-panel {
    padding: 28px;
    background: var(--tb-surface);
    border: 1px solid rgba(248, 113, 113, 0.3);
    border-radius: var(--tb-radius);
    max-width: 640px;
}

.tb-error-panel h3 { margin: 6px 0 10px; }
.tb-error-panel p  { color: var(--tb-text-muted); margin-bottom: 16px; }

.tb-error-stack {
    margin-top: 18px;
    padding: 12px;
    background: var(--tb-bg-deep);
    color: var(--tb-text-muted);
    font-family: var(--tb-font-mono);
    font-size: 0.75rem;
    border-radius: var(--tb-radius-sm);
    max-height: 240px;
    overflow: auto;
    white-space: pre-wrap;
}

/* ---------- Card / row delete chip ---------- */
.tb-card-delete, .tb-row-delete {
    background: transparent;
    border: 1px solid var(--tb-border);
    color: var(--tb-text-dim);
    font-size: 1rem;
    line-height: 1;
    padding: 4px 10px;
    border-radius: var(--tb-radius-sm);
    cursor: pointer;
    transition: all var(--tb-t-fast);
}
.tb-card-delete {
    position: absolute;
    top: 12px;
    right: 12px;
}
.tb-card-delete:hover, .tb-row-delete:hover {
    border-color: var(--tb-danger);
    color: var(--tb-danger);
    background: rgba(248, 113, 113, 0.08);
}

/* ---------- LUFS Chip ---------- */
.tb-lufs-chip {
    font-size: 0.75rem;
    padding: 2px 8px;
    border-radius: var(--tb-radius-sm);
    background: var(--tb-surface);
    border: 1px solid var(--tb-border);
}
.tb-lufs-quiet { color: #6b8aff; }
.tb-lufs-nominal { color: #60c060; }
.tb-lufs-loud { color: #e0a040; }
.tb-lufs-hot { color: #f87171; }

/* ---------- Mood Picker ---------- */
.tb-mood-display { font-size: 1.2rem; }
.tb-mood-grid {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 4px;
    padding: 4px;
    border: 1px solid var(--tb-border);
    border-radius: var(--tb-radius-sm);
    background: var(--tb-surface);
}
.tb-mood-btn { font-size: 1.1rem; padding: 2px 6px; line-height: 1; min-width: 32px; }

/* ---------- Resume Card ---------- */
.tb-resume-card {
    border-left: 3px solid var(--tb-accent);
}

/* ---------- Stuck Button ---------- */
.tb-stuck-button .badge { font-size: 0.8rem; }

/* ---------- Ack Buttons ---------- */
.tb-ack-buttons .tb-ack-btn {
    font-size: 0.7rem;
    padding: 1px 5px;
    line-height: 1.2;
}

/* ---------- Skeleton loading ---------- */
.skeleton {
    position: relative;
    overflow: hidden;
    background: var(--tb-surface-2);
    border-radius: var(--tb-radius);
    color: transparent !important;
    pointer-events: none;
    user-select: none;
}

.skeleton::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(
        90deg,
        transparent 0%,
        rgba(255, 255, 255, 0.04) 40%,
        rgba(255, 255, 255, 0.06) 50%,
        rgba(255, 255, 255, 0.04) 60%,
        transparent 100%
    );
    animation: tb-shimmer 1.6s ease-in-out infinite;
}

@keyframes tb-shimmer {
    0%   { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

.skeleton-text {
    display: block;
    height: 0.9em;
    margin-bottom: 0.55em;
    border-radius: var(--tb-radius-sm);
}

.skeleton-text--heading {
    height: 1.4em;
    width: 60%;
    margin-bottom: 0.65em;
}

.skeleton-text--short {
    width: 40%;
}

.skeleton-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border-bottom: 1px solid var(--tb-border-subtle);
}

.skeleton-row .skeleton-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    flex-shrink: 0;
}

.skeleton-row .skeleton-lines {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.skeleton-row .skeleton-lines .skeleton-text { margin-bottom: 0; }
.skeleton-row .skeleton-lines .skeleton-text:first-child { width: 70%; }
.skeleton-row .skeleton-lines .skeleton-text:last-child { width: 45%; }

.skeleton-card {
    background: var(--tb-surface);
    border: 1px solid var(--tb-border);
    border-radius: var(--tb-radius);
    padding: 18px;
}

.skeleton-card .skeleton-text:first-child { width: 55%; }
.skeleton-card .skeleton-text:nth-child(2) { width: 80%; }
.skeleton-card .skeleton-text:last-child { width: 30%; }

.skeleton-kpi {
    background: var(--tb-surface);
    border: 1px solid var(--tb-border);
    border-radius: var(--tb-radius);
    padding: 14px 16px;
}

.skeleton-kpi .skeleton-text:first-child { width: 50%; height: 0.7em; }
.skeleton-kpi .skeleton-text:last-child { width: 35%; height: 1.6em; margin-bottom: 0; }

.skeleton-table-row {
    display: grid;
    grid-template-columns: 50px 2fr 1fr 1fr 80px 80px 40px;
    gap: 12px;
    align-items: center;
    padding: 12px;
    border-bottom: 1px solid var(--tb-border-subtle);
}

.skeleton-table-row .skeleton-text { margin-bottom: 0; width: 100%; }

@media (prefers-reduced-motion: reduce) {
    .skeleton::after {
        animation: none;
    }
}

/* ---------- Empty state ---------- */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px 24px;
    text-align: center;
}

.empty-state-icon {
    font-size: 2.5rem;
    color: var(--tb-text-dim);
    margin-bottom: 16px;
    opacity: 0.7;
}

.empty-state h3 {
    font-family: var(--tb-font-display);
    font-size: 1.15rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    color: var(--tb-text);
    margin: 0 0 8px;
}

.empty-state p {
    color: var(--tb-text-muted);
    font-size: 0.9rem;
    line-height: 1.55;
    max-width: 28rem;
    margin: 0 0 18px;
}

.empty-state .btn {
    margin-top: 4px;
}

/* ---------- Search ---------- */
.tb-search {
    position: relative;
    margin-bottom: 14px;
}

.tb-search input[type="search"] {
    background: var(--tb-bg-deep);
    color: var(--tb-text);
    border: 1px solid var(--tb-border);
    border-radius: var(--tb-radius);
    padding: 8px 12px 8px 34px;
    font-family: var(--tb-font-body);
    font-size: 0.88rem;
    width: 100%;
    max-width: 320px;
    transition: border-color var(--tb-t-fast), box-shadow var(--tb-t-fast);
}

.tb-search input[type="search"]:focus {
    border-color: var(--tb-primary);
    box-shadow: 0 0 0 2px var(--tb-primary-glow);
    outline: none;
}

.tb-search input[type="search"]::placeholder {
    color: var(--tb-text-dim);
    font-family: var(--tb-font-display);
    font-size: 0.78rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

/* Webkit cancel button styling */
.tb-search input[type="search"]::-webkit-search-cancel-button {
    -webkit-appearance: none;
    height: 12px;
    width: 12px;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%238A8A8F'%3E%3Cpath d='M4.646 4.646a.5.5 0 0 1 .708 0L8 7.293l2.646-2.647a.5.5 0 0 1 .708.708L8.707 8l2.647 2.646a.5.5 0 0 1-.708.708L8 8.707l-2.646 2.647a.5.5 0 0 1-.708-.708L7.293 8 4.646 5.354a.5.5 0 0 1 0-.708z'/%3E%3C/svg%3E") no-repeat center;
    cursor: pointer;
}

.tb-search-icon {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--tb-text-dim);
    font-size: 0.88rem;
    pointer-events: none;
}

/* ---------- Row action dropdown ---------- */
.tb-row-actions {
    position: relative;
    display: inline-block;
}

.tb-row-actions-btn {
    background: transparent;
    border: 1px solid transparent;
    color: var(--tb-text-dim);
    font-size: 1rem;
    line-height: 1;
    padding: 4px 8px;
    border-radius: var(--tb-radius-sm);
    cursor: pointer;
    transition: all var(--tb-t-fast);
}

.tb-row-actions-btn:hover,
.tb-row-actions-btn[aria-expanded="true"] {
    border-color: var(--tb-border-strong);
    color: var(--tb-text);
    background: var(--tb-glass-hover);
}

.tb-dropdown-menu {
    position: absolute;
    right: 0;
    top: calc(100% + 4px);
    min-width: 180px;
    background: var(--tb-surface);
    border: 1px solid var(--tb-border-strong);
    border-radius: var(--tb-radius);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
    z-index: 300;
    padding: 4px 0;
    animation: tb-dropdown-in 120ms ease-out;
}

@keyframes tb-dropdown-in {
    from { opacity: 0; transform: translateY(-4px); }
    to   { opacity: 1; transform: translateY(0); }
}

.tb-dropdown-item {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 7px 14px;
    background: transparent;
    border: none;
    color: var(--tb-text);
    font-family: var(--tb-font-body);
    font-size: 0.85rem;
    cursor: pointer;
    text-align: left;
    transition: background-color var(--tb-t-fast), color var(--tb-t-fast);
}

.tb-dropdown-item:hover {
    background: var(--tb-glass-hover);
    color: var(--tb-primary);
}

.tb-dropdown-item i {
    width: 16px;
    text-align: center;
    font-size: 0.85rem;
    color: var(--tb-text-muted);
}

.tb-dropdown-item:hover i {
    color: var(--tb-primary);
}

.tb-dropdown-item--danger {
    color: var(--tb-danger);
}

.tb-dropdown-item--danger:hover {
    color: var(--tb-danger);
    background: rgba(248, 113, 113, 0.08);
}

.tb-dropdown-item--danger i {
    color: var(--tb-danger);
    opacity: 0.7;
}

.tb-dropdown-item--danger:hover i {
    color: var(--tb-danger);
    opacity: 1;
}

.tb-dropdown-divider {
    height: 1px;
    margin: 4px 0;
    background: var(--tb-border);
    border: none;
}

/* Inline download button on version rows */
.tb-download-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: 4px;
    color: var(--tb-text-muted);
    text-decoration: none;
    transition: background-color var(--tb-t-fast), color var(--tb-t-fast);
}

.tb-download-btn:hover {
    background: var(--tb-glass-hover);
    color: var(--tb-primary);
}

/* Dropdown-item styled as an anchor */
a.tb-dropdown-item {
    text-decoration: none;
}

/* Overlay to close dropdown when clicking outside */
.tb-dropdown-backdrop {
    position: fixed;
    inset: 0;
    z-index: 299;
    background: transparent;
}

/* ---------- Feature Tips (TipKit equivalent) ---------- */
.tb-tip {
    position: relative;
    background: linear-gradient(135deg, rgba(120, 180, 255, 0.08), rgba(155, 127, 212, 0.06));
    border: 1px solid rgba(120, 180, 255, 0.2);
    border-radius: var(--tb-radius-lg);
    padding: 12px 40px 12px 14px;
    margin-bottom: 12px;
    animation: tipSlideIn 300ms ease;
}
.tb-tip-icon { color: var(--tb-primary); margin-right: 8px; font-size: 1.1em; }
.tb-tip-title { font-family: var(--tb-font-display); font-weight: 600; font-size: 0.9rem; color: var(--tb-text); }
.tb-tip-body { font-size: 0.82rem; color: var(--tb-text-muted); margin-top: 2px; }
.tb-tip-dismiss {
    position: absolute; top: 8px; right: 8px;
    background: none; border: none; color: var(--tb-text-dim);
    cursor: pointer; font-size: 0.9rem; line-height: 1; padding: 4px;
}
.tb-tip-dismiss:hover { color: var(--tb-text); }
@keyframes tipSlideIn { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: translateY(0); } }

/* ---------- Command Palette ---------- */
.tb-cmd-backdrop {
    position: fixed; inset: 0; z-index: 10000;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: flex; justify-content: center; padding-top: 15vh;
    animation: fadeIn 120ms ease;
}
.tb-cmd-dialog {
    width: min(520px, 90vw);
    max-height: 400px;
    background: var(--tb-surface);
    border: 1px solid var(--tb-border-strong);
    border-radius: var(--tb-radius-lg);
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    animation: cmdSlideIn 150ms ease;
}
.tb-cmd-input {
    width: 100%; padding: 14px 16px;
    background: var(--tb-surface-2); border: none; border-bottom: 1px solid var(--tb-border);
    color: var(--tb-text); font-family: var(--tb-font-body); font-size: 1rem;
    outline: none;
}
.tb-cmd-input::placeholder { color: var(--tb-text-dim); }
.tb-cmd-list { max-height: 320px; overflow-y: auto; padding: 4px 0; }
.tb-cmd-item {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 16px; cursor: pointer; color: var(--tb-text-muted);
    transition: background var(--tb-t-fast), color var(--tb-t-fast);
}
.tb-cmd-item:hover, .tb-cmd-item.active { background: var(--tb-surface-hover); color: var(--tb-text); }
.tb-cmd-item i { font-size: 1.1em; width: 20px; text-align: center; }
.tb-cmd-kbd { margin-left: auto; font-size: 0.75rem; color: var(--tb-text-dim); font-family: var(--tb-font-mono); }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes cmdSlideIn { from { opacity: 0; transform: translateY(-12px); } to { opacity: 1; transform: translateY(0); } }

/* ---------- Keyboard shortcut hints ---------- */
.tb-kbd {
    display: inline-block; padding: 1px 6px;
    font-family: var(--tb-font-mono); font-size: 0.72rem;
    background: var(--tb-surface-2); border: 1px solid var(--tb-border);
    border-radius: 3px; color: var(--tb-text-muted);
}

/* ---------- Accessibility ---------- */
.tb-skip-link {
    position: absolute; top: -100px; left: 16px;
    background: var(--tb-primary); color: var(--tb-text-inverse);
    padding: 8px 16px; border-radius: var(--tb-radius);
    z-index: 99999; font-weight: 600; text-decoration: none;
}
.tb-skip-link:focus { top: 8px; }

*:focus-visible {
    outline: 2px solid var(--tb-primary);
    outline-offset: 2px;
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    .skeleton { animation: none !important; background: var(--tb-surface-2) !important; }
}

/* ---------- Responsive ---------- */
@media (max-width: 768px) {
    .tb-sidebar { display: none; }
    .tb-main { margin-left: 0; }
    .tb-content { padding: 20px 16px 32px; }
    .tb-toolbar { padding: 0 16px; }

    .tb-search input[type="search"] { max-width: 100%; }
    .tb-dropdown-menu { min-width: 160px; }
}

/* ---------- Global Search drawer ---------- */
.tb-search-dialog {
    width: min(680px, 92vw);
    max-height: 70vh;
}
.tb-search-list {
    max-height: calc(70vh - 56px);
}
.tb-search-group-label {
    font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.08em;
    color: var(--tb-text-dim); padding: 10px 16px 4px;
}
.tb-search-row {
    align-items: flex-start;
    gap: 12px;
}
.tb-search-row-body {
    display: flex; flex-direction: column; min-width: 0; flex: 1;
}
.tb-search-row-title {
    color: var(--tb-text); font-weight: 500;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.tb-search-row-snippet {
    color: var(--tb-text-dim); font-size: 0.82rem; margin-top: 2px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.tb-search-row-snippet mark, .tb-search-row-title mark {
    background: var(--tb-accent, #ffd76a); color: var(--tb-bg, #111);
    padding: 0 2px; border-radius: 2px;
}
.tb-search-row-time {
    font-size: 0.72rem; color: var(--tb-text-dim);
    white-space: nowrap; align-self: center;
}
.tb-search-chip {
    display: inline-block;
    padding: 1px 8px; border-radius: 999px;
    font-size: 0.68rem; font-weight: 600; letter-spacing: 0.04em;
    text-transform: uppercase;
    background: var(--tb-surface-2);
    border: 1px solid var(--tb-border);
    color: var(--tb-text-muted);
    line-height: 1.4;
    flex-shrink: 0;
}
.tb-search-chip--project { color: #9ad0ff; border-color: #2a5a8a; }
.tb-search-chip--song { color: #b6e6a0; border-color: #3a6a32; }
.tb-search-chip--annotation { color: #ffd76a; border-color: #806530; }
.tb-search-chip--comment { color: #f3a6c8; border-color: #804060; }
.tb-search-chip--idea { color: #c8a6f3; border-color: #604080; }


/* ─── Mini player (layout-pinned transport bar) ───────────────────── */
.tb-mini-player {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    background: #14142a;
    border-top: 1px solid #2a2a4a;
    box-shadow: 0 -8px 24px rgba(0,0,0,0.35);
    z-index: 950;
    color: #e6e6f0;
    user-select: none;
}
.tb-mini-progress {
    height: 2px;
    background: rgba(255,255,255,0.06);
    overflow: hidden;
}
.tb-mini-progress-fill {
    height: 100%;
    background: var(--tb-accent, #4a9eff);
    transition: width 250ms linear;
}
.tb-mini-row {
    display: flex; align-items: center; justify-content: space-between;
    gap: 12px;
    padding: 6px 16px;
    min-height: 44px;
}
.tb-mini-meta {
    display: flex; align-items: center; gap: 8px;
    color: inherit;
    text-decoration: none;
    min-width: 0;
    flex: 1 1 auto;
    overflow: hidden;
}
.tb-mini-meta:hover .tb-mini-title { text-decoration: underline; }
.tb-mini-title {
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.tb-mini-version {
    font-size: 0.78rem;
    opacity: 0.65;
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 4px;
    padding: 1px 6px;
    flex-shrink: 0;
}
.tb-mini-controls {
    display: flex; align-items: center; gap: 6px;
    flex-shrink: 0;
}
.tb-mini-time {
    font-size: 0.78rem;
    font-variant-numeric: tabular-nums;
    opacity: 0.7;
    margin: 0 4px;
}
@media (max-width: 600px) {
    .tb-mini-version, .tb-mini-time { display: none; }
}
