/* ===== CSS変数 ===== */
:root {
    --primary:       #7c5cbf;
    --primary-dark:  #5e3fa3;
    --primary-light: #ede9f8;
    --accent:        #e040fb;
    --bg:            #f5f3ff;
    --surface:       #ffffff;
    --text:          #2d2540;
    --text-muted:    #7b6fa0;
    --border:        #e2ddf0;
    --row-even:      #ffffff;
    --row-odd:       #faf8ff;
    --row-hover:     #f0ebff;
    --new-tag:       #f43f5e;
    --link:          #6d28d9;
    --shadow-sm:     0 1px 4px rgba(124, 92, 191, 0.10);
    --shadow-md:     0 4px 16px rgba(124, 92, 191, 0.15);
    --shadow-lg:     0 8px 32px rgba(124, 92, 191, 0.20);
    --radius:        12px;
    --radius-sm:     8px;
}

/* ===== リセット・ベース ===== */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Noto Sans JP', sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

/* ===== ページヘッダー ===== */
.page-header {
    background: linear-gradient(135deg, var(--primary) 0%, #a07dda 100%);
    color: white;
    padding: 20px 24px;
    box-shadow: var(--shadow-md);
}

.header-inner {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-icon {
    font-size: 28px;
}

h1 {
    font-size: 22px;
    font-weight: 700;
    letter-spacing: 0.03em;
}

/* ===== コンテナ ===== */
.container {
    max-width: 1200px;
    margin: 24px auto;
    padding: 0 16px 48px;
}

/* ===== フィルタカード ===== */
.filter-card {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    padding: 20px 24px;
    margin-bottom: 20px;
    display: flex;
    align-items: flex-start;
    gap: 24px;
    flex-wrap: wrap;
}

.filter-left {
    flex: 1;
    min-width: 280px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.filter-right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 12px;
}

/* ===== トグルボタン ===== */
.toggle-buttons {
    display: flex;
    gap: 8px;
    background: var(--primary-light);
    border-radius: 999px;
    padding: 4px;
    width: fit-content;
}

.toggle-buttons label {
    cursor: pointer;
}

.toggle-buttons input[type="radio"] {
    display: none;
}

.toggle-buttons input[type="radio"] + span {
    display: block;
    padding: 6px 18px;
    border-radius: 999px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-muted);
    transition: background 0.2s, color 0.2s;
}

.toggle-buttons input[type="radio"]:checked + span {
    background: var(--primary);
    color: white;
}

/* ===== フィルタ行 ===== */
.filter-select-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.filter-select-row label {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-muted);
    white-space: nowrap;
}

.filter-select-row select {
    height: 38px;
    padding: 0 32px 0 12px;
    font-size: 14px;
    font-family: 'Noto Sans JP', sans-serif;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    background: white;
    color: var(--text);
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%237b6fa0' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    min-width: 200px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.filter-select-row select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(124, 92, 191, 0.15);
}

/* ===== 動画フィルタ ===== */
.video-filter-row {
    display: flex;
    align-items: center;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text);
    cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
    appearance: none;
    width: 18px;
    height: 18px;
    border: 2px solid var(--border);
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s;
    flex-shrink: 0;
}

.checkbox-label input[type="checkbox"]:checked {
    background: var(--primary);
    border-color: var(--primary);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath fill='white' d='M2 6l3 3 5-5' stroke='white' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: center;
}

/* ===== 表示件数 ===== */
.row-count {
    font-size: 13px;
    font-weight: 600;
    color: var(--primary);
    background: var(--primary-light);
    padding: 5px 14px;
    border-radius: 999px;
    white-space: nowrap;
}

