/* ═══════════════════════════════════════════
   电音基调查询网 · 主样式
   ═══════════════════════════════════════════ */

/* ── 重置 ────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ── CSS 变量 ────────────────────────────── */
:root {
    --primary:       #1A73E8;
    --primary-dark:  #1557B0;
    --primary-light: #E8F0FE;
    --accent:        #D32F2F;

    --bg:      #F8F9FA;
    --surface: #FFFFFF;
    --border:  #DADCE0;

    --text:     #202124;
    --text-2:   #5F6368;
    --text-3:   #9AA0A6;

    --mark-bg:  #FFF176;

    --sh-sm: 0 1px 3px rgba(60,64,67,.15);
    --sh-md: 0 2px 8px rgba(60,64,67,.12), 0 1px 3px rgba(60,64,67,.08);
    --sh-lg: 0 8px 24px rgba(60,64,67,.10), 0 2px 8px rgba(60,64,67,.08);
    --sh-in: 0 2px 14px rgba(26,115,232,.22);

    --r-sm:   6px;
    --r:     10px;
    --r-lg:  16px;
    --r-pill:100px;

    --ease: .2s cubic-bezier(.4,0,.2,1);
    --nav-h: 56px;
}

/* ── 全局 ────────────────────────────────── */
html { scroll-behavior: smooth; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI",
                 "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei",
                 sans-serif;
    font-size: 15px;
    line-height: 1.6;
    color: var(--text);
    background: var(--bg);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── 导航栏 ──────────────────────────────── */
.navbar {
    position: sticky; top: 0; z-index: 200;
    height: var(--nav-h);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center;
    padding: 0 24px; gap: 12px;
    box-shadow: var(--sh-sm);
}
.navbar-logo {
    display: flex; align-items: center; gap: 10px;
    flex-shrink: 0; text-decoration: none;
}
.navbar-logo .n-icon {
    width: 32px; height: 32px;
    border-radius: 8px;
    overflow: hidden;
    flex-shrink: 0;
    display: block;
}
.navbar-logo .n-brand { font-size: 15px; font-weight: 600; color: var(--text); }
.navbar-logo:hover { text-decoration: none; }

.navbar-nav { display: flex; gap: 2px; }
.nav-link {
    padding: 6px 14px; border-radius: var(--r-sm);
    font-size: 14px; color: var(--text-2);
    transition: background var(--ease), color var(--ease);
    text-decoration: none;
}
.nav-link:hover, .nav-link.active {
    background: var(--primary-light); color: var(--primary);
    text-decoration: none;
}
.nav-link.active { font-weight: 600; }

.navbar-spacer { flex: 1; }
.navbar-stat { font-size: 13px; color: var(--text-3); white-space: nowrap; }

/* ── 主体 ────────────────────────────────── */
main { flex: 1; }

/* ════ 首页 Hero ════════════════════════════ */
.hero {
    min-height: calc(100vh - var(--nav-h) - 80px);
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    padding: 60px 20px 80px;
    background:
        radial-gradient(ellipse 70% 50% at 50% -5%,
            rgba(26,115,232,.07) 0%, transparent 70%),
        var(--bg);
}

.hero-logo {
    display: flex; align-items: center; gap: 22px;
    margin-bottom: 48px;
    animation: fadeDown .5s ease both;
}
.hero-logo .h-icon {
    width: 82px; height: 82px;
    border-radius: 20px;
    overflow: hidden;
    flex-shrink: 0;
    box-shadow: 0 8px 32px rgba(139,92,246,.38);
    display: block;
}
.hero-logo .h-text h1 {
    font-size: 34px; font-weight: 800;
    color: var(--text); letter-spacing: .5px; line-height: 1.2;
}
.hero-logo .h-text p {
    font-size: 14px; color: var(--text-3);
    margin-top: 5px; letter-spacing: .5px;
}

@keyframes fadeDown {
    from { opacity: 0; transform: translateY(-18px); }
    to   { opacity: 1; transform: translateY(0); }
}
@keyframes fadeUp {
    from { opacity: 0; transform: translateY(16px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ── 搜索框 ──────────────────────────────── */
.search-box {
    width: 100%; max-width: 700px;
    animation: fadeUp .5s .1s ease both;
}
/* 结果页的搜索框不需要动画 */
.result-header .search-box { animation: none; max-width: 600px; }

.search-form { position: relative; }

.search-row {
    display: flex;
    border-radius: var(--r-lg);
    overflow: hidden;
    box-shadow: var(--sh-md);
    transition: box-shadow var(--ease);
}
.search-row:focus-within { box-shadow: var(--sh-in); }

.search-input-wrap { position: relative; flex: 1; }

.s-icon {
    position: absolute; left: 16px; top: 50%; transform: translateY(-50%);
    color: var(--text-3); font-size: 17px; pointer-events: none;
    transition: color var(--ease);
}
.search-input-wrap:focus-within .s-icon { color: var(--primary); }

.search-input {
    width: 100%; height: 54px;
    padding: 0 44px 0 46px;
    font-size: 16px; font-family: inherit;
    border: 2px solid var(--border); border-right: none;
    border-radius: var(--r-lg) 0 0 var(--r-lg);
    outline: none; color: var(--text); background: var(--surface);
    transition: border-color var(--ease);
}
.search-input::placeholder { color: var(--text-3); }
.search-input:focus { border-color: var(--primary); }

.search-clear {
    position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
    width: 22px; height: 22px; border-radius: 50%;
    border: none; background: #E0E0E0; color: var(--text-2);
    cursor: pointer; display: none; align-items: center;
    justify-content: center; font-size: 12px; font-weight: 700;
    line-height: 1; padding: 0;
    transition: background var(--ease);
}
.search-clear:hover { background: #BDBDBD; color: #fff; }

.search-btn {
    width: 104px; height: 54px;
    background: var(--primary); color: #fff;
    border: none; font-size: 15px; font-weight: 600;
    cursor: pointer; letter-spacing: 2px;
    border-radius: 0 var(--r-lg) var(--r-lg) 0;
    transition: background var(--ease), transform .1s;
    white-space: nowrap; flex-shrink: 0; font-family: inherit;
}
.search-btn:hover  { background: var(--primary-dark); }
.search-btn:active { transform: scale(.97); }
.search-btn:disabled { background: var(--text-3); cursor: not-allowed; transform: none; }

/* ── 搜索类型 ─────────────────────────────── */
.search-types {
    display: flex; gap: 6px;
    margin-top: 14px;
    justify-content: center; flex-wrap: wrap;
}
.result-header .search-types { margin-top: 10px; justify-content: flex-start; }

.type-label {
    display: inline-block;
    padding: 5px 16px; border-radius: var(--r-pill);
    font-size: 13px; color: var(--text-2);
    background: var(--surface); border: 1px solid var(--border);
    cursor: pointer; user-select: none;
    transition: background var(--ease), color var(--ease), border-color var(--ease);
}
.type-label input[type="radio"] { display: none; }
.type-label:hover  { background: var(--primary-light); color: var(--primary); border-color: var(--primary); }
.type-label.active { background: var(--primary); color: #fff; border-color: var(--primary); font-weight: 600; }

.result-header .type-label { padding: 3px 12px; font-size: 12px; }

/* ── 历史下拉 ─────────────────────────────── */
.search-dropdown {
    position: absolute; top: calc(100% + 6px); left: 0; right: 0;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--r); box-shadow: var(--sh-lg);
    display: none; z-index: 300; overflow: hidden;
}
.dd-header {
    padding: 10px 16px 6px;
    display: flex; justify-content: space-between; align-items: center;
    font-size: 12px; color: var(--text-3);
    font-weight: 500; letter-spacing: .5px; text-transform: uppercase;
}
.dd-clear {
    font-size: 12px; color: var(--primary); cursor: pointer;
    font-weight: 400; letter-spacing: 0; text-transform: none;
}
.dd-clear:hover { text-decoration: underline; }

.history-item {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 16px; cursor: pointer;
    font-size: 14px; color: var(--text);
    transition: background var(--ease);
}
.history-item:hover { background: var(--bg); }
.hi-icon  { color: var(--text-3); font-size: 14px; flex-shrink: 0; }
.hi-text  { flex: 1; }
.hi-arrow { color: var(--text-3); font-size: 12px; opacity: 0; transition: opacity var(--ease); }
.history-item:hover .hi-arrow { opacity: 1; }

/* ── 快捷键提示 ───────────────────────────── */
.search-hint {
    margin-top: 14px; font-size: 13px;
    color: var(--text-3); text-align: center;
}
.kbd {
    display: inline-block; padding: 1px 6px;
    border: 1px solid var(--border); border-radius: 4px;
    font-size: 11px; font-family: monospace;
    background: var(--surface); color: var(--text-2);
}

/* ── shake 动画（空提交） ─────────────────── */
@keyframes shake {
    0%,100% { transform: translateX(0); }
    20%,60% { transform: translateX(-6px); }
    40%,80% { transform: translateX( 6px); }
}
.search-input.shake { animation: shake .4s ease; }

/* ════ 结果页顶部栏 ══════════════════════════ */
.result-header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 14px 24px;
    display: flex; align-items: flex-start; gap: 16px; flex-wrap: wrap;
}
.result-header .search-row  { box-shadow: var(--sh-sm); }
.result-header .search-input { height: 44px; font-size: 14px; padding: 0 40px 0 42px; }
.result-header .s-icon       { font-size: 15px; }
.result-header .search-btn   { height: 44px; width: 80px; font-size: 14px; }

/* ════ 结果列表 ══════════════════════════════ */
.results-wrap {
    max-width: 960px; margin: 0 auto;
    padding: 20px 16px 48px;
}

.results-meta {
    display: flex; align-items: center; flex-wrap: wrap; gap: 6px;
    font-size: 13px; color: var(--text-3);
    margin-bottom: 16px; padding-bottom: 14px;
    border-bottom: 1px solid var(--border);
}
.results-meta .rc  { color: var(--primary); font-weight: 600; font-size: 14px; }
.results-meta .sep { color: var(--border); }

/* ── 结果卡片 ─────────────────────────────── */
.result-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r);
    padding: 16px 20px;
    margin-bottom: 10px;
    display: flex; align-items: center; gap: 16px;
    transition: box-shadow var(--ease), border-color var(--ease), transform var(--ease);
}
.result-card:hover {
    box-shadow: var(--sh-md);
    border-color: #C5D7F5;
    transform: translateY(-1px);
}

/* ── 基调徽章 ─────────────────────────────── */
.card-key {
    flex-shrink: 0;
    width: 64px; height: 64px; border-radius: var(--r);
    display: flex; flex-direction: column;
    align-items: center; justify-content: center; gap: 2px;
    color: #fff;
    text-shadow: 0 1px 4px rgba(0,0,0,.35);
    box-shadow: 0 2px 8px rgba(0,0,0,.22);
    padding: 4px;
}
.key-note {
    font-family: "SF Mono","Fira Code","Courier New", monospace;
    font-size: 22px; font-weight: 900; line-height: 1;
    letter-spacing: 0;
}
.key-mode {
    font-size: 11px; font-weight: 700; line-height: 1;
    opacity: .9; letter-spacing: 1px;
}

/* 12 音 + 默认 */
.key-c    { background: linear-gradient(135deg,#E53935,#B71C1C); }
.key-cs   { background: linear-gradient(135deg,#F4511E,#BF360C); }
.key-d    { background: linear-gradient(135deg,#F57C00,#E65100); }
.key-ds   { background: linear-gradient(135deg,#FFB300,#FF6F00); }
.key-e    { background: linear-gradient(135deg,#7CB342,#33691E); }
.key-f    { background: linear-gradient(135deg,#43A047,#1B5E20); }
.key-fs   { background: linear-gradient(135deg,#00897B,#004D40); }
.key-g    { background: linear-gradient(135deg,#1E88E5,#0D47A1); }
.key-gs   { background: linear-gradient(135deg,#3949AB,#1A237E); }
.key-a    { background: linear-gradient(135deg,#8E24AA,#4A148C); }
.key-as   { background: linear-gradient(135deg,#D81B60,#880E4F); }
.key-b    { background: linear-gradient(135deg,#6D4C41,#3E2723); }
.key-default { background: linear-gradient(135deg,#546E7A,#37474F); }

/* ── 卡片内容 ─────────────────────────────── */
.card-body { flex: 1; min-width: 0; }

.card-title {
    display: flex; align-items: baseline;
    flex-wrap: wrap; gap: 8px; margin-bottom: 5px;
}
.card-title .song   { font-size: 17px; font-weight: 700; color: var(--text); line-height: 1.3; }
.card-title .singer { font-size: 13px; color: var(--text-2); }

.card-tags { display: flex; gap: 5px; flex-wrap: wrap; margin-bottom: 6px; }

.tag {
    display: inline-block; padding: 2px 8px;
    border-radius: var(--r-sm);
    font-size: 11px; font-weight: 600; line-height: 1.7;
}
.tag-major  { background: #E8F5E9; color: #2E7D32; }
.tag-minor  { background: #E3F2FD; color: #1565C0; }
.tag-other  { background: #F3E5F5; color: #6A1B9A; }

.card-footer {
    display: flex; align-items: center;
    gap: 16px; margin-top: 8px;
    font-size: 12px; color: var(--text-3);
}
.ft-item { display: flex; align-items: center; gap: 4px; }

mark {
    background: var(--mark-bg); color: inherit;
    border-radius: 2px; padding: 0 1px;
}

/* ── 空结果 / 错误 ────────────────────────── */
.empty-state {
    text-align: center; padding: 80px 20px 60px;
    color: var(--text-2);
}
.empty-state .es-icon { font-size: 56px; display: block; margin-bottom: 16px; opacity: .7; }
.empty-state h3 { font-size: 18px; font-weight: 600; color: var(--text); margin-bottom: 8px; }
.empty-state p  { font-size: 14px; max-width: 380px; margin: 0 auto; }
.empty-tips {
    display: flex; flex-direction: column; gap: 6px;
    align-items: center; margin-top: 20px;
    font-size: 13px; color: var(--text-3);
}

.alert {
    display: flex; gap: 10px; align-items: flex-start;
    padding: 14px 18px; border-radius: var(--r);
    margin-bottom: 16px; font-size: 14px;
}
.alert-error { background: #FFEBEE; border: 1px solid #FFCDD2; color: #C62828; }

/* ── 分页 ────────────────────────────────── */
.pagination {
    display: flex; justify-content: center;
    align-items: center; gap: 4px;
    margin-top: 32px; flex-wrap: wrap;
}
.page-btn {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 36px; height: 36px; padding: 0 10px;
    border-radius: var(--r-sm); font-size: 14px;
    text-decoration: none; border: 1px solid var(--border);
    color: var(--text); background: var(--surface);
    transition: background var(--ease), color var(--ease), border-color var(--ease);
    cursor: pointer;
}
.page-btn:hover   { background: var(--primary-light); color: var(--primary); border-color: var(--primary); text-decoration: none; }
.page-btn.active  { background: var(--primary); color: #fff; border-color: var(--primary); font-weight: 600; }
.page-btn.disabled{ color: #BDBDBD; pointer-events: none; }
.page-btn.pn      { padding: 0 14px; font-size: 13px; }

/* ── 页脚 ────────────────────────────────── */
footer {
    background: var(--surface); border-top: 1px solid var(--border);
    padding: 24px 20px; text-align: center; margin-top: auto;
}
.footer-links { display: flex; justify-content: center; gap: 24px; margin-bottom: 10px; }
.footer-links a { font-size: 13px; color: var(--primary); }
.footer-copy    { font-size: 12px; color: var(--text-3); }

/* ── 响应式 ──────────────────────────────── */
@media (max-width: 640px) {
    .hero-logo .h-icon { width: 62px; height: 62px; border-radius: 14px; box-shadow: 0 6px 20px rgba(139,92,246,.30); }
    .hero-logo .h-text h1 { font-size: 26px; }
    .result-header { flex-direction: column; padding: 12px 16px; }
    .result-header .search-box { max-width: 100%; }
    .navbar-logo .n-brand { display: none; }
    .card-key { width: 54px; height: 54px; }
    .card-key .key-note { font-size: 18px; }
    .card-key .key-mode { font-size: 10px; }
}
@media (max-width: 480px) {
    .hero-logo { flex-direction: column; text-align: center; gap: 14px; }
    .search-input { height: 48px; font-size: 15px; }
    .search-btn   { height: 48px; width: 80px; }
    .card-key     { display: flex !important; width: 48px; height: 48px; }
    .card-key .key-note { font-size: 16px; }
    .card-key .key-mode { font-size: 9px; letter-spacing: .5px; }
    .result-card  { padding: 12px 12px; gap: 10px; }
}
