/* ========================================
   古音律 - 中国古代音律学习平台
   ======================================== */

:root {
    --bg-primary: #0f0f1a;
    --bg-secondary: #1a1a2e;
    --bg-card: rgba(255, 255, 255, 0.05);
    --bg-card-hover: rgba(255, 255, 255, 0.08);
    --gold: #c9a96e;
    --gold-light: #e8c987;
    --gold-dark: #8b7355;
    --red: #c0392b;
    --blue: #4a90d9;
    --green: #27ae60;
    --purple: #8e44ad;
    --text-primary: #f0f0f0;
    --text-secondary: #a0a0b0;
    --text-muted: #6a6a7a;
    --border: rgba(201, 169, 110, 0.2);
    --border-light: rgba(255, 255, 255, 0.1);
    --shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    --radius: 12px;
    --radius-lg: 16px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

html {
    scroll-behavior: smooth;
    scroll-snap-type: proximity;
}

body {
    font-family: 'PingFang SC', 'Microsoft YaHei', 'WenQuanYi Micro Hei', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.8;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* 加载动画 */
#loader {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: var(--bg-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.6s ease, visibility 0.6s ease;
}

#loader.hidden {
    opacity: 0;
    visibility: hidden;
}

.loader-content {
    text-align: center;
}

.loader-symbol {
    font-size: 48px;
    color: var(--gold);
    animation: pulse 1.5s ease-in-out infinite;
    width: 80px;
    height: 80px;
    border: 2px solid var(--gold);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
}

.loader-text {
    color: var(--gold);
    font-size: 14px;
    letter-spacing: 4px;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.1); opacity: 0.7; }
}

/* 导航栏 */
#navbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    background: rgba(15, 15, 26, 0.9);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    transition: var(--transition);
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 8px;
}

.nav-logo {
    font-size: 22px;
    color: var(--gold);
    animation: float 3s ease-in-out infinite;
}

.nav-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--gold);
    letter-spacing: 2px;
}

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

.menu-btn {
    background: none;
    border: none;
    color: var(--gold);
    font-size: 24px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
    transition: var(--transition);
}

.menu-btn:hover {
    background: var(--bg-card);
}

/* 侧边栏 */
.sidebar {
    position: fixed;
    top: 0;
    left: -280px;
    width: 280px;
    height: 100vh;
    z-index: 200;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    transition: left 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow);
}

.sidebar.open {
    left: 0;
}

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

.sidebar-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--gold);
    letter-spacing: 2px;
}

.close-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 18px;
    cursor: pointer;
    padding: 4px;
}

.nav-list {
    list-style: none;
    padding: 12px 0;
    flex: 1;
    overflow-y: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 13px 24px;
    color: var(--text-secondary);
    text-decoration: none;
    transition: var(--transition);
    font-size: 15px;
    border-left: 3px solid transparent;
}

.nav-item:hover,
.nav-item.active {
    color: var(--gold);
    background: var(--bg-card);
    border-left-color: var(--gold);
}

.nav-icon {
    font-size: 18px;
    width: 24px;
    text-align: center;
}

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border-light);
    text-align: center;
}

.sidebar-footer p {
    font-size: 12px;
    color: var(--text-muted);
    letter-spacing: 1px;
}

.overlay {
    position: fixed;
    inset: 0;
    z-index: 150;
    background: rgba(0, 0, 0, 0.6);
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
}

.overlay.show {
    opacity: 1;
    visibility: visible;
}

/* 主内容 */
#app {
    padding-top: 56px;
}

.page {
    display: none;
    padding: 24px 16px 60px;
    max-width: 900px;
    margin: 0 auto;
    animation: fadeInUp 0.5s ease;
}

