/* ═══════════════════════════════════════════════════════════════════
   base.css — Global PSC Master stylesheet
   Extracted from templates/base.html (Issue 18).
   Served by WhiteNoise with far-future Cache-Control headers so the
   browser re-parses it once per deploy, not on every page load.
═══════════════════════════════════════════════════════════════════ */

/* Google Fonts are loaded via <link rel="preconnect">/<link rel="stylesheet">
   in templates/base.html instead of a render-blocking @import here. */

/* ── Dark theme (default) ── */
:root, [data-theme="dark"] {
    --study-font-scale: 1;
    --bg-color: #121214;
    --card-color: #1a1a22;
    --card-color-alt: #242430;
    --card-color-deep: #16161d;
    --text-color: #f1f5f9;
    --text-muted: #94a3b8;
    --text-subtle: #cbd5e1;
    --text-light: #e2e8f0;
    --primary-color: #a78bfa;
    --primary-hover: #c4b5fd;
    --secondary-color: #2dd4bf;
    --border-color: rgba(255, 255, 255, 0.10);
    --border-subtle: rgba(255, 255, 255, 0.16);
    --tab-inactive-bg: #242430;
    --tab-inactive-text: #94a3b8;
    --ring-track: #242430;
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.35);
    --header-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
    --legend-bg: #1a1a22;
    --chart-grid: rgba(255, 255, 255, 0.05);
    /* inputs & form elements */
    --input-bg: #242430;
    --input-color: #f1f5f9;
    --input-border: rgba(255, 255, 255, 0.14);
    /* option/answer blocks */
    --option-bg: #242430;
    --option-hover: #2e2e3d;
    --option-color: #f1f5f9;
    --answer-reveal-bg: rgba(34, 197, 94, 0.15);
    --answer-section-bg: #20202a;
    --explanation-color: #cbd5e1;
    /* dropdown menu */
    --dropdown-bg: #1a1a22;
    --dropdown-item-color: #f1f5f9;
    --dropdown-item-hover: #242430;
    --dropdown-divider: rgba(255, 255, 255, 0.10);
    --menu-btn-hover: #242430;
    /* modal */
    --modal-bg: #1a1a22;
    /* metadata strip */
    --meta-strip-bg: #16161d;
    --meta-strip-border: rgba(255, 255, 255, 0.08);
    /* misc */
    --divider-color: rgba(255, 255, 255, 0.10);
    --state-new-bg: #1e293b;
    --state-new-color: #38bdf8;
    --undo-btn-bg: #242430;
    --undo-btn-color: #cbd5e1;
    --undo-btn-border: rgba(255, 255, 255, 0.14);
    --bury-btn-bg: rgba(14, 165, 233, 0.15);
    --bury-btn-color: #38bdf8;
    --bury-btn-border: rgba(14, 165, 233, 0.35);
    --topic-toggle-bg: #2e2e3d;
    --topic-label-color: #f1f5f9;
    --order-row-bg: #242430;
    /* errors / destructive */
    --danger-color: #f87171;
    --danger-bg: rgba(239, 68, 68, 0.15);
    --danger-border: rgba(239, 68, 68, 0.4);
    --success-color: #4ade80;
    --warning-color: #fbbf24;
}

