/* ===========================================
   UI Component Library
   SyncVault Modern Dark Theme
   =========================================== */

/* ===== CARDS ===== */
.card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--space-6);
    transition: border-color var(--transition-base);
}

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

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: var(--space-4);
    margin-bottom: var(--space-4);
    border-bottom: 1px solid var(--border);
}

.card-title {
    font-size: var(--text-lg);
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

.card-title i {
    color: var(--primary);
}

.card-body {
    color: var(--text-secondary);
}

/* ===== RADIO PILLS ===== */
.radio-pill {
    display: inline-flex;
    align-items: center;
    cursor: pointer;
    font-size: var(--text-sm);
    user-select: none;
}
.radio-pill input[type="radio"] { display: none; }
.radio-pill span {
    padding: var(--space-1) var(--space-3);
    border-radius: var(--radius-full);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    transition: all 0.15s ease;
}
.radio-pill:hover span {
    border-color: var(--border-hover);
}
.radio-pill input[type="radio"]:checked + span {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* ===== BUTTONS ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-5);
    font-size: var(--text-sm);
    font-weight: 600;
    border-radius: var(--radius-md);
    border: none;
    cursor: pointer;
    transition: all var(--transition-base);
    text-decoration: none;
    white-space: nowrap;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Primary Button */
.btn-primary,
.btn {
    background: var(--primary);
    color: white;
}

.btn-primary:hover,
.btn:hover:not(:disabled) {
    background: var(--primary-hover);
    box-shadow: var(--shadow-glow);
}

.btn-primary:active,
.btn:active {
    transform: scale(0.98);
}

/* Secondary Button */
.btn-secondary,
.btn-sm {
    background: var(--bg-surface-2);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: var(--space-2) var(--space-4);
    font-size: var(--text-sm);
    font-weight: 500;
}

.btn.btn-secondary:hover,
.btn.btn-sm:hover {
    border-color: var(--primary);
    color: var(--text-primary);
    background: var(--bg-hover);
}

/* Outline Button */
.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-primary);
}

.btn-outline:hover {
    border-color: var(--primary);
    background: var(--primary);
    color: white;
}

/* Ghost Button */
.btn-ghost {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: var(--space-2);
}

.btn-ghost:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}

/* Size Variants */
.btn-lg {
    padding: var(--space-4) var(--space-6);
    font-size: var(--text-base);
}

.btn-icon {
    padding: var(--space-2);
    width: 36px;
    height: 36px;
}

/* ===== FORM INPUTS ===== */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="url"],
input[type="search"],
textarea,
select {
    width: 100%;
    padding: var(--space-3) var(--space-4);
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    font-size: var(--text-base);
    font-family: inherit;
    color: var(--text-primary);
    transition: all var(--transition-fast);
}

input::placeholder,
textarea::placeholder {
    color: var(--text-muted);
}

input:hover,
textarea:hover,
select:hover {
    border-color: var(--border-hover);
}

input:focus,
textarea:focus,
select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
    outline: none;
}

/* Input with icon */
.input-group {
    position: relative;
}

.input-group input {
    padding-left: var(--space-10);
}

.input-group i {
    position: absolute;
    left: var(--space-4);
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

/* Checkbox */
input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
    cursor: pointer;
}

/* ===== BADGES ===== */
.badge {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    padding: var(--space-1) var(--space-3);
    font-size: var(--text-xs);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    border-radius: var(--radius-full);
    border: 1px solid transparent;
}

.badge-green,
.badge-success {
    background: var(--success-soft);
    color: var(--success);
    border-color: var(--success-border);
}

.badge-red,
.badge-danger {
    background: var(--danger-soft);
    color: var(--danger);
    border-color: var(--danger-border);
}

.badge-yellow,
.badge-warning {
    background: var(--warning-soft);
    color: var(--warning);
    border-color: var(--warning-border);
}

