:root {
    --color-page: oklch(96.8% 0.006 250);
    --color-surface: oklch(99% 0.004 250);
    --color-surface-muted: oklch(94.5% 0.014 242);
    --color-border: oklch(88.5% 0.018 246);
    --color-text: oklch(28% 0.018 248);
    --color-heading: oklch(24% 0.02 248);
    --color-on-dark: oklch(98.5% 0.006 250);
    --color-sidebar: oklch(25% 0.025 252);
    --color-sidebar-hover: oklch(100% 0 0 / 0.12);
    --color-primary: oklch(50% 0.16 258);
    --color-primary-soft: oklch(72% 0.1 258);
    --color-danger: oklch(55% 0.18 28);
    --color-success: oklch(48% 0.13 145);
    --color-warning: oklch(70% 0.13 85);
    --radius-sm: 6px;
    --radius-md: 8px;
    --shadow-card: 0 12px 28px oklch(28% 0.018 248 / 0.08);
    --shadow-panel: 8px 0 24px oklch(20% 0.025 248 / 0.16);
    --space-1: 0.25rem;
    --space-2: 0.5rem;
    --space-3: 0.75rem;
    --space-4: 1rem;
    --space-5: 1.25rem;
    --space-6: 1.5rem;
    --space-page-x: 2rem;
    --space-page-y: 3rem;
}

body {
    background-color: var(--color-page);
    color: var(--color-text);
}

.app-shell {
    display: flex;
    min-height: 100vh;
}

.main-content > .container-fluid {
    max-width: 1200px;
}

h1,
h3,
h4 {
    color: var(--color-heading);
}

h1 {
    margin-bottom: 1.35rem;
    padding: 0;
    font-weight: 750;
    line-height: 1.08;
}
.app-panel,
.lesson-content,
.jumble-content,
.writing-task {
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background: var(--color-surface);
    padding: var(--space-5);
    box-shadow: 0 10px 24px oklch(28% 0.018 248 / 0.05);
}

.narrow-panel {
    max-width: 800px;
    margin: 1.25rem auto;
}

.section-list {
    max-height: 240px;
    overflow-y: auto;
    margin-bottom: var(--space-4);
}

.button-row {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-3);
    align-items: center;
    margin-top: var(--space-4);
}

.source-toggle {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-4);
    margin-bottom: var(--space-4);
}

.action-btn {
    margin: 0 var(--space-1) var(--space-2) 0;
}

.feedback,
.assessment-feedback,
.question-feedback,
.story-text {
    margin-top: var(--space-3);
}

.score,
.timer {
    font-weight: 700;
}

.timer {
    color: var(--color-danger);
}

.hidden-word {
    background-color: var(--color-border);
    color: var(--color-border);
    cursor: pointer;
}

.hidden-word:hover {
    background-color: oklch(84% 0.016 246);
}

.revealed-word {
    background-color: transparent;
    color: var(--color-text);
}

.added {
    text-decoration-line: underline;
    text-decoration-color: oklch(70% 0.01 248);
    text-decoration-style: dashed;
}

.shell-status {
    margin-bottom: var(--space-4);
}

.loading-message {
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background: var(--color-surface-muted);
    color: var(--color-text);
    padding: var(--space-3) var(--space-4);
}
.form-check-inline {
    margin-right: 1rem;
}
.alert {
    margin-top: 1rem;
}
.htmx-indicator {
    display: none;
}
.htmx-request .htmx-indicator {
    display: inline-block;
}
.htmx-request.htmx-indicator {
    display: inline-block;
}
.card {
    border-radius: var(--radius-md);
    border: 1px solid var(--color-border);
    box-shadow: var(--shadow-card);
}
.card-header {
    background-color: var(--color-surface-muted);
    color: var(--color-heading);
    font-weight: 700;
}
.sync_button_container {
    display: flex;
    align-items: baseline;
}

form {
    display: grid;
    justify-content: stretch;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background-color: var(--color-surface);
    padding: 1.25rem 1.5rem;
    box-shadow: 0 10px 24px oklch(28% 0.018 248 / 0.06);
}

button.is-submitting {
    cursor: progress;
    opacity: 0.76;
}
.table {
    font-size: 0.9rem;
}
.table th,
.table td {
    vertical-align: middle;
}

.table-sort-button {
    border: 0;
    background: transparent;
    color: inherit;
    font: inherit;
    font-weight: 700;
    padding: 0;
    text-align: inherit;
}

