/* ===== 全局重置 & 变量 ===== */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --secondary: #8b5cf6;
    --accent: #06b6d4;
    --bg-dark: #0f172a;
    --bg-card: #1e293b;
    --bg-light: #f8fafc;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-dark: #1e293b;
    --shadow: 0 10px 30px -5px rgba(0, 0, 0, 0.3);
    --radius: 16px;
    --radius-sm: 10px;
    --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

html {
    scroll-behavior: smooth;
}

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

/* ===== 滚动条 ===== */
::-webkit-scrollbar {
    width: 8px;
}
::-webkit-scrollbar-track {
    background: var(--bg-dark);
}
::-webkit-scrollbar-thumb {
    background: var(--primary);
    border-radius: 10px;
}

/* ===== 导航 ===== */
.navbar {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 1000;
    background: rgba(15, 23, 42, 0.7);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid rgba(99, 102, 241, 0.15);
    transition: var(--transition);
}

.navbar.scrolled {
    background: rgba(15, 23, 42, 0.95);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

.nav-container {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    height: 64px;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.5px;
}

.nav-brand i {
    color: var(--primary);
    font-size: 1.5rem;
}

.nav-links {
    display: flex;
    gap: 32px;
    list-style: none;
}

.nav-links a {
    text-decoration: none;
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 0.95rem;
    transition: var(--transition);
    position: relative;
    padding: 4px 0;
}

.nav-links a::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 0;
    height: 2px;
    background: var(--primary);
    transition: var(--transition);
    border-radius: 2px;
}

.nav-links a:hover,
.nav-links a.active {
    color: var(--text-primary);
}

.nav-links a:hover::after,
.nav-links a.active::after {
    width: 100%;
}

.hamburger {
    display: none;
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 8px;
    transition: var(--transition);
}

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

/* ===== 通用 Section ===== */
section {
    padding: 80px 24px;
    max-width: 1200px;
    margin: 0 auto;
}

.section-title {
    text-align: center;
    margin-bottom: 48px;
}

.section-title h2 {
    font-size: 2.2rem;
    font-weight: 700;
    margin-bottom: 12px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.section-title p {
    color: var(--text-secondary);
    font-size: 1.1rem;
}

/* ===== Hero ===== */
.hero-section {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding-top: 80px;
    position: relative;
    overflow: hidden;
}

.hero-section::before {
    content: '';
    position: absolute;
    top: -30%;
    right: -20%;
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, rgba(99, 102, 241, 0.15), transparent 70%);
    pointer-events: none;
}

.hero-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 60px;
    width: 100%;
}

.hero-text {
    flex: 1;
}

.hero-text h1 {
    font-size: 3.8rem;
    font-weight: 700;
    line-height: 1.2;
    margin-bottom: 20px;
    letter-spacing: -1px;
}

.hero-text p {
    font-size: 1.2rem;
    color: var(--text-secondary);
    margin-bottom: 32px;
    max-width: 480px;
}

.hero-actions {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}

.btn-primary {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    padding: 14px 32px;
    border-radius: 50px;
    font-weight: 600;
    font-size: 1rem;
    text-decoration: none;
    border: none;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: 0 4px 20px rgba(99, 102, 241, 0.3);
}

.btn-primary:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 30px rgba(99, 102, 241, 0.4);
}

.btn-secondary {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: transparent;
    color: var(--text-primary);
    padding: 14px 32px;
    border-radius: 50px;
    font-weight: 600;
    font-size: 1rem;
    text-decoration: none;
    border: 1px solid rgba(255, 255, 255, 0.2);
    cursor: pointer;
    transition: var(--transition);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--primary);
}

.hero-visual {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
}

.floating-keys {
    display: flex;
    gap: 12px;
    animation: float 4s ease-in-out infinite;
}

.floating-keys .key-white {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 60px;
    height: 120px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-secondary);
    backdrop-filter: blur(4px);
    transition: var(--transition);
}

.floating-keys .key-white:hover {
    background: rgba(99, 102, 241, 0.15);
    border-color: var(--primary);
    transform: translateY(-8px);
}

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

/* ===== 钢琴区 ===== */
.piano-section {
    padding-top: 40px;
}

.controls {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 16px;
    margin-top: 16px;
}

.control-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    padding: 10px 20px;
    border-radius: 50px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: var(--transition);
}

.control-btn:hover {
    background: rgba(99, 102, 241, 0.15);
    border-color: var(--primary);
}

.control-btn.active {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

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

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

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

.piano-container {
    display: flex;
    justify-content: center;
    padding: 20px 0;
}

.piano-keyboard {
    display: flex;
    position: relative;
    background: #1a1a2e;
    border-radius: var(--radius);
    padding: 16px 12px 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.05);
    overflow-x: auto;
    max-width: 100%;
}

.key {
    cursor: pointer;
    transition: all 0.07s ease;
    position: relative;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding-bottom: 10px;
    font-weight: 600;
    font-size: 0.75rem;
    user-select: none;
    border-radius: 0 0 6px 6px;
    flex-shrink: 0;
}