.page.active {
    display: block;
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Hero */
.hero {
    position: relative;
    min-height: calc(100vh - 56px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    overflow: hidden;
}

.hero-bg {
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse at center, rgba(201, 169, 110, 0.08) 0%, transparent 70%),
                radial-gradient(circle at 30% 40%, rgba(74, 144, 217, 0.05) 0%, transparent 50%),
                radial-gradient(circle at 70% 60%, rgba(142, 68, 173, 0.05) 0%, transparent 50%);
    animation: bgShift 20s ease-in-out infinite;
}

@keyframes bgShift {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

.hero-content {
    position: relative;
    z-index: 1;
}

.hero-title {
    display: flex;
    gap: 8px;
    justify-content: center;
    margin-bottom: 16px;
}

.hero-title .char {
    font-size: clamp(48px, 10vw, 80px);
    font-weight: 700;
    color: var(--gold);
    text-shadow: 0 0 40px rgba(201, 169, 110, 0.3);
    animation: charAppear 0.8s ease forwards;
    animation-delay: calc(var(--i) * 0.2s);
    opacity: 0;
    transform: translateY(30px);
}

@keyframes charAppear {
    to { opacity: 1; transform: translateY(0); }
}

.hero-subtitle {
    font-size: clamp(16px, 4vw, 20px);
    color: var(--text-secondary);
    letter-spacing: 4px;
    margin-bottom: 12px;
}

.hero-desc {
    font-size: 14px;
    color: var(--text-muted);
    letter-spacing: 2px;
    margin-bottom: 32px;
}

.hero-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
}

.scroll-hint {
    position: absolute;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    text-align: center;
    cursor: pointer;
    animation: bounce 2s ease-in-out infinite;
    z-index: 1;
}

.scroll-hint span {
    font-size: 12px;
    color: var(--text-muted);
    letter-spacing: 2px;
}

.scroll-arrow {
    font-size: 20px;
    color: var(--gold);
    margin-top: 4px;
}

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

/* 按钮 */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 22px;
    border: none;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
    letter-spacing: 1px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--gold), var(--gold-dark));
    color: var(--bg-primary);
    box-shadow: 0 4px 16px rgba(201, 169, 110, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 24px rgba(201, 169, 110, 0.4);
}

.btn-secondary {
    background: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: var(--bg-card-hover);
    border-color: var(--gold);
}

.btn-ghost {
    background: transparent;
    color: var(--gold);
    border: 1px solid var(--gold);
}

.btn-ghost:hover {
    background: rgba(201, 169, 110, 0.1);
}

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

.btn-arrow {
    transition: transform 0.3s;
}

.btn:hover .btn-arrow {
    transform: translateX(4px);
}

/* 首页卡片 */
.home-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 12px;
    padding: 32px 0;
}

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

.home-card:hover {
    background: var(--bg-card-hover);
    border-color: var(--gold);
    transform: translateY(-4px);
}

.home-card-icon {
    font-size: 32px;
    margin-bottom: 8px;
}

.home-card h3 {
    font-size: 15px;
    color: var(--gold);
    margin-bottom: 4px;
}

.home-card p {
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.5;
}

/* 引用 */
.quote-section {
    padding: 40px 0;
    text-align: center;
}

.quote-section blockquote {
    font-size: clamp(16px, 4vw, 20px);
    color: var(--gold);
    font-style: italic;
    max-width: 600px;
    margin: 0 auto;
    padding: 24px;
    border-left: 3px solid var(--gold);
    border-right: 3px solid var(--gold);
    background: var(--bg-card);
    border-radius: var(--radius);
}

.quote-section cite {
    display: block;
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 8px;
    font-style: normal;
}

/* Section Header */
.section-header {
    text-align: center;
    margin-bottom: 32px;
    padding-top: 16px;
}

.section-num {
    display: inline-block;
    width: 40px;
    height: 40px;
    line-height: 40px;
    border: 2px solid var(--gold);
    border-radius: 50%;
    color: var(--gold);
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 12px;
}

.section-header h2 {
    font-size: clamp(24px, 5vw, 32px);
    color: var(--gold);
    margin-bottom: 8px;
    letter-spacing: 2px;
}

.section-desc {
    font-size: 14px;
    color: var(--text-muted);
}

/* 五音卡片 */
.wuyin-notes {
    display: flex;
    justify-content: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 24px;
}

.note-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 16px 12px;
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    transition: var(--transition);
    min-width: 90px;
}

.note-card:hover {
    transform: translateY(-4px);
    border-color: var(--gold);
}

.note-circle {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: hsla(var(--hue), 60%, 50%, 0.2);
    border: 2px solid hsla(var(--hue), 60%, 50%, 0.5);
    transition: var(--transition);
}

.note-cn {
    font-size: 22px;
    font-weight: 700;
    color: hsla(var(--hue), 70%, 65%, 1);
}

