@import url("https://fonts.googleapis.com/css2?family=Momo+Trust+Display&family=VT323&display=swap");

/*
 * TAMS application styles.
 *
 * Every class used by `index.html`, `static/dashboard.html` and the dashboard
 * module is defined here. The colour palette is driven by CSS custom
 * properties so the dark theme only has to override a handful of values.
 */

/* --- Design tokens --------------------------------------------------------- */

:root {
    /* Catppuccin Latte (Light) */
    --bg: #eff1f5;
    --bg-secondary: #ffffff; /* Pure white cards for contrast */
    --surface: #e6e9ef;
    --text: #4c4f69;
    --text-muted: #6c6f85;
    --border: #ccd0da;
    --accent: #8839ef;
    --header-gradient: linear-gradient(135deg, #dd7878 0%, #04a5e5 100%);

    /* Missing Variables */
    --font: "Momo Trust Display", sans-serif;
    --primary: var(--accent);
    --primary-hover: #7225d9;
    --primary-contrast: #ffffff;
    --surface-alt: #e6e9ef;
    --success: #40a02b;
    --danger-text: #d20f39;
    --danger-bg: #fce8ea;
    --danger-border: #f38ba8;

    /* Spacing */
    --space-1: 0.25rem;
    --space-2: 0.5rem;
    --space-3: 0.75rem;
    --space-4: 1rem;
    --space-5: 1.5rem;
    --space-6: 2rem;

    /* Borders & Shadows */
    --radius-sm: 4px;
    --radius: 8px;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

[data-theme="dark"] {
    /* Catppuccin Mocha (Dark) */
    --bg: #1e1e2e;
    --bg-secondary: #181825;
    --surface: #313244;
    --text: #cdd6f4;
    --text-muted: #a6adc8;
    --border: #45475a;
    --accent: #cba6f7;
    --header-gradient: linear-gradient(135deg, #f38ba8 0%, #89b4fa 100%);

    --primary-hover: #b48be6;
    --surface-alt: #313244;
    --success: #a6e3a1;
    --danger-text: #f38ba8;
    --danger-bg: #302d41;
    --danger-border: #f38ba8;
}

/* --- Base ------------------------------------------------------------------ */

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

html,
body {
    padding: 0;
    margin: 0;
}

body {
    background-color: var(--bg);
    color: var(--text);
    transition:
        background-color 0.3s,
        color 0.3s;
    font-family: var(--font);
    font-size: 16px;
    line-height: 1.5;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3,
h4 {
    margin: 0 0 var(--space-2);
    line-height: 1.25;
}

h1 {
    font-size: 1.75rem;
}

h2 {
    font-size: 1.35rem;
}

h3 {
    font-size: 1.1rem;
}

p {
    margin: 0 0 var(--space-3);
}

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

/* Visibility helper used by the screen manager and the offline banner. */
.hidden {
    display: none !important;
}

/* Screen-reader only text (the custom checkbox). */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* --- Offline banner -------------------------------------------------------- */

.offline-banner {
    background: #fff3cd;
    color: #664d03;
    border-bottom: 1px solid #ffe08a;
    padding: var(--space-2) var(--space-4);
    text-align: center;
    font-size: 0.9rem;
    font-weight: 500;
}

@media (prefers-color-scheme: dark) {
    .offline-banner {
        background: #4a3c10;
        color: #ffe6a3;
        border-bottom-color: #6b561a;
    }
}

/* --- Loading overlay ------------------------------------------------------- */

#loading-overlay {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.85);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    font-family: var(--font);
    font-size: 1.2rem;
}

@media (prefers-color-scheme: dark) {
    #loading-overlay {
        background: rgba(16, 19, 28, 0.85);
    }
}

.loading-container {
    text-align: center;
}

.spinner {
    border: 4px solid var(--surface-alt);
    border-top: 4px solid var(--primary);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 0 auto var(--space-3);
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}

@media (prefers-reduced-motion: reduce) {
    .spinner {
        animation-duration: 3s;
    }
}

/* --- Layout ---------------------------------------------------------------- */

#app {
    max-width: 960px;
    margin: 0 auto;
    padding: var(--space-5) var(--space-4) var(--space-6);
}

.screen {
    display: block;
    animation: fade-in 160ms ease-out;
}

@keyframes fade-in {
    from {
        opacity: 0;
        transform: translateY(4px);
    }
    to {
        opacity: 1;
        transform: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    .screen {
        animation: none;
    }
}

.app-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    margin-bottom: var(--space-5);
    padding-bottom: var(--space-3);
    border-bottom: 1px solid var(--border);
}

.app-header h4 {
    margin: 0;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-muted);
}

