:root {
    color-scheme: light;
    --primary: #d1487c;
    --primary-dark: #ab3564;
    --gold: #e8a3b8;
    --gold-text: #5c1f38;
    --bg: #fdf0f2;
    --text: #3a2317;
    --muted: #8a6f68;
    --card-bg: #ffffff;
    --border: #f3d3da;
    --accent: #d1487c;
    --success-bg: #dff5e1;
    --success-text: #1e6b2e;
    --error-bg: #fbe2e2;
    --error-text: #ab3564;
}

@media (prefers-color-scheme: dark) {
    :root {
        color-scheme: dark;
        --primary: #e8749b;
        --primary-dark: #c15b80;
        --gold: #b5677f;
        --gold-text: #2c1017;
        --bg: #1c1315;
        --text: #f3dfe2;
        --muted: #b59698;
        --card-bg: #2b1e21;
        --border: #4a2f36;
        --accent: #f0a0bb;
        --success-bg: #1d3a24;
        --success-text: #93d9a3;
        --error-bg: #452028;
        --error-text: #f0a0bb;
    }
}

* {
    box-sizing: border-box;
}

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

.khmer-script, .romanization {
    font-family: "Noto Sans Khmer", -apple-system, sans-serif;
}

a {
    color: var(--accent);
}

.site-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.75rem;
    padding: 0.75rem 2rem;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    color: var(--text);
}

.site-header .brand {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    color: var(--text);
    text-decoration: none;
    font-weight: 700;
    font-size: 1.2rem;
}

.site-header .brand img {
    height: 56px;
    width: auto;
    border-radius: 8px;
    display: block;
}

.site-header nav {
    display: flex;
    align-items: center;
    gap: 1.25rem;
}

.site-header nav a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
}

.site-header nav a:hover {
    text-decoration: underline;
}

.hero-banner {
    display: flex;
    justify-content: center;
    margin-bottom: 1.5rem;
}

.hero-banner img {
    max-width: 100%;
    width: 420px;
    border-radius: 16px;
    box-shadow: 0 8px 24px rgba(209, 72, 124, 0.25);
}

.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 2rem;
}

.subtitle {
    color: var(--muted);
}

.messages {
    list-style: none;
    padding: 0;
    margin: 0 0 1.5rem;
}

.message {
    padding: 0.75rem 1rem;
    border-radius: 8px;
    margin-bottom: 0.5rem;
}

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

.message.error {
    background: var(--error-bg);
    color: var(--error-text);
}

.category-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.25rem;
    margin: 1.5rem 0;
}

.category-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.5rem;
    text-align: center;
}

.card-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
    margin-top: 1rem;
}

.button {
    display: inline-block;
    padding: 0.6rem 1.2rem;
    border-radius: 8px;
    background: var(--primary);
    color: white;
    text-decoration: none;
    border: none;
    cursor: pointer;
    font-size: 1rem;
}

.button:hover {
    background: var(--primary-dark);
}

.button:disabled {
    opacity: 0.5;
    cursor: default;
}

.button.secondary {
    background: var(--gold);
    color: var(--gold-text);
}

.flashcard-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-top: 2rem;
}

.flashcard {
    width: 320px;
    height: 320px;
    perspective: 1200px;
    cursor: pointer;
}

.flashcard-inner {
    position: relative;
    width: 100%;
    height: 100%;
    transition: transform 0.5s;
    transform-style: preserve-3d;
}

.flashcard.flipped .flashcard-inner {
    transform: rotateY(180deg);
}

.flashcard-face {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    border-radius: 16px;
    background: var(--card-bg);
    border: 2px solid var(--border);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 1rem;
}

.flashcard-back {
    transform: rotateY(180deg);
}

.khmer-script {
    font-size: 5rem;
}

.romanization {
    font-size: 2rem;
    font-weight: 700;
    color: var(--accent);
}

.notes {
    color: var(--muted);
    font-size: 0.9rem;
    padding: 0 1rem;
}

.flashcard-controls {
    display: flex;
    gap: 0.75rem;
    margin-top: 1.5rem;
}

.counter {
    margin-top: 0.5rem;
    color: var(--muted);
}

.quiz-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 2rem;
    text-align: center;
    margin-top: 1.5rem;
}

.quiz-script-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 2rem;
}

.khmer-script.large {
    font-size: 6rem;
}

.quiz-choices {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 0.75rem;
}

.choice-button {
    font-size: 1.2rem;
    padding: 1rem;
}

.quiz-next-row {
    margin-top: 1.5rem;
}

.progress-list {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    margin-top: 1.5rem;
}

.progress-row {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.25rem;
}

.progress-label {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.5rem;
}

.progress-bar {
    background: var(--border);
    border-radius: 999px;
    height: 12px;
    overflow: hidden;
}

.progress-bar-fill {
    background: var(--primary);
    height: 100%;
}

.progress-meta {
    display: flex;
    justify-content: space-between;
    color: var(--muted);
    font-size: 0.85rem;
    margin-top: 0.4rem;
}
