/* ════════════════════════════════════════════
   唱歌打分系统 — 全局样式
   ════════════════════════════════════════════ */

:root {
    --primary: #6C5CE7;
    --primary-light: #A29BFE;
    --accent: #FD79A8;
    --success: #00B894;
    --warning: #FDCB6E;
    --danger: #E17055;
    --dark: #2D3436;
    --darker: #1E272E;
    --light: #DFE6E9;
    --card-bg: rgba(255, 255, 255, 0.92);
    --gradient-overlay: linear-gradient(135deg, rgba(108, 92, 231, 0.12) 0%, rgba(253, 121, 168, 0.08) 100%);
    --radius: 16px;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
    --shadow-hover: 0 8px 32px rgba(0, 0, 0, 0.14);
    --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
    background:
        linear-gradient(135deg, rgba(108, 92, 231, 0.85) 0%, rgba(253, 121, 168, 0.65) 50%, rgba(0, 184, 148, 0.55) 100%),
        url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 800 600"><defs><linearGradient id="g" x1="0%%" y1="0%%" x2="100%%" y2="100%%"><stop offset="0%%" stop-color="rgba(108,92,231,0.03)"/><stop offset="100%%" stop-color="rgba(253,121,168,0.06)"/></linearGradient></defs><rect fill="url(%23g)" width="800" height="600"/><circle cx="120" cy="100" r="60" fill="rgba(255,255,255,0.04)"/><circle cx="680" cy="80" r="80" fill="rgba(255,255,255,0.03)"/><circle cx="200" cy="500" r="100" fill="rgba(255,255,255,0.04)"/><circle cx="600" cy="450" r="120" fill="rgba(255,255,255,0.03)"/></svg>');
    background-size: cover;
    background-attachment: fixed;
    background-position: center;
    min-height: 100vh;
    color: var(--dark);
    line-height: 1.6;
}

/* ─── Navbar ─── */
.navbar {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.3);
    padding: 0 24px;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 16px rgba(0, 0, 0, 0.06);
}

.navbar-brand {
    font-size: 22px;
    font-weight: 800;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    display: flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
}

.navbar-brand .icon { font-size: 28px; -webkit-text-fill-color: initial; }

.navbar-links { display: flex; gap: 8px; }

.navbar-links a {
    text-decoration: none;
    padding: 8px 18px;
    border-radius: 10px;
    font-weight: 600;
    font-size: 14px;
    color: var(--dark);
    transition: var(--transition);
}

.navbar-links a:hover,
.navbar-links a.active {
    background: var(--primary);
    color: white;
}

/* ─── Container ─── */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 24px 20px;
}

/* ─── Card ─── */
.card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 28px;
    margin-bottom: 20px;
    box-shadow: var(--shadow);
    transition: var(--transition);
    border: 1px solid rgba(255, 255, 255, 0.5);
}

.card:hover { box-shadow: var(--shadow-hover); }

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

.card-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--darker);
}

/* ─── Buttons ─── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 22px;
    border-radius: 12px;
    border: none;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    letter-spacing: 0.02em;
}

.btn:active { transform: scale(0.97); }

.btn-primary {
    background: var(--primary);
    color: white;
    box-shadow: 0 4px 14px rgba(108, 92, 231, 0.35);
}
.btn-primary:hover {
    background: #5A4BD1;
    box-shadow: 0 6px 20px rgba(108, 92, 231, 0.45);
    transform: translateY(-1px);
}

.btn-accent {
    background: var(--accent);
    color: white;
    box-shadow: 0 4px 14px rgba(253, 121, 168, 0.35);
}
.btn-accent:hover {
    background: #E86A9A;
    box-shadow: 0 6px 20px rgba(253, 121, 168, 0.45);
    transform: translateY(-1px);
}

.btn-success {
    background: var(--success);
    color: white;
    box-shadow: 0 4px 14px rgba(0, 184, 148, 0.35);
}

.btn-outline {
    background: white;
    border: 2px solid var(--light);
    color: var(--dark);
}
.btn-outline:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-lg {
    padding: 14px 32px;
    font-size: 16px;
    border-radius: 14px;
}

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

/* ─── Forms ─── */
.form-group { margin-bottom: 18px; }