/* ── Light theme ── */
[data-theme="light"] {
    --study-font-scale: 1;
    --bg-color: #f8fafc;
    --card-color: #ffffff;
    --card-color-alt: #f1f5f9;
    --card-color-deep: #e2e8f0;
    --text-color: #0f172a;
    --text-muted: #64748b;
    --text-subtle: #475569;
    --text-light: #334155;
    --primary-color: #6d28d9;
    --primary-hover: #5b21b6;
    --secondary-color: #0d9488;
    --border-color: #e2e8f0;
    --border-subtle: #cbd5e1;
    --tab-inactive-bg: #f1f5f9;
    --tab-inactive-text: #64748b;
    --ring-track: #e2e8f0;
    --shadow: 0 4px 16px rgba(15, 23, 42, 0.06);
    --header-shadow: 0 1px 4px rgba(15, 23, 42, 0.08);
    --legend-bg: #ffffff;
    --chart-grid: rgba(0, 0, 0, 0.06);
    /* inputs & form elements */
    --input-bg: #ffffff;
    --input-color: #0f172a;
    --input-border: #cbd5e1;
    /* option/answer blocks */
    --option-bg: #ffffff;
    --option-hover: #f8fafc;
    --option-color: #0f172a;
    --answer-reveal-bg: #f0fdf4;
    --answer-section-bg: #f8fafc;
    --explanation-color: #334155;
    /* dropdown menu */
    --dropdown-bg: #ffffff;
    --dropdown-item-color: #0f172a;
    --dropdown-item-hover: #f1f5f9;
    --dropdown-divider: #e2e8f0;
    --menu-btn-hover: #f1f5f9;
    /* modal */
    --modal-bg: #ffffff;
    /* metadata strip */
    --meta-strip-bg: #f8fafc;
    --meta-strip-border: #e2e8f0;
    /* misc */
    --divider-color: #e2e8f0;
    --state-new-bg: #e0f2fe;
    --state-new-color: #0369a1;
    --undo-btn-bg: #f1f5f9;
    --undo-btn-color: #334155;
    --undo-btn-border: #cbd5e1;
    --bury-btn-bg: #f0f9ff;
    --bury-btn-color: #0284c7;
    --bury-btn-border: #bae6fd;
    --topic-toggle-bg: #e2e8f0;
    --topic-label-color: #0f172a;
    --order-row-bg: #f8fafc;
    /* errors / destructive */
    --danger-color: #dc2626;
    --danger-bg: rgba(220, 38, 38, 0.08);
    --danger-border: rgba(220, 38, 38, 0.35);
    --success-color: #16a34a;
    --warning-color: #d97706;
}

html, body, button, a, input, select, textarea, [role="button"], .exam-option {
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Noto Sans Malayalam', 'Noto Sans', 'AnjaliOldLipi', 'Kartika', 'Rachana', Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Google OAuth entry point shared by login and signup. */
.social-auth-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 18px 0;
    color: var(--text-muted);
    font-size: 0.82rem;
    text-transform: uppercase;
}

.social-auth-divider::before,
.social-auth-divider::after {
    content: "";
    flex: 1;
    height: 1px;
    background: var(--divider-color);
}

.social-auth-form {
    margin: 0;
}

.google-auth-button {
    width: 100%;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 10px 14px;
    border: 1px solid var(--input-border);
    border-radius: 8px;
    background: var(--card-color-alt);
    color: var(--text-color);
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s, border-color 0.2s, transform 0.1s;
}

.google-auth-button:hover {
    background: var(--option-hover);
    border-color: var(--border-subtle);
}

.google-auth-button:focus-visible {
    outline: 3px solid var(--secondary-color);
    outline-offset: 2px;
}

.google-auth-button:active {
    transform: translateY(1px);
}

.google-auth-icon {
    width: 20px;
    height: 20px;
    flex: 0 0 20px;
}

/* ── Header – single row ── */
header {
    background-color: var(--card-color);
    padding: 0 1rem;
    height: 54px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 2px 6px var(--header-shadow);
    position: relative;
    z-index: 100;
}

.header-logo {
    display: flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
}

#study-toolbar-reveal[hidden] {
    display: none;
}

#app-header.session-fullscreen-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    transform: translateY(calc(var(--study-toolbar-offset, 0px) - 100%));
    visibility: hidden;
    transition: none;
}

#app-header.session-fullscreen-header.toolbar-visible {
    visibility: visible;
}