.list {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    background-color: var(--bg-secondary);
    color: var(--text);
}

/* --- Cards ----------------------------------------------------------------- */

.card {
    background: var(--bg-secondary, var(--surface));
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: var(--space-5);
    margin-bottom: var(--space-4);
}

.card > :last-child {
    margin-bottom: 0;
}

.subtitle {
    color: var(--text-muted);
    margin: 0 0 var(--space-4);
    font-size: 0.95rem;
}

/* --- Forms ----------------------------------------------------------------- */

.form-group {
    margin-bottom: var(--space-4);
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.form-group label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
    letter-spacing: 0.01em;
}

input[type="text"],
input[type="password"],
input[type="number"],
textarea,
.form-input {
    width: 100%;
    padding: 0.65rem 0.8rem;
    font: inherit;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    transition:
        border-color 120ms ease,
        box-shadow 120ms ease;
}

textarea,
.form-input {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.85rem;
    line-height: 1.5;
    resize: vertical;
}

input:focus,
textarea:focus,
.form-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(47, 109, 246, 0.18);
}

input[type="number"] {
    max-width: 220px;
}

/* --- Buttons --------------------------------------------------------------- */

.btn-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    width: 100%;
    padding: 0.7rem 1.1rem;
    font: inherit;
    font-weight: 600;
    color: var(--primary-contrast);
    background: var(--primary);
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition:
        background 120ms ease,
        transform 80ms ease;
}

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

.btn-primary:active {
    transform: translateY(1px);
}

.btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-text {
    padding: 0.4rem 0.6rem;
    font: inherit;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--primary);
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
}

.btn-text:hover {
    background: var(--surface-alt);
}

/* --- Custom checkbox ------------------------------------------------------- */

.custom-checkbox-wrapper {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    margin-bottom: var(--space-4);
    font-size: 0.9rem;
    color: var(--text-muted);
    cursor: pointer;
    user-select: none;
}

.custom-checkbox {
    width: 18px;
    height: 18px;
    flex: 0 0 18px;
    border: 1px solid var(--border);
    border-radius: 5px;
    background: var(--surface);
    position: relative;
    transition:
        background 120ms ease,
        border-color 120ms ease;
}

.sr-only:checked + .custom-checkbox {
    background: var(--primary);
    border-color: var(--primary);
}

.sr-only:checked + .custom-checkbox::after {
    content: "";
    position: absolute;
    left: 5px;
    top: 1px;
    width: 5px;
    height: 10px;
    border: solid var(--primary-contrast);
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.sr-only:focus-visible + .custom-checkbox {
    box-shadow: 0 0 0 3px rgba(47, 109, 246, 0.3);
}

/* --- Schedule -------------------------------------------------------------- */

.block-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: var(--space-4);
}

.block-info h4 {
    margin: 0 0 var(--space-1);
    font-size: 1.05rem;
}

.block-info p {
    margin: 0;
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* --- Recommendation -------------------------------------------------------- */

.recommendation-box {
    background: var(--surface-alt);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: var(--space-4);
    margin-bottom: var(--space-4);
    text-align: center;
}

.recommendation-box p {
    margin: 0 0 var(--space-1);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
}

.recommendation-box h3 {
    margin: 0;
    color: var(--primary);
}

/* --- Flashcards -------------------------------------------------------------- */

.flashcard-deck {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
}

.flashcard {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--space-3);
    min-height: 200px;
    padding: var(--space-5);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface-alt);
    box-shadow: var(--shadow-sm);
    text-align: center;
    cursor: pointer;
    user-select: none;
    transition:
        transform 160ms ease,
        border-color 160ms ease;
}

.flashcard:hover {
    transform: translateY(-2px);
    border-color: var(--primary);
}

.flashcard:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 3px;
}

.flashcard-face {
    margin: 0;
    font-size: 1.15rem;
    line-height: 1.45;
}

