:root {
    color-scheme: light;
    --gold-900: #6e4b00;
    --gold-700: #a36a00;
    --gold-500: #d99a00;
    --gold-300: #f6c431;
    --gold-100: #fff2b8;
    --cream: #fffaf0;
    --paper: rgba(255, 255, 255, 0.94);
    --ink: #312810;
    --muted: #71664c;
    --line: rgba(163, 106, 0, 0.2);
    --shadow: 0 18px 50px rgba(92, 62, 0, 0.13);
    --radius-lg: 24px;
    --radius-md: 14px;
    font-family: Inter, "Noto Sans SC", "Microsoft YaHei", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
    margin: 0;
    min-width: 280px;
    color: var(--ink);
    background:
        radial-gradient(circle at 10% 5%, rgba(246, 196, 49, 0.2), transparent 30rem),
        linear-gradient(180deg, #fffefa 0, var(--cream) 70%, #fff7dd 100%);
}
button, input, select { font: inherit; }
button, select { cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible, a:focus-visible, tr:focus-visible {
    outline: 3px solid #3d75d6;
    outline-offset: 3px;
}

.skip-link {
    position: fixed;
    z-index: 50;
    top: 12px;
    left: 12px;
    transform: translateY(-150%);
    padding: 10px 14px;
    border-radius: 10px;
    color: #fff;
    background: #1f1a0d;
}
.skip-link:focus { transform: none; }
.home-link {
    position: fixed;
    top: max(14px, env(safe-area-inset-top));
    left: max(14px, env(safe-area-inset-left));
    z-index: 20;
    display: grid;
    place-items: center;
    width: 46px;
    height: 46px;
    border: 1px solid rgba(163, 106, 0, .3);
    border-radius: 15px;
    color: var(--gold-900);
    background: rgba(255, 253, 246, .95);
    box-shadow: 0 4px 18px rgba(49, 40, 16, .15);
}
.home-link svg { width: 24px; height: 24px; }
.home-link:hover { background: #fff2b8; }
.radio-link { top: calc(max(14px, env(safe-area-inset-top)) + 56px); }

.hero {
    position: relative;
    height: var(--hero-height, clamp(180px, 42vw, 560px));
    overflow: hidden;
    border-bottom: 4px solid var(--gold-300);
    background: #17130b;
    transition: height 380ms cubic-bezier(0.22, 1, 0.36, 1);
    will-change: height;
}
.hero.is-pulling { cursor: ns-resize; user-select: none; transition: none; }
.hero.is-resizing { transition: none; }
.hero__media, .hero__shade {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}
.hero__media { object-fit: cover; object-position: center top; }
.hero__shade { background: linear-gradient(180deg, rgba(42, 28, 0, 0.04) 35%, rgba(42, 28, 0, 0.66) 100%); }
.hero__content {
    position: absolute;
    right: max(24px, calc((100% - 1180px) / 2));
    bottom: clamp(24px, 5vw, 66px);
    left: max(24px, calc((100% - 1180px) / 2));
    color: #fff;
    text-shadow: 0 2px 18px rgba(0, 0, 0, 0.6);
}
.hero__content h1 {
    margin: 4px 0 8px;
    font-family: Georgia, "Noto Serif SC", "Songti SC", serif;
    font-size: clamp(2rem, 5.5vw, 5.2rem);
    line-height: 1;
    letter-spacing: 0.06em;
}
.hero__content p { margin: 0; font-size: clamp(0.95rem, 1.8vw, 1.3rem); }
.hero__eyebrow { font-weight: 800; letter-spacing: 0.18em; }
.page-shell {
    width: min(1180px, calc(100% - 32px));
    margin: clamp(28px, 5vw, 72px) auto 48px;
}
.song-panel {
    overflow: clip;
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    background: var(--paper);
    box-shadow: var(--shadow);
}
.panel-heading {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 24px;
    padding: clamp(24px, 4vw, 42px);
    border-bottom: 1px solid var(--line);
}
.panel-heading h2 {
    margin: 4px 0 0;
    color: var(--gold-900);
    font-family: Georgia, "Noto Serif SC", "Songti SC", serif;
    font-size: clamp(1.7rem, 3vw, 2.6rem);
}
.section-kicker {
    margin: 0;
    color: var(--gold-700);
    font-size: 0.75rem;
    font-weight: 900;
    letter-spacing: 0.18em;
}

.primary-button, .quiet-button, .reset-button, .copy-button {
    min-height: 44px;
    border-radius: 999px;
    font-weight: 800;
    transition: transform 160ms ease, box-shadow 160ms ease, background-color 160ms ease;
}
.primary-button {
    padding: 0 24px;
    border: 0;
    color: #3b2a00;
    background: linear-gradient(135deg, #ffe583, var(--gold-300));
    box-shadow: 0 8px 22px rgba(163, 106, 0, 0.23);
}
.primary-button:hover, .quiet-button:hover, .reset-button:hover, .copy-button:hover { transform: translateY(-1px); }
.quiet-button, .reset-button, .copy-button {
    border: 1px solid var(--line);
    color: var(--gold-900);
    background: #fff;
}
.quiet-button { flex: 0 0 auto; padding: 0 18px; }

.random-result {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    margin: 24px clamp(24px, 4vw, 42px) 0;
    padding: 18px 20px;
    border: 1px solid rgba(217, 154, 0, 0.35);
    border-radius: var(--radius-md);
    background: linear-gradient(135deg, #fff9dc, #fff2b4);
}
.random-result[hidden] { display: none; }
.random-result > div { display: grid; gap: 3px; }
.random-result__label { color: var(--gold-700); font-size: 0.78rem; font-weight: 800; }
.random-result strong { font-size: 1.2rem; }
.random-result span:last-child { color: var(--muted); }

.filters {
    display: grid;
    grid-template-columns: minmax(230px, 1.5fr) minmax(150px, 0.7fr) minmax(220px, 1fr) auto;
    align-items: end;
    gap: 14px;
    padding: 28px clamp(24px, 4vw, 42px) 20px;
}
.field { display: grid; gap: 7px; min-width: 0; }
.field > span { color: var(--muted); font-size: 0.78rem; font-weight: 800; }
.field input, .field select {
    width: 100%;
    min-height: 48px;
    border: 1px solid rgba(163, 106, 0, 0.28);
    border-radius: 12px;
    color: var(--ink);
    background: #fffdf7;
}
.field input { padding: 0 15px; }
.field select { padding: 0 38px 0 13px; text-overflow: ellipsis; }
.reset-button { padding: 0 17px; }

.results-summary {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    padding: 0 clamp(24px, 4vw, 42px) 14px;
    color: var(--muted);
    font-size: 0.84rem;
}
#result-count { color: var(--gold-900); font-weight: 800; }
.table-shell { position: relative; border-top: 1px solid var(--line); }
.song-table { width: 100%; border-collapse: collapse; table-layout: fixed; }
.song-table th, .song-table td {
    padding: 15px 18px;
    text-align: left;
    vertical-align: middle;
    overflow-wrap: anywhere;
}
.song-table th {
    position: sticky;
    z-index: 2;
    top: 0;
    color: #fff;
    background: #8f6500;
    font-size: 0.82rem;
    letter-spacing: 0.03em;
}
.song-table th:nth-child(1) { width: 31%; }
.song-table th:nth-child(2) { width: 25%; }
.song-table th:nth-child(3) { width: 10%; }
.song-table th:nth-child(4) { width: 23%; }
.song-table th:nth-child(5) { width: 11%; }
.song-table tbody tr {
    border-bottom: 1px solid rgba(163, 106, 0, 0.12);
    transition: background-color 140ms ease;
}
.song-table tbody tr:hover, .song-table tbody tr:focus-visible { background: #fff8d8; }
.song-name { color: var(--ink); font-weight: 850; }
.song-name a { color: #765000; text-decoration-thickness: 1px; text-underline-offset: 3px; }
.song-video-trigger {
    padding: 0;
    border: 0;
    color: #765000;
    background: none;
    font: inherit;
    font-weight: inherit;
    text-align: left;
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 3px;
    overflow-wrap: anywhere;
}
.song-official-link {
    display: inline-block;
    margin-left: 8px;
    padding: 2px 7px;
    border-radius: 999px;
    color: #655936;
    background: #f7f3e9;
    font-size: 0.72rem;
    font-weight: 700;
    white-space: nowrap;
}
.song-official-link--date-fallback { color: #93420f; background: #fff0e5; }
.song-video-date-fallback { color: #9b3f12; text-decoration-color: #bc6a3b; }
.song-date-note {
    display: inline-block;
    margin-left: 8px;
    color: #93420f;
    font-size: 0.72rem;
    font-weight: 700;
}
.song-date-note--official { color: #655936; }
.artist, .remarks { color: var(--muted); }
.tag-list { display: inline-flex; flex-wrap: wrap; gap: 6px; margin-top: 7px; }
.tag {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    padding: 2px 8px;
    border-radius: 999px;
    color: #5a3b00;
    background: var(--gold-100);
    font-size: 0.72rem;
    font-weight: 850;
}
.tag--video { color: #1c5487; background: #dff1ff; }
.tag--signature { color: #7d2d64; background: #ffe5f7; }
.song-table tbody tr.is-signature { background: #fffaf0; }
.copy-button { width: 100%; min-height: 36px; padding: 0 10px; font-size: 0.78rem; }

.empty-state, .error-state {
    display: grid;
    justify-items: center;
    gap: 8px;
    padding: 58px 24px;
    color: var(--muted);
    text-align: center;
}
.empty-state[hidden], .error-state[hidden] { display: none; }
.empty-state strong, .error-state strong { color: var(--gold-900); font-size: 1.1rem; }

.site-notice {
    margin-top: 22px;
    padding: 20px 24px;
    border: 1px solid rgba(163, 106, 0, 0.2);
    border-radius: var(--radius-md);
    color: #655936;
    background: rgba(255, 250, 232, 0.92);
    font-size: 0.88rem;
    line-height: 1.7;
}
.site-notice p { margin: 0; }
.site-notice p + p { margin-top: 7px; }
.site-footer { padding: 12px 20px 40px; color: #877650; text-align: center; font-size: 0.78rem; }

.video-dialog {
    width: min(620px, calc(100vw - 28px));
    max-height: min(76vh, 720px);
    padding: 24px;
    border: 1px solid rgba(163, 106, 0, 0.3);
    border-radius: 18px;
    color: var(--ink);
    background: #fffdf7;
    box-shadow: 0 24px 70px rgba(42, 31, 5, 0.3);
}
.video-dialog::backdrop { background: rgba(37, 28, 10, 0.58); }
.video-dialog__header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.video-dialog__header h2 { margin: 0; color: var(--gold-900); font-size: 1.25rem; overflow-wrap: anywhere; }
.video-dialog__close { min-width: 56px; min-height: 44px; border: 1px solid var(--line); border-radius: 12px; color: var(--gold-900); background: #fff; }
.video-dialog__hint { margin: 10px 0 18px; color: var(--muted); font-size: 0.84rem; }
.video-dialog__choices { display: grid; gap: 9px; max-height: min(55vh, 500px); overflow-y: auto; overscroll-behavior: contain; }
.video-choice { display: block; min-width: 0; min-height: 48px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; color: var(--gold-900); background: #fff9e6; overflow-wrap: anywhere; }
.video-choice:hover { background: #fff0ba; }
.video-choice--official { color: #655936; background: #f7f3e9; }
.video-choice--date-fallback { color: #93420f; border-color: #d7a071; background: #fff0e5; }
.video-choice--date-fallback:hover { background: #ffe2ce; }

.toast {
    position: fixed;
    z-index: 20;
    right: 18px;
    bottom: 18px;
    max-width: min(360px, calc(100% - 36px));
    padding: 12px 16px;
    border-radius: 12px;
    color: #fff;
    background: rgba(42, 31, 5, 0.94);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.24);
    opacity: 0;
    transform: translateY(12px);
    pointer-events: none;
    transition: opacity 160ms ease, transform 160ms ease;
}
.toast.is-visible { opacity: 1; transform: none; }
.visually-hidden {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

@media (max-width: 920px) {
    .filters { grid-template-columns: 1fr 1fr; }
    .reset-button { width: max-content; }
    .song-table th, .song-table td { padding-right: 13px; padding-left: 13px; }
}

@media (max-width: 700px) {
    .hero__content { right: 20px; bottom: 22px; left: 20px; }
    .page-shell { width: min(100% - 20px, 1180px); margin-top: 20px; }
    .song-panel { border-radius: 18px; }
    .panel-heading { align-items: stretch; flex-direction: column; padding: 22px 18px; }
    .primary-button { width: 100%; }
    .random-result { align-items: stretch; flex-direction: column; margin: 18px 16px 0; }
    .filters { grid-template-columns: 1fr; padding: 22px 16px 18px; }
    .reset-button { width: 100%; }
    .results-summary { padding: 0 16px 14px; }
    .results-summary__tip { display: none; }
    .song-table, .song-table tbody, .song-table tr, .song-table td { display: block; width: 100%; }
    .song-table { padding: 14px; table-layout: auto; }
    .song-table thead { display: none; }
    .song-table tbody tr {
        display: grid;
        grid-template-columns: 1fr;
        gap: 0;
        margin-bottom: 12px;
        padding: 15px 15px 12px;
        border: 1px solid var(--line);
        border-radius: var(--radius-md);
        background: #fff;
        box-shadow: 0 6px 16px rgba(92, 62, 0, 0.07);
    }
    .song-table td {
        display: grid;
        grid-template-columns: minmax(62px, 0.27fr) minmax(0, 1fr);
        gap: 10px;
        padding: 7px 0;
        overflow: visible;
        white-space: normal;
    }
    .song-table td::before {
        content: attr(data-label);
        color: var(--gold-700);
        font-size: 0.75rem;
        font-weight: 850;
    }
    .song-table td:first-child { padding-top: 0; }
    .song-table .song-official-link { grid-column: 2; justify-self: start; margin-left: 0; }
    .song-table td .tag-list { grid-column: 2; }
    .song-table td:last-child { display: block; padding-bottom: 0; }
    .song-table td:last-child::before { content: none; }
    .copy-button { margin-top: 5px; }
    .site-notice { padding: 17px 18px; }
    .toast { right: 12px; bottom: 12px; left: 12px; max-width: none; text-align: center; }
    .video-dialog { width: calc(100vw - 20px); max-height: 85dvh; padding: 17px; }
    .video-dialog__choices { max-height: 62dvh; }
}

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    *, *::before, *::after { scroll-behavior: auto !important; transition-duration: 0.01ms !important; }
}
