:root,
html[data-theme="afternoon"] {
    --story-bg: #f4efe4;
    --story-surface: #ebe3d4;
    --story-surface-strong: #fffaf0;
    --story-text: #20231d;
    --story-muted: #6f7466;
    --story-line: rgba(55, 61, 48, .2);
    --story-accent: #a2472e;
    --story-accent-text: #fff9ef;
    --story-marker: #6f7953;
    --story-shadow: rgba(57, 44, 26, .18);
}

html[data-theme="dusk"] {
    color-scheme: dark;
    --story-bg: #2c211d;
    --story-surface: #3b2b24;
    --story-surface-strong: #49342a;
    --story-text: #f5e8d5;
    --story-muted: #c2a995;
    --story-line: rgba(245, 222, 193, .2);
    --story-accent: #db7440;
    --story-accent-text: #201410;
    --story-marker: #cf9c5e;
    --story-shadow: rgba(0, 0, 0, .34);
}

html[data-theme="night"] {
    color-scheme: dark;
    --story-bg: #101315;
    --story-surface: #191d1f;
    --story-surface-strong: #22272a;
    --story-text: #edf0eb;
    --story-muted: #9ca7a7;
    --story-line: rgba(218, 227, 225, .16);
    --story-accent: #d6a85f;
    --story-accent-text: #14120d;
    --story-marker: #8497a0;
    --story-shadow: rgba(0, 0, 0, .46);
}

html[data-theme="rain"] {
    color-scheme: dark;
    --story-bg: #2d383d;
    --story-surface: #354349;
    --story-surface-strong: #405057;
    --story-text: #edf1ef;
    --story-muted: #b1c0c2;
    --story-line: rgba(225, 237, 238, .18);
    --story-accent: #d0925c;
    --story-accent-text: #1e2426;
    --story-marker: #8fb3b9;
    --story-shadow: rgba(10, 22, 27, .42);
}

html[data-theme="cloudy"] {
    --story-bg: #dfe0dc;
    --story-surface: #d2d4d0;
    --story-surface-strong: #eef0ec;
    --story-text: #292d2b;
    --story-muted: #696f6c;
    --story-line: rgba(47, 54, 50, .2);
    --story-accent: #8f5942;
    --story-accent-text: #fff;
    --story-marker: #65716a;
    --story-shadow: rgba(48, 54, 51, .18);
}

* { box-sizing: border-box; }
html, body { min-width: 320px; min-height: 100%; margin: 0; }
body {
    min-height: 100vh;
    color: var(--story-text);
    background: var(--story-bg);
    font-family: "Segoe UI", "Microsoft YaHei UI", sans-serif;
    transition: color .35s ease, background .35s ease;
}
button, input { font: inherit; }
button { color: inherit; }
button:focus-visible, input:focus-visible, a:focus-visible {
    outline: 2px solid var(--story-accent);
    outline-offset: 3px;
}
.app-shell { width: 100%; min-height: 100vh; }
.wordmark { margin: 0; font-family: "STSong", "SimSun", serif; font-size: 22px; font-weight: 700; letter-spacing: .08em; }
.story-kicker { margin: 0; color: var(--story-accent); font-size: 12px; font-weight: 800; letter-spacing: .16em; }
.spinner { border-color: var(--story-line); border-top-color: var(--story-accent); }

.center-state {
    min-height: 100vh;
    gap: 20px;
    color: var(--story-muted);
    background: var(--story-bg);
}

.login-view {
    width: min(1280px, calc(100% - 64px));
    min-height: 100vh;
    display: grid;
    grid-template-columns: minmax(0, 1.45fr) minmax(340px, 440px);
    align-items: center;
    gap: clamp(56px, 10vw, 160px);
    margin: auto;
    padding: 72px 0;
}
.login-copy { max-width: 720px; }
.login-copy .wordmark { margin-bottom: clamp(70px, 11vh, 130px); }
.login-copy h1 {
    margin: 18px 0 0;
    font-family: "STSong", "SimSun", serif;
    font-size: clamp(54px, 6.2vw, 94px);
    font-weight: 700;
    line-height: 1.08;
    letter-spacing: -.07em;
}
.login-copy > p:not(.wordmark):not(.story-kicker):not(.security-note) {
    max-width: 600px;
    margin: 28px 0 0;
    color: var(--story-muted);
    font-size: 17px;
    line-height: 1.9;
}
.security-note {
    display: inline-block;
    margin: 34px 0 0;
    padding-top: 12px;
    border-top: 1px solid var(--story-line);
    color: var(--story-muted);
    font-size: 13px;
}
.login-card {
    padding: 12px 0 12px 42px;
    border: 0;
    border-left: 1px solid var(--story-line);
    border-radius: 0;
    color: var(--story-text);
    background: transparent;
    box-shadow: none;
    backdrop-filter: none;
}
.login-card__head { margin-bottom: 34px; }
.login-card__head > span { color: var(--story-accent); font-size: 12px; font-weight: 800; letter-spacing: .12em; }
.login-card__head h2 { margin: 12px 0 0; font-family: "STSong", "SimSun", serif; font-size: 36px; letter-spacing: -.04em; }
.login-card__head p { margin: 10px 0 0; color: var(--story-muted); line-height: 1.7; }
.field { gap: 9px; margin-top: 20px; }
.field > span { color: var(--story-muted); font-size: 12px; }
.field input {
    height: 50px;
    padding: 0;
    border: 0;
    border-bottom: 1px solid var(--story-line);
    border-radius: 0;
    outline: 0;
    color: var(--story-text);
    background: transparent;
}
.field input:focus { border-bottom-color: var(--story-accent); box-shadow: none; }
.field input::placeholder { color: color-mix(in srgb, var(--story-muted), transparent 30%); }
.primary-button {
    width: 100%;
    min-height: 50px;
    margin-top: 30px;
    border: 0;
    border-radius: 0;
    color: var(--story-accent-text);
    background: var(--story-accent);
    box-shadow: none;
    font-weight: 750;
}
.form-error {
    border-color: color-mix(in srgb, var(--story-accent), transparent 60%);
    color: var(--story-text);
    background: color-mix(in srgb, var(--story-accent), transparent 88%);
}

