/* ========================================
   Math → Music - Main Stylesheet
   ======================================== */

/* === CSS Variables === */
:root {
    --bg-primary: #0a0a1a;
    --bg-secondary: #111128;
    --bg-card: #1a1a3e;
    --bg-card-hover: #222255;
    --text-primary: #e8e8f0;
    --text-secondary: #9999bb;
    --text-muted: #666688;
    --accent: #6c5ce7;
    --accent-light: #a29bfe;
    --accent-glow: rgba(108, 92, 231, 0.3);
    --success: #00b894;
    --warning: #fdcb6e;
    --danger: #ff6b6b;
    --exp-color: #ff6b6b;
    --log-color: #a29bfe;
    --linear-color: #fdcb6e;
    --trig-color: #55efc4;
    --poly-color: #fd79a8;
    --sqrt-color: #74b9ff;
    --border: rgba(255, 255, 255, 0.08);
    --shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    --radius: 12px;
    --radius-sm: 8px;
    --transition: all 0.3s ease;
    --font-mono: 'JetBrains Mono', monospace;
    --font-sans: 'Noto Sans SC', -apple-system, sans-serif;
}

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-sans);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    overflow-x: hidden;
    min-height: 100vh;
}

/* === Background Canvas === */
#bg-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
    opacity: 0.4;
}

/* === App Container === */
.app-container {
    position: relative;
    z-index: 1;
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* === Header === */
.app-header {
    text-align: center;
    padding: 40px 0 30px;
}

.logo {
    display: inline-block;
}

.logo-icon {
    font-size: 2.5rem;
    color: var(--accent-light);
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}

.logo h1 {
    font-size: 2.8rem;
    font-weight: 700;
    letter-spacing: -1px;
    margin: 8px 0;
    background: linear-gradient(135deg, var(--accent-light), #55efc4, var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.logo .accent {
    font-family: var(--font-mono);
}

.subtitle {
    color: var(--text-secondary);
    font-size: 1.1rem;
    font-weight: 300;
}

/* === Cards === */
.input-card, .graph-card, .music-info-card, .player-card, .roll-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
    transition: var(--transition);
}

.input-card:hover, .graph-card:hover, .music-info-card:hover {
    border-color: rgba(108, 92, 231, 0.2);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.card-header h3 {
    font-size: 1rem;
    color: var(--text-secondary);
    font-weight: 600;
}

.card-header h3 i {
    margin-right: 8px;
    color: var(--accent-light);
}

/* === Input Section === */
.input-section {
    margin-bottom: 24px;
}

.input-card h2 {
    font-size: 1.2rem;
    margin-bottom: 16px;
    color: var(--text-primary);
}

.input-card h2 i {
    margin-right: 8px;
    color: var(--accent-light);
}

.input-group {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.input-group label {
    font-family: var(--font-mono);
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--accent-light);
    white-space: nowrap;
}

.input-group input[type="text"] {
    flex: 1;
    background: rgba(0, 0, 0, 0.3);
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 1.1rem;
    outline: none;
    transition: var(--transition);
}

.input-group input[type="text"]:focus {
    border-color: var(--accent);
    box-shadow: 0 0 20px var(--accent-glow);
}

.input-group input[type="text"]::placeholder {
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* === Buttons === */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    border: none;
    border-radius: var(--radius-sm);
    font-family: var(--font-sans);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent), #8b5cf6);
    color: white;
    box-shadow: 0 4px 15px var(--accent-glow);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 25px var(--accent-glow);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    background: rgba(108, 92, 231, 0.15);
    color: var(--accent-light);
    border: 1px solid rgba(108, 92, 231, 0.3);
}

.btn-secondary:hover {
    background: rgba(108, 92, 231, 0.25);
    transform: translateY(-2px);
}

.btn-outline {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border);
    padding: 8px 16px;
    font-size: 0.85rem;
}

.btn-outline:hover {
    border-color: var(--accent);
    color: var(--accent-light);
}

