:root {
    --bg: #030712;
    --surface: rgba(8, 14, 28, 0.82);
    --surface-2: rgba(12, 20, 40, 0.95);
    --border: rgba(0, 245, 255, 0.12);
    --border-bright: rgba(0, 245, 255, 0.35);
    --text: #e8f4ff;
    --muted: #6b8299;
    --cyan: #00f5ff;
    --purple: #7c3aed;
    --pink: #ec4899;
    --success: #10b981;
    --danger: #ef4444;
    --glow-cyan: 0 0 30px rgba(0, 245, 255, 0.35);
    --glow-purple: 0 0 40px rgba(124, 58, 237, 0.3);
    --radius: 16px;
    --font-mono: "JetBrains Mono", "SF Mono", "Fira Code", monospace;
}

*, *::before, *::after { box-sizing: border-box; }

body {
    margin: 0;
    min-height: 100vh;
    font-family: "SF Pro Display", "PingFang SC", "Microsoft YaHei", sans-serif;
    color: var(--text);
    background: var(--bg);
    overflow-x: hidden;
}

/* ── 背景 ── */
.bg-grid {
    position: fixed;
    inset: 0;
    background-image:
        linear-gradient(rgba(0, 245, 255, 0.04) 1px, transparent 1px),
        linear-gradient(90deg, rgba(0, 245, 255, 0.04) 1px, transparent 1px);
    background-size: 48px 48px;
    mask-image: radial-gradient(ellipse 80% 70% at 50% 30%, black 20%, transparent 80%);
    pointer-events: none;
    z-index: 0;
}

.bg-glow {
    position: fixed;
    border-radius: 50%;
    filter: blur(100px);
    pointer-events: none;
    z-index: 0;
}

.bg-glow-a {
    width: 600px; height: 600px;
    top: -200px; left: -100px;
    background: rgba(124, 58, 237, 0.18);
}

.bg-glow-b {
    width: 500px; height: 500px;
    bottom: -150px; right: -100px;
    background: rgba(0, 245, 255, 0.12);
}

.page {
    position: relative;
    z-index: 1;
    max-width: 1280px;
    margin: 0 auto;
    padding: 28px 20px 56px;
}

/* ── Header ── */
.hero {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 24px;
    margin-bottom: 32px;
}

.hero-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 5px 12px;
    border: 1px solid var(--border-bright);
    border-radius: 999px;
    font-family: var(--font-mono);
    font-size: 11px;
    letter-spacing: 0.14em;
    color: var(--cyan);
    background: rgba(0, 245, 255, 0.06);
    margin-bottom: 14px;
}

.pulse-dot {
    width: 7px; height: 7px;
    border-radius: 50%;
    background: var(--cyan);
    box-shadow: var(--glow-cyan);
    animation: pulse-dot 2s ease-in-out infinite;
}

@keyframes pulse-dot {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(0.8); }
}

h1 {
    margin: 0 0 10px;
    font-size: clamp(30px, 5vw, 48px);
    font-weight: 700;
    letter-spacing: -0.02em;
    background: linear-gradient(135deg, #fff 30%, var(--cyan) 70%, var(--purple));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.subtitle {
    margin: 0;
    color: var(--muted);
    font-size: 15px;
    line-height: 1.7;
}

.session-chip {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 12px 16px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface);
    backdrop-filter: blur(12px);
    font-family: var(--font-mono);
}

.chip-label {
    font-size: 10px;
    letter-spacing: 0.12em;
    color: var(--muted);
}

.session-chip code {
    font-size: 13px;
    color: var(--cyan);
}

/* ── Layout ── */
.layout {
    display: grid;
    grid-template-columns: 1fr 1.05fr;
    gap: 20px;
    align-items: start;
}

.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    backdrop-filter: blur(20px);
    padding: 24px;
    position: relative;
    overflow: hidden;
}

.panel::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--cyan), var(--purple), transparent);
    opacity: 0.5;
}

.panel-head {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 24px;
}

.panel-icon {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--cyan);
    border: 1px solid var(--border-bright);
    padding: 4px 8px;
    border-radius: 6px;
}

.panel h2 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
}

.field { margin-bottom: 20px; }

.field-label {
    display: block;
    margin-bottom: 10px;
    font-size: 12px;
    font-family: var(--font-mono);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
}

.field-hint {
    margin: 8px 0 0;
    font-size: 12px;
    color: var(--muted);
    line-height: 1.5;
}

