/* ==========================================================================
   PocketShala website – same calm, grown-up look as the app (Bootstrap 5.3)

   One theme for every board and every age (pocketshala_app/constants/theme.js): deep indigo-blue with a
   burnt-orange accent used sparingly, a neutral grey page, white cards with fine borders, deep navy "hero"
   cards and muted tints for standards / subjects. Fonts: Hind Vadodara (Gujarati), Mukta (Hindi), Inter.
   A view sets the board class on <body> (BoardCategory::boardColorClass('theme')); it only picks the
   colour of the board's medium mark (ગુ / हि / Aa) – the brand colour stays the same.
   ========================================================================== */

/* ----- Tokens (theme.js) -------------------------------------------------- */

:root {
    --brand: #3346c9;
    --brand-dark: #2635a3;
    --brand-soft: #e9ecfb;
    --brand-rgb: 51, 70, 201;
    --accent: #e0651c;
    --accent-soft: #fcefe5;
    --hero: #131b3b;
    --hero-alt: #1e2856;
    --on-hero-muted: rgba(255, 255, 255, 0.7);

    --page: #ffffff;
    --surface: #ffffff;
    --surface-2: #eef0f4;
    --line: #e2e5eb;
    --line-strong: #cdd2db;
    --ink: #151a26;
    --ink-2: #5a6271;
    --ink-3: #98a0ad;

    --success: #13834a;
    --success-soft: #e3f4ea;
    --danger: #c9302c;
    --danger-soft: #fbe9e8;
    --warning: #b86a00;
    --warning-soft: #fdf1dc;

    --radius-sm: 8px;
    --radius: 10px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    /* every card: its own border + a white gap + a second thin line (double border), lifting it off the pattern */
    --ring-gap: #ffffff;
    --shadow: 0 0 0 3px var(--ring-gap), 0 0 0 4px #dde1e8, 0 6px 16px -8px rgba(27, 35, 51, 0.18);
    --shadow-hover: 0 0 0 3px var(--ring-gap), 0 0 0 4px rgba(var(--brand-rgb), 0.45), 0 12px 24px -12px rgba(27, 35, 51, 0.3);

    /* muted tint pairs (FUN_COLORS) */
    --fun-1-bg: #eef1fb; --fun-1-fg: #3346c9;
    --fun-2-bg: #e7f3f1; --fun-2-fg: #0f766e;
    --fun-3-bg: #fcf1e6; --fun-3-fg: #b45309;
    --fun-4-bg: #f2eefb; --fun-4-fg: #6a3fbf;
    --fun-5-bg: #e9f1fa; --fun-5-fg: #1d5fa8;
    --fun-6-bg: #fbedef; --fun-6-fg: #b4233c;

    /* the board's medium mark (BoardOption in the app): Gujarati amber, Hindi rose, English teal */
    --medium-bg: var(--fun-1-bg);
    --medium-fg: var(--fun-1-fg);

    --font: 'Inter', 'Hind Vadodara', 'Mukta', system-ui, -apple-system, 'Segoe UI', sans-serif;
}

html[lang^="gu"] { --font: 'Hind Vadodara', 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif; }
html[lang^="hi"] { --font: 'Mukta', 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif; }

.gseb-theme { --medium-bg: var(--fun-3-bg); --medium-fg: var(--fun-3-fg); }
.cbse-hindi-theme { --medium-bg: var(--fun-6-bg); --medium-fg: var(--fun-6-fg); }
.cbse-english-theme { --medium-bg: var(--fun-2-bg); --medium-fg: var(--fun-2-fg); }

.fun-1 { --fun-bg: var(--fun-1-bg); --fun-fg: var(--fun-1-fg); }
.fun-2 { --fun-bg: var(--fun-2-bg); --fun-fg: var(--fun-2-fg); }
.fun-3 { --fun-bg: var(--fun-3-bg); --fun-fg: var(--fun-3-fg); }
.fun-4 { --fun-bg: var(--fun-4-bg); --fun-fg: var(--fun-4-fg); }
.fun-5 { --fun-bg: var(--fun-5-bg); --fun-fg: var(--fun-5-fg); }
.fun-6 { --fun-bg: var(--fun-6-bg); --fun-fg: var(--fun-6-fg); }

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