/* === Function Hints === */
.function-hints {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.hint-title {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.hint-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    border: 1px solid transparent;
}

.tag small {
    font-weight: 400;
    opacity: 0.7;
}

.tag-exp { background: rgba(255, 107, 107, 0.15); color: var(--exp-color); }
.tag-log { background: rgba(162, 155, 254, 0.15); color: var(--log-color); }
.tag-linear { background: rgba(253, 203, 110, 0.15); color: var(--linear-color); }
.tag-trig { background: rgba(85, 239, 196, 0.15); color: var(--trig-color); }
.tag-poly { background: rgba(253, 121, 168, 0.15); color: var(--poly-color); }
.tag-sqrt { background: rgba(116, 185, 255, 0.15); color: var(--sqrt-color); }

.tag:hover {
    transform: scale(1.05);
    border-color: currentColor;
}

/* === Visualization Section === */
.viz-section {
    margin-bottom: 24px;
}

.viz-panel {
    display: grid;
    grid-template-columns: 1.5fr 1fr;
    gap: 20px;
}

.graph-card {
    min-height: 350px;
}

#graph-canvas {
    width: 100%;
    height: 280px;
    border-radius: var(--radius-sm);
    background: rgba(0, 0, 0, 0.2);
}

.graph-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.range-input {
    width: 60px;
    padding: 4px 8px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 0.85rem;
    outline: none;
    text-align: center;
}

.range-input:focus {
    border-color: var(--accent);
}

.graph-tooltip {
    position: absolute;
    background: var(--bg-card);
    border: 1px solid var(--accent);
    border-radius: 6px;
    padding: 6px 10px;
    font-family: var(--font-mono);
    font-size: 0.8rem;
    pointer-events: none;
    display: none;
    z-index: 10;
}

/* === Music Params === */
.music-params {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.param-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 200px;
    color: var(--text-muted);
    text-align: center;
}

.param-placeholder i {
    font-size: 2rem;
    margin-bottom: 12px;
    animation: pulseLeft 2s ease-in-out infinite;
}

@keyframes pulseLeft {
    0%, 100% { transform: translateX(0); opacity: 0.5; }
    50% { transform: translateX(-10px); opacity: 1; }
}

.param-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: var(--radius-sm);
    border-left: 3px solid var(--accent);
}

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

.param-value {
    font-family: var(--font-mono);
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
}

.param-row.mood-exp { border-left-color: var(--exp-color); }
.param-row.mood-log { border-left-color: var(--log-color); }
.param-row.mood-linear { border-left-color: var(--linear-color); }
.param-row.mood-trig { border-left-color: var(--trig-color); }
.param-row.mood-poly { border-left-color: var(--poly-color); }
.param-row.mood-sqrt { border-left-color: var(--sqrt-color); }

/* === Player Section === */
.player-section {
    margin-bottom: 24px;
}

.player-card {
    display: flex;
    align-items: center;
    gap: 24px;
    flex-wrap: wrap;
}

.player-info {
    flex: 1;
    min-width: 200px;
}

.now-playing {
    display: flex;
    align-items: center;
    gap: 16px;
}

/* Music Wave Animation */
.music-wave {
    display: flex;
    align-items: flex-end;
    gap: 3px;
    height: 40px;
}

.music-wave span {
    display: block;
    width: 4px;
    background: var(--accent-light);
    border-radius: 2px;
    transition: height 0.2s ease;
}

.music-wave.playing span {
    animation: wave 0.8s ease-in-out infinite;
}

.music-wave span:nth-child(1) { height: 10px; animation-delay: 0s; }
.music-wave span:nth-child(2) { height: 20px; animation-delay: 0.1s; }
.music-wave span:nth-child(3) { height: 30px; animation-delay: 0.2s; }
.music-wave span:nth-child(4) { height: 20px; animation-delay: 0.3s; }
.music-wave span:nth-child(5) { height: 10px; animation-delay: 0.4s; }

@keyframes wave {
    0%, 100% { transform: scaleY(0.5); }
    50% { transform: scaleY(1.5); }
}

.track-info h3 {
    font-size: 1rem;
    color: var(--text-primary);
    margin-bottom: 2px;
}

.track-info p {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-family: var(--font-mono);
}

/* Player Controls */
.player-controls {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 2;
    min-width: 300px;
}

