/* World-owned tokens. Default deliberately inherits the original app palette. */
html[data-world-theme="scifi"],body[data-world-theme="scifi"] {
  --text-rgb:216,246,245; --accent-rgb:89,227,218;
  color-scheme:dark; --bg:#04131d; --bg2:#092531; --card:#0a2835; --card2:#103846;
  --line:#236071; --text:#d8f6f5; --muted:#9bbec7; --accent:#59e3da;
  --gold:#59e3da; --mint:#c3e57b; --radius:3px; --shadow:0 8px 32px #0005;
  --theme-heading:"Consolas","Courier New",monospace; --theme-panel:#08212e;
  --theme-pattern:linear-gradient(#59e3da06 1px,transparent 1px),linear-gradient(90deg,#59e3da06 1px,transparent 1px);
}
html[data-world-theme="fantasy"],body[data-world-theme="fantasy"] {
  --text-rgb:56,43,33; --accent-rgb:128,81,34; --theme-text-min-opacity:.72;
  color-scheme:light; --bg:#e6d8b8; --bg2:#f4ead3; --card:#f2e7cd; --card2:#e6d5ae;
  --line:#b8a177; --text:#382b21; --muted:#6c5943; --accent:#805122;
  --gold:#805122; --mint:#426044; --radius:10px; --shadow:0 8px 25px #59401d18;
  --theme-heading:Georgia,"Times New Roman",serif; --theme-panel:#efe1c0;
  --theme-pattern:radial-gradient(ellipse at 15% 0%,#fff7dfaa,transparent 70%),repeating-linear-gradient(22deg,#93774c05 0px,#93774c05 1px,transparent 1px,transparent 4px);
}
html[data-world-theme="western"],body[data-world-theme="western"] {
  --text-rgb:60,39,30; --accent-rgb:145,67,34; --theme-text-min-opacity:.72;
  color-scheme:light; --bg:#d3b68c; --bg2:#efe0c4; --card:#ead7b5; --card2:#ddc29b;
  --line:#ac8257; --text:#3c271e; --muted:#725340; --accent:#914322;
  --gold:#914322; --mint:#53603d; --radius:4px; --shadow:3px 5px 0 #593e2020;
  --theme-heading:Rockwell,"Courier New",serif; --theme-panel:#e4ccaa;
  --theme-pattern:repeating-linear-gradient(0deg,#6f432008 0px,#6f432008 1px,transparent 1px,transparent 7px),radial-gradient(ellipse at top,#fff4d066,transparent 75%);
}
body[data-world-theme]:not([data-world-theme="default"]) {
  background-color:var(--bg); background-image:var(--theme-pattern); color:var(--text);
}
body[data-world-theme="scifi"] { background-size:40px 40px; }
body[data-world-theme]:not([data-world-theme="default"]) :is(h1,h2,h3,.brand-title,.brand-sub) { font-family:var(--theme-heading); color:var(--text); }
body[data-world-theme="scifi"] :is(h1,h2,.brand-title) { letter-spacing:.035em; }
body[data-world-theme="western"] :is(h1,h2,.brand-title) { font-weight:900; }
/* Shared surfaces and screen-specific panels use the same world material. */
body[data-world-theme]:not([data-world-theme="default"]) :is(.nav,.mobile-appbar,.play-topbar,.composer,.play-companion,.play-side,.cs-panel,.comp-sidebar,.comp-main,.comp-topbar,.comp-toolbar,.lib-panel,.lib-browser,.lib-story-panel,.lib-story-view-modal,.modal-card,.modal-panel,.modal-content,.map-sidebar,.map-toolbar,.map-panel,.native-map-toolbar,.native-map-sidebar,.dice-tray,.journey-dialog,.sheet-panel,.auth-card,.world-select) {
  background:var(--theme-panel); color:var(--text); border-color:var(--line);
}
body[data-world-theme]:not([data-world-theme="default"]) :is(.card,.workspace-path,.workspace-empty,.workspace-list,.entry-card,.quick-adventure,.lib-story-card,.play-check,.cs-section,.cs-card,.panel,.modal-box,.sheet-card,.map-card) {
  background:var(--card); color:var(--text); border-color:var(--line); border-radius:var(--radius); box-shadow:var(--shadow);
}
body[data-world-theme]:not([data-world-theme="default"]) :is(input:not([type="radio"]):not([type="checkbox"]):not([type="range"]):not([type="color"]),select,textarea) {
  background:var(--bg2); color:var(--text); border-color:var(--line); border-radius:var(--radius);
}
body[data-world-theme]:not([data-world-theme="default"]) input::placeholder,
body[data-world-theme]:not([data-world-theme="default"]) textarea::placeholder { color:var(--muted); opacity:1; }
body[data-world-theme]:not([data-world-theme="default"]) :is(.btn,.auth-link,.play-quiet-button,.play-next-actions button,.cs-tab,.tab-btn,.tb-btn,.tb-icon-btn,.icon-tab-btn,.filter-btn) {
  background:var(--card2); color:var(--text); border:1px solid var(--line); border-radius:var(--radius);
}
body[data-world-theme]:not([data-world-theme="default"]) .btn:not(.ghost) { background:var(--accent); color:var(--bg2); border-color:var(--accent); }
body[data-world-theme="scifi"] .btn:not(.ghost) { color:#04131d; }
body[data-world-theme]:not([data-world-theme="default"]) :is(.nav-item.active,.nav-item:hover,.cat-tree-row:hover,.cat-tree-row.active,.cat-tree-row.selected,.cs-tab.active) { background:var(--card2); color:var(--accent); border-color:var(--accent); }
body[data-world-theme]:not([data-world-theme="default"]) :is(.muted,.auth-email,.auth-link.secondary,.page-subtitle,.entry-card-summary,.world-stats,.lib-hint,.cs-label,.cs-muted) { color:var(--muted); }
body[data-world-theme]:not([data-world-theme="default"]) :is(.workspace-kicker,.story-kicker,.workspace-path>span:last-child) { color:var(--accent); }
body[data-world-theme]:not([data-world-theme="default"]) :is(.workspace-status,.workspace-badge) { color:var(--mint); border-color:var(--mint); }
body[data-world-theme]:not([data-world-theme="default"]) .world-hero { background:var(--theme-panel); border:1px solid var(--line); border-radius:var(--radius); }
body[data-world-theme]:not([data-world-theme="default"]) .world-hero-copy { background:linear-gradient(90deg,var(--theme-panel) 60%,transparent); }
body[data-world-theme]:not([data-world-theme="default"]) .world-hero p { color:var(--text); }
body[data-world-theme="scifi"] :is(.world-hero,.setup-masthead) { border-top:2px solid var(--accent); background-image:radial-gradient(ellipse at top right,#2ec7c321,transparent 65%); }
body[data-world-theme="fantasy"] :is(.world-hero,.setup-masthead) { border:4px double var(--line); }
body[data-world-theme="western"] :is(.world-hero,.setup-masthead) { border-block:5px double var(--accent); }
body[data-world-theme]:not([data-world-theme="default"]) :is(.play-log,.play-main,.play-reading-stage,.lib-story-view-body) { background:var(--bg); color:var(--text); }
body[data-world-theme]:not([data-world-theme="default"]) :is(.msg,.msg.assistant,.msg.user,.play-reading-card,.book-page,.reader-page,.story-reader) { background:var(--card); color:var(--text); border-color:var(--line); }
body[data-world-theme]:not([data-world-theme="default"]) :is(.cat-icon-wrap,.entry-card-icon-fallback) { background:var(--card2); border-color:var(--line); }
body[data-world-theme]:not([data-world-theme="default"]) :is(.flash-banner,.readonly-banner) { color:var(--text); }
body[data-world-theme]:not([data-world-theme="default"]) :is(.readonly-banner a,.flash-banner a) { color:var(--accent); text-decoration:underline; }
body[data-world-theme]:not([data-world-theme="default"]) :focus-visible { outline-color:var(--accent); }
body[data-world-theme]:not([data-world-theme="default"]) :is(.char-panel,.char-header,.char-card,.char-tab-content,.char-tabs,.entry-side,.entry-main,.entry-sidebar,.native-toolbar,.native-sidebar,.sheet-section,.play-stat-modal,.play-modal,.play-summary-modal,.lib-modal,.modal-backdrop>.modal,.toast) { background:var(--theme-panel); color:var(--text); border-color:var(--line); }
body[data-world-theme]:not([data-world-theme="default"]) :is(.composer-send,.char-tab.active,.char-mode-btn.active) { background:var(--accent); color:var(--bg2); }
body[data-world-theme="scifi"] :is(.composer-send,.char-tab.active,.char-mode-btn.active) { color:var(--bg); }
body:is([data-world-theme="fantasy"],[data-world-theme="western"]) :is(.msg-action-btn img,.char-card-label-icon) { filter:brightness(.3); }
body:is([data-world-theme="fantasy"],[data-world-theme="western"]) .cat-tree-icon-img:not([src*="/themes/"]) { background:#5c4a35; }
body[data-world-theme]:not([data-world-theme="default"]) :is(.native-modal-card,.native-modal-stepbar,.native-modal-actions,.native-style-card,.native-settings-card,.native-asset-picker-selected-card,.native-asset-picker-card-item,.native-import-item,.native-inspector,.native-side-panel,.native-panel,.native-segmented button,.native-aspect-grid button) { background:var(--theme-panel); color:var(--text); border-color:var(--line); }
body[data-world-theme]:not([data-world-theme="default"]) :is(.native-step,.native-settings-card label,.native-style-card small) { color:var(--muted); }
body[data-world-theme]:not([data-world-theme="default"]) :is(.native-step.active,.native-style-card.active) { color:var(--accent); border-color:var(--accent); }
body[data-world-theme]:not([data-world-theme="default"]) :is(.native-segmented button.active,.native-aspect-grid button.active) { background:var(--accent); color:var(--bg); }
body[data-world-theme]:not([data-world-theme="default"]) :is(.native-map-root,.native-topbar,.native-tool-rail,.native-tool-tooltip,.native-commandbar,.native-sidebar,.native-settings-menu,.native-asset-choice-large,.native-linked-entry) { background:var(--theme-panel); color:var(--text); border-color:var(--line); }
body[data-world-theme]:not([data-world-theme="default"]) :is(.native-action-btn.primary,.native-segment-pill.active) { background:var(--card2); color:var(--accent); border-color:var(--accent); }
body[data-world-theme]:not([data-world-theme="default"]) :is(#sceneLocation,#mobileActionsToggle,.msg-tools>summary,.play-dialog label,.play-context-panel summary,.play-context-panel a) { color:var(--text); }
body[data-world-theme]:not([data-world-theme="default"]) :is(.play-dialog,.adventure-settings .settings-choice,.msg-tools .msg-actions,.play-attached-roll,.composer-mic:not([aria-pressed="true"])) { background:var(--card2); color:var(--text); border-color:var(--line); }
body:is([data-world-theme="fantasy"],[data-world-theme="western"]) .play-view-switch img { filter:brightness(.3); }
body[data-world-theme]:not([data-world-theme="default"]) #charTabBar { background:var(--theme-panel); border-color:var(--line); }
body[data-world-theme]:not([data-world-theme="default"]) #charTabBar .char-tab { color:var(--muted); }
body[data-world-theme]:not([data-world-theme="default"]) #charTabBar .char-tab.active { color:var(--accent); background:var(--card2); border-color:var(--accent); }
body:is([data-world-theme="fantasy"],[data-world-theme="western"]) #charTabBar .char-tab img.play-tab-icon { filter:brightness(.3); }
body:is([data-world-theme="fantasy"],[data-world-theme="western"]) .char-stat-pill.gp-pill strong { color:var(--accent); }
body[data-world-theme]:not([data-world-theme="default"]) .native-map-root button { background:var(--card2); color:var(--text); border-color:var(--line); }
body[data-world-theme]:not([data-world-theme="default"]) .native-map-root button.active { background:var(--card); color:var(--accent); border-color:var(--accent); }
body:is([data-world-theme="fantasy"],[data-world-theme="western"]) .native-tool-rail button img { filter:brightness(.3); }
body:is([data-world-theme="fantasy"],[data-world-theme="western"]) .native-tool-rail .native-rail-icon { filter:brightness(.3); }
body[data-world-theme]:not([data-world-theme="default"]) :is(.native-overlay-pill,.native-overlay-palette) { background:var(--theme-panel); color:var(--text); border-color:var(--line); }
/* Setup is responsive and useful without JavaScript; JS adds live preview. */
body[data-world-theme]:not([data-world-theme="default"]) :is(.modal-inner,.custom-modal-content,.mg-modal-card,.lib-collection-modal,.play-confirm-modal) { background:var(--theme-panel);color:var(--text);border-color:var(--line); }
.setup-page { max-width:1120px; margin:0 auto; padding-bottom:60px; }
.setup-masthead { padding:36px 30px; margin-bottom:24px; border:1px solid var(--line); border-radius:var(--radius); background:var(--card); }
.setup-masthead h1 { font-size:clamp(28px,4vw,46px); margin:14px 0; line-height:1.15; }
.setup-masthead p { color:var(--muted); max-width:700px; line-height:1.7; }
.setup-form { padding:28px; }
.setting-fields { display:grid; gap:12px; }
.setting-fields label { font-size:14px; }
.setting-fields input:not([type="radio"]),.setting-fields textarea { width:100%; padding:12px; }
.setup-section-heading { margin-top:22px; }
.setup-section-heading h2 { margin:10px 0; }
.setup-section-heading p { margin:0 0 10px; line-height:1.6; }
.setting-grid { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:12px; }
.setting-option { display:flex; align-items:flex-start; gap:12px; border:1px solid var(--line); padding:18px; border-radius:var(--radius); cursor:pointer; }
.setting-option input,.theme-option input { width:18px; height:18px; flex-shrink:0; accent-color:var(--accent); }
.setting-option strong,.theme-option strong { display:block; margin-bottom:6px; }
.setting-option small,.theme-option small { display:block; color:var(--muted); line-height:1.6; }
.setting-option:has(input:checked),.theme-option:has(input:checked) { border-color:var(--accent); box-shadow:inset 0 0 0 1px var(--accent); background:var(--card2); }
.theme-grid { display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); gap:12px; }
.theme-option { position:relative; border:1px solid var(--line); border-radius:var(--radius); padding:12px; cursor:pointer; }
.theme-option>input { position:absolute; top:17px; right:17px; }
.theme-swatch { display:flex; flex-direction:column; gap:10px; height:125px; padding:25px 15px 12px 28px; margin-bottom:14px; overflow:hidden; border:1px solid; position:relative; }
.theme-swatch i { position:absolute; inset:0 auto 0 0; width:13px; background:currentColor; opacity:.25; }
.theme-swatch b { font:12px Georgia,serif; }
.theme-swatch em { border:1px solid; height:17px; opacity:.6; }
.theme-swatch-default { background:#0b1a25; color:#64b5ff; border-radius:9px; }
.theme-swatch-fantasy { background:radial-gradient(at top left,#fff6dd,#e2cda0); color:#805122; border-style:double; border-width:3px; }
.theme-swatch-scifi { background:repeating-linear-gradient(0deg,#0a2934,#0a2934 9px,#123d47 10px); color:#59e3da; }
.theme-swatch-scifi b { font-family:Consolas,monospace; }
.theme-swatch-western { background:repeating-linear-gradient(0deg,#d8bc90,#d8bc90 4px,#d2b487 5px); color:#743b22; border-block:4px double; }
.theme-swatch-western b { font-family:Rockwell,"Courier New",serif; font-weight:bold; }
.setup-footer { display:flex; flex-wrap:wrap; gap:12px; justify-content:flex-end; align-items:center; margin-top:28px; }
.setup-steps { display:flex; gap:10px; flex-wrap:wrap; margin-bottom:20px; }
.setup-steps a { flex:1; min-width:190px; padding:14px; border:1px solid var(--line); border-radius:var(--radius); font-size:13px; }
.setup-steps span { float:right; color:var(--accent); }
.setup-identity { margin-bottom:20px; }
.setup-identity>summary { padding:8px; cursor:pointer; }
.setup-identity>summary span { display:inline-block; font-size:12px; margin-left:15px; }
.setup-section { padding:28px; margin:20px 0; scroll-margin-top:20px; }
.setup-section>p { max-width:780px; line-height:1.7; }
.setup-imports,.starter-grid { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:20px; }
.setup-import { padding:20px; border:1px solid var(--line); border-radius:var(--radius); }
.setup-import form { display:grid; gap:12px; margin:14px 0; }
.setup-import label { display:grid; gap:7px; font-size:13px; }
.setup-import :is(input,textarea) { width:100%; min-width:0; padding:10px; }
.setup-import summary,.starter-card summary,.setup-sources summary { cursor:pointer; color:var(--accent); padding:8px 0; }
.setup-sources { margin-top:16px; }
.setup-callout { padding:16px; border-left:3px solid var(--accent); background:var(--card2); line-height:1.6; }
.setup-callout a { text-decoration:underline; }
.starter-grid { margin:20px 0; }
.starter-card { border:1px solid var(--line); border-radius:var(--radius); padding:20px; min-width:0; }
.starter-card label { cursor:pointer; }
.starter-card strong { display:block; font-size:20px; margin:12px 0; }
.starter-card p { color:var(--muted); line-height:1.65; }
.starter-body { white-space:pre-wrap; overflow-wrap:anywhere; font-size:14px; line-height:1.7; }
.setup-discard { margin-top:10px; }
[data-generation-status] { display:inline-block; margin:10px; }
.setup-world-link { display:flex; justify-content:space-between; align-items:center; gap:12px; margin-bottom:16px; }
@media(max-width:700px) {
  .setting-grid,.setup-imports,.starter-grid { grid-template-columns:1fr; }
  .theme-grid { grid-template-columns:repeat(2,minmax(0,1fr)); }
  .setup-form,.setup-section,.setup-masthead { padding:18px; }
  .setup-world-link { flex-wrap:wrap; }
}