.flashcard-back {
    display: none;
    color: var(--text);
}

.flashcard[data-flipped="true"] .flashcard-front {
    display: none;
}

.flashcard[data-flipped="true"] .flashcard-back {
    display: block;
}

.flashcard-hint {
    margin: 0;
    font-size: 0.85rem;
    color: var(--text-muted);
    white-space: pre-line;
}

.flashcard-actions {
    display: flex;
    justify-content: center;
    gap: var(--space-3);
    margin-top: var(--space-4);
}

.flashcard-actions .btn-text,
.flashcard-actions .btn-primary {
    width: auto;
    padding: 10px 22px;
}

/* --- SQ3R -------------------------------------------------------------------- */

.sq3r-progress {
    margin-bottom: var(--space-4);
}

.sq3r-progress-bar {
    height: 8px;
    border-radius: 999px;
    background: var(--surface-alt);
    border: 1px solid var(--border);
    overflow: hidden;
}

.sq3r-progress-fill {
    display: block;
    height: 100%;
    width: 0;
    background: var(--primary);
    transition: width 200ms ease;
}

.sq3r-phases {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
    list-style: none;
    margin: 0;
    padding: 0;
}

.sq3r-phase {
    flex: 1 1 150px;
}

.sq3r-phase-button {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface-alt);
    color: var(--text);
    font: inherit;
    text-align: left;
    cursor: pointer;
    transition:
        border-color 160ms ease,
        background-color 160ms ease;
}

.sq3r-phase-button:hover {
    border-color: var(--primary);
}

.sq3r-phase[data-state="current"] .sq3r-phase-button {
    border-color: var(--primary);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
}

.sq3r-phase[data-state="done"] .sq3r-phase-marker {
    background: var(--success);
    color: var(--primary-contrast);
}

.sq3r-phase[data-state="current"] .sq3r-phase-marker {
    background: var(--primary);
    color: var(--primary-contrast);
}

.sq3r-phase-marker {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    flex: 0 0 24px;
    border-radius: 50%;
    background: var(--border);
    color: var(--text);
    font-size: 0.8rem;
    font-weight: 600;
}

.sq3r-phase-title {
    flex: 1 1 auto;
    font-weight: 500;
}

.sq3r-phase-count {
    font-size: 0.8rem;
    color: var(--text-muted);
    white-space: nowrap;
}

.sq3r-step-title {
    margin: 0 0 var(--space-2);
    font-size: 1.25rem;
}

.sq3r-subtitle-heading {
    margin: var(--space-4) 0 var(--space-2);
    font-size: 1rem;
    color: var(--primary);
}

.sq3r-lead {
    margin: 0 0 var(--space-3);
    font-size: 1.05rem;
}

.sq3r-facts {
    margin: 0 0 var(--space-3);
    font-size: 0.85rem;
    color: var(--text-muted);
}

.sq3r-tiers,
.sq3r-outline,
.sq3r-media,
.sq3r-graph,
.sq3r-hints {
    margin: 0 0 var(--space-3);
    padding-left: 1.2rem;
}

.sq3r-tier,
.sq3r-outline-item,
.sq3r-media-item,
.sq3r-graph-node {
    margin-bottom: var(--space-2);
}

.sq3r-reminder {
    margin: 0 0 var(--space-4);
    padding: var(--space-3) var(--space-4);
    border-left: 3px solid var(--primary);
    border-radius: var(--radius-sm);
    background: var(--surface-alt);
}

.sq3r-question-box,
.sq3r-quiz {
    padding: var(--space-4);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface-alt);
    margin-bottom: var(--space-4);
}

.sq3r-question-prompt {
    margin: 0 0 var(--space-3);
    font-size: 1.1rem;
    font-weight: 500;
}

.sq3r-label {
    display: block;
    margin-bottom: var(--space-1);
    font-size: 0.85rem;
    color: var(--text-muted);
}

.sq3r-textarea {
    width: 100%;
    min-height: 80px;
    resize: vertical;
}

.sq3r-markdown {
    margin-bottom: var(--space-4);
}

.sq3r-markdown > :last-child {
    margin-bottom: 0;
}

.sq3r-recite-list {
    list-style: none;
    margin: 0 0 var(--space-4);
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
}

