/* ============================================================
   The Grammar Index — Corporate Theme
   ============================================================ */

:root {
    --primary: #1B5E9E;
    --primary-dark: #14486F;
    --primary-light: #2980C4;
    --bg: #F5F6FA;
    --bg-card: #FFFFFF;
    --text: #2C3E50;
    --text-muted: #6C7A89;
    --border: #E0E4EB;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    --shadow-hover: 0 4px 16px rgba(0, 0, 0, 0.12);
    --radius: 8px;
    --radius-sm: 4px;
    --radius-pill: 50px;
    --success: #27AE60;
    --danger: #E74C3C;
    --warning: #F39C12;
    --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
        "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji",
        "Segoe UI Emoji";
}

/* Reset & base */
*, *::before, *::after {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    font-family: var(--font-family);
    font-size: 15px;
    line-height: 1.6;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ---- Loading screen ---- */
.loading-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100vh;
    background: var(--bg);
}

.loading-content {
    text-align: center;
}

.loading-title {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 1.5rem;
}

.loading-spinner {
    display: flex;
    justify-content: center;
    margin-bottom: 1rem;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-text {
    color: var(--text-muted);
    font-size: 0.95rem;
}

/* ---- Blazor error UI ---- */
#blazor-error-ui {
    background: var(--danger);
    color: #fff;
    padding: 0.75rem 1.25rem;
    position: fixed;
    bottom: 0;
    width: 100%;
    z-index: 9999;
    display: none;
    text-align: center;
}

#blazor-error-ui .reload,
#blazor-error-ui .dismiss {
    color: #fff;
    margin-left: 1rem;
    text-decoration: underline;
    cursor: pointer;
}

/* ---- Header ---- */
.app-header {
    background: var(--primary);
    color: #fff;
    padding: 0;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.app-header2 {
    background: var(--primary);
    color: #fff;
    padding: 0;
    position: sticky;
    top: 0;
    z-index: 100;
}



.header-inner {
    max-width: 1280px;
    margin: 0 auto;
    padding: 0.9rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* FocusOnNavigate (App.razor) moves keyboard focus to the page heading on each
   navigation so screen readers announce it. That programmatic focus otherwise
   draws a visible outline around the heading on launch (it showed around the
   logo while the logo was the first h1). Headings are not keyboard tab-stops, so
   suppressing their focus outline does not affect keyboard users — interactive
   controls keep their focus rings. */
h1:focus,
[tabindex="-1"]:focus {
    outline: none;
}

.header-title {
    font-size: 1.35rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin: 0;
}

.header-subtitle {
    font-size: 0.82rem;
    opacity: 0.8;
    font-weight: 400;
    margin-left: 0.75rem;
}

/* ---- Footer ---- */
.app-footer {
    text-align: center;
    padding: 1.5rem 1rem;
    font-size: 0.82rem;
    color: var(--text-muted);
    border-top: 1px solid var(--border);
    margin-top: 2rem;
}

/* ---- Main content ---- */
.main-content {
    max-width: 1280px;
    margin: 0 auto;
    padding: 1.5rem;
}

/* ---- Page title ---- */
.page-title {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--text);
    margin: 0 0 0.5rem 0;
}

.page-subtitle {
    color: var(--text-muted);
    font-size: 0.95rem;
    margin: 0 0 0.4rem 0;
}

.page-hint {
    color: var(--primary, #1B5E9E);
    font-size: 0.9rem;
    font-weight: 500;
    margin: 0 0 1.5rem 0;
}

/* ---- Search bar ---- */
.search-bar {
    margin-bottom: 1.25rem;
}

.search-bar .dxbl-text-edit {
    border-radius: var(--radius) !important;
}

/* ---- Section chips ---- */
.section-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

.section-chip {
    display: inline-flex;
    align-items: center;
    padding: 0.35rem 0.9rem;
    border-radius: var(--radius-pill);
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    border: 2px solid var(--border);
    background: var(--bg-card);
    color: var(--text);
    transition: all 0.2s ease;
    user-select: none;
}

.section-chip:hover {
    border-color: var(--primary-light);
    color: var(--primary);
}

.section-chip.active {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

/* ---- Custom filter modal ----
   User picks a subset of topics to focus on. Modal is plain HTML/CSS (not a
   DevExpress popup) so it stays lightweight and matches the rest of the
   home-screen visual language. */
.custom-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1rem;
}

.custom-modal {
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
    max-width: 760px;
    width: 100%;
    max-height: 86vh;
    display: flex;
    flex-direction: column;
}

.custom-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
}

.custom-modal-header h3 {
    margin: 0;
    color: var(--primary);
    font-size: 1.1rem;
}

.custom-modal-close {
    background: none;
    border: none;
    font-size: 1.6rem;
    cursor: pointer;
    color: #888;
    line-height: 1;
    padding: 0 0.3rem;
}

.custom-modal-close:hover {
    color: var(--primary);
}

.custom-modal-body {
    overflow-y: auto;
    padding: 0.5rem 1.25rem 1rem;
    flex: 1;
}

.custom-modal-intro {
    font-size: 0.88rem;
    color: #555;
    margin: 0.5rem 0 1rem;
}

.custom-modal-section-group {
    margin-bottom: 0.75rem;
}

.custom-modal-section-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-weight: 700;
    color: var(--primary);
    margin: 0.75rem 0 0.25rem;
    padding-bottom: 0.25rem;
    border-bottom: 1px solid var(--border);
    font-size: 0.95rem;
}