.note-info {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.note-name {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
}

.note-scale {
    font-size: 13px;
    color: var(--gold);
}

.note-element, .note-organ {
    font-size: 11px;
    color: var(--text-muted);
}

.play-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 1px solid var(--gold);
    background: rgba(201, 169, 110, 0.1);
    color: var(--gold);
    cursor: pointer;
    font-size: 14px;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.play-btn:hover {
    background: var(--gold);
    color: var(--bg-primary);
}

.play-btn.playing {
    background: var(--gold);
    color: var(--bg-primary);
    animation: pulse 1s ease-in-out infinite;
}

.wuyin-controls {
    display: flex;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 24px;
}

/* 信息卡片 */
.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.info-card {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    padding: 20px;
    transition: var(--transition);
}

.info-card:hover {
    border-color: var(--gold);
}

.info-card.full-width {
    grid-column: 1 / -1;
}

.info-card.warning {
    border-color: rgba(192, 57, 43, 0.4);
    background: rgba(192, 57, 43, 0.05);
}

.info-card h4 {
    color: var(--gold);
    font-size: 16px;
    margin-bottom: 12px;
}

.info-list {
    list-style: none;
    padding: 0;
}

.info-list li {
    padding: 6px 0;
    color: var(--text-secondary);
    font-size: 14px;
    border-bottom: 1px solid var(--border-light);
}

.info-list li:last-child {
    border-bottom: none;
}

.info-text {
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 8px;
}

.classic-quote {
    color: var(--text-primary);
    font-size: 15px;
    line-height: 2.2;
    padding: 8px 0;
}

.classic-quote cite {
    display: block;
    margin-top: 8px;
    color: var(--text-muted);
    font-size: 13px;
}

.text-muted {
    color: var(--text-muted);
    font-size: 13px;
}

/* 七声音阶 */
.seven-note-section {
    margin-bottom: 24px;
}

.seven-note-section h3 {
    color: var(--gold);
    font-size: 16px;
    margin-bottom: 16px;
    text-align: center;
}

.seven-note-bar {
    display: flex;
    justify-content: center;
    gap: 6px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}

.seven-note-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 12px 8px;
    border-radius: var(--radius);
    background: hsla(var(--hue), 50%, 40%, 0.15);
    border: 1px solid hsla(var(--hue), 50%, 40%, 0.3);
    min-width: 48px;
    transition: var(--transition);
}

.seven-note-item:hover {
    transform: scale(1.05);
}

.seven-note-item.variant {
    border-style: dashed;
    opacity: 0.85;
}

.seven-note-item span {
    font-size: 14px;
    font-weight: 700;
    color: hsla(var(--hue), 70%, 70%, 1);
}

.seven-note-item small {
    font-size: 11px;
    color: var(--text-muted);
}

.seven-note-desc {
    text-align: center;
    font-size: 13px;
    color: var(--text-muted);
}

/* 十二律 */
.lv-lvg-selector {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.lv-tab {
    padding: 8px 18px;
    border: 1px solid var(--border);
    border-radius: 20px;
    background: var(--bg-card);
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
    font-size: 13px;
    font-family: inherit;
}

.lv-tab.active,
.lv-tab:hover {
    background: var(--gold);
    color: var(--bg-primary);
    border-color: var(--gold);
}

.shierlv-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 10px;
    margin-bottom: 28px;
}