.sq3r-recite-card {
    padding: var(--space-4);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface-alt);
    cursor: pointer;
}

.sq3r-recite-back {
    display: none;
    margin: 0 0 var(--space-2);
}

.sq3r-recite-card[data-flipped="true"] .sq3r-recite-front {
    display: none;
}

.sq3r-recite-card[data-flipped="true"] .sq3r-recite-back {
    display: block;
}

.sq3r-recite-hint {
    margin: 0;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.sq3r-recite-card[data-flipped="true"] .sq3r-recite-hint {
    display: none;
}

.sq3r-quiz-counter {
    margin: 0 0 var(--space-2);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
}

.sq3r-quiz-answer {
    margin-bottom: var(--space-4);
    padding: var(--space-3);
    border-radius: var(--radius-sm);
    background: var(--surface);
    border: 1px solid var(--border);
}

.sq3r-quiz-answer[data-revealed="false"] {
    display: none;
}

.sq3r-actions {
    display: flex;
    justify-content: flex-end;
    gap: var(--space-3);
    margin-top: var(--space-4);
}

.sq3r-actions .btn-primary,
.sq3r-quiz .btn-primary,
.sq3r-quiz .btn-text {
    width: auto;
    padding: 10px 22px;
}

/* --- Notes editor ------------------------------------------------------------ */

.notes-editor-wrap {
    display: block;
}

.notes-editor {
    min-height: 120px;
    padding: var(--space-3);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    font: inherit;
    line-height: 1.5;
}

.notes-editor:focus-within {
    border-color: var(--primary);
    outline: none;
    box-shadow: var(--shadow-sm);
}

.notes-editor p {
    margin: 0 0 var(--space-2);
}

.notes-editor p:last-child {
    margin-bottom: 0;
}

/* --- Stats ----------------------------------------------------------------- */

.stats-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.92rem;
}

.stats-table th,
.stats-table td {
    text-align: left;
    padding: var(--space-2) var(--space-3);
    border-bottom: 1px solid var(--border);
}

.stats-table th {
    color: var(--text-muted);
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

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

/* --- Calendar -------------------------------------------------------------- */

.markdown-it-calendar {
    overflow-x: auto;
}

.markdown-it-calendar table.calendar {
    width: 100%;
    border-collapse: collapse;
}

.markdown-it-calendar .calendar-cell {
    vertical-align: top;
    height: 90px;
    border: 1px solid var(--border);
    padding: var(--space-2);
}

.markdown-it-calendar .calendar-cell-date {
    margin: 0 0 var(--space-1);
    font-weight: 600;
    color: var(--text-muted);
}

.markdown-it-calendar .calendar-cell-title {
    font-weight: 600;
    font-size: 0.85rem;
}

.markdown-it-calendar .calendar-content-tag {
    font-size: 0.8rem;
    margin-top: var(--space-1);
}

.markdown-it-calendar .calendar-content-tag-hover,
.markdown-it-calendar .calendar-overview {
    display: none;
}

.markdown-it-calendar .calendar-time {
    text-align: left;
    font-weight: 600;
    padding: var(--space-2);
}

/* --- Lockout --------------------------------------------------------------- */

#lockout-screen {
    text-align: center;
    padding: var(--space-6);
    color: var(--danger-text);
    background: var(--danger-bg);
    border: 1px solid var(--danger-border);
    border-radius: var(--radius);
}

/* --- Responsive ------------------------------------------------------------ */

@media (max-width: 640px) {
    #app {
        padding: var(--space-4) var(--space-3) var(--space-5);
    }

    .card {
        padding: var(--space-4);
    }

    .app-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .block-item {
        flex-direction: column;
        align-items: stretch;
    }

    .block-item .btn-primary {
        width: 100%;
    }

    .stats-table {
        font-size: 0.85rem;
    }
}

.modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}
.modal.hidden {
    display: none;
}
.modal-content {
    background-color: var(--bg-secondary);
    color: var(--text);
    border: 1px solid var(--border);
    padding: 24px;
    border-radius: 8px;
    max-width: 400px;
    margin: 16px;
}
.modal-content h2 {
    margin-top: 0;
    color: var(--text, #e5e7eb);
}
.modal-content p {
    margin: 8px 0;
    color: var(--text, #e5e7eb);
}
.modal-content button {
    margin-top: 16px;
}

#due-section {
    margin-bottom: 24px;
    padding: 16px;
    border: 1px solid var(--border, #374151);
    border-radius: 8px;
    background: var(--bg-secondary, var(--bg, #1f2937));
}
#due-section h3 {
    margin: 0 0 12px 0;
    font-size: 16px;
    color: var(--text, #e5e7eb);
}
.due-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid var(--border, #374151);
}
.due-item:last-child {
    border-bottom: none;
}
.due-info h4 {
    margin: 0;
    font-size: 14px;
    color: var(--text, #e5e7eb);
}
.due-info p {
    margin: 4px 0 0 0;
    font-size: 12px;
    color: var(--text-muted, #9ca3af);
}

/* --- TAMS Header (Figma Match) --- */
.tams-header {
    position: relative;
    margin: -20px -20px 20px -20px; /* Assumes dashboard has padding, adjust if needed */
    border-bottom-left-radius: 20px;
    border-bottom-right-radius: 20px;
    overflow: hidden;
    color: #fff;
    font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
}
.tams-header-bg {
    position: absolute;
    inset: 0;
    background: var(--header-gradient);
    z-index: 1;
}
.tams-header-content {
    position: relative;
    z-index: 2;
    padding: 20px 30px 10px 30px;
}
.tams-topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.tams-logo-area {
    display: flex;
    align-items: center;
    gap: 20px;
}
.tam-reading {
    height: 96px;
    width: auto;
    image-rendering: pixelated;
}
.tams-logo {
    height: 80px;
    width: auto;
    image-rendering: pixelated;
}

.stat-pill {
    background: rgba(255, 255, 255, 0.4);
    border: 2px solid #fff;
    border-radius: 20px;
    padding: 4px 12px;
    display: flex;
    align-items: center;
    gap: 6px;
    color: #11111b;
    font-weight: bold;
    font-size: 14px;
}
.stat-icon {
    height: 24px;
    width: auto;
    image-rendering: pixelated;
}
.btn-icon {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
}
.btn-icon img {
    height: 36px;
    width: auto;
    image-rendering: pixelated;
}

.tams-greeting {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 10px;
}
.greeting-icons {
    display: flex;
    gap: 16px;
}
.greeting-icon-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    color: #11111b;
    font-size: 12px;
    font-weight: bold;
    text-align: center;
}
.greeting-icon-item img {
    height: 48px;
    margin-bottom: 8px;
    image-rendering: pixelated;
    filter: drop-shadow(1px 1px 0px rgba(255, 255, 255, 0.5));
}
.greeting-center {
    text-align: center;
    color: #2a4365;
}
.greeting-center h2 {
    margin: 0 0 10px 0;
    font-size: 24px;
    font-weight: 800;
    color: #11111b;
}
.btn-start-session {
    background: #a8957a;
    color: white;
    border: 2px solid #fff;
    border-radius: 20px;
    padding: 10px 30px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}
.greeting-character {
    position: relative;
}
.greeting-character img {
    height: 180px;
    width: auto;
    image-rendering: pixelated;
}
.level-badge {
    position: absolute;
    bottom: 0;
    right: 0;
    background: #ffd700;
    color: #333;
    border: 3px solid #fff;
    border-radius: 12px;
    padding: 4px 10px;
    font-size: 14px;
    font-weight: bold;
}

.tams-xp-bar-container {
    margin-top: 15px;
    background: rgba(255, 255, 255, 0.3);
    height: 16px;
    border-radius: 8px;
    position: relative;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.5);
}
.tams-xp-bar-fill {
    height: 100%;
    background: #2b6cb0;
    width: 0%;
    transition: width 0.5s ease;
}
.tams-xp-text {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: bold;
    color: #fff;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
    z-index: 3;
}

.tams-greeting h2,
.greeting-icon-item span {
    color: #2a4365;
}

#due-block {
    margin-bottom: 12px;
}
#upcoming-block {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px dashed var(--border, #374151);
}
#upcoming-block.hidden {
    display: none;
}
#due-block.hidden {
    display: none;
}
.upcoming-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0;
    opacity: 0.75;
}
.upcoming-item .due-info h4 {
    font-weight: 500;
    font-size: 13px;
}