.badge-purple {
    background: rgba(168, 85, 247, 0.12);
    color: #a855f7;
    border-color: rgba(168, 85, 247, 0.25);
}

.badge-blue,
.badge-info {
    background: var(--info-soft);
    color: var(--info);
    border-color: var(--info-border);
}

.badge-gray {
    background: var(--bg-surface-2);
    color: var(--text-secondary);
    border-color: var(--border);
}

.badge-pink,
.badge-primary {
    background: var(--primary-soft);
    color: var(--primary);
    border: 1px solid rgba(255, 0, 85, 0.3);
}

/* ===== TABS ===== */
.tabs {
    display: flex;
    gap: var(--space-1);
    background: var(--bg-surface-2);
    padding: var(--space-1);
    border-radius: var(--radius-lg);
    margin-bottom: var(--space-6);
}

.tab {
    flex: 1;
    padding: var(--space-3) var(--space-5);
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--text-muted);
    background: transparent;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-base);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
}

.tab:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}

.tab.active {
    background: var(--primary);
    color: white;
    box-shadow: var(--shadow-sm);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
    animation: fadeIn var(--transition-base);
}

/* ===== TIMELINE / STEPS ===== */
.timeline {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-4) 0;
    margin-bottom: var(--space-6);
}

.timeline-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-2);
    flex: 1;
    position: relative;
}

.timeline-step:not(:last-child)::after {
    content: '';
    position: absolute;
    top: 14px;
    left: 50%;
    width: 100%;
    height: 2px;
    background: var(--border);
    z-index: 0;
}

.timeline-step.completed:not(:last-child)::after {
    background: var(--success);
}

.timeline-step.active:not(:last-child)::after {
    background: linear-gradient(90deg, var(--primary) 50%, var(--border) 50%);
}

.timeline-dot {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--bg-surface-2);
    border: 2px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--text-xs);
    color: var(--text-muted);
    position: relative;
    z-index: 1;
    transition: all var(--transition-base);
}

.timeline-step.active .timeline-dot {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
    box-shadow: 0 0 15px var(--primary-glow);
    animation: pulse 2s infinite;
}

.timeline-step.completed .timeline-dot {
    background: var(--success);
    border-color: var(--success);
    color: white;
}

.timeline-label {
    font-size: var(--text-xs);
    color: var(--text-muted);
    text-align: center;
    max-width: 80px;
    line-height: 1.3;
}

.timeline-step.active .timeline-label,
.timeline-step.completed .timeline-label {
    color: var(--text-primary);
}

/* ===== PROGRESS BAR ===== */
.progress-bar-container {
    display: flex;
    align-items: center;
    gap: var(--space-4);
    padding: 0 var(--space-1);
    margin-bottom: var(--space-4);
}

.progress-bar-track {
    flex: 1;
    height: 6px;
    background: var(--bg-surface-2);
    border-radius: var(--radius-full);
    overflow: hidden;
    position: relative;
}

.progress-bar-fill {
    height: 100%;
    border-radius: var(--radius-full);
    background: linear-gradient(90deg, var(--primary) 0%, var(--primary-hover) 100%);
    box-shadow: 0 0 8px var(--primary-glow);
    transition: width 0.6s cubic-bezier(0.22, 1, 0.36, 1);
    position: relative;
}

.progress-bar-fill::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(
        90deg,
        transparent 0%,
        rgba(255, 255, 255, 0.15) 50%,
        transparent 100%
    );
    animation: progressShimmer 2s ease-in-out infinite;
}

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

.progress-bar-text {
    font-size: var(--text-xs);
    font-weight: 700;
    color: var(--text-muted);
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
    min-width: 72px;
    text-align: right;
    letter-spacing: 0.02em;
}

/* ===== CATEGORY SCORE CARDS ===== */
.category-scores-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-3);
}

.category-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--space-4) var(--space-3);
    text-align: center;
    cursor: pointer;
    transition: all var(--transition-base);
    position: relative;
    overflow: hidden;
}