.lv-card {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    padding: 14px 10px;
    text-align: center;
    transition: var(--transition);
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.lv-card:hover {
    transform: translateY(-3px);
    border-color: var(--gold);
}

.lv-card.yang {
    border-left: 3px solid var(--red);
}

.lv-card.yin {
    border-left: 3px solid var(--blue);
}

.lv-card.hidden-card {
    opacity: 0.2;
    pointer-events: none;
}

.lv-card-name {
    font-size: 17px;
    font-weight: 700;
    color: var(--text-primary);
}

.lv-card-pitch {
    font-size: 12px;
    color: var(--gold);
    margin-top: 2px;
}

.lv-card-type {
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 10px;
    display: inline-block;
    margin-top: 4px;
}

.lv-card-type.yang {
    background: rgba(192, 57, 43, 0.2);
    color: #e74c3c;
}

.lv-card-type.yin {
    background: rgba(74, 144, 217, 0.2);
    color: #5dade2;
}

.lv-card-play {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 1px solid var(--gold);
    background: rgba(201, 169, 110, 0.1);
    color: var(--gold);
    cursor: pointer;
    font-size: 11px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.lv-card-play:hover {
    background: var(--gold);
    color: var(--bg-primary);
}

/* 律管可视化 */
.lv-visualization {
    margin-bottom: 28px;
}

.lv-visualization h3 {
    color: var(--gold);
    font-size: 16px;
    margin-bottom: 4px;
}

.viz-desc {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 16px;
}

.lv-bars {
    display: flex;
    align-items: flex-end;
    gap: 4px;
    height: 200px;
    padding: 16px;
    background: var(--bg-card);
    border-radius: var(--radius);
    border: 1px solid var(--border-light);
    overflow-x: auto;
}

.lv-bar-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
    min-width: 50px;
}

.lv-bar {
    width: 36px;
    border-radius: 4px 4px 0 0;
    transition: height 0.8s cubic-bezier(0.4, 0, 0.2, 1);
    min-height: 4px;
    position: relative;
}

.lv-bar.yang-bar {
    background: linear-gradient(to top, var(--red), rgba(192, 57, 43, 0.4));
}

.lv-bar.yin-bar {
    background: linear-gradient(to top, var(--blue), rgba(74, 144, 217, 0.4));
}

.lv-bar-value {
    font-size: 9px;
    color: var(--text-muted);
    position: absolute;
    top: -16px;
    left: 50%;
    transform: translateX(-50%);
    white-space: nowrap;
}

.lv-bar-label {
    font-size: 11px;
    color: var(--text-secondary);
    font-weight: 500;
}

/* 表格 */
.table-wrapper {
    overflow-x: auto;
    border-radius: var(--radius);
    border: 1px solid var(--border-light);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    min-width: 500px;
}

.data-table th {
    background: rgba(201, 169, 110, 0.1);
    color: var(--gold);
    padding: 10px 12px;
    text-align: left;
    font-weight: 600;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.data-table td {
    padding: 8px 12px;
    border-bottom: 1px solid var(--border-light);
    color: var(--text-secondary);
    white-space: nowrap;
}

.data-table tr:hover td {
    background: var(--bg-card-hover);
    color: var(--text-primary);
}

.data-table.small {
    font-size: 12px;
}

.data-table.small th,
.data-table.small td {
    padding: 6px 8px;
}

/* 三分损益 */
.sanfen-intro {
    margin-bottom: 24px;
}

.sanfen-calculator {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-bottom: 28px;
}

.sanfen-calculator h3 {
    color: var(--gold);
    font-size: 16px;
    margin-bottom: 16px;
}

.calc-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.calc-controls label {
    font-size: 14px;
    color: var(--text-secondary);
}

.calc-controls input {
    width: 80px;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 14px;
    text-align: center;
    font-family: inherit;
}

.calc-steps {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 20px;
    max-height: 400px;
    overflow-y: auto;
}

.calc-step {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-radius: 8px;
    background: var(--bg-primary);
    border: 1px solid var(--border-light);
    font-size: 13px;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from { opacity: 0; transform: translateX(-20px); }
    to { opacity: 1; transform: translateX(0); }
}

.calc-step .step-num {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--gold);
    color: var(--bg-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    flex-shrink: 0;
}

.calc-step .step-name {
    font-weight: 700;
    color: var(--gold);
    min-width: 50px;
}

.calc-step .step-formula {
    color: var(--text-muted);
    font-family: 'Courier New', monospace;
    font-size: 12px;
}

.calc-step .step-result {
    margin-left: auto;
    font-weight: 700;
    color: var(--text-primary);
}

.calc-step .step-tag {
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
}

.tag-loss {
    background: rgba(192, 57, 43, 0.2);
    color: #e74c3c;
}

.tag-gain {
    background: rgba(39, 174, 96, 0.2);
    color: #2ecc71;
}

.calc-visual {
    padding: 16px;
    background: var(--bg-primary);
    border-radius: var(--radius);
    min-height: 60px;
}

.calc-visual-bar {
    height: 8px;
    border-radius: 4px;
    margin: 4px 0;
    transition: width 0.5s ease;
    position: relative;
}

.calc-visual-bar .bar-label {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 10px;
    color: var(--text-primary);
    white-space: nowrap;
}

/* 生成流程 */
.generation-flow {
    margin-bottom: 28px;
}

.generation-flow h3 {
    color: var(--gold);
    font-size: 16px;
    margin-bottom: 16px;
    text-align: center;
}

.flow-diagram {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    justify-content: center;
    padding: 20px;
    background: var(--bg-card);
    border-radius: var(--radius);
    border: 1px solid var(--border-light);
}

.flow-node {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 10px 6px;
    border-radius: 8px;
    background: var(--bg-primary);
    border: 1px solid var(--border-light);
    min-width: 64px;
    transition: var(--transition);
    cursor: default;
}

.flow-node:hover {
    border-color: var(--gold);
    transform: scale(1.05);
}

.flow-node .flow-name {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-primary);
}

.flow-node .flow-op {
    font-size: 10px;
    padding: 1px 6px;
    border-radius: 8px;
}

.flow-node .flow-value {
    font-size: 10px;
    color: var(--text-muted);
}

.flow-arrow {
    display: flex;
    align-items: center;
    color: var(--gold);
    font-size: 16px;
}

.flow-note {
    text-align: center;
    margin-top: 12px;
    font-size: 13px;
    color: var(--text-muted);
}

/* 黄钟问题 */
.huangzhong-issue {
    margin-bottom: 24px;
}

.issue-visual {
    margin: 16px 0;
}

.issue-bar {
    margin-bottom: 8px;
}

.issue-bar-fill {
    height: 32px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    padding-left: 12px;
    font-size: 13px;
    font-weight: 600;
    color: var(--bg-primary);
    transition: width 1s ease;
}

.issue-detail {
    font-size: 14px;
    color: var(--text-secondary);
    margin-top: 8px;
}

/* 旋宫 */
.xg-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.xg-controls label {
    font-size: 14px;
    color: var(--text-secondary);
}

.xg-select {
    padding: 8px 16px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-primary);
    color: var(--gold);
    font-size: 15px;
    cursor: pointer;
    font-family: inherit;
}

