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

:root {
    --bg: #0f0f13;
    --fg: #e8e8f0;
    --accent: #7eb8f7;
    --muted: #555568;
    --surface: #1a1a24;
    --border: #2a2a3a;
}

@media (prefers-color-scheme: light) {
    :root {
        --bg: #f0f0f5;
        --fg: #0f0f1a;
        --accent: #1565c0;
        --muted: #888899;
        --surface: #e0e0ea;
        --border: #c0c0d0;
    }
}

html, body {
    height: 100%;
}

body {
    background-color: var(--bg);
    color: var(--fg);
    font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    display: flex;
    justify-content: center;
}

.container {
    width: 100%;
    max-width: 1000px;
    display: flex;
    flex-direction: column;
}

/* ── Preferences gear button ── */
.prefs-gear {
    position: fixed;
    top: 1rem;
    right: 1rem;
    background: none;
    border: 1px solid transparent;
    border-radius: 6px;
    color: var(--muted);
    cursor: pointer;
    padding: 0.35rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.15s, border-color 0.15s;
    z-index: 100;
}
.prefs-gear:hover,
.prefs-gear[aria-expanded="true"] {
    color: var(--fg);
    border-color: var(--border);
}

/* ── Preferences popup ── */
.prefs-popup {
    position: fixed;
    top: 3.2rem;
    right: 1rem;
    width: 260px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 1rem;
    z-index: 99;
    display: none;
    flex-direction: column;
    gap: 0.75rem;
    box-shadow: 0 8px 24px rgba(0,0,0,0.3);
}
.prefs-popup.open {
    display: flex;
}

.prefs-popup h2 {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted);
    margin-bottom: 0.25rem;
}

.prefs-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.prefs-label {
    font-size: 0.9rem;
    color: var(--fg);
}

.prefs-toggle {
    background: var(--bg);
    color: var(--muted);
    border: 1px solid var(--border);
    border-radius: 5px;
    padding: 0.25em 0.7em;
    font-size: 0.8rem;
    cursor: pointer;
    font-family: inherit;
    transition: color 0.15s, border-color 0.15s;
    white-space: nowrap;
}
.prefs-toggle:hover {
    color: var(--fg);
    border-color: var(--muted);
}
.prefs-toggle.active {
    color: var(--accent);
    border-color: var(--accent);
}

.prefs-radio-group {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    margin-top: 0.1rem;
}
.prefs-radio-group label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    color: var(--fg);
    cursor: pointer;
}
.prefs-radio-group input[type="radio"] {
    accent-color: var(--accent);
    cursor: pointer;
}