.form-label {
    display: block;
    font-weight: 600;
    font-size: 14px;
    color: var(--darker);
    margin-bottom: 6px;
}

.form-input {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--light);
    border-radius: 12px;
    font-size: 15px;
    transition: var(--transition);
    background: rgba(255, 255, 255, 0.8);
    font-family: inherit;
    box-sizing: border-box;
    height: 46px;
    line-height: 1.4;
}

.form-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(108, 92, 231, 0.1);
    background: white;
}

/* select 下拉统一高度+圆角 */
select.form-input {
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'><path fill='%23636E72' d='M6 8L1 3h10z'/></svg>");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 12px;
    padding-right: 36px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

/* ─── Recorder ─── */
.recorder-box {
    text-align: center;
    padding: 32px 20px;
    border: 2px dashed var(--light);
    border-radius: var(--radius);
    transition: var(--transition);
    min-height: 180px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

.recorder-box.recording {
    border-color: var(--accent);
    background: rgba(253, 121, 168, 0.06);
    animation: pulse-border 1.5s ease-in-out infinite;
}

.recorder-box.has-audio {
    border-color: var(--success);
    background: rgba(0, 184, 148, 0.04);
}

@keyframes pulse-border {
    0%, 100% { border-color: var(--accent); }
    50% { border-color: rgba(253, 121, 168, 0.3); }
}

.rec-btn {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
}

.rec-btn-start {
    background: var(--primary);
    color: white;
    box-shadow: 0 6px 24px rgba(108, 92, 231, 0.4);
}
.rec-btn-start:hover { transform: scale(1.08); }

.rec-btn-stop {
    background: var(--danger);
    color: white;
    animation: pulse-rec 1.2s ease-in-out infinite;
    box-shadow: 0 6px 24px rgba(225, 112, 85, 0.4);
}

@keyframes pulse-rec {
    0%, 100% { box-shadow: 0 0 0 0 rgba(225, 112, 85, 0.5); }
    50% { box-shadow: 0 0 0 14px rgba(225, 112, 85, 0); }
}

.rec-timer {
    font-size: 24px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: var(--danger);
}

.rec-timer.idle { color: var(--dark); }
.rec-timer.stopped { color: var(--success); }

/* ─── Score Display ─── */
.score-big {
    font-size: 64px;
    font-weight: 900;
    text-align: center;
    line-height: 1;
}

.score-big.perfect { color: var(--success); }
.score-big.good { color: #6C5CE7; }
.score-big.ok { color: var(--warning); }
.score-big.low { color: var(--danger); }

.score-grade {
    display: inline-block;
    padding: 6px 16px;
    border-radius: 20px;
    font-weight: 700;
    font-size: 14px;
}

.grade-developing { background: #FEEAA7; color: #8B6914; }
.grade-good { background: #A3E4BC; color: #1E5A3C; }
.grade-excellent { background: #A29BFE; color: #3C2788; }
.grade-beginner { background: #FAB1A0; color: #8B2E15; }

.subscore-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 12px;
    margin: 16px 0;
}

.subscore-item {
    background: linear-gradient(135deg, rgba(108, 92, 231, 0.06), rgba(108, 92, 231, 0.02));
    border-radius: 12px;
    padding: 16px;
    text-align: center;
    border: 1px solid rgba(108, 92, 231, 0.1);
}

.subscore-label {
    font-size: 13px;
    font-weight: 600;
    color: #636E72;
    margin-bottom: 6px;
}

.subscore-value {
    font-size: 28px;
    font-weight: 800;
    color: var(--primary);
}

.subscore-bar {
    height: 6px;
    border-radius: 3px;
    background: #F0F0F0;
    margin-top: 8px;
    overflow: hidden;
}

.subscore-bar-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.fill-high { background: var(--success); }
.fill-mid { background: var(--primary); }
.fill-low { background: var(--accent); }

/* ─── Table ─── */
.table-container { overflow-x: auto; }

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

th {
    padding: 12px 14px;
    text-align: left;
    font-weight: 700;
    font-size: 13px;
    color: #636E72;
    border-bottom: 2px solid #F0F0F0;
    white-space: nowrap;
}

td {
    padding: 14px;
    border-bottom: 1px solid #F5F5F5;
}

tr:hover td { background: rgba(108, 92, 231, 0.03); }

.score-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    font-weight: 800;
    font-size: 15px;
    color: white;
}

.score-excellent { background: var(--success); }
.score-good { background: var(--primary); }
.score-developing { background: var(--warning); color: #8B6914; }
.score-beginner { background: var(--danger); }

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: #B2BEC3;
}

.empty-state .icon { font-size: 56px; margin-bottom: 16px; display: block; }
.empty-state h3 { font-size: 18px; margin-bottom: 8px; }

/* ─── Filters ─── */
.filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 16px;
    align-items: center;
}

.filter-bar .form-input {
    width: auto;
    min-width: 140px;
    padding: 8px 12px;
    font-size: 13px;
}

.filter-bar .btn-sm { white-space: nowrap; }

/* ─── Tags ─── */
.tag-list { display: flex; flex-wrap: wrap; gap: 6px; }

.tag {
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

.tag-tip { background: #E8F8F5; color: #1E8449; }
.tag-strength { background: #EBF5FB; color: #2E86C1; }
.tag-warning { background: #FEF9E7; color: #B7950B; }
.tag-song { background: #F4ECF7; color: #7D3C98; }

/* ─── Song cards ─── */
.song-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: rgba(108, 92, 231, 0.04);
    border-radius: 12px;
    margin-bottom: 8px;
    border-left: 3px solid var(--primary);
}

.song-card .song-index {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 13px;
    flex-shrink: 0;
}

/* ─── Audio player ─── */
.audio-player {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    background: #F8F9FA;
    border-radius: 10px;
}

.audio-player audio { flex: 1; height: 36px; }

/* ─── Toast ─── */
.toast-container {
    position: fixed;
    top: 24px;
    right: 24px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    padding: 14px 20px;
    border-radius: 12px;
    color: white;
    font-weight: 600;
    font-size: 14px;
    box-shadow: var(--shadow-hover);
    animation: slideInRight 0.3s ease;
    max-width: 400px;
}

.toast-success { background: var(--success); }
.toast-error { background: var(--danger); }

@keyframes slideInRight {
    from { transform: translateX(120%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* ─── Loading ─── */
.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto;
}

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

.overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 999;
    gap: 16px;
    color: white;
    font-weight: 600;
    font-size: 16px;
}

/* ─── Responsive ─── */
@media (max-width: 768px) {
    .form-row { grid-template-columns: 1fr; }
    .container { padding: 16px 12px; }
    .card { padding: 20px 16px; }
    .subscore-grid { grid-template-columns: repeat(3, 1fr); }
    .score-big { font-size: 48px; }
}

/* ─── Auth: Balance & Role Badges ─── */

.balance-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: rgba(0, 184, 148, 0.08);
    color: var(--success);
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    border: 1px solid rgba(0, 184, 148, 0.2);
}

.balance-badge strong {
    color: #008B6E;
}

.role-badge {
    display: inline-flex;
    align-items: center;
    background: linear-gradient(135deg, rgba(253, 203, 110, 0.3), rgba(253, 203, 110, 0.1));
    color: #8B6914;
    padding: 2px 10px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 700;
    border: 1px solid rgba(253, 203, 110, 0.4);
}

/* ─── Navbar Auth Section ─── */

.navbar-auth {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-left: auto;
    flex-wrap: wrap;
}

@media (max-width: 768px) {
    .navbar {
        flex-wrap: wrap;
        height: auto;
        padding: 12px 16px;
        gap: 8px;
    }
    .navbar-links {
        flex-wrap: wrap;
        width: 100%;
        justify-content: flex-start;
    }
    .navbar-auth {
        margin-left: 0;
        width: 100%;
        justify-content: flex-start;
    }
    .balance-badge {
        font-size: 12px;
        padding: 3px 8px;
    }
}

/* ─── Auth FormError State ─── */

.auth-error {
    color: var(--danger);
    font-size: 13px;
    text-align: center;
    margin-top: 10px;
    min-height: 20px;
}