.custom-modal-section-toggle {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-pill);
    font-size: 0.72rem;
    padding: 0.15rem 0.7rem;
    cursor: pointer;
    color: var(--primary);
    font-weight: 600;
}

.custom-modal-section-toggle:hover {
    border-color: var(--primary);
}

.custom-modal-row {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.35rem 0.25rem;
    cursor: pointer;
    border-radius: 4px;
}

.custom-modal-row:hover {
    background: #f5f5fa;
}

.custom-modal-row input[type="checkbox"] {
    width: 1.05rem;
    height: 1.05rem;
    cursor: pointer;
    accent-color: var(--primary);
}

.custom-modal-row .title {
    flex: 1;
    font-size: 0.92rem;
}

.custom-modal-footer {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.85rem 1.25rem;
    border-top: 1px solid var(--border);
    flex-wrap: wrap;
}

.custom-modal-count {
    margin-right: auto;
    font-size: 0.88rem;
    color: #555;
    font-weight: 600;
}

.custom-modal-btn {
    border-radius: var(--radius-pill);
    padding: 0.45rem 1.1rem;
    font-weight: 600;
    cursor: pointer;
    font-size: 0.85rem;
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text);
}

.custom-modal-btn:hover {
    border-color: var(--primary);
}

.custom-modal-btn.primary {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

.custom-modal-btn.primary:hover {
    background: var(--primary);
    filter: brightness(1.1);
}

.custom-modal-btn.danger {
    color: #c0392b;
    border-color: #f4caca;
}

/* ---- Card grid ---- */
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 1.25rem;
}

/* ---- Grammar card ---- */
.grammar-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.25rem;
    cursor: pointer;
    transition: box-shadow 0.2s ease, transform 0.2s ease;
    border: 1px solid var(--border);
    display: flex;
    flex-direction: column;
}

.grammar-card:hover {
    box-shadow: var(--shadow-hover);
    transform: translateY(-2px);
}

.grammar-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.grammar-card-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text);
    margin: 0;
    line-height: 1.4;
}

.grammar-card-definition {
    color: var(--text-muted);
    font-size: 0.88rem;
    line-height: 1.55;
    margin-bottom: 0.75rem;
    flex: 1;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.grammar-card-example {
    background: var(--bg);
    border-radius: var(--radius-sm);
    padding: 0.6rem 0.75rem;
    font-size: 0.82rem;
    color: var(--text-muted);
    line-height: 1.5;
    border-left: 3px solid var(--primary-light);
}

.grammar-card-example-label {
    font-weight: 600;
    color: var(--text);
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin-bottom: 0.2rem;
}

.grammar-card-more {
    margin-top: 0.6rem;
    color: var(--primary, #1B5E9E);
    font-size: 0.78rem;
    font-weight: 600;
    text-align: right;
}

/* ---- Tag badge ---- */
.tag-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.6rem;
    border-radius: var(--radius-pill);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    white-space: nowrap;
    color: #fff;
    flex-shrink: 0;
}

/* ---- Entry detail page ---- */
.entry-detail {
    max-width: 800px;
    margin: 0 auto;
}

.entry-detail-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.entry-detail-title {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--text);
    margin: 0;
}

.entry-detail-definition {
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.25rem 1.5rem;
    margin-bottom: 1.5rem;
    border: 1px solid var(--border);
    line-height: 1.7;
    font-size: 1rem;
    color: var(--text);
}