.table-sort-button:hover,
.table-sort-button:focus {
    color: var(--color-primary);
}

/* Sidebar styling */
.sidebar {
    width: 246px;
    height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1000;
    transition: transform 0.2s ease-in-out;
    background-color: var(--color-sidebar);
    box-shadow: var(--shadow-panel);
}

.sidebar.hidden {
    transform: translateX(-245px);
}

.sidebar-content {
    display: flex;
    flex-direction: column;
    width: 100%;
    min-height: 100vh;
    padding: 1rem 0.75rem;
}

.sidebar-title {
    background: linear-gradient(135deg, var(--color-primary), var(--color-danger));
    border-radius: var(--radius-sm);
    color: var(--color-on-dark);
    font-variant: petite-caps;
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: 0;
    text-align: center;
    margin: 0.25rem 0 1.75rem;
    padding: 0.45rem 0.6rem;
}

.sidebar-link {
    color: oklch(98.5% 0.006 250 / 0.86);
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    width: 100%;
    padding: 0.75rem 0.95rem;
    text-align: left;
    text-decoration: none;
    border-radius: var(--radius-sm);
    transition: background-color 0.2s, color 0.2s;
}

.sidebar-link i {
    margin-right: 8px; /* Space between icon and text */
}

.sidebar-link:hover,
.sidebar-link.active {
    background-color: var(--color-sidebar-hover);
    color: var(--color-on-dark);
}

.sidebar-more-tools {
    margin-top: 1.25rem;
    padding-top: 0.75rem;
    border-top: 1px solid oklch(98.5% 0.006 250 / 0.2);
    color: oklch(98.5% 0.006 250 / 0.86);
}

.arcade-workspace .sidebar-more-tools { order: 2; }

.sidebar-more-tools > summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 44px;
    padding: 0.65rem 0.95rem;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    cursor: pointer;
    list-style: none;
}

.sidebar-more-tools > summary::-webkit-details-marker { display: none; }
.sidebar-more-tools > summary::after { content: '+'; font-size: 1.1rem; }
.sidebar-more-tools[open] > summary::after { content: '−'; }
.sidebar-more-tools > summary:hover { background: var(--color-sidebar-hover); }
.sidebar-more-tools > summary:focus-visible { outline: 2px solid currentColor; outline-offset: 2px; }
.sidebar-more-tools .sidebar-link { font-size: 0.875rem; }

/* New class for icon-only links */
.sidebar-icon-link {
    color: oklch(98.5% 0.006 250 / 0.7);
    align-items: center;
    justify-content: center;
    text-decoration: none;
    font-size: 1.4rem;
    transition: background-color 0.2s;
}

.sidebar-icon-link:hover,
.sidebar-icon-link.active {
    color: var(--color-primary-soft);
}

.sidebar-icon-link i {
    margin: 0; /* No margin since it's icon-only */
}

.navbar-toggler {
    margin: 10px;
}

.sidebar-nodule {
    position: absolute;
    top: 50%;
    right: -15px;
    width: 15px;
    height: 85px;
    background-color: var(--color-sidebar);
    border-radius: 0 10px 10px 0;
    transform: translateY(-50%);
    cursor: pointer;
    z-index: 1001;
}

