/* Layout */
.app-layout {
    display: grid;
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
    grid-template-areas:
        "header"
        "main";
    min-height: 100vh;
}

/* Layout with Sidebar (applied via JS when needed) */
/* Layout with Sidebar (Removed as per user request) */
.app-layout.with-sidebar {
    grid-template-columns: 1fr;
    grid-template-areas:
        "header"
        "main";
}

/* Header */
.app-header {
    grid-area: header;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--text-base) 2.5rem;
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    border-bottom: 1px solid var(--glass-border);
    z-index: 100;
    position: sticky;
    top: 0;
}

/* ... (Header content styles unchanged, skipping brevity) ... */





.header-content {
    /* max-width: 1400px; Remove max-width to align with fluid main content */
    /* margin: 0 auto; */
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.header-right {
    display: flex;
    align-items: center;
    gap: var(--space-lg);
}

.app-version {
    font-size: 0.7rem;
    color: var(--text-muted);
    font-weight: 500;
    letter-spacing: 0.05em;
    padding: 2px var(--radius-md);
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-secondary);
    border-radius: var(--radius-full);
    text-transform: uppercase;
    opacity: 0.8;
}


.logo-section {
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

.logo {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
}

.stat-value {
    font-size: 13px;
    font-weight: 600;
    line-height: 1.2;
    margin-bottom: 2px;
}

.logo h1 {
    font-size: var(--text-2xl);
    font-weight: 700;
    line-height: 1;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-hover));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin: 0;
}

.header-divider {
    width: 1px;
    height: 24px;
    background-color: var(--border-secondary);
}

.tagline {
    font-size: var(--text-xs);
    color: var(--text-secondary);
    font-weight: 300;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    opacity: 0.8;
}

/* Preset Sidebar */
.preset-sidebar {
    grid-area: sidebar;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-primary);
    padding: var(--space-lg);
    overflow-y: auto;
    height: 100%;
}

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

.sidebar-header h2 {
    font-size: 1.3rem;
    font-weight: 300;
    font-family: var(--font-base);
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--text-primary);
}

.preset-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.preset-item {
    padding: var(--space-md);
    background: var(--bg-card);
    border: 1px solid var(--border-secondary);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-base);
    position: relative;
}

.preset-item:hover {
    background: rgba(168, 85, 247, 0.1);
    border-color: var(--accent-primary);
    transform: translateX(var(--radius-sm));
}

.preset-item.active {
    background: rgba(168, 85, 247, 0.15);
    border-color: var(--accent-primary);
}

.preset-name {
    font-size: var(--text-base);
    font-weight: 300;
    font-family: var(--font-base);
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--text-primary);
    margin-bottom: var(--space-xs);
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.preset-desc {
    font-size: 0.95rem;
    color: var(--text-secondary);
    line-height: 1.4;
}

.preset-badge {
    display: inline-block;
    padding: 2px var(--radius-md);
    background: var(--accent-primary);
    color: var(--bg-primary);
    font-size: 0.85rem;
    border-radius: var(--radius-full);
    font-weight: 600;
    font-family: var(--font-base);
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

/* Main Content Area */
.main-content {
    grid-area: main;
    padding: 0;
    /* Full width support */
    overflow-y: auto;
    width: 100%;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: var(--space-xl);
    width: 100%;
}

.main-content.centered {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

/* When sidebar is hidden (Upload Phase), main content takes full width */
.app-layout:not(.with-sidebar) .main-content {
    grid-column: 1 / -1;
    max-width: 100%;
}

.preview-section {
    width: 100%;
    max-width: 1000px;
    /* Start hidden */
}

/* Tabs */
.tabs {
    display: flex;
    gap: var(--space-sm);
    margin-bottom: var(--space-xl);
    border-bottom: 2px solid var(--border-secondary);
    padding-bottom: 0;
}

.tab {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-md) var(--space-lg);
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 500;
    border-bottom: 3px solid transparent;
    transition: all var(--transition-base);
    position: relative;
    bottom: -2px;
}

.tab:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.02);
}

.tab.active {
    color: var(--accent-primary);
    border-bottom-color: var(--accent-primary);
}

.tab svg {
    transition: transform var(--transition-base);
}

.tab:hover svg {
    transform: scale(1.1);
}

/* Tab Panels */
.tab-panels {
    animation: fadeIn 0.3s ease;
}

.tab-panel {
    display: none;
    animation: fadeIn 0.3s ease;
}