body {
    --bs-body-font-family: var(--font);
    --bs-body-color: var(--ink);
    --bs-body-bg: var(--page);
    --bs-border-color: var(--line);
    --bs-secondary-color: var(--ink-2);
    --bs-link-color-rgb: var(--brand-rgb);
    --bs-link-hover-color-rgb: var(--brand-rgb);
    font-family: var(--font);
    font-size: 1rem;
    line-height: 1.6;
    color: var(--ink);
    /* white page with soft outline study doodles (maths, science, fruits, vehicles) – img/study-pattern.svg */
    background: var(--page) url("../img/study-pattern.svg") repeat;
    background-size: 960px;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6 {
    color: var(--ink);
    font-weight: 700;
    letter-spacing: -0.01em;
}

a {
    text-decoration: none;
}

.form-control,
.form-select {
    border-color: var(--line-strong);
    border-radius: var(--radius);
}

.form-control:focus,
.form-select:focus {
    border-color: var(--brand);
    box-shadow: 0 0 0 0.2rem rgba(var(--brand-rgb), 0.15);
}

/* yii2-bootstrap4 ActiveForm still emits .form-group */
.form-group {
    margin-bottom: 1rem;
}

.text-brand {
    color: var(--brand) !important;
}

:focus-visible {
    outline: 2px solid rgba(var(--brand-rgb), 0.5);
    outline-offset: 2px;
}

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

.btn {
    font-weight: 600;
    border-radius: var(--radius);
}

.btn-brand {
    --bs-btn-color: #fff;
    --bs-btn-bg: var(--brand);
    --bs-btn-border-color: var(--brand);
    --bs-btn-hover-color: #fff;
    --bs-btn-hover-bg: var(--brand-dark);
    --bs-btn-hover-border-color: var(--brand-dark);
    --bs-btn-active-color: #fff;
    --bs-btn-active-bg: var(--brand-dark);
    --bs-btn-active-border-color: var(--brand-dark);
    --bs-btn-disabled-color: #fff;
    --bs-btn-disabled-bg: var(--brand);
    --bs-btn-disabled-border-color: var(--brand);
    --bs-btn-focus-shadow-rgb: var(--brand-rgb);
}

.btn-brand-soft {
    --bs-btn-color: var(--brand);
    --bs-btn-bg: var(--brand-soft);
    --bs-btn-border-color: var(--brand-soft);
    --bs-btn-hover-color: var(--brand-dark);
    --bs-btn-hover-bg: var(--brand-soft);
    --bs-btn-hover-border-color: rgba(var(--brand-rgb), 0.35);
    --bs-btn-active-color: var(--brand-dark);
    --bs-btn-active-bg: var(--brand-soft);
    --bs-btn-active-border-color: var(--brand);
    --bs-btn-disabled-color: var(--brand);
    --bs-btn-disabled-bg: var(--brand-soft);
    --bs-btn-disabled-border-color: var(--brand-soft);
    --bs-btn-focus-shadow-rgb: var(--brand-rgb);
}

.btn-line {
    --bs-btn-color: var(--ink);
    --bs-btn-bg: var(--surface);
    --bs-btn-border-color: var(--line-strong);
    --bs-btn-hover-color: var(--brand);
    --bs-btn-hover-bg: var(--surface);
    --bs-btn-hover-border-color: var(--brand);
    --bs-btn-active-bg: var(--surface-2);
    --bs-btn-active-border-color: var(--brand);
}

/* ----- Header & footer ------------------------------------------------- */

.site-header {
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: saturate(160%) blur(8px);
    border-bottom: 1px solid var(--line);
}

.site-header .navbar {
    --bs-navbar-padding-y: 0.6rem;
    --bs-navbar-color: var(--ink-2);
    --bs-navbar-hover-color: var(--ink);
    --bs-navbar-active-color: var(--brand);
}

.site-header .navbar-brand {
    font-weight: 700;
    font-size: 1.3rem;
    letter-spacing: -0.01em;
    color: var(--ink);
}

.brand-logo {
    width: 2.25rem;
    height: 2.25rem;
    border-radius: var(--radius);
}

.brand-accent {
    color: var(--accent);
}

.site-header .nav-link {
    font-weight: 500;
    border-radius: var(--radius-sm);
    padding-inline: 0.85rem !important;
}

.site-header .nav-link:hover {
    background: var(--surface-2);
}

.site-header .nav-link.active {
    font-weight: 600;
    background: var(--brand-soft);
}

.board-menu {
    --bs-dropdown-border-color: var(--line);
    --bs-dropdown-border-radius: var(--radius-lg);
    --bs-dropdown-padding-x: 0.35rem;
    --bs-dropdown-item-border-radius: var(--radius-sm);
    min-width: 16rem;
    box-shadow: 0 14px 30px -18px rgba(15, 23, 42, 0.35);
}

.board-menu .dropdown-item {
    padding: 0.55rem 0.75rem;
    font-weight: 500;
}

.board-menu .dropdown-item:hover,
.board-menu .dropdown-item.active,
.board-menu .dropdown-item:active {
    color: var(--ink);
    background: var(--brand-soft);
}

.board-dot {
    display: inline-block;
    flex-shrink: 0;
    width: 0.6rem;
    height: 0.6rem;
    border-radius: 50%;
    background: var(--medium-fg);
}

.board-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.2rem 0.75rem;
    border-radius: 999px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--ink-2);
    background: var(--surface);
    border: 1px solid var(--line);
    white-space: nowrap;
}

/* room between the page content and the footer (the footer itself uses mt-auto to stay at the bottom) */
main[role="main"] {
    padding-bottom: 3.5rem;
}

.site-footer {
    background: var(--surface);
    border-top: 1px solid var(--line);
    color: var(--ink-2);
}

.footer-brand {
    color: var(--ink);
    font-weight: 700;
    font-size: 1.15rem;
}

.footer-heading {
    margin-bottom: 0.75rem;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--ink-3);
}

.footer-links li + li {
    margin-top: 0.45rem;
}

.footer-links a {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--ink-2);
}

.footer-links a:hover {
    color: var(--brand);
}

.footer-bottom {
    border-top: 1px solid var(--line);
    color: var(--ink-3);
}

/* ----- Page header: navy hero card (HeroCard in the app) ----------------- */

.page-hero {
    padding: 1.25rem 0 0.25rem;
}

.page-hero .hero-card {
    position: relative;
    overflow: hidden;
    padding: 1.4rem 1.5rem;
    border-radius: var(--radius-xl);
    background: var(--hero);
    color: #fff;
}

.hero-card::after {
    content: '';
    position: absolute;
    top: -70px;
    right: -40px;
    width: 220px;
    height: 220px;
    border-radius: 50%;
    background: var(--hero-alt);
    pointer-events: none;
}

.hero-card > * {
    position: relative;
    z-index: 1;
}

.page-hero .breadcrumb {
    --bs-breadcrumb-divider-color: rgba(255, 255, 255, 0.45);
    --bs-breadcrumb-item-active-color: var(--on-hero-muted);
    margin-bottom: 0.9rem;
    font-size: 0.875rem;
}

.page-hero .breadcrumb a {
    color: #fff;
}

.page-hero .breadcrumb a:hover {
    text-decoration: underline;
}

.hero-logo {
    flex-shrink: 0;
    display: grid;
    place-items: center;
    width: 3.75rem;
    height: 3.75rem;
    padding: 0.3rem;
    border-radius: var(--radius-lg);
    background: #fff;
}

.hero-logo img {
    max-width: 100%;
    max-height: 100%;
    border-radius: 50%;
    object-fit: contain;
}

.hero-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.05rem 0.6rem;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--on-hero-muted);
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.16);
}

.hero-badge-accent {
    color: #fff;
    background: var(--accent);
    border-color: var(--accent);
}

.hero-title {
    margin: 0;
    color: #fff;
    font-weight: 700;
    font-size: clamp(1.5rem, 1.2rem + 1.1vw, 2.1rem);
    line-height: 1.3;
}

.hero-subtitle {
    margin: 0.2rem 0 0;
    color: var(--on-hero-muted);
}

.page-body {
    padding-top: 1rem;
}

/* ----- Shared blocks ----------------------------------------------------- */

.surface {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
}

