:root {
    color-scheme: light;
    --bg: #f5f7fa;
    --surface: #ffffff;
    --panel: #f8fafc;
    --border: #e2e8f0;
    --text: #111827;
    --muted: #475569;
    --accent: #0b5fff;
    --accent-strong: #094fcc;
    --danger: #dc2626;
    --danger-strong: #b91c1c;
    --success-bg: #ecffef;
    --success-text: #166534;
    --error-bg: #ffecec;
    --error-text: #b00020;
    --info-bg: #eff6ff;
    --info-border: #bfdbfe;
    --info-text: #1d4ed8;
}

body {
    font-family: system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    margin: 0;
    padding: 0;
}

body[data-theme='dark'] {
    color-scheme: dark;
    background: #111827;
    color: #e5e7eb;
}

body[data-theme='dark'] {
    --bg: #111827;
    --surface: #1f2937;
    --panel: #111827;
    --border: #374151;
    --text: #e5e7eb;
    --muted: #9ca3af;
    --accent: #60a5fa;
    --accent-strong: #3b82f6;
    --danger: #f87171;
    --danger-strong: #ef4444;
    --success-bg: #14532d;
    --success-text: #d1fae5;
    --error-bg: #4b1111;
    --error-text: #fee2e2;
    --info-bg: #1e40af;
    --info-border: #60a5fa;
    --info-text: #bfdbfe;
}

.card {
    width: min(75vw, 1180px);
    margin: 48px auto;
    background: var(--surface);
    padding: 24px;
    border-radius: 16px;
    box-shadow: 0 14px 40px rgba(15, 23, 42, 0.12);
}

h1 {
    margin: 0 0 12px;
    font-size: 28px;
}

p {
    margin: 10px 0;
}

label {
    display: block;
    margin: 14px 0;
    font-weight: 500;
}

input,
select {
    width: 100%;
    padding: 12px 14px;
    margin-top: 6px;
    border: 1px solid var(--border);
    border-radius: 12px;
    font-size: 15px;
    background: var(--surface);
    color: var(--text);
    box-sizing: border-box;
}

button,
.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 16px;
    border: none;
    border-radius: 12px;
    background: var(--accent);
    color: white;
    text-decoration: none;
    font-weight: 600;
    cursor: pointer;
}

button:hover,
.button:hover {
    background: var(--accent-strong);
}

button.danger,
.button.danger {
    background: var(--danger);
}

button.danger:hover,
.button.danger:hover {
    background: var(--danger-strong);
}

.button.secondary {
    background: #6b7280;
}

.button.secondary:hover {
    background: #4b5563;
}

.theme-switch-wrapper {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding-right: 4px;
}

.theme-icon {
    font-size: 1rem;
    line-height: 1;
}

.theme-switch {
    position: relative;
    width: 52px;
    height: 28px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--panel);
    cursor: pointer;
    padding: 0;
    display: inline-flex;
    align-items: center;
    transition: background 0.25s ease, border-color 0.25s ease;
}

.theme-switch:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 3px;
}

.theme-switch-handle {
    position: absolute;
    left: 4px;
    top: 4px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--accent);
    transition: transform 0.25s ease, background 0.25s ease;
}

body[data-theme='dark'] .theme-switch-handle {
    transform: translateX(24px);
}

.icon-link {
    color: var(--accent);
    text-decoration: none;
    font-size: 18px;
    margin-right: 0.75rem;
}

.icon-link:hover {
    color: var(--accent-strong);
}

.icon-link.delete-link {
    color: #c0392b;
}

.icon-link.delete-link:hover {
    color: #941f1f;
}

.error {
    background: var(--error-bg);
    color: var(--error-text);
    padding: 10px 12px;
    border-radius: 10px;
    margin-bottom: 12px;
}

.success {
    background: var(--success-bg);
    color: var(--success-text);
    padding: 10px 12px;
    border-radius: 10px;
    margin-bottom: 12px;
}

table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
}

th,
td {
    text-align: left;
    padding: 14px 10px;
    border-bottom: 1px solid var(--border);
}

.sortable-header {
    color: var(--muted);
    font-weight: 700;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.sortable-header:hover,
.sortable-header:focus-visible {
    text-decoration: underline;
}

.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 24px;
}

@media (max-width: 900px) {
    .card {
        width: 92vw;
        margin: 32px auto;
    }
}

.filter-panel {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 18px;
    margin-bottom: 22px;
    transition: background 0.25s ease, border-color 0.25s ease;
}

