/* =========================================================
   Mobile app shell — design system
   Loaded on public pages only (after style.css, which still
   supplies form/modal/comment basics). Admin never loads this.
   Class prefix: ap-
   ========================================================= */

/* ---------- 1. Tokens ---------- */
:root {
    --ap-font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --ap-serif: "Iowan Old Style", "Palatino Linotype", Palatino, Charter, Georgia, "Times New Roman", serif;
    --ap-max: 600px;
    --ap-tab-h: 60px;
    --ap-safe-b: env(safe-area-inset-bottom, 0px);
    --ap-safe-t: env(safe-area-inset-top, 0px);
    --ap-r-card: 16px;
    --ap-r-btn: 14px;
    --ap-r-cover: 10px;
    --ap-ease: cubic-bezier(.2, .8, .2, 1);
    --ap-spring: cubic-bezier(.34, 1.56, .64, 1);

    color-scheme: light;
    --ap-bg: #F8F7F4;
    --ap-bg-outer: #EFEDE8;
    --ap-surface: #FFFFFF;
    --ap-surface-2: #F1EFEA;
    --ap-surface-3: #E7E4DD;
    --ap-primary: #E94F70;
    --ap-cta: #D1385A;
    --ap-cta-press: #BC2F50;
    --ap-on-cta: #FFFFFF;
    --ap-accent-text: #C22F52;
    --ap-primary-soft: #FFF0F4;
    --ap-blue-soft: #EAF3FF;
    --ap-blue-text: #2F5F9E;
    --ap-text: #171717;
    --ap-text-2: #6B6B6B;
    --ap-border: #EEEEEE;
    --ap-border-strong: #E2DFD8;
    --ap-success: #237548;
    --ap-success-soft: #E8F5EE;
    --ap-warn: #946012;
    --ap-warn-soft: #FFF6E5;
    --ap-error: #C0392B;
    --ap-error-soft: #FDECEA;
    --ap-star: #F5A524;
    --ap-shadow-1: 0 1px 2px rgba(23, 23, 23, .06), 0 2px 8px rgba(23, 23, 23, .05);
    --ap-shadow-2: 0 10px 30px rgba(23, 23, 23, .16), 0 2px 8px rgba(23, 23, 23, .08);
    --ap-scrim: rgba(20, 18, 16, .48);
    --ap-bar-bg: rgba(248, 247, 244, .86);

    /* Legacy tokens (style.css) follow the new palette so old components stay in step */
    --bg: var(--ap-bg);
    --card-bg: var(--ap-surface);
    --card-bg-2: var(--ap-surface-2);
    --border: var(--ap-border-strong);
    --text: var(--ap-text);
    --muted: var(--ap-text-2);
    --primary: var(--ap-cta);
    --gold: var(--ap-accent-text);
    --on-accent: var(--ap-on-cta);
    --success-text: var(--ap-success);
    --success-bg: var(--ap-success-soft);
    --error-text: var(--ap-error);
    --error-bg: var(--ap-error-soft);
    --dark: var(--ap-text);
    --font-display: var(--ap-font);
    --font-body: var(--ap-font);
}

:root[data-theme="dark"] {
    color-scheme: dark;
    --ap-bg: #121214;
    --ap-bg-outer: #0A0A0B;
    --ap-surface: #1C1C1F;
    --ap-surface-2: #26262A;
    --ap-surface-3: #313136;
    --ap-primary: #F2718C;
    --ap-cta: #F2718C;
    --ap-cta-press: #E45C7A;
    --ap-on-cta: #1A1013;
    --ap-accent-text: #F58BA1;
    --ap-primary-soft: rgba(242, 113, 140, .14);
    --ap-blue-soft: rgba(96, 165, 250, .14);
    --ap-blue-text: #8DBBF5;
    --ap-text: #F2F2F3;
    --ap-text-2: #A1A1A8;
    --ap-border: #2A2A2F;
    --ap-border-strong: #38383E;
    --ap-success: #5FCB93;
    --ap-success-soft: rgba(95, 203, 147, .14);
    --ap-warn: #F0B95E;
    --ap-warn-soft: rgba(240, 185, 94, .14);
    --ap-error: #FF8A80;
    --ap-error-soft: rgba(255, 138, 128, .14);
    --ap-shadow-1: 0 0 0 1px rgba(255, 255, 255, .04);
    --ap-shadow-2: 0 12px 32px rgba(0, 0, 0, .6), 0 0 0 1px rgba(255, 255, 255, .05);
    --ap-scrim: rgba(0, 0, 0, .62);
    --ap-bar-bg: rgba(18, 18, 20, .86);
}

