/* Hadia SongBook — split index + playlist (not chip/card songbook clone) */

:root {
    --bg-main: #fffdf8;
    --bg-card: #ffffff;
    --primary: #fdd835;
    --primary-deep: #ffb300;
    --mint: #81c784;
    --mint-soft: #e8f5e9;
    --text: #1f2937;
    --muted: #6b7280;
    --line: #f0ebe0;
    --line-strong: #e5dfd0;
    --soft: #fff8e1;
    --heart: #f43f5e;
    --shadow: 0 12px 36px rgba(255, 179, 0, 0.08);
    --radius: 20px;
    font-family: 'Pretendard', system-ui, sans-serif;
}

[data-theme="dark"] {
    --bg-main: #18181b;
    --bg-card: #27272a;
    --primary: #fcd34d;
    --primary-deep: #fbbf24;
    --mint: #86efac;
    --mint-soft: #14532d;
    --text: #f4f4f5;
    --muted: #a1a1aa;
    --line: #3f3f46;
    --line-strong: #52525b;
    --soft: #3f3f46;
    --shadow: 0 12px 36px rgba(0, 0, 0, 0.4);
}

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

body {
    min-height: 100vh;
    color: var(--text);
    background: var(--bg-main);
    line-height: 1.45;
    overflow-x: hidden;
}

button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; }
input, select { outline: none; }

.ambient-bg {
    position: fixed; inset: 0; z-index: -1; pointer-events: none; overflow: hidden;
}
.ambient-glow {
    position: absolute; width: 620px; height: 620px; border-radius: 50%;
    filter: blur(130px); opacity: 0.26;
    animation: floatGlow 16s infinite alternate ease-in-out;
}
.color-yellow {
    top: -180px; left: 5%;
    background: radial-gradient(circle, rgba(253,216,53,.42), transparent 70%);
}
.color-mint {
    bottom: -200px; right: 0;
    background: radial-gradient(circle, rgba(129,199,130,.32), transparent 70%);
    animation-delay: -7s;
}
@keyframes floatGlow {
    from { transform: translate(0, 0) scale(1); }
    to { transform: translate(36px, 24px) scale(1.08); }
}

.mobile-only { display: none !important; }

.page {
    width: min(1180px, calc(100% - 28px));
    margin: 0 auto;
    padding: 18px 0 48px;
}

/* Topbar */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 18px;
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-avatar {
    width: 54px; height: 54px; border-radius: 50%;
    object-fit: cover; background: var(--bg-card);
    box-shadow: 0 8px 20px rgba(0,0,0,.08);
    border: 3px solid var(--bg-card);
    transition: transform .25s cubic-bezier(.34,1.4,.64,1);
}
.brand:hover .brand-avatar { transform: rotate(6deg) scale(1.05); }
.brand-eyebrow {
    display: block;
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--muted);
}
.brand-text h1 {
    font-family: 'Outfit', 'Pretendard', sans-serif;
    font-size: 1.55rem;
    font-weight: 800;
    letter-spacing: -0.03em;
}
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.nav-link, .icon-btn, .pill-btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    height: 40px; border-radius: 999px;
    text-decoration: none; color: var(--text);
    font-weight: 700; font-size: 0.85rem;
    background: rgba(255,255,255,.72);
    border: 1.5px solid var(--line-strong);
    backdrop-filter: blur(8px);
    transition: .18s;
}
[data-theme="dark"] .nav-link,
[data-theme="dark"] .icon-btn,
[data-theme="dark"] .pill-btn { background: rgba(39,39,42,.8); }
.icon-btn { width: 40px; }
.nav-link { padding: 0 12px; }
.pill-btn {
    padding: 0 14px;
    border-color: var(--primary);
    box-shadow: 0 4px 12px rgba(253,216,53,.18);
}
.pill-btn i { color: var(--primary-deep); }
.nav-link:hover, .icon-btn:hover, .pill-btn:hover { transform: translateY(-2px); }
.login-wrap { position: relative; display: flex; }
.login-wrap #custom-login-btn { pointer-events: none; }
.google-login-overlay {
    position: absolute; inset: 0; opacity: 0.001; overflow: hidden; z-index: 2;
}

/* Workspace: rail + playlist */
.workspace {
    display: grid;
    grid-template-columns: 250px minmax(0, 1fr);
    gap: 16px;
    align-items: start;
    min-height: 70vh;
}