.section-head {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.section-title {
    margin: 0;
    color: var(--ink);
    font-size: 1.2rem;
    font-weight: 700;
}

.section-icon {
    display: grid;
    place-items: center;
    flex-shrink: 0;
    width: 2rem;
    height: 2rem;
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-style: normal;
    color: var(--brand);
    background: var(--brand-soft);
}

/* semester tabs (standard page) – SegmentedControl in the app */
.sem-tabs {
    display: flex;
    gap: 4px;
    padding: 4px;
    margin: 0 0 1rem;
    max-width: 420px;
    border-radius: var(--radius);
    background: var(--surface-2);
}

.sem-tabs a {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.5rem 0.8rem;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    font-weight: 500;
    color: var(--ink-2);
    text-decoration: none;
    transition: background 0.15s, color 0.15s;
}

.sem-tabs a:hover {
    color: var(--ink);
}

.sem-tabs a.active {
    font-weight: 600;
    color: var(--brand);
    background: var(--surface);
    border-color: var(--line);
}

.sem-bar {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.55rem 0.9rem;
    margin-bottom: 0.8rem;
    border-radius: var(--radius);
    background: var(--brand-soft);
    color: var(--brand);
    font-weight: 600;
    font-size: 0.92rem;
}

.sem-bar .sem-switch {
    flex-shrink: 0;
    padding: 0.15rem 0.7rem;
    border: 1.5px solid currentColor;
    border-radius: 999px;
    color: inherit;
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 600;
}

.sub-heading {
    margin: 1.5rem 0 0.6rem;
    color: var(--ink-2);
    font-size: 0.95rem;
    font-weight: 600;
}

.count-badge {
    color: var(--brand);
    background: var(--brand-soft);
    font-weight: 600;
}

/* grid card (standards, books) – Tile in the app: white card, number or icon in a tinted square, label */
.tile {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.15rem;
    min-height: 7.5rem;
    height: 100%;
    padding: 1rem 0.75rem;
    text-align: center;
    color: var(--ink);
    font-weight: 600;
    line-height: 1.35;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.tile:hover,
.tile:focus-visible {
    color: var(--ink);
    border-color: var(--fun-fg, var(--brand));
    box-shadow: var(--shadow-hover);
}

.tile .tile-big,
.tile .tile-emoji {
    display: grid;
    place-items: center;
    width: 3rem;
    height: 3rem;
    margin-bottom: 0.35rem;
    border-radius: var(--radius);
    color: var(--fun-fg, var(--brand));
    background: var(--fun-bg, var(--brand-soft));
}

.tile .tile-big {
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1;
}

.tile .tile-emoji {
    font-size: 1.4rem;
    line-height: 1;
}

.tile small {
    color: var(--ink-2);
    font-weight: 400;
    font-size: 0.85rem;
}

/* row card: icon, title, hint, chevron (chapter list, book actions, downloads) – ListCard in the app */
.list-card {
    display: flex;
    align-items: center;
    gap: 0.9rem;
    padding: 0.95rem 1.1rem;
    color: var(--ink);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

a.list-card:hover,
button.list-card:hover,
a.list-card:focus-visible {
    color: var(--ink);
    border-color: var(--line-strong);
    box-shadow: var(--shadow-hover);
}

button.list-card {
    width: 100%;
    text-align: start;
}

.list-card.is-disabled {
    opacity: 0.55;
    pointer-events: none;
}

.list-card .list-icon {
    display: grid;
    place-items: center;
    flex-shrink: 0;
    width: 2.75rem;
    height: 2.75rem;
    border-radius: var(--radius);
    font-size: 1.25rem;
}

.list-card .list-title {
    display: block;
    font-weight: 600;
    line-height: 1.4;
}

.list-card .list-hint {
    display: block;
    color: var(--ink-2);
    font-size: 0.875rem;
}

.list-card .chevron {
    margin-left: auto;
    color: var(--ink-3);
}

.soon-badge {
    margin-left: auto;
    padding: 0.1rem 0.6rem;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--ink-2);
    background: var(--surface-2);
    white-space: nowrap;
}

.tone-book { color: var(--fun-4-fg); background: var(--fun-4-bg); }
.tone-download { color: var(--fun-2-fg); background: var(--fun-2-bg); }
.tone-quiz { color: var(--fun-3-fg); background: var(--fun-3-bg); }
.tone-answers { color: var(--fun-5-fg); background: var(--fun-5-bg); }
.tone-video { color: var(--fun-6-fg); background: var(--fun-6-bg); }
.tone-kids { color: var(--accent); background: var(--accent-soft); }

/* numbered chapter row – ChapterCard in the app */
.chapter-row .chapter-no {
    display: grid;
    place-items: center;
    flex-shrink: 0;
    width: 2.75rem;
    height: 2.75rem;
    border-radius: var(--radius);
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--fun-fg, var(--brand));
    background: var(--fun-bg, var(--brand-soft));
}

.chapter-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.1rem;
    color: var(--ink-2);
    font-size: 0.85rem;
}

.mini-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0 0.55rem;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--ink-2);
    background: var(--surface-2);
}

.empty-state {
    padding: 2.5rem 1rem;
    text-align: center;
    color: var(--ink-2);
}

.empty-state .bi {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 2.2rem;
    color: var(--ink-3);
}

/* subject cards (books page) */
.subject-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    height: 100%;
    padding: 1.1rem 0.8rem;
    color: var(--ink);
    text-align: center;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.subject-card:hover {
    color: var(--ink);
    border-color: var(--brand);
    box-shadow: var(--shadow-hover);
}

.subject-avatar {
    display: grid;
    place-items: center;
    width: 3rem;
    height: 3rem;
    border-radius: var(--radius);
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--brand);
    background: var(--brand-soft);
}

.subject-name {
    font-weight: 600;
}

.subject-cta {
    color: var(--brand);
    font-size: 0.875rem;
    font-weight: 600;
}

.semester-pills .nav-link {
    color: var(--ink-2);
    font-weight: 500;
    border-radius: var(--radius-sm);
}

.semester-pills .nav-link.active {
    color: #fff;
    background: var(--brand);
}

/* ----- Home -------------------------------------------------------------- */

.home-intro {
    padding: 1.5rem 0 0.5rem;
}

.home-hero {
    position: relative;
    overflow: hidden;
    padding: clamp(1.5rem, 1rem + 2vw, 2.5rem);
    border-radius: var(--radius-xl);
    background: var(--hero);
    color: #fff;
}