.btn-play {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, var(--accent), #8b5cf6);
    color: white;
    font-size: 1.1rem;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 15px var(--accent-glow);
    flex-shrink: 0;
}

.btn-play:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 25px var(--accent-glow);
}

.btn-control {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.btn-control:hover {
    border-color: var(--accent);
    color: var(--accent-light);
}

.progress-bar {
    flex: 1;
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    overflow: hidden;
    cursor: pointer;
}

.progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--accent), var(--accent-light));
    border-radius: 3px;
    transition: width 0.1s linear;
}

.time-display {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--text-muted);
    white-space: nowrap;
    min-width: 90px;
    text-align: right;
}

/* Player Extra */
.player-extra {
    display: flex;
    align-items: center;
    gap: 16px;
}

.volume-control {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-muted);
}

.volume-control input[type="range"] {
    -webkit-appearance: none;
    width: 80px;
    height: 4px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
    outline: none;
}

.volume-control input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--accent-light);
    cursor: pointer;
}

/* === Piano Roll === */
.roll-section {
    margin-bottom: 24px;
}

#roll-canvas {
    width: 100%;
    height: 200px;
    border-radius: var(--radius-sm);
    background: rgba(0, 0, 0, 0.2);
}

/* === Presets Section === */
.presets-section {
    margin-bottom: 40px;
}

.presets-section h2 {
    font-size: 1.3rem;
    margin-bottom: 20px;
    color: var(--text-primary);
}

.presets-section h2 i {
    color: var(--warning);
    margin-right: 8px;
}

.presets-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 16px;
}

.preset-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
}

.preset-card:hover {
    transform: translateY(-4px);
    border-color: var(--accent);
    box-shadow: 0 8px 30px var(--accent-glow);
}

.preset-icon {
    width: 56px;
    height: 56px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 12px;
    font-size: 1.5rem;
    color: white;
}

.preset-card h4 {
    font-size: 1rem;
    margin-bottom: 6px;
    color: var(--text-primary);
}

.preset-card code {
    display: block;
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--accent-light);
    margin-bottom: 8px;
}

.preset-card p {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* === How It Works === */
.how-section {
    margin-bottom: 40px;
}

.how-section h2 {
    font-size: 1.3rem;
    margin-bottom: 24px;
    color: var(--text-primary);
}

.how-section h2 i {
    color: var(--accent-light);
    margin-right: 8px;
}

.how-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 16px;
}

.how-step {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    text-align: center;
    position: relative;
}

.step-num {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), #8b5cf6);
    color: white;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 12px;
    font-size: 0.95rem;
}

.how-step h4 {
    font-size: 0.95rem;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.how-step p {
    font-size: 0.8rem;
    color: var(--text-muted);
    line-height: 1.5;
}

/* === Footer === */
.app-footer {
    text-align: center;
    padding: 30px 0;
    border-top: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* === Responsive === */
@media (max-width: 900px) {
    .viz-panel {
        grid-template-columns: 1fr;
    }
    .how-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .input-group {
        flex-wrap: wrap;
    }
    .input-group input[type="text"] {
        width: 100%;
    }
    .player-card {
        flex-direction: column;
        align-items: stretch;
    }
    .player-controls {
        min-width: unset;
    }
}

@media (max-width: 600px) {
    .app-container {
        padding: 12px;
    }
    .logo h1 {
        font-size: 2rem;
    }
    .presets-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .how-grid {
        grid-template-columns: 1fr;
    }
}

/* === Animations === */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.fade-in {
    animation: fadeIn 0.5s ease forwards;
}

/* === Waveform Visualization Section === */
.waveform-section {
    margin-bottom: 24px;
}

.waveform-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
}

.waveform-card .card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.waveform-badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 1px;
    color: #ff6b6b;
    background: rgba(255, 107, 107, 0.15);
    border: 1px solid rgba(255, 107, 107, 0.3);
    animation: livePulse 2s ease-in-out infinite;
}

@keyframes livePulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.waveform-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 16px;
}

.waveform-panel {
    position: relative;
}