.category-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    opacity: 0;
    transition: opacity var(--transition-base);
}

.category-low::before { background: var(--success); }
.category-medium::before { background: var(--warning); }
.category-high::before { background: #a855f7; }
.category-critical::before { background: var(--danger); }

.category-card:hover {
    border-color: var(--border-hover);
    background: var(--bg-surface-2);
}

.category-card:hover::before {
    opacity: 1;
}

.category-label {
    font-size: var(--text-xs);
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: var(--space-1);
}

.category-score {
    font-size: var(--text-3xl);
    font-weight: 900;
    line-height: 1;
    margin-bottom: 2px;
    font-variant-numeric: tabular-nums;
    transition: color var(--transition-base);
}

.category-low .category-score { color: var(--success); }
.category-medium .category-score { color: var(--warning); }
.category-high .category-score { color: #a855f7; }
.category-critical .category-score { color: var(--danger); }

.category-sub {
    font-size: 0.65rem;
    color: var(--text-muted);
    margin-bottom: var(--space-2);
}

.category-card .badge {
    font-size: 0.6rem;
    padding: 2px var(--space-2);
}

.category-detail {
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    transition: max-height 0.3s ease, opacity 0.2s ease, margin-top 0.3s ease;
    margin-top: 0;
}

.category-card.expanded .category-detail {
    max-height: 300px;
    opacity: 1;
    margin-top: var(--space-3);
    overflow-y: auto;
}

.category-breakdown {
    display: flex;
    justify-content: center;
    gap: var(--space-4);
    font-size: var(--text-xs);
    color: var(--text-secondary);
    font-weight: 600;
    margin-bottom: var(--space-2);
    font-variant-numeric: tabular-nums;
}

.category-reasoning {
    font-size: var(--text-xs);
    color: var(--text-muted);
    font-style: italic;
    line-height: 1.4;
}

/* Compact step grid (auto-fill adapts to step count) */
#steps-grid-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: var(--space-3);
    margin-bottom: var(--space-6);
}

.step-item {
    background: var(--bg-surface);
    border: 1px dashed var(--border);
    padding: var(--space-3) var(--space-2);
    border-radius: var(--radius-md);
    text-align: center;
    opacity: 0.4;
    transition: all var(--transition-slow);
}

.step-item.active {
    opacity: 1;
    border-style: solid;
    border-color: var(--warning);
    box-shadow: 0 0 0 2px rgba(234, 179, 8, 0.25);
    background: var(--warning-soft);
    color: var(--warning);
    animation: pulseAmber 2s ease-in-out infinite;
}

.step-item.completed {
    opacity: 1;
    border-style: solid;
    border-color: var(--success);
    color: var(--success);
    background: var(--success-soft);
}

/* Amber pulse for active tiles */
@keyframes pulseAmber {
    0%, 100% { box-shadow: 0 0 0 2px rgba(234, 179, 8, 0.25); }
    50% { box-shadow: 0 0 12px 4px rgba(234, 179, 8, 0.12); }
}

/* Inline spinner for active step tiles */
.tile-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(234, 179, 8, 0.3);
    border-top-color: var(--warning);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.step-icon {
    font-size: var(--text-lg);
    margin-bottom: var(--space-2);
}

.step-label {
    font-size: var(--text-xs);
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Report stage full width */
#stage-REPORT {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-4);
    padding: var(--space-6);
    margin-top: var(--space-3);
    min-height: 80px;
    font-size: var(--text-lg);
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

#stage-REPORT.active {
    background: var(--primary-soft);
    border-color: var(--primary);
    color: var(--primary);
    box-shadow: var(--shadow-glow);
}

#stage-REPORT.completed {
    background: var(--success-soft);
    border-color: var(--success);
    color: var(--success);
}