.nav-rail {
    position: sticky;
    top: 14px;
    background: rgba(255,255,255,.88);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    backdrop-filter: blur(10px);
    padding: 16px 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
[data-theme="dark"] .nav-rail { background: rgba(39,39,42,.9); }

.rail-head {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 4px;
}
.rail-head h2 {
    font-family: 'Outfit', sans-serif;
    font-size: 0.95rem;
    font-weight: 800;
    letter-spacing: 0.04em;
}

.rail-fav {
    display: flex; align-items: center; gap: 8px;
    width: 100%;
    padding: 10px 12px;
    border-radius: 12px;
    background: var(--soft);
    color: var(--muted);
    font-weight: 800;
    font-size: 0.86rem;
    transition: .15s;
}
.rail-fav i { color: #f9a8d4; }
.rail-fav b {
    margin-left: auto;
    min-width: 22px; height: 22px; padding: 0 6px;
    border-radius: 999px;
    background: #fff; color: var(--heart);
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 0.72rem;
}
[data-theme="dark"] .rail-fav b { background: #18181b; }
.rail-fav.active {
    background: #ffe4e6;
    color: var(--heart);
}
[data-theme="dark"] .rail-fav.active { background: #4c0519; }

.rail-label {
    margin-top: 8px;
    font-size: 0.7rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    color: var(--muted);
    text-transform: uppercase;
}

.genre-nav {
    display: flex;
    flex-direction: column;
    gap: 3px;
    max-height: 280px;
    overflow-y: auto;
}

.genre-item {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 8px 10px;
    border-radius: 10px;
    font-weight: 700;
    font-size: 0.88rem;
    color: var(--muted);
    text-align: left;
    transition: .12s;
}
.genre-item:hover { background: var(--soft); color: var(--text); }
.genre-item.active {
    background: linear-gradient(90deg, rgba(253,216,53,.45), rgba(253,216,53,.12));
    color: var(--text);
}
.genre-item .count {
    margin-left: auto;
    font-size: 0.72rem;
    font-weight: 800;
    color: var(--muted);
    opacity: 0.8;
}

.diff-nav {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
}
.diff-opt {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    min-height: 34px;
    border-radius: 10px;
    border: 1px solid var(--line-strong);
    background: var(--bg-card);
    font-weight: 800;
    font-size: 0.78rem;
    color: var(--muted);
}
.diff-opt.active {
    background: var(--primary);
    border-color: var(--primary-deep);
    color: #374151;
}

.rail-actions {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 10px;
    padding-top: 12px;
    border-top: 1px dashed var(--line-strong);
}
.rail-actions button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    min-height: 40px;
    border-radius: 12px;
    font-weight: 800;
    font-size: 0.86rem;
    background: var(--soft);
    color: var(--text);
    transition: .15s;
}
.rail-actions button:hover { transform: translateY(-1px); }
#btn-random {
    background: linear-gradient(135deg, #fdd835, #ffb300);
    color: #374151;
    box-shadow: 0 6px 14px rgba(255,179,0,.25);
}
#btn-add-song { background: var(--mint-soft); color: #1b5e20; }
[data-theme="dark"] #btn-add-song { color: #bbf7d0; }

.admin-only { display: none !important; }
body.admin-mode .admin-only { display: inline-flex !important; }

.nav-backdrop {
    display: none;
    position: fixed; inset: 0; z-index: 40;
    background: rgba(20,16,8,.28);
}

/* Playlist panel */
.playlist {
    background: rgba(255,255,255,.9);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    backdrop-filter: blur(10px);
    padding: 18px 18px 10px;
    min-width: 0;
}
[data-theme="dark"] .playlist { background: rgba(39,39,42,.92); }

.playlist-head { margin-bottom: 10px; }

.search-field {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 14px;
    height: 48px;
    border-radius: 14px;
    background: var(--soft);
    border: 1px solid var(--line-strong);
}
.search-field i { color: var(--primary-deep); }
.search-field input {
    flex: 1;
    border: 0;
    background: transparent;
    font-weight: 700;
    font-size: 0.95rem;
}

.playlist-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 12px;
    flex-wrap: wrap;
}
.playlist-meta strong {
    font-family: 'Outfit', sans-serif;
    font-size: 1.05rem;
    margin-right: 8px;
}
.connection {
    font-size: 0.74rem;
    font-weight: 700;
    color: var(--muted);
}
.connection::before {
    content: '';
    display: inline-block;
    width: 6px; height: 6px;
    margin-right: 5px;
    border-radius: 50%;
    background: #d1d5db;
    vertical-align: 1px;
}
.connection.online::before { background: var(--mint); }
.connection.error::before { background: var(--primary-deep); }

.sort-field {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--muted);
}
.sort-field select {
    height: 34px;
    padding: 0 8px;
    border: 1px solid var(--line-strong);
    border-radius: 10px;
    background: var(--bg-card);
    font-weight: 800;
    color: var(--text);
}

.active-summary {
    margin-top: 8px;
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--muted);
}