.home-hero::after {
    content: '';
    position: absolute;
    top: -90px;
    right: -60px;
    width: 300px;
    height: 300px;
    border-radius: 50%;
    background: var(--hero-alt);
    pointer-events: none;
}

.home-hero > * {
    position: relative;
    z-index: 1;
}

.home-eyebrow {
    margin: 0 0 0.25rem;
    color: var(--on-hero-muted);
    font-weight: 600;
    font-size: 0.95rem;
}

.home-title {
    margin: 0 0 0.4rem;
    color: #fff;
    font-weight: 700;
    font-size: clamp(1.8rem, 1.3rem + 2vw, 2.6rem);
    line-height: 1.2;
}

.home-subtitle {
    max-width: 38rem;
    margin: 0;
    color: var(--on-hero-muted);
    font-size: 1.05rem;
}

.home-points {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1.25rem;
    margin: 1.25rem 0 0;
    padding: 0;
    list-style: none;
    color: rgba(255, 255, 255, 0.85);
    font-size: 0.92rem;
}

.home-points li {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
}

.home-points .bi {
    color: var(--accent);
}

/* board card – BoardOption in the app: medium mark (ગુ / हि / Aa), logo + name, medium, description */
.board-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    height: 100%;
    padding: 1.1rem 1.15rem;
    color: var(--ink);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.board-card:hover,
.board-card:focus-visible {
    color: var(--ink);
    border-color: var(--brand);
    box-shadow: var(--shadow-hover);
}

.board-card-mark {
    display: grid;
    place-items: center;
    flex-shrink: 0;
    width: 3.5rem;
    height: 3.5rem;
    border-radius: var(--radius-lg);
    color: #fff;
    font-size: 1.6rem;
    font-weight: 700;
    line-height: 1;
    background: var(--medium-fg);
}

.board-card-mark.lang-gu { font-family: 'Hind Vadodara', sans-serif; }
.board-card-mark.lang-hi { font-family: 'Mukta', sans-serif; }
.board-card-mark.lang-en { font-family: 'Inter', sans-serif; }

.board-card-logo {
    display: inline-grid;
    place-items: center;
    flex-shrink: 0;
    width: 1.4rem;
    height: 1.4rem;
    border: 1px solid var(--line);
    border-radius: 50%;
    background: #fff;
    overflow: hidden;
}

.board-card-logo img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.board-card-title {
    margin: 0;
    font-size: 1.15rem;
    font-weight: 700;
}

.board-card-lang {
    display: block;
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--medium-fg);
}

.board-card-desc {
    margin: 0.15rem 0 0;
    color: var(--ink-2);
    font-size: 0.875rem;
    line-height: 1.45;
}

/* ----- Reader -------------------------------------------------------------- */

.reader-bar {
    background: var(--surface);
    border-bottom: 1px solid var(--line);
}

.reader-bar .breadcrumb {
    --bs-breadcrumb-divider-color: var(--ink-3);
    margin: 0;
    font-size: 0.82rem;
    flex-wrap: nowrap;
    overflow: hidden;
    white-space: nowrap;
}

.reader-title {
    color: var(--ink);
    font-weight: 700;
    font-size: 1.05rem;
}

.btn-reader-back {
    --bs-btn-color: var(--ink);
    --bs-btn-bg: #fff;
    --bs-btn-border-color: var(--line);
    --bs-btn-hover-color: var(--brand);
    --bs-btn-hover-bg: var(--brand-soft);
    --bs-btn-hover-border-color: var(--brand);
}

.reader-stage {
    padding: 1rem 0.75rem 7rem;
    background: var(--surface-2);
    min-height: 100%;
}

.reader-canvas {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    justify-content: center;
    gap: 1rem;
}

.reader-canvas canvas {
    max-width: 100%;
    max-height: calc(100vh - 12rem);
    width: auto;
    height: auto;
    border-radius: 4px;
    background: var(--surface);
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.08), 0 10px 30px -18px rgba(15, 23, 42, 0.45);
}

.reader-canvas.double canvas {
    max-width: calc(50% - 0.5rem);
}

/* ---- reader: full screen (only the page; ✕ top-right, page number flashes) */
.reader-fs-close, .reader-fs-pill { display: none; }
.reader-stage { touch-action: pan-y pinch-zoom; }
.reader-stage.is-fullscreen {
    position: fixed;
    inset: 0;
    z-index: 2000;
    padding: 0.5rem;
    min-height: 0;
    background: #141414;
    display: flex;
    align-items: center;
    justify-content: center;
}
.reader-stage.is-fullscreen .reader-row { width: 100%; height: 100%; }
.reader-stage.is-fullscreen .reader-canvas { height: 100%; align-items: center; }
.reader-stage.is-fullscreen .reader-canvas canvas { max-height: calc(100vh - 1rem); max-height: calc(100dvh - 1rem); box-shadow: none; }
.reader-stage.is-fullscreen .reader-nav { position: absolute; bottom: 1.2rem; z-index: 2; background: rgba(0, 0, 0, 0.5); color: #fff; border-color: transparent; }
.reader-stage.is-fullscreen #prevPage { left: 1rem; }
.reader-stage.is-fullscreen #nextPage { right: 1rem; }
.reader-stage.is-fullscreen .reader-nav:disabled { opacity: 0.25; }
.reader-stage.is-fullscreen .reader-fs-close {
    display: grid;
    place-items: center;
    position: absolute;
    top: max(0.8rem, env(safe-area-inset-top));
    right: 0.9rem;
    z-index: 3;
    width: 2.9rem;
    height: 2.9rem;
    border: 0;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
    font-size: 1.25rem;
    cursor: pointer;
}
.reader-stage.is-fullscreen .reader-fs-close:hover { background: rgba(0, 0, 0, 0.8); }
.reader-stage.is-fullscreen .reader-fs-pill {
    display: block;
    position: absolute;
    bottom: 1.5rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 2;
    padding: 0.3rem 0.9rem;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.65);
    color: #fff;
    font-weight: 600;
    font-size: 0.9rem;
    opacity: 0;
    transition: opacity 0.5s;
    pointer-events: none;
}
.reader-stage.is-fullscreen .reader-fs-pill.show { opacity: 1; transition: opacity 0.1s; }
body.reader-is-fullscreen { overflow: hidden; }
body.reader-is-fullscreen .reader-toolbar { display: none; }

