/* Story atmosphere and reading appearance are independent. Preview scopes use
   the same palettes and ornaments without changing the editor or saved settings. */
:is(:root[data-theme],.story-theme-preview) {
  --story-pattern:none; --story-pattern-size:auto; --story-radius:18px;
  --story-ornament:radial-gradient(ellipse at 100% 0,color-mix(in srgb,var(--story-accent) 12%,transparent),transparent 65%);
}
:is(:root[data-theme=xiandai],.story-theme-preview[data-story-theme=xiandai]) {
  --story-page:#f4f0f2; --story-paper:#fcf9fb; --story-tint:#ece4e9; --story-soft:#e7dce4;
  --story-ink:#423740; --story-muted:#6f5d6c; --story-border:#d7c6d0; --story-accent:#7b526e; --story-action:#7b526e;
  --story-ornament:linear-gradient(120deg,transparent 65%,color-mix(in srgb,var(--story-accent) 7%,transparent) 65%);
  --story-radius:12px;
}
:is(:root[data-theme=gufeng],.story-theme-preview[data-story-theme=gufeng]) {
  --story-page:#f4efe5; --story-paper:#fffdf7; --story-tint:#eee7d9; --story-soft:#f4e4de;
  --story-ink:#3c352c; --story-muted:#71634f; --story-border:#d8cbb5; --story-accent:#8c3035; --story-action:#8c3035;
  --story-pattern:repeating-linear-gradient(0deg,transparent 0 5px,color-mix(in srgb,var(--story-accent) 3%,transparent) 5px 6px);
  --story-ornament:radial-gradient(ellipse at 100% 0,#b3ab8733,transparent 65%); --story-radius:5px 20px 5px 20px;
}
:is(:root[data-theme=anye],.story-theme-preview[data-story-theme=anye]) {
  --story-page:#edeef4; --story-paper:#f7f7fb; --story-tint:#e3e4ee; --story-soft:#dcdfee;
  --story-ink:#343749; --story-muted:#5c617b; --story-border:#c5c8da; --story-accent:#555e8a; --story-action:#555e8a;
  --story-ornament:radial-gradient(ellipse at 100% 0,color-mix(in srgb,var(--story-accent) 12%,transparent),transparent 65%);
  --story-pattern:radial-gradient(color-mix(in srgb,var(--story-accent) 9%,transparent) 1px,transparent 1px); --story-pattern-size:67px 67px;
}
:is(:root[data-theme=minguo],.story-theme-preview[data-story-theme=minguo]) {
  --story-page:#f0eee8; --story-paper:#f9f7f0; --story-tint:#e6e3da; --story-soft:#dedfd9;
  --story-ink:#373d42; --story-muted:#5d6264; --story-border:#c9c7bd; --story-accent:#4e5d67; --story-action:#4e5d67;
  --story-pattern:repeating-linear-gradient(90deg,transparent 0 28px,color-mix(in srgb,var(--story-accent) 5%,transparent) 28px 29px);
  --story-ornament:repeating-linear-gradient(135deg,transparent 0 17px,color-mix(in srgb,var(--story-accent) 7%,transparent) 17px 18px); --story-radius:4px;
}
:is(:root[data-theme=gongting],.story-theme-preview[data-story-theme=gongting]) {
  --story-page:#f5eae8; --story-paper:#fff8f4; --story-tint:#efded9; --story-soft:#ecd5d1;
  --story-ink:#493236; --story-muted:#73575a; --story-border:#cbb18b; --story-accent:#853f4b; --story-action:#853f4b;
  --story-ornament:repeating-linear-gradient(45deg,transparent 0 19px,color-mix(in srgb,var(--story-accent) 6%,transparent) 19px 20px); --story-radius:8px;
}
:is(:root[data-theme=xuanhuan],.story-theme-preview[data-story-theme=xuanhuan]) {
  --story-page:#f1edf8; --story-paper:#fefcff; --story-tint:#eae3f4; --story-soft:#e9def6;
  --story-ink:#3a3050; --story-muted:#6a5b7e; --story-border:#d2c3e5; --story-accent:#70469e; --story-action:#70469e;
  --story-pattern:radial-gradient(color-mix(in srgb,var(--story-accent) 17%,transparent) 1px,transparent 1px); --story-pattern-size:59px 43px;
  --story-ornament:radial-gradient(ellipse at 95% 0,#b99be14d,transparent 68%); --story-radius:24px 8px 24px 8px;
}
:is(:root[data-theme=wuxia],.story-theme-preview[data-story-theme=wuxia]) {
  --story-page:#ecf0e7; --story-paper:#fbfcf6; --story-tint:#e4eadc; --story-soft:#dce9d9;
  --story-ink:#2f3d30; --story-muted:#5b6b54; --story-border:#c5d0b7; --story-accent:#456538; --story-action:#456538;
  --story-ornament:linear-gradient(155deg,transparent 50%,color-mix(in srgb,var(--story-accent) 8%,transparent) 50% 72%,transparent 72%),linear-gradient(30deg,transparent 65%,color-mix(in srgb,var(--story-accent) 7%,transparent) 65%); --story-radius:4px 18px 4px 18px;
}
:is(:root[data-theme=keji],.story-theme-preview[data-story-theme=keji]) {
  --story-page:#eaf2f7; --story-paper:#f9fdff; --story-tint:#dfeaf2; --story-soft:#d8edf4;
  --story-ink:#263e50; --story-muted:#526d7e; --story-border:#b6cedc; --story-accent:#17617f; --story-action:#17617f;
  --story-pattern:linear-gradient(color-mix(in srgb,var(--story-accent) 5%,transparent) 1px,transparent 1px),linear-gradient(90deg,color-mix(in srgb,var(--story-accent) 5%,transparent) 1px,transparent 1px); --story-pattern-size:32px 32px; --story-ornament:var(--story-pattern); --story-radius:12px 3px 12px 3px;
}
:is(:root[data-theme=xiaoyuan],.story-theme-preview[data-story-theme=xiaoyuan]) {
  --story-page:#edf4fb; --story-paper:#ffffff; --story-tint:#e4eef8; --story-soft:#ddebf9;
  --story-ink:#2f4058; --story-muted:#53677f; --story-border:#c3d4e8; --story-accent:#3c6195; --story-action:#3c6195;
  --story-ornament:repeating-linear-gradient(0deg,transparent 0 23px,color-mix(in srgb,var(--story-accent) 8%,transparent) 23px 24px); --story-radius:20px;
}
:is(:root[data-theme=qinggan],.story-theme-preview[data-story-theme=qinggan]) {
  --story-page:#fbf0f3; --story-paper:#fffdfd; --story-tint:#f6e7ed; --story-soft:#f3dfe8;
  --story-ink:#4a3240; --story-muted:#7b596a; --story-border:#e5c8d4; --story-accent:#a03f65; --story-action:#a03f65;
  --story-ornament:radial-gradient(ellipse at 100% 0,#e9abc44d,transparent 64%); --story-radius:26px 26px 8px 26px;
}
:is(:root[data-theme=mishi],.story-theme-preview[data-story-theme=mishi]) {
  --story-page:#eeedf3; --story-paper:#fbfaff; --story-tint:#e6e3ee; --story-soft:#ece2d3;
  --story-ink:#383348; --story-muted:#686077; --story-border:#ccc4d8; --story-accent:#795a2a; --story-action:#795a2a;
  --story-pattern:repeating-linear-gradient(135deg,transparent 0 22px,color-mix(in srgb,var(--story-accent) 4%,transparent) 22px 23px);
  --story-ornament:radial-gradient(ellipse at 100% 0,#c09b593b,transparent 66%); --story-radius:10px;
}
:is(:root[data-theme=warm_paper],.story-theme-preview[data-story-theme=warm_paper]) {
  --story-page:#f2e9e5; --story-paper:#fffaf6; --story-tint:#eddfda; --story-soft:#ead6c4;
  --story-ink:#45333a; --story-muted:#735b5a; --story-border:#cfb8ad; --story-accent:#874f55; --story-action:#765044;
  --story-pattern:repeating-linear-gradient(135deg,transparent 0 26px,color-mix(in srgb,#a97852 5%,transparent) 26px 27px);
  --story-ornament:repeating-linear-gradient(45deg,transparent 0 17px,color-mix(in srgb,#b08450 9%,transparent) 17px 18px),linear-gradient(120deg,transparent 58%,#b0845014 58% 60%,transparent 60%); --story-radius:7px;
}
:is(:root[data-theme=night_glow],.story-theme-preview[data-story-theme=night_glow]) {
  --story-page:#f2ecf2; --story-paper:#fffaf6; --story-tint:#eee4ed; --story-soft:#f0e2d5;
  --story-ink:#382b3a; --story-muted:#6a5262; --story-border:#d8c4cc; --story-accent:#775028; --story-action:#76502e;
  --story-pattern:radial-gradient(ellipse at 12% 0%,#dba57333,transparent 42%),radial-gradient(ellipse at 85% 4%,#7a9ac33d,transparent 48%);
  --story-pattern-size:100% clamp(340px,65vh,680px); --story-radius:18px;
  --story-ornament:radial-gradient(ellipse at 0% 0%,#c58a6326,transparent 70%);
}
:is(:root[data-appearance=dark][data-theme=xiandai],.story-theme-preview[data-preview-appearance=dark][data-story-theme=xiandai]) { --story-page:#29242a; --story-paper:#342d36; --story-tint:#403543; --story-soft:#4b3a4b; --story-ink:#e5dce4; --story-muted:#c5b3c0; --story-border:#6b5667; --story-accent:#d4b4ca; --story-action:#7b526e; }
:is(:root[data-appearance=dark][data-theme=gufeng],.story-theme-preview[data-preview-appearance=dark][data-story-theme=gufeng]) { --story-page:#29241f; --story-paper:#342e27; --story-tint:#40382e; --story-soft:#4b3330; --story-ink:#efe6d5; --story-muted:#cabb9f; --story-border:#685744; --story-accent:#f1b3a3; --story-action:#923b39; }
:is(:root[data-appearance=dark][data-theme=anye],.story-theme-preview[data-preview-appearance=dark][data-story-theme=anye]) { --story-page:#1a1c2b; --story-paper:#242737; --story-tint:#2e3245; --story-soft:#383e57; --story-ink:#d9dce7; --story-muted:#aeb5cc; --story-border:#505974; --story-accent:#b2b8d7; --story-action:#515c88; }
:is(:root[data-appearance=dark][data-theme=minguo],.story-theme-preview[data-preview-appearance=dark][data-story-theme=minguo]) { --story-page:#272622; --story-paper:#34322d; --story-tint:#403d36; --story-soft:#49463d; --story-ink:#e3e0d7; --story-muted:#c3bdaf; --story-border:#696256; --story-accent:#c9c2b1; --story-action:#605b50; }
:is(:root[data-appearance=dark][data-theme=gongting],.story-theme-preview[data-preview-appearance=dark][data-story-theme=gongting]) { --story-page:#2b2025; --story-paper:#38292f; --story-tint:#46343c; --story-soft:#523b44; --story-ink:#e8dcd7; --story-muted:#cbb7ac; --story-border:#79654f; --story-accent:#d6b88c; --story-action:#853f4b; }
:is(:root[data-appearance=dark][data-theme=xuanhuan],.story-theme-preview[data-preview-appearance=dark][data-story-theme=xuanhuan]) { --story-page:#211c30; --story-paper:#302740; --story-tint:#3c3150; --story-soft:#49365f; --story-ink:#eee6fa; --story-muted:#c6b5df; --story-border:#695381; --story-accent:#cfb2f5; --story-action:#7447a4; }
:is(:root[data-appearance=dark][data-theme=wuxia],.story-theme-preview[data-preview-appearance=dark][data-story-theme=wuxia]) { --story-page:#20281f; --story-paper:#2c372a; --story-tint:#374431; --story-soft:#3e5036; --story-ink:#e6efda; --story-muted:#c0cfae; --story-border:#5e7150; --story-accent:#bad596; --story-action:#4b6939; }
:is(:root[data-appearance=dark][data-theme=keji],.story-theme-preview[data-preview-appearance=dark][data-story-theme=keji]) { --story-page:#152330; --story-paper:#203344; --story-tint:#294152; --story-soft:#294b5c; --story-ink:#e0f0fa; --story-muted:#aecddd; --story-border:#456e85; --story-accent:#8fd7f2; --story-action:#1f6584; }
:is(:root[data-appearance=dark][data-theme=xiaoyuan],.story-theme-preview[data-preview-appearance=dark][data-story-theme=xiaoyuan]) { --story-page:#1d2739; --story-paper:#29364c; --story-tint:#34445c; --story-soft:#3a4d6b; --story-ink:#e7eefb; --story-muted:#bdcde5; --story-border:#546d90; --story-accent:#abcaf6; --story-action:#3f6197; }
:is(:root[data-appearance=dark][data-theme=qinggan],.story-theme-preview[data-preview-appearance=dark][data-story-theme=qinggan]) { --story-page:#2b202a; --story-paper:#3b2b38; --story-tint:#4b3646; --story-soft:#56394b; --story-ink:#f6e7ef; --story-muted:#dcbccc; --story-border:#80586f; --story-accent:#f2b2ce; --story-action:#9b4065; }
:is(:root[data-appearance=dark][data-theme=mishi],.story-theme-preview[data-preview-appearance=dark][data-story-theme=mishi]) { --story-page:#22212c; --story-paper:#302e3e; --story-tint:#3c394d; --story-soft:#4b4032; --story-ink:#eee9f6; --story-muted:#c9bed9; --story-border:#696078; --story-accent:#e7c28c; --story-action:#7d5b2c; }
:is(:root[data-appearance=dark][data-theme=warm_paper],.story-theme-preview[data-preview-appearance=dark][data-story-theme=warm_paper]) { --story-page:#241e25; --story-paper:#332932; --story-tint:#40323b; --story-soft:#4c3638; --story-ink:#f0e5dc; --story-muted:#cdb7ad; --story-border:#6d5554; --story-accent:#e0bd83; --story-action:#895448; --story-pattern:repeating-linear-gradient(135deg,transparent 0 26px,#d4ad7430 26px 27px); --story-ornament:repeating-linear-gradient(45deg,transparent 0 17px,#d4ad7426 17px 18px),linear-gradient(120deg,transparent 58%,#d4ad741f 58% 60%,transparent 60%); }
:is(:root[data-appearance=dark][data-theme=night_glow],.story-theme-preview[data-preview-appearance=dark][data-story-theme=night_glow]) {
  --story-page:#120e19; --story-paper:#211827; --story-tint:#2b2032; --story-soft:#382a38;
  --story-ink:#f4eae1; --story-muted:#c7b5bc; --story-border:#544054; --story-accent:#e8c396; --story-action:#805931;
  --story-pattern:radial-gradient(ellipse at 12% 0%,#794c3970,transparent 42%),radial-gradient(ellipse at 78% 6%,#40577b75,transparent 51%);
  --story-ornament:radial-gradient(ellipse at 0% 0%,#774d5d55,transparent 70%);
}
html[data-theme=night_glow] body:is(.reader-page,.discovery-detail),
.story-theme-preview[data-story-theme=night_glow] { background-repeat:no-repeat; }
html[data-theme=night_glow] .discovery-detail :is(.hero-card,.detail-status) { background-image:var(--story-ornament); }

:root[data-appearance][data-theme]:not([data-theme=""]) {
  --site-page:var(--story-page); --site-paper:var(--story-paper); --site-tint:var(--story-tint); --site-soft:var(--story-soft);
  --site-ink:var(--story-ink); --site-muted:var(--story-muted); --site-border:var(--story-border);
  --site-accent:var(--story-accent); --site-action:var(--story-action); --site-accent-hover:var(--story-accent);
  --site-sage:var(--story-tint); --site-sage-ink:var(--story-muted);
  --atmo-color:color-mix(in srgb,var(--story-accent) 26%,transparent); --atmo-color-soft:color-mix(in srgb,var(--story-accent) 12%,transparent);
}
html[data-theme]:not([data-theme=""]) body:is(.reader-page,.discovery-detail) {
  background-color:var(--story-page); background-image:var(--story-pattern); background-size:var(--story-pattern-size); background-attachment:scroll;
}
html[data-theme] .discovery-detail .detail-hero,
html[data-theme] #opening-overlay .opening-welcome,
.story-theme-preview .theme-preview-heading {
  background-color:var(--story-paper); background-image:var(--story-ornament); background-size:auto;
  border-color:var(--story-border);
}
html[data-theme] .discovery-detail .detail-hero { border-radius:var(--story-radius); border-top:3px solid var(--story-accent); }
html[data-theme] .discovery-detail :is(.entry-context,.world-background,.entry-role) { background:var(--story-paper); border-color:var(--story-border); }
html[data-theme] .discovery-detail #cover-box .cover-letter { background:var(--story-ornament),var(--story-tint); color:var(--story-accent); }
html[data-theme] #opening-overlay .opening-profile-preview { background:var(--story-tint); border-radius:var(--story-radius); border-color:var(--story-border); }
html[data-theme] #opening-overlay .opening-profile-preview::before { background:var(--story-soft); border:1px solid var(--story-border); }
html[data-theme] #opening-overlay .setup-field label:has(input:checked) { border-color:var(--story-accent); }
html[data-theme] .reader-page .narrative:not(.is-player),
.story-theme-preview .theme-preview-passage {
  background:var(--story-paper); color:var(--story-ink); border:1px solid var(--story-border); border-radius:var(--story-radius);
  box-shadow:inset 3px 0 var(--story-soft);
}
html[data-theme] .reader-page .narrative.is-player { background:var(--story-soft); color:var(--story-ink); border-color:var(--story-border); }
html[data-theme] .reader-page .side-panel { background:var(--story-paper); border-color:var(--story-border); border-top:3px solid var(--story-accent); }
html[data-theme] .reader-page .input-zone { background:var(--story-tint); border-color:var(--story-border); }
html[data-theme] .reader-page .choices button { background:var(--story-paper); color:var(--story-ink); border-color:var(--story-border); }
html[data-theme] .reader-page .choices button:hover:not(:disabled) { border-color:var(--story-accent); background:var(--story-soft); }
html[data-theme] .reader-page .turn-divider { color:var(--story-muted); }
html[data-theme=gongting] .reader-page .narrative:not(.is-player) { outline:1px solid var(--story-border); outline-offset:3px; }
html[data-theme=minguo] .reader-page .narrative:not(.is-player) { border-top:3px double var(--story-border); border-bottom:3px double var(--story-border); }

/* Preview chrome stays in the site's appearance; only the sample is themed. */
.theme-preview-control { margin:18px 0 8px; min-width:0; }
.theme-preview-toolbar { display:flex; flex-wrap:wrap; align-items:center; justify-content:space-between; gap:12px; margin-bottom:10px; }
.theme-preview-toolbar strong { font-size:13px; font-weight:600; color:var(--ink); }
.theme-preview-modes { display:flex; gap:3px; padding:3px; background:var(--site-tint); border:1px solid var(--border); border-radius:9px; }
.theme-preview-modes button { font:inherit; font-size:11px; min-height:30px; padding:4px 10px; border:0; border-radius:6px; color:var(--ink-light); background:transparent; cursor:pointer; }
.theme-preview-modes button[aria-pressed=true] { color:var(--ink); background:var(--site-paper); box-shadow:0 1px 3px #0001; }
.theme-preview-modes button:focus-visible { outline:2px solid var(--accent); outline-offset:2px; }
.story-theme-preview { padding:18px; background:var(--story-pattern),var(--story-page); background-size:var(--story-pattern-size); border:1px solid var(--story-border); border-radius:14px; color:var(--story-ink); overflow:hidden; }
.theme-preview-heading { padding:14px 16px; border:1px solid var(--story-border); border-radius:var(--story-radius); margin-bottom:12px; display:flex; justify-content:space-between; gap:12px; }
.theme-preview-heading b { font-size:15px; font-weight:600; color:var(--story-ink); }
.theme-preview-heading span { font-size:11px; color:var(--story-accent); align-self:center; white-space:nowrap; }
.story-theme-preview .theme-preview-passage { padding:18px 20px; font-family:var(--font-story); font-size:15px; line-height:1.95; margin:0; white-space:pre-wrap; overflow-wrap:anywhere; }
.theme-preview-footer { display:flex; align-items:center; flex-wrap:wrap; gap:10px; margin-top:12px; }
.theme-preview-role { background:var(--story-soft); border:1px solid var(--story-border); border-radius:8px; padding:7px 11px; color:var(--story-muted); font-size:11px; }
.theme-preview-choice { margin-left:auto; background:var(--story-action); color:#fff; border-radius:8px; padding:8px 14px; font-size:12px; }
.theme-preview-control > .theme-preview-note { font-size:11px; line-height:1.8; color:var(--ink-light); margin:9px 0 0; }
@media(max-width:600px) { .story-theme-preview { padding:12px; } .theme-preview-heading { padding:12px; } .story-theme-preview .theme-preview-passage { padding:15px; } .theme-preview-heading b { font-size:14px; } }