.xg-result {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    gap: 10px;
    margin-bottom: 24px;
}

.xg-note {
    text-align: center;
    padding: 14px 8px;
    border-radius: var(--radius);
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    transition: var(--transition);
}

.xg-note.is-gong {
    border-color: var(--gold);
    background: rgba(201, 169, 110, 0.1);
    transform: scale(1.05);
}

.xg-note-name {
    font-size: 20px;
    font-weight: 700;
    color: var(--gold);
}

.xg-note-scale {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
}

.xg-note-lv {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 2px;
}

.xg-note-element {
    font-size: 11px;
    color: var(--text-muted);
}

.xg-circle-container {
    display: flex;
    justify-content: center;
    margin-bottom: 24px;
}

#xgCanvas {
    max-width: 100%;
    height: auto;
}

/* 纳音 */
.nayin-search {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-bottom: 28px;
    text-align: center;
}

.nayin-search h3 {
    color: var(--gold);
    font-size: 16px;
    margin-bottom: 16px;
}

.nayin-search-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.nayin-select {
    padding: 10px 18px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-primary);
    color: var(--gold);
    font-size: 18px;
    cursor: pointer;
    font-family: inherit;
    min-width: 70px;
}

.nayin-plus {
    font-size: 20px;
    color: var(--text-muted);
}

.nayin-result {
    padding: 20px;
    border-radius: var(--radius);
    background: var(--bg-primary);
    min-height: 80px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.nayin-result.has-result {
    border: 1px solid var(--gold);
}

.nayin-result-name {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 4px;
}

.nayin-result-wuxing {
    font-size: 18px;
    padding: 4px 16px;
    border-radius: 20px;
    margin-bottom: 4px;
}

.nayin-result-desc {
    font-size: 13px;
    color: var(--text-muted);
}

.nayin-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 8px;
    margin-bottom: 28px;
}

.nayin-cell {
    padding: 10px 6px;
    border-radius: 8px;
    text-align: center;
    border: 1px solid var(--border-light);
    transition: var(--transition);
    cursor: pointer;
}

.nayin-cell:hover {
    transform: translateY(-2px);
    border-color: var(--gold);
}

.nayin-cell-ganzhi {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-primary);
}

.nayin-cell-name {
    font-size: 12px;
    color: var(--gold);
    margin-top: 2px;
}

.nayin-cell-wuxing {
    font-size: 10px;
    margin-top: 2px;
    padding: 1px 6px;
    border-radius: 8px;
    display: inline-block;
}