.waveform-panel canvas {
    width: 100%;
    height: 150px;
    border-radius: var(--radius-sm);
    background: rgba(10, 10, 26, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.waveform-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 6px;
    text-align: center;
}

.waveform-legend {
    display: flex;
    justify-content: center;
    gap: 24px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.78rem;
    color: var(--text-muted);
}

.legend-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* === Overview Waveform Section === */
.overview-section {
    margin-bottom: 24px;
}

.overview-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
}

.overview-card .card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.overview-badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 1px;
    color: #74b9ff;
    background: rgba(116, 185, 255, 0.15);
    border: 1px solid rgba(116, 185, 255, 0.3);
}

#overview-canvas {
    width: 100%;
    height: 120px;
    border-radius: var(--radius-sm);
    background: rgba(10, 10, 26, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.overview-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 8px;
    text-align: center;
}

/* MIDI Download Button */
.btn-midi {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: none;
    border-radius: var(--radius-sm);
    font-family: var(--font-sans);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
    background: linear-gradient(135deg, #00b894, #00cec9);
    color: white;
    box-shadow: 0 3px 10px rgba(0, 184, 148, 0.25);
}

.btn-midi:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 18px rgba(0, 184, 148, 0.35);
}

.btn-midi:active {
    transform: translateY(0);
}

@media (max-width: 900px) {
    .waveform-grid {
        grid-template-columns: 1fr;
    }
    .waveform-legend {
        flex-wrap: wrap;
        gap: 12px;
    }
}

/* === Generation Progress Log === */
.progress-section {
    margin-bottom: 24px;
}

.progress-log-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px 24px;
    box-shadow: var(--shadow);
}

.progress-log-card .card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.gen-status-badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 1px;
    transition: var(--transition);
}

.gen-status-badge.processing {
    color: #fdcb6e;
    background: rgba(253, 203, 110, 0.15);
    border: 1px solid rgba(253, 203, 110, 0.3);
    animation: livePulse 1.5s ease-in-out infinite;
}

.gen-status-badge.success {
    color: #55efc4;
    background: rgba(85, 239, 196, 0.15);
    border: 1px solid rgba(85, 239, 196, 0.3);
    animation: none;
}

.gen-status-badge.error {
    color: #ff6b6b;
    background: rgba(255, 107, 107, 0.15);
    border: 1px solid rgba(255, 107, 107, 0.3);
    animation: none;
}

.gen-progress-bar {
    width: 100%;
    height: 4px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 2px;
    overflow: hidden;
    margin-bottom: 16px;
}

.gen-progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--accent), #55efc4);
    border-radius: 2px;
    transition: width 0.3s ease;
}

.gen-steps {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-family: var(--font-mono);
    font-size: 0.82rem;
    max-height: 260px;
    overflow-y: auto;
}

.gen-step {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    transition: background 0.2s ease;
    line-height: 1.5;
}

.gen-step:last-child {
    background: rgba(255, 255, 255, 0.02);
}

.gen-step-icon {
    flex-shrink: 0;
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    margin-top: 2px;
}

.gen-step-icon.pending {
    color: var(--text-muted);
}

.gen-step-icon.running {
    color: #fdcb6e;
    animation: spin 1s linear infinite;
}

.gen-step-icon.done {
    color: #55efc4;
}

.gen-step-icon.fail {
    color: #ff6b6b;
}

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

.gen-step-text {
    flex: 1;
    color: var(--text-secondary);
}

.gen-step-text .step-label {
    color: var(--text-primary);
    font-weight: 600;
}

.gen-step-text .step-detail {
    color: var(--text-muted);
    font-size: 0.75rem;
}

.gen-step-time {
    flex-shrink: 0;
    font-size: 0.72rem;
    color: var(--text-muted);
    min-width: 50px;
    text-align: right;
}

.gen-summary {
    margin-top: 12px;
    padding: 12px 14px;
    background: rgba(85, 239, 196, 0.06);
    border: 1px solid rgba(85, 239, 196, 0.15);
    border-radius: var(--radius-sm);
    font-size: 0.82rem;
    color: var(--text-secondary);
    line-height: 1.6;
}