.hidden-block {
    display: none !important;
}

textarea:read-only {
    opacity: 0.85;
    cursor: default;
}

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

/* ── Genre chips ── */
.genre-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}

.genre-chip {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 12px 8px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: rgba(255,255,255,0.02);
    color: var(--muted);
    font: inherit;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.genre-chip:hover {
    border-color: var(--border-bright);
    color: var(--text);
    background: rgba(0, 245, 255, 0.04);
}

.genre-chip.active {
    border-color: var(--cyan);
    color: var(--cyan);
    background: rgba(0, 245, 255, 0.08);
    box-shadow: var(--glow-cyan), inset 0 0 20px rgba(0, 245, 255, 0.05);
}

.genre-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 22px;
    font-size: 18px;
    line-height: 1;
}

.genre-icon .genre-svg {
    width: 18px;
    height: 18px;
    display: block;
}

/* ── Inputs ── */
.select-wrap, .textarea-wrap {
    border: 1px solid var(--border);
    border-radius: 12px;
    background: rgba(0, 0, 0, 0.3);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.select-wrap:focus-within, .textarea-wrap:focus-within {
    border-color: var(--border-bright);
    box-shadow: 0 0 0 3px rgba(0, 245, 255, 0.08);
}

select, textarea {
    width: 100%;
    border: none;
    background: transparent;
    color: var(--text);
    padding: 12px 14px;
    font: inherit;
    outline: none;
    resize: vertical;
}

textarea { min-height: 200px; line-height: 1.7; }

/* ── Mode tabs ── */
.mode-switch { border: none; padding: 0; margin: 0 0 20px; }
.mode-switch legend { padding: 0; }

.mode-tabs {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.mode-tabs-dual {
    grid-template-columns: 1fr 1fr;
}

.mode-tab {
    cursor: pointer;
}

.mode-tab input { display: none; }

.mode-tab-body {
    display: block;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 10px;
    text-align: center;
    transition: all 0.2s;
}

.mode-tab-title {
    display: block;
    font-size: 14px;
    color: var(--muted);
    font-weight: 600;
    margin-bottom: 4px;
}

.mode-tab-desc {
    display: block;
    font-size: 11px;
    color: var(--muted);
    opacity: 0.75;
    line-height: 1.4;
    font-weight: 400;
}

.mode-tab input:checked + .mode-tab-body {
    border-color: var(--purple);
    background: rgba(124, 58, 237, 0.12);
    box-shadow: var(--glow-purple);
}

.mode-tab input:checked + .mode-tab-body .mode-tab-title,
.mode-tab input:checked + .mode-tab-body .mode-tab-desc {
    color: var(--text);
    opacity: 1;
}

.lyrics-draft-panel {
    margin-bottom: 20px;
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: rgba(0, 0, 0, 0.22);
}

.draft-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.draft-head .field-label {
    margin-bottom: 0;
}

.draft-badge {
    font-family: var(--font-mono);
    font-size: 10px;
    letter-spacing: 0.08em;
    padding: 3px 8px;
    border-radius: 999px;
    border: 1px solid var(--border);
    color: var(--muted);
}

.draft-badge.ready {
    color: var(--cyan);
    border-color: rgba(0, 245, 255, 0.35);
    background: rgba(0, 245, 255, 0.08);
}

.btn-draft {
    width: 100%;
    margin: 12px 0;
    padding: 12px;
    font-size: 14px;
}

.lyrics-wrap {
    margin-top: 4px;
}

/* ── Buttons ── */
.btn {
    border: none;
    border-radius: 10px;
    padding: 10px 16px;
    font: inherit;
    cursor: pointer;
    transition: transform 0.15s, opacity 0.15s;
}

.btn:hover:not(:disabled) { transform: translateY(-1px); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.btn-ghost {
    background: rgba(255,255,255,0.04);
    border: 1px solid var(--border);
    color: var(--text);
    font-size: 13px;
}

.btn-sm { padding: 6px 12px; font-size: 12px; }

.btn-primary {
    position: relative;
    width: 100%;
    padding: 16px;
    background: linear-gradient(135deg, rgba(0,245,255,0.15), rgba(124,58,237,0.25));
    border: 1px solid var(--border-bright);
    color: var(--text);
    font-size: 15px;
    font-weight: 600;
    letter-spacing: 0.04em;
    overflow: hidden;
}

.btn-primary .btn-glow {
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, var(--cyan), var(--purple));
    opacity: 0;
    transition: opacity 0.3s;
}

.btn-primary:hover:not(:disabled) .btn-glow { opacity: 0.15; }
.btn-primary .btn-text { position: relative; z-index: 1; }

/* ── Status terminal ── */
.status-terminal {
    display: flex;
    align-items: center;
    gap: 18px;
    padding: 20px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: rgba(0, 0, 0, 0.35);
    min-height: 100px;
    transition: border-color 0.3s;
}

.status-terminal.idle { border-color: var(--border); }
.status-terminal.working { border-color: rgba(0, 245, 255, 0.4); }
.status-terminal.streaming { border-color: rgba(124, 58, 237, 0.5); }
.status-terminal.done { border-color: rgba(16, 185, 129, 0.45); }
.status-terminal.error { border-color: rgba(239, 68, 68, 0.45); }

.status-ring {
    position: relative;
    width: 56px; height: 56px;
    flex-shrink: 0;
}

.status-ring svg {
    width: 100%; height: 100%;
    transform: rotate(-90deg);
}

.status-ring circle {
    fill: none;
    stroke: var(--border);
    stroke-width: 3;
}

.status-terminal.working .status-ring circle,
.status-terminal.streaming .status-ring circle {
    stroke: url(#ringGrad);
    stroke-dasharray: 264;
    stroke-dashoffset: 180;
    animation: ring-spin 1.5s linear infinite;
}

@keyframes ring-spin {
    to { stroke-dashoffset: -264; }
}

.status-core {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: var(--cyan);
}

.status-text { flex: 1; min-width: 0; }

#statusMessage {
    margin: 0;
    font-size: 15px;
    line-height: 1.5;
}

.status-meta {
    margin: 6px 0 0;
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--muted);
}

.progress-track {
    position: absolute;
    bottom: 0; left: 0; right: 0;
    height: 3px;
    background: rgba(255,255,255,0.05);
    overflow: hidden;
    border-radius: 0 0 14px 14px;
}

.progress-track.hidden { display: none; }

.progress-glow {
    height: 100%;
    width: 40%;
    background: linear-gradient(90deg, var(--cyan), var(--purple));
    animation: progress-slide 1.2s ease-in-out infinite;
}

@keyframes progress-slide {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(350%); }
}