.entry-back-link {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 1.25rem;
    transition: color 0.15s;
}

.entry-back-link:hover {
    color: var(--primary-dark);
}

.entry-section-label {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

/* ---- Example blocks ---- */
.examples-section {
    margin-top: 1.5rem;
}

.examples-section-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text);
    margin: 0 0 1rem 0;
}

.example-block {
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1rem 1.25rem;
    margin-bottom: 1rem;
    border: 1px solid var(--border);
    border-left: 4px solid var(--primary-light);
}

.example-block.correct {
    border-left-color: var(--success);
}

.example-block.incorrect {
    border-left-color: var(--danger);
}

.example-block-label {
    font-weight: 700;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 0.35rem;
    color: var(--text-muted);
}

.example-block.correct .example-block-label {
    color: var(--success);
}

.example-block.incorrect .example-block-label {
    color: var(--danger);
}

.example-block-sentence {
    font-size: 0.95rem;
    line-height: 1.65;
    color: var(--text);
}

.example-block-sentence .hl {
    background: rgba(27, 94, 158, 0.12);
    padding: 0.1em 0.25em;
    border-radius: 3px;
    font-weight: 600;
    color: var(--primary);
}

.example-block.correct .example-block-sentence .hl {
    background: rgba(39, 174, 96, 0.12);
    color: var(--success);
}

.example-block.incorrect .example-block-sentence .hl {
    background: rgba(231, 76, 60, 0.12);
    color: var(--danger);
    text-decoration: line-through;
}

.example-block-note {
    margin-top: 0.5rem;
    font-size: 0.82rem;
    color: var(--text-muted);
    font-style: italic;
}

/* ---- Joke box ----
   Closes the Imagery & Poetry entries. Deliberately unlike .example-block —
   dashed border, warm wash, no card shadow — because it is an aside about the
   device rather than a worked example of it. Matches the International and
   KS2/3 editions rule for rule. */
.joke-box {
    margin-top: 2rem;
    padding: 1.1rem 1.35rem;
    background: linear-gradient(135deg, rgba(255, 213, 79, 0.18), rgba(255, 167, 38, 0.12));
    border: 1px dashed rgba(255, 152, 0, 0.55);
    border-radius: var(--radius);
}

.joke-box-label {
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #b07000;
    margin-bottom: 0.4rem;
}

.joke-box-text {
    font-size: 1rem;
    line-height: 1.55;
    color: var(--text);
    /* Flex row so the read-aloud button sits centred at the end of the joke
       instead of on the text baseline — .speak-btn is a fixed 2rem circle, and
       inline-flex next to 1rem text drops the whole line box. */
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.joke-box-text + .joke-box-text {
    margin-top: 0.6rem;
    padding-top: 0.6rem;
    border-top: 1px dashed rgba(255, 152, 0, 0.35);
}

/* ---- No results ---- */
.no-results {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-muted);
}

.no-results-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.4;
}

.no-results-text {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.no-results-hint {
    font-size: 0.9rem;
}

/* ---- Activation page ---- */
.activation-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--bg);
    padding: 1.5rem;
}

.activation-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.1);
    padding: 2.5rem;
    max-width: 440px;
    width: 100%;
    text-align: center;
    border: 1px solid var(--border);
}

.activation-logo {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 0.5rem;
}

.activation-subtitle {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 2rem;
}

.activation-input {
    margin-bottom: 1rem;
}

.activation-message {
    margin-top: 1rem;
    font-size: 0.88rem;
    padding: 0.6rem 0.75rem;
    border-radius: var(--radius-sm);
}

.activation-message.error {
    background: rgba(231, 76, 60, 0.1);
    color: var(--danger);
}

.activation-message.success {
    background: rgba(39, 174, 96, 0.1);
    color: var(--success);
}

/* ---- Back to top ---- */
.back-to-top {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    border: none;
    cursor: pointer;
    box-shadow: var(--shadow-hover);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    transition: opacity 0.2s, transform 0.2s;
    z-index: 50;
}

.back-to-top:hover {
    background: var(--primary-dark);
    transform: scale(1.1);
}