/* --- Theme Overrides (Force) --------------------------------------------------- */

body,
#app,
.screen {
    background-color: var(--bg) !important;
    color: var(--text) !important;
}

.list .block-item,
#schedule-list .block-item {
    background-color: var(--bg-secondary) !important;
    color: var(--text) !important;
    border: 1px solid var(--border) !important;
}

.stats-table,
.modal-content {
    background-color: var(--bg-secondary) !important;
    color: var(--text) !important;
    border: 1px solid var(--border) !important;
}

.stats-table td,
.stats-table th {
    color: var(--text) !important;
    border-bottom: 1px solid var(--border) !important;
}

/* Ensure buttons look good */
.btn-primary {
    background-color: var(--accent) !important;
    color: #fff !important;
    border: none;
}
h1,
h2,
h3,
h4,
h5,
h6,
p,
span,
div {
    color: inherit;
}

/* Ensure the outer HTML page changes color, not just the app container */
html {
    background-color: var(--bg) !important;
}

/* Header text must be dark because the Catppuccin gradients are bright */
.greeting-center h2,
.greeting-icon-item span {
    color: #11111b !important;
}

.tams-header .stat-pill {
    color: #11111b !important;
    background: rgba(255, 255, 255, 0.7) !important;
}

/* Force parent to align items horizontally */
.tams-stats-area {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    gap: 12px !important;
}

/* The unified cream pill container */
.stats-container {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    background-color: #fdf6e3 !important; /* Cream background */
    border: 2px solid #b8a88a !important; /* Brown border */
    border-radius: 12px !important;
    padding: 6px 16px !important;
    gap: 16px !important;
}

/* Individual stat column (Coins / Canes) */
.stat-item {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    line-height: 1.2 !important;
}

/* The vertical line between Coins and Canes */
.stat-divider {
    width: 2px !important;
    height: 32px !important;
    background-color: #b8a88a !important; /* Brown divider */
    border-radius: 2px !important;
}

/* --- Figma Layout & Typography --- */
/* Base body font */
body {
    font-family: "Momo Trust Display", sans-serif !important;
    font-size: 16px;
    letter-spacing: normal;
}

/* UI Elements, Headers, and Buttons use the Pixel font */
h1,
h2,
h3,
h4,
h5,
h6,
button,
.btn-primary,
.btn-text,
.btn-start-session,
.stat-label,
.stat-value,
.task-manager-header h3,
.progress-widget h4,
.keep-going,
.greeting-icon-item span {
    font-family: "VT323", monospace !important;
    letter-spacing: 0.5px;
}

/* Base font size for VT323 needs to be slightly larger to be readable */
h2 {
    font-size: 2.2rem;
}
h3 {
    font-size: 1.8rem;
}

/* Split Layout */
.dashboard-body {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 20px;
    margin-top: 20px;
    align-items: start;
}

@media (max-width: 768px) {
    .dashboard-body {
        grid-template-columns: 1fr; /* Stack on mobile */
    }
}

.left-panel {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Right Panel (Task Manager) */
.right-panel {
    background-color: #fdf6e3; /* Figma cream color */
    border: 1px solid #d3c6aa;
    border-radius: 8px;
    padding: 20px;
    color: #4c4f69;
    display: flex;
    flex-direction: column;
    height: 100%;
}

[data-theme="dark"] .right-panel {
    background-color: #1e1e2e;
    border-color: #45475a;
    color: #cdd6f4;
}

.task-manager-header h3 {
    margin: 0;
}
.task-manager-header p {
    margin: 0 0 20px 0;
    font-size: 1rem;
    color: #6c6f85;
}

/* Progress Widget */
.progress-widget {
    border: 2px solid #d3c6aa;
    border-radius: 8px;
    padding: 16px;
    text-align: center;
    background: #fdf6e3;
}
[data-theme="dark"] .progress-widget {
    border-color: #45475a;
    background: #181825;
}

.progress-widget h4 {
    margin: 0 0 15px 0;
    font-size: 1.4rem;
}

.circular-progress {
    position: relative;
    width: 120px;
    height: 120px;
    margin: 0 auto;
    border-radius: 50%;
    background: conic-gradient(#a6e3a1 0%, #cdd6f4 0%); /* Default */
    display: flex;
    align-items: center;
    justify-content: center;
}

.circular-progress::before {
    content: "";
    position: absolute;
    inset: 10px;
    background: #fdf6e3;
    border-radius: 50%;
}
[data-theme="dark"] .circular-progress::before {
    background: #181825;
}

#progress-text {
    position: relative;
    z-index: 2;
    font-size: 2rem;
    font-weight: bold;
    color: #4c4f69;
}
[data-theme="dark"] #progress-text {
    color: #cdd6f4;
}