html.study-session-toolbar body {
    /* Reserve room for fixed controls within the viewport, rather than adding
       empty scroll space below a short question. Long content can still grow. */
    box-sizing: border-box;
    padding-top: var(--study-toolbar-offset, 0px);
}

html.study-session-toolbar .exam-topbar,
html.study-session-toolbar .arena-top {
    top: var(--study-toolbar-offset, 0px);
}

html.study-session-toolbar {
    scroll-padding-top: var(--study-toolbar-offset, 0px);
    /* Changing the toolbar space must not anchor the document in the opposite
       direction and feed that synthetic movement back into the toolbar. */
    overflow-anchor: none;
}

.study-toolbar-reveal {
    position: fixed;
    z-index: 101;
    top: 0;
    left: 0;
    width: 1px;
    height: 1px;
    padding: 0;
    border: 0;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}

.study-toolbar-reveal:focus-visible {
    width: auto;
    height: auto;
    min-height: 44px;
    padding: 8px 12px;
    clip-path: none;
    background: var(--card-color);
    color: var(--text-color);
    font: inherit;
    outline: 2px solid var(--primary-color);
    outline-offset: -2px;
}

.study-fullscreen-status {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}

@media (prefers-reduced-motion: reduce) {
    #app-header.session-fullscreen-header { transition: none; }
}

.header-logo h1 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* ── Desktop Primary Navigation (hidden on mobile <768px) ── */
.header-desktop-nav {
    display: none;
    align-items: center;
    gap: 2px;
    margin: 0 12px;
}

@media (min-width: 768px) {
    .header-desktop-nav {
        display: flex;
    }
}

.desktop-nav-link {
    display: inline-flex;
    align-items: center;
    padding: 7px 12px;
    border-radius: 8px;
    font-size: 0.86rem;
    font-weight: 600;
    color: var(--text-muted);
    text-decoration: none;
    white-space: nowrap;
    transition: background 0.15s, color 0.15s;
}

.desktop-nav-link:hover {
    color: var(--text-color);
    background: var(--card-color-alt);
}

.desktop-nav-link.active,
.desktop-nav-link[aria-current="page"] {
    color: var(--primary-color);
    background: var(--card-color-alt);
    font-weight: 700;
}

/* ── Header right-side action buttons ── */
.header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.header-nav-link {
    box-sizing: border-box;
    min-height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 14px;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    background: var(--card-color-alt);
    color: var(--text-color);
    font-size: 0.82rem;
    font-weight: 700;
    line-height: 1;
    text-decoration: none;
    white-space: nowrap;
    transition: background 0.18s, border-color 0.18s, color 0.18s, transform 0.15s;
}

.header-nav-link:hover,
.header-nav-link:focus-visible {
    background: var(--card-color-deep);
    border-color: var(--primary-color);
    color: var(--primary-color);
    transform: translateY(-1px);
}

.header-signup-btn {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: #fff !important;
}

[data-theme="dark"] .header-signup-btn {
    color: #000 !important;
}

.header-signup-btn:hover {
    filter: brightness(1.1);
}

.font-size-controls {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    padding: 2px;
    background: var(--card-color-alt);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    box-sizing: border-box;
    height: 36px;
}

.font-size-btn {
    width: 32px;
    height: 30px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--text-color);
    font-family: inherit;
    font-size: 0.82rem;
    font-weight: 800;
    cursor: pointer;
    transition: background 0.18s, color 0.18s;
}

.font-size-btn:hover:not(:disabled) {
    background: var(--card-color-deep);
    color: var(--primary-color);
}

.font-size-btn:disabled {
    cursor: default;
    opacity: 0.38;
}

.font-size-value {
    min-width: 38px;
    text-align: center;
    color: var(--text-subtle);
    font-size: 0.72rem;
    font-weight: 700;
    line-height: 1;
}

.hdr-btn {
    background: var(--card-color-alt);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    box-sizing: border-box;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.05rem;
    color: var(--text-color);
    transition: background 0.18s, border-color 0.18s, color 0.18s, transform 0.15s;
    position: relative;
    text-decoration: none;
}