@media (prefers-color-scheme: dark) {
    :root[data-theme="system"] {
        color-scheme: dark;
        --ap-bg: #121214;
        --ap-bg-outer: #0A0A0B;
        --ap-surface: #1C1C1F;
        --ap-surface-2: #26262A;
        --ap-surface-3: #313136;
        --ap-primary: #F2718C;
        --ap-cta: #F2718C;
        --ap-cta-press: #E45C7A;
        --ap-on-cta: #1A1013;
        --ap-accent-text: #F58BA1;
        --ap-primary-soft: rgba(242, 113, 140, .14);
        --ap-blue-soft: rgba(96, 165, 250, .14);
        --ap-blue-text: #8DBBF5;
        --ap-text: #F2F2F3;
        --ap-text-2: #A1A1A8;
        --ap-border: #2A2A2F;
        --ap-border-strong: #38383E;
        --ap-success: #5FCB93;
        --ap-success-soft: rgba(95, 203, 147, .14);
        --ap-warn: #F0B95E;
        --ap-warn-soft: rgba(240, 185, 94, .14);
        --ap-error: #FF8A80;
        --ap-error-soft: rgba(255, 138, 128, .14);
        --ap-shadow-1: 0 0 0 1px rgba(255, 255, 255, .04);
        --ap-shadow-2: 0 12px 32px rgba(0, 0, 0, .6), 0 0 0 1px rgba(255, 255, 255, .05);
        --ap-scrim: rgba(0, 0, 0, .62);
        --ap-bar-bg: rgba(18, 18, 20, .86);
    }
}