.tab-panel.active {
    display: block;
}

/* --- Preview Section --- */
#preview-section {
    max-width: 900px;
    margin: var(--space-xl) auto;
    text-align: center;
}

#preview-section .card {
    padding: var(--space-xl);
}

#preview-section h2 {
    margin-bottom: var(--space-xs);
    font-size: var(--text-2xl);
}

.preview-controls {
    margin: var(--text-2xl) 0;
}

/* --- Header Preset Info --- */
.header-preset-info {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: var(--text-base);
    flex: 1;
}

.header-preset-info .info-icon {
    font-size: 24px;
    /* Larger icon */
    display: flex;
    align-items: center;
    justify-content: center;
}

.header-preset-info .info-text {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.header-preset-info .info-name {
    font-size: 18px;
    font-weight: 700;
    color: #fff;
    line-height: 1.35;
}




/* --- V260 Updates: forced overrides --- */
.stat-value {
    font-family: var(--font-mono);
    font-size: 18px !important;
    font-weight: 700;
    margin: var(--radius-sm) 0;
    color: var(--text-primary) !important;
    /* Force high contrast */
    text-shadow: 0 0 10px var(--glass-border);
}



.header-preset-info .info-name {
    font-size: 18px;
    font-weight: 700;
    color: #fff;
    line-height: 1.35;
}

.card-info {
    display: none;
}

.header-right-group {
    margin-left: auto !important;
    display: flex;
    align-items: center;
    gap: var(--radius-lg);
}

/* --- Global Mastering Settings (Toolbar) --- */
.global-settings-toolbar {
    background: rgba(24, 24, 27, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--radius-lg);
    padding: var(--text-2xl);
    margin-bottom: var(--space-xl);
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-xl);
    align-items: flex-start;
    justify-content: center;
    /* Center align for better look */
}

.setting-group {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
    align-items: center;
    /* Center labels above inputs */
}

.setting-group label.group-label {
    font-size: 0.7rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
}

.setting-row {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
}

.setting-input-num {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-primary);
    color: var(--text-primary);
    border-radius: var(--radius-sm);
    padding: 6px var(--radius-md);
    width: 64px;
    font-size: 0.9rem;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

.setting-input-num:focus {
    border-color: var(--accent-primary);
    outline: none;
}


.unit-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.setting-desc {
    font-size: 0.7rem;
    color: var(--text-secondary);
    /* Zync-400 */
    max-width: 180px;
    /* Adjusted from 140px to fit 2 lines */
    text-align: center;
    line-height: 1.4;
    margin-top: 6px;
    font-weight: 400;
}

.mastering-hub-btn {
    width: 320px;
    height: 128px;
    background: var(--glass-border);
    backdrop-filter: none;
    /* Removed blur to fix rendering bugs */
    border: 1px solid var(--glass-border);
    color: var(--text-primary);
    border-radius: var(--radius-md);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.5s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    box-shadow:
        inset 0 1px 1px var(--glass-border),
        0 var(--radius-sm) 24px -4px rgba(0, 0, 0, 0.5);
}

/* REMOVED: .mastering-hub-btn::before and :hover::before to fix visual bugs */

.hub-btn-content {
    display: flex;
    align-items: center;
    gap: var(--radius-lg);
    z-index: 2;
    transition: transform 0.3s ease;
}

.hub-btn-glow {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 140%;
    height: 140%;
    background: radial-gradient(circle, var(--accent-primary) 0%, transparent 70%);
    transform: translate(-50%, -50%) scale(0);
    opacity: 0;
    transition: transform 0.6s ease, opacity 0.6s ease;
    filter: blur(20px);
    z-index: 1;
}

.mastering-hub-btn:hover {
    border-color: rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.05);
    /* Unified with preset-card */
}

/* REMOVED: .mastering-hub-btn:hover .hub-btn-glow to fix visual bugs */

/* Fix for v4.7: Hide idle glow when in complete state to prevent flickering */
.mastering-hub-btn.complete:hover .hub-btn-glow {
    opacity: 0;
}

.mastering-hub-btn:active {
    transform: scale(0.98);
}

/* Processing State */
.mastering-hub-btn.processing {
    border-color: var(--border-primary);
    color: var(--text-secondary);
    cursor: wait;
    pointer-events: none;
    font-size: 0.7rem;
    letter-spacing: 0.1em;
}

.mastering-hub-btn.processing .btn-icon {
    animation: hub-pulse 2s infinite;
}