.reader-nav {
    flex-shrink: 0;
    display: grid;
    place-items: center;
    width: 2.8rem;
    height: 2.8rem;
    padding: 0;
    border-radius: 50%;
    font-size: 1.3rem;
}

.reader-toolbar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 1rem;
    z-index: 1030;
    display: flex;
    justify-content: center;
    padding: 0 0.75rem;
    pointer-events: none;
}

.reader-toolbar-inner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 0.6rem 1rem;
    padding: 0.55rem 0.8rem;
    border-radius: 999px;
    pointer-events: auto;
    box-shadow: 0 14px 30px -16px rgba(15, 23, 42, 0.45);
}

.reader-page-input {
    width: 3.6rem;
    text-align: center;
    font-weight: 700;
}

.reader-chapter-range {
    color: var(--ink-2);
    font-size: 0.85rem;
}

.download-menu {
    --bs-dropdown-border-color: var(--line);
    --bs-dropdown-border-radius: var(--radius);
    --bs-dropdown-padding-x: 0.4rem;
    --bs-dropdown-padding-y: 0.4rem;
    min-width: 17rem;
    box-shadow: 0 16px 34px -18px rgba(15, 23, 42, 0.45);
}

.download-menu .dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    padding: 0.55rem 0.6rem;
    border-radius: 0.6rem;
    white-space: normal;
}

.download-menu .dropdown-item:active {
    color: var(--ink);
    background: var(--brand-soft);
}

.download-menu .list-icon {
    display: grid;
    place-items: center;
    flex-shrink: 0;
    width: 2.3rem;
    height: 2.3rem;
    border-radius: 0.55rem;
    font-size: 1.1rem;
}

.download-menu .dl-title {
    display: block;
    font-weight: 700;
    line-height: 1.3;
}

.download-menu .dl-hint {
    display: block;
    color: var(--ink-2);
    font-size: 0.82rem;
}

.download-status {
    font-size: 0.85rem;
    color: var(--ink-2);
}

.is-embed .reader-stage {
    padding: 0.5rem 0.25rem 5.5rem;
}

.is-embed .reader-canvas canvas {
    max-height: calc(100vh - 7rem);
}

@media (max-width: 575.98px) {
    .reader-nav {
        width: 2.3rem;
        height: 2.3rem;
        font-size: 1.05rem;
    }

    .reader-toolbar-inner {
        border-radius: var(--radius);
    }
}

/* ----- MCQ practice -------------------------------------------------------- */

.mcq-counter {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--brand);
}

.mcq-score-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.1rem 0.7rem;
    border-radius: 999px;
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--success);
    background: var(--success-soft);
}

.mcq-progress {
    height: 0.4rem;
    border-radius: 999px;
    background: var(--surface-2);
    overflow: hidden;
}

.mcq-progress span {
    display: block;
    height: 100%;
    border-radius: 999px;
    background: var(--brand);
    transition: width 0.3s ease;
}

.mcq-question {
    margin-bottom: 1.1rem;
    font-size: clamp(1.15rem, 1rem + 0.6vw, 1.45rem);
    font-weight: 700;
    line-height: 1.5;
    white-space: pre-line;
}

.mcq-options {
    display: grid;
    gap: 0.6rem;
}

.mcq-option {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    width: 100%;
    padding: 0.75rem 0.9rem;
    text-align: start;
    font: inherit;
    font-weight: 500;
    color: var(--ink);
    background: var(--surface);
    border: 1.5px solid var(--line);
    border-radius: var(--radius);
    transition: border-color 0.15s, background-color 0.15s;
}

.mcq-option:not(:disabled):hover,
.mcq-option:not(:disabled):focus-visible {
    border-color: var(--brand);
    background: var(--brand-soft);
    outline: none;
}

.mcq-letter {
    flex-shrink: 0;
    display: grid;
    place-items: center;
    width: 2.1rem;
    height: 2.1rem;
    border-radius: 0.5rem;
    font-weight: 700;
    color: var(--ink);
    background: var(--surface-2);
}

.mcq-text {
    flex-grow: 1;
}

.mcq-mark {
    font-size: 1.25rem;
}

.mcq-option:disabled {
    cursor: default;
}

.mcq-option:disabled:not(.is-correct):not(.is-wrong) {
    opacity: 0.6;
}

.mcq-option.is-correct {
    border-color: var(--success);
    background: var(--success-soft);
}

.mcq-option.is-correct .mcq-letter {
    color: #fff;
    background: var(--success);
}

.mcq-option.is-correct .mcq-mark {
    color: var(--success);
}

.mcq-option.is-wrong {
    border-color: var(--danger);
    background: var(--danger-soft);
}

.mcq-option.is-wrong .mcq-letter {
    color: #fff;
    background: var(--danger);
}

.mcq-option.is-wrong .mcq-mark {
    color: var(--danger);
}

.mcq-feedback {
    margin-top: 1rem;
    padding: 0.8rem 1rem;
    border-radius: var(--radius);
    border-left: 4px solid;
}

.mcq-feedback.is-correct {
    color: #0d5a33;
    background: var(--success-soft);
    border-color: var(--success);
}

.mcq-feedback.is-wrong {
    color: #7f1d1d;
    background: var(--danger-soft);
    border-color: var(--danger);
}

.mcq-side {
    position: sticky;
    top: 5rem;
}

.mcq-nav {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(2.5rem, 1fr));
    gap: 0.4rem;
}

.mcq-nav-btn {
    height: 2.5rem;
    border: 1.5px solid var(--line);
    border-radius: 0.5rem;
    font-weight: 700;
    color: var(--ink);
    background: var(--surface);
}

.mcq-nav-btn:hover {
    border-color: var(--brand);
}

.mcq-nav-btn.is-current {
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(var(--brand-rgb), 0.18);
}

.mcq-nav-btn.is-correct {
    color: #fff;
    background: var(--success);
    border-color: var(--success);
}

.mcq-nav-btn.is-wrong {
    color: #fff;
    background: var(--danger);
    border-color: var(--danger);
}

.mcq-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem 1rem;
    color: var(--ink-2);
}