.wx-jin { background: rgba(192, 57, 43, 0.15); color: #e74c3c; }
.wx-huo { background: rgba(230, 126, 34, 0.15); color: #f39c12; }
.wx-mu { background: rgba(39, 174, 96, 0.15); color: #2ecc71; }
.wx-shui { background: rgba(74, 144, 217, 0.15); color: #5dade2; }
.wx-tu { background: rgba(149, 132, 95, 0.15); color: #d4a96a; }

.wuxing-correspondence {
    text-align: center;
    margin-bottom: 24px;
}

.wuxing-correspondence h3 {
    color: var(--gold);
    font-size: 16px;
    margin-bottom: 8px;
}

.wuxing-order {
    font-size: 15px;
    color: var(--text-secondary);
    margin-bottom: 16px;
    letter-spacing: 2px;
}

.wuxing-cycle {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 6px;
}

.wx-item {
    padding: 12px 16px;
    border-radius: var(--radius);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    min-width: 60px;
    border: 1px solid transparent;
}

.wx-item span {
    font-size: 20px;
    font-weight: 700;
}

.wx-item small {
    font-size: 10px;
    opacity: 0.8;
}

.wx-arrow {
    font-size: 18px;
    color: var(--gold);
    font-weight: 700;
}

.cycle-back {
    color: var(--text-muted);
    font-size: 24px;
}

/* 律历 */
.calendar-container {
    margin-bottom: 28px;
}

.month-lv-map {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 10px;
}

.month-card {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    padding: 14px;
    transition: var(--transition);
    cursor: pointer;
}

.month-card:hover {
    border-color: var(--gold);
    transform: translateY(-2px);
}

.month-card-month {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.month-card-lv {
    font-size: 18px;
    font-weight: 700;
    color: var(--gold);
}

.month-card-info {
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 4px;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.month-card-info span {
    padding: 1px 6px;
    background: var(--bg-primary);
    border-radius: 4px;
}

/* 时辰 */
.shichen-map {
    margin-bottom: 24px;
}

.shichen-map h3 {
    color: var(--gold);
    font-size: 16px;
    margin-bottom: 16px;
    text-align: center;
}

.shichen-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 8px;
}

.shichen-cell {
    text-align: center;
    padding: 10px 6px;
    border-radius: 8px;
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    transition: var(--transition);
}

.shichen-cell:hover {
    border-color: var(--gold);
}

.sc-time {
    font-size: 11px;
    color: var(--text-muted);
}

.sc-name {
    font-size: 16px;
    font-weight: 700;
    color: var(--gold);
}

.sc-lv {
    font-size: 11px;
    color: var(--text-secondary);
}

.sc-zodiac {
    font-size: 18px;
    margin-top: 2px;
}

/* 琴台 */
.keyboard-container {
    margin-bottom: 24px;
}

.keyboard-mode {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.mode-btn {
    padding: 8px 18px;
    border: 1px solid var(--border);
    border-radius: 20px;
    background: var(--bg-card);
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
    font-size: 13px;
    font-family: inherit;
}

.mode-btn.active,
.mode-btn:hover {
    background: var(--gold);
    color: var(--bg-primary);
    border-color: var(--gold);
}

.keyboard {
    display: flex;
    position: relative;
    height: 180px;
    margin-bottom: 16px;
    overflow-x: auto;
    padding: 0 4px;
}

.key-white {
    flex-shrink: 0;
    width: 48px;
    height: 180px;
    background: linear-gradient(to bottom, #f8f8f8, #e0e0e0);
    border: 1px solid #ccc;
    border-radius: 0 0 6px 6px;
    margin: 0 1px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    padding-bottom: 8px;
    transition: background 0.1s;
    position: relative;
    user-select: none;
}

.key-white:active,
.key-white.active {
    background: linear-gradient(to bottom, var(--gold-light), var(--gold));
}

.key-white .key-label {
    font-size: 10px;
    color: #666;
    font-weight: 600;
}

.key-black {
    position: absolute;
    width: 32px;
    height: 110px;
    background: linear-gradient(to bottom, #333, #111);
    border-radius: 0 0 4px 4px;
    cursor: pointer;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    padding-bottom: 6px;
    transition: background 0.1s;
    user-select: none;
}

.key-black:active,
.key-black.active {
    background: linear-gradient(to bottom, var(--gold), var(--gold-dark));
}

.key-black .key-label {
    font-size: 9px;
    color: #aaa;
    font-weight: 600;
}

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

.control-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.control-group label {
    font-size: 13px;
    color: var(--text-secondary);
}

.control-group select {
    padding: 6px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 13px;
    cursor: pointer;
    font-family: inherit;
}

/* 经典旋律 */
.classic-melodies {
    margin-bottom: 24px;
}

.classic-melodies h3 {
    color: var(--gold);
    font-size: 16px;
    margin-bottom: 16px;
    text-align: center;
}

.melody-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
}

.melody-card {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    padding: 16px;
    text-align: center;
    transition: var(--transition);
}

.melody-card:hover {
    border-color: var(--gold);
    transform: translateY(-2px);
}

.melody-card h5 {
    font-size: 15px;
    color: var(--gold);
    margin-bottom: 4px;
}

.melody-card p {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 10px;
}

/* 测验 */
.quiz-container {
    max-width: 600px;
    margin: 0 auto 32px;
}

.quiz-progress {
    height: 6px;
    background: var(--bg-card);
    border-radius: 3px;
    margin-bottom: 12px;
    overflow: hidden;
}

.quiz-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--gold), var(--gold-light));
    border-radius: 3px;
    transition: width 0.3s ease;
    width: 0;
}

.quiz-score {
    text-align: right;
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 16px;
}

.quiz-score span {
    color: var(--gold);
    font-weight: 700;
}

.quiz-card {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    padding: 28px 24px;
    min-height: 250px;
    display: flex;
    flex-direction: column;
}

.quiz-question {
    font-size: 17px;
    color: var(--text-primary);
    margin-bottom: 20px;
    line-height: 1.6;
}

.quiz-options {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 16px;
}

.quiz-option {
    padding: 12px 16px;
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    background: var(--bg-primary);
    color: var(--text-primary);
    cursor: pointer;
    transition: var(--transition);
    font-size: 14px;
    text-align: left;
    font-family: inherit;
}

.quiz-option:hover {
    border-color: var(--gold);
    background: rgba(201, 169, 110, 0.05);
}

.quiz-option.correct {
    border-color: var(--green);
    background: rgba(39, 174, 96, 0.1);
    color: #2ecc71;
}

.quiz-option.wrong {
    border-color: var(--red);
    background: rgba(192, 57, 43, 0.1);
    color: #e74c3c;
}

.quiz-option.disabled {
    pointer-events: none;
    opacity: 0.6;
}

.quiz-feedback {
    margin-top: auto;
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 14px;
    min-height: 20px;
}

.quiz-feedback.correct {
    background: rgba(39, 174, 96, 0.1);
    color: #2ecc71;
    border: 1px solid rgba(39, 174, 96, 0.3);
}

.quiz-feedback.wrong {
    background: rgba(192, 57, 43, 0.1);
    color: #e74c3c;
    border: 1px solid rgba(192, 57, 43, 0.3);
}

.quiz-actions {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin-top: 16px;
}

/* 听音辨律 */
.ear-training {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    padding: 24px;
    max-width: 600px;
    margin: 0 auto;
}

.ear-training h3 {
    color: var(--gold);
    font-size: 16px;
    margin-bottom: 8px;
    text-align: center;
}

.ear-desc {
    text-align: center;
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 16px;
}

.ear-controls {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

.ear-options {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: center;
}

.ear-option {
    padding: 8px 18px;
    border: 1px solid var(--border);
    border-radius: 20px;
    background: var(--bg-primary);
    color: var(--text-primary);
    cursor: pointer;
    transition: var(--transition);
    font-size: 13px;
    font-family: inherit;
}

.ear-option:hover {
    border-color: var(--gold);
}

.ear-option.correct {
    border-color: var(--green);
    background: rgba(39, 174, 96, 0.15);
    color: #2ecc71;
}

.ear-option.wrong {
    border-color: var(--red);
    background: rgba(192, 57, 43, 0.15);
    color: #e74c3c;
}

.ear-result {
    margin-top: 12px;
    text-align: center;
    font-size: 14px;
    min-height: 20px;
}

/* Footer */
#footer {
    text-align: center;
    padding: 32px 20px;
    border-top: 1px solid var(--border-light);
    color: var(--text-muted);
    font-size: 13px;
}

.footer-sub {
    font-size: 12px;
    margin-top: 4px;
    color: var(--text-muted);
    opacity: 0.7;
}

/* 响应式 */
@media (max-width: 640px) {
    .page {
        padding: 16px 12px 60px;
    }

    .home-cards {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }

    .note-card {
        min-width: 70px;
        padding: 12px 6px;
    }

    .note-circle {
        width: 44px;
        height: 44px;
    }

    .note-cn {
        font-size: 18px;
    }

    .wuyin-notes {
        gap: 6px;
    }

    .lv-bar-item {
        min-width: 40px;
    }

    .lv-bar {
        width: 28px;
    }

    .flow-diagram {
        gap: 4px;
        padding: 12px;
    }

    .flow-node {
        min-width: 52px;
        padding: 8px 4px;
    }

    .keyboard {
        height: 150px;
    }

    .key-white {
        width: 40px;
        height: 150px;
    }

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

    .xg-result {
        grid-template-columns: repeat(5, 1fr);
        gap: 6px;
    }

    .xg-note {
        padding: 10px 4px;
    }

    .nayin-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .month-lv-map {
        grid-template-columns: repeat(2, 1fr);
    }

    .shichen-grid {
        grid-template-columns: repeat(4, 1fr);
    }

    .wuxing-cycle {
        gap: 4px;
    }

    .wx-item {
        padding: 8px 10px;
        min-width: 44px;
    }

    .wx-item span {
        font-size: 16px;
    }

    .quiz-card {
        padding: 20px 16px;
    }

    .hero-actions {
        flex-direction: column;
        align-items: center;
    }
}

@media (min-width: 641px) and (max-width: 1024px) {
    .page {
        max-width: 720px;
    }
}

@media (min-width: 1025px) {
    .page {
        max-width: 900px;
    }

    #navbar {
        padding: 14px 40px;
    }

    .menu-btn {
        display: none;
    }

    .sidebar {
        left: 0;
        width: 240px;
    }

    .sidebar-header .close-btn {
        display: none;
    }

    #app {
        margin-left: 240px;
    }

    .overlay {
        display: none !important;
    }

    .home-cards {
        grid-template-columns: repeat(3, 1fr);
    }

    .xg-result {
        grid-template-columns: repeat(5, 1fr);
    }

    .nayin-grid {
        grid-template-columns: repeat(6, 1fr);
    }

    .month-lv-map {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* 滚动条 */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

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

::-webkit-scrollbar-thumb {
    background: var(--gold-dark);
    border-radius: 3px;
}

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

/* 动画辅助 */
.animate-on-scroll {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.6s ease, transform 0.6s ease;
}

.animate-on-scroll.visible {
    opacity: 1;
    transform: translateY(0);
}

/* 涟漪效果 */
.ripple {
    position: absolute;
    border-radius: 50%;
    background: rgba(201, 169, 110, 0.3);
    transform: scale(0);
    animation: rippleAnim 0.6s linear;
    pointer-events: none;
}

@keyframes rippleAnim {
    to {
        transform: scale(4);
        opacity: 0;
    }
}

/* ============ 音律动画：声波涟漪（点击发声元素时扩散） ============ */
.sound-ripple {
    position: absolute;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(255, 220, 150, 0.7), rgba(201, 169, 110, 0));
    transform: scale(0);
    animation: soundRipple 0.7s ease-out forwards;
    pointer-events: none;
    z-index: 5;
}
@keyframes soundRipple {
    0%   { transform: scale(0);   opacity: 0.9; }
    100% { transform: scale(12);  opacity: 0;   }
}

/* 发声卡片播放时的律动高亮 */
.note-card.is-playing,
.key.is-playing,
.lv-card.is-playing {
    animation: notePulse 0.5s ease;
}
@keyframes notePulse {
    0%   { transform: translateY(0)    scale(1);    box-shadow: 0 0 0 rgba(255, 220, 150, 0); }
    40%  { transform: translateY(-8px) scale(1.06); box-shadow: 0 0 28px rgba(255, 220, 150, 0.7); }
    100% { transform: translateY(0)    scale(1);    box-shadow: 0 0 0 rgba(255, 220, 150, 0); }
}

/* ============ 首页五声律动画布 ============ */
#hero-wave {
    display: block;
    width: 100%;
    max-width: 420px;
    height: 120px;
    margin: 18px auto 0;
    opacity: 0.9;
}

/* ============ 音频激活按钮 ============ */
#btn-audio-unlock {
    display: block;
    margin: 16px auto 0;
    animation: pulse 2.2s ease-in-out infinite;
}
#btn-audio-unlock.unlocked {
    animation: none;
    opacity: 0.85;
}

/* 全局音律动画层（用于跨元素涟漪，预留） */
#sound-wave-layer {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 1;
}

/* 确保发声元素可容纳涟漪 */
.note-card, .key, .lv-card, .scale-btn, .pitch-btn {
    isolation: isolate;
}