/* Track table — playlist rows, not cards */
.track-table { min-width: 0; }
.track-head,
.track-row {
    display: grid;
    grid-template-columns: 40px minmax(0, 1.6fr) 90px 110px 88px;
    gap: 8px;
    align-items: center;
    padding: 0 8px;
}
.track-head {
    height: 34px;
    font-size: 0.7rem;
    font-weight: 800;
    letter-spacing: 0.06em;
    color: var(--muted);
    text-transform: uppercase;
    border-bottom: 1px solid var(--line);
}
.track-body {
    max-height: min(68vh, 720px);
    overflow-y: auto;
    padding-bottom: 8px;
}
.track-row {
    min-height: 58px;
    border-radius: 12px;
    transition: background .12s;
}
.track-row:hover { background: var(--soft); }
.track-row.is-favorite .track-title { color: #be123c; }

.track-index {
    font-family: 'Outfit', sans-serif;
    font-weight: 800;
    font-size: 0.85rem;
    color: var(--muted);
    text-align: center;
}
.track-main {
    min-width: 0;
    text-align: left;
    padding: 8px 0;
    background: transparent;
    color: inherit;
}
.track-title {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 800;
    font-size: 0.98rem;
}
.track-artist {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin-top: 2px;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--muted);
}
.track-genre {
    font-size: 0.72rem;
    font-weight: 800;
    color: #92400e;
    background: var(--soft);
    border-radius: 8px;
    padding: 4px 8px;
    line-height: 1.35;
    white-space: normal;
    word-break: keep-all;
    justify-self: start;
}
[data-theme="dark"] .track-genre { color: var(--primary); }

.difficulty-meter {
    display: flex;
    gap: 2px;
    align-items: center;
}
img.yogurt {
    width: 20px;
    height: 20px;
    object-fit: contain;
    display: block;
    opacity: 0.28;
    filter: grayscale(1) contrast(0.9);
    transition: opacity .15s, filter .15s, transform .15s;
    flex-shrink: 0;
}
img.yogurt.on {
    opacity: 1;
    filter: none;
}
[data-theme="dark"] img.yogurt.on {
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.45));
}
.difficulty-meter:hover img.yogurt.on {
    transform: translateY(-1px);
}
.diff-opt img.yogurt {
    width: 16px;
    height: 16px;
    opacity: 1;
    filter: none;
}
#modal-diff .difficulty-meter {
    gap: 4px;
}
#modal-diff img.yogurt {
    width: 26px;
    height: 26px;
}