.sidebar-nodule::after {
    color: var(--color-on-dark);
    font-size: 0.8rem;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.main-content {
    margin-left: 250px;
    padding: var(--space-page-y) var(--space-page-x);
    transition: margin-left 0.2s ease-in-out;
    width: calc(100% - 250px);
    min-height: 100vh;
}

.main-content.full-width {
    margin-left: 5px;
}

@media (max-width: 991.98px) {
    .app-shell {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        height: auto;
        position: relative;
        flex: 0 0 auto;
        transform: translateX(0);
        box-shadow: none;
    }

    .sidebar.hidden {
        transform: translateX(0);
    }

    .sidebar-content {
        min-height: 0;
        padding: 0.75rem;
    }

    .sidebar-title {
        margin: 0.25rem 0 0.75rem;
    }

    .sidebar-pages {
        padding: 0.5rem 0 0;
    }

    .sidebar-link {
        justify-content: flex-start;
    }

    .sidebar-shortcuts,
    .sidebar-stats {
        display: none;
    }

    .main-content {
        margin-left: 0;
        width: 100%;
        padding: 1.25rem;
    }

    .main-content.full-width {
        margin-left: 0;
    }

    .navbar-collapse {
        background-color: var(--color-sidebar);
    }

    .sidebar-nodule {
        display: none;
    }
}

.card.sticky-top {
    top: 20px;
}

.sticky-dashboard {
    top: 1.25rem;
}

.questions-container {
    max-height: 800px;
    overflow-y: auto;
    padding: 10px;
}

.main-content {
    flex-grow: 1;
    transition: margin-left 0.3s ease, margin-right 0.3s ease;
}

.main-content.is-loading {
    opacity: 0.65;
    pointer-events: none;
}

.main-content.left-sidebar-hidden {
    margin-left: 16px;
    width: calc(100% - 16px);
}

.sidebar-pages {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    padding: 7rem 0 7rem;
}

.sidebar-shortcuts {
    display: flex;
    flex-direction: row;
    align-content: space-between;
    flex-wrap: wrap;
    justify-content: space-evenly;
    padding: 0rem 2rem;
}

.visibility-options .form-check {
    display: flex;
    align-items: center;
}
.visibility-options .form-check-input {
    margin-right: 10px;
}
.visibility-options .form-check-label {
    margin: 4px;
}

.form-check {
    padding-left: 1rem;
}

.form-control {
    max-height: 80px;
}

.comprehension-content {
    width: 64%;
}

.comprehension-panel {
    position: sticky;
    top: 1rem;
}

.comprehension-panel form {
    display: block;
    width: 100%;
}

.comprehension-panel .form-control {
    max-height: none;
}

.img-fluid {
    border: 6px solid oklch(22% 0.02 248 / 0.86);
    border-radius: var(--radius-md);
    filter: drop-shadow(4px 3px 3px oklch(55% 0.01 248 / 0.55));
    width: 90%;
}

.audio-player {
    display: flex;
    justify-content: center;
    margin-bottom: 4rem;
}

.story-text-mount {
    overflow-wrap: anywhere;
    max-width: 100%;
}

.story-illustration {
    max-width: 100%;
    height: auto;
}

.qa-heading {
    display: flex;
    justify-content: center;
}

.btn-full {
    width: 100%;
}

.review-cards-btn {
    --bs-btn-bg: var(--color-success);
    --bs-btn-border-color: var(--color-success);
    --bs-btn-hover-bg: oklch(42% 0.13 145);
    --bs-btn-hover-border-color: oklch(42% 0.13 145);
}

.modal-preview-list {
    max-height: 260px;
    overflow: auto;
    padding-inline-start: 1.25rem;
}

.word-modal {
    display: block;
    position: fixed;
    width: min(320px, calc(100vw - 24px));
    max-height: calc(100vh - 24px);
    overflow-y: auto;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: var(--color-surface);
    color: var(--color-text);
    padding: var(--space-3);
    box-shadow: 0 10px 28px oklch(20% 0.025 248 / 0.2);
    font-size: 0.875rem;
    pointer-events: auto;
    opacity: 1;
    z-index: 10000;
}

.word-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-2);
}

.word-modal-row {
    margin: 0 0 var(--space-2);
}
.btn-secondary {
    --bs-btn-bg: var(--color-surface-muted) !important;
    --bs-btn-color: var(--color-text);
}

.word-span:hover {
    color: var(--color-primary);
}

.list-group {
    max-height: 400px;
}

#question-form {
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.2rem;
    padding: 1rem;
}

.sidebar-stats {
    color: var(--color-on-dark);
    margin-top: auto;
    padding: 1.5rem 0 0;
    text-align: center;
}

.buttons-flashcards {
    display: flex;
    gap: 0.75rem;
}

.buttons-flashcards .btn,
.sidebar-link,
.sidebar-icon-link,
.navbar-toggler {
    min-height: 44px;
}

#vocab-table,
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

#vocab-table table,
.table-responsive > .table {
    min-width: 720px;
}

textarea.form-control {
    max-height: none;
}

input.form-control {
    max-height: 80px;
}

.question-card {
    background: var(--color-surface-muted);
    border-radius: var(--radius-md);
    padding: 1rem;
}

.grid-span-all {
    grid-column: 1 / -1;
}

@media (max-width: 575.98px) {
    form {
        padding: 1rem;
    }

    .buttons-flashcards {
        flex-direction: column;
    }

    #question-form {
        grid-template-columns: 1fr;
    }

    .comprehension-panel {
        position: static;
    }

    .main-content {
        padding: 1rem;
    }
}