/* ===== 操作説明 ===== */
.instructions {
    background: var(--bg);
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.inst-item {
    font-size: 13px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 8px;
}

.inst-icon {
    font-size: 14px;
    width: 18px;
    text-align: center;
    flex-shrink: 0;
}

/* ===== テーブルラッパー ===== */
.table-wrapper {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    overflow: hidden;
}

/* ===== テーブル ===== */
table {
    border-collapse: collapse;
    width: 100%;
}

thead {
    position: sticky;
    top: 0;
    z-index: 10;
}

th {
    background: linear-gradient(180deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    padding: 12px 14px;
    text-align: left;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.04em;
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
    transition: background 0.15s;
}

th:hover {
    background: linear-gradient(180deg, #8d6dc8 0%, #6a4aaa 100%);
}

th.sorted {
    background: linear-gradient(180deg, #5e3fa3 0%, #4a2e8a 100%);
}

td {
    padding: 10px 14px;
    font-size: 14px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

tr.row-even td { background: var(--row-even); }
tr.row-odd  td { background: var(--row-odd);  }

tbody tr:hover td {
    background: var(--row-hover);
}

tbody tr:last-child td {
    border-bottom: none;
}

/* ===== 各列 ===== */
.singer-column {
    max-width: 140px;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    font-weight: 500;
    color: var(--text);
}

.song-column {
    max-width: 280px;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.song-column.has-lyrics {
    cursor: pointer;
    color: var(--link);
}

.song-column.has-lyrics:hover {
    text-decoration: underline;
    text-decoration-style: dotted;
}

.notes-column {
    max-width: 160px;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    font-size: 13px;
    color: var(--text-muted);
}

.link-column {
    text-align: center;
    white-space: nowrap;
}

.video-link {
    display: inline-block;
    background: var(--primary);
    color: white;
    text-decoration: none;
    padding: 4px 12px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    transition: background 0.2s, transform 0.1s;
}

.video-link:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
}

.no-video {
    color: var(--border);
    font-size: 16px;
}

/* ===== Newタグ ===== */
.new-tag {
    display: inline-block;
    background: var(--new-tag);
    color: white;
    font-size: 10px;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 999px;
    margin-left: 6px;
    vertical-align: middle;
    letter-spacing: 0.05em;
}

/* ===== ローディング ===== */
.loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    gap: 16px;
    color: var(--text-muted);
    font-size: 14px;
}

.spinner {
    width: 36px;
    height: 36px;
    border: 3px solid var(--primary-light);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.error-msg {
    padding: 40px 20px;
    text-align: center;
    color: #dc2626;
    font-size: 14px;
}

/* ===== オーバーレイ ===== */
.overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(30, 20, 60, 0.55);
    z-index: 2000;
    backdrop-filter: blur(2px);
}

/* ===== 歌詞ポップアップ ===== */
.lyrics-popup {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    border-radius: var(--radius);
    width: min(640px, 92vw);
    max-height: 82vh;
    z-index: 2100;
    flex-direction: column;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

.lyrics-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: linear-gradient(135deg, var(--primary) 0%, #a07dda 100%);
    color: white;
    flex-shrink: 0;
}

.lyrics-title {
    font-size: 15px;
    font-weight: 700;
}

.close-btn {
    background: rgba(255,255,255,0.2);
    border: none;
    color: white;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    flex-shrink: 0;
}

.close-btn:hover {
    background: rgba(255,255,255,0.35);
}

.lyrics-body {
    padding: 20px 24px;
    overflow-y: auto;
    font-size: 15px;
    line-height: 2;
    color: var(--text);
    white-space: pre-wrap;
}

/* ===== リンクプレビュー ===== */
.link-preview {
    display: none;
    position: absolute;
    background: white;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    z-index: 1000;
    max-width: 220px;
}

.link-preview img {
    width: 100%;
    display: block;
}

.link-preview .preview-title {
    padding: 8px 10px;
    font-size: 12px;
    color: var(--text);
    line-height: 1.4;
}

/* ===== レスポンシブ ===== */
@media (max-width: 640px) {
    .page-header {
        padding: 16px;
    }

    h1 {
        font-size: 17px;
    }

    .container {
        padding: 0 10px 32px;
        margin-top: 16px;
    }

    .filter-card {
        flex-direction: column;
        padding: 16px;
        gap: 16px;
    }

    .filter-left {
        min-width: 0;
        width: 100%;
    }

    .filter-right {
        align-items: flex-start;
        width: 100%;
    }

    .filter-select-row {
        width: 100%;
    }

    .filter-select-row select {
        min-width: 0;
        width: 100%;
        flex: 1;
    }

    .singer-column { max-width: 100px; }
    .song-column   { max-width: 160px; }
    .notes-column  { display: none; }

    td, th { padding: 8px 10px; font-size: 13px; }
}