/* ===== CONSOLE ===== */
.console-card {
    background: var(--bg-body);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.console-header {
    background: var(--bg-surface);
    padding: var(--space-3) var(--space-4);
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border);
}

.console-header span {
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.console-body {
    padding: var(--space-4);
    font-family: var(--font-mono);
    font-size: var(--text-sm);
    color: var(--text-secondary);
    height: 300px;
    overflow-y: auto;
    line-height: 1.7;
}

.console-body div {
    padding: var(--space-1) 0;
    border-bottom: 1px solid var(--border);
}

.console-body div:last-child {
    border-bottom: none;
}

/* ===== META LIST ===== */
.meta-list {
    list-style: none;
}

.meta-list li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-3) 0;
    border-bottom: 1px solid var(--border);
    font-size: var(--text-sm);
}

.meta-list li:last-child {
    border-bottom: none;
}

.meta-label {
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.meta-val {
    color: var(--text-primary);
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

/* ===== INFO BOX ===== */
.info-box {
    background: var(--bg-surface-2);
    border: 1px solid var(--border);
    padding: var(--space-5);
    border-radius: var(--radius-lg);
}

.info-box h4 {
    font-size: var(--text-sm);
    font-weight: 700;
    color: var(--primary);
    margin-bottom: var(--space-3);
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.info-box p {
    color: var(--text-secondary);
    line-height: 1.7;
    margin: 0;
}

/* ===== STAT CARDS ===== */
.stat-card {
    flex: 1;
    min-width: 180px;
    background: var(--bg-surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--space-4);
}

.stat-label {
    font-size: var(--text-xs);
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: var(--space-1);
}

.stat-value {
    font-size: var(--text-xl);
    font-weight: 800;
    color: var(--text-primary);
}

/* ===== MUSIC BOX ===== */
.music-detected-box {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    background: var(--success-soft);
    border: 1px solid var(--success-border);
    padding: var(--space-4);
    border-radius: var(--radius-lg);
    gap: var(--space-4);
}

.music-icon {
    width: 44px;
    height: 44px;
    background: rgba(34, 197, 94, 0.2);
    color: var(--success);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--text-lg);
}

.music-info {
    flex: 1;
}

.music-title {
    font-weight: 700;
    color: var(--success);
    font-size: var(--text-base);
}

.music-artist {
    font-size: var(--text-sm);
    color: var(--success);
    opacity: 0.8;
}

.music-actions {
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

/* ===== WARNING BOX ===== */
.warning-box {
    padding: var(--space-4);
    background: var(--warning-soft);
    border: 1px solid var(--warning-border);
    border-radius: var(--radius-lg);
    color: var(--warning);
    font-size: var(--text-sm);
}

/* ===== DARK TABLE ===== */
.dark-table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--text-sm);
}

.dark-table thead tr {
    background: var(--bg-surface-2);
}

.dark-table th,
.dark-table td {
    text-align: left;
    padding: var(--space-3) var(--space-4);
    border-bottom: 1px solid var(--border);
    color: var(--text-primary);
}

.dark-table th {
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    font-size: var(--text-xs);
    letter-spacing: 0.05em;
}

.dark-table tbody tr:hover {
    background: var(--bg-hover);
}

/* ===== TRANSCRIPT BOX ===== */
.transcript-box {
    background: var(--bg-surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--space-5);
    font-size: var(--text-sm);
    color: var(--text-primary);
    max-height: 500px;
    overflow-y: auto;
    line-height: 1.8;
}

/* ===== FRAME GRID ===== */
.frame-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--space-2);
}

.frame-thumb {
    cursor: pointer;
    aspect-ratio: 16/9;
    border-radius: var(--radius-md);
    overflow: hidden;
    border: 1px solid var(--border);
    transition: all var(--transition-fast);
}

.frame-thumb:hover {
    border-color: var(--primary);
    transform: scale(1.02);
}

.frame-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform var(--transition-base);
}

.frame-thumb:hover img {
    transform: scale(1.1);
}