/* ---- Responsive ---- */
@media (max-width: 768px) {
    .card-grid {
        grid-template-columns: 1fr;
    }

    .header-inner {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.2rem;
    }

    .header-subtitle {
        margin-left: 0;
    }

    .main-content {
        padding: 1rem;
    }

    .entry-detail-title {
        font-size: 1.4rem;
    }

    .activation-card {
        padding: 1.5rem;
    }

    .entry-detail-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
}

@media (max-width: 480px) {
    .section-chips {
        gap: 0.35rem;
    }

    .section-chip {
        padding: 0.25rem 0.65rem;
        font-size: 0.75rem;
    }
}

/* ===== Quiz feature ===== */
.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}
.header-title-link { text-decoration: none; color: inherit; }
.header-title-link:hover { opacity: 0.85; }

.header-nav {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}
/* Plain text links: no fill and no outline at rest — the icon and label carry
   them. The header is --primary (#1B5E9E), so the text HAS to be white: the
   old dark --text (#2C3E50) only ever worked because it sat on a near-white
   pill, and against the blue it measures about 1.65:1.

   The 1px border is kept but transparent rather than dropped, so the padding
   box does not change size between rest and hover — border-box would shrink
   each link by 2px and the hover pill would jump. border-radius likewise
   stays: it shapes the hover fill. */
.header-nav-link {
    padding: 0.45rem 0.95rem;
    border-radius: 999px;
    font-size: 0.9rem;
    font-weight: 600;
    text-decoration: none;
    color: #fff;
    background: transparent;
    border: 1px solid transparent;
    transition: background 0.15s, transform 0.15s;
}

.header-nav-link:hover {
    background: rgba(255, 255, 255, 0.15);
    transform: translateY(-1px);
}

/* The white pill used to supply the contrast the browser's default focus ring
   needed. With it gone, an explicit white ring keeps keyboard focus visible
   against the blue header. */
.header-nav-link:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 2px;
}

.quiz-cta { margin: 1.25rem 0 2rem; }
.quiz-cta-button {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1.1rem 1.4rem;
    background: linear-gradient(135deg, var(--primary), #2C7EBA);
    color: #fff;
    border-radius: var(--radius);
    text-decoration: none;
    box-shadow: 0 4px 12px rgba(27, 94, 158, 0.25);
    transition: transform 0.15s, box-shadow 0.15s;
}
.quiz-cta-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(27, 94, 158, 0.35);
    color: #fff;
}
.quiz-cta-icon { font-size: 1.8rem; }
.quiz-cta-text { display: flex; flex-direction: column; }
.quiz-cta-text strong { font-size: 1.1rem; margin-bottom: 0.15rem; }
.quiz-cta-hint { font-size: 0.85rem; opacity: 0.92; }

.quiz-pool-note {
    background: rgba(27, 94, 158, 0.08);
    border-left: 3px solid var(--primary);
    padding: 0.6rem 0.9rem;
    border-radius: 4px;
    font-size: 0.9rem;
    color: var(--text-muted);
    margin: 0 0 1.5rem 0;
}

.quiz-question {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-left: 4px solid var(--primary-light);
    border-radius: var(--radius);
    padding: 1.1rem 1.25rem;
    margin-bottom: 1rem;
    box-shadow: var(--shadow);
}
.quiz-question.quiz-q-right { border-left-color: var(--success); }
.quiz-question.quiz-q-wrong { border-left-color: var(--danger); }
.quiz-question-num {
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}
.quiz-question-sentence { font-size: 1.05rem; line-height: 1.6; margin-bottom: 0.5rem; }
.quiz-question-sentence .hl {
    background: rgba(27, 94, 158, 0.12);
    padding: 0.1em 0.3em;
    border-radius: 3px;
    font-weight: 600;
    color: var(--primary);
    text-decoration: underline;
    text-decoration-thickness: 2px;
    text-underline-offset: 3px;
}
.quiz-question-prompt { font-size: 0.95rem; font-weight: 600; margin: 0.7rem 0 0.6rem; color: var(--text); }

.quiz-options { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 0.5rem; }
.quiz-option {
    padding: 0.65rem 0.9rem;
    background: #fff;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.12s, border-color 0.12s;
    text-align: left;
    color: var(--text);
}
.quiz-option:hover:not(:disabled) { border-color: var(--primary); background: rgba(27, 94, 158, 0.05); }
.quiz-option.selected { background: rgba(27, 94, 158, 0.12); border-color: var(--primary); color: var(--primary); }
.quiz-option.correct { background: rgba(39, 174, 96, 0.15); border-color: var(--success); color: var(--success); }
.quiz-option.wrong { background: rgba(231, 76, 60, 0.12); border-color: var(--danger); color: var(--danger); text-decoration: line-through; }
.quiz-option:disabled { cursor: default; }