.status-terminal { position: relative; overflow: hidden; }

/* ── Player stage ── */
.player-stage {
    margin-top: 20px;
    border: 1px solid var(--border-bright);
    border-radius: 16px;
    background: var(--surface-2);
    overflow: hidden;
    box-shadow: var(--glow-purple);
}

.player-stage.hidden { display: none; }

.wave-container {
    position: relative;
    height: 160px;
    min-height: 160px;
    background: linear-gradient(180deg, rgba(0,245,255,0.06), rgba(124,58,237,0.08));
    overflow: hidden;
    border-bottom: 1px solid rgba(0, 245, 255, 0.1);
}

#waveCanvas {
    display: block;
    width: 100%;
    height: 100%;
    min-height: 160px;
    position: relative;
    z-index: 1;
}

.wave-overlay {
    position: absolute;
    inset: 0;
    z-index: 2;
    background: linear-gradient(180deg, transparent 70%, rgba(12, 20, 40, 0.85));
    pointer-events: none;
}

.player-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 16px 18px 0;
    gap: 12px;
}

.player-title {
    margin: 0 0 4px;
    font-size: 18px;
    font-weight: 600;
}

.player-meta {
    margin: 0;
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--muted);
}

.sync-badge {
    flex-shrink: 0;
    padding: 4px 10px;
    border-radius: 999px;
    font-family: var(--font-mono);
    font-size: 10px;
    letter-spacing: 0.1em;
    color: var(--cyan);
    border: 1px solid var(--border-bright);
    background: rgba(0, 245, 255, 0.08);
    animation: badge-glow 2s ease-in-out infinite;
}

.sync-badge.hidden { display: none; }

@keyframes badge-glow {
    0%, 100% { box-shadow: none; }
    50% { box-shadow: var(--glow-cyan); }
}

.player-controls {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 18px;
}

.btn-play {
    width: 48px; height: 48px;
    border-radius: 50%;
    border: 1px solid var(--border-bright);
    background: linear-gradient(135deg, rgba(0,245,255,0.2), rgba(124,58,237,0.3));
    color: var(--text);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: box-shadow 0.2s, transform 0.15s;
}