.frame-more {
    cursor: pointer;
    aspect-ratio: 16/9;
    border-radius: var(--radius-md);
    background: var(--bg-surface-2);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--text-sm);
    font-weight: 700;
    color: var(--text-muted);
    transition: all var(--transition-fast);
}

.frame-more:hover {
    border-color: var(--primary);
    color: var(--primary);
}

/* ===== SOCIAL BUTTONS ===== */
.social-btn {
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-md);
    border: none;
    color: white;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    font-size: var(--text-sm);
    font-weight: 500;
    transition: all var(--transition-fast);
    text-decoration: none;
}

.social-btn:hover {
    transform: scale(1.05);
    opacity: 0.9;
}

.social-btn.spotify { background: #1DB954; }
.social-btn.deezer { background: linear-gradient(90deg, #FEAA2D, #EF3054, #A62DA2, #24298E); }
.social-btn.youtube { background: #FF0000; }

/* ===== MODAL ===== */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: var(--z-modal);
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
}

.modal {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    overflow: hidden;
    animation: slideUp var(--transition-slow);
}

.modal-header {
    background: var(--bg-body);
    padding: var(--space-5);
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    font-size: var(--text-lg);
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: var(--space-3);
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-muted);
    line-height: 1;
    padding: var(--space-1);
    transition: color var(--transition-fast);
}

.modal-close:hover {
    color: var(--primary);
}

.modal-body {
    padding: var(--space-6);
    max-height: 70vh;
    overflow-y: auto;
}

/* Modal Sections */
.modal-section {
    padding: var(--space-5);
    border-bottom: 1px solid var(--border);
}

.modal-section:last-child {
    border-bottom: none;
}

.modal-section-header {
    font-size: var(--text-xs);
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: var(--space-3);
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.modal-section-header i {
    color: var(--primary);
}

.modal-section .meta-list li:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

/* ===== GALLERY ===== */
.gallery-overlay {
    display: none;
    position: fixed;
    z-index: var(--z-modal);
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.95);
    backdrop-filter: blur(8px);
    align-items: center;
    justify-content: center;
}

.gallery-card {
    background: var(--bg-surface);
    width: 90%;
    max-width: 1000px;
    max-height: 90vh;
    border-radius: var(--radius-xl);
    border: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: slideUp var(--transition-slow);
}

.gallery-header {
    padding: var(--space-4) var(--space-5);
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-body);
}

.gallery-title {
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

.gallery-counter {
    font-size: var(--text-xs);
    color: var(--text-muted);
    background: var(--bg-surface-2);
    padding: var(--space-1) var(--space-3);
    border-radius: var(--radius-full);
    font-weight: 600;
}

.gallery-close-btn {
    background: none;
    border: none;
    font-size: 1.8rem;
    color: var(--text-muted);
    cursor: pointer;
    line-height: 1;
    transition: color var(--transition-fast);
}

.gallery-close-btn:hover {
    color: var(--primary);
}

.gallery-body {
    flex: 1;
    position: relative;
    background: var(--bg-body);
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 400px;
    overflow: hidden;
}

.gallery-image {
    max-width: 100%;
    max-height: 75vh;
    object-fit: contain;
}

.gallery-nav-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: var(--bg-surface);
    border: 1px solid var(--border);
    color: var(--text-primary);
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: var(--text-lg);
    transition: all var(--transition-base);
    z-index: 10;
}

.gallery-nav-btn:hover {
    background: var(--primary);
    border-color: var(--primary);
    transform: translateY(-50%) scale(1.1);
}

.gallery-prev { left: var(--space-5); }
.gallery-next { right: var(--space-5); }

/* ===== DETAILS/ACCORDION ===== */
details {
    background: var(--bg-surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

details summary {
    cursor: pointer;
    color: var(--text-primary);
    font-weight: 600;
    padding: var(--space-4);
    list-style: none;
    display: flex;
    align-items: center;
    gap: var(--space-3);
    transition: background var(--transition-fast);
}

details summary::-webkit-details-marker {
    display: none;
}

details summary::before {
    content: "\f054";
    font-family: "Font Awesome 6 Free";
    font-weight: 900;
    font-size: var(--text-xs);
    transition: transform var(--transition-fast);
}

details[open] summary::before {
    transform: rotate(90deg);
}

details summary:hover {
    background: var(--bg-hover);
}

details > *:not(summary) {
    padding: 0 var(--space-4) var(--space-4);
}

/* ===== FILTER TAGS ===== */
.filter-tag {
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-md);
    font-size: var(--text-sm);
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    border: 1px solid transparent;
    font-weight: 500;
}

.tag-visual {
    background: var(--info-soft);
    color: var(--info);
    border-color: var(--info-border);
}

.tag-audio {
    background: var(--primary-soft);
    color: var(--primary);
    border-color: rgba(255, 0, 85, 0.3);
}

.filter-tag span {
    cursor: pointer;
    font-weight: bold;
    opacity: 0.6;
    font-size: var(--text-base);
    line-height: 1;
}

.filter-tag span:hover {
    opacity: 1;
    color: var(--danger);
}

/* ===== POLICY CHECKBOX ===== */
.policy-checkbox {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    font-size: var(--text-sm);
    color: var(--text-primary);
    cursor: pointer;
    background: var(--bg-surface-2);
    padding: var(--space-3);
    border-radius: var(--radius-md);
    border: 1px solid transparent;
    transition: all var(--transition-fast);
}

.policy-checkbox:hover {
    background: var(--bg-hover);
    border-color: var(--border);
}

.policy-checkbox:has(input:checked) {
    border-color: var(--border-hover);
    background: var(--bg-surface-3);
}

/* ===== ANALYSIS STEP SELECTION ===== */
.analysis-groups-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-4);
}