.keep-going {
    margin-top: 15px;
    font-weight: bold;
    font-size: 1.2rem;
}

.mascot-container {
    margin-top: auto;
    position: relative;
    display: flex;
    justify-content: flex-end;
    align-items: flex-end;
    padding-top: 40px; /* Space for the speech bubble */
    min-height: 200px;
}

.mascot-img {
    height: 140px;
    width: auto;
    image-rendering: pixelated;
    position: relative;
    z-index: 2;
}

.speech-bubble-img {
    position: absolute;
    bottom: 130px; /* Adjust this so the tail of the bubble points to the head */
    right: 40px;
    max-width: 120px;
    height: auto;
    image-rendering: pixelated;
    z-index: 1;
}

/* --- Header Overrides (Figma Match) --- */
.stat-pill {
    background: #fdf6e3 !important;
    border: 2px solid #b8a88a !important;
    border-radius: 12px !important;
    padding: 4px 12px !important;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    line-height: 1;
}

.stat-label {
    font-size: 0.7rem;
    color: #8c7b62;
    text-transform: uppercase;
    margin-bottom: 2px;
}

.stat-value {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 1.4rem;
    font-weight: bold;
    color: #4c4f69;
}

.btn-start-session {
    background: #a68a64 !important; /* Brown from Figma */
    color: #fff !important;
    border: 2px solid #fdf6e3 !important;
    border-radius: 20px !important;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-size: 1.4rem; /* Pixel fonts need to be a bit larger */
}

.tams-xp-bar-container {
    background: #a6e3a1 !important; /* Green hill base */
    border: none !important;
}
.tams-xp-bar-fill {
    background: #40a02b !important; /* Darker green */
}

/* Content text balancing */
.block-info h4,
.due-info h4 {
    font-family: "Momo Trust Display", sans-serif !important;
    font-size: 1.1rem;
    font-weight: 600;
    letter-spacing: normal;
}

.block-info p,
.due-info p,
.stats-table {
    font-family: "Momo Trust Display", sans-serif !important;
    font-size: 0.9rem;
    letter-spacing: normal;
}

/* --- Cloze Deletion --- */
.cloze-card {
    padding: var(--space-4);
}
.cloze-sentence {
    font-family: "Momo Trust Display", sans-serif !important;
    font-size: 1.3rem;
    line-height: 2;
    margin-bottom: var(--space-5);
    color: var(--text);
}
.cloze-input {
    display: inline-block;
    width: 120px;
    margin: 0 4px;
    padding: 4px 8px;
    font-family: inherit;
    font-size: 1.2rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 4px;
    text-align: center;
    transition: all 0.2s ease;
}
.cloze-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(136, 57, 239, 0.3);
}
.cloze-input.correct {
    background-color: rgba(64, 160, 43, 0.2);
    border-color: #40a02b;
    color: #40a02b;
    font-weight: bold;
}
.cloze-input.incorrect {
    background-color: rgba(210, 15, 57, 0.1);
    border-color: #d20f39;
    color: #d20f39;
    animation: shake 0.3s;
}
@keyframes shake {
    0%,
    100% {
        transform: translateX(0);
    }
    25% {
        transform: translateX(-4px);
    }
    75% {
        transform: translateX(4px);
    }
}
.cloze-actions {
    display: flex;
    justify-content: center;
    margin-top: var(--space-4);
}
#cloze-feedback {
    margin-top: var(--space-4);
    text-align: center;
}
#cloze-feedback .btn-primary {
    width: auto;
    margin-top: var(--space-3);
}

[data-theme="dark"] .cloze-input.correct {
    color: #a6e3a1;
}
[data-theme="dark"] .cloze-input.incorrect {
    color: #f38ba8;
}