/* Reader themes remap the whole palette so bars and sheets match the page */
:root[data-reader="light"] {
    color-scheme: light;
    --ap-bg: #FFFFFF; --ap-bg-outer: #F2F2F2; --ap-surface: #FFFFFF; --ap-surface-2: #F3F3F3; --ap-surface-3: #E9E9E9;
    --ap-primary: #E94F70; --ap-cta: #D1385A; --ap-cta-press: #BC2F50; --ap-on-cta: #FFFFFF; --ap-accent-text: #C22F52;
    --ap-primary-soft: #FFF0F4; --ap-text: #1B1B1B; --ap-text-2: #666666; --ap-border: #ECECEC; --ap-border-strong: #E0E0E0;
    --ap-success: #237548; --ap-success-soft: #E8F5EE; --ap-warn: #946012; --ap-warn-soft: #FFF6E5; --ap-error: #C0392B; --ap-error-soft: #FDECEA;
    --ap-shadow-2: 0 10px 30px rgba(23, 23, 23, .16), 0 2px 8px rgba(23, 23, 23, .08);
    --ap-scrim: rgba(20, 18, 16, .48); --ap-bar-bg: rgba(255, 255, 255, .88);
}
:root[data-reader="warm"] {
    color-scheme: light;
    --ap-bg: #F5ECD7; --ap-bg-outer: #EADFC6; --ap-surface: #FBF5E6; --ap-surface-2: #EBE0C6; --ap-surface-3: #E0D3B4;
    --ap-primary: #C7455F; --ap-cta: #B93A55; --ap-cta-press: #A32F49; --ap-on-cta: #FFFFFF; --ap-accent-text: #A8304A;
    --ap-primary-soft: #F6DDD6; --ap-text: #3A2F20; --ap-text-2: #6F5F47; --ap-border: #E5D8BB; --ap-border-strong: #D9CAA6;
    --ap-success: #2C6B44; --ap-success-soft: #E1EBD7; --ap-warn: #85570F; --ap-warn-soft: #F3E4BF; --ap-error: #A93226; --ap-error-soft: #F3DAD0;
    --ap-shadow-2: 0 10px 30px rgba(58, 47, 32, .18), 0 2px 8px rgba(58, 47, 32, .1);
    --ap-scrim: rgba(40, 30, 16, .5); --ap-bar-bg: rgba(245, 236, 215, .88);
}
:root[data-reader="gray"] {
    color-scheme: light;
    --ap-bg: #E6E7E9; --ap-bg-outer: #D9DBDE; --ap-surface: #F0F1F2; --ap-surface-2: #DADCDF; --ap-surface-3: #CDD0D4;
    --ap-primary: #D1385A; --ap-cta: #C22F52; --ap-cta-press: #AE2646; --ap-on-cta: #FFFFFF; --ap-accent-text: #B02748;
    --ap-primary-soft: #F3DCE1; --ap-text: #24262A; --ap-text-2: #565A62; --ap-border: #D5D7DB; --ap-border-strong: #C6C9CE;
    --ap-success: #22693F; --ap-success-soft: #DDEBE3; --ap-warn: #85570F; --ap-warn-soft: #EEE2C8; --ap-error: #A93226; --ap-error-soft: #F0DAD7;
    --ap-shadow-2: 0 10px 30px rgba(36, 38, 42, .18), 0 2px 8px rgba(36, 38, 42, .1);
    --ap-scrim: rgba(20, 22, 26, .5); --ap-bar-bg: rgba(230, 231, 233, .88);
}
:root[data-reader="dark"] {
    color-scheme: dark;
    --ap-bg: #101012; --ap-bg-outer: #0A0A0B; --ap-surface: #19191C; --ap-surface-2: #232327; --ap-surface-3: #2E2E33;
    --ap-primary: #F2718C; --ap-cta: #F2718C; --ap-cta-press: #E45C7A; --ap-on-cta: #1A1013; --ap-accent-text: #F58BA1;
    --ap-primary-soft: rgba(242, 113, 140, .14); --ap-text: #D2D2D6; --ap-text-2: #97979F; --ap-border: #27272B; --ap-border-strong: #35353B;
    --ap-success: #5FCB93; --ap-success-soft: rgba(95, 203, 147, .14); --ap-warn: #F0B95E; --ap-warn-soft: rgba(240, 185, 94, .14); --ap-error: #FF8A80; --ap-error-soft: rgba(255, 138, 128, .14);
    --ap-shadow-2: 0 12px 32px rgba(0, 0, 0, .6), 0 0 0 1px rgba(255, 255, 255, .05);
    --ap-scrim: rgba(0, 0, 0, .62); --ap-bar-bg: rgba(16, 16, 18, .88);
}