/* Complete State (Download) v4.9: Brighter Solid & Controlled Hover */
.mastering-hub-btn.complete {
    border: none;
    background: color-mix(in srgb, var(--preset-active-color, var(--success)), black 15%);
    color: #fff;
    font-weight: 600;
    box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.7);
    /* Darker shadow */
    text-shadow: none;
}

.mastering-hub-btn.complete .processing-spinner {
    background: color-mix(in srgb, var(--preset-active-color, var(--success)), black 40%);
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.5);
    /* Use darker shadow instead of white glow */
}

.mastering-hub-btn.complete .btn-icon svg {
    stroke: #fff;
}

.mastering-hub-btn.complete:hover {
    background: color-mix(in srgb, var(--preset-active-color, var(--success)), black 5%);
    border-color: rgba(255, 255, 255, 0.3);
}

.processing-spinner {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 2px;
    background: var(--accent-primary);
    width: 0%;
    transition: width 0.3s ease;
    z-index: 3;
    box-shadow: 0 0 10px var(--accent-primary);
}

@keyframes hub-pulse {
    0% {
        transform: scale(1);
        opacity: 1;
    }

    50% {
        transform: scale(1.2);
        opacity: 0.5;
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.eq-slider.is-tweaking::-webkit-slider-thumb {
    background: var(--accent-primary);
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.4);
}

.eq-slider {
    transition: filter 0.2s ease;
}

.eq-slider:hover {
    filter: brightness(1.2);
}

/* --- Global Processing Overlay --- */
.processing-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(var(--radius-lg));
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    opacity: 1;
    transition: opacity 0.4s ease, visibility 0.4s;
    cursor: wait;
}

.processing-overlay.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.overlay-content {
    text-align: center;
    max-width: 400px;
    width: 90%;
}

.premium-loader {
    position: relative;
    width: 100px;
    height: 100px;
    margin: 0 auto 2.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.loader-ring {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    /* conic-gradient を使用して消えていく光の跡を表現 */
    background: conic-gradient(from 0deg,
            transparent 0%,
            color-mix(in srgb, var(--preset-active-color, var(--accent-primary)), transparent 80%) 50%,
            var(--preset-active-color, var(--accent-primary)) 100%);
    /* マスクを使用してリングの形状にする */
    -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 3px), #000 calc(100% - 2px));
    mask: radial-gradient(farthest-side, transparent calc(100% - 3px), #000 calc(100% - 2px));
    animation: spin-premium 1s linear infinite;
}

/* リングの先端に光る点（ヘッド）を追加 */
.loader-ring::after {
    content: '';
    position: absolute;
    top: -1px;
    left: 50%;
    width: var(--radius-sm);
    height: var(--radius-sm);
    background: #fff;
    border-radius: 50%;
    box-shadow: 0 0 10px 2px var(--preset-active-color, var(--accent-primary));
    transform: translateX(-50%);
}

.loader-pulse {
    position: absolute;
    width: 60%;
    height: 60%;
    background: radial-gradient(circle,
            color-mix(in srgb, var(--preset-active-color, var(--accent-primary)), transparent 40%) 0%,
            transparent 70%);
    border-radius: 50%;
    filter: blur(var(--radius-md));
    animation: pulse-glow-premium 2s ease-in-out infinite;
}

@keyframes spin-premium {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

@keyframes pulse-glow-premium {

    0%,
    100% {
        transform: scale(0.85);
        opacity: 0.2;
    }

    50% {
        transform: scale(1.15);
        opacity: 0.5;
    }
}

.status-container h3 {
    font-size: 1.4rem;
    font-weight: 300;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-primary);
    margin-bottom: var(--text-xs);
    font-family: var(--font-base);
}

#overlay-status-text {
    font-size: 1.05rem;
    color: var(--text-secondary);
    font-family: var(--font-base);
    margin-top: var(--text-2xl);
    margin-bottom: var(--space-xl);
    line-height: 1.6;
    height: 1.6em;
}

#overlay-progress-bar-container {
    width: 100%;
    height: 2px;
    background: var(--glass-border);
    border-radius: 1px;
    overflow: hidden;
}

#overlay-progress-bar {
    height: 100%;
    width: 0%;
    background: var(--accent-primary);
    box-shadow: 0 0 10px var(--accent-glow);
    transition: width 0.3s ease;
}

body.is-processing {
    overflow: hidden;
}

body.is-processing * {
    cursor: wait !important;
}