.key-white {
    width: 48px;
    height: 180px;
    background: linear-gradient(180deg, #f8f9fa 0%, #e9ecef 100%);
    border: 1px solid #ced4da;
    border-right: 1px solid #adb5bd;
    color: #495057;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    z-index: 1;
    margin-right: 1px;
}

.key-white:last-child {
    margin-right: 0;
}

.key-white.active {
    background: linear-gradient(180deg, #d0ebff 0%, #a5d8ff 100%);
    box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.15);
    transform: scaleY(0.97);
}

.key-black {
    width: 32px;
    height: 110px;
    background: linear-gradient(180deg, #2d3436 0%, #1e272e 100%);
    border: 1px solid #0f0f0f;
    border-radius: 0 0 6px 6px;
    color: #dfe6e9;
    font-size: 0.6rem;
    z-index: 2;
    position: absolute;
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.5);
    padding-bottom: 6px;
}

.key-black.active {
    background: linear-gradient(180deg, #636e72 0%, #2d3436 100%);
    transform: scaleY(0.95);
    box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.4);
}

.pressed-keys-display {
    text-align: center;
    margin-top: 20px;
    padding: 12px 20px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: var(--radius-sm);
    border: 1px solid rgba(255, 255, 255, 0.06);
    font-size: 1rem;
    color: var(--text-secondary);
    min-height: 48px;
}

.pressed-keys-display #currentNotes {
    color: var(--accent);
    font-weight: 600;
}

/* ===== 和弦助手 ===== */
.chords-section {
    padding-top: 40px;
}

.chord-helper {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 32px;
    border: 1px solid rgba(255, 255, 255, 0.06);
    box-shadow: var(--shadow);
}

.chord-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    align-items: flex-end;
    margin-bottom: 28px;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.control-group label {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
    letter-spacing: 0.3px;
}

.control-group select {
    padding: 10px 16px;
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    font-size: 1rem;
    font-weight: 500;
    outline: none;
    cursor: pointer;
    transition: var(--transition);
    min-width: 140px;
}

.control-group select:hover,
.control-group select:focus {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.1);
}

.chord-result {
    text-align: center;
    padding: 24px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: var(--radius-sm);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.chord-name {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 8px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.chord-notes {
    font-size: 1.1rem;
    color: var(--text-secondary);
    margin-bottom: 16px;
    letter-spacing: 2px;
}

.chord-keys-preview {
    display: flex;
    justify-content: center;
    gap: 8px;
    flex-wrap: wrap;
}

.chord-keys-preview .preview-key {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background: rgba(99, 102, 241, 0.15);
    border: 1px solid rgba(99, 102, 241, 0.3);
    color: var(--text-primary);
    font-weight: 600;
    font-size: 0.9rem;
}

/* ===== 关于 ===== */
.about-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 24px;
}

.about-card {
    background: var(--bg-card);
    padding: 32px 24px;
    border-radius: var(--radius);
    border: 1px solid rgba(255, 255, 255, 0.06);
    text-align: center;
    transition: var(--transition);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.about-card:hover {
    transform: translateY(-6px);
    border-color: var(--primary);
    box-shadow: 0 12px 40px rgba(99, 102, 241, 0.15);
}

.about-card i {
    font-size: 2.5rem;
    color: var(--primary);
    margin-bottom: 16px;
}

.about-card h3 {
    font-size: 1.3rem;
    margin-bottom: 8px;
}

.about-card p {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

/* ===== 页脚 ===== */
.footer {
    text-align: center;
    padding: 32px 24px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* ===== 响应式 ===== */
@media (max-width: 768px) {
    .nav-links {
        position: fixed;
        top: 64px;
        left: 0;
        width: 100%;
        background: rgba(15, 23, 42, 0.98);
        backdrop-filter: blur(20px);
        flex-direction: column;
        align-items: center;
        padding: 24px 0;
        gap: 20px;
        transform: translateY(-120%);
        transition: var(--transition);
        border-bottom: 1px solid rgba(255, 255, 255, 0.05);
        box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
    }

    .nav-links.open {
        transform: translateY(0);
    }

    .hamburger {
        display: block;
    }

    .hero-content {
        flex-direction: column;
        text-align: center;
    }

    .hero-text h1 {
        font-size: 2.5rem;
    }

    .hero-text p {
        margin: 0 auto 24px;
    }

    .hero-actions {
        justify-content: center;
    }

    .floating-keys .key-white {
        width: 44px;
        height: 90px;
        font-size: 1rem;
    }

    .piano-keyboard {
        padding: 12px 8px 16px;
    }

    .key-white {
        width: 40px;
        height: 150px;
        font-size: 0.65rem;
    }

    .key-black {
        width: 28px;
        height: 90px;
    }

    .chord-helper {
        padding: 20px;
    }

    .chord-controls {
        flex-direction: column;
        align-items: stretch;
    }

    .control-group select {
        min-width: unset;
        width: 100%;
    }

    .volume-control {
        width: 100%;
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .hero-text h1 {
        font-size: 2rem;
    }

    .key-white {
        width: 34px;
        height: 130px;
    }

    .key-black {
        width: 24px;
        height: 78px;
    }

    .section-title h2 {
        font-size: 1.7rem;
    }

    .about-card {
        padding: 24px 16px;
    }
}

@media (min-width: 769px) and (max-width: 1024px) {
    .hero-text h1 {
        font-size: 3rem;
    }
    .key-white {
        width: 44px;
        height: 160px;
    }
    .key-black {
        width: 30px;
        height: 100px;
    }
}