.quiz-answer-reveal { margin-top: 0.6rem; font-size: 0.9rem; color: var(--text-muted); font-style: italic; }

.quiz-submit {
    display: block;
    width: 100%;
    margin-top: 1rem;
    padding: 0.9rem 1.2rem;
    font-size: 1rem;
    font-weight: 700;
    color: #fff;
    background: var(--primary);
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    transition: background 0.15s;
}
.quiz-submit:hover:not(:disabled) { background: #1A507F; }
.quiz-submit:disabled { background: var(--border); color: var(--text-muted); cursor: not-allowed; }

.quiz-result {
    margin-top: 1.25rem;
    padding: 1.25rem 1.4rem;
    background: linear-gradient(135deg, rgba(39, 174, 96, 0.12), rgba(27, 94, 158, 0.08));
    border: 1px solid rgba(39, 174, 96, 0.25);
    border-radius: var(--radius);
    text-align: center;
}
.quiz-result-score { font-size: 1.6rem; font-weight: 800; color: var(--success); margin-bottom: 0.35rem; }
.quiz-result-message { font-size: 1rem; color: var(--text); margin-bottom: 1rem; }

/* ── Read-aloud (speaker buttons + reading-speed control) ─────────────────── */
.speak-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    width: 2rem;
    height: 2rem;
    padding: 0;
    font-size: 1rem;
    line-height: 1;
    color: var(--primary);
    background: rgba(27, 94, 158, 0.1);
    background: color-mix(in srgb, var(--primary) 10%, transparent);
    border: 1px solid rgba(27, 94, 158, 0.3);
    border: 1px solid color-mix(in srgb, var(--primary) 30%, transparent);
    border-radius: 50%;
    cursor: pointer;
    transition: background-color 0.15s ease, color 0.15s ease, transform 0.1s ease;
    -webkit-tap-highlight-color: transparent;
}

.speak-btn:hover {
    background: color-mix(in srgb, var(--primary) 18%, transparent);
}

.speak-btn:active {
    transform: scale(0.92);
}

.speak-btn:focus-visible {
    outline: 3px solid color-mix(in srgb, var(--primary) 45%, transparent);
    outline-offset: 2px;
}

.speak-btn.is-playing {
    color: #fff;
    background: var(--primary);
    border-color: var(--primary);
}

.speak-btn-lg {
    width: 2.5rem;
    height: 2.5rem;
    font-size: 1.25rem;
}

/* White scheme for dark/coloured backgrounds. */
.speak-btn.is-light {
    color: #fff;
    background: rgba(255, 255, 255, 0.18);
    border-color: rgba(255, 255, 255, 0.55);
}

.speak-btn.is-light:hover {
    background: rgba(255, 255, 255, 0.3);
}

.speak-btn.is-light.is-playing {
    color: var(--primary);
    background: #fff;
    border-color: #fff;
}

/* Reading-speed control */
.read-aloud-toolbar {
    display: flex;
    justify-content: flex-end;
    margin: 0 0 1rem;
}

.speech-speed {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    flex-wrap: wrap;
}

.speech-speed-label {
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    margin-right: 0.15rem;
}

.speech-speed-btn {
    min-width: 2.6rem;
    padding: 0.25rem 0.55rem;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--primary);
    background: var(--bg-card);
    border: 1px solid rgba(27, 94, 158, 0.3);
    border: 1px solid color-mix(in srgb, var(--primary) 30%, transparent);
    border-radius: 999px;
    cursor: pointer;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.speech-speed-btn:hover {
    background: color-mix(in srgb, var(--primary) 10%, transparent);
}

.speech-speed-btn.active {
    color: #fff;
    background: var(--primary);
    border-color: var(--primary);
}

.speech-speed-btn:focus-visible {
    outline: 3px solid color-mix(in srgb, var(--primary) 45%, transparent);
    outline-offset: 2px;
}

/* Keep the tag badge and speaker together at the right of a browse card. */
.grammar-card-header-actions {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    flex: 0 0 auto;
}

/* Example block: label on the left, speaker on the right. */
.example-block-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.6rem;
}

/* Let the speaker sit inline at the end of a quiz sentence. */
.quiz-question-sentence {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-wrap: wrap;
}