.gen-summary .summary-title {
    color: #55efc4;
    font-weight: 600;
    font-family: var(--font-mono);
    margin-bottom: 4px;
}

.gen-summary .summary-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px 16px;
}

.gen-summary .summary-item {
    display: flex;
    justify-content: space-between;
    gap: 8px;
}

.gen-summary .summary-item .s-label {
    color: var(--text-muted);
}

.gen-summary .summary-item .s-value {
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-weight: 600;
}

/* Generate button loading state */
.btn-generating {
    position: relative;
    pointer-events: none;
    opacity: 0.8;
}

.btn-generating::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    border: 2px solid transparent;
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
}

/* === Scrollbar === */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
    background: var(--bg-card);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--accent);
}

/* === Loading State === */
.loading {
    position: relative;
    pointer-events: none;
}

.loading::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.3);
    border-radius: inherit;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Error shake */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

.shake {
    animation: shake 0.3s ease;
    border-color: var(--danger) !important;
}

/* === Cloud Gallery === */
.gallery-section {
    margin-bottom: 40px;
}
.gallery-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
}
.gallery-header h2 {
    margin-bottom: 0;
}
.gallery-actions {
    display: flex;
    gap: 10px;
}
.gallery-subtitle {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin: 8px 0 16px;
}
.gallery-grid {
    margin-top: 0;
}
.gallery-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.gallery-card:hover {
    transform: translateY(-4px);
    border-color: var(--accent);
    box-shadow: 0 8px 30px var(--accent-glow);
}
.gallery-card-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}
.gallery-mood {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--accent-light);
    background: rgba(162, 155, 254, 0.12);
    border: 1px solid rgba(162, 155, 254, 0.25);
    border-radius: 999px;
    padding: 3px 10px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.gallery-time {
    font-size: 0.72rem;
    color: var(--text-muted);
    white-space: nowrap;
}
.gallery-card code {
    display: block;
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--accent-light);
    word-break: break-all;
    line-height: 1.5;
}
.gallery-play {
    font-size: 0.75rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: auto;
    transition: var(--transition);
}
.gallery-card:hover .gallery-play {
    color: var(--accent);
}
.gallery-status {
    grid-column: 1 / -1;
    text-align: center;
    padding: 28px 16px;
    font-size: 0.9rem;
    color: var(--text-muted);
    background: var(--bg-card);
    border: 1px dashed var(--border);
    border-radius: var(--radius);
}
.gallery-status-error {
    color: #ff7675;
    border-color: rgba(255, 118, 117, 0.4);
}
.cloud-toast {
    position: fixed;
    left: 50%;
    bottom: 28px;
    transform: translateX(-50%) translateY(16px);
    background: var(--bg-card);
    color: var(--accent-light);
    border: 1px solid var(--accent);
    box-shadow: 0 8px 30px var(--accent-glow);
    border-radius: var(--radius);
    padding: 12px 22px;
    font-size: 0.9rem;
    opacity: 0;
    pointer-events: none;
    transition: all 0.25s ease;
    z-index: 99999;
    max-width: 86vw;
    word-break: break-all;
}
.cloud-toast-show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}
.cloud-toast-error {
    color: #ff7675;
    border-color: #ff7675;
    box-shadow: 0 8px 30px rgba(255, 118, 117, 0.25);
}
@media (max-width: 768px) {
    .gallery-header {
        flex-direction: column;
        align-items: stretch;
    }
    .gallery-actions {
        justify-content: stretch;
    }
    .gallery-actions .btn {
        flex: 1;
    }
}

/* === Language Switch === */
.app-header { position: relative; }
.lang-switch {
    position: absolute;
    top: 20px;
    right: 24px;
    display: flex;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 3px;
    gap: 2px;
    z-index: 10;
}
.lang-btn {
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 0.78rem;
    font-weight: 600;
    padding: 4px 12px;
    border-radius: 999px;
    cursor: pointer;
    transition: var(--transition);
    font-family: var(--font-mono);
}
.lang-btn:hover { color: var(--text); }
.lang-btn.active { background: var(--accent); color: #fff; }
@media (max-width: 768px) {
    .lang-switch { top: 10px; right: 12px; }
}