.analysis-group {
    background: var(--bg-surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--space-3);
}

.analysis-group-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-3);
}

.analysis-group-header span {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    font-size: var(--text-sm);
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.analysis-group-header .flex {
    gap: var(--space-1);
}

.analysis-steps {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-2);
}

.step-checkbox {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    font-size: var(--text-sm);
    color: var(--text-primary);
    cursor: pointer;
    background: var(--bg-surface);
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-md);
    border: 1px solid transparent;
    transition: all var(--transition-fast);
}

.step-checkbox:hover {
    background: var(--bg-hover);
    border-color: var(--border);
}

.step-checkbox:has(input:checked) {
    border-color: var(--border-hover);
    background: var(--bg-surface-3);
}

.step-checkbox:has(input:disabled) {
    opacity: 0.5;
    cursor: not-allowed;
}

.step-checkbox:has(input:disabled):has(input:checked) {
    opacity: 0.85;
    border-color: var(--success);
    background: var(--success-soft);
    color: var(--success);
}

/* Single-item groups: let checkbox span full width */
.analysis-steps:has(> :only-child) {
    grid-template-columns: 1fr;
}

#video-status-badge {
    font-size: var(--text-xs);
    font-weight: 600;
    padding: var(--space-1) var(--space-3);
    border-radius: var(--radius-full);
}

#video-status-badge.badge-new {
    background: var(--primary-soft);
    color: var(--primary);
    border: 1px solid var(--primary);
}

#video-status-badge.badge-existing {
    background: var(--success-soft);
    color: var(--success);
    border: 1px solid var(--success);
}

/* ===== CONFIG SECTION ===== */
.config-section {
    border-bottom: 1px solid var(--border);
    padding-bottom: var(--space-6);
    margin-bottom: var(--space-6);
}

.config-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

/* ===== FILTER RESULTS ===== */
.filter-results {
    display: flex;
    gap: var(--space-8);
    flex-wrap: wrap;
    padding: var(--space-5);
}