.mcq-legend li {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

.mcq-dot {
    width: 0.8rem;
    height: 0.8rem;
    border-radius: 0.25rem;
    border: 1.5px solid var(--line);
    background: var(--surface);
}

.mcq-dot.is-correct {
    background: var(--success);
    border-color: var(--success);
}

.mcq-dot.is-wrong {
    background: var(--danger);
    border-color: var(--danger);
}

.mcq-ring {
    --pct: 0;
    display: grid;
    place-items: center;
    width: 8.5rem;
    height: 8.5rem;
    border-radius: 50%;
    border: 9px solid var(--brand-soft);
    background: var(--surface);
}

.mcq-ring span {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.1rem;
    font-size: 1.1rem;
    color: var(--ink-2);
}

.mcq-ring strong {
    font-size: 2.3rem;
    line-height: 1;
    color: var(--brand);
}

.mcq-review {
    display: grid;
    gap: 0.6rem;
    padding-left: 1.25rem;
}

.mcq-review li {
    padding: 0.7rem 0.9rem;
    border-radius: var(--radius);
    border-left: 4px solid var(--line-strong);
    background: var(--surface-2);
}

.mcq-review li.is-correct {
    border-color: var(--success);
}

.mcq-review li.is-wrong {
    border-color: var(--danger);
}

/* ----- Misc pages --------------------------------------------------------- */
/* ----- Misc pages --------------------------------------------------------- */

.page-intro {
    margin-bottom: 1.25rem;
}

.page-intro .breadcrumb {
    font-size: 0.875rem;
}

.error-icon {
    display: inline-grid;
    place-items: center;
    width: 4.5rem;
    height: 4.5rem;
    border-radius: 50%;
    font-size: 2rem;
    color: var(--warning);
    background: var(--warning-soft);
}

.cursor-pointer {
    cursor: pointer;
}

/* ----- Chapter page: chapter card + action cards (ActionBubble in the app) */

.chapter-hero {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.2rem;
}

.chapter-hero .chapter-big-no {
    display: grid;
    place-items: center;
    flex-shrink: 0;
    width: 3.4rem;
    height: 3.4rem;
    border-radius: var(--radius-lg);
    color: #fff;
    font-size: 1.5rem;
    font-weight: 700;
    background: var(--brand);
}

.action-bubble {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
    width: 100%;
    height: 100%;
    min-height: 9rem;
    padding: 1rem 1.1rem;
    color: var(--ink);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    text-align: start;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

a.action-bubble:hover,
button.action-bubble:hover,
.action-bubble:focus-visible {
    color: var(--ink);
    border-color: var(--fun-fg, var(--brand));
    box-shadow: var(--shadow-hover);
}

.action-bubble.is-disabled {
    opacity: 0.55;
    pointer-events: none;
}

.action-bubble .action-emoji {
    display: grid;
    place-items: center;
    flex-shrink: 0;
    width: 2.75rem;
    height: 2.75rem;
    margin-bottom: 0.6rem;
    border-radius: var(--radius);
    font-size: 1.3rem;
    color: var(--fun-fg, var(--brand));
    background: var(--fun-bg, var(--brand-soft));
}

.action-bubble .action-title {
    font-size: 1.05rem;
    font-weight: 700;
    line-height: 1.35;
}

.action-bubble .action-hint {
    color: var(--ink-2);
    font-size: 0.875rem;
    font-weight: 400;
}

.action-bubble .action-tag {
    align-self: flex-start;
    margin-top: 0.5rem;
    padding: 0 0.6rem;
    border: 1.5px solid var(--line-strong);
    border-radius: 999px;
    color: var(--ink-2);
    font-size: 0.78rem;
    font-weight: 600;
}

/* ----- Readability over the background pattern ----------------------------- */

/* headings outside cards get a soft white glow, so the doodles behind them never cut through the letters */
.section-title,
.sub-heading,
.section-head {
    text-shadow: 0 0 6px #fff, 0 0 12px #fff, 0 0 18px #fff;
}

/* the double border needs room: card grids get a little more space between cards */
@media (max-width: 767.98px) {
    .row.g-2 {
        --bs-gutter-x: 0.75rem;
        --bs-gutter-y: 0.75rem;
    }
}

/* ----- Coloured double border on every card ---------------------------------
   Inner border 2px + white gap + outer ring 2.5px, in the card's own colour: its tint (fun-1 … fun-6) on
   standards, books, chapters and actions, the medium colour on board cards, the brand indigo elsewhere. */
.tile,
.list-card,
.board-card,
.action-bubble,
.surface,
.subject-card {
    --card-tone: var(--fun-fg, var(--brand));
    border: 2px solid color-mix(in srgb, var(--card-tone) 45%, #fff);
    box-shadow:
        0 0 0 3px #fff,
        0 0 0 5.5px color-mix(in srgb, var(--card-tone) 28%, #fff),
        0 8px 18px -10px rgba(27, 35, 51, 0.22);
}

.board-card {
    --card-tone: var(--medium-fg);
}

.tile:hover,
.tile:focus-visible,
a.list-card:hover,
button.list-card:hover,
a.list-card:focus-visible,
.board-card:hover,
.board-card:focus-visible,
a.action-bubble:hover,
button.action-bubble:hover,
.action-bubble:focus-visible,
.subject-card:hover {
    border-color: var(--card-tone);
    box-shadow:
        0 0 0 3px #fff,
        0 0 0 5.5px color-mix(in srgb, var(--card-tone) 55%, #fff),
        0 14px 26px -12px rgba(27, 35, 51, 0.3);
}

/* the outer ring is wider now: a bit more room between cards */
.row.g-2,
.row.g-3 {
    --bs-gutter-x: 1.1rem;
    --bs-gutter-y: 1.1rem;
}

.d-grid.gap-2 {
    gap: 0.9rem !important;
}

/* ----- Board page: small standard cards, one line per stage -------------------- */
.std-row {
    display: flex;
    gap: 1.4rem;
    padding: 8px 6px;          /* room for the outer ring and the hover lift */
    margin: 0 -6px;
}

.tile.tile-sm {
    flex: 0 0 8.5rem;
    min-height: 0;
    height: auto;
    padding: 1rem 0.5rem 0.85rem;
    gap: 0.1rem;
    transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease, background-color 0.18s ease;
}

/* just the coloured number – no tinted square behind it */
.tile.tile-sm .tile-big {
    width: auto;
    height: auto;
    margin: 0;
    font-size: 2.3rem;
    line-height: 1.2;
    background: none;
    transition: transform 0.18s ease;
}

.tile.tile-sm small {
    font-size: 0.95rem;
    line-height: 1.2;
    transition: color 0.18s ease;
}

/* hover: lifts up, takes a light tint of its colour, number grows a little */
.tile.tile-sm:hover,
.tile.tile-sm:focus-visible {
    transform: translateY(-4px);
    background-color: var(--fun-bg, var(--brand-soft));
}

.tile.tile-sm:hover .tile-big,
.tile.tile-sm:focus-visible .tile-big {
    transform: scale(1.12);
}

.tile.tile-sm:hover small,
.tile.tile-sm:focus-visible small {
    color: var(--fun-fg, var(--brand));
}

.tile.tile-sm:active {
    transform: translateY(-1px);
}

/* phones: same size in every row; shrinks a little only when 5 cards would not fit */
@media (max-width: 575.98px) {
    .std-row {
        gap: 0.75rem;
    }

    .tile.tile-sm {
        /* the same size in every row: 6.5rem, or a fifth of the row when the screen is narrower */
        flex: 0 0 min(6.5rem, calc((100% - 4 * 0.75rem) / 5));
        min-width: 0;
        padding: 0.75rem 0.2rem 0.6rem;
    }

    .tile.tile-sm .tile-big {
        font-size: 1.8rem;
    }

    .tile.tile-sm small {
        font-size: 0.82rem;
    }
}

/* ----- Chapter popup (book page) – ChapterSheet in the app ---------------------
   Centred card on larger screens, a bottom sheet on phones. */
.chapter-sheet .modal-content {
    padding: 1.25rem;
    border: 0;
    border-radius: var(--radius-xl);
    box-shadow: 0 24px 60px -20px rgba(15, 23, 42, 0.45);
}

.chapter-sheet .modal-backdrop,
.modal-backdrop.show {
    opacity: 0.45;
}

.sheet-head {
    display: flex;
    align-items: center;
    gap: 0.9rem;
    padding-bottom: 1rem;
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--line);
}

.sheet-head .btn-close {
    align-self: flex-start;
    flex-shrink: 0;
}

.sheet-no {
    display: grid;
    place-items: center;
    flex-shrink: 0;
    width: 3.2rem;
    height: 3.2rem;
    border-radius: var(--radius-lg);
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--fun-fg, var(--brand));
    background: var(--fun-bg, var(--brand-soft));
}

.sheet-title {
    margin: 0 0 0.25rem;
    font-size: 1.15rem;
    font-weight: 700;
    line-height: 1.4;
}

.sheet-actions {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
}

.sheet-action {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
    padding: 0.9rem;
    color: var(--ink);
    background: var(--surface);
    border: 2px solid color-mix(in srgb, var(--fun-fg) 35%, #fff);
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: transform 0.15s ease, background-color 0.15s ease, border-color 0.15s ease;
}

.sheet-action:hover,
.sheet-action:focus-visible {
    color: var(--ink);
    border-color: var(--fun-fg);
    background: var(--fun-bg);
    transform: translateY(-2px);
}

.sheet-action.is-disabled {
    opacity: 0.5;
    cursor: default;
    pointer-events: none;
}

.sheet-icon {
    display: grid;
    place-items: center;
    width: 2.5rem;
    height: 2.5rem;
    border-radius: var(--radius);
    font-size: 1.2rem;
    color: var(--fun-fg);
    background: var(--fun-bg);
}

.sheet-action:hover .sheet-icon {
    background: var(--surface);
}

.sheet-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.sheet-label {
    font-weight: 700;
    line-height: 1.3;
}

.sheet-hint {
    color: var(--ink-2);
    font-size: 0.82rem;
    line-height: 1.35;
}

.sheet-foot {
    display: flex;
    justify-content: space-between;
    gap: 0.75rem;
    margin-top: 1.1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--line);
}

.sheet-foot .btn:disabled {
    visibility: hidden;
}

.sheet-handle {
    width: 2.75rem;
    height: 5px;
    margin: -0.4rem auto 0.9rem;
    border-radius: 3px;
    background: var(--line-strong);
}

/* phones: a sheet sliding up from the bottom, actions in two columns */
@media (max-width: 575.98px) {
    .chapter-sheet .modal-dialog {
        display: flex;
        align-items: flex-end;
        min-height: 100%;
        margin: 0;
        max-width: none;
    }

    .chapter-sheet.fade .modal-dialog {
        transform: translateY(100%);
        transition: transform 0.25s ease-out;
    }

    .chapter-sheet.show .modal-dialog {
        transform: none;
    }

    .chapter-sheet .modal-content {
        border-radius: 20px 20px 0 0;
        padding: 1rem 1rem calc(1rem + env(safe-area-inset-bottom));
    }

    .sheet-actions {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.6rem;
    }

    .sheet-action {
        flex-direction: row;
        align-items: center;
        padding: 0.7rem;
        gap: 0.6rem;
    }

    .sheet-icon {
        flex-shrink: 0;
        width: 2.2rem;
        height: 2.2rem;
        font-size: 1.05rem;
    }

    .sheet-foot .btn {
        font-size: 0.9rem;
        padding: 0.4rem 0.7rem;
    }
}

/* ----- Book page: chapters as small cards in a grid ----------------------------
   1 per row on phones, 2 on tablets, 3 on laptops, 4 on large screens. */
.chapter-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
    padding: 6px;              /* room for the outer ring and the hover lift */
    margin: 0 -6px;
}

@media (min-width: 576px) {
    .chapter-grid { grid-template-columns: repeat(2, 1fr); gap: 1.1rem; }
}

@media (min-width: 992px) {
    .chapter-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (min-width: 1200px) {
    .chapter-grid { grid-template-columns: repeat(4, 1fr); gap: 1.25rem; }
}

.list-card.chapter-card {
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
    height: 100%;
    padding: 0.9rem 1rem 0.85rem;
    transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease, background-color 0.18s ease;
}

.chapter-card-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.chapter-card .chapter-no {
    display: grid;
    place-items: center;
    width: 2.4rem;
    height: 2.4rem;
    border-radius: var(--radius);
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--fun-fg, var(--brand));
    background: var(--fun-bg, var(--brand-soft));
    transition: background-color 0.18s ease;
}

.chapter-card .chevron {
    margin: 0;
    transition: transform 0.18s ease, color 0.18s ease;
}

/* the name: at most 3 lines, the meta row always at the bottom */
.chapter-card .list-title {
    flex-grow: 1;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    font-size: 0.98rem;
    line-height: 1.45;
}

.chapter-card .chapter-meta {
    margin-top: 0;
    font-size: 0.8rem;
}

.chapter-card:hover,
.chapter-card:focus-visible {
    transform: translateY(-3px);
    background-color: var(--fun-bg, var(--brand-soft));
}

.chapter-card:hover .chapter-no {
    background: var(--surface);
}

.chapter-card:hover .chevron {
    color: var(--fun-fg, var(--brand));
    transform: translateX(3px);
}

/* phones: one card per row, number beside the name (shorter cards) */
@media (max-width: 575.98px) {
    .list-card.chapter-card {
        display: grid;
        grid-template-columns: auto 1fr;
        grid-template-areas: "top title" "top meta";
        column-gap: 0.85rem;
        row-gap: 0.25rem;
        align-items: center;
    }

    .chapter-card-top {
        grid-area: top;
    }

    .chapter-card .chevron {
        display: none;
    }

    .chapter-card .list-title {
        grid-area: title;
        -webkit-line-clamp: 2;
    }

    .chapter-card .chapter-meta {
        grid-area: meta;
    }
}

/* chapter popup: download in the header, 4 action cards in one row (2 × 2 on phones) */
.sheet-download {
    flex-shrink: 0;
    align-self: flex-start;
}

.sheet-download .btn {
    display: inline-flex;
    align-items: center;
    padding: 0.4rem 0.85rem;
}

.chapter-sheet .sheet-actions {
    grid-template-columns: repeat(4, 1fr);
}

@media (max-width: 575.98px) {
    .chapter-sheet .sheet-actions {
        grid-template-columns: repeat(2, 1fr);
    }

    .sheet-download .btn {
        padding: 0.4rem 0.65rem;
    }
}

/* reader: a small spinner over the page only when a page takes a moment (the old page stays visible) */
.reader-canvas {
    position: relative;
}

.reader-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: grid;
    place-items: center;
    width: 3rem;
    height: 3rem;
    border-radius: 50%;
    color: var(--brand);
    background: rgba(255, 255, 255, 0.92);
    box-shadow: 0 6px 18px -8px rgba(15, 23, 42, 0.35);
    pointer-events: none;
}

.reader-canvas .empty-state {
    align-self: center;
}

/* ----- Reader zoom ---------------------------------------------------------------- */
.reader-zoom .btn {
    padding-inline: 0.55rem;
}

.reader-zoom-level {
    min-width: 3.6rem;
    font-variant-numeric: tabular-nums;
}

/* zoomed: the reading area scrolls (drag with the mouse, or swipe), the page keeps its zoomed size */
.reader-canvas.zoomed {
    overflow: auto;
    justify-content: flex-start;
    align-items: flex-start;
    max-height: calc(100vh - 12rem);
    max-height: calc(100dvh - 12rem);
    cursor: grab;
    touch-action: pan-x pan-y;
}

.reader-canvas.zoomed.dragging {
    cursor: grabbing;
    user-select: none;
}

.reader-canvas.zoomed canvas {
    max-width: none !important;
    max-height: none !important;
    margin: auto;               /* centred while smaller than the area, and never cut off on the left */
    flex-shrink: 0;
}

.reader-stage.is-fullscreen .reader-canvas.zoomed {
    max-height: calc(100vh - 1rem);
    max-height: calc(100dvh - 1rem);
}

/* ----- Reader: tools in the top bar – the page gets the full height -------------------- */
.reader-tools {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex-shrink: 0;
}

.reader-tool {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    height: 2.1rem;
    padding: 0 0.6rem;
    white-space: nowrap;
}

.reader-tools .reader-zoom .btn {
    height: 2.1rem;
}

.reader-page-box {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    height: 2.1rem;
    padding: 0 0.5rem 0 0.2rem;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius);
    background: var(--surface);
    white-space: nowrap;
}