.btn-play:hover { box-shadow: var(--glow-cyan); transform: scale(1.05); }
.btn-play.playing { box-shadow: var(--glow-cyan); border-color: var(--cyan); }

.seek-wrap {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 10px;
}

.time-label {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--muted);
    min-width: 32px;
}

.seek-bar {
    flex: 1;
    height: 6px;
    border-radius: 999px;
    background: rgba(255,255,255,0.08);
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.seek-fill {
    height: 100%;
    width: 0%;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--cyan), var(--purple));
    box-shadow: 0 0 8px rgba(0,245,255,0.5);
    transition: width 0.1s linear;
}

/* ── Lyrics sync ── */
.lyrics-stage {
    border-top: 1px solid var(--border);
    padding: 0 18px 18px;
}

.lyrics-stage-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0 8px;
    font-family: var(--font-mono);
    font-size: 11px;
    letter-spacing: 0.08em;
    color: var(--muted);
    text-transform: uppercase;
}

.lyrics-scroll {
    height: 220px;
    overflow-y: auto;
    scroll-behavior: smooth;
    mask-image: linear-gradient(180deg, transparent, black 12%, black 88%, transparent);
    padding: 8px 0;
}

.lyrics-scroll::-webkit-scrollbar { width: 4px; }
.lyrics-scroll::-webkit-scrollbar-thumb {
    background: rgba(0,245,255,0.3);
    border-radius: 4px;
}

.lyric-section-tag {
    font-family: var(--font-mono);
    font-size: 10px;
    letter-spacing: 0.14em;
    color: var(--purple);
    text-align: center;
    padding: 12px 0 4px;
    opacity: 0.7;
}

.lyric-line {
    margin: 0;
    padding: 10px 16px;
    text-align: center;
    font-size: 16px;
    line-height: 1.6;
    color: rgba(232, 244, 255, 0.35);
    transition: all 0.35s ease;
    border-radius: 8px;
}

.lyric-line.past {
    color: rgba(232, 244, 255, 0.2);
    transform: scale(0.96);
}

.lyric-line.active {
    color: var(--text);
    font-size: 20px;
    font-weight: 600;
    background: linear-gradient(135deg, rgba(0,245,255,0.1), rgba(124,58,237,0.12));
    border: 1px solid rgba(0, 245, 255, 0.25);
    box-shadow: 0 0 24px rgba(0, 245, 255, 0.12);
    transform: scale(1.02);
    text-shadow: 0 0 20px rgba(0, 245, 255, 0.4);
}

.lyrics-fallback {
    text-align: center;
    color: var(--muted);
    line-height: 1.8;
    white-space: pre-wrap;
    padding: 20px;
}

/* ── History ── */
.history-block {
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
}

.history-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.history-head h3 {
    margin: 0;
    font-size: 14px;
    font-family: var(--font-mono);
    letter-spacing: 0.06em;
    color: var(--muted);
    text-transform: uppercase;
}

.task-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 8px;
}

.task-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: rgba(0,0,0,0.25);
    transition: border-color 0.2s;
}

.task-item:hover { border-color: var(--border-bright); }

.task-meta strong {
    display: block;
    font-size: 14px;
    margin-bottom: 3px;
}

.task-meta span {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--muted);
}

.task-status {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 10px;
    font-family: var(--font-mono);
    margin-right: 6px;
}

.task-status.done { color: var(--success); border: 1px solid rgba(16,185,129,0.3); }
.task-status.pending { color: var(--cyan); border: 1px solid rgba(0,245,255,0.3); }

.empty-tip {
    color: var(--muted);
    font-size: 13px;
    padding: 8px 2px;
    font-family: var(--font-mono);
}

.gen-toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(120%);
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    border-radius: 14px;
    border: 1px solid var(--border-bright);
    background: rgba(8, 14, 28, 0.95);
    backdrop-filter: blur(16px);
    box-shadow: var(--glow-cyan);
    z-index: 100;
    transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
    font-size: 14px;
}

.gen-toast.visible {
    transform: translateX(-50%) translateY(0);
}

@media (max-width: 960px) {
    .layout { grid-template-columns: 1fr; }
    .hero { flex-direction: column; }
    .genre-grid { grid-template-columns: repeat(4, 1fr); }
}

@media (max-width: 520px) {
    .genre-grid { grid-template-columns: repeat(2, 1fr); }
    .mode-tabs { grid-template-columns: 1fr; }
    .lyrics-scroll { height: 180px; }
    .lyric-line.active { font-size: 17px; }
}