/* ---------- 2. Base ---------- */
html { background: var(--ap-bg-outer); -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body.ap {
    margin: 0;
    background: var(--ap-bg-outer);
    color: var(--ap-text);
    font-family: var(--ap-font);
    font-size: 15px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
    overscroll-behavior-y: none;
    width: 100%;
}
.ap *, .ap *::before, .ap *::after { box-sizing: border-box; }
.ap a { color: inherit; text-decoration: none; }
.ap img { max-width: 100%; }
.ap button { font-family: inherit; }
.ap :focus-visible { outline: 2px solid var(--ap-primary); outline-offset: 2px; border-radius: 6px; }
.ap ::selection { background: var(--ap-primary-soft); }
.ap h1, .ap h2, .ap h3, .ap h4 { font-family: var(--ap-font); letter-spacing: -.011em; line-height: 1.25; color: var(--ap-text); margin: 0; }

.ap-sr { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.ap-muted { color: var(--ap-text-2); }
.ap-i { width: 22px; height: 22px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.skip-link { position: absolute; left: 12px; top: -60px; z-index: 300; background: var(--ap-surface); color: var(--ap-text); padding: 10px 14px; border-radius: 10px; box-shadow: var(--ap-shadow-2); }
.skip-link:focus { top: calc(var(--ap-safe-t) + 8px); }

/* ---------- 3. Shell ---------- */
.ap-shell {
    max-width: var(--ap-max);
    margin: 0 auto;
    min-height: 100vh;
    min-height: 100dvh;
    background: var(--ap-bg);
    position: relative;
    overflow-x: clip;
}
@media (min-width: 640px) {
    .ap-shell { box-shadow: 0 0 0 1px var(--ap-border), 0 0 60px rgba(0, 0, 0, .06); }
}
.ap-main { display: block; padding: 0 0 calc(var(--ap-tab-h) + var(--ap-safe-b) + 24px); min-height: 70vh; }
.ap-main.no-tabs { padding-bottom: calc(var(--ap-safe-b) + 32px); }
.ap-main.has-cta { padding-bottom: calc(96px + var(--ap-safe-b)); }
.ap-pad { padding-left: 16px; padding-right: 16px; }

/* Fixed layers are centred to the same column as the shell */
.ap-fixed { position: fixed; left: 50%; transform: translateX(-50%); width: min(100%, var(--ap-max)); z-index: 40; }

/* ---------- 4. Top bars ---------- */
.ap-topbar {
    position: sticky; top: 0; z-index: 30;
    display: flex; align-items: center; gap: 4px;
    min-height: calc(56px + var(--ap-safe-t));
    padding: var(--ap-safe-t) 8px 0;
    background: var(--ap-bar-bg);
    -webkit-backdrop-filter: saturate(1.6) blur(16px);
    backdrop-filter: saturate(1.6) blur(16px);
    border-bottom: 1px solid transparent;
    transition: border-color .2s, background-color .2s;
}
.ap-topbar.is-scrolled { border-bottom-color: var(--ap-border); }
.ap-topbar__title { flex: 1; min-width: 0; font-size: 18px; font-weight: 700; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: 0 4px; }
.ap-topbar__spacer { width: 12px; }
.ap-topbar__actions { display: flex; align-items: center; min-width: 44px; justify-content: flex-end; }
.ap-topbar--left .ap-topbar__title { text-align: left; font-size: 24px; letter-spacing: -.02em; padding-left: 8px; }
.ap-iconbtn {
    width: 44px; height: 44px; flex: none;
    display: inline-flex; align-items: center; justify-content: center;
    background: transparent; border: 0; border-radius: 50%;
    color: var(--ap-text); cursor: pointer; position: relative;
}
.ap-iconbtn:hover { background: var(--ap-surface-2); }
.ap-iconbtn--sm { width: 36px; height: 36px; }
.ap-iconbtn--sm::after { content: ""; position: absolute; inset: -4px; }
.ap-iconbtn--fill { background: var(--ap-surface); box-shadow: var(--ap-shadow-1); }
.ap-iconbtn.is-on { color: var(--ap-primary); }
.ap-iconbtn.is-on .ap-i { animation: ap-pop .42s var(--ap-spring); }
.ap-topbar.is-transparent { position: fixed; left: 50%; transform: translateX(-50%); width: min(100%, var(--ap-max)); background: transparent; -webkit-backdrop-filter: none; backdrop-filter: none; }
.ap-topbar.is-transparent .ap-topbar__title { opacity: 0; transition: opacity .2s; }
.ap-topbar.is-transparent.is-scrolled { background: var(--ap-bar-bg); -webkit-backdrop-filter: saturate(1.6) blur(16px); backdrop-filter: saturate(1.6) blur(16px); }
.ap-topbar.is-transparent.is-scrolled .ap-topbar__title { opacity: 1; }
.ap-topbar.is-transparent .ap-iconbtn { background: rgba(255, 255, 255, .78); color: #171717; -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); }
.ap-topbar.is-transparent.is-scrolled .ap-iconbtn { background: transparent; color: var(--ap-text); }
.ap-topbar.is-transparent .ap-topbar__actions { gap: 8px; }
:root[data-theme="dark"] .ap-topbar.is-transparent:not(.is-scrolled) .ap-iconbtn { background: rgba(20, 20, 22, .6); color: #F2F2F3; }

/* Home header */
.ap-home-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: calc(var(--ap-safe-t) + 12px) 16px 4px 16px; min-height: calc(60px + var(--ap-safe-t)); }
.ap-brand { display: inline-flex; align-items: center; gap: 8px; font-size: 22px; font-weight: 800; letter-spacing: -.03em; color: var(--ap-text); min-height: 44px; }
.ap-brand img { max-height: 30px; width: auto; display: block; }
.ap-hello { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.ap-hello small { font-size: 13px; color: var(--ap-text-2); font-weight: 500; }
.ap-hello strong { font-size: 20px; font-weight: 750; letter-spacing: -.02em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- 5. Tab bar ---------- */
.ap-tabbar {
    position: fixed; left: 50%; transform: translateX(-50%); bottom: 0; z-index: 50;
    width: min(100%, var(--ap-max));
    display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr);
    padding: 6px 4px calc(6px + var(--ap-safe-b));
    background: var(--ap-bar-bg);
    -webkit-backdrop-filter: saturate(1.6) blur(18px);
    backdrop-filter: saturate(1.6) blur(18px);
    border-top: 1px solid var(--ap-border);
}
.ap-tab { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 48px; color: var(--ap-text-2); font-size: 11px; font-weight: 600; letter-spacing: .005em; }
.ap-tab__icon { display: grid; place-items: center; width: min(56px, 100%); height: 30px; border-radius: 15px; transition: background-color .25s var(--ap-ease), color .2s; }
.ap-tab .ap-i { width: 23px; height: 23px; transition: transform .35s var(--ap-spring); }
.ap-tab.is-active { color: var(--ap-accent-text); }
.ap-tab.is-active .ap-tab__icon { background: var(--ap-primary-soft); color: var(--ap-primary); }
.ap-tab.is-active .ap-i { stroke-width: 2.2; transform: translateY(-1px) scale(1.04); }
.ap-tab:active .ap-i { transform: scale(.88); }
.ap-tab__dot { position: absolute; }

/* ---------- 6. Buttons ---------- */
.ap-press { transition: transform .3s var(--ap-spring), background-color .15s, box-shadow .2s; -webkit-user-select: none; user-select: none; }
.ap-press:active { transform: scale(.965); transition-duration: .08s; }
.ap-btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    min-height: 48px; padding: 0 22px;
    border: 0; border-radius: var(--ap-r-btn);
    font-size: 15px; font-weight: 650; letter-spacing: -.005em; line-height: 1.1;
    cursor: pointer; text-align: center; white-space: nowrap;
}
.ap-btn .ap-i { width: 20px; height: 20px; }
.ap-btn--primary { background: var(--ap-cta); color: var(--ap-on-cta); }
.ap-btn--primary:hover { background: var(--ap-cta-press); }
.ap-btn--soft { background: var(--ap-primary-soft); color: var(--ap-accent-text); }
.ap-btn--ghost { background: transparent; color: var(--ap-text); box-shadow: inset 0 0 0 1.5px var(--ap-border-strong); }
.ap-btn--dark { background: var(--ap-text); color: var(--ap-bg); }
.ap-btn--sm { min-height: 44px; padding: 0 18px; font-size: 14px; border-radius: 12px; }
.ap-btn--block { display: flex; width: 100%; }
.ap-btn[disabled], .ap-btn.is-disabled { opacity: .5; pointer-events: none; }
.ap-btn.is-loading { pointer-events: none; color: transparent; position: relative; }
.ap-btn.is-loading::after { content: ""; position: absolute; width: 20px; height: 20px; border-radius: 50%; border: 2.5px solid currentColor; border-color: var(--ap-on-cta) transparent var(--ap-on-cta) transparent; animation: ap-spin .7s linear infinite; }
.ap-linkbtn { background: none; border: 0; padding: 0; min-height: 44px; color: var(--ap-accent-text); font-weight: 600; font-size: 14px; cursor: pointer; }

/* ---------- 7. Chips / tabs ---------- */
.ap-chips { display: flex; gap: 8px; overflow-x: auto; padding: 8px 16px; scrollbar-width: none; -webkit-overflow-scrolling: touch; scroll-padding-inline: 16px; }
.ap-chips::-webkit-scrollbar { display: none; }
.ap-chip {
    position: relative; flex: none;
    display: inline-flex; align-items: center; gap: 6px;
    height: 36px; padding: 0 15px;
    border-radius: 999px; border: 0;
    background: var(--ap-surface); color: var(--ap-text-2);
    box-shadow: inset 0 0 0 1px var(--ap-border-strong);
    font-size: 14px; font-weight: 600; cursor: pointer; white-space: nowrap;
    transition: background-color .2s, color .2s, box-shadow .2s;
}
.ap-chip::after { content: ""; position: absolute; inset: -4px -2px; }
.ap-chip.is-active { background: var(--ap-text); color: var(--ap-bg); box-shadow: none; }
.ap-chips--sticky { position: sticky; top: 0; z-index: 20; background: var(--ap-bar-bg); -webkit-backdrop-filter: saturate(1.6) blur(16px); backdrop-filter: saturate(1.6) blur(16px); padding-top: calc(8px + var(--ap-safe-t)); padding-bottom: 8px; }

.ap-seg { display: flex; gap: 4px; padding: 4px; background: var(--ap-surface-2); border-radius: 14px; }
.ap-seg button, .ap-seg a { flex: 1; min-height: 40px; border: 0; border-radius: 10px; background: transparent; color: var(--ap-text-2); font-size: 14px; font-weight: 650; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; text-align: center; padding: 0 10px; }
.ap-seg .is-active { background: var(--ap-surface); color: var(--ap-text); box-shadow: var(--ap-shadow-1); }

.ap-tabs { display: flex; gap: 22px; padding: 0 16px; overflow-x: auto; scrollbar-width: none; border-bottom: 1px solid var(--ap-border); }
.ap-tabs::-webkit-scrollbar { display: none; }
.ap-tabs a, .ap-tabs button { position: relative; flex: none; min-height: 48px; display: inline-flex; align-items: center; background: none; border: 0; padding: 0 2px; font-size: 16px; font-weight: 650; color: var(--ap-text-2); cursor: pointer; }
.ap-tabs .is-active { color: var(--ap-text); }
.ap-tabs .is-active::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 3px; border-radius: 3px 3px 0 0; background: var(--ap-primary); }

/* ---------- 8. Search bar ---------- */
.ap-search {
    display: flex; align-items: center; gap: 10px;
    width: 100%; min-height: 48px; padding: 0 14px;
    background: var(--ap-surface); border: 0; border-radius: 14px;
    box-shadow: inset 0 0 0 1px var(--ap-border-strong);
    color: var(--ap-text-2); font-size: 15px; text-align: left; cursor: text;
}
.ap-search .ap-i { color: var(--ap-text-2); }
.ap-search input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--ap-text); font: inherit; font-size: 16px; padding: 12px 0; -webkit-appearance: none; appearance: none; }
.ap-search input::placeholder { color: var(--ap-text-2); }
.ap-search:focus-within { box-shadow: inset 0 0 0 2px var(--ap-primary); }
.ap-search__clear { display: none; }
.ap-search.has-value .ap-search__clear { display: inline-flex; }

/* ---------- 9. Sections & rails ---------- */
.ap-section { margin-top: 28px; }
.ap-section__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 16px; min-height: 44px; }
.ap-h2 { font-size: 19px; font-weight: 750; letter-spacing: -.02em; }
.ap-more { display: inline-flex; align-items: center; min-height: 44px; padding-left: 8px; color: var(--ap-text-2); font-size: 14px; font-weight: 600; }
.ap-more .ap-i { width: 16px; height: 16px; margin-left: 2px; }
.ap-rail {
    display: flex; gap: 14px; overflow-x: auto;
    padding: 6px 16px 10px;
    scroll-snap-type: x proximity; scroll-padding-inline: 16px;
    scrollbar-width: none; -webkit-overflow-scrolling: touch; overscroll-behavior-x: contain;
}
.ap-rail::-webkit-scrollbar { display: none; }
.ap-rail > * { flex: none; scroll-snap-align: start; }
.ap-list { display: flex; flex-direction: column; padding: 0 16px; }
.ap-list > .ap-book--row { padding: 14px 0; border-bottom: 1px solid var(--ap-border); }
.ap-list > .ap-book--row:last-child { border-bottom: 0; }
.ap-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 22px 14px; padding: 8px 16px 0; }
@media (min-width: 520px) { .ap-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }

/* ---------- 10. Covers & book cards ---------- */
.ap-cover {
    position: relative; display: block; width: 100%; aspect-ratio: 2 / 3;
    border-radius: var(--ap-r-cover); overflow: hidden;
    background: var(--ap-surface-2);
    box-shadow: 0 1px 2px rgba(23, 23, 23, .1), 0 8px 16px -8px rgba(23, 23, 23, .28), inset 0 0 0 1px rgba(23, 23, 23, .06);
}
:root[data-theme="dark"] .ap-cover { box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .07); }
.ap-cover::after {
    content: ""; position: absolute; inset: 0 auto 0 0; width: 7%;
    background: linear-gradient(90deg, rgba(0, 0, 0, .3), rgba(255, 255, 255, .16) 55%, rgba(255, 255, 255, 0));
    pointer-events: none;
}
.ap-cover img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
.js .ap-cover img { opacity: 0; transition: opacity .3s ease; }
.js .ap-cover img.is-loaded { opacity: 1; }
.ap-cover__fb {
    position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; text-align: center; padding: 14% 12% 14% 16%;
    background: linear-gradient(160deg, hsl(var(--h) 42% 34%), hsl(calc(var(--h) + 34) 48% 20%));
    color: #FFF8F0; font-family: var(--ap-serif); font-weight: 700; font-size: 13px; line-height: 1.2;
}
.ap-cover__fb span { display: -webkit-box; -webkit-line-clamp: 5; -webkit-box-orient: vertical; overflow: hidden; text-wrap: balance; }