.track-acts {
    display: flex;
    justify-content: flex-end;
    gap: 4px;
}
.track-acts button {
    width: 32px; height: 32px;
    border-radius: 9px;
    color: var(--muted);
    display: grid; place-items: center;
}
.track-acts button:hover {
    background: var(--bg-card);
    color: var(--text);
}
.track-acts .fav.active { color: var(--heart); }
.track-acts .danger:hover { color: #ef4444; }

.empty {
    padding: 56px 16px;
    text-align: center;
    color: var(--muted);
    font-weight: 700;
    line-height: 1.8;
}

.footer {
    text-align: center;
    margin-top: 24px;
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 600;
}

/* Dialogs */
.song-dialog {
    border: 0;
    padding: 0;
    margin: auto; /* showModal() 기본 중앙정렬 — margin 없으면 좌상단으로 붙음 */
    width: min(460px, calc(100% - 28px));
    max-height: calc(100vh - 40px);
    border-radius: 18px;
    background: var(--bg-card);
    color: var(--text);
    box-shadow: var(--shadow);
}
.song-dialog::backdrop {
    background: rgba(40, 30, 10, 0.3);
    backdrop-filter: blur(3px);
}
.modal-head {
    position: relative;
    padding: 22px 22px 16px;
    border-bottom: 1px solid var(--line);
    background: linear-gradient(135deg, var(--soft), var(--bg-card));
}
.modal-kicker {
    color: var(--primary-deep);
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.08em;
}
.modal-head h2 {
    margin: 6px 72px 0 0;
    font-size: 1.35rem;
    font-weight: 800;
}
.modal-head p { margin: 6px 0 0; color: var(--muted); font-weight: 600; }
.modal-close, .modal-fav {
    position: absolute; top: 16px;
    width: 36px; height: 36px; border-radius: 10px;
    background: rgba(255,255,255,.7);
    color: var(--muted);
    display: grid; place-items: center;
}
.modal-close { right: 16px; }
.modal-close:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}
.modal-fav { right: 56px; }
.modal-fav.active { color: var(--heart); }
.modal-body { padding: 18px 22px 22px; }
.detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}
.detail {
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--soft);
}
.detail small {
    display: block; margin-bottom: 6px;
    color: var(--muted); font-size: 0.7rem; font-weight: 800;
}
.modal-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-top: 14px;
}
.modal-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 42px;
    border-radius: 12px;
    border: 1px solid var(--line-strong);
    background: var(--bg-card);
    font-weight: 800;
    text-decoration: none;
    color: inherit;
}
.modal-btn.is-disabled {
    opacity: 0.4;
    pointer-events: none;
}
.track-acts .video.has-link { color: var(--primary-deep); }
.track-acts .video:disabled {
    opacity: 0.28;
    cursor: default;
}
.modal-btn.primary {
    background: var(--primary);
    border-color: var(--primary-deep);
    color: #374151;
}
.modal-btn.primary:disabled {
    opacity: 0.55;
    cursor: wait;
}
.modal-btn.danger { color: #b91c1c; }
#modal-random { grid-column: 1 / -1; }
#modal-edit {
    background: var(--soft);
}

.field { display: block; margin-bottom: 12px; }
.field > span {
    display: block; margin-bottom: 6px;
    font-size: 0.8rem; font-weight: 800;
}
.field input, .field select {
    width: 100%; height: 42px; padding: 0 12px;
    border: 1px solid var(--line-strong);
    border-radius: 10px;
    background: var(--soft);
    font-weight: 700;
}
.diff-picker { display: flex; gap: 6px; }
.diff-picker button {
    flex: 1; height: 40px; border-radius: 10px;
    border: 1px solid var(--line-strong);
    background: var(--soft);
    font-weight: 800; color: var(--muted);
}
.diff-picker button.active {
    background: var(--primary);
    border-color: var(--primary-deep);
    color: #374151;
}
.genre-picker {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.genre-picker button {
    height: 34px;
    padding: 0 10px;
    border-radius: 10px;
    border: 1px solid var(--line-strong);
    background: var(--soft);
    font-weight: 800;
    font-size: 0.8rem;
    color: var(--muted);
}
.genre-picker button.active {
    background: var(--primary);
    border-color: var(--primary-deep);
    color: #374151;
}

.toast {
    position: fixed; left: 50%; bottom: 28px; z-index: 120;
    transform: translate(-50%, 16px); opacity: 0; pointer-events: none;
    padding: 11px 16px; border-radius: 999px;
    background: var(--bg-card); border: 1px solid var(--line);
    box-shadow: var(--shadow);
    font-weight: 800; font-size: 0.86rem;
    transition: .2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 900px) {
    .mobile-only { display: inline-flex !important; }
    .workspace { grid-template-columns: 1fr; }
    .nav-rail {
        position: fixed;
        top: 0; left: 0; bottom: 0;
        width: min(300px, 86vw);
        z-index: 50;
        border-radius: 0;
        transform: translateX(-105%);
        transition: transform .22s ease;
        overflow-y: auto;
    }
    .nav-rail.open { transform: translateX(0); }
    .nav-backdrop[hidden] { display: none; }
    .nav-backdrop:not([hidden]) { display: block; }
    .track-head, .track-row {
        grid-template-columns: 32px minmax(0, 1fr) 96px 72px;
    }
    .col-genre, .track-genre { display: none; }
    .nav-link span, .pill-btn span { display: none; }
    .nav-link { width: 40px; padding: 0; }
    .detail-grid { grid-template-columns: 1fr; }
    .modal-actions { grid-template-columns: 1fr; }
    #modal-random { grid-column: auto; }
}

@media (max-width: 560px) {
    .page { width: calc(100% - 16px); }
    .playlist { padding: 14px 10px 8px; }
    .track-head, .track-row {
        grid-template-columns: 28px minmax(0, 1fr) 70px;
    }
    .col-diff, .track-diff { display: none; }
    .track-body { max-height: none; }
}
