html[data-theme="dark"] {
    --page: #101727;
    --surface: #192337;
    --line: #3d4b65;
    --ink: #fff4df;
    --muted: #d0c5b6;
}
.story-night {
    position: relative;
    isolation: isolate;
    overflow: hidden;
    display: grid;
    align-items: center;
    min-height: clamp(15rem, 30vw, 21rem);
    padding: clamp(1.5rem, 5vw, 4rem);
    border: 1px solid #344664;
    border-radius: 1.35rem;
    color: #fff5e1;
    background: radial-gradient(ellipse at 86% 36%, #4b4160 0%, transparent 46%), #121e34;
}
.story-night-text { z-index: 1; max-width: 31rem; }
.story-night h1 { text-wrap: balance; }
.story-night p { color: #e8dcc8; font-size: 1.0625rem; line-height: 1.5; }
.story-night-action {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    margin-top: .4rem;
    padding: .55rem 1.05rem;
    border-radius: .65rem;
    background: #ffd887;
    color: #2a241c;
    font-weight: 700;
    text-decoration: none;
}
.story-night-action:focus-visible { outline-color: #ffedb6; }
.story-sky {
    position: absolute;
    inset: 0 0 0 46%;
    pointer-events: none;
    background:
        radial-gradient(circle at 12% 24%, #ffe3a3 0 1px, transparent 2px),
        radial-gradient(circle at 24% 66%, #ffdfa3 0 2px, transparent 3px),
        radial-gradient(circle at 44% 39%, #ffe4a5 0 1px, transparent 2px),
        radial-gradient(circle at 54% 16%, #ffdf8c 0 1px, transparent 2px),
        radial-gradient(circle at 67% 79%, #ffdf8c 0 1px, transparent 2px),
        radial-gradient(circle at 84% 23%, #ffdf8c 0 2px, transparent 3px),
        radial-gradient(circle at 87% 59%, #ffdf8c 0 1px, transparent 2px);
}
.story-sky::before {
    content: "";
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse at 74% 42%, #f6ba714f, transparent 48%);
}
.story-sky::after {
    content: "";
    position: absolute;
    top: 22%;
    right: 18%;
    width: clamp(3.4rem, 12vw, 8.75rem);
    aspect-ratio: 1;
    border-radius: 50%;
    box-shadow: inset -.8rem -.48rem 0 #ffd88f, .7rem .6rem 2rem -.75rem #ffd58f75;
    transform: rotate(-17deg);
}
.popular-stories { margin-block: clamp(1.75rem, 4vw, 3rem); }
.popular-stories h2 { font: 700 clamp(1.6rem, 4vw, 2.2rem) / 1.2 var(--book-font); margin: 0 0 1rem; }
.top-tales,
.top-more ul,
.author-directory {
    list-style: none;
    padding: 0;
    margin: 0;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 10rem), 1fr));
    gap: .75rem;
}
.top-tale {
    display: grid;
    grid-template-rows: auto 1fr;
    height: 100%;
    border: 1px solid var(--line);
    border-radius: .85rem;
    overflow: clip;
    background: var(--surface);
    text-decoration: none;
}
.top-tale:hover { border-color: var(--accent); }
.top-tale > img,
.top-initial { width: 100%; height: auto; aspect-ratio: 4 / 3; }
.top-tale > img { display: block; object-fit: cover; }
.top-tale > .top-label { padding: .7rem; line-height: 1.27; font-weight: 650; }
.top-label small, .top-more small { display: block; margin-top: .25rem; color: var(--muted); font-weight: 400; }
.top-initial {
    display: grid;
    place-items: center;
    font: 700 2.75rem / 1 var(--book-font);
    color: #ffe1a8;
    background: radial-gradient(ellipse at 70% 25%, #5a4860, #202d46 66%);
}
.top-more { margin-top: 1rem; }
.top-more summary { cursor: pointer; min-height: 44px; width: fit-content; padding-block: .55rem; font-weight: 650; }
.top-more ul,
.author-directory { grid-template-columns: repeat(auto-fit, minmax(min(100%, 14rem), 1fr)); }
.top-more li a,
.author-directory li a {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .45rem;
    min-height: 44px;
    padding: .65rem .75rem;
    border: 1px solid var(--line);
    border-radius: .65rem;
    background: var(--surface);
    text-decoration: none;
    line-height: 1.4;
}
.top-more li a:hover, .author-directory li a:hover { color: var(--accent); border-color: var(--accent); }
.author-directory li a { justify-content: space-between; height: 100%; }
.author-directory span { color: var(--muted); font-variant-numeric: tabular-nums; }
@media (max-width: 40rem) {
    .story-night-text { max-width: 16rem; }
    .story-sky { inset-inline-start: 50%; opacity: .72; }
    .story-sky::after { top: 12%; right: 17%; }
    .top-tales { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .library-paths a { flex-grow: 1; justify-content: center; }
}
.author-search { grid-template-columns: minmax(0, 26rem); margin-bottom: 1.25rem; }
.author-search[hidden], .author-directory > [hidden] { display: none; }
.top-more small { flex-basis: 100%; margin-top: 0; }

/* A quiet star field outside the reading column and catalogue surfaces. */
html {
    --star-ink: #98643082;
    --star-bright: #af763dc9;
    --night-glow: #f5c17144;
}
html[data-theme="dark"] {
    --star-ink: #e7bf7ab3;
    --star-bright: #ffe3a5;
    --night-glow: #9461343d;
}
body {
    background-image:
        radial-gradient(circle at 17px 21px, var(--star-bright) 0 1px, transparent 2px),
        radial-gradient(circle at 85px 74px, var(--star-ink) 0 1px, transparent 2px),
        radial-gradient(circle at 110px 31px, var(--star-ink) 0 1px, transparent 2px),
        radial-gradient(circle at 54px 138px, var(--star-bright) 0 1.2px, transparent 2.5px),
        radial-gradient(circle at 37px 118px, var(--star-ink) 0 .7px, transparent 1.6px),
        radial-gradient(ellipse at 92% 3%, var(--night-glow), transparent 55%);
    background-size: 173px 179px, 223px 153px, 249px 187px, 317px 269px, 281px 271px, 100% 48rem;
    background-repeat: repeat, repeat, repeat, repeat, repeat, no-repeat;
}
.reader > article {
    border-radius: .9rem;
    box-shadow: 0 0 0 clamp(.4rem, 1vw, .85rem) var(--page);
    background: var(--page);
}
.story-comments {
    margin-block: 2.25rem 1.5rem;
    padding: clamp(.75rem, 2vw, 1.125rem);
    border: 1px solid var(--line);
    border-radius: .9rem;
    background: var(--page);
}
.story-comments > h2 {
    margin: 0 0 .6rem;
    font: 700 1.6rem/1.2 var(--book-font);
}
.story-comments-frame { display: block; width: 100%; border: 0; color-scheme: inherit; }

html:not([data-theme="dark"]) body {
    isolation: isolate;
    background-image: radial-gradient(ellipse at 88% 12%, #f3bf6b3b, transparent 52%),
                      radial-gradient(ellipse at 5% 36%, #d2c5ec46, transparent 55%);
    background-size: 100% 50rem;
    background-repeat: no-repeat;
}
html:not([data-theme="dark"]) body:not(.comments-embedded)::before,
html:not([data-theme="dark"]) body:not(.comments-embedded)::after {
    position: fixed;
    z-index: -1;
    color: #a97838;
    pointer-events: none;
    line-height: 1;
}
html:not([data-theme="dark"]) body:not(.comments-embedded)::before {
    content: "✦";
    inset: 19vh auto auto 4vw;
    font-size: clamp(.85rem,2vw,1.6rem);
    text-shadow: 1.5vw 29vh #bc9453a0, -1.5vw 50vh #a9783890, 1vw 71vh #c19761a0;
}
html:not([data-theme="dark"]) body:not(.comments-embedded)::after {
    content: "✧";
    inset: 28vh 4vw auto auto;
    font-size: clamp(.9rem,2.1vw,1.8rem);
    text-shadow: -1vw 26vh #a9783888, 1.3vw 45vh #aa7a4677;
}
html:not([data-theme="dark"]) .story-night {
    color: #382744;
    border-color: #e0c9ad;
    background: radial-gradient(ellipse at 81% 41%, #f8d99c 0%, transparent 43%), linear-gradient(125deg,#fff5e6,#f2dfeb);
}
html:not([data-theme="dark"]) .story-night p { color: #604b62; }
html:not([data-theme="dark"]) .story-sky {
    background: none;
}
html:not([data-theme="dark"]) .story-sky::before {
    content: "✧";
    inset: 12% 11% auto auto;
    color: #a67030;
    background: none;
    font-size: clamp(1.2rem,3vw,2.4rem);
    text-shadow: -8vw 4.5rem #aa713b90, -4vw 8rem #936597aa;
}
html:not([data-theme="dark"]) .story-sky::after {
    box-shadow: inset -.8rem -.48rem 0 #efb14d, .7rem .6rem 2rem -.75rem #e8ad6d9c;
}
.catalogue-home .story-night {
    min-height: clamp(9.5rem, 19vw, 15rem);
    padding-block: clamp(1.15rem, 3.2vw, 2.75rem);
}
.catalogue-home .story-night h1 { font-size: clamp(2rem, 5.2vw, 3.7rem); }
.catalogue-home .story-night p { margin-bottom: 0; }
.catalogue-home .library-paths { margin-block: 1rem 1.45rem; }
.catalogue-home .library-controls { margin-top: .75rem; }
.catalogue-home .browse-topics { margin: 1.05rem 0 1.5rem; }
.catalogue-home .browse-topics summary { cursor: pointer; font-weight: 650; width: fit-content; padding: .45rem 0; }
.catalogue-home .browse-topics nav { margin: .5rem 0 0; }
.catalogue-home .popular-stories { margin-block: 1.5rem 2.2rem; }
.catalogue-home .popular-stories[hidden] { display: none; }
@media (max-width: 42rem) {
    html:not([data-theme="dark"]) body:not(.comments-embedded)::before { left: 1vw; }
    html:not([data-theme="dark"]) body:not(.comments-embedded)::after { right: 1vw; }
    .catalogue-home .library-paths a { justify-content: center; }
}