.reader-page-box .reader-page-input {
    width: 3.2rem;
    height: 1.7rem;
    padding: 0 0.25rem;
    border: 0;
    box-shadow: none;
    text-align: center;
    font-weight: 700;
}

.reader-page-total {
    color: var(--ink-2);
    font-size: 0.85rem;
}

.reader-tools .download-status:empty {
    display: none;
}

.reader-tools .download-status {
    font-size: 0.8rem;
    white-space: nowrap;
}

/* no bottom toolbar any more: the page fills the screen under the top bar */
body:not(.is-embed) .reader-stage {
    padding: 0.6rem 0.5rem 0.6rem;
}

body:not(.is-embed) .reader-canvas canvas {
    max-height: calc(100vh - 5.6rem);
    max-height: calc(100dvh - 5.6rem);
}

body:not(.is-embed) .reader-canvas.zoomed {
    max-height: calc(100vh - 5.6rem);
    max-height: calc(100dvh - 5.6rem);
}

@media (max-width: 575.98px) {
    .reader-title {
        font-size: 0.95rem;
    }

    .reader-tools {
        gap: 0.3rem;
    }

    .reader-tool {
        padding: 0 0.5rem;
    }

    .reader-page-box .reader-page-input {
        width: 2.4rem;
    }
}

/* phones: the ‹ › buttons float over the page edges, so the page gets the full width (swipe also turns pages) */
@media (max-width: 575.98px) {
    body:not(.is-embed) .reader-stage {
        position: relative;
        padding: 0.4rem 0.25rem;
    }

    body:not(.is-embed) .reader-row {
        gap: 0 !important;
    }

    body:not(.is-embed) .reader-stage:not(.is-fullscreen) .reader-nav {
        position: absolute;
        top: 50%;
        z-index: 3;
        width: 2.2rem;
        height: 2.2rem;
        transform: translateY(-50%);
        background: rgba(255, 255, 255, 0.85);
        box-shadow: 0 4px 12px -6px rgba(15, 23, 42, 0.45);
    }

    body:not(.is-embed) .reader-stage:not(.is-fullscreen) #prevPage { left: 0.3rem; }
    body:not(.is-embed) .reader-stage:not(.is-fullscreen) #nextPage { right: 0.3rem; }
    body:not(.is-embed) .reader-stage:not(.is-fullscreen) .reader-nav:disabled { opacity: 0; }
}