.filter-results-group {
    flex: 1;
    min-width: 250px;
}

.filter-results-label {
    font-size: var(--text-xs);
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    margin-bottom: var(--space-3);
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.filter-results-items {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.filter-result-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    border-left: 3px solid transparent;
    background: var(--bg-surface-2);
    transition: all var(--transition-base);
}

.filter-result-item:hover {
    background: var(--bg-hover);
}

.filter-result-item.detected {
    background: var(--success-soft);
    border-color: var(--success-border);
    border-left-color: var(--success);
}

.filter-result-item.not-found {
    background: var(--danger-soft);
    border-color: var(--danger-border);
    border-left-color: var(--danger);
}

.filter-term {
    font-weight: 600;
    color: var(--text-primary);
}

.filter-status {
    font-size: var(--text-xs);
    font-weight: 700;
    text-transform: uppercase;
    display: flex;
    align-items: center;
    gap: var(--space-1);
}

.filter-result-item.detected .filter-status { color: var(--success); }
.filter-result-item.not-found .filter-status { color: var(--danger); }

/* ===== AUDIT CONFIG CARD ===== */
.audit-config-card {
    margin-bottom: var(--space-6);
    background: linear-gradient(135deg, var(--bg-surface) 0%, var(--bg-surface-2) 100%);
}

.policy-count {
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--primary);
    background: var(--primary-soft);
    padding: var(--space-1) var(--space-3);
    border-radius: var(--radius-md);
    border: 1px solid rgba(255, 0, 85, 0.3);
}

/* ===== LOADING SPINNER ===== */
.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.spinner-lg {
    width: 40px;
    height: 40px;
    border-width: 3px;
}

/* ===== EMPTY STATE ===== */
.empty-state {
    text-align: center;
    padding: var(--space-12);
    color: var(--text-muted);
}

.empty-state i {
    font-size: 3rem;
    margin-bottom: var(--space-4);
    opacity: 0.5;
}

/* ===== NOT PERFORMED (skipped analysis) ===== */
.not-performed {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-3);
    padding: var(--space-6);
    color: var(--text-muted);
    font-style: italic;
    font-size: var(--text-sm);
}

.not-performed i {
    font-size: var(--text-lg);
    opacity: 0.5;
}

/* ===== TOOLTIP ===== */
[data-tooltip] {
    position: relative;
}

[data-tooltip]:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    padding: var(--space-2) var(--space-3);
    background: var(--bg-surface-3);
    color: var(--text-primary);
    font-size: var(--text-xs);
    border-radius: var(--radius-md);
    white-space: nowrap;
    border: 1px solid var(--border);
    z-index: var(--z-tooltip);
    margin-bottom: var(--space-2);
}

/* ===== AUDIO PLAYER ===== */
audio {
    width: 100%;
    height: 40px;
    margin-top: var(--space-3);
    color-scheme: dark;
}

/* ===== FILTER SECTION ===== */
.filter-section {
    margin-bottom: var(--space-4);
}

.filter-section:last-child {
    margin-bottom: 0;
}

.filter-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-2);
}

.filter-label {
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.filter-tags {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
    min-height: 32px;
}

/* ===== POLICY GRID ===== */
.policy-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: var(--space-2);
}

/* ===== INPUT GROUP ===== */
.input-group {
    position: relative;
}

.input-icon {
    position: absolute;
    left: var(--space-3);
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: var(--text-base);
    pointer-events: none;
}

.input-with-icon {
    padding-left: var(--space-10) !important;
}