.portal-view { width: 100%; min-height: 100vh; overflow-x: hidden; }
.topbar {
    position: relative;
    z-index: 20;
    width: min(1440px, calc(100% - 80px));
    min-height: 64px;
    margin: auto;
    padding: 14px 0 10px;
    border-bottom: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    backdrop-filter: none;
}
.brand-button {
    display: block;
    padding: 0;
    border: 0;
    color: var(--story-text);
    background: transparent;
    text-align: left;
}
.brand-button strong { font-family: "STSong", "SimSun", serif; font-size: 18px; letter-spacing: .08em; }
.ui-icon { width: 1em; height: 1em; flex: 0 0 auto; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.account-area { gap: 18px; }
.theme-note { padding-right: 18px; border-right: 1px solid var(--story-line); color: var(--story-muted); font-size: 11px; font-weight: 500; }
.account-copy strong { color: var(--story-text); }
.account-copy span { color: var(--story-muted); }
.ghost-button {
    min-height: 36px;
    padding: 0 14px;
    border: 1px solid var(--story-line);
    border-radius: 0;
    color: var(--story-text);
    background: transparent;
}
.content-view { width: min(1440px, calc(100% - 80px)); margin: 0 auto; padding: 0 0 28px; }

.story-home {
    min-height: calc(100vh - 64px);
    display: grid;
    grid-template-columns: minmax(300px, 31%) minmax(0, 69%);
    grid-template-rows: minmax(470px, 1fr) auto;
}

.story-heading {
    grid-column: 1;
    grid-row: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    gap: clamp(28px, 4vh, 48px);
    padding: clamp(20px, 3vh, 36px) 46px 24px 8px;
}
.story-title h1 {
    margin: 0;
    font-family: "STSong", "SimSun", serif;
    font-size: clamp(58px, 5vw, 82px);
    line-height: 1.04;
    letter-spacing: -.08em;
    max-width: 100%;
    text-wrap: balance;
    overflow-wrap: anywhere;
}
.story-title i {
    position: relative;
    width: 220px;
    height: 26px;
    display: block;
    margin-top: 14px;
    overflow: visible;
    pointer-events: none;
    background:
        radial-gradient(circle at 34% 47%, var(--story-accent) 0 1px, transparent 1.6px),
        radial-gradient(circle at 52% 34%, var(--story-accent) 0 .9px, transparent 1.5px),
        radial-gradient(circle at 67% 54%, var(--story-accent) 0 .8px, transparent 1.4px),
        radial-gradient(circle at 82% 39%, var(--story-accent) 0 .7px, transparent 1.3px),
        radial-gradient(circle at 93% 51%, var(--story-accent) 0 .6px, transparent 1.2px);
    opacity: .88;
}
.story-title i::before {
    content: "";
    position: absolute;
    left: 0;
    top: 9px;
    width: 100%;
    height: 15px;
    border-top: 1px solid var(--story-accent);
    border-radius: 58% 42% 0 0 / 100% 100% 0 0;
    transform: rotate(.7deg) skewX(-8deg);
    transform-origin: left center;
    opacity: .62;
    filter: drop-shadow(0 0 3px var(--story-accent));
    -webkit-mask-image: linear-gradient(90deg, transparent 0%, #000 7%, #000 78%, transparent 100%);
    mask-image: linear-gradient(90deg, transparent 0%, #000 7%, #000 78%, transparent 100%);
}
.story-title i::after {
    content: "";
    position: absolute;
    left: 14px;
    top: 7px;
    width: 8px;
    height: 8px;
    background: var(--story-accent);
    clip-path: polygon(50% 0, 61% 38%, 100% 50%, 61% 62%, 50% 100%, 39% 62%, 0 50%, 39% 38%);
    filter: drop-shadow(0 0 3px var(--story-accent)) drop-shadow(0 0 8px var(--story-accent));
}
.story-title > p {
    max-width: 300px;
    margin: 20px 0 0;
    color: var(--story-muted);
    font-size: 13px;
    line-height: 1.85;
}
.period-copy { padding: 0; border: 0; }
.period-copy strong { display: block; color: var(--story-marker); font-family: Georgia, serif; font-size: 24px; font-weight: 500; }
.period-copy span { display: block; margin-top: 2px; font-family: "STSong", "SimSun", serif; font-size: 44px; line-height: 1.15; }
.period-copy b { display: block; margin-top: 10px; color: var(--story-text); font-size: 12px; font-weight: 500; }
.period-copy b::first-letter { color: var(--story-marker); }
.period-copy p { max-width: 250px; margin: 12px 0 0; color: var(--story-muted); font-size: 12px; line-height: 1.65; }

.story-stage {
    grid-column: 2;
    grid-row: 1;
    position: relative;
    min-height: 0;
    display: block;
    padding: 0;
}
.story-stage::before {
    content: "";
    position: absolute;
    left: 2%;
    right: -8%;
    top: 57%;
    height: 1px;
    background: color-mix(in srgb, var(--story-marker), transparent 35%);
    transform: rotate(-4deg);
    transform-origin: center;
}
.story-card {
    position: absolute;
    z-index: 1;
    min-width: 0;
    padding: 0;
    border: 0;
    color: var(--story-text);
    background: transparent;
    cursor: pointer;
    text-align: left;
}
.story-card--featured { width: 52%; left: 20%; top: 12%; transform: rotate(-1deg); }
.story-card--side:first-child { width: 17%; left: 0; top: 46%; transform: rotate(-2deg); }
.story-card--side:last-child { width: 15%; right: 8%; top: 46%; transform: rotate(2deg); }
.story-card__media {
    position: relative;
    overflow: hidden;
    display: block;
    border: 8px solid var(--story-surface-strong);
    background: var(--story-surface);
    box-shadow: 0 18px 40px var(--story-shadow);
}
.story-card--featured .story-card__media { aspect-ratio: .96 / 1; }
.story-card--side .story-card__media { aspect-ratio: 3 / 4; }
.story-card__media img { width: 100%; height: 100%; display: block; object-fit: cover; transition: transform .5s ease; }
.story-card:hover .story-card__media img { transform: scale(1.025); }
html[data-theme="night"] .story-card__media img { filter: saturate(.76) contrast(1.08); }
html[data-theme="rain"] .story-card__media img { filter: saturate(.58) contrast(.96); }
html[data-theme="cloudy"] .story-card__media img { filter: saturate(.72) contrast(.96); }
.story-card__empty { width: 100%; height: 100%; display: grid; place-items: center; color: var(--story-muted); }
.story-card__copy { display: block; padding: 12px 3px 0; }
.story-card__date { color: var(--story-muted); font-family: Georgia, serif; font-size: 13px; }
.story-card__copy h2 { margin: 5px 0 0; font-family: "STSong", "SimSun", serif; font-size: clamp(24px, 2.5vw, 40px); line-height: 1.14; }
.story-card--side .story-card__copy h2 { font-size: clamp(17px, 1.5vw, 24px); }
.story-card__copy p { margin: 8px 0 0; color: var(--story-muted); font-size: 12px; line-height: 1.6; }
.story-card__action {
    display: inline-block;
    margin-top: 13px;
    padding-bottom: 4px;
    border-bottom: 1px solid var(--story-accent);
    color: var(--story-accent);
    font-size: 12px;
    font-weight: 750;
}
.story-card--featured .story-card__action {
    position: absolute;
    right: 16px;
    bottom: 16px;
    margin: 0;
    padding: 13px 18px;
    min-width: 140px;
    text-align: center;
    border: 0;
    color: var(--story-accent-text);
    background: var(--story-accent);
}
.story-card--featured .story-card__copy {
    position: absolute;
    left: 20px;
    bottom: 18px;
    max-width: calc(100% - 190px);
    padding: 0;
    color: #fffaf0;
    text-shadow: 0 2px 12px rgba(0, 0, 0, .6);
}
.story-card--featured .story-card__date,
.story-card--featured .story-card__copy p { color: rgba(255, 250, 240, .84); }
.story-card--featured .story-card__copy h2 { font-size: clamp(26px, 2.7vw, 42px); }
.story-empty { min-height: 360px; border-top: 1px solid var(--story-line); border-bottom: 1px solid var(--story-line); }

.story-archive {
    grid-column: 1 / -1;
    grid-row: 2;
    padding: 18px 8px 4px;
    border-top: 1px solid var(--story-line);
}
.archive-heading { display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.archive-heading > strong { font-family: "STSong", "SimSun", serif; font-size: 22px; }
.date-jump { display: inline-flex; align-items: center; gap: 12px; color: var(--story-muted); font-size: 12px; }
.date-jump input {
    min-height: 36px;
    padding: 0 10px;
    border: 1px solid var(--story-line);
    border-radius: 0;
    color: var(--story-text);
    background: transparent;
}
.year-rail, .month-rail, .day-rail { display: flex; align-items: center; overflow-x: auto; scrollbar-width: thin; }
.year-rail { justify-content: center; gap: 10px; margin-top: -32px; }
.month-rail { justify-content: center; gap: 4px; margin-top: 4px; }
.day-rail { justify-content: space-between; gap: 0; margin-top: 6px; padding: 6px 0 2px; border-top: 1px solid var(--story-line); }
.archive-button {
    flex: 0 0 auto;
    min-height: 34px;
    padding: 0 13px;
    border: 0;
    border-bottom: 2px solid transparent;
    color: var(--story-muted);
    background: transparent;
    cursor: pointer;
}
.archive-button:hover { color: var(--story-text); }
.archive-button.active { border-bottom-color: var(--story-marker); color: var(--story-marker); font-weight: 800; }
.archive-button:disabled { opacity: .28; cursor: default; }
.day-button {
    min-width: 30px;
    display: grid;
    gap: 3px;
    justify-items: center;
    padding: 4px 2px;
    border: 1px solid transparent;
    color: var(--story-muted);
    background: transparent;
    cursor: pointer;
}
.day-button strong { font-family: Georgia, serif; font-size: 12px; }
.day-button span { font-size: 9px; }
.day-button.active { border-color: var(--story-marker); color: var(--story-text); background: var(--story-surface); }
.day-button:disabled { opacity: .38; cursor: default; }

.gallery-story { padding-top: 56px; }
.gallery-heading { margin-bottom: 24px; }
.back-button {
    min-height: 38px;
    padding: 0;
    border: 0;
    border-bottom: 1px solid var(--story-line);
    border-radius: 0;
    color: var(--story-muted);
    background: transparent;
}
.gallery-title-row { margin-top: 42px; }
.folder-type-badge {
    display: inline-block;
    padding: 0 0 5px;
    border-bottom: 1px solid var(--story-accent);
    border-radius: 0;
    color: var(--story-accent);
    background: transparent;
}
.gallery-title-row h1 { color: var(--story-text); font-family: "STSong", "SimSun", serif; font-size: clamp(44px, 6vw, 82px); }
.gallery-title-row p, .gallery-stats span { color: var(--story-muted); }
.gallery-stats strong { color: var(--story-text); }
.toolbar {
    border: 0;
    border-top: 1px solid var(--story-line);
    border-bottom: 1px solid var(--story-line);
    border-radius: 0;
    background: transparent;
    box-shadow: none;
}
.search-box {
    min-height: 42px;
    border: 0;
    border-radius: 0;
    color: var(--story-muted);
    background: transparent;
}
.search-box > span { font-size: 11px; font-weight: 700; }
.search-box input { color: var(--story-text); }
.download-hint { color: var(--story-muted); }
.media-grid { gap: 18px; }
.media-card { border: 0; border-radius: 0; color: var(--story-text); background: transparent; }
.media-card__image { border-radius: 0; background: var(--story-surface); }
.media-card__copy span { color: var(--story-muted); }
.empty-state { color: var(--story-muted); }
.empty-state h2 { color: var(--story-text); }

.viewer-dialog { background: rgba(8, 9, 9, .98); }
.viewer-topbar { background: rgba(12, 13, 13, .92); }
.viewer-action, .viewer-nav {
    border-radius: 0;
    color: #f4f4ef;
    background: rgba(255, 255, 255, .07);
}
.viewer-nav { width: auto; min-width: 72px; padding: 0 14px; font-size: 12px; }
.viewer-nav--prev { left: 18px; }
.viewer-nav--next { right: 18px; }

@media (max-width: 980px) {
    .login-view { grid-template-columns: 1fr; gap: 58px; padding: 50px 0; }
    .login-copy .wordmark { margin-bottom: 64px; }
    .login-card { max-width: 520px; padding: 34px 0 0; border-left: 0; border-top: 1px solid var(--story-line); }
    .story-home { display: block; }
    .story-heading { min-height: 540px; }
    .period-copy { display: grid; grid-template-columns: auto auto 1fr; align-items: end; gap: 12px; padding: 0; border-left: 0; }
    .period-copy p { margin: 0 0 4px 12px; }
    .story-stage { grid-template-columns: 1fr 1.35fr; min-height: auto; }
    .story-card--side:last-child { display: none; }
}

@media (max-width: 680px) {
    .login-view, .content-view, .topbar { width: min(100% - 32px, 1390px); }
    .login-copy h1, .story-title h1 { font-size: clamp(42px, 13vw, 64px); }
    .topbar { min-height: 76px; }
    .account-copy { display: none; }
    .story-heading { padding-top: 42px; }
    .period-copy { grid-template-columns: auto auto; }
    .period-copy p { grid-column: 1 / -1; margin-left: 0; }
    .story-stage { display: flex; align-items: stretch; gap: 20px; min-height: 0; margin-right: -16px; padding: 18px 16px 34px 0; overflow-x: auto; }
    .story-stage::before { display: none; }
    .story-card, .story-card--featured, .story-card--side:first-child, .story-card--side:last-child {
        position: relative;
        inset: auto;
        width: min(80vw, 360px);
        flex: 0 0 auto;
        grid-column: auto;
        transform: none;
    }
    .story-card--featured { order: -1; }
    .story-card--side:last-child { display: block; }
    .story-card--side .story-card__media, .story-card--featured .story-card__media { aspect-ratio: 4 / 3; }
    .story-card--featured .story-card__action { position: static; margin-top: 13px; }
    .archive-heading { align-items: flex-start; flex-direction: column; }
    .year-rail, .month-rail { justify-content: flex-start; }
    .date-jump { width: 100%; justify-content: space-between; }
    .gallery-title-row { display: block; }
    .gallery-stats { margin-top: 20px; text-align: left; }
    .toolbar { align-items: stretch; flex-direction: column; }
    .search-box { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        scroll-behavior: auto !important;
        transition: none !important;
    }
}

/* Final theme palette. The reference layout stays unchanged, while each
   administrator-selected atmosphere now controls the complete visitor page. */
:root,
html[data-theme="afternoon"] {
    color-scheme: light;
    --story-bg: #f4efe6;
    --story-surface: #e9e1d2;
    --story-surface-strong: #fffaf1;
    --story-text: #1c1d19;
    --story-muted: #696b5f;
    --story-line: rgba(72, 73, 61, .19);
    --story-accent: #b63b28;
    --story-accent-text: #fffaf0;
    --story-marker: #747a54;
    --story-shadow: rgba(60, 45, 27, .2);
    --story-paper-overlay: linear-gradient(rgba(250, 247, 239, .58), rgba(248, 243, 234, .54));
    --story-paper-blend: multiply;
    --story-image-filter: none;
    --story-compass-filter: none;
}

html[data-theme="dusk"] {
    color-scheme: dark;
    --story-bg: #32231e;
    --story-surface: #473229;
    --story-surface-strong: #5b4033;
    --story-text: #f5e7d3;
    --story-muted: #c6aa92;
    --story-line: rgba(247, 222, 193, .2);
    --story-accent: #d2673c;
    --story-accent-text: #fff7ec;
    --story-marker: #c49a62;
    --story-shadow: rgba(0, 0, 0, .38);
    --story-paper-overlay: linear-gradient(rgba(77, 48, 36, .72), rgba(37, 25, 21, .82));
    --story-paper-blend: soft-light;
    --story-image-filter: saturate(.88) sepia(.08) brightness(.86) contrast(1.04);
    --story-compass-filter: sepia(.45) saturate(.65) brightness(1.35);
}

html[data-theme="night"] {
    color-scheme: dark;
    --story-bg: #11171d;
    --story-surface: #1a232b;
    --story-surface-strong: #28343d;
    --story-text: #edf2ef;
    --story-muted: #9eacb0;
    --story-line: rgba(220, 232, 232, .17);
    --story-accent: #d2a65b;
    --story-accent-text: #17140e;
    --story-marker: #8298a2;
    --story-shadow: rgba(0, 0, 0, .5);
    --story-paper-overlay: linear-gradient(rgba(15, 23, 30, .86), rgba(10, 14, 19, .92));
    --story-paper-blend: soft-light;
    --story-image-filter: saturate(.72) brightness(.78) contrast(1.1);
    --story-compass-filter: grayscale(1) brightness(1.65) contrast(.8);
}

html[data-theme="rain"] {
    color-scheme: light;
    --story-bg: #d9e0df;
    --story-surface: #cbd5d4;
    --story-surface-strong: #edf2f0;
    --story-text: #273134;
    --story-muted: #667477;
    --story-line: rgba(47, 66, 70, .2);
    --story-accent: #8b554e;
    --story-accent-text: #fff;
    --story-marker: #607d82;
    --story-shadow: rgba(42, 57, 61, .2);
    --story-paper-overlay: linear-gradient(rgba(226, 234, 233, .72), rgba(208, 220, 219, .7));
    --story-paper-blend: luminosity;
    --story-image-filter: saturate(.58) brightness(.94) contrast(.98);
    --story-compass-filter: grayscale(.5) hue-rotate(145deg) saturate(.55);
}

html[data-theme="cloudy"] {
    color-scheme: light;
    --story-bg: #e2e2dc;
    --story-surface: #d4d5ce;
    --story-surface-strong: #f1f1eb;
    --story-text: #2a2e2a;
    --story-muted: #6c726c;
    --story-line: rgba(50, 58, 52, .2);
    --story-accent: #8f5942;
    --story-accent-text: #fff;
    --story-marker: #65715f;
    --story-shadow: rgba(48, 54, 49, .2);
    --story-paper-overlay: linear-gradient(rgba(236, 236, 230, .7), rgba(220, 221, 214, .66));
    --story-paper-blend: multiply;
    --story-image-filter: saturate(.76) brightness(.96) contrast(.97);
    --story-compass-filter: grayscale(.22) saturate(.72);
}

body {
    background-color: var(--story-bg);
    background-image:
        var(--story-paper-overlay),
        url("/assets/story/paper-texture.png");
    background-position: center top, center top;
    background-repeat: repeat, repeat;
    background-size: auto, 1254px 1254px;
    background-blend-mode: normal, var(--story-paper-blend);
    -webkit-font-smoothing: antialiased;
    text-rendering: geometricPrecision;
}

html[data-theme] .story-card__media img { filter: var(--story-image-filter); }
html[data-theme] .story-hero-canvas::after { filter: var(--story-compass-filter); }


.app-shell {
    width: 100%;
    max-width: none;
    margin: 0;
    padding: 0;
}

.brand-button,
.ghost-button,
.date-jump,
.month-note,
.archive-legend span {
    display: inline-flex;
    align-items: center;
}

.brand-button { gap: 12px; }
.brand-button > .ui-icon { width: 18px; height: 18px; }
.ghost-button { gap: 9px; }
.ghost-button > .ui-icon { width: 23px; height: 23px; }

.period-copy b {
    position: relative;
    border-top: 0;
    font-style: normal;
}
.period-copy b::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 23px;
    height: 2px;
    background: var(--story-marker);
}
.period-copy b em {
    color: var(--story-accent);
    font-style: normal;
    font-weight: 650;
}
.month-note {
    gap: 8px;
    color: var(--story-muted);
}

.story-card__media { isolation: isolate; }
.story-card__media img {
    position: relative;
    z-index: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.story-card--featured .story-card__media::after {
    content: "";
    position: absolute;
    z-index: 1;
    inset: 34% 0 0;
    background: linear-gradient(to bottom, transparent, rgba(9, 10, 7, .18) 35%, rgba(8, 9, 6, .76) 100%);
    pointer-events: none;
}
.story-card--featured .story-card__copy,
.story-card--featured .story-card__action { z-index: 2; }
.story-card__copy p { display: grid; gap: 4px; }
.story-card__count,
.story-card__description { display: block; }
.story-card__description {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.story-route-label {
    display: none;
    position: absolute;
    z-index: 2;
    min-width: 92px;
    color: var(--story-muted);
    pointer-events: none;
}
.story-route-label b,
.story-route-label small { display: block; }
.story-route-label b {
    font-family: Georgia, "Times New Roman", serif;
    font-size: 12px;
    font-weight: 400;
    letter-spacing: .02em;
}
.story-route-label small {
    margin-top: 7px;
    font-size: 11px;
    white-space: nowrap;
}
.story-route-label small i {
    display: inline-block;
    width: 20px;
    color: var(--story-marker);
    font-family: Georgia, serif;
    font-size: 17px;
    font-style: normal;
    line-height: 10px;
    vertical-align: -2px;
}

.day-rail-wrap {
    display: grid;
    grid-template-columns: 38px minmax(0, 1fr) 38px;
    align-items: start;
    gap: 10px;
}
.archive-arrow {
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    margin-top: 7px;
    padding: 0;
    border: 1px solid var(--story-line);
    border-radius: 50%;
    color: var(--story-muted);
    background: rgba(255, 250, 240, .16);
    cursor: pointer;
}
.archive-arrow .ui-icon { width: 16px; height: 16px; }
.archive-arrow:hover:not(:disabled) { color: var(--story-text); border-color: var(--story-marker); }
.archive-arrow:disabled { opacity: .28; cursor: default; }
.archive-legend {
    display: flex;
    justify-content: center;
    gap: 42px;
    color: var(--story-muted);
    font-size: 11px;
}
.archive-legend span { gap: 8px; }
.legend-dot { width: 7px; height: 7px; border-radius: 50%; }
.archive-legend span:first-child .legend-dot { background: var(--story-marker); }
.archive-legend span:last-child .legend-dot { background: rgba(105, 107, 95, .3); }

.story-hero-viewport,
.story-hero-canvas { display: contents; }

.story-route-layer { display: none; }

@media (min-width: 981px) and (min-aspect-ratio: 4 / 3) {
    :root {
        /* Positions use one 1536 × 714 design field. Only positions may spread
           with the viewport; every visible object keeps one uniform size scale. */
        --ref-header-h: 9.5703125dvh;
        --ref-hero-h: 69.7265625dvh;
        --ref-archive-h: 20.703125dvh;
        --story-hero-scale: 1;
        --story-route-arrow-angle: -24.267deg;
    }

    html,
    body,
    .app-shell,
    .portal-view {
        width: 100%;
        height: 100%;
        min-height: 100%;
    }

    body.story-home-active { overflow: hidden; }
    body.story-home-active .portal-view { overflow: hidden; }

    body.story-home-active .topbar {
        position: relative;
        inset: auto;
        z-index: 30;
        width: 100%;
        max-width: none;
        height: var(--ref-header-h);
        min-height: var(--ref-header-h);
        margin: 0;
        padding: 0 3.2552083vw;
        display: flex;
        align-items: center;
        justify-content: space-between;
        background: transparent;
    }
    body.story-home-active .brand-button { gap: max(8px, calc(12px * var(--story-hero-scale))); }
    body.story-home-active .brand-button > .ui-icon {
        width: max(14px, calc(18px * var(--story-hero-scale)));
        height: max(14px, calc(18px * var(--story-hero-scale)));
    }
    body.story-home-active .brand-button strong {
        font-family: "Noto Serif CJK SC", "Songti SC", "STSong", "SimSun", serif;
        font-size: max(14px, calc(20px * var(--story-hero-scale)));
        font-weight: 520;
        letter-spacing: .09em;
    }
    body.story-home-active .account-area { gap: max(14px, calc(24px * var(--story-hero-scale))); }
    body.story-home-active .theme-note {
        padding-right: max(16px, calc(28px * var(--story-hero-scale)));
        border-right: 1px solid rgba(71, 72, 61, .22);
        font-size: max(9px, calc(12px * var(--story-hero-scale)));
        font-weight: 400;
    }
    body.story-home-active .account-copy { display: none; }
    body.story-home-active .ghost-button {
        min-height: max(26px, calc(32px * var(--story-hero-scale)));
        padding: 0;
        border: 0;
        font-size: max(9px, calc(12px * var(--story-hero-scale)));
        background: transparent;
    }

    body.story-home-active .content-view.story-home {
        position: relative;
        width: 100%;
        max-width: none;
        height: calc(100dvh - var(--ref-header-h));
        min-height: 0;
        margin: 0;
        padding: 0;
        display: grid;
        grid-template-columns: 1fr;
        grid-template-rows: var(--ref-hero-h) var(--ref-archive-h);
        overflow: hidden;
    }
    body.story-home-active .story-home::before { content: none; }

    body.story-home-active .story-hero-viewport {
        position: relative;
        grid-column: 1;
        grid-row: 1;
        display: block;
        width: 100%;
        height: 100%;
        min-width: 0;
        min-height: 0;
        overflow: hidden;
    }
    body.story-home-active .story-hero-canvas {
        position: absolute;
        inset: 0;
        display: block;
        width: 100%;
        height: 100%;
        overflow: hidden;
    }

    /* Curve, markers and arrow use the same normalized coordinate field.
       The curve may adapt to aspect ratio, while the markers and arrow keep
       their own shape and are positioned at the exact matching percentages. */
    body.story-home-active .story-route-layer {
        position: absolute;
        z-index: 0;
        inset: 0;
        display: block;
        width: 100%;
        height: 100%;
        overflow: hidden;
        pointer-events: none;
    }
    body.story-home-active .story-route-curve {
        position: absolute;
        inset: 0;
        display: block;
        width: 100%;
        height: 100%;
        overflow: hidden;
    }
    body.story-home-active .story-route-path {
        fill: none;
        stroke: var(--story-marker);
        stroke-width: 1.2;
        stroke-linecap: round;
        stroke-linejoin: round;
        vector-effect: non-scaling-stroke;
        opacity: .62;
    }
    body.story-home-active .story-route-marker,
    body.story-home-active .story-route-arrow {
        position: absolute;
        z-index: 1;
        display: block;
        box-sizing: border-box;
        transform: translate(-50%, -50%);
    }
    body.story-home-active .story-route-marker {
        width: max(6px, calc(8px * var(--story-hero-scale)));
        height: max(6px, calc(8px * var(--story-hero-scale)));
        border-radius: 50%;
        background: var(--story-marker);
        box-shadow: 0 0 0 max(1px, calc(2px * var(--story-hero-scale))) var(--story-bg);
        opacity: .9;
    }
    body.story-home-active .story-route-marker--start {
        left: 13.8020833%;
        top: 88.7955182%;
        width: max(10px, calc(12px * var(--story-hero-scale)));
        height: max(10px, calc(12px * var(--story-hero-scale)));
        border: max(1px, calc(2px * var(--story-hero-scale))) solid var(--story-marker);
        background: var(--story-bg);
        box-shadow: none;
    }
    body.story-home-active .story-route-marker--left {
        left: 25.8463542%;
        top: 76.5077206%;
    }
    body.story-home-active .story-route-marker--right {
        left: 76.0416667%;
        top: 50.9749860%;
    }
    body.story-home-active .story-route-arrow {
        /* JS reads the SVG path's real rendered endpoint and writes pixel
           coordinates here. The wrapper is a zero-size anchor located exactly
           at that endpoint, so viewport aspect-ratio changes cannot separate
           the arrow from the curve. */
        left: var(--story-route-arrow-x, 95.703125%);
        top: var(--story-route-arrow-y, 35.0140056%);
        width: 0;
        height: 0;
        transform: rotate(var(--story-route-arrow-angle));
        transform-origin: 0 0;
        opacity: .82;
    }
    body.story-home-active .story-route-arrow svg {
        position: absolute;
        right: 0;
        top: 0;
        display: block;
        width: max(20px, calc(28px * var(--story-hero-scale)));
        height: auto;
        aspect-ratio: 28 / 16;
        overflow: visible;
        transform: translateY(-50%);
    }
    body.story-home-active .story-route-arrow path {
        fill: var(--story-marker);
        stroke: none;
    }

    body.story-home-active .story-hero-canvas::after {
        content: "";
        position: absolute;
        z-index: 0;
        /* Anchor the compass from the right edge so wide and narrow desktop
           screens keep it in the same lower-right editorial slot. The top
           coordinate belongs to the same 1536 × 714 hero field, while width
           uses the single uniform scale and therefore never stretches. */
        left: auto;
        right: 3.05%;
        top: 67.10%;
        width: max(82px, calc(106px * var(--story-hero-scale)));
        aspect-ratio: 803 / 870;
        display: block;
        background: url("/assets/story/compass-cropped.png") center / contain no-repeat;
        opacity: .25;
        pointer-events: none;
    }

    body.story-home-active .story-heading {
        position: absolute;
        z-index: 2;
        left: 4.8177083%;
        top: 0;
        width: max(300px, calc(480px * var(--story-hero-scale)));
        height: 100%;
        min-height: 0;
        padding: 0;
        display: flex;
        flex-direction: column;
        align-items: flex-start;
    }
    body.story-home-active .story-title {
        position: relative;
        left: auto;
        top: auto;
        margin-top: 6.4425770%;
    }
    body.story-home-active .story-title h1 {
        margin: 0;
        font-family: "Noto Serif CJK SC", "Songti SC", "STSong", "SimSun", serif;
        font-size: max(58px, calc(92px * var(--story-hero-scale)));
        font-weight: 500;
        line-height: 1.105;
        letter-spacing: -.045em;
        transform: none;
        max-width: max(280px, calc(470px * var(--story-hero-scale)));
        text-wrap: balance;
        overflow-wrap: anywhere;
    }
    body.story-home-active .story-title h1.story-space-name--medium {
        font-size: max(50px, calc(76px * var(--story-hero-scale)));
        letter-spacing: -.035em;
    }
    body.story-home-active .story-title h1.story-space-name--long {
        font-size: max(40px, calc(60px * var(--story-hero-scale)));
        line-height: 1.14;
        letter-spacing: -.02em;
    }
    body.story-home-active .story-title i {
        width: max(170px, calc(230px * var(--story-hero-scale)));
        height: max(20px, calc(27px * var(--story-hero-scale)));
        margin-top: max(12px, calc(18px * var(--story-hero-scale)));
    }
    body.story-home-active .story-title > p { display: none; }

    body.story-home-active .period-copy {
        position: relative;
        left: auto;
        top: auto;
        min-height: 0;
        margin-top: max(28px, calc(44px * var(--story-hero-scale)));
        padding: 0;
    }
    body.story-home-active .period-copy strong {
        font-size: max(18px, calc(27px * var(--story-hero-scale)));
        font-weight: 500;
    }
    body.story-home-active .period-copy span:not(.month-note) {
        margin-top: max(2px, calc(4px * var(--story-hero-scale)));
        font-family: "Noto Serif CJK SC", "Songti SC", "STSong", "SimSun", serif;
        font-size: max(31px, calc(47px * var(--story-hero-scale)));
        font-weight: 500;
    }
    body.story-home-active .period-copy b {
        width: fit-content;
        margin-top: max(10px, calc(15px * var(--story-hero-scale)));
        padding-top: max(10px, calc(15px * var(--story-hero-scale)));
        font-size: max(9px, calc(12px * var(--story-hero-scale)));
        font-weight: 500;
    }
    body.story-home-active .period-copy p { display: none; }
    body.story-home-active .period-copy .month-note {
        margin-top: max(16px, calc(24px * var(--story-hero-scale)));
        font-size: max(9px, calc(12px * var(--story-hero-scale)));
    }
    body.story-home-active .period-copy .month-note .ui-icon {
        width: max(11px, calc(14px * var(--story-hero-scale)));
        height: max(11px, calc(14px * var(--story-hero-scale)));
    }

    body.story-home-active .story-stage {
        position: absolute;
        z-index: 1;
        inset: 0;
        display: block;
        width: 100%;
        height: 100%;
        min-height: 0;
        overflow: visible;
    }
    body.story-home-active .story-stage::before { display: none; }
    body.story-home-active .story-card {
        position: absolute;
        z-index: 3;
    }
    body.story-home-active .story-card--featured {
        left: 42.5781250%;
        top: 12.0448179%;
        width: calc(460px * var(--story-hero-scale));
        transform: rotate(-.6deg);
    }
    body.story-home-active .story-card.story-card--left {
        left: 31.5104167%;
        top: 43.1372549%;
        width: calc(141px * var(--story-hero-scale));
        transform: rotate(-1.05deg);
    }
    body.story-home-active .story-card.story-card--right {
        left: 75%;
        top: 43.9775910%;
        width: calc(137px * var(--story-hero-scale));
        transform: rotate(1.1deg);
    }

    body.story-home-active .story-card__media {
        border-width: max(4px, calc(6px * var(--story-hero-scale)));
        box-shadow: 0 max(10px, calc(15px * var(--story-hero-scale))) max(22px, calc(32px * var(--story-hero-scale))) rgba(65, 48, 27, .19),
                    0 2px 5px rgba(65, 48, 27, .1);
    }
    body.story-home-active .story-card--featured .story-card__media { aspect-ratio: 460 / 482; }
    body.story-home-active .story-card--side .story-card__media { aspect-ratio: 141 / 201; }

    body.story-home-active .story-card--featured .story-card__copy {
        left: calc(26px * var(--story-hero-scale));
        bottom: calc(25px * var(--story-hero-scale));
        max-width: calc(100% - calc(246px * var(--story-hero-scale)));
        padding: 0;
    }
    body.story-home-active .story-card--featured .story-card__date { font-size: calc(13px * var(--story-hero-scale)); }
    body.story-home-active .story-card--featured .story-card__copy h2 {
        margin-top: calc(5px * var(--story-hero-scale));
        font-family: "Noto Serif CJK SC", "Songti SC", "STSong", "SimSun", serif;
        font-size: calc(39px * var(--story-hero-scale));
        font-weight: 500;
        line-height: 1.08;
        letter-spacing: -.025em;
    }
    body.story-home-active .story-card--featured .story-card__copy p {
        margin-top: calc(8px * var(--story-hero-scale));
        font-size: calc(12px * var(--story-hero-scale));
    }
    body.story-home-active .story-card--featured .story-card__action {
        right: calc(25px * var(--story-hero-scale));
        bottom: calc(27px * var(--story-hero-scale));
        min-width: calc(192px * var(--story-hero-scale));
        padding: calc(10px * var(--story-hero-scale)) calc(27px * var(--story-hero-scale));
        border: 0;
        font-family: "Noto Serif CJK SC", "Songti SC", "STSong", "SimSun", serif;
        font-size: calc(16px * var(--story-hero-scale));
        font-weight: 500;
        line-height: 1.35;
    }
    body.story-home-active .story-card--featured .story-card__action::after {
        content: "→";
        margin-left: calc(28px * var(--story-hero-scale));
        font-size: 1.15em;
    }

    body.story-home-active .story-card--side .story-card__copy { padding: calc(13px * var(--story-hero-scale)) 2px 0; }
    body.story-home-active .story-card--side .story-card__date { font-size: calc(12px * var(--story-hero-scale)); }
    body.story-home-active .story-card--side .story-card__copy h2 {
        margin-top: calc(7px * var(--story-hero-scale));
        font-family: "Noto Serif CJK SC", "Songti SC", "STSong", "SimSun", serif;
        font-size: calc(23px * var(--story-hero-scale));
        font-weight: 500;
        line-height: 1.14;
        letter-spacing: -.025em;
    }
    body.story-home-active .story-card--side .story-card__copy p {
        margin-top: calc(7px * var(--story-hero-scale));
        font-size: calc(11px * var(--story-hero-scale));
        line-height: 1.55;
    }
    body.story-home-active .story-card--side .story-card__action { display: none; }

    body.story-home-active .story-route-label { display: block; }
    body.story-home-active .story-route-label--left { left: 24.4140625%; top: 56.1624650%; }
    body.story-home-active .story-route-label--right { left: 74.4140625%; top: 31.5126050%; }
    body.story-home-active .story-route-label b { font-size: calc(12px * var(--story-hero-scale)); }
    body.story-home-active .story-route-label small {
        margin-top: calc(7px * var(--story-hero-scale));
        font-size: calc(11px * var(--story-hero-scale));
    }
    body.story-home-active .story-route-label small i {
        width: calc(20px * var(--story-hero-scale));
        font-size: calc(17px * var(--story-hero-scale));
    }

    body.story-home-active .story-empty {
        position: absolute;
        inset: 21% 28% 17%;
        z-index: 5;
    }

    body.story-home-active .story-archive {
        position: relative;
        z-index: 4;
        grid-column: 1;
        grid-row: 2;
        width: 100%;
        height: var(--ref-archive-h);
        min-height: 0;
        margin: 0;
        padding: calc(24px * var(--story-hero-scale)) 4.8177083vw 0;
        border-top: 1px solid rgba(71, 72, 61, .2);
        overflow: hidden;
        background: transparent;
    }
    body.story-home-active .archive-heading {
        justify-content: flex-start;
        gap: max(28px, calc(42px * var(--story-hero-scale)));
    }
    body.story-home-active .archive-heading > strong {
        font-family: "Noto Serif CJK SC", "Songti SC", "STSong", "SimSun", serif;
        font-size: max(15px, calc(22px * var(--story-hero-scale)));
        font-weight: 500;
    }
    body.story-home-active .date-jump {
        position: relative;
        gap: max(6px, calc(9px * var(--story-hero-scale)));
        min-height: max(22px, calc(29px * var(--story-hero-scale)));
        color: var(--story-muted);
        font-size: max(9px, calc(12px * var(--story-hero-scale)));
        cursor: pointer;
    }
    body.story-home-active .date-jump .ui-icon {
        width: max(13px, calc(18px * var(--story-hero-scale)));
        height: max(13px, calc(18px * var(--story-hero-scale)));
    }
    body.story-home-active .date-jump input {
        position: absolute;
        inset: 0;
        width: 100%;
        height: 100%;
        min-height: 0;
        padding: 0;
        border: 0;
        opacity: 0;
        cursor: pointer;
    }
    body.story-home-active .year-rail {
        justify-content: center;
        gap: calc(18px * var(--story-hero-scale));
        margin-top: calc(-35px * var(--story-hero-scale));
        overflow: visible;
    }
    body.story-home-active .year-rail .archive-button {
        min-width: calc(64px * var(--story-hero-scale));
        min-height: calc(34px * var(--story-hero-scale));
        font-family: Georgia, "Times New Roman", serif;
        font-size: calc(18px * var(--story-hero-scale));
    }
    body.story-home-active .year-rail .archive-button.active {
        font-size: calc(24px * var(--story-hero-scale));
        font-weight: 500;
    }
    body.story-home-active .month-rail {
        justify-content: center;
        gap: calc(13px * var(--story-hero-scale));
        margin-top: calc(11px * var(--story-hero-scale));
        overflow: visible;
    }
    body.story-home-active .month-rail .archive-button {
        min-width: calc(50px * var(--story-hero-scale));
        min-height: calc(34px * var(--story-hero-scale));
        padding: 0 calc(9px * var(--story-hero-scale));
        font-family: "Noto Serif CJK SC", "Songti SC", "STSong", "SimSun", serif;
        font-size: calc(13px * var(--story-hero-scale));
    }
    body.story-home-active .archive-button:disabled { opacity: .55; }
    body.story-home-active .day-rail-wrap {
        margin: calc(1px * var(--story-hero-scale)) 0 0;
        grid-template-columns: calc(38px * var(--story-hero-scale)) minmax(0, 1fr) calc(38px * var(--story-hero-scale));
        gap: calc(10px * var(--story-hero-scale));
    }
    body.story-home-active .day-rail {
        justify-content: space-between;
        margin: calc(8px * var(--story-hero-scale)) 0 0;
        padding: calc(6px * var(--story-hero-scale)) 4px 0;
        overflow: visible;
    }
    body.story-home-active .day-button {
        min-width: calc(28px * var(--story-hero-scale));
        padding: calc(3px * var(--story-hero-scale)) 1px;
    }
    body.story-home-active .day-button strong { font-size: calc(12px * var(--story-hero-scale)); }
    body.story-home-active .day-button span { font-size: max(6px, calc(8px * var(--story-hero-scale))); }
    body.story-home-active .day-button.active {
        border-color: transparent;
        color: var(--story-marker);
        background: transparent;
    }
    body.story-home-active .day-button.active span { color: var(--story-marker); }
    body.story-home-active .archive-arrow {
        width: max(24px, calc(34px * var(--story-hero-scale)));
        height: max(24px, calc(34px * var(--story-hero-scale)));
        margin-top: max(5px, calc(7px * var(--story-hero-scale)));
    }
    body.story-home-active .archive-legend {
        margin-top: calc(10px * var(--story-hero-scale));
        font-size: max(8px, calc(11px * var(--story-hero-scale)));
    }
}

@media (max-width: 980px) {
    .story-route-label { display: none; }
    .day-rail-wrap {
        grid-template-columns: 34px minmax(0, 1fr) 34px;
        gap: 6px;
    }
    .archive-arrow { width: 32px; height: 32px; }
    .day-rail { margin-inline: 0; }
}

@media (max-width: 680px) {
    .day-rail-wrap {
        grid-template-columns: 30px minmax(0, 1fr) 30px;
        gap: 4px;
    }
    .archive-arrow { width: 28px; height: 28px; margin-top: 9px; }
}

/* =====================================================================
   Story 12.3 — mobile editorial layout
   Mobile does not reuse the absolute desktop canvas. The title, period,
   cards and archive return to normal document flow so there is no horizontal
   clipping, overlap or viewport-dependent drift.
   ===================================================================== */
@media (max-width: 980px) {
    html,
    body,
    .app-shell,
    .portal-view {
        width: 100%;
        height: auto;
        min-height: 100%;
    }

    body.story-home-active {
        overflow-x: hidden;
        overflow-y: auto;
    }
    body.story-home-active .portal-view { overflow: visible; }

    body.story-home-active .topbar {
        position: relative;
        inset: auto;
        z-index: 20;
        width: 100%;
        min-height: 60px;
        margin: 0;
        padding: max(12px, env(safe-area-inset-top)) max(20px, env(safe-area-inset-right)) 10px max(20px, env(safe-area-inset-left));
        display: flex;
        align-items: center;
        justify-content: space-between;
        background: transparent;
    }
    body.story-home-active .brand-button { gap: 9px; }
    body.story-home-active .brand-button > .ui-icon { width: 15px; height: 15px; }
    body.story-home-active .brand-button strong {
        font-family: "Noto Serif CJK SC", "Songti SC", "STSong", "SimSun", serif;
        font-size: 16px;
        font-weight: 520;
        letter-spacing: .07em;
    }
    body.story-home-active .account-area { gap: 10px; }
    body.story-home-active .account-copy { display: none; }
    body.story-home-active .theme-note {
        padding-right: 10px;
        font-size: 10px;
    }
    body.story-home-active .ghost-button {
        min-height: 32px;
        padding: 0 9px;
        border-color: var(--story-line);
        font-size: 11px;
    }

    body.story-home-active .content-view.story-home {
        width: 100%;
        min-height: 0;
        margin: 0;
        padding: 0;
        display: block;
        overflow: visible;
    }
    body.story-home-active .story-hero-viewport,
    body.story-home-active .story-hero-canvas {
        position: relative;
        inset: auto;
        width: 100%;
        height: auto;
        min-height: 0;
        display: block;
        overflow: visible;
    }
    body.story-home-active .story-hero-canvas {
        padding: 22px max(20px, env(safe-area-inset-right)) 0 max(20px, env(safe-area-inset-left));
    }
    body.story-home-active .story-hero-canvas::after,
    body.story-home-active .story-route-layer,
    body.story-home-active .story-route-label { display: none !important; }

    body.story-home-active .story-heading {
        position: relative;
        inset: auto;
        width: 100%;
        height: auto;
        min-height: 0;
        padding: 0;
        display: block;
    }
    body.story-home-active .story-title,
    body.story-home-active .period-copy {
        position: relative;
        inset: auto;
        width: 100%;
    }
    body.story-home-active .story-title h1 {
        margin: 0;
        font-family: "Noto Serif CJK SC", "Songti SC", "STSong", "SimSun", serif;
        font-size: clamp(46px, 12vw, 72px);
        font-weight: 500;
        line-height: 1.05;
        letter-spacing: -.055em;
        text-wrap: balance;
        overflow-wrap: anywhere;
    }
    body.story-home-active .story-title h1.story-space-name--medium {
        font-size: clamp(40px, 10.5vw, 62px);
    }
    body.story-home-active .story-title h1.story-space-name--long {
        font-size: clamp(32px, 8.6vw, 50px);
        line-height: 1.12;
        letter-spacing: -.02em;
    }
    body.story-home-active .story-title i {
        width: min(58vw, 190px);
        height: 22px;
        margin-top: 12px;
    }
    body.story-home-active .story-title i::after {
        left: 11px;
        top: 7px;
        width: 7px;
        height: 7px;
    }
    body.story-home-active .story-title > p {
        max-width: 30em;
        margin: 15px 0 0;
        font-size: 12px;
        line-height: 1.8;
    }

    body.story-home-active .period-copy {
        margin-top: 22px;
        padding: 16px 0 15px;
        display: grid;
        grid-template-columns: minmax(84px, auto) minmax(0, 1fr);
        grid-template-rows: auto auto auto;
        column-gap: 22px;
        row-gap: 4px;
        align-items: start;
        border-top: 1px solid var(--story-line);
        border-bottom: 1px solid var(--story-line);
    }
    body.story-home-active .period-copy strong {
        grid-column: 1;
        grid-row: 1;
        display: block;
        margin: 0;
        color: var(--story-marker);
        font-size: 20px;
        line-height: 1.2;
    }
    body.story-home-active .period-copy > span:not(.month-note) {
        grid-column: 1;
        grid-row: 2;
        display: block;
        margin: 2px 0 0;
        font-family: "Noto Serif CJK SC", "Songti SC", "STSong", "SimSun", serif;
        font-size: 36px;
        line-height: 1.15;
    }
    body.story-home-active .period-copy b {
        grid-column: 2;
        grid-row: 1;
        width: fit-content;
        margin: 0;
        padding: 10px 0 0;
        font-size: 11px;
        line-height: 1.5;
    }
    body.story-home-active .period-copy p { display: none; }
    body.story-home-active .period-copy .month-note {
        grid-column: 1 / -1;
        grid-row: 3;
        display: inline-flex;
        align-items: center;
        justify-self: start;
        gap: 7px;
        margin: 12px 0 0;
        color: var(--story-muted);
        font-family: "Segoe UI", "Microsoft YaHei UI", sans-serif;
        font-size: 11px !important;
        font-weight: 400;
        line-height: 1.4;
        letter-spacing: 0;
    }
    body.story-home-active .period-copy .month-note .ui-icon {
        width: 13px;
        height: 13px;
    }

    body.story-home-active .story-stage {
        position: relative;
        inset: auto;
        z-index: 1;
        width: 100%;
        height: auto;
        min-height: 0;
        margin: 24px 0 0;
        padding: 0;
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 22px 16px;
        align-items: start;
        overflow: visible;
    }
    body.story-home-active .story-stage::before { display: none; }
    body.story-home-active .story-card,
    body.story-home-active .story-card--featured,
    body.story-home-active .story-card--side:first-child,
    body.story-home-active .story-card--side:last-child,
    body.story-home-active .story-card.story-card--left,
    body.story-home-active .story-card.story-card--right {
        position: relative;
        inset: auto;
        width: auto;
        min-width: 0;
        margin: 0;
        transform: none;
        overflow: visible;
    }
    body.story-home-active .story-card--featured {
        grid-column: 1 / -1;
        order: -2;
    }
    body.story-home-active .story-card--left { order: -1; }
    body.story-home-active .story-card--right { order: 0; }
    body.story-home-active .story-card__media {
        width: 100%;
        border-width: 5px;
        box-shadow: 0 12px 26px rgba(65, 48, 27, .16), 0 2px 5px rgba(65, 48, 27, .08);
    }
    body.story-home-active .story-card--featured .story-card__media { aspect-ratio: 4 / 5; }
    body.story-home-active .story-card--side .story-card__media { aspect-ratio: 3 / 4; }
    body.story-home-active .story-card--featured .story-card__copy {
        left: 18px;
        right: 18px;
        bottom: 18px;
        max-width: calc(100% - 36px);
        padding: 0 0 52px;
    }
    body.story-home-active .story-card--featured .story-card__date { font-size: 12px; }
    body.story-home-active .story-card--featured .story-card__copy h2 {
        margin-top: 4px;
        font-size: clamp(28px, 8vw, 42px);
        line-height: 1.08;
    }
    body.story-home-active .story-card--featured .story-card__copy p {
        margin-top: 7px;
        font-size: 11px;
    }
    body.story-home-active .story-card--featured .story-card__action {
        right: 16px;
        bottom: 17px;
        min-width: 132px;
        padding: 10px 15px;
        font-size: 13px;
    }
    body.story-home-active .story-card--featured .story-card__action::after {
        content: "→";
        margin-left: 18px;
    }
    body.story-home-active .story-card--side .story-card__copy {
        min-width: 0;
        padding: 10px 1px 0;
    }
    body.story-home-active .story-card--side .story-card__date { font-size: 11px; }
    body.story-home-active .story-card--side .story-card__copy h2 {
        max-width: 100%;
        margin-top: 5px;
        overflow: hidden;
        color: var(--story-text);
        font-size: clamp(17px, 4.8vw, 23px);
        line-height: 1.2;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    body.story-home-active .story-card--side .story-card__copy p {
        margin-top: 6px;
        font-size: 10px;
        line-height: 1.5;
    }
    body.story-home-active .story-card--side .story-card__action { display: none; }

    body.story-home-active .story-archive {
        position: relative;
        inset: auto;
        width: 100%;
        height: auto;
        min-height: 0;
        margin: 30px 0 0;
        padding: 22px max(20px, env(safe-area-inset-right)) calc(28px + env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left));
        border-top: 1px solid var(--story-line);
        overflow: hidden;
    }
    body.story-home-active .archive-heading {
        display: grid;
        grid-template-columns: 1fr;
        gap: 14px;
        align-items: start;
    }
    body.story-home-active .archive-heading > strong {
        font-family: "Noto Serif CJK SC", "Songti SC", "STSong", "SimSun", serif;
        font-size: 24px;
        font-weight: 600;
    }
    body.story-home-active .date-jump {
        width: 100%;
        min-height: 42px;
        padding: 0 12px;
        display: grid;
        grid-template-columns: auto auto minmax(0, 1fr);
        align-items: center;
        gap: 8px;
        border: 1px solid var(--story-line);
        color: var(--story-muted);
        font-size: 12px;
    }
    body.story-home-active .date-jump .ui-icon { width: 15px; height: 15px; }
    body.story-home-active .date-jump input {
        position: static;
        inset: auto;
        width: 100%;
        min-width: 0;
        height: 40px;
        min-height: 40px;
        margin: 0;
        padding: 0;
        border: 0;
        opacity: 1;
        color: var(--story-text);
        background: transparent;
        text-align: right;
        color-scheme: light;
    }
    body.story-home-active .year-rail,
    body.story-home-active .month-rail,
    body.story-home-active .day-rail {
        width: 100%;
        justify-content: flex-start;
        overflow-x: auto;
        overflow-y: hidden;
        scrollbar-width: none;
        overscroll-behavior-inline: contain;
        scroll-snap-type: x proximity;
        -webkit-overflow-scrolling: touch;
    }
    body.story-home-active .year-rail::-webkit-scrollbar,
    body.story-home-active .month-rail::-webkit-scrollbar,
    body.story-home-active .day-rail::-webkit-scrollbar { display: none; }
    body.story-home-active .year-rail {
        gap: 8px;
        margin-top: 18px;
        padding: 0 1px 2px;
    }
    body.story-home-active .month-rail {
        gap: 4px;
        margin-top: 8px;
        padding: 0 1px 2px;
    }
    body.story-home-active .year-rail .archive-button,
    body.story-home-active .month-rail .archive-button {
        scroll-snap-align: center;
    }
    body.story-home-active .year-rail .archive-button {
        min-width: 62px;
        min-height: 38px;
        padding: 0 10px;
        font-family: Georgia, "Times New Roman", serif;
        font-size: 17px;
    }
    body.story-home-active .year-rail .archive-button.active { font-size: 21px; }
    body.story-home-active .month-rail .archive-button {
        min-width: 48px;
        min-height: 38px;
        padding: 0 9px;
        font-size: 14px;
    }
    body.story-home-active .day-rail-wrap {
        width: 100%;
        margin: 7px 0 0;
        grid-template-columns: 30px minmax(0, 1fr) 30px;
        gap: 6px;
        align-items: start;
        overflow: hidden;
    }
    body.story-home-active .day-rail {
        gap: 2px;
        margin: 0;
        padding: 7px 0 2px;
        border-top: 1px solid var(--story-line);
    }
    body.story-home-active .day-button {
        min-width: 36px;
        padding: 5px 1px;
        scroll-snap-align: center;
    }
    body.story-home-active .day-button strong { font-size: 12px; }
    body.story-home-active .day-button span { font-size: 8px; }
    body.story-home-active .archive-arrow {
        width: 28px;
        height: 28px;
        margin-top: 8px;
    }
    body.story-home-active .archive-legend {
        margin-top: 13px;
        gap: 26px;
        font-size: 10px;
    }
}

@media (max-width: 640px) {
    body.story-home-active .topbar {
        min-height: 54px;
        padding-left: max(16px, env(safe-area-inset-left));
        padding-right: max(16px, env(safe-area-inset-right));
    }
    body.story-home-active .theme-note { display: none; }
    body.story-home-active .ghost-button {
        width: 34px;
        height: 34px;
        min-height: 34px;
        padding: 0;
        display: grid;
        place-items: center;
        border-radius: 50%;
    }
    body.story-home-active .ghost-button span { display: none; }
    body.story-home-active .ghost-button > .ui-icon { width: 18px; height: 18px; }

    body.story-home-active .story-hero-canvas {
        padding-top: 16px;
        padding-left: max(16px, env(safe-area-inset-left));
        padding-right: max(16px, env(safe-area-inset-right));
    }
    body.story-home-active .story-title h1 { font-size: clamp(43px, 14vw, 58px); }
    body.story-home-active .story-title h1.story-space-name--medium { font-size: clamp(36px, 11.5vw, 50px); }
    body.story-home-active .story-title h1.story-space-name--long { font-size: clamp(29px, 9.2vw, 42px); }
    body.story-home-active .story-title > p { font-size: 11px; }

    body.story-home-active .period-copy {
        grid-template-columns: 76px minmax(0, 1fr);
        column-gap: 16px;
        margin-top: 25px;
    }
    body.story-home-active .period-copy strong { font-size: 18px; }
    body.story-home-active .period-copy > span:not(.month-note) { font-size: 32px; }
    body.story-home-active .period-copy p { display: none; }

    body.story-home-active .story-stage {
        grid-template-columns: 1fr;
        gap: 18px;
        margin-top: 20px;
    }
    body.story-home-active .story-card--featured { grid-column: 1; }
    body.story-home-active .story-card--featured .story-card__media { aspect-ratio: 4 / 5; }
    body.story-home-active .story-card--side {
        display: grid;
        grid-template-columns: 112px minmax(0, 1fr);
        gap: 14px;
        align-items: start;
        text-align: left;
    }
    body.story-home-active .story-card--side .story-card__media {
        width: 112px;
        aspect-ratio: 3 / 4;
    }
    body.story-home-active .story-card--side .story-card__copy {
        align-self: center;
        padding: 2px 0;
    }
    body.story-home-active .story-card--side .story-card__copy h2 {
        font-size: 20px;
        white-space: normal;
        display: -webkit-box;
        -webkit-box-orient: vertical;
        -webkit-line-clamp: 2;
    }
    body.story-home-active .story-card--side .story-card__description {
        white-space: normal;
        display: -webkit-box;
        -webkit-box-orient: vertical;
        -webkit-line-clamp: 2;
    }

    body.story-home-active .story-archive {
        margin-top: 26px;
        padding-left: max(16px, env(safe-area-inset-left));
        padding-right: max(16px, env(safe-area-inset-right));
    }
    body.story-home-active .archive-heading > strong { font-size: 22px; }
    body.story-home-active .date-jump {
        grid-template-columns: auto auto minmax(0, 1fr);
        padding-inline: 10px;
    }
    body.story-home-active .date-jump input { font-size: 13px; }
    body.story-home-active .year-rail .archive-button { min-width: 58px; }
    body.story-home-active .month-rail .archive-button { min-width: 44px; padding-inline: 7px; }
    body.story-home-active .archive-legend { justify-content: flex-start; }
}

@media (max-width: 390px) {
    body.story-home-active .story-card--side {
        grid-template-columns: 100px minmax(0, 1fr);
        gap: 12px;
    }
    body.story-home-active .story-card--side .story-card__media { width: 100px; }
    body.story-home-active .story-card--featured .story-card__action {
        min-width: 118px;
        padding-inline: 12px;
    }
    body.story-home-active .story-card--featured .story-card__action::after { margin-left: 12px; }
}

/* Mobile correction: restore the third card on tablet widths and keep the
   featured action inside the photograph instead of letting it flow outside. */
@media (max-width: 980px) {
    body.story-home-active .story-card--side:last-child { display: block; }
    body.story-home-active .story-card--featured .story-card__media { aspect-ratio: 4 / 3; }
    body.story-home-active .story-card--featured .story-card__action {
        position: absolute;
        z-index: 2;
        margin: 0;
    }
}
@media (max-width: 640px) {
    body.story-home-active .story-card--featured .story-card__media { aspect-ratio: 4 / 5; }
}
@media (max-width: 640px) {
    body.story-home-active .story-card--side:last-child { display: grid; }
}


/* v12.9 image protection layering */
.story-card__media { position: relative; }
.story-card__media > .media-save-guard { z-index: 4; }
.story-card--featured .story-card__action { z-index: 6; pointer-events: none; }
.media-card__image { position: relative; }
.media-card__image > .media-save-guard { z-index: 4; }
.play-mark { z-index: 6; pointer-events: none; }

/* v14.0：保留管理员自定义故事内容，仅删除旧模板固定结尾。 */
body.story-home-active .period-copy .active-story-description {
    display: -webkit-box;
    max-width: 250px;
    margin: 16px 0 0;
    overflow: hidden;
    color: var(--story-muted);
    font-size: 12px;
    line-height: 1.8;
    white-space: pre-line;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 5;
}
body.story-home-active .period-copy .active-story-description[hidden] { display: none !important; }
@media (max-width: 980px) {
    body.story-home-active .period-copy .active-story-description {
        grid-column: 1 / -1;
        max-width: none;
        margin-top: 10px;
        -webkit-line-clamp: 6;
    }
}