.filter-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    margin-bottom: 16px;
}

.filter-panel-header h2 {
    margin: 0;
    font-size: 1.05rem;
    color: var(--text);
}

.filter-panel-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.filter-toggle-icon {
    display: inline-block;
    margin-right: 6px;
    transition: transform 0.25s ease;
}

.filter-panel.collapsed .filter-toggle-icon {
    transform: rotate(-90deg);
}

.filter-form {
    margin: 0;
}

.filter-form form {
    display: grid;
    grid-template-columns: repeat(4, minmax(220px, 1fr));
    gap: 18px;
    align-items: start;
    grid-auto-flow: dense;
}

.filter-group {
    display: grid;
    gap: 8px;
}

.filter-group label {
    color: var(--muted);
    font-size: 0.95rem;
    font-weight: 600;
}

.filter-group.filter-checkbox {
    display: grid;
    gap: 10px;
    margin-top: 8px;
}

.filter-group.filter-checkbox label {
    margin: 0;
}

.filter-group.filter-checkbox input {
    width: auto;
    margin: 0;
    margin-top: 6px;
}

.filter-group.filter-search {
    grid-column: span 3;
}

.filter-actions {
    grid-column: 2 / 5;
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

@media (max-width: 1000px) {
    .filter-form form {
        grid-template-columns: repeat(2, minmax(220px, 1fr));
    }
    .filter-group.filter-search,
    .filter-actions {
        grid-column: span 2;
    }
    .filter-group.filter-checkbox {
        grid-column: span 2;
    }
}

@media (max-width: 720px) {
    .filter-form form {
        grid-template-columns: 1fr;
    }
    .filter-actions {
        justify-content: flex-start;
    }
    .filter-group.filter-search,
    .filter-actions,
    .filter-group.filter-checkbox {
        grid-column: auto;
    }
}

.filter-form input,
.filter-form select {
    margin-top: 0;
}

.filter-actions {
    grid-column: 1 / -1;
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

.filter-panel.collapsed .filter-form {
    display: none;
}

.filter-panel.collapsed .filter-panel-header h2::after {
    content: ' (hidden)';
    color: var(--muted);
    font-weight: 400;
    font-size: 0.95rem;
}

.table-actions {
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    margin-bottom: 24px;
}

.dashboard-header a.button {
    margin-left: 0;
}

.detail-card {
    padding: 24px;
    background: var(--surface);
    border: 1px solid var(--border);
}

.detail-header {
    display: flex;
    justify-content: space-between;
    gap: 18px;
    align-items: flex-start;
    margin-bottom: 22px;
}

.detail-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.detail-cover img {
    width: 100%;
    border-radius: 16px;
    object-fit: cover;
    max-height: 360px;
}

.detail-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
    margin-top: 20px;
}

.detail-card {
    background: var(--surface);
}

.detail-card-item {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 18px;
}

.detail-card-item h2 {
    margin: 0 0 10px;
    font-size: 1rem;
    color: var(--text);
}

.detail-card-item p {
    color: var(--text);
}

.subtext {
    color: var(--muted);
    margin-top: 4px;
}

.info-box {
    margin-top: 24px;
    padding: 14px 16px;
    background: var(--info-bg);
    border: 1px solid var(--info-border);
    border-radius: 14px;
    color: var(--info-text);
}

@media (max-width: 720px) {
    .filter-form form {
        grid-template-columns: 1fr;
    }

    .filter-actions {
        justify-content: flex-start;
    }
    .dashboard-header {
        flex-direction: column;
        align-items: stretch;
    }
    .detail-header {
        flex-direction: column;
        align-items: stretch;
    }
    .detail-grid {
        grid-template-columns: 1fr;
    }
}

.add-links {
    margin-top: 18px;
    display: grid;
    gap: 8px;
}

.add-links p {
    margin: 0;
}

.add-links a {
    color: var(--accent);
    text-decoration: none;
    font-weight: 600;
}

.add-links a:hover {
    text-decoration: underline;
}

.speedrun-cell {
    text-align: center;
}

.speedrun-yes,
.speedrun-no {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 26px;
    min-height: 26px;
    border-radius: 999px;
    font-weight: 700;
    padding: 0 8px;
}

.speedrun-yes {
    background: var(--success-bg);
    color: var(--success-text);
}

.speedrun-no {
    background: var(--panel);
    color: var(--muted);
    border: 1px solid var(--border);
}