.hdr-btn:hover {
    background: var(--card-color-deep);
    border-color: var(--primary-color);
    color: var(--primary-color);
    transform: translateY(-1px);
}

/* ── Profile dropdown (Modern & Grouped) ── */
.profile-wrap {
    position: relative;
}

.profile-dropdown {
    display: none;
    position: absolute;
    right: 0;
    top: calc(100% + 8px);
    background: var(--dropdown-bg);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    min-width: 240px;
    box-shadow: 0 12px 32px var(--shadow), 0 4px 12px rgba(0,0,0,0.15);
    overflow-y: auto;
    max-height: calc(var(--app-viewport-height, 100vh) - 80px);
    max-width: calc(100vw - 20px);
    z-index: 3000;
    padding: 6px 0;
}

.profile-dropdown.open {
    display: block !important;
    animation: dropFadeIn 0.18s ease;
}

@keyframes dropFadeIn {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: translateY(0); }
}

.dd-header-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    text-decoration: none;
    border-bottom: 1px solid var(--dropdown-divider);
    background: var(--card-color-alt);
    margin: -6px 0 4px;
}

.dd-avatar-mini {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 800;
    font-size: 0.95rem;
    flex-shrink: 0;
}

.dd-user-meta {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.dd-header-name {
    font-size: 0.92rem;
    font-weight: 700;
    color: var(--text-color);
    line-height: 1.25;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.dd-header-tier {
    font-size: 0.74rem;
    color: var(--text-muted);
    font-weight: 600;
}

.dd-section {
    padding: 2px 0;
}

.dd-section-label {
    padding: 6px 14px 3px;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.profile-dropdown a.dd-item,
.profile-dropdown button.dd-item {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 8px 14px;
    color: var(--dropdown-item-color);
    text-decoration: none;
    font-size: 0.86rem;
    font-weight: 500;
    background: none;
    border: none;
    width: 100%;
    text-align: left;
    cursor: pointer;
    box-sizing: border-box;
    transition: background 0.15s, color 0.15s;
}

.profile-dropdown a.dd-item:hover,
.profile-dropdown button.dd-item:hover {
    background: var(--dropdown-item-hover);
    color: var(--primary-color);
}

.dd-icon {
    font-size: 0.95rem;
    width: 20px;
    text-align: center;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.dd-logout {
    color: var(--danger-color) !important;
    font-weight: 600 !important;
}

.dd-logout:hover {
    background: var(--danger-bg) !important;
}

.profile-dropdown .dd-divider {
    height: 1px;
    background: var(--dropdown-divider);
    margin: 4px 0;
}

@media (max-width: 540px) {
    header { padding: 0 0.6rem; }
    .header-logo h1 { font-size: 1.05rem; }
    .header-actions { gap: 6px; }
    .hdr-btn { width: 34px; height: 34px; font-size: 0.95rem; }
    .xp-header progress { display: none; }
    .xp-header { width: auto; }
}

html[data-font-size="small"]  { --study-font-scale: 0.92; }
html[data-font-size="normal"] { --study-font-scale: 1; }
html[data-font-size="large"]  { --study-font-scale: 1.14; }
html[data-font-size="xlarge"] { --study-font-scale: 1.28; }
html[data-font-size="xxlarge"] { --study-font-scale: 1.5; }
html[data-font-size="xxxlarge"] { --study-font-scale: 1.75; }
html[data-font-size="xxxxlarge"] { --study-font-scale: 2; }

/* Practice mode — lightweight question wrapper */
#practice-container > .question-content > h3,
#practice-container > .question-content .option,
#practice-container > .question-content .recall-options-list,
#practice-container > .question-content .answer-reveal,
#practice-container > .question-content .answer-section,
#practice-container > .question-content .explanation,
/* Practice mode — new exam-style classes (AJAX-swapped cards) */
#practice-container .qn-text,
#practice-container .exam-option,
#practice-container .instant-feedback,
#practice-container .explanation-box,
/* question-card (AJAX rendered) */
#question-card h3,
#question-card .option,
#question-card .qn-text,
#question-card .exam-option,
#question-card .instant-feedback,
#question-card .explanation-box,
#question-card .recall-options-list,
#question-card .answer-reveal,
#question-card .answer-section,
#question-card .explanation,
/* Exam attend mode */
.exam-qcard .qn-text,
.exam-qcard .exam-option,
.exam-qcard .instant-feedback,
.exam-qcard .explanation-box {
    font-size: calc(1rem * var(--study-font-scale)) !important;
    line-height: 1.65;
}

/* Readable Markdown blocks in every question/explanation surface. Single
   newlines render as <br> and intentionally keep the normal line height. */
:where(.qn-text, .explanation-box, .fp-question, .fp-explain) > :where(p, ul, ol) {
    margin-block: 0 0.65em;
}

:where(.qn-text, .explanation-box, .fp-question, .fp-explain) > :first-child {
    margin-block-start: 0;
}

:where(.qn-text, .explanation-box, .fp-question, .fp-explain) > :last-child {
    margin-block-end: 0;
}

:where(.qn-text, .explanation-box, .fp-question, .fp-explain) li + li {
    margin-block-start: 0.3em;
}

:where(.qn-text, .explanation-box, .fp-question, .fp-explain) li > :where(ul, ol) {
    margin-block: 0.3em 0;
}

/* Keep list-first explanations flush with regular explanation text while
   retaining a hanging indent for wrapped list items. */
.explanation-box > ul:first-child,
.explanation-box > ol:first-child {
    margin-block-start: 0;
}

.explanation-box > ul:first-child {
    padding-inline-start: 1.1em;
}

.explanation-box > ol:first-child {
    padding-inline-start: 1.5em;
}

/* AI Chatbot-Style Explanation Box formatting */
.explanation-box strong {
    color: var(--text-color, #f1f5f9);
    font-weight: 700;
}
[data-theme="light"] .explanation-box strong {
    color: #0f172a;
}

/* Responsive MathJax formula display */
/* Inherited text can grow wider than MathJax's measured width after fonts load
   or the study font size changes. Reserve its natural width in the formula. */
mjx-container[jax="CHTML"] mjx-utext[variant="-explicitFont"] {
    min-width: max-content;
}

.explanation-box mjx-container,
.qn-text mjx-container,
.exam-option mjx-container,
.choice-tag mjx-container,
.fp-question mjx-container,
.fp-explain mjx-container {
    max-width: 100%;
}

/* Prevent adjacent inline math from crowding surrounding text/punctuation (e.g. comma + italic b) */
.explanation-box mjx-container:not([display="true"]),
.qn-text mjx-container:not([display="true"]),
.exam-option mjx-container:not([display="true"]),
.choice-tag mjx-container:not([display="true"]),
.fp-question mjx-container:not([display="true"]),
.fp-explain mjx-container:not([display="true"]) {
    margin-inline: 0.15em;
}

mjx-container[display="true"] {
    overflow-x: auto;
    overflow-y: hidden;
    max-width: 100%;
    -webkit-overflow-scrolling: touch;
}

#practice-container > .question-content img,
#question-card img,
.exam-qcard img,
.ans-qtext img,
.choice-tag img,
.explanation-result img {
    max-width: 100%;
    height: auto;
    border-radius: 6px;
}

img.qimg-block,
#practice-container > .question-content img:not(.qimg),
#question-card img:not(.qimg),
.exam-qcard img:not(.qimg),
.ans-qtext img:not(.qimg),
.choice-tag img:not(.qimg),
.explanation-result img:not(.qimg) {
    display: block;
    margin: 10px 0;
}

img.qimg-inline {
    display: inline-block;
    width: auto;
    max-width: min(100%, 260px);
    margin: 0 4px;
    vertical-align: middle;
}

img.qimg-left {
    float: left;
    margin: 4px 14px 10px 0;
}

img.qimg-right {
    float: right;
    margin: 4px 0 10px 14px;
}

.qcrop-frame {
    display: inline-block;
    overflow: hidden;
    max-width: 100%;
    vertical-align: middle;
    border-radius: 6px;
}

.qcrop-frame > img.qimg {
    display: block !important;
    max-width: none !important;
    float: none !important;
    object-fit: cover;
}

img.qimg-crop {
    aspect-ratio: 1 / 1;
    height: auto;
    object-fit: cover;
    object-position: center center;
}

main {
    flex: 1;
    padding: 20px;
    max-width: 800px;
    margin: 0 auto;
    width: 100%;
    box-sizing: border-box;
}

main.study-session {
    max-width: none;
}

/* Keep answer rows and columns equally spaced as study text grows. */
.study-session .exam-options,
.study-session .options {
    gap: calc(0.75rem * var(--study-font-scale));
}

.btn {
    display: inline-block;
    padding: 10px 20px;
    background-color: var(--primary-color);
    color: #fff;
    text-decoration: none;
    border-radius: 5px;
    font-weight: bold;
    border: none;
    cursor: pointer;
    transition: background 0.3s;
}

[data-theme="dark"] .btn {
    color: #000;
}

/* ── Global input/select/textarea theming ── */
input[type="text"],
input[type="password"],
input[type="email"],
input[type="number"],
select,
textarea {
    background: var(--input-bg);
    color: var(--input-color);
    border: 1px solid var(--input-border);
    border-radius: 4px;
    padding: 10px 12px;
    box-sizing: border-box;
    font-family: inherit;
    font-size: 1rem;
    transition: background 0.2s, color 0.2s, border-color 0.2s;
}
input[type="text"]::placeholder,
input[type="password"]::placeholder,
textarea::placeholder {
    color: var(--text-muted);
}

/* ── Password show/hide toggle (login, signup, change password) ── */
.pw-wrap { position: relative; }
.pw-wrap input[type="password"],
.pw-wrap input[type="text"] { padding-right: 44px; }
.pw-toggle {
    position: absolute;
    top: 50%; right: 6px;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1em;
    line-height: 1;
    padding: 6px;
    color: var(--text-muted);
}

.btn:hover {
    opacity: 0.85;
}

.card {
    background-color: var(--card-color);
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 4px 6px var(--shadow);
    margin-bottom: 20px;
    transition: background-color 0.25s ease, box-shadow 0.25s ease;
}

/* ── PWA Install Banner ── */
.pwa-banner {
    display: none;
    position: fixed;
    bottom: 20px;
    left: 20px;
    right: 20px;
    background-color: var(--card-color);
    border: 1px solid var(--primary-color);
    box-shadow: 0 4px 12px var(--shadow);
    border-radius: 10px;
    padding: 15px 20px;
    z-index: 1000;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
    animation: slideUp 0.3s ease-out;
}

.pwa-banner.show {
    display: flex;
}

.pwa-banner-text {
    flex: 1;
    font-size: 0.95rem;
    color: var(--text-color);
}

.pwa-banner-actions {
    display: flex;
    gap: 10px;
}

.pwa-banner-btn {
    padding: 8px 16px;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    font-size: 0.9rem;
    transition: opacity 0.2s;
}

.pwa-banner-btn.install {
    background-color: var(--primary-color);
    color: #fff;
}

[data-theme="dark"] .pwa-banner-btn.install {
    color: #000;
}

.pwa-banner-btn.dismiss {
    background-color: var(--card-color-alt);
    color: var(--text-color);
    border: 1px solid var(--border-color);
}

.pwa-banner-btn:hover {
    opacity: 0.85;
}

@keyframes slideUp {
    from { transform: translateY(100px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

@media (max-width: 480px) {
    .pwa-banner {
        flex-direction: column;
        text-align: center;
        bottom: 10px;
        left: 10px;
        right: 10px;
    }
    .pwa-banner-actions {
        width: 100%;
        justify-content: center;
    }
}
/* Study guide and discoverable practice controls */
.study-guide { box-sizing: border-box; width: min(640px, calc(100% - 24px)); max-height: calc(var(--app-viewport-height, 100vh) - 32px); padding: 20px; border: 1px solid var(--border-color); border-radius: 16px; background: var(--modal-bg); color: var(--text-color); overflow-y: auto; line-height: 1.6; }
.study-guide::backdrop { background: rgba(0,0,0,.65); }
.study-guide-open { overflow: hidden; }
.guide-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.guide-title-wrap { display: flex; align-items: center; gap: 12px; flex: 1; flex-wrap: wrap; }
.guide-title-wrap h2 { margin: 0; font-size: 1.25rem; font-weight: 800; }
.guide-lang-toggle { display: inline-flex; align-items: center; background: var(--card-color-alt); border: 1px solid var(--border-color); border-radius: 999px; padding: 2px; gap: 2px; }
.guide-lang-btn { border: 0; border-radius: 999px; padding: 4px 12px; font-size: 0.82rem; font-weight: 700; background: transparent; color: var(--text-muted); cursor: pointer; transition: background 0.15s ease, color 0.15s ease; }
.guide-lang-btn:hover { color: var(--text-color); }
.guide-lang-btn.active { background: var(--primary-color); color: #fff; box-shadow: 0 2px 6px rgba(0,0,0,.15); }
.guide-lang-btn:focus-visible { outline: 2px solid var(--secondary-color); outline-offset: 2px; }
.guide-close-btn { min-width: 36px; min-height: 36px; padding: 4px 10px; font-size: 1rem; flex-shrink: 0; }
.guide-content-panel { margin-top: 6px; }
.guide-lead { margin: 0 0 14px; font-size: 0.95rem; line-height: 1.6; color: var(--text-color); }
[data-guide-panel="ml"] { font-family: 'Noto Sans Malayalam', 'Noto Sans', 'AnjaliOldLipi', 'Kartika', system-ui, sans-serif; line-height: 1.7; }
[data-guide-panel="ml"] summary { font-size: 1rem; }
.guide-button { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 8px 12px; border: 1px solid var(--border-color); border-radius: 10px; background: var(--card-color); color: var(--text-color); font: inherit; cursor: pointer; text-decoration: none; overflow-wrap: anywhere; }
.guide-button:hover { background: var(--card-color-alt); }
.guide-button:focus-visible, .study-guide summary:focus-visible { outline: 3px solid var(--secondary-color); outline-offset: 3px; }
.study-guide details { border-top: 1px solid var(--border-color); padding: 12px 0; }
.study-guide summary { cursor: pointer; font-weight: 700; padding: 4px; }
.study-guide li { margin-bottom: 8px; }
kbd { font-family: monospace; border: 1px solid var(--border-color); border-radius: 4px; padding: 1px 5px; font-size: .75em; background: var(--card-color-alt); color: var(--text-color); }
.support-links { display: flex; flex-wrap: wrap; gap: 10px; }
.dd-section-label { color: var(--text-muted); font-size: .78rem; font-weight: 700; padding: 8px 14px 3px; }
@media (max-width: 480px) {
    .study-guide { padding: 16px; }
    .guide-title-wrap { flex-direction: column; align-items: flex-start; gap: 8px; }
    .guide-title-wrap h2 { font-size: 1.1rem; }
    .support-links { flex-direction: column; }
}

#study-guide-btn:focus-visible { outline: 3px solid var(--secondary-color); outline-offset: 3px; }