.ap-book { display: block; min-width: 0; color: var(--ap-text); }
.ap-book__title { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; font-size: 15px; font-weight: 650; line-height: 1.28; letter-spacing: -.01em; }
.ap-book__author { display: block; font-size: 13px; color: var(--ap-text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ap-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 10px; font-size: 12.5px; color: var(--ap-text-2); }
.ap-meta__item { display: inline-flex; align-items: center; gap: 3px; white-space: nowrap; }
.ap-meta .ap-i { width: 13px; height: 13px; }
.ap-rating .ap-i { color: var(--ap-star); }
.ap-rating { color: var(--ap-text); font-weight: 650; }

.ap-book--rail, .ap-book--grid { display: flex; flex-direction: column; gap: 8px; }
.ap-book--rail { width: clamp(96px, 27vw, 140px); }
.ap-book--rail .ap-book__title, .ap-book--grid .ap-book__title { font-size: 14px; margin-top: 2px; }
.ap-book--grid .ap-book__title { font-size: 15px; }
.ap-book--rail .ap-meta, .ap-book--grid .ap-meta { margin-top: -3px; }
.ap-book--rail .ap-meta__item:nth-child(2), .ap-book--grid .ap-meta__item:nth-child(2) { overflow: hidden; text-overflow: ellipsis; max-width: 100%; }

.ap-book--row { display: grid; grid-template-columns: 84px minmax(0, 1fr); gap: 14px; align-items: start; }
.ap-book--row.has-rank { grid-template-columns: 30px 76px minmax(0, 1fr); gap: 12px; }
.ap-book--row .ap-cover { width: 100%; }
.ap-book__body { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.ap-book--row .ap-book__title { font-size: 16px; }
.ap-book__desc { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; font-size: 13px; line-height: 1.4; color: var(--ap-text-2); }
.ap-book__tags { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 2px; }

.ap-rank { align-self: center; font-size: 20px; font-weight: 750; letter-spacing: -.03em; color: var(--ap-text-2); font-variant-numeric: tabular-nums; text-align: center; opacity: .8; }
.ap-rank--1, .ap-rank--2, .ap-rank--3 { color: var(--ap-primary); opacity: 1; }
.ap-rank--2 { opacity: .78; }
.ap-rank--3 { opacity: .58; }

.ap-tag { display: inline-flex; align-items: center; height: 24px; padding: 0 9px; border-radius: 8px; background: var(--ap-surface-2); color: var(--ap-text-2); font-size: 12px; font-weight: 550; white-space: nowrap; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
a.ap-tag { min-height: 32px; height: auto; padding: 0 12px; font-size: 13px; }
.ap-status { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 650; color: var(--ap-text-2); }
.ap-status::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.ap-status.is-completed { color: var(--ap-success); }
.ap-status.is-hiatus { color: var(--ap-warn); }
.ap-status.is-ongoing { color: var(--ap-blue-text); }

.ap-progress { display: block; height: 4px; border-radius: 4px; background: var(--ap-surface-3); overflow: hidden; }
.ap-progress > span { display: block; height: 100%; border-radius: 4px; background: var(--ap-primary); transition: width .7s var(--ap-ease); }

/* Featured card */
.ap-feature {
    position: relative; display: grid; grid-template-columns: 128px minmax(0, 1fr); gap: 16px;
    margin: 12px 16px 0; padding: 16px;
    border-radius: 22px; background: linear-gradient(140deg, var(--ap-primary-soft), var(--ap-surface) 62%);
    box-shadow: inset 0 0 0 1px var(--ap-border-strong), var(--ap-shadow-1);
}
.ap-feature__cover { display: block; align-self: start; }
.ap-feature__cover .ap-cover { box-shadow: 0 2px 4px rgba(23, 23, 23, .12), 0 14px 24px -10px rgba(23, 23, 23, .4); }
.ap-feature__body { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; min-width: 0; }
.ap-feature__genre { font-size: 12.5px; font-weight: 650; color: var(--ap-accent-text); }
.ap-feature__title { font-size: 21px; font-weight: 780; letter-spacing: -.025em; line-height: 1.15; }
.ap-feature__title a::after { content: ""; position: absolute; inset: 0; border-radius: 22px; }
.ap-feature__author { margin: 0; font-size: 13.5px; color: var(--ap-text-2); }
.ap-feature__desc { margin: 2px 0 0; font-size: 13.5px; line-height: 1.45; color: var(--ap-text-2); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.ap-feature .ap-btn { margin-top: 8px; position: relative; z-index: 1; }
@media (max-width: 359px) { .ap-feature { grid-template-columns: 104px minmax(0, 1fr); gap: 12px; padding: 12px; } .ap-feature__title { font-size: 18px; } }

/* Latest updates rows */
.ap-update { display: grid; grid-template-columns: 52px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--ap-border); min-height: 72px; }
.ap-update:last-child { border-bottom: 0; }
.ap-update .ap-cover { border-radius: 7px; }
.ap-update__t { font-size: 15px; font-weight: 650; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ap-update__s { font-size: 13px; color: var(--ap-text-2); display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ap-update__time { font-size: 12px; color: var(--ap-text-2); white-space: nowrap; }

/* Legal footer */
.ap-legal { margin-top: 36px; padding: 0 16px; text-align: center; color: var(--ap-text-2); font-size: 12.5px; }
.ap-legal nav { display: flex; flex-wrap: wrap; justify-content: center; gap: 0 4px; }
.ap-legal nav a { display: inline-flex; align-items: center; min-height: 44px; padding: 0 8px; color: var(--ap-text-2); font-weight: 550; }
.ap-legal p { margin: 0 0 8px; }

@keyframes ap-pop { 0% { transform: scale(1); } 40% { transform: scale(1.32); } 100% { transform: scale(1); } }
@keyframes ap-spin { to { transform: rotate(360deg); } }

/* Sitewide: no text selection or long-press "callout" menu (Copy/Select/Translate) — form fields, and anything the
   user types into, are the only exception, so search boxes, comments, chapter titles in admin, etc. still work
   normally. Pairs with the contextmenu-blocking script in includes/footer.php. */
html, body { -webkit-user-select: none; -moz-user-select: none; user-select: none; -webkit-touch-callout: none; }
input, textarea, select, [contenteditable="true"], .rich-content[contenteditable] {
    -webkit-user-select: text; -moz-user-select: text; user-select: text; -webkit-touch-callout: default;
}