/* ===== CONSOLE ALIAS ===== */
.console {
    background: var(--bg-body);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

/* ===== SCROLL FADE INDICATOR ===== */
.scroll-fade {
    position: relative;
    mask-image: linear-gradient(to bottom, black 85%, transparent 100%);
    -webkit-mask-image: linear-gradient(to bottom, black 85%, transparent 100%);
}

/* ===== MOBILE RESPONSIVE ===== */
@media (max-width: 768px) {
    /* Steps grid: auto-fill already adapts, just tighten gap */
    #steps-grid-container {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
        gap: var(--space-2);
    }

    /* Frame grid: 4col -> 2col */
    .frame-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    /* Stat cards: remove min-width, allow 2-up */
    .stat-card {
        min-width: 0;
        flex-basis: calc(50% - var(--space-2));
    }

    /* Tabs: horizontal scroll */
    .tabs {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }
    .tabs::-webkit-scrollbar {
        display: none;
    }
    .tab {
        white-space: nowrap;
        flex: 0 0 auto;
        padding: var(--space-3) var(--space-4);
        min-height: 44px;
    }

    /* Gallery: full-screen on mobile */
    .gallery-card {
        width: 100%;
        max-width: 100%;
        height: 100vh;
        max-height: 100vh;
        border-radius: 0;
    }
    .gallery-body {
        min-height: 0;
        flex: 1;
    }
    .gallery-nav-btn {
        width: 40px;
        height: 40px;
    }
    .gallery-prev { left: var(--space-2); }
    .gallery-next { right: var(--space-2); }

    /* Music detected box: stack */
    .music-detected-box {
        flex-direction: column;
        align-items: flex-start;
    }
    .music-actions {
        width: 100%;
        justify-content: flex-start;
    }

    /* Policy grid: smaller minmax */
    .policy-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    }

    /* Filter results: stack */
    .filter-results {
        flex-direction: column;
        gap: var(--space-4);
        padding: var(--space-3);
    }
    .filter-results-group {
        min-width: 0;
    }

    /* Timeline: compact labels */
    .timeline-label {
        font-size: 0.65rem;
        max-width: 60px;
    }

    /* Category cards: keep 2x2 on mobile */
    .category-scores-grid {
        gap: var(--space-2);
    }

    .category-score {
        font-size: var(--text-2xl);
    }

    /* Console body: shorter */
    .console-body {
        height: 200px;
    }

    /* Modal: wider on mobile */
    .modal {
        width: 95%;
        max-width: none;
    }
    .modal-body {
        padding: var(--space-4);
    }

    /* Analysis groups: 1 column on tablet */
    .analysis-groups-grid {
        grid-template-columns: 1fr;
    }

    /* Input + button rows: stack on mobile */
    .input-action-row {
        flex-direction: column;
    }
    .input-action-row .btn {
        width: 100%;
        justify-content: center;
    }
}

@media (max-width: 480px) {
    /* Card padding reduction */
    .card {
        padding: var(--space-4);
    }
    .card-header {
        padding-bottom: var(--space-3);
        margin-bottom: var(--space-3);
        flex-wrap: wrap;
        gap: var(--space-2);
    }

    /* Steps grid: tighter */
    #steps-grid-container {
        gap: var(--space-1);
    }
    .step-item {
        padding: var(--space-2) var(--space-1);
    }
    .step-label {
        font-size: 0.65rem;
    }

    /* Stat cards: full width */
    .stat-card {
        flex-basis: 100%;
    }

    /* Info box: less padding */
    .info-box {
        padding: var(--space-3);
    }

    /* Transcript box: shorter */
    .transcript-box {
        max-height: 300px;
    }

    /* Frame grid: tighter gap */
    .frame-grid {
        gap: var(--space-1);
    }

    /* Empty state: less padding */
    .empty-state {
        padding: var(--space-6);
    }

    /* Analysis steps: single column + compact on small screens */
    .analysis-steps {
        grid-template-columns: 1fr;
    }
    .analysis-group {
        padding: var(--space-2);
    }
    .step-checkbox {
        font-size: var(--text-xs);
        padding: var(--space-2);
    }

    /* Meta list: wrap on small screens */
    .meta-list li {
        flex-wrap: wrap;
        gap: var(--space-1);
    }
}
