:root{
  --bg:#f2ede5;
  --bg2:#e8e0d5;
  --surface:rgba(251,248,243,.74);
  --surface-2:rgba(255,252,247,.54);
  --surface-strong:rgba(253,249,244,.95);
  --paper:#fffaf3;
  --text:#302b26;
  --muted:#827970;
  --line:rgba(72,60,49,.11);
  --shadow:0 18px 54px rgba(70,53,38,.10);
  --blur:22px;
  --accent:#9f735f;
  --accent-2:#b39a80;
  --accent-soft:rgba(159,115,95,.11);
  --danger:#ad645e;
  --danger-soft:rgba(173,100,94,.11);
  --ambient-a:#c59b83;--ambient-b:#bcb093;--ambient-c:#cfb19b;
  --ambient-opacity:.14;
  --radius:22px;--radius-sm:14px;
  --editor-font:'Merriweather',Georgia,serif;--editor-size:17px;
}
















/* Sylva — tema ufficiale: palette del marchio, UI foglia scura e carta crema. */
html[data-theme="sylva"]{
  --bg:#242920;--bg2:#30362a;
  --surface:rgba(47,52,39,.86);--surface-2:rgba(116,118,96,.18);--surface-strong:#343a2d;
  --paper:#f3eee5;--sylva-paper-hi:#fbf7ef;--sylva-paper-low:#ded8cb;--sylva-ink:#2d2923;--sylva-paper-muted:#746d61;
  --text:#f3eee5;--muted:#b6b09f;--line:rgba(222,216,203,.12);--shadow:0 22px 66px rgba(12,15,10,.28);
  --accent:#ff7a1f;--accent-2:#b59c70;--accent-soft:rgba(255,122,31,.12);
  --danger:#c36d62;--danger-soft:rgba(195,109,98,.12);
  --ambient-a:#747660;--ambient-b:#9a9a7f;--ambient-c:#b59c70;--ambient-opacity:.085;
}

html[data-theme="sylva-dark"]{
  --bg:#121812;--bg2:#192219;
  --surface:rgba(22,29,24,.88);--surface-2:rgba(75,91,77,.18);--surface-strong:#1a241d;
  --paper:#f1eadf;--sylva-paper-hi:#faf5ed;--sylva-paper-low:#d8d1c3;--sylva-ink:#2e2a23;--sylva-paper-muted:#776e61;
  --text:#ebe4d8;--muted:#a59d90;--line:rgba(230,222,208,.11);--shadow:0 22px 66px rgba(0,0,0,.36);
  --accent:#ff9a3d;--accent-2:#c3a47a;--accent-soft:rgba(255,154,61,.14);
  --danger:#c77b72;--danger-soft:rgba(199,123,114,.12);
  --ambient-a:#41503f;--ambient-b:#5b664e;--ambient-c:#8c734b;--ambient-opacity:.08;
  --sylva-ui:Inter,system-ui,sans-serif;--nature-display:'Cormorant Garamond',serif;
}



html[data-theme="sylva-dark"]{color-scheme:dark}
html[data-theme="sylva"]{color-scheme:light}

*{box-sizing:border-box}
html,body{margin:0;min-height:100%;background:linear-gradient(145deg,var(--bg),var(--bg2));color:var(--text);font-family:Inter,system-ui,sans-serif}
body{overflow:hidden}
button,input,select,textarea{font:inherit;color:inherit}
button{cursor:pointer}
button:focus-visible,input:focus-visible,select:focus-visible,textarea:focus-visible{outline:2px solid color-mix(in srgb,var(--accent) 58%,transparent);outline-offset:2px}
.scene-editor:focus,.scene-editor:focus-visible{outline:none!important;box-shadow:none!important}

/* 1.2.1 · peso del manoscritto leggermente più fine, senza cambiare font o dimensioni. */
.scene-editor,.reader-editor{font-weight:350;-webkit-font-smoothing:antialiased;text-rendering:optimizeLegibility}
.scene-editor b,.scene-editor strong,.reader-editor b,.reader-editor strong{font-weight:650}
.scene-editor h1,.scene-editor h2,.scene-editor h3,.reader-editor h1,.reader-editor h2,.reader-editor h3{font-weight:500}

/* 1.2.1: ambienti visivamente equivalenti ma senza grandi filter:blur rasterizzati a ogni frame. */
.ambient{position:fixed;border-radius:999px;pointer-events:none;opacity:var(--ambient-opacity,.08);transition:opacity .4s ease;contain:paint;transform:translateZ(0)}
.ambient-a{width:620px;height:620px;background:radial-gradient(circle at 50% 50%,color-mix(in srgb,var(--ambient-a) 92%,transparent) 0%,color-mix(in srgb,var(--ambient-a) 52%,transparent) 34%,transparent 72%);left:-240px;top:-270px}
.ambient-b{width:700px;height:700px;background:radial-gradient(circle at 50% 50%,color-mix(in srgb,var(--ambient-b) 90%,transparent) 0%,color-mix(in srgb,var(--ambient-b) 48%,transparent) 35%,transparent 72%);right:-285px;top:8%}
.ambient-c{width:600px;height:600px;background:radial-gradient(circle at 50% 50%,color-mix(in srgb,var(--ambient-c) 90%,transparent) 0%,color-mix(in srgb,var(--ambient-c) 48%,transparent) 34%,transparent 72%);left:34%;bottom:-360px}

.glass{background:var(--surface);backdrop-filter:blur(var(--blur)) saturate(.92);-webkit-backdrop-filter:blur(var(--blur)) saturate(.92);border:1px solid var(--line);box-shadow:var(--shadow)}
.glass-lite{background:var(--surface-2);backdrop-filter:blur(14px);-webkit-backdrop-filter:blur(14px);border:1px solid var(--line)}

.app-shell{height:100vh;display:grid;grid-template-columns:76px 1fr;grid-template-rows:68px 1fr;gap:12px;padding:12px}
.rail{grid-row:1/3;border-radius:24px;display:flex;flex-direction:column;align-items:center;padding:12px 8px;z-index:20}
.brand{width:46px;height:46px;border:1px solid var(--line);border-radius:15px;background:linear-gradient(145deg,color-mix(in srgb,var(--accent) 76%,var(--surface-strong)),color-mix(in srgb,var(--accent) 48%,var(--bg)));color:#f4f0e6;font-weight:700;letter-spacing:.06em;box-shadow:0 10px 28px rgba(0,0,0,.22)}
.rail-nav{display:flex;flex-direction:column;gap:8px;margin-top:22px;width:100%}
.rail-bottom{margin-top:auto;display:flex;flex-direction:column;gap:8px;width:100%}
.rail-btn{border:0;background:transparent;border-radius:15px;padding:9px 3px;display:flex;flex-direction:column;align-items:center;gap:4px;color:var(--muted);transition:.28s ease}
.rail-btn:hover,.rail-btn.active{background:var(--accent-soft);color:var(--text)}
.rail-btn span{font-weight:650}
.rail-btn small{font-size:9px}

.topbar{grid-column:2;border-radius:22px;display:grid;grid-template-columns:1fr auto 1fr;align-items:center;padding:0 16px;z-index:15}
.topbar-left,.topbar-actions{display:flex;align-items:center;gap:10px}
.topbar-actions{justify-content:flex-end}
.book-title-top{font-size:14px;font-weight:600}
.save-state{font-size:10px;color:var(--muted);margin-top:2px}
.topbar-center{display:flex;background:var(--surface-2);padding:4px;border-radius:14px;border:1px solid var(--line)}
.scope-btn,.soft-btn,.primary-btn,.mini-btn,.icon-btn{border:1px solid transparent;background:transparent;border-radius:11px;transition:.22s ease}
.scope-btn{padding:7px 12px;font-size:12px;color:var(--muted)}
.scope-btn.active{background:var(--surface-strong);color:var(--text);box-shadow:0 4px 16px rgba(0,0,0,.08)}
.soft-btn{padding:8px 11px;border-color:var(--line);background:var(--surface-2);font-size:12px}
.soft-btn:hover{background:color-mix(in srgb,var(--surface-strong) 78%,var(--accent-soft))}
.soft-btn.active{background:var(--accent-soft);border-color:color-mix(in srgb,var(--accent) 32%,transparent)}
.soft-btn.danger{color:var(--danger);background:var(--danger-soft);border-color:color-mix(in srgb,var(--danger) 22%,transparent)}
.primary-btn{padding:9px 14px;background:var(--text);color:var(--bg);font-weight:650;font-size:12px;box-shadow:0 6px 18px rgba(0,0,0,.08)}
.primary-btn:hover{transform:translateY(-1px)}
.icon-btn{width:34px;height:34px;font-size:18px;color:var(--muted)}
.icon-btn:hover{background:var(--accent-soft);color:var(--text)}

.main-area{grid-column:2;grid-row:2;min-width:0;min-height:0;position:relative}
.view{display:none;width:100%;height:100%}
.view.active{display:flex}
.panel-fade{transition:opacity .35s ease,transform .35s ease,width .35s ease}
.structure-panel{width:270px;min-width:270px;border-radius:22px;padding:14px;overflow:auto;transition:.32s ease;z-index:10;scroll-padding-top:112px}
.structure-panel.collapsed{width:0;min-width:0;padding:0;border:0;opacity:0;transform:translateX(-20px);pointer-events:none}
.edge-handle{position:absolute;left:0;top:42%;width:12px;height:74px;border:0;border-radius:0 10px 10px 0;background:var(--surface-strong);box-shadow:var(--shadow);z-index:30}
.hidden{display:none!important}
.panel-head{display:flex;justify-content:space-between;align-items:center}
.panel-head small,.view-heading small,.card-head small{font-size:9px;letter-spacing:.16em;color:var(--muted);font-weight:700}
.panel-head h2{font-size:18px;margin:4px 0}
.structure-sticky-tools{position:sticky;top:-14px;z-index:24;margin:-14px -14px 8px;padding:14px 14px 8px;background:linear-gradient(to bottom,color-mix(in srgb,var(--surface-strong) 98%,var(--bg) 2%) 0%,color-mix(in srgb,var(--surface-strong) 96%,transparent) 78%,color-mix(in srgb,var(--surface-strong) 88%,transparent) 100%);border-radius:22px 22px 12px 12px;border-bottom:1px solid color-mix(in srgb,var(--line) 76%,transparent)}
.structure-sticky-tools .panel-head{margin:0}
.structure-actions{display:flex;gap:6px;margin:12px 0 0}
.mini-btn{font-size:10px;padding:7px 8px;background:var(--surface-2);border-color:var(--line)}
.structure-tree{display:flex;flex-direction:column;gap:5px}
.tree-row{display:flex;align-items:center;gap:7px;padding:8px 9px;border-radius:11px;color:var(--muted);font-size:12px;transition:.18s}
.tree-row:hover{background:var(--surface-2);color:var(--text)}
.tree-row.active{background:var(--accent-soft);color:var(--text)}
.tree-row[data-type="chapter"]{margin-left:10px}
.tree-row[data-type="scene"]{margin-left:24px}

.tree-row .tree-title{white-space:nowrap;overflow:hidden;text-overflow:ellipsis;flex:1}
.tree-row .tree-menu{opacity:0;border:0;background:none;color:var(--muted)}
.tree-row:hover .tree-menu{opacity:1}

#writerView{gap:12px;position:relative}
.editor-stage{position:relative;min-width:0;flex:1;height:100%;display:flex;flex-direction:column;align-items:center}
.document-meta{height:36px;width:min(850px,92%);display:flex;justify-content:space-between;align-items:center;font-size:10px;color:var(--muted)}
.editor-viewport{width:100%;flex:1;overflow:auto;padding:14px 0 110px;scroll-behavior:smooth}
.multi-scene-editor{width:min(850px,92%);margin:0 auto;display:flex;flex-direction:column;gap:22px}
.scene-sheet{position:relative;background:var(--paper,var(--surface-strong));border:0;border-radius:20px;box-shadow:0 15px 55px rgba(0,0,0,.10);padding:58px clamp(32px,7vw,82px) 80px;min-height:70vh;transition:.28s}
.scene-sheet:hover{box-shadow:0 20px 68px rgba(0,0,0,.14)}
.scene-label{position:absolute;left:22px;top:18px;font:600 10px Inter,sans-serif;letter-spacing:.08em;color:var(--muted);text-transform:uppercase}
.scene-editor{outline:none;min-height:50vh;font-family:var(--editor-font);font-size:var(--editor-size);line-height:1.82;caret-color:var(--accent);word-break:break-word}
.scene-editor p{margin:0 0 .9em}
.scene-editor h1{font-size:2em;line-height:1.25;margin:1.2em 0 .55em}
.scene-editor h2{font-size:1.55em;line-height:1.3;margin:1.1em 0 .5em}
.scene-editor h3{font-size:1.25em;line-height:1.35;margin:1em 0 .45em}
.scene-editor img{max-width:100%;border-radius:12px;box-shadow:0 8px 30px rgba(0,0,0,.12);margin:16px auto;display:block}
.scene-editor img[data-wrap="left"]{float:left;max-width:45%;margin:10px 22px 12px 0}
.scene-editor img[data-wrap="right"]{float:right;max-width:45%;margin:10px 0 12px 22px}
.codex-mark{border-radius:5px;padding:0 .05em;background:color-mix(in srgb,var(--codex-color) 18%,transparent);box-shadow:inset 0 -2px 0 color-mix(in srgb,var(--codex-color) 72%,transparent)}
.bookmark-anchor{--bookmark-color:var(--accent);display:inline-flex;align-items:center;justify-content:center;width:19px;height:22px;margin:0 4px;vertical-align:-3px;position:relative;cursor:grab;border-radius:7px;user-select:none;-webkit-user-select:none;touch-action:none;transition:transform .15s ease,background .15s ease,opacity .15s ease;outline:none}
.bookmark-anchor:hover{background:color-mix(in srgb,var(--bookmark-color) 10%,transparent);transform:translateY(-1px)}
.bookmark-anchor:active,.bookmark-anchor.dragging{cursor:grabbing;opacity:.38;transform:scale(.90)}
.bookmark-icon{display:inline-block;color:var(--bookmark-color);font:700 13px/1 system-ui,sans-serif;text-shadow:0 1px 3px rgba(0,0,0,.28);pointer-events:none}
.bookmark-drag-ghost{position:fixed;z-index:200;width:30px;height:30px;border-radius:10px;background:var(--surface-strong);border:1px solid color-mix(in srgb,var(--bookmark-color) 34%,var(--line));box-shadow:var(--shadow);display:grid;place-items:center;pointer-events:none;transform:translate(-50%,-50%);opacity:.94}
.bookmark-drag-ghost .bookmark-icon{font-size:15px}
.scene-editor.bookmark-drop-target{background:color-mix(in srgb,var(--accent) 2.5%,transparent);box-shadow:none!important;border-radius:8px}
body.bookmark-is-dragging,body.bookmark-is-dragging *{cursor:grabbing!important}

.floating-toolbar{position:absolute;z-index:35;top:46px;display:flex;align-items:center;gap:3px;padding:6px;border-radius:15px;opacity:.22;transform:translateY(-5px);transition:.28s ease}
.floating-toolbar:hover,.floating-toolbar.focused{opacity:1;transform:none}
.floating-toolbar button,.floating-toolbar select{height:29px;border:0;background:transparent;border-radius:8px;font-size:11px}
.floating-toolbar button{min-width:29px}
.floating-toolbar .tool-emoji{font-family:"Segoe UI Emoji","Apple Color Emoji","Noto Color Emoji",system-ui,sans-serif;font-size:14px;line-height:1;display:inline-grid;place-items:center}
.floating-toolbar button:hover,.floating-toolbar select:hover{background:var(--accent-soft)}
.floating-toolbar select{max-width:115px;color:var(--muted)}
.separator{width:1px;height:18px;background:var(--line);margin:0 3px}
.highlight-menu{display:flex;gap:2px}
.highlight-dot{width:19px!important;min-width:19px!important;height:19px!important;border-radius:50%!important;border:1px solid rgba(0,0,0,.08)!important}
.highlight-dot:nth-child(1){background:#fff09a}
.highlight-dot:nth-child(2){background:#ffd2dc}
.highlight-dot:nth-child(3){background:#ccebdc}
.highlight-dot:nth-child(4){background:#cfdcf8}
.highlight-dot:nth-child(5){background:#e3d2f3}

.bookmark-panel{position:absolute;right:0;top:0;height:100%;width:330px;padding:16px;border-radius:22px;z-index:40;transform:translateX(calc(100% + 20px));opacity:0;pointer-events:none;transition:.3s ease}
.bookmark-panel.open{transform:none;opacity:1;pointer-events:auto}
.bookmark-list{display:flex;flex-direction:column;gap:9px;margin-top:14px}
.bookmark-item{--bookmark-color:var(--accent);padding:11px;border-radius:13px;background:var(--surface-2);border:1px solid var(--line);box-shadow:inset 2px 0 0 color-mix(in srgb,var(--bookmark-color) 76%,transparent);transition:.18s ease}
.bookmark-item .bm-top{display:flex;justify-content:space-between;align-items:center;gap:8px}.bm-title{display:flex;align-items:center;gap:7px;min-width:0}.bm-title b{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.bm-mini-icon{width:12px;flex:0 0 auto;color:var(--bookmark-color);font:700 10px/1 system-ui,sans-serif;font-style:normal;text-align:center}.bm-actions{display:flex;gap:2px}
.bookmark-item b{font-size:11px}
.bookmark-item p{font-size:11px;line-height:1.5;color:var(--muted);margin:7px 0 4px}.bookmark-item small{display:block;font-size:8px;color:color-mix(in srgb,var(--muted) 78%,transparent)}
.bookmark-item button{border:0;background:none;color:var(--muted);font-size:10px;border-radius:7px;padding:4px 5px}.bookmark-item button:hover{background:color-mix(in srgb,var(--bookmark-color) 13%,transparent);color:var(--text)}
.note-bubble{--bookmark-color:var(--accent);position:absolute;z-index:60;width:min(310px,calc(100vw - 20px));padding:12px 14px;border-radius:15px;background:color-mix(in srgb,var(--surface-strong) 92%,var(--bookmark-color) 8%);backdrop-filter:blur(18px);box-shadow:var(--shadow);border:1px solid color-mix(in srgb,var(--bookmark-color) 35%,var(--line));font-size:12px;line-height:1.5;animation:pop .2s ease}.note-bubble-title{display:flex;align-items:center;gap:7px;font-size:10px;font-weight:700;color:var(--muted);margin-bottom:6px}.note-bubble-title i{width:12px;color:var(--bookmark-color);font:700 10px/1 system-ui,sans-serif;font-style:normal;text-align:center}
.note-bubble:after{content:'';position:absolute;left:28px;bottom:-8px;width:15px;height:15px;background:color-mix(in srgb,var(--surface-strong) 92%,var(--bookmark-color) 8%);border-right:1px solid color-mix(in srgb,var(--bookmark-color) 35%,var(--line));border-bottom:1px solid color-mix(in srgb,var(--bookmark-color) 35%,var(--line));transform:rotate(45deg)}
@keyframes pop{from{opacity:0;transform:translateY(5px)}to{opacity:1;transform:none}}

.content-view{width:min(1180px,96%);height:100%;margin:0 auto;overflow:auto;padding:34px 12px 80px}
.content-view.wide{width:min(1320px,97%)}
.view-heading{display:flex;justify-content:space-between;align-items:flex-end;gap:20px;margin-bottom:24px}
.view-heading h1{font-size:34px;letter-spacing:-.04em;margin:5px 0 4px}
.view-heading p{margin:0;color:var(--muted);font-size:13px;line-height:1.5}
.heading-actions{display:flex;gap:8px}

/* Codex */
.codex-layout{display:grid;grid-template-columns:220px 1fr;gap:15px}
.codex-categories{border-radius:20px;padding:12px;height:fit-content;position:sticky;top:0}
.search-wrap input{width:100%;border:1px solid var(--line);background:var(--surface-2);border-radius:11px;padding:10px 11px;outline:none;font-size:12px}
.category-item{display:grid;grid-template-columns:minmax(0,1fr) auto auto;gap:7px;align-items:center;margin-top:5px;padding:7px 8px 7px 10px;border-radius:10px;font-size:12px;color:var(--muted);cursor:pointer}
.category-item:hover,.category-item.active{background:var(--accent-soft);color:var(--text)}
.category-name{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.category-count{font-size:10px}.category-edit{width:25px;height:25px;border:0;border-radius:7px;background:transparent;color:var(--muted);opacity:.55}.category-edit:hover{background:var(--surface-strong);color:var(--text);opacity:1}
.codex-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(245px,1fr));gap:12px}
.codex-card{border-radius:18px;padding:17px;background:var(--surface-2);border:1px solid var(--line);transition:.22s;cursor:pointer;min-height:155px}
.codex-card:hover{transform:translateY(-2px);background:var(--surface)}
.codex-color{width:12px;height:12px;border-radius:50%;display:inline-block}
.codex-card-head{display:flex;justify-content:space-between;align-items:center}
.codex-card h3{font-size:16px;margin:10px 0 5px}
.codex-card .tags{display:flex;gap:5px;flex-wrap:wrap}
.tag{font-size:9px;border-radius:999px;padding:4px 7px;background:var(--accent-soft);color:var(--muted)}
.codex-card p{font-size:11px;line-height:1.55;color:var(--muted);display:-webkit-box;-webkit-line-clamp:3;-webkit-box-orient:vertical;overflow:hidden}
.codex-category-picker{display:flex;gap:7px;flex-wrap:wrap;padding:2px 0}
.category-check{position:relative;display:inline-flex;align-items:center;gap:6px;padding:8px 11px;border-radius:999px;border:1px solid var(--line);background:var(--surface-2);font-size:11px;color:var(--muted);cursor:pointer;transition:.18s ease;user-select:none}
.category-check input{position:absolute;opacity:0;pointer-events:none;width:auto!important}
.category-check:hover{background:var(--accent-soft);color:var(--text)}
.category-check:has(input:checked){background:var(--accent-soft);border-color:color-mix(in srgb,var(--accent) 38%,transparent);color:var(--text)}
.category-check:has(input:checked)::before{content:'✓';font-size:10px;color:var(--accent)}

/* Analysis */
.analysis-view{width:min(1320px,97%)}
.stats-grid{display:grid;grid-template-columns:repeat(4,1fr);gap:10px;margin-bottom:15px}
.stats-grid-rich{grid-template-columns:repeat(8,minmax(0,1fr))}
.stat-card{border-radius:17px;padding:17px;background:var(--surface-2);border:1px solid var(--line);min-width:0}
.stat-card b{display:block;font-size:24px;letter-spacing:-.04em;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.stat-card span{font-size:9px;color:var(--muted);text-transform:uppercase;letter-spacing:.07em}
.analysis-grid{display:grid;grid-template-columns:1fr 1fr;gap:15px;margin-bottom:15px}
.analysis-grid-main{grid-template-columns:minmax(0,1.5fr) minmax(280px,.5fr)}
.analysis-card{border-radius:20px;padding:18px;min-width:0}
.analysis-card.span-2{min-width:0}
.card-head{display:flex;justify-content:space-between;align-items:center;gap:12px;margin-bottom:14px}
.card-head h3{font-size:14px;margin:3px 0 0}
.metric-note{font-size:9px;color:var(--muted)}
.bar-list,.presence-list{display:flex;flex-direction:column;gap:10px}
.bar-row{display:grid;grid-template-columns:minmax(90px,150px) 1fr 60px;gap:10px;align-items:center;font-size:10px;color:var(--muted)}
.bar-row strong{font-weight:500;color:var(--text);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.bar-track{height:8px;border-radius:999px;background:var(--line);overflow:hidden}
.bar-fill{height:100%;border-radius:999px;background:linear-gradient(90deg,var(--accent),var(--accent-2));transition:width .45s ease}
.presence-row{display:flex;justify-content:space-between;padding:8px 0;border-bottom:1px solid var(--line);font-size:12px}
.presence-row:last-child{border:0}
.presence-name{display:flex;align-items:center;gap:7px;min-width:0}
.presence-name span{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.presence-dot{width:8px;height:8px;border-radius:50%;flex:0 0 auto}
.donut-wrap{display:grid;grid-template-columns:150px 1fr;gap:20px;align-items:center;min-height:180px}
.donut{width:150px;aspect-ratio:1;border-radius:50%;position:relative;box-shadow:inset 0 0 0 1px var(--line)}
.donut::after{content:'';position:absolute;inset:28px;border-radius:50%;background:var(--surface-strong);border:1px solid var(--line)}
.donut-center{position:absolute;inset:0;display:grid;place-items:center;z-index:2;text-align:center;pointer-events:none}
.donut-center b{font-size:21px}
.donut-center span{display:block;font-size:9px;color:var(--muted)}
.donut-legend{display:flex;flex-direction:column;gap:9px;min-width:0}
.legend-row{display:grid;grid-template-columns:9px 1fr auto;align-items:center;gap:8px;font-size:10px;color:var(--muted)}
.legend-row i{width:9px;height:9px;border-radius:50%}
.legend-row strong{font-weight:500;color:var(--text);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.scene-distribution{min-height:244px;display:block;padding:4px 0 0;overflow-x:auto;overflow-y:hidden}
.scene-chart-inner{height:220px;display:flex;align-items:stretch;gap:7px;min-width:max-content;padding:6px 4px 0;border-bottom:1px solid var(--line);background:linear-gradient(to top,color-mix(in srgb,var(--line) 55%,transparent) 1px,transparent 1px);background-size:100% 25%}
.scene-bar-wrap{width:52px;min-width:52px;height:100%;display:grid;grid-template-rows:22px 1fr 32px;align-items:end;position:relative;text-align:center}
.scene-value{font-size:8px;line-height:1;color:var(--muted);padding-bottom:5px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.scene-bar-slot{height:100%;display:flex;align-items:flex-end;justify-content:center;min-height:0}
.scene-column{width:26px;min-height:3px;border-radius:6px 6px 2px 2px;background:linear-gradient(180deg,var(--accent-2),var(--accent));opacity:.76;transition:opacity .2s ease,filter .2s ease,transform .2s ease;box-shadow:inset 0 0 0 1px color-mix(in srgb,var(--text) 5%,transparent)}
.scene-column.above-average{opacity:.92}
.scene-bar-wrap:hover .scene-column{opacity:1;filter:brightness(1.08);transform:translateY(-1px)}
.scene-axis-label{height:32px;padding-top:7px;font-size:8px;line-height:1.15;color:var(--muted);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;border-top:1px solid color-mix(in srgb,var(--line) 55%,transparent)}
.scene-chart-legend{display:flex;justify-content:space-between;gap:14px;align-items:center;padding:9px 4px 0;font-size:8px;color:var(--muted)}
.scene-chart-legend span:first-child{display:flex;align-items:center;gap:6px}.scene-chart-legend i{width:8px;height:8px;border-radius:3px;background:linear-gradient(180deg,var(--accent-2),var(--accent))}.scene-chart-legend b{color:var(--text);font-weight:600}
.detail-metrics{display:grid;grid-template-columns:1fr 1fr;gap:9px}
.detail-metric{padding:12px;border-radius:13px;background:color-mix(in srgb,var(--surface-2) 76%,transparent);border:1px solid var(--line)}
.detail-metric b{font-size:16px;display:block;margin-bottom:3px}
.detail-metric span{font-size:9px;color:var(--muted);line-height:1.35}
.heatmap-card{margin-top:0}
.heatmap-scroll{overflow:auto;padding-bottom:4px}
.heatmap{display:grid;gap:4px;min-width:max-content;align-items:center}
.heatmap-head,.heatmap-name{font-size:9px;color:var(--muted)}
.heatmap-head{writing-mode:vertical-rl;transform:rotate(180deg);height:70px;display:flex;align-items:center;justify-content:flex-start;max-width:26px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.heatmap-name{width:145px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;padding-right:8px;color:var(--text)}
.heat-cell{width:26px;height:26px;border-radius:6px;border:1px solid var(--line);display:grid;place-items:center;font-size:8px;color:transparent;background:var(--surface-2)}
.heat-cell[data-count]:hover{color:var(--text);outline:1px solid color-mix(in srgb,var(--accent) 40%,transparent)}

/* Revisions */
.revision-list{display:flex;flex-direction:column;gap:10px}
.revision-item{display:grid;grid-template-columns:90px 1fr auto;gap:16px;align-items:center;padding:16px 18px;border-radius:18px;background:var(--surface-2);border:1px solid var(--line)}
.revision-version{font-size:15px;font-weight:700}
.revision-info b{font-size:12px}
.revision-info p{font-size:10px;color:var(--muted);margin:4px 0 0}
.revision-actions{display:flex;gap:6px}
.revision-actions button{border:1px solid var(--line);background:var(--surface-2);border-radius:9px;padding:7px 9px;font-size:10px}
.revision-actions .revision-delete{color:var(--danger,#c66f72);border-color:color-mix(in srgb,var(--danger,#c66f72) 36%,var(--line));background:color-mix(in srgb,var(--danger,#c66f72) 7%,var(--surface-2))}
.revision-actions .revision-delete:hover{background:color-mix(in srgb,var(--danger,#c66f72) 13%,var(--surface-2));transform:translateY(-1px)}
.empty-state{color:var(--muted);font-size:12px;padding:18px 4px}

/* Library */
.home-view{max-width:1120px}
.book-library-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(300px,1fr));gap:12px}
.book-card{position:relative;border-radius:22px;padding:20px;background:var(--surface-2);border:1px solid var(--line);transition:.24s ease;min-height:165px;display:flex;flex-direction:column}
.book-card:hover{transform:translateY(-2px);background:var(--surface)}
.book-card.active-book{border-color:color-mix(in srgb,var(--accent) 32%,var(--line));box-shadow:inset 0 0 0 1px color-mix(in srgb,var(--accent) 12%,transparent)}
.book-card-top{display:flex;justify-content:space-between;align-items:flex-start;gap:12px}
.book-card h2{font-size:19px;line-height:1.22;margin:0;letter-spacing:-.02em}
.book-card .book-version{display:inline-flex;margin-top:8px;font-size:9px;padding:4px 7px;border-radius:999px;background:var(--accent-soft);color:var(--accent)}
.book-card-meta{display:grid;grid-template-columns:repeat(3,1fr);gap:8px;margin-top:auto;padding-top:18px}
.book-meta-cell{border-top:1px solid var(--line);padding-top:9px}
.book-meta-cell b{display:block;font-size:13px}
.book-meta-cell span{font-size:8px;color:var(--muted);text-transform:uppercase;letter-spacing:.07em}
.book-card-footer{display:flex;align-items:center;justify-content:space-between;gap:10px;margin-top:14px}
.book-card-footer small{font-size:9px;color:var(--muted)}
.book-card-actions{display:flex;gap:6px}
.book-icon-btn{width:30px;height:30px;border:1px solid var(--line);background:var(--surface-2);border-radius:9px;color:var(--muted);font-size:12px}
.book-icon-btn:hover{background:var(--accent-soft);color:var(--text)}
.book-icon-btn.danger:hover{background:var(--danger-soft);color:var(--danger)}
.empty-library{grid-column:1/-1;border-radius:22px;padding:42px 24px;text-align:center;background:var(--surface-2);border:1px dashed var(--line)}
.empty-library h2{font-size:18px;margin:0 0 7px}
.empty-library p{font-size:11px;color:var(--muted);margin:0}
.home-actions{display:grid;grid-template-columns:repeat(4,1fr);gap:10px;margin-top:12px}
.big-action{border-radius:18px;padding:18px;border:1px solid var(--line);text-align:left;display:flex;flex-direction:column;gap:5px;transition:.2s;background:var(--surface-2)}
.big-action:hover:not(.disabled){transform:translateY(-2px);background:var(--surface)}
.big-action span{font-size:15px;color:var(--accent);font-weight:700}
.big-action b{font-size:12px}
.big-action small{font-size:9px;color:var(--muted)}
.big-action.disabled{opacity:.45;cursor:default}

/* Modals */
.modal-backdrop{position:fixed;inset:0;background:rgba(12,10,8,.46);display:flex;align-items:center;justify-content:center;z-index:100;opacity:0;pointer-events:none;transition:opacity .22s ease;contain:layout paint style}
.modal-backdrop.open{opacity:1;pointer-events:auto}
.modal-backdrop.blur-ready{backdrop-filter:blur(9px);-webkit-backdrop-filter:blur(9px)}
.modal-backdrop.perf-moving{will-change:opacity}
.modal{width:min(620px,92vw);max-height:88vh;overflow:auto;border-radius:24px;padding:23px}
.modal h2{font-size:21px;margin:0 0 5px}
.modal p{font-size:11px;color:var(--muted);line-height:1.55}
.form-grid{display:grid;gap:13px;margin-top:17px}
.form-row{display:grid;gap:6px;min-width:0}
.form-row>label{font-size:9px;letter-spacing:.08em;text-transform:uppercase;color:var(--muted);font-weight:700}
.form-row input:not([type="checkbox"]):not([type="radio"]):not([type="range"]),.form-row textarea,.form-row select{width:100%;border:1px solid var(--line);background:var(--surface-2);border-radius:11px;padding:10px 11px;outline:none}
.form-row input[type="range"]{width:100%;accent-color:var(--accent)}
.form-row textarea{min-height:112px;resize:vertical}
.form-cols{display:grid;grid-template-columns:1fr 1fr;gap:10px}
.modal-actions{display:flex;justify-content:flex-end;align-items:center;gap:8px;margin-top:20px}
.modal-actions .push-left{margin-right:auto}
.color-grid{display:grid;grid-template-columns:repeat(10,1fr);gap:8px;max-width:440px}
.color-choice{aspect-ratio:1;border-radius:50%;border:2px solid transparent;min-width:0;box-shadow:inset 0 0 0 1px rgba(255,255,255,.08)}
.color-choice.selected{border-color:var(--text);box-shadow:0 0 0 2px var(--surface-strong),0 0 0 3px color-mix(in srgb,var(--text) 45%,transparent)}
.danger-copy{padding:11px 12px;border-radius:12px;background:var(--danger-soft);color:color-mix(in srgb,var(--danger) 82%,var(--text));font-size:10px;line-height:1.45}

.toast-container{position:fixed;right:20px;bottom:20px;display:flex;flex-direction:column;gap:8px;z-index:120}
.toast{min-width:220px;max-width:360px;padding:11px 13px;border-radius:14px;background:var(--surface-strong);backdrop-filter:blur(16px);border:1px solid var(--line);box-shadow:var(--shadow);font-size:11px;animation:toastIn .25s ease}
.toast b{display:block;font-size:11px;margin-bottom:2px}
.toast span{color:var(--muted)}
@keyframes toastIn{from{opacity:0;transform:translateY(8px)}to{opacity:1;transform:none}}
.mobile-only{display:none}

@media(max-width:1120px){
  .stats-grid-rich{grid-template-columns:repeat(4,1fr)}
}

@media(max-width:900px){
  body{overflow:hidden}
  .app-shell{grid-template-columns:1fr;grid-template-rows:60px 1fr;padding:8px;gap:8px}
  .rail{position:fixed;left:8px;top:8px;bottom:8px;width:72px;transform:translate3d(-100px,0,0);transition:transform .3s ease;z-index:80;backface-visibility:hidden}
  .rail.open{transform:translate3d(0,0,0)}
  .topbar{grid-column:1;grid-row:1;grid-template-columns:1fr auto;padding:0 10px}
  .main-area{grid-column:1;grid-row:2}
  .topbar-center{display:none}
  .topbar-actions .soft-btn{display:none}
  .mobile-only{display:inline-flex}
  .structure-panel{position:absolute;left:0;top:0;height:100%;width:min(82vw,330px);min-width:0;z-index:50;transform:translateX(calc(-100% - 15px));opacity:0}
  .structure-panel.mobile-open{transform:none;opacity:1}
  .structure-panel.collapsed{width:min(82vw,330px);padding:14px;border:1px solid var(--line)}
  .edge-handle{display:block!important}
  .floating-toolbar{position:sticky;top:5px;margin-top:5px;max-width:94vw;overflow-x:auto;opacity:1;transform:none}
  .floating-toolbar select{max-width:95px}
  .document-meta{width:94%}
  .multi-scene-editor{width:96%;gap:12px}
  .scene-sheet{border-radius:17px;padding:48px 24px 70px;min-height:72vh}
  .scene-editor{font-size:16px;line-height:1.78}
  .bookmark-panel{width:min(90vw,350px)}
  .view-heading{align-items:flex-start;flex-direction:column}
  .codex-layout{grid-template-columns:1fr}
  .codex-categories{position:static}
  .stats-grid-rich{grid-template-columns:repeat(4,1fr)}
  .analysis-grid,.analysis-grid-main{grid-template-columns:1fr}
  .donut-wrap{grid-template-columns:130px 1fr}
  .donut{width:130px}
  .home-actions{grid-template-columns:repeat(2,1fr)}
  .revision-item{grid-template-columns:70px 1fr}
  .revision-actions{grid-column:1/3;justify-content:flex-end}
}

@media(max-width:560px){
  .topbar-actions .primary-btn{padding:8px 10px}
  .book-title-top{max-width:42vw;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
  .home-actions{grid-template-columns:1fr}
  .book-library-grid{grid-template-columns:1fr}
  .codex-grid{grid-template-columns:1fr}
  .stats-grid-rich{grid-template-columns:1fr 1fr}
  .form-cols{grid-template-columns:1fr}
  .scene-sheet{padding-left:18px;padding-right:18px}
  .highlight-menu{display:none}
  .floating-toolbar{justify-content:flex-start}
  .content-view{width:98%;padding-top:24px}
  .view-heading h1{font-size:28px}
  .color-grid{grid-template-columns:repeat(5,1fr);max-width:280px}
  .modal{width:min(94vw,620px);padding:18px;border-radius:20px}
  .modal-actions{position:sticky;bottom:-18px;background:linear-gradient(180deg,transparent 0,var(--surface-strong) 24%);padding-top:20px;padding-bottom:2px}
  .donut-wrap{grid-template-columns:1fr;justify-items:center}
  .donut-legend{width:100%}
  .detail-metrics{grid-template-columns:1fr 1fr}
  .bar-row{grid-template-columns:90px 1fr 45px}
}

/* v0.4 — note colors / clean editor */
.note-color-grid{display:grid;grid-template-columns:repeat(8,28px);gap:8px;align-items:center}
.note-color-choice{width:28px;height:28px;border-radius:50%;border:2px solid transparent;background:var(--note-color);box-shadow:inset 0 0 0 1px rgba(255,255,255,.08);transition:.16s ease}
.note-color-choice.selected{border-color:var(--text);box-shadow:0 0 0 2px var(--surface-strong),0 0 0 3px color-mix(in srgb,var(--note-color) 58%,transparent)}
.scene-editor .user-highlight{border-radius:4px;padding:0 .04em;color:#20231f!important;text-shadow:none!important;box-decoration-break:clone;-webkit-box-decoration-break:clone}
html[data-scheme="dark"] .scene-editor .user-highlight{color:#20231f!important}
html[data-scheme="dark"] .scene-sheet{background:var(--paper,var(--surface-strong))}
html[data-scheme="dark"] .floating-toolbar{background:color-mix(in srgb,var(--surface-strong) 78%,transparent)}
html[data-scheme="dark"] .topbar,html[data-scheme="dark"] .rail,html[data-scheme="dark"] .structure-panel,html[data-scheme="dark"] .bookmark-panel{background:color-mix(in srgb,var(--surface) 88%,transparent)}

/* v0.4 — extended analysis */
.svg-chart{width:100%;min-height:220px;overflow:hidden}
.svg-chart svg{width:100%;height:220px;display:block;overflow:visible}
.chart-grid line{stroke:var(--line);stroke-width:1}
.chart-grid text{fill:var(--muted);font:9px Inter,sans-serif}
.chart-area{fill:color-mix(in srgb,var(--accent) 10%,transparent)}
.chart-line{fill:none;stroke:var(--accent);stroke-width:2.5;stroke-linecap:round;stroke-linejoin:round}
.svg-chart circle{fill:var(--accent-2);stroke:var(--surface-strong);stroke-width:2;transition:.16s ease}
.svg-chart circle:hover{r:5;fill:var(--text)}
.stacked-list{display:flex;flex-direction:column;gap:11px;max-height:340px;overflow:auto;padding-right:3px}
.stacked-row{display:grid;grid-template-columns:minmax(105px,145px) 1fr;gap:11px;align-items:center}
.stacked-label{display:flex;flex-direction:column;min-width:0;gap:2px}
.stacked-label strong{font-size:10px;font-weight:500;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.stacked-label span{font-size:8px;color:var(--muted)}
.stacked-track{height:10px;border-radius:999px;overflow:hidden;display:flex;background:var(--line);border:1px solid color-mix(in srgb,var(--line) 70%,transparent)}
.stacked-track i{display:block;height:100%}
.stacked-dialogue{background:linear-gradient(90deg,var(--accent),var(--accent-2))}
.stacked-narrative{background:color-mix(in srgb,var(--muted) 18%,transparent)}
.compact-columns{height:245px;display:flex;align-items:flex-end;gap:6px;overflow-x:auto;border-bottom:1px solid var(--line);padding:18px 4px 0}
.compact-col{min-width:28px;flex:1;height:100%;display:grid;grid-template-rows:18px 1fr 30px;align-items:end;text-align:center;position:relative}
.compact-col>span{font-size:8px;color:var(--muted);align-self:end;padding-bottom:4px}
.compact-col>i{display:block;width:72%;max-width:34px;justify-self:center;border-radius:6px 6px 2px 2px;background:linear-gradient(180deg,var(--accent-2),var(--accent));opacity:.82;min-height:10px}
.compact-col>small{font-size:7px;color:var(--muted);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;width:100%;padding-top:7px;align-self:start}
.coverage-note{font-size:9px;line-height:1.45;color:var(--muted);padding-top:7px;border-top:1px solid var(--line)}
.coverage-donut{filter:saturate(.86)}
@media(max-width:560px){.note-color-grid{grid-template-columns:repeat(4,28px)}.stacked-row{grid-template-columns:92px 1fr}.svg-chart svg{height:190px}.svg-chart{min-height:190px}}

/* v0.4 — storage reset */
.danger-zone{padding-top:12px;border-top:1px solid var(--line)}
.danger-zone small{display:block;color:var(--muted);font-size:10px;line-height:1.5;margin:-3px 0 7px}


/* v0.6 — themes, settings, quiet writing canvas */
.settings-quick{font-size:15px;opacity:.82}
.settings-quick:hover{opacity:1}
.theme-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:10px;margin-top:12px}
.theme-card{--preview-bg:#222;--preview-surface:#333;--preview-accent:#999;display:grid;grid-template-columns:50px 1fr auto;align-items:center;gap:11px;text-align:left;padding:10px;border:1px solid var(--line);border-radius:14px;background:var(--surface-2);color:var(--text);transition:.18s ease}
.theme-card:hover{transform:translateY(-1px);background:var(--accent-soft)}
.theme-card.active{border-color:color-mix(in srgb,var(--accent) 48%,var(--line));box-shadow:inset 0 0 0 1px color-mix(in srgb,var(--accent) 20%,transparent)}
.theme-preview{width:50px;height:36px;border-radius:10px;background:var(--preview-bg);position:relative;overflow:hidden;border:1px solid rgba(127,127,127,.16)}
.theme-preview:before{content:'';position:absolute;left:7px;top:7px;width:25px;height:22px;border-radius:6px;background:var(--preview-surface)}
.theme-preview:after{content:'';position:absolute;right:7px;top:8px;width:7px;height:20px;border-radius:99px;background:var(--preview-accent)}
.theme-copy{min-width:0}.theme-copy b{display:block;font-size:11px}.theme-copy small{font-size:9px;color:var(--muted)}
.theme-check{font-size:11px;color:var(--accent)}
.storage-facts{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px;margin-top:8px}
.storage-fact{padding:10px;border-radius:12px;background:var(--surface-2);border:1px solid var(--line)}
.storage-fact small{display:block;font-size:8px;color:var(--muted);text-transform:uppercase;letter-spacing:.06em}.storage-fact b{display:block;margin-top:3px;font-size:11px;overflow:hidden;text-overflow:ellipsis}
.mmbook-info{padding:11px 12px;border-radius:13px;background:var(--surface-2);border:1px solid var(--line);font-size:10px;line-height:1.55;color:var(--muted)}
@media(max-width:620px){.theme-grid{grid-template-columns:1fr}.settings-quick{display:inline-grid}.storage-facts{grid-template-columns:1fr}}

/* v0.6 — hierarchy separators inside long manuscript views */
.manuscript-separator{
  width:min(100%,920px);
  margin:34px auto 10px;
  padding:4px clamp(18px,3vw,34px) 0;
  color:var(--text);
}
.manuscript-separator .separator-kicker{
  display:block;
  font:650 10px/1.2 Inter,sans-serif;
  letter-spacing:.16em;
  color:var(--muted);
  text-transform:uppercase;
  margin-bottom:10px;
}
.manuscript-separator .separator-line{
  height:1px;
  width:100%;
  background:linear-gradient(90deg,var(--line),transparent 78%);
  margin-bottom:15px;
  opacity:.9;
}
.manuscript-separator h2{
  margin:0;
  font:500 clamp(20px,2vw,28px)/1.22 var(--editor-font, Merriweather),serif;
  letter-spacing:-.015em;
  color:var(--text);
}
.manuscript-separator.act{
  margin-top:58px;
  padding-top:22px;
}
.manuscript-separator.act .separator-line{
  height:1px;
  background:linear-gradient(90deg,color-mix(in srgb,var(--accent) 50%,var(--line)),transparent 84%);
}
.manuscript-separator.act h2{
  font-size:clamp(25px,2.6vw,36px);
}
.manuscript-separator.chapter{
  margin-top:28px;
}
.manuscript-separator + .scene-sheet{margin-top:10px}
@media(max-width:900px){
  .manuscript-separator{margin-top:24px;padding-left:16px;padding-right:16px}
  .manuscript-separator.act{margin-top:40px}
}


/* v0.8 — typography, trim formats, cover art and scroll tracking */
.document-meta,.multi-scene-editor{width:min(var(--manuscript-width,850px),92%)}
.scene-sheet{min-height:var(--scene-min-height,70vh)}
.scene-editor{font-size:var(--editor-size,17px);line-height:var(--editor-line-height,1.82)}
.scene-editor p{margin:0 0 var(--editor-paragraph-spacing,.9em);text-indent:var(--editor-indent,0)}
.multi-scene-editor[data-align="justify"] .scene-editor{text-align:justify;text-justify:inter-word}
.multi-scene-editor[data-align="left"] .scene-editor{text-align:left}
.multi-scene-editor[data-chicago="true"] .scene-editor p:first-child,
.multi-scene-editor[data-chicago="true"] .scene-editor h1 + p,
.multi-scene-editor[data-chicago="true"] .scene-editor h2 + p,
.multi-scene-editor[data-chicago="true"] .scene-editor h3 + p{ text-indent:0 }
.tree-row.context-active{background:color-mix(in srgb,var(--accent-soft) 58%,transparent);color:color-mix(in srgb,var(--text) 88%,var(--muted));box-shadow:inset 2px 0 0 color-mix(in srgb,var(--accent) 26%,transparent)}
.tree-row.active{background:color-mix(in srgb,var(--accent-soft) 100%,transparent);color:var(--text);box-shadow:inset 2px 0 0 color-mix(in srgb,var(--accent) 66%,transparent)}
.floating-toolbar .tool-text{font-weight:700;letter-spacing:-.04em;font-family:Georgia,serif}

/* Scene separator modes — purely visual */
.multi-scene-editor[data-scene-divider="line"]{gap:0}
.multi-scene-editor[data-scene-divider="line"] .scene-sheet{background:transparent!important;box-shadow:none!important;border-radius:0;border-bottom:1px solid var(--line);padding-top:58px;margin:0}
.multi-scene-editor[data-scene-divider="dots"]{gap:0}
.multi-scene-editor[data-scene-divider="dots"] .scene-sheet{background:transparent!important;box-shadow:none!important;border-radius:0;margin:0;padding-bottom:100px}
.multi-scene-editor[data-scene-divider="dots"] .scene-sheet:not(:last-child)::after{content:'•••';position:absolute;left:50%;bottom:32px;transform:translateX(-50%);letter-spacing:.45em;color:var(--muted);font-size:10px}
.multi-scene-editor[data-scene-divider="none"]{gap:0}
.multi-scene-editor[data-scene-divider="none"] .scene-sheet{background:transparent!important;box-shadow:none!important;border-radius:0;margin:0;padding-bottom:58px;padding-top:58px}

.typography-head small{font-size:9px;color:var(--muted);letter-spacing:.12em}.typography-head h2{margin:5px 0 6px}.typography-head p{margin:0;color:var(--muted);font-size:11px;line-height:1.5}
.typography-grid{display:grid;grid-template-columns:1fr 1fr;gap:18px 22px;margin-top:22px}.type-setting{min-width:0}.type-setting.span-2{grid-column:1/3}.type-setting>label{display:block;font-size:11px;font-weight:600;margin-bottom:8px}.type-setting select{width:100%;border:1px solid var(--line);background:var(--surface-2);border-radius:11px;padding:10px 11px;outline:none}.setting-help,.type-setting>small{display:block;margin-top:7px;color:var(--muted);font-size:9px;line-height:1.45}
.choice-strip{display:flex;gap:5px;flex-wrap:wrap}.choice-btn{height:42px;min-width:44px;border:1px solid var(--line);background:var(--surface-2);border-radius:9px;color:var(--muted);padding:0 10px;font-size:10px;transition:.16s ease}.choice-btn:hover{background:var(--accent-soft);color:var(--text)}.choice-btn.active{border-color:color-mix(in srgb,var(--accent) 60%,var(--line));background:var(--accent-soft);color:var(--text);box-shadow:inset 0 0 0 1px color-mix(in srgb,var(--accent) 16%,transparent)}
.text-size-strip .choice-btn:nth-child(1){font-size:10px}.text-size-strip .choice-btn:nth-child(2){font-size:13px}.text-size-strip .choice-btn:nth-child(3){font-size:16px}.text-size-strip .choice-btn:nth-child(4){font-size:19px}.icon-strip .choice-btn{position:relative;color:transparent;width:45px;padding:0}.icon-strip .choice-btn::before{content:'';position:absolute;left:9px;right:9px;top:12px;height:17px;background:repeating-linear-gradient(to bottom,var(--muted) 0 2px,transparent 2px 5px);opacity:.8}.icon-strip .choice-btn.active::before{background:repeating-linear-gradient(to bottom,var(--text) 0 2px,transparent 2px 5px)}.icon-strip.five .choice-btn{width:42px;min-width:42px}.toggle-line{display:flex!important;align-items:center;gap:7px;margin-top:9px!important;color:var(--muted);font-weight:500!important}.toggle-line input{accent-color:var(--accent)}

@media(max-width:700px){.typography-grid{grid-template-columns:1fr}.type-setting.span-2{grid-column:1}.choice-strip{gap:4px}}
/* v0.8 typography icon semantics */
.choice-btn[data-pref-group="lineHeight"]::before{background:repeating-linear-gradient(to bottom,var(--muted) 0 2px,transparent 2px 5px)}
.choice-btn[data-pref-group="lineHeight"]:nth-child(1)::before{background-size:100% 3px}
.choice-btn[data-pref-group="lineHeight"]:nth-child(2)::before{background-size:100% 4px}
.choice-btn[data-pref-group="lineHeight"]:nth-child(3)::before{background-size:100% 5px}
.choice-btn[data-pref-group="lineHeight"]:nth-child(4)::before{background-size:100% 6px}
.choice-btn[data-pref-group="indent"]::before{left:9px;right:9px;background:linear-gradient(var(--muted),var(--muted)) 0 0/100% 2px no-repeat,linear-gradient(var(--muted),var(--muted)) 20% 5px/80% 2px no-repeat,linear-gradient(var(--muted),var(--muted)) 0 10px/100% 2px no-repeat,linear-gradient(var(--muted),var(--muted)) 0 15px/100% 2px no-repeat}
.choice-btn[data-pref-group="indent"]:nth-child(1)::before{background:repeating-linear-gradient(to bottom,var(--muted) 0 2px,transparent 2px 5px)}
.choice-btn[data-pref-group="indent"]:nth-child(3)::before{background:linear-gradient(var(--muted),var(--muted)) 0 0/100% 2px no-repeat,linear-gradient(var(--muted),var(--muted)) 34% 5px/66% 2px no-repeat,linear-gradient(var(--muted),var(--muted)) 0 10px/100% 2px no-repeat,linear-gradient(var(--muted),var(--muted)) 0 15px/100% 2px no-repeat}
.choice-btn[data-pref-group="indent"]:nth-child(4)::before{background:linear-gradient(var(--muted),var(--muted)) 0 0/100% 2px no-repeat,linear-gradient(var(--muted),var(--muted)) 48% 5px/52% 2px no-repeat,linear-gradient(var(--muted),var(--muted)) 0 10px/100% 2px no-repeat,linear-gradient(var(--muted),var(--muted)) 0 15px/100% 2px no-repeat}
.choice-btn[data-pref-group="paragraphSpacing"]::before{background:linear-gradient(var(--muted),var(--muted)) 0 0/100% 2px no-repeat,linear-gradient(var(--muted),var(--muted)) 0 4px/100% 2px no-repeat,linear-gradient(var(--muted),var(--muted)) 0 12px/100% 2px no-repeat,linear-gradient(var(--muted),var(--muted)) 0 16px/100% 2px no-repeat}
.choice-btn[data-pref-group="paragraphSpacing"]:nth-child(1)::before{background:repeating-linear-gradient(to bottom,var(--muted) 0 2px,transparent 2px 4px)}
.choice-btn[data-pref-group="paragraphSpacing"]:nth-child(3)::before{background:linear-gradient(var(--muted),var(--muted)) 0 0/100% 2px no-repeat,linear-gradient(var(--muted),var(--muted)) 0 4px/100% 2px no-repeat,linear-gradient(var(--muted),var(--muted)) 0 13px/100% 2px no-repeat,linear-gradient(var(--muted),var(--muted)) 0 17px/100% 2px no-repeat}
.choice-btn[data-pref-group="paragraphSpacing"]:nth-child(4)::before{background:linear-gradient(var(--muted),var(--muted)) 0 0/100% 2px no-repeat,linear-gradient(var(--muted),var(--muted)) 0 4px/100% 2px no-repeat,linear-gradient(var(--muted),var(--muted)) 0 15px/100% 2px no-repeat}
.choice-btn[data-pref-group="pageWidth"]::before{top:11px;bottom:11px;height:auto;left:50%;right:auto;transform:translateX(-50%);background:repeating-linear-gradient(to bottom,var(--muted) 0 2px,transparent 2px 5px)}
.choice-btn[data-pref-group="pageWidth"]:nth-child(1)::before{width:8px}.choice-btn[data-pref-group="pageWidth"]:nth-child(2)::before{width:14px}.choice-btn[data-pref-group="pageWidth"]:nth-child(3)::before{width:20px}.choice-btn[data-pref-group="pageWidth"]:nth-child(4)::before{width:27px}.choice-btn[data-pref-group="pageWidth"]:nth-child(5)::before{width:32px}


/* v0.81 — select readability, tablet alignment and phone guard */
select{
  color-scheme:inherit;
  color:var(--text);
  background-color:var(--bg2);
}
select option{
  color:var(--text)!important;
  background-color:var(--bg2)!important;
}
select optgroup{
  color:var(--text)!important;
  background-color:var(--bg)!important;
  font-weight:700;
}
.form-row select,.type-setting select{
  color:var(--text);
  background:var(--surface-strong);
  border-color:var(--line);
}
.floating-toolbar select{
  color:var(--text);
  background:var(--surface-2);
  padding-inline:7px;
}
html[data-scheme="dark"] select{color-scheme:dark}
html[data-scheme="light"] select{color-scheme:light}

/* Keep the writing toolbar geometrically centered, not centered by its content flow. */
.floating-toolbar{
  left:50%;
  transform:translate(-50%,-5px);
}
.floating-toolbar:hover,.floating-toolbar.focused{
  transform:translate(-50%,0);
}


@media(max-width:900px){
  .editor-stage{width:100%;min-width:0}
  .floating-toolbar{
    position:sticky;
    left:auto;
    top:5px;
    align-self:center;
    width:max-content;
    max-width:calc(100vw - 24px);
    margin:5px auto 0;
    transform:none!important;
    overflow-x:auto;
    overflow-y:hidden;
    scrollbar-width:thin;
  }
  .floating-toolbar select{max-width:112px;flex:0 0 auto}
  .modal-backdrop{padding:12px}
  .modal{width:min(680px,calc(100vw - 24px));max-height:calc(100dvh - 24px);margin:auto}
  .document-meta{width:min(94vw,850px);margin-inline:auto}
  .bookmark-panel{right:0}
  .toast-container{right:12px;bottom:12px}
}

/* Unified select chrome: removes the bright operating-system arrow block. */
select:not([multiple]){
  -webkit-appearance:none;
  appearance:none;
  padding-right:30px!important;
  background-image:
    linear-gradient(45deg,transparent 50%,var(--muted) 50%),
    linear-gradient(135deg,var(--muted) 50%,transparent 50%);
  background-position:calc(100% - 13px) 50%,calc(100% - 9px) 50%;
  background-size:5px 5px,5px 5px;
  background-repeat:no-repeat;
}
.floating-toolbar select:not([multiple]){padding-right:25px!important;background-position:calc(100% - 11px) 50%,calc(100% - 7px) 50%}
@media(max-width:900px){.floating-toolbar{scrollbar-width:none}.floating-toolbar::-webkit-scrollbar{display:none}}

/* v0.82 — tablet viewport hardening and responsive audit */
html,body{
  width:100%;
  height:100%;
  min-height:100%;
  overflow:hidden;
  overscroll-behavior:none;
}
.app-shell{
  height:100vh;
  min-height:100vh;
  max-height:100vh;
  overflow:hidden;
}
@supports(height:100dvh){
  .app-shell{height:100dvh;min-height:100dvh;max-height:100dvh}
}
.main-area,.view,.editor-stage{min-height:0;overflow:hidden}
.editor-viewport,.content-view{
  min-height:0;
  overscroll-behavior:contain;
  -webkit-overflow-scrolling:touch;
  scrollbar-gutter:stable;
}
.editor-viewport{
  padding-bottom:max(70px,calc(env(safe-area-inset-bottom) + 34px));
}
.content-view{
  padding-bottom:max(64px,calc(env(safe-area-inset-bottom) + 30px));
}

/* Tablet layout: use overlay navigation and viewport-centered controls on touch devices. */
@media (max-width:900px), (pointer:coarse) and (min-width:561px) and (max-width:1366px){
  .app-shell{
    grid-template-columns:1fr;
    grid-template-rows:60px minmax(0,1fr);
    padding:8px;
    gap:8px;
  }
  .rail{
    position:fixed;
    left:8px;top:8px;bottom:8px;
    width:72px;
    transform:translateX(-100px);
    transition:.3s;
    z-index:80;
  }
  .rail.open{transform:none}
  .topbar{
    grid-column:1;grid-row:1;
    grid-template-columns:minmax(0,1fr) auto;
    padding:0 10px;
  }
  .main-area{grid-column:1;grid-row:2}
  .topbar-center{display:none}
  .topbar-actions .soft-btn{display:none}
  .mobile-only{display:inline-flex}
  .structure-panel{
    position:absolute;left:0;top:0;height:100%;
    width:min(72vw,340px);min-width:0;z-index:50;
    transform:translateX(calc(-100% - 15px));opacity:0;
  }
  .structure-panel.mobile-open{transform:none;opacity:1}
  .structure-panel.collapsed{width:min(72vw,340px);padding:14px;border:1px solid var(--line)}
  .edge-handle{display:block!important}

  .floating-toolbar{
    position:fixed;
    top:76px;
    left:50%;
    right:auto;
    width:max-content;
    max-width:calc(100vw - 28px);
    margin:0;
    transform:translateX(-50%)!important;
    opacity:.96;
    overflow-x:auto;
    overflow-y:hidden;
    scrollbar-width:none;
    z-index:70;
  }
  .floating-toolbar::-webkit-scrollbar{display:none}
  .floating-toolbar:hover,.floating-toolbar.focused{transform:translateX(-50%)!important;opacity:1}
  .floating-toolbar select{max-width:108px;flex:0 0 auto}
  .document-meta{width:min(94vw,var(--manuscript-width,850px));margin-inline:auto;padding-top:42px;height:76px}
  .multi-scene-editor{width:min(94vw,var(--manuscript-width,850px));gap:14px}
  .scene-sheet{border-radius:18px;padding:50px clamp(28px,6vw,64px) 68px;min-height:66dvh}
  .bookmark-panel{width:min(78vw,360px);right:0}

  .content-view{width:min(100%,1100px);padding:24px 12px 64px}
  .analysis-view{width:100%}
  .stats-grid-rich{grid-template-columns:repeat(4,minmax(0,1fr))}
  .analysis-grid,.analysis-grid-main{grid-template-columns:1fr}
  .analysis-card{padding:16px}
  .analysis-card.span-2{grid-column:auto}
  .card-head{align-items:flex-start;flex-wrap:wrap}
  .scene-distribution,.heatmap-scroll,.compact-columns,.svg-chart{max-width:100%;min-width:0}
  .donut-wrap{grid-template-columns:140px minmax(0,1fr)}
  .donut{width:140px}
  .bar-row{grid-template-columns:minmax(86px,140px) minmax(100px,1fr) 54px}
  .modal-backdrop{padding:12px}
  .modal{width:min(720px,calc(100vw - 24px));max-height:calc(100dvh - 24px)}
  .toast-container{right:12px;bottom:max(12px,env(safe-area-inset-bottom))}
}

/* Tablet portrait: simplify dense analysis cards further. */
@media (pointer:coarse) and (min-width:561px) and (max-width:820px){
  .stats-grid-rich{grid-template-columns:repeat(2,minmax(0,1fr))}
  .stat-card b{font-size:21px}
  .donut-wrap{grid-template-columns:1fr;justify-items:center}
  .donut-legend{width:100%}
  .detail-metrics{grid-template-columns:1fr 1fr}
  .bar-row{grid-template-columns:minmax(76px,112px) minmax(80px,1fr) 46px;gap:8px}
  .scene-bar-wrap{width:48px;min-width:48px}
  .scene-column{width:23px}
  .book-library-grid{grid-template-columns:1fr}
  .codex-grid{grid-template-columns:1fr 1fr}
}

/* Prevent accidental outer-page scrolling if a mobile browser changes its UI height. */
@media (pointer:coarse){
  body{position:fixed;inset:0;width:100%;height:100%;touch-action:manipulation}
  .editor-viewport,.content-view,.structure-panel,.bookmark-panel,.modal{touch-action:pan-y pinch-zoom}
}

/* v0.90 — Firebase cloud account & sync */
.save-lines{display:flex;align-items:center;gap:7px;margin-top:2px;min-width:0}
.save-lines .save-state,.save-lines .cloud-state{margin-top:0;white-space:nowrap}
.cloud-state{font-size:10px;color:var(--muted);display:inline-flex;align-items:center;gap:5px}
.cloud-state::before{content:'';width:5px;height:5px;border-radius:50%;background:var(--muted);opacity:.7}
.cloud-state[data-state="synced"]{color:color-mix(in srgb,var(--accent) 84%,var(--text))}
.cloud-state[data-state="synced"]::before{background:var(--accent);box-shadow:0 0 0 3px color-mix(in srgb,var(--accent) 10%,transparent)}
.cloud-state[data-state="syncing"]::before{background:var(--accent);animation:cloudPulse 1.1s ease-in-out infinite}
.cloud-state[data-state="pending"]::before{background:#b39a6e}
.cloud-state[data-state="error"]{color:var(--danger)}
.cloud-state[data-state="error"]::before{background:var(--danger)}
.cloud-state[data-state="offline"]::before{background:var(--muted)}
@keyframes cloudPulse{50%{opacity:.25;transform:scale(.72)}}
.cloud-btn{height:34px;padding:0 10px;border-radius:11px;border:1px solid var(--line);background:var(--surface-2);color:var(--text);display:inline-flex;align-items:center;gap:7px;font-size:11px;transition:.2s ease}
.cloud-btn:hover{background:var(--surface-strong)}
.cloud-dot{width:7px;height:7px;border-radius:50%;background:var(--muted)}
.cloud-btn[data-state="synced"] .cloud-dot{background:var(--accent);box-shadow:0 0 0 3px color-mix(in srgb,var(--accent) 10%,transparent)}
.cloud-btn[data-state="syncing"] .cloud-dot{background:var(--accent);animation:cloudPulse 1.1s ease-in-out infinite}
.cloud-btn[data-state="pending"] .cloud-dot{background:#b39a6e}
.cloud-btn[data-state="error"] .cloud-dot{background:var(--danger)}
.cloud-account{display:grid;grid-template-columns:46px minmax(0,1fr);gap:12px;align-items:center;padding:12px;border:1px solid var(--line);background:var(--surface-2);border-radius:16px}
.cloud-avatar{width:46px;height:46px;border-radius:50%;object-fit:cover;background:var(--surface-strong);border:1px solid var(--line);display:grid;place-items:center;font-weight:700;color:var(--accent)}
.cloud-account-copy{min-width:0}.cloud-account-copy b,.cloud-account-copy span{display:block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.cloud-account-copy span{font-size:10px;color:var(--muted);margin-top:3px}
.cloud-panel-status{display:grid;grid-template-columns:repeat(3,1fr);gap:8px;margin-top:14px}
.cloud-panel-status>div{padding:10px;border:1px solid var(--line);background:var(--surface-2);border-radius:13px}.cloud-panel-status small{display:block;font-size:8px;color:var(--muted);text-transform:uppercase;letter-spacing:.08em}.cloud-panel-status b{display:block;margin-top:4px;font-size:13px}
.cloud-help{margin-top:14px;padding:12px 13px;border-radius:14px;background:var(--surface-2);border:1px solid var(--line);font-size:10px;color:var(--muted);line-height:1.55}
.cloud-help b{color:var(--text)}
.cloud-login-hero{text-align:center;padding:14px 6px 4px}.cloud-login-icon{width:52px;height:52px;margin:0 auto 12px;display:grid;place-items:center;border-radius:17px;background:var(--surface-2);border:1px solid var(--line);font-size:22px}.google-login-btn{width:100%;justify-content:center;margin-top:14px;min-height:42px}.cloud-conflict{color:#b79c76}
@media(max-width:900px){
  .save-lines{gap:5px}.cloud-state{display:none}
  .cloud-btn{width:34px;padding:0;justify-content:center}.cloud-btn-label{display:none}
  .topbar-actions{gap:6px}
}
@media (pointer:coarse) and (min-width:561px) and (max-width:1366px){
  .cloud-btn{display:inline-flex!important}
}

/* v0.91 — entry experience, icon system & sync details */
.entry-gate{position:fixed;inset:0;z-index:900;display:grid;place-items:center;overflow:hidden;background:#171612;color:#efe9df;transition:opacity .55s ease,visibility .55s ease}
.entry-gate::before{content:"";position:absolute;inset:0;background:radial-gradient(circle at 14% 18%,rgba(166,145,113,.13),transparent 36%),radial-gradient(circle at 83% 78%,rgba(98,115,93,.11),transparent 34%),linear-gradient(130deg,#171612 0%,#1b1a16 45%,#151713 100%)}
.entry-gate::after{content:"";position:absolute;inset:0;opacity:.16;pointer-events:none;background-image:linear-gradient(rgba(255,255,255,.018) 1px,transparent 1px),linear-gradient(90deg,rgba(255,255,255,.014) 1px,transparent 1px);background-size:46px 46px;mask-image:linear-gradient(to bottom,black,transparent 88%)}
.entry-gate.leaving{opacity:0;visibility:hidden}.entry-gate.hidden-gate{display:none}
.entry-shell{position:relative;z-index:2;width:min(1180px,calc(100vw - 64px));min-height:min(720px,calc(100dvh - 70px));display:grid;grid-template-columns:minmax(0,1.18fr) minmax(360px,.72fr);gap:clamp(50px,7vw,110px);align-items:center;padding:clamp(28px,4vw,58px)}
.entry-brand-block{align-self:center}.entry-kicker{margin:24px 0 20px;font-size:10px;letter-spacing:.18em;text-transform:uppercase;color:#9f998f}
.entry-brand-block h1{font-family:"Libre Baskerville",Georgia,serif;font-size:clamp(42px,5.7vw,78px);font-weight:400;line-height:1.06;letter-spacing:-.055em;margin:0;max-width:760px}.entry-brand-block h1 em{font-style:italic;color:#b3aa99;font-weight:400}
.entry-lead{max-width:610px;color:#a8a298;font-size:14px;line-height:1.75;margin:24px 0 0}.entry-features{display:flex;flex-wrap:wrap;gap:8px;margin-top:30px}.entry-features span{padding:7px 10px;border:1px solid rgba(239,233,223,.12);border-radius:999px;color:#b8b1a6;font-size:9px;letter-spacing:.08em;text-transform:uppercase;background:rgba(255,255,255,.025)}
.writer-logo{display:inline-flex;align-items:center;height:64px;position:relative;isolation:isolate}.writer-logo-mm{font:700 clamp(40px,4.5vw,58px)/1 Inter,sans-serif;letter-spacing:-.085em;color:#f2ede4}.writer-logo-mm>span{color:#a79172;display:inline-block;animation:logoDot 3.4s ease-in-out infinite}.writer-logo-divider{width:1px;height:34px;background:rgba(239,233,223,.2);margin:0 16px 0 20px;transform-origin:center;animation:logoLine 1.15s ease both}.writer-logo-word{font:600 11px/1 Inter,sans-serif;letter-spacing:.28em;color:#9eaa99;transform:translateY(1px)}.writer-logo-caret{width:1px;height:18px;margin-left:8px;background:#9eaa99;animation:logoCaret 1.25s steps(1,end) infinite}
@keyframes logoDot{0%,70%,100%{opacity:1;transform:translateY(0)}82%{opacity:.42;transform:translateY(-2px)}}@keyframes logoLine{from{transform:scaleY(0);opacity:0}to{transform:scaleY(1);opacity:1}}@keyframes logoCaret{0%,48%{opacity:1}49%,100%{opacity:.12}}
.entry-access{border-color:rgba(239,233,223,.105);background:rgba(41,40,34,.62);box-shadow:0 35px 90px rgba(0,0,0,.28);border-radius:28px;padding:clamp(26px,3.2vw,42px);backdrop-filter:blur(30px) saturate(.8);-webkit-backdrop-filter:blur(30px) saturate(.8)}.entry-access small{font-size:9px;letter-spacing:.18em;color:#918b81}.entry-access h2{font-family:"Libre Baskerville",Georgia,serif;font-weight:400;font-size:25px;letter-spacing:-.03em;margin:10px 0 9px}.entry-access p{font-size:11px;line-height:1.65;color:#a8a298;margin:0}
.entry-login-btn,.entry-guest-btn{width:100%;height:48px;border-radius:14px;transition:.22s ease}.entry-login-btn{margin-top:24px;border:1px solid rgba(255,255,255,.13);background:#ede7dc;color:#191814;display:grid;grid-template-columns:26px 1fr 20px;align-items:center;text-align:left;padding:0 15px}.entry-login-btn:hover{transform:translateY(-1px);box-shadow:0 14px 30px rgba(0,0,0,.18)}.entry-login-btn b{font-size:11px;font-weight:650}.google-g{width:22px;height:22px;display:grid;place-items:center;border-radius:50%;background:#fff;color:#3c4043;font-weight:800;font-family:Inter,sans-serif}.entry-guest-btn{margin-top:8px;border:1px solid rgba(239,233,223,.10);background:transparent;color:#aaa49a;font-size:10px}.entry-guest-btn:hover{color:#eee8de;background:rgba(255,255,255,.035)}
.entry-status{display:flex;align-items:center;gap:7px;margin-top:20px;color:#817c73;font-size:9px}.entry-status i{width:6px;height:6px;border-radius:50%;background:#777269}.entry-status[data-state="working"] i{background:#a79172;animation:cloudPulse 1s ease infinite}.entry-status[data-state="ok"]{color:#9eaa99}.entry-status[data-state="ok"] i{background:#9eaa99}.entry-status[data-state="error"]{color:#bd857b}.entry-status[data-state="error"] i{background:#bd857b}
.entry-warning-mark{margin:22px 0 4px;padding:18px;border-radius:15px;border:1px solid rgba(167,145,114,.22);background:rgba(167,145,114,.07);font:600 15px/1 Inter,sans-serif;letter-spacing:.1em;color:#c0ad91}.entry-success{text-align:center;padding:18px 0}.entry-success-icon{width:54px;height:54px;margin:0 auto 18px;border-radius:50%;display:grid;place-items:center;border:1px solid rgba(158,170,153,.35);background:rgba(158,170,153,.08);color:#a9b7a4;font-size:20px;animation:entrySuccess .5s ease both}@keyframes entrySuccess{from{transform:scale(.7);opacity:0}to{transform:scale(1);opacity:1}}
.entry-footer{position:absolute;left:clamp(28px,4vw,58px);right:clamp(28px,4vw,58px);bottom:6px;display:flex;justify-content:space-between;color:#706b63;font-size:8px;letter-spacing:.12em;text-transform:uppercase}.entry-orbit{position:absolute;border:1px solid rgba(239,233,223,.04);border-radius:50%;pointer-events:none}.entry-orbit-a{width:520px;height:520px;right:-260px;top:-220px;animation:orbitDrift 18s ease-in-out infinite alternate}.entry-orbit-b{width:360px;height:360px;left:-190px;bottom:-150px;animation:orbitDrift 14s ease-in-out infinite alternate-reverse}@keyframes orbitDrift{to{transform:translate(24px,18px) scale(1.04)}}

/* Unified line icon language */
.brand{display:grid;place-items:center;background:var(--surface-2);color:var(--accent);box-shadow:none}.rail-icon-wrap{width:25px;height:25px;display:grid;place-items:center}.rail-icon{width:21px;height:21px;fill:none;stroke:currentColor;stroke-width:1.55;stroke-linecap:round;stroke-linejoin:round;transition:transform .3s cubic-bezier(.2,.7,.2,1),stroke-width .25s ease}.brand .rail-icon{width:23px;height:23px}.brand:hover .rail-icon{transform:perspective(70px) rotateY(-13deg) translateY(-1px)}.rail-btn:hover .rail-icon,.rail-btn.active .rail-icon{transform:translateY(-1px) scale(1.06);stroke-width:1.8}.rail-btn:active .rail-icon{transform:scale(.94)}.rail-btn span.rail-icon-wrap{font-weight:400}

/* Cover-free library */
.book-card-body{display:grid;grid-template-columns:48px 1fr;gap:14px;min-height:100%}.book-card-mark{width:44px;height:44px;border-radius:13px;display:grid;place-items:center;background:var(--accent-soft);color:var(--accent);border:1px solid color-mix(in srgb,var(--accent) 15%,var(--line))}.book-card-mark svg{width:21px;height:21px;fill:none;stroke:currentColor;stroke-width:1.45;stroke-linecap:round;stroke-linejoin:round}.book-card-copy{display:flex;flex-direction:column;min-width:0}.book-card{min-height:170px}.book-card h2{font-size:17px}

.sync-detail-grid,.sync-settings{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px;margin-top:12px}.sync-detail-grid>div,.sync-settings>div{padding:10px 11px;border:1px solid var(--line);background:var(--surface-2);border-radius:12px}.sync-detail-grid small,.sync-settings small{display:block;font-size:8px;color:var(--muted);text-transform:uppercase;letter-spacing:.08em}.sync-detail-grid b,.sync-settings b{display:block;margin-top:4px;font-size:10px;font-weight:600;line-height:1.35}.sync-settings+button{margin-top:9px}
.revision-lock{text-align:center;max-width:520px;margin:60px auto;padding:34px 26px;border:1px solid var(--line);background:var(--surface-2);border-radius:22px}.revision-lock-icon{width:50px;height:50px;margin:0 auto 14px;border-radius:15px;display:grid;place-items:center;background:var(--accent-soft);color:var(--accent);font-size:22px}.revision-lock h2{font-size:18px;margin:0 0 8px}.revision-lock p{font-size:11px;line-height:1.6;color:var(--muted);margin:0 0 18px}

@media(max-width:900px){.entry-shell{width:min(760px,calc(100vw - 34px));grid-template-columns:1fr;gap:26px;min-height:auto;max-height:calc(100dvh - 26px);overflow:auto;padding:28px 22px}.entry-brand-block h1{font-size:clamp(34px,7vw,54px)}.entry-lead{font-size:12px}.entry-features{margin-top:18px}.entry-access{padding:25px}.entry-footer{position:static;grid-column:1;order:3;margin-top:0;padding:0 2px 4px}.writer-logo{height:52px}.writer-logo-mm{font-size:42px}.sync-settings{grid-template-columns:1fr 1fr}}
@media(max-height:720px) and (min-width:901px){.entry-shell{min-height:calc(100dvh - 24px);padding-top:22px;padding-bottom:22px}.entry-brand-block h1{font-size:48px}.entry-features{margin-top:18px}.entry-kicker{margin:18px 0 14px}.entry-lead{margin-top:16px}.entry-access{padding:26px}.entry-footer{display:none}}
.rail-btn[hidden]{display:none!important}

/* v0.92 — outline workspace, coherent library and entry hardening */
[hidden]{display:none!important}
.entry-access [hidden]{display:none!important}
.entry-gate button{position:relative;z-index:3;pointer-events:auto;touch-action:manipulation;-webkit-tap-highlight-color:transparent}
.entry-login-btn,.entry-guest-btn{appearance:none;-webkit-appearance:none;user-select:none}
.entry-guest-btn:active,.entry-login-btn:active{transform:translateY(1px) scale(.995)}

/* Keep writer-only controls out of the way in the other workspaces. */
html:not([data-route="writer"]) #scopeGroup{visibility:hidden;pointer-events:none}
html:not([data-route="writer"]) #codexToggle,
html:not([data-route="writer"]) #bookmarkPanelBtn{display:none}

.rail-more .rail-icon circle{fill:currentColor;stroke:none}
.rail-more .rail-icon-wrap{transition:transform .25s ease}
.rail-more:hover .rail-icon-wrap{transform:translateY(-1px) scale(1.06)}

.btn-svg,.action-icon,.meta-icon{display:inline-grid;place-items:center;flex:0 0 auto}
.btn-svg{width:17px;height:17px;margin-right:6px}
.btn-svg svg,.action-icon svg,.meta-icon svg,.book-icon-btn svg,.book-open-btn svg,.outline-icon-btn svg{width:100%;height:100%;fill:none;stroke:currentColor;stroke-width:1.55;stroke-linecap:round;stroke-linejoin:round}
.icon-text-btn{display:inline-flex;align-items:center;justify-content:center}

/* Outline / structure workspace */
.outline-view{max-width:1180px}
.outline-heading{align-items:flex-end}
.outline-heading .heading-actions{align-self:flex-end}
.outline-legend{min-height:38px;display:flex;align-items:center;gap:7px;flex-wrap:wrap;margin:0 0 12px;padding:9px 12px;border:1px solid var(--line);border-radius:14px;background:color-mix(in srgb,var(--surface-2) 72%,transparent);backdrop-filter:blur(16px)}
.outline-legend-label{font-size:8px;letter-spacing:.14em;color:var(--muted);margin-right:3px}
.outline-legend-empty{font-size:10px;color:var(--muted)}
.outline-tree{display:flex;flex-direction:column;gap:16px;padding-bottom:40px}
.outline-act{border-radius:23px;padding:0;overflow:hidden;border:1px solid var(--line);background:color-mix(in srgb,var(--surface) 84%,transparent);box-shadow:0 18px 45px rgba(0,0,0,.08)}
.outline-act-head{display:flex;align-items:flex-start;justify-content:space-between;gap:16px;padding:19px 20px;background:color-mix(in srgb,var(--surface-strong) 70%,transparent);border-bottom:1px solid var(--line)}
.outline-chapters{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px;padding:14px}
.outline-chapter{border:1px solid var(--line);border-radius:17px;background:color-mix(in srgb,var(--surface-2) 82%,transparent);overflow:hidden;min-width:0}
.outline-chapter-head{display:flex;align-items:flex-start;justify-content:space-between;gap:10px;padding:14px 14px 12px;border-bottom:1px solid color-mix(in srgb,var(--line) 78%,transparent)}
.outline-scenes{display:flex;flex-direction:column}
.outline-scene{display:flex;align-items:flex-start;justify-content:space-between;gap:10px;padding:12px 13px;border-bottom:1px solid color-mix(in srgb,var(--line) 58%,transparent);transition:background .18s ease,transform .18s ease}
.outline-scene:last-child{border-bottom:0}
.outline-scene:hover{background:color-mix(in srgb,var(--accent-soft) 35%,transparent)}
.outline-node-main{min-width:0;display:flex;flex-direction:column;gap:7px}
.outline-node-title{display:flex;flex-direction:column;gap:4px;min-width:0}
.outline-title-button{border:0;background:transparent;color:var(--text);padding:0;text-align:left;font:inherit;min-width:0;display:block}
.outline-title-button span{display:block;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;font-weight:650;letter-spacing:-.015em}
.outline-act-head .outline-title-button span{font-size:19px}
.outline-chapter-head .outline-title-button span{font-size:14px}
.outline-scene .outline-title-button span{font-size:11px;font-weight:600}
.outline-title-button:hover span{color:var(--accent)}
.outline-title-input{display:block;width:min(100%,520px);min-width:120px;height:32px;border:1px solid color-mix(in srgb,var(--accent) 45%,var(--line));border-radius:9px;background:var(--surface-2);color:var(--text);padding:0 9px;font:inherit;font-weight:600;letter-spacing:-.015em;outline:none;box-shadow:0 0 0 3px color-mix(in srgb,var(--accent) 10%,transparent)}
.outline-act-head .outline-title-input{font-size:19px;height:38px}.outline-chapter-head .outline-title-input{font-size:14px}.outline-scene .outline-title-input{font-size:11px;height:30px}
.outline-node-meta{font-size:8px;letter-spacing:.08em;text-transform:uppercase;color:var(--muted)}
.outline-node-actions{display:flex;align-items:center;gap:5px;flex:0 0 auto}
.outline-icon-btn{width:30px;height:30px;padding:7px;border-radius:9px;border:1px solid transparent;background:transparent;color:var(--muted);transition:.18s ease}
.outline-icon-btn:hover{color:var(--text);border-color:var(--line);background:var(--surface-2)}
.outline-icon-btn.danger:hover{color:#c88980;border-color:color-mix(in srgb,#c88980 30%,var(--line));background:color-mix(in srgb,#c88980 8%,transparent)}
.outline-add-tag{height:29px;padding:0 9px;border-radius:9px;border:1px solid var(--line);background:var(--surface-2);color:var(--muted);font-size:9px;transition:.18s ease}
.outline-add-tag:hover{color:var(--text);border-color:color-mix(in srgb,var(--accent) 30%,var(--line));background:var(--accent-soft)}
.outline-tag-list{display:flex;gap:5px;flex-wrap:wrap}
.outline-tag{--tag-color:var(--accent);display:inline-flex;align-items:center;max-width:180px;padding:4px 7px;border-radius:999px;border:1px solid color-mix(in srgb,var(--tag-color) 34%,var(--line));background:color-mix(in srgb,var(--tag-color) 14%,var(--surface-2));color:color-mix(in srgb,var(--tag-color) 66%,var(--text));font-size:8px;font-weight:650;line-height:1;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.outline-tag.legend{font-size:8px;padding:4px 8px}
.tag-assignment-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px;margin-top:16px}
.tag-choice{--tag-color:var(--accent);height:42px;border-radius:12px;border:1px solid var(--line);background:var(--surface-2);color:var(--text);display:grid;grid-template-columns:12px 1fr 18px;align-items:center;gap:9px;text-align:left;padding:0 11px;transition:.18s ease}
.tag-choice i{width:10px;height:10px;border-radius:50%;background:var(--tag-color);box-shadow:0 0 0 3px color-mix(in srgb,var(--tag-color) 13%,transparent)}
.tag-choice span{font-size:10px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.tag-choice b{text-align:center;color:var(--tag-color);font-size:12px}
.tag-choice.active{border-color:color-mix(in srgb,var(--tag-color) 48%,var(--line));background:color-mix(in srgb,var(--tag-color) 10%,var(--surface-2))}
.structure-tag-manager{display:flex;flex-direction:column;gap:7px;margin-top:15px;max-height:420px;overflow:auto}
.structure-tag-row{display:grid;grid-template-columns:14px minmax(120px,1fr) minmax(80px,auto) 32px 32px;align-items:center;gap:9px;padding:9px 10px;border:1px solid var(--line);border-radius:12px;background:var(--surface-2)}
.structure-tag-row>b{font-size:10px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.structure-tag-dot{--tag-color:var(--accent);width:10px;height:10px;border-radius:50%;background:var(--tag-color)}
.structure-tag-preview{justify-self:start}.tag-color-editor{display:flex;align-items:flex-start;gap:12px}.tag-color-editor input[type="color"]{width:52px!important;height:42px!important;padding:4px!important;border-radius:10px!important;flex:0 0 auto}
.tag-color-palette{display:grid;grid-template-columns:repeat(10,20px);gap:6px;flex:1}.tag-color-palette button{width:20px;height:20px;padding:0;border-radius:50%;border:2px solid transparent;background:var(--swatch);box-shadow:inset 0 0 0 1px rgba(255,255,255,.09)}.tag-color-palette button.active{border-color:var(--text);transform:scale(1.08)}
.empty-state.compact{padding:24px 14px}

/* Library refresh */
.home-view{max-width:1180px}
.home-heading{align-items:flex-end}
.book-library-grid{grid-template-columns:repeat(auto-fill,minmax(340px,1fr));gap:14px}
.book-card{min-height:220px;padding:18px;border-radius:23px;background:linear-gradient(145deg,color-mix(in srgb,var(--surface) 88%,transparent),color-mix(in srgb,var(--surface-2) 82%,transparent));backdrop-filter:blur(22px) saturate(.82);box-shadow:0 18px 40px rgba(0,0,0,.07)}
.book-card:hover{transform:translateY(-3px);border-color:color-mix(in srgb,var(--accent) 22%,var(--line));box-shadow:0 25px 55px rgba(0,0,0,.10)}
.book-card-top{align-items:flex-start}.book-card-identity{display:flex;align-items:flex-start;gap:12px;min-width:0}.book-card-identity>div:last-child{min-width:0}
.book-card-mark{width:42px;height:42px;border-radius:13px;flex:0 0 auto}.book-card h2{font-family:"Libre Baskerville",Georgia,serif;font-weight:400;font-size:18px;line-height:1.3;margin:8px 0 0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.book-status-line{display:flex;align-items:center;gap:5px;flex-wrap:wrap}.book-card .book-version{margin:0;background:var(--surface-2);color:var(--muted);border:1px solid var(--line)}
.book-state-chip{display:inline-flex;padding:4px 7px;border-radius:999px;font-size:8px;border:1px solid var(--line);color:var(--muted);background:var(--surface-2)}.book-state-chip.active{color:var(--accent);border-color:color-mix(in srgb,var(--accent) 24%,var(--line));background:var(--accent-soft)}.book-state-chip.synced{color:#879b88}.book-state-chip.pending{color:#a49376}
.book-card-actions{gap:5px}.book-icon-btn{width:31px;height:31px;padding:7px;border:1px solid var(--line);border-radius:10px;background:color-mix(in srgb,var(--surface-2) 76%,transparent);color:var(--muted);transition:.18s}.book-icon-btn:hover{color:var(--text);transform:translateY(-1px);background:var(--surface)}.book-icon-btn.danger:hover{color:#c88980}
.book-card-meta{margin-top:22px;padding:12px;border:1px solid color-mix(in srgb,var(--line) 76%,transparent);border-radius:14px;background:color-mix(in srgb,var(--surface-2) 55%,transparent)}
.book-meta-cell{display:flex!important;align-items:center;gap:8px;padding:0 8px!important;border-right:1px solid color-mix(in srgb,var(--line) 70%,transparent)}.book-meta-cell:last-child{border-right:0}.book-meta-cell>div{display:flex;flex-direction:column}.book-meta-cell b{font-size:12px}.book-meta-cell span{font-size:8px}
.meta-icon{width:17px;height:17px;color:var(--muted)}
.book-card-footer{margin-top:auto;padding-top:15px}.book-open-btn{display:inline-flex;align-items:center;gap:7px}.book-open-btn svg{width:15px;height:15px;transition:transform .18s}.book-open-btn:hover svg{transform:translateX(2px)}
.home-actions{gap:12px;margin-top:15px}.big-action{min-height:116px;padding:16px;border-radius:19px;background:linear-gradient(145deg,color-mix(in srgb,var(--surface) 78%,transparent),color-mix(in srgb,var(--surface-2) 74%,transparent));backdrop-filter:blur(18px)}
.big-action .action-icon{width:25px;height:25px;margin-bottom:5px;color:var(--accent)}.big-action b{font-size:11px}.big-action small{font-size:8px}

@media(max-width:1100px){
  .outline-chapters{grid-template-columns:1fr}
  .book-library-grid{grid-template-columns:repeat(2,minmax(0,1fr))}
}
@media(max-width:820px){
  .outline-view{padding-left:12px;padding-right:12px}.outline-act-head{padding:16px}.outline-chapters{padding:10px}.outline-chapter-head{padding:12px}.outline-scene{padding:11px}
  .outline-act-head .outline-title-button span{font-size:17px}.tag-assignment-grid{grid-template-columns:1fr}.tag-color-palette{grid-template-columns:repeat(5,20px)}
  .book-library-grid{grid-template-columns:1fr}.book-card{min-height:205px}
}
.entry-confirm-btn{grid-template-columns:1fr 20px;text-align:left;padding-left:16px}
.entry-confirm-btn b{min-width:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.entry-guest-btn{display:flex;align-items:center;justify-content:center;padding:0 16px}
.book-meta-cell{border-top:0}


/* v0.93 — Codex narrative restyle, Reading mode, entry composition */
.entry-shell{align-items:stretch}.entry-brand-block{align-self:center;display:flex;flex-direction:column;justify-content:center;padding-bottom:4vh}.entry-brand-block h1{max-width:800px}.entry-lead{max-width:540px}.entry-access{align-self:center}.entry-kicker{margin-top:18px}.writer-logo{margin-bottom:3px}

/* Codex: visual atlas rather than database */
.codex-layout{grid-template-columns:250px minmax(0,1fr);gap:18px}.codex-categories{padding:14px;border-radius:23px;background:color-mix(in srgb,var(--surface) 80%,transparent)}.codex-categories .search-wrap{margin-bottom:10px}.codex-categories .search-wrap input{height:40px;border-radius:13px;background:color-mix(in srgb,var(--surface-2) 75%,transparent)}
.category-item,.category-row{width:100%;border:0}.category-item,.category-main{display:grid;grid-template-columns:31px minmax(0,1fr) auto;align-items:center;gap:9px;width:100%;min-height:42px;padding:6px 8px;border:0;border-radius:12px;background:transparent;color:var(--muted);text-align:left;transition:.18s ease}.category-row{display:grid;grid-template-columns:minmax(0,1fr) 27px;gap:3px;align-items:center;margin-top:3px;border-radius:12px}.category-main:hover,.category-item:hover,.category-row.active .category-main,.category-item.active{background:var(--accent-soft);color:var(--text)}.category-icon{width:29px;height:29px;display:grid;place-items:center;border-radius:9px;background:color-mix(in srgb,var(--surface-strong) 68%,transparent);color:var(--accent)}.category-icon svg{width:16px;height:16px}.category-count{font:500 9px Inter,sans-serif;color:var(--muted);padding-right:3px}.category-edit{font-size:8px;letter-spacing:1px}.category-row.active .category-icon{background:color-mix(in srgb,var(--accent) 13%,var(--surface-strong));color:var(--accent)}
.codex-grid{grid-template-columns:repeat(auto-fill,minmax(260px,1fr));gap:14px}.codex-card{--entry-color:var(--accent);min-height:220px;display:flex;flex-direction:column;padding:18px 18px 16px;border-radius:22px;background:color-mix(in srgb,var(--surface) 86%,transparent);position:relative;overflow:hidden;box-shadow:0 16px 44px rgba(0,0,0,.06)}.codex-card:before{content:'';position:absolute;inset:0 auto 0 0;width:2px;background:var(--entry-color);opacity:.68}.codex-card:hover{transform:translateY(-3px);background:color-mix(in srgb,var(--surface-strong) 92%,transparent);box-shadow:0 22px 55px rgba(0,0,0,.10)}.codex-card-top{display:flex;justify-content:space-between;align-items:flex-start}.codex-card-symbol{width:43px;height:43px;border-radius:14px;display:grid;place-items:center;background:color-mix(in srgb,var(--entry-color) 12%,var(--surface-2));color:var(--entry-color);border:1px solid color-mix(in srgb,var(--entry-color) 16%,var(--line))}.codex-card-symbol svg{width:23px;height:23px}.codex-card-more{width:30px;height:30px;border:0;background:transparent;color:var(--muted);border-radius:9px;font-size:9px;letter-spacing:1px;display:grid;place-items:center}.codex-card-more:hover{background:var(--accent-soft);color:var(--text)}.codex-card h3{font-family:var(--ui-font,Inter),sans-serif;font-size:18px;letter-spacing:-.025em;margin:16px 0 8px}.codex-card-categories{display:flex;gap:5px;flex-wrap:wrap}.codex-card-categories span{display:inline-flex;align-items:center;gap:4px;padding:5px 7px;border-radius:999px;background:var(--surface-2);color:var(--muted);font-size:8px}.mini-codex-symbol{width:10px!important;height:10px!important}.codex-card p{font-size:11px;line-height:1.65;margin:13px 0 20px;-webkit-line-clamp:4}.codex-card-foot{margin-top:auto;display:flex;align-items:center;gap:7px;color:var(--muted);font-size:8px}.codex-card-foot i{width:6px;height:6px;border-radius:50%;background:var(--entry-color)}.codex-symbol{width:18px;height:18px;fill:none;stroke:currentColor;stroke-width:1.55;stroke-linecap:round;stroke-linejoin:round}.codex-empty{grid-column:1/-1;min-height:330px;display:grid;place-items:center;align-content:center;text-align:center;color:var(--muted);border:1px dashed var(--line);border-radius:23px;padding:30px}.codex-empty>span{width:55px;height:55px;display:grid;place-items:center;border-radius:17px;background:var(--accent-soft);color:var(--accent);margin-bottom:13px}.codex-empty>span svg{width:28px;height:28px}.codex-empty h3{font-size:16px;color:var(--text);margin:0 0 6px}.codex-empty p{font-size:10px;max-width:310px;line-height:1.6;margin:0}
.codex-icon-picker{display:grid;grid-template-columns:repeat(9,1fr);gap:6px;max-height:190px;overflow:auto;padding:3px}.codex-icon-choice{aspect-ratio:1;border-radius:10px;border:1px solid var(--line);background:var(--surface-2);color:var(--muted);display:grid;place-items:center;transition:.15s ease}.codex-icon-choice:hover{background:var(--accent-soft);color:var(--text);transform:translateY(-1px)}.codex-icon-choice.selected{background:var(--accent-soft);color:var(--accent);border-color:color-mix(in srgb,var(--accent) 42%,var(--line));box-shadow:inset 0 0 0 1px color-mix(in srgb,var(--accent) 15%,transparent)}.codex-icon-choice svg{width:19px;height:19px}.codex-entry-form{display:grid;gap:15px}.codex-entry-form .form-row>label small{font-weight:400;color:var(--muted);text-transform:none;letter-spacing:0}.picker-cat-icon{width:16px;height:16px;display:grid;place-items:center}.picker-cat-icon svg{width:13px;height:13px}.category-check{padding:8px 10px}

/* Reading — the rest of the application falls away. */
html[data-route="reader"] .main-area{position:fixed;inset:0;grid-column:1/-1;grid-row:1/-1;width:100vw;height:100dvh;z-index:70}.reader-view{background:var(--bg);overflow:hidden}.reader-shell{width:100%;height:100%;position:relative;display:flex;flex-direction:column}.reader-bar{position:absolute;z-index:80;top:max(14px,env(safe-area-inset-top));left:50%;transform:translateX(-50%);height:48px;max-width:calc(100vw - 28px);display:flex;align-items:center;gap:4px;padding:5px 7px;border-radius:17px;opacity:.32;transition:.28s ease}.reader-bar:hover,.reader-bar:focus-within{opacity:1}.reader-icon-btn,.reader-note-btn{height:36px;border:0;background:transparent;color:var(--muted);border-radius:10px;display:inline-flex;align-items:center;justify-content:center}.reader-icon-btn{width:36px}.reader-icon-btn:hover,.reader-note-btn:hover{background:var(--accent-soft);color:var(--text)}.reader-icon-btn svg,.reader-note-btn svg{width:17px;height:17px;fill:none;stroke:currentColor;stroke-width:1.55;stroke-linecap:round;stroke-linejoin:round}.reader-position{min-width:150px;max-width:280px;padding:0 10px;line-height:1.1}.reader-position small{display:block;font-size:7px;color:var(--muted);letter-spacing:.08em;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.reader-position b{display:block;margin-top:4px;font-size:10px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.reader-scope{height:34px;max-width:105px;border:0;background:transparent;color:var(--muted);font-size:9px}.reader-bar-separator{width:1px;height:21px;background:var(--line);margin:0 3px}.reader-highlights{display:flex;gap:3px;padding:0 3px}.reader-highlights button{width:17px;height:17px;border-radius:50%;border:1px solid color-mix(in srgb,#000 12%,transparent);background:var(--reader-highlight);padding:0}.reader-note-btn{gap:6px;padding:0 9px;font-size:9px}.reader-viewport{flex:1;overflow:auto;padding:90px 0 14vh;scroll-behavior:smooth}.reader-document{width:min(var(--manuscript-width,850px),calc(100vw - 48px));margin:0 auto;display:flex;flex-direction:column;gap:0}.reader-sheet{position:relative;padding:42px clamp(24px,7vw,78px) 56px;background:transparent}.reader-scene-label{font:600 8px Inter,sans-serif;letter-spacing:.12em;color:var(--muted);text-transform:uppercase;margin-bottom:27px;opacity:.55}.reader-editor{outline:none;font-family:var(--editor-font);font-size:var(--editor-size);line-height:var(--editor-line-height);text-align:var(--reader-align,left);caret-color:transparent}.reader-editor p{margin:0 0 var(--editor-paragraph-spacing)}.reader-editor p:first-child{text-indent:var(--editor-indent)}.reader-editor .user-highlight{border-radius:4px;padding:0 .04em;color:#20231f!important;text-shadow:none!important;box-decoration-break:clone;-webkit-box-decoration-break:clone}.reader-editor .bookmark-anchor{cursor:pointer}.reader-separator{padding:58px clamp(24px,7vw,78px) 18px;border-top:1px solid var(--line);margin-top:28px}.reader-separator:first-child{border-top:0;margin-top:0}.reader-separator small{font:600 8px Inter,sans-serif;letter-spacing:.18em;color:var(--muted)}.reader-separator h2{font-family:var(--editor-font);font-weight:400;font-size:clamp(24px,3vw,34px);margin:8px 0 0;letter-spacing:-.03em}.reader-separator.chapter{padding-top:40px}.reader-separator.chapter h2{font-size:clamp(19px,2.4vw,27px)}
@media(max-width:900px){.entry-brand-block{padding-bottom:0}.codex-layout{grid-template-columns:1fr}.codex-categories{position:static}.codex-icon-picker{grid-template-columns:repeat(7,1fr)}.reader-bar{top:max(9px,env(safe-area-inset-top));max-width:calc(100vw - 18px)}.reader-position{min-width:105px;max-width:160px;padding:0 5px}.reader-note-btn span{display:none}.reader-note-btn{width:34px;padding:0}.reader-scope{max-width:85px}.reader-document{width:min(var(--manuscript-width,850px),calc(100vw - 26px))}.reader-sheet{padding-left:clamp(20px,6vw,52px);padding-right:clamp(20px,6vw,52px)}}

/* MM-Writer v0.94 — radio sospesa */
.music-radio-trigger{width:36px;height:36px;border:1px solid var(--line);background:var(--surface-2);color:var(--muted);border-radius:12px;display:inline-flex;align-items:center;justify-content:center;transition:.22s ease;position:relative}.music-radio-trigger svg{width:16px;height:16px;fill:none;stroke:currentColor;stroke-width:1.65;stroke-linecap:round;stroke-linejoin:round}.music-radio-trigger:hover,.music-radio-trigger.active{color:var(--text);background:var(--accent-soft);transform:translateY(-1px)}.music-radio-trigger.active:after{content:"";position:absolute;inset:-4px;border:1px solid color-mix(in srgb,var(--accent) 35%,transparent);border-radius:15px;animation:radioPulse 1.8s ease-in-out infinite}@keyframes radioPulse{50%{opacity:.2;transform:scale(1.05)}}
.spotify-radio-rig{position:fixed;z-index:14;top:70px;right:clamp(12px,3vw,46px);width:min(390px,calc(100vw - 24px));height:0;pointer-events:none;opacity:0;visibility:hidden;transition:opacity .34s ease,visibility 0s linear 1.08s}.radio-ceiling-pin{position:absolute;top:-5px;right:74px;width:20px;height:10px;border-radius:0 0 9px 9px;background:var(--surface-3);border:1px solid var(--line);border-top:0;opacity:0;transform:translateY(-5px);transition:opacity .3s ease,transform .55s ease}.radio-cable{position:absolute;top:0;right:83px;width:2px;height:76px;background:linear-gradient(#2a2a27,#6b685d);transform:scaleY(0);transform-origin:top;transition:transform .78s cubic-bezier(.18,.72,.2,1);box-shadow:0 0 0 1px rgba(255,255,255,.025)}.spotify-radio{position:absolute;top:72px;right:0;width:100%;padding:15px;border:1px solid color-mix(in srgb,var(--line) 82%,#7c735f);border-radius:18px;background:linear-gradient(145deg,color-mix(in srgb,var(--surface) 94%,#736348 6%),color-mix(in srgb,var(--surface-2) 96%,#2d352b 4%));box-shadow:0 22px 70px rgba(0,0,0,.38),inset 0 1px rgba(255,255,255,.04);transform:translateY(-520px) rotate(1.6deg) scale(.985);transform-origin:calc(100% - 84px) -72px;opacity:0;pointer-events:none;transition:transform .9s cubic-bezier(.18,.76,.18,1),opacity .42s ease;backdrop-filter:blur(22px) saturate(.8)}.spotify-radio-rig.open{pointer-events:auto;opacity:1;visibility:visible;transition:opacity .2s ease,visibility 0s}.spotify-radio-rig.open .radio-ceiling-pin{opacity:1;transform:translateY(0);transition-delay:.05s}.spotify-radio-rig.open .radio-cable{transform:scaleY(1);transition-delay:.08s}.spotify-radio-rig.open .spotify-radio{opacity:1;pointer-events:auto;transform:translateY(0) rotate(0) scale(1);transition-delay:.12s;animation:radioSwing 1.35s .86s cubic-bezier(.2,.72,.24,1) both}@keyframes radioSwing{0%{transform:rotate(0)}20%{transform:rotate(-2.1deg)}43%{transform:rotate(1.35deg)}65%{transform:rotate(-.65deg)}82%{transform:rotate(.28deg)}100%{transform:rotate(0)}}.radio-handle{position:absolute;left:50%;top:-17px;width:112px;height:27px;transform:translateX(-50%);border:5px solid color-mix(in srgb,var(--line) 70%,#736858);border-bottom:0;border-radius:20px 20px 0 0;opacity:.85}.radio-topline{height:24px;display:flex;align-items:center;justify-content:space-between;padding:0 2px 7px}.radio-brand{font:700 8px Inter,sans-serif;letter-spacing:.16em;color:var(--muted)}.radio-brand i{font-style:normal;color:var(--text)}.radio-close{width:24px;height:24px;border:0;background:transparent;color:var(--muted);font-size:18px;line-height:1;border-radius:8px}.radio-close:hover{background:var(--surface-3);color:var(--text)}.radio-face{display:grid;grid-template-columns:108px 1fr;gap:13px;min-height:132px}.radio-speaker{border:1px solid var(--line);border-radius:14px;background:radial-gradient(circle at 50% 45%,rgba(255,255,255,.035),transparent 64%),repeating-radial-gradient(circle at 50% 50%,transparent 0 5px,rgba(0,0,0,.14) 6px 7px);display:flex;flex-direction:column;justify-content:center;gap:6px;padding:13px}.radio-speaker span{height:2px;border-radius:2px;background:color-mix(in srgb,var(--muted) 30%,transparent)}.radio-console{min-width:0}.radio-frequency{height:20px;border-bottom:1px solid var(--line);display:flex;align-items:center;justify-content:space-between;color:var(--muted);font:600 7px Inter,sans-serif}.radio-frequency i{height:5px;width:1px;background:var(--line)}.radio-display{margin-top:8px;min-height:62px;border:1px solid color-mix(in srgb,var(--line) 70%,#8e7e5d);border-radius:9px;background:linear-gradient(180deg,rgba(174,157,108,.08),rgba(40,43,35,.14)),var(--bg);padding:9px 11px;box-shadow:inset 0 0 22px rgba(0,0,0,.18)}.radio-display>small{display:block;font:600 6.5px Inter,sans-serif;letter-spacing:.16em;color:color-mix(in srgb,var(--accent) 72%,var(--muted));margin-bottom:7px}.radio-display a{display:block;color:inherit;text-decoration:none}.radio-display strong,.radio-display span{display:block;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.radio-display strong{font:600 12px var(--editor-font,serif);color:var(--text)}.radio-display span{font:500 8px Inter,sans-serif;color:var(--muted);margin-top:4px}.radio-controls{height:36px;margin-top:7px;display:flex;align-items:center;justify-content:space-between}.radio-knob{width:31px;height:31px;border-radius:50%;border:1px solid color-mix(in srgb,var(--line) 70%,#7a6d59);background:radial-gradient(circle at 38% 30%,#777367,#35372f 45%,#1c211d 72%);box-shadow:inset 0 0 0 3px rgba(255,255,255,.025),0 3px 6px rgba(0,0,0,.22);position:relative}.radio-knob:disabled{opacity:.35}.radio-play span{position:absolute;left:12px;top:9px;width:0;height:0;border-top:6px solid transparent;border-bottom:6px solid transparent;border-left:9px solid #d9d4c7}.radio-play.paused span{left:10px;top:10px;width:10px;height:11px;border:0;border-left:3px solid #d9d4c7;border-right:3px solid #d9d4c7}.radio-volume-wrap{display:flex;align-items:center;gap:7px;font:600 6px Inter,sans-serif;color:var(--muted)}.radio-volume-wrap input{width:82px;accent-color:var(--accent)}.radio-setup,.radio-connected{margin-top:13px;border-top:1px solid var(--line);padding-top:12px}.radio-setup p{font-size:9px;color:var(--muted);line-height:1.45;margin:0 0 9px}.radio-client-row{display:flex;gap:6px}.radio-client-row input,.radio-search-form input{min-width:0;flex:1;height:34px;border:1px solid var(--line);border-radius:10px;background:var(--surface-2);color:var(--text);padding:0 10px;font-size:9px}.radio-client-row button{height:34px;border:1px solid var(--line);border-radius:10px;background:var(--accent-soft);color:var(--text);padding:0 12px;font-size:8px;font-weight:700}.radio-setup>small{display:block;margin-top:7px;color:var(--muted);font-size:7px;line-height:1.4}.radio-setup code{user-select:all;color:var(--text)}.radio-search-form{display:flex;gap:6px}.radio-search-form button{width:34px;height:34px;border:1px solid var(--line);border-radius:10px;background:var(--surface-2);color:var(--muted)}.radio-search-form svg{width:15px;height:15px;fill:none;stroke:currentColor;stroke-width:1.6}.radio-search-results{margin-top:8px;max-height:190px;overflow:auto;display:flex;flex-direction:column;gap:4px;padding-right:2px}.radio-empty{font-size:8px;color:var(--muted);padding:12px 4px;margin:0}.radio-result{display:grid;grid-template-columns:1fr 30px;align-items:center;gap:7px;border:1px solid transparent;border-radius:10px;padding:6px 6px 6px 9px;transition:.18s}.radio-result:hover{background:var(--surface-2);border-color:var(--line)}.radio-result>a{min-width:0;color:inherit;text-decoration:none}.radio-result b,.radio-result small{display:block;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.radio-result b{font-size:8.5px}.radio-result small{font-size:7px;color:var(--muted);margin-top:2px}.radio-result-play{width:27px;height:27px;border-radius:50%;border:1px solid var(--line);background:var(--surface-3);position:relative}.radio-result-play span{position:absolute;left:10px;top:7px;border-top:5px solid transparent;border-bottom:5px solid transparent;border-left:7px solid var(--text)}.radio-footer{display:flex;align-items:center;justify-content:space-between;border-top:1px solid var(--line);margin-top:9px;padding-top:8px}.radio-footer img{display:block;width:74px;height:auto}.radio-footer button{border:0;background:transparent;color:var(--muted);font-size:7px}.radio-footer button:hover{color:var(--text)}
@media(max-width:900px){.spotify-radio-rig{top:68px;right:10px;width:min(365px,calc(100vw - 20px))}.radio-face{grid-template-columns:92px 1fr}.radio-speaker{padding:10px}.music-radio-trigger{width:34px;height:34px}}
@media(max-width:520px){.spotify-radio-rig{display:none}.music-radio-trigger{display:none}}
html[data-route="reader"] .spotify-radio-rig,html[data-route="reader"] .music-radio-trigger{display:none!important}
@media(prefers-reduced-motion:reduce){.spotify-radio,.radio-cable,.music-radio-trigger{transition:none!important;animation:none!important}}

/* v0.95 — three writer widths and tablet-safe scaling */
.document-meta,.multi-scene-editor{width:min(var(--manuscript-width,850px),calc(100% - 34px))}
@media(max-width:1366px) and (pointer:coarse){.document-meta,.multi-scene-editor{width:min(var(--manuscript-width,850px),calc(100vw - 38px))}.scene-sheet{padding-left:clamp(26px,5.5vw,58px);padding-right:clamp(26px,5.5vw,58px)}}
@media(max-width:900px){.document-meta,.multi-scene-editor{width:min(var(--manuscript-width,850px),calc(100vw - 26px))}.scene-sheet{padding-left:clamp(22px,5vw,44px);padding-right:clamp(22px,5vw,44px)}}


/* v0.951 — writer width selector always visible in the Writer toolbar */
.writer-width-quick{display:flex;align-items:center;gap:2px;height:29px;padding:2px;border-left:1px solid var(--line);border-right:1px solid var(--line);margin:0 2px}
.floating-toolbar .writer-width-btn{width:27px;min-width:27px;height:25px!important;padding:0;display:grid;place-items:center;color:var(--muted);border-radius:7px!important}
.floating-toolbar .writer-width-btn.active{background:var(--accent-soft);color:var(--text);box-shadow:inset 0 0 0 1px color-mix(in srgb,var(--accent) 28%,var(--line))}
.writer-width-glyph{display:block;height:10px;border:1.4px solid currentColor;border-radius:2px;opacity:.9}
.writer-width-glyph.size-1{width:9px}.writer-width-glyph.size-2{width:14px}.writer-width-glyph.size-3{width:19px}
@media(max-width:900px){.writer-width-quick{flex:0 0 auto}.floating-toolbar .writer-width-btn{width:29px;min-width:29px}}


/* v0.97 · Search, revision compare, Codex appearances */
.global-search-trigger{display:inline-flex;align-items:center;gap:7px}.global-search-trigger svg{width:15px;height:15px;fill:none;stroke:currentColor;stroke-width:1.7;stroke-linecap:round}.modal.global-search-modal,.modal.revision-compare-modal{width:min(1120px,calc(100vw - 34px));max-width:none;max-height:min(88dvh,920px);padding:0;overflow:hidden}.global-search-shell,.revision-compare-shell{display:flex;flex-direction:column;min-height:min(720px,82dvh);max-height:min(88dvh,920px)}.global-search-head,.revision-compare-title{display:flex;justify-content:space-between;align-items:flex-start;padding:24px 26px 17px;border-bottom:1px solid var(--line)}.global-search-head small,.revision-compare-title small{font:600 8px Inter,sans-serif;letter-spacing:.16em;color:var(--muted)}.global-search-head h2,.revision-compare-title h2{margin:5px 0 0;font-weight:500;letter-spacing:-.035em}.revision-compare-title p{margin:5px 0 0;color:var(--muted);font-size:10px}.global-search-close{width:34px;height:34px;border:1px solid var(--line);border-radius:50%;background:var(--surface-2);color:var(--muted);font-size:19px;line-height:1}.global-search-close:hover{color:var(--text);background:var(--surface-3)}.global-search-box{margin:17px 26px 10px;height:52px;border:1px solid var(--line);border-radius:16px;background:var(--surface-2);display:grid;grid-template-columns:22px 1fr auto;align-items:center;gap:10px;padding:0 15px;box-shadow:inset 0 1px rgba(255,255,255,.025)}.global-search-box svg{width:19px;height:19px;fill:none;stroke:var(--muted);stroke-width:1.6}.global-search-box input{border:0!important;background:transparent!important;box-shadow:none!important;height:100%!important;padding:0!important;font-size:14px!important;color:var(--text)!important}.global-search-box input:focus{outline:none}.global-search-box>span{font:500 8px Inter,sans-serif;color:var(--muted);white-space:nowrap}.global-search-filters{display:flex;gap:6px;padding:0 26px 12px;overflow:auto}.global-search-filter{border:1px solid var(--line);background:transparent;color:var(--muted);border-radius:999px;padding:7px 11px;font:600 8px Inter,sans-serif;white-space:nowrap}.global-search-filter.active{background:var(--accent-soft);border-color:color-mix(in srgb,var(--accent) 30%,var(--line));color:var(--text)}.global-search-results{flex:1;overflow:auto;padding:4px 16px 16px}.global-result{width:100%;display:grid;grid-template-columns:58px minmax(0,1fr) 22px;gap:12px;align-items:center;text-align:left;border:1px solid transparent;background:transparent;color:var(--text);padding:11px 12px;border-radius:14px;transition:.16s}.global-result:hover{background:var(--surface-2);border-color:var(--line)}.global-result-kind{font:600 7px Inter,sans-serif;letter-spacing:.08em;text-transform:uppercase;color:var(--muted)}.global-result-copy{min-width:0}.global-result-copy>b,.global-result-copy>small,.global-result-copy>span{display:block}.global-result-copy>b{font-size:11px}.global-result-copy>small{font:500 7px Inter,sans-serif;color:var(--muted);margin:3px 0 5px}.global-result-copy>span{font-size:9px;color:color-mix(in srgb,var(--text) 78%,var(--muted));white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.global-result mark,.codex-appearance-jump mark{background:color-mix(in srgb,var(--accent) 25%,transparent);color:inherit;border-radius:3px;padding:0 1px}.global-result>svg{width:17px;height:17px;fill:none;stroke:var(--muted);stroke-width:1.5}.global-search-empty{min-height:240px;display:flex;flex-direction:column;align-items:center;justify-content:center;text-align:center;color:var(--muted);gap:6px}.global-search-empty b{color:var(--text);font-weight:500}.global-search-empty span{font-size:9px}.global-search-empty kbd{margin-top:9px;border:1px solid var(--line);border-bottom-width:2px;border-radius:7px;padding:5px 8px;background:var(--surface-2);font:600 7px Inter,sans-serif}.global-replace{border-top:1px solid var(--line);background:color-mix(in srgb,var(--surface-2) 55%,transparent);padding:0 26px}.global-replace summary{cursor:pointer;padding:13px 0;font:600 8px Inter,sans-serif;color:var(--muted);letter-spacing:.04em}.global-replace[open] summary{color:var(--text)}.global-replace-grid{display:grid;grid-template-columns:1fr 1fr 170px auto;gap:8px;align-items:end;padding-bottom:8px}.global-replace-grid label span{display:block;font:600 7px Inter,sans-serif;color:var(--muted);margin:0 0 5px}.global-replace-grid input,.global-replace-grid select{width:100%;height:36px}.global-replace-grid button{height:36px}.global-replace>p{font-size:7px;color:var(--muted);margin:0 0 14px}.revision-compare-summary{display:grid;grid-template-columns:repeat(4,1fr);gap:1px;background:var(--line);border-bottom:1px solid var(--line)}.revision-compare-summary>div{background:var(--surface);padding:14px 18px}.revision-compare-summary b,.revision-compare-summary span{display:block}.revision-compare-summary b{font-size:15px;font-weight:500}.revision-compare-summary span{font:500 7px Inter,sans-serif;color:var(--muted);margin-top:4px}.plus{color:#79a88b!important}.minus{color:#c07f82!important}.revision-compare-layout{display:grid;grid-template-columns:300px minmax(0,1fr);min-height:0;flex:1}.revision-change-list{border-right:1px solid var(--line);overflow:auto;padding:10px}.revision-change-item{width:100%;display:grid;grid-template-columns:7px minmax(0,1fr) auto;gap:10px;align-items:center;text-align:left;border:1px solid transparent;background:transparent;color:var(--text);border-radius:12px;padding:10px;transition:.16s}.revision-change-item:hover,.revision-change-item.active{background:var(--surface-2);border-color:var(--line)}.revision-change-item>i{width:6px;height:24px;border-radius:4px;background:var(--muted)}.revision-change-item>i.added{background:#79a88b}.revision-change-item>i.deleted{background:#c07f82}.revision-change-item>i.modified{background:#b7a06c}.revision-change-item b,.revision-change-item small{display:block}.revision-change-item b{font-size:9px}.revision-change-item small{font-size:7px;color:var(--muted);margin-top:2px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.revision-change-item em{font:600 7px Inter,sans-serif;font-style:normal;text-align:right}.revision-change-item em span{display:block}.revision-change-item em span:first-child{color:#79a88b}.revision-change-item em span:last-child{color:#c07f82;margin-top:3px}.revision-compare-detail{min-width:0;overflow:auto;padding:18px 22px 34px}.revision-diff-head{display:flex;justify-content:space-between;gap:16px;align-items:flex-start;padding-bottom:16px;border-bottom:1px solid var(--line)}.revision-diff-head small{font:600 7px Inter,sans-serif;letter-spacing:.13em;color:var(--muted)}.revision-diff-head h3{font-size:20px;font-weight:500;margin:5px 0 4px}.revision-diff-head p{font-size:8px;color:var(--muted);margin:0}.revision-delta{display:flex;gap:7px;font:600 8px Inter,sans-serif}.revision-delta span{padding:6px 8px;border-radius:8px;background:var(--surface-2);border:1px solid var(--line)}.revision-diff-body{padding-top:13px}.diff-line,.diff-change-pair,.diff-single{border-radius:11px;margin:5px 0}.diff-line{padding:7px 10px}.diff-line p,.diff-single p,.diff-change-pair p{margin:0;font-family:var(--editor-font);font-size:11px;line-height:1.65}.diff-line small,.diff-single small,.diff-change-pair small{display:block;font:600 6px Inter,sans-serif;letter-spacing:.12em;color:var(--muted);margin-bottom:5px}.diff-line.same{opacity:.42}.diff-line.removed,.diff-single.deleted{background:color-mix(in srgb,#b76e73 10%,transparent);border:1px solid color-mix(in srgb,#b76e73 20%,transparent)}.diff-line.added,.diff-single.added{background:color-mix(in srgb,#72a486 10%,transparent);border:1px solid color-mix(in srgb,#72a486 20%,transparent)}.diff-single{padding:14px}.diff-change-pair{display:grid;grid-template-columns:1fr 1fr;gap:7px}.diff-change-pair>div{padding:10px;border:1px solid var(--line);border-radius:10px;background:var(--surface-2)}.diff-change-pair del{background:color-mix(in srgb,#b76e73 22%,transparent);text-decoration-color:#b76e73;border-radius:3px}.diff-change-pair ins{background:color-mix(in srgb,#72a486 22%,transparent);text-decoration:none;border-radius:3px}.revision-identical,.revision-loading{flex:1;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:7px;color:var(--muted);text-align:center;padding:50px}.revision-identical b,.revision-loading h2{color:var(--text);font-weight:500}.revision-identical span,.revision-loading p{font-size:9px}.revision-loading>span{width:26px;height:26px;border:2px solid var(--line);border-top-color:var(--accent);border-radius:50%;animation:spin .8s linear infinite}.revision-actions .revision-compare{color:var(--text);background:var(--accent-soft)}
.codex-entry-modal{width:min(760px,calc(100vw - 34px));max-height:min(90dvh,920px);overflow:auto}.codex-appearances{margin:18px 0 3px;border-top:1px solid var(--line);padding-top:17px}.codex-appearance-head{display:flex;justify-content:space-between;gap:16px;align-items:flex-end}.codex-appearance-head small{font:600 7px Inter,sans-serif;letter-spacing:.13em;color:var(--muted)}.codex-appearance-head h3{font-size:17px;font-weight:500;margin:4px 0 0}.codex-appearance-head>span{font:500 7px Inter,sans-serif;color:var(--muted)}.codex-appearance-range{display:grid;grid-template-columns:1fr 1fr;gap:7px;margin:10px 0}.codex-appearance-range>div{border:1px solid var(--line);background:var(--surface-2);border-radius:10px;padding:9px 11px;min-width:0}.codex-appearance-range small,.codex-appearance-range b{display:block}.codex-appearance-range small{font:600 6px Inter,sans-serif;color:var(--muted);text-transform:uppercase;letter-spacing:.1em}.codex-appearance-range b{font-size:8px;margin-top:4px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.codex-appearance-list{display:flex;flex-direction:column;gap:4px;max-height:250px;overflow:auto}.codex-appearance-jump{width:100%;display:grid;grid-template-columns:minmax(0,1fr) 30px 18px;gap:8px;align-items:center;text-align:left;border:1px solid transparent;background:transparent;color:var(--text);border-radius:10px;padding:8px 9px}.codex-appearance-jump:hover{background:var(--surface-2);border-color:var(--line)}.codex-appearance-jump b,.codex-appearance-jump small,.codex-appearance-jump em{display:block}.codex-appearance-jump b{font-size:8px}.codex-appearance-jump small{font-size:6.5px;color:var(--muted);margin-top:2px}.codex-appearance-jump em{font:400 7px Inter,sans-serif;font-style:normal;color:color-mix(in srgb,var(--text) 70%,var(--muted));white-space:nowrap;overflow:hidden;text-overflow:ellipsis;margin-top:3px}.codex-appearance-jump>strong{font:600 8px Inter,sans-serif;color:var(--muted);text-align:center}.codex-appearance-jump>svg{width:15px;height:15px;fill:none;stroke:var(--muted);stroke-width:1.6}.codex-appearance-empty{margin-top:10px;border:1px dashed var(--line);border-radius:10px;padding:13px;color:var(--muted);font-size:8px}
@media(max-width:900px){.global-search-trigger span{display:none}.global-search-trigger{width:34px;padding:0;justify-content:center}.modal.global-search-modal,.modal.revision-compare-modal{width:calc(100vw - 18px);max-height:92dvh}.global-search-shell,.revision-compare-shell{min-height:78dvh;max-height:92dvh}.global-search-head,.revision-compare-title{padding:18px}.global-search-box{margin:12px 18px 8px}.global-search-filters{padding:0 18px 10px}.global-search-results{padding:3px 8px 12px}.global-result{grid-template-columns:48px minmax(0,1fr) 18px;padding:10px 8px}.global-replace{padding:0 18px}.global-replace-grid{grid-template-columns:1fr 1fr}.global-replace-grid label:nth-child(3),.global-replace-grid button{grid-column:auto}.revision-compare-summary{grid-template-columns:1fr 1fr}.revision-compare-layout{grid-template-columns:230px minmax(0,1fr)}.diff-change-pair{grid-template-columns:1fr}.codex-entry-modal{width:calc(100vw - 18px)}.codex-appearance-range{grid-template-columns:1fr}}
@media(max-width:700px){.revision-compare-layout{grid-template-columns:1fr;grid-template-rows:auto minmax(0,1fr)}.revision-change-list{border-right:0;border-bottom:1px solid var(--line);display:flex;overflow:auto;padding:8px}.revision-change-item{min-width:210px}.revision-compare-detail{padding:15px}.global-replace-grid{grid-template-columns:1fr}.global-replace-grid label,.global-replace-grid button{grid-column:1}}

@keyframes spin{to{transform:rotate(360deg)}}
@media(max-width:900px){.topbar-actions .global-search-trigger{display:inline-flex!important}}

.revision-actions{flex-wrap:wrap}


/* MM-Writer 1.0 · writing sessions */
.session-trigger{height:34px;min-width:34px;padding:0 10px;border:1px solid var(--line);border-radius:11px;background:var(--surface-2);color:var(--muted);display:inline-flex;align-items:center;justify-content:center;gap:7px;transition:.25s ease;white-space:nowrap}
.session-trigger svg{width:16px;height:16px;fill:none;stroke:currentColor;stroke-width:1.65;stroke-linecap:round;stroke-linejoin:round;flex:0 0 auto}
.session-trigger span{font-size:10px;font-weight:650;font-variant-numeric:tabular-nums}
.session-trigger:hover{background:color-mix(in srgb,var(--surface-strong) 78%,var(--accent-soft));color:var(--text)}
.session-trigger.active{color:var(--text);background:var(--accent-soft);border-color:color-mix(in srgb,var(--accent) 34%,var(--line));box-shadow:inset 0 0 0 1px color-mix(in srgb,var(--accent) 8%,transparent)}
.session-trigger.active svg{animation:sessionPulse 1.8s ease-in-out infinite}
@keyframes sessionPulse{0%,100%{opacity:.65;transform:scale(.94)}50%{opacity:1;transform:scale(1.05)}}
.writing-session-modal{width:min(520px,calc(100vw - 28px))}
.session-modal-head small{display:block;font-size:8px;letter-spacing:.16em;color:var(--muted);font-weight:750;margin-bottom:7px}.session-modal-head h2{margin:0;font-size:27px}.session-modal-head p{color:var(--muted);font-size:11px;line-height:1.62;margin:9px 0 0}
.session-start-mark{width:86px;height:86px;margin:25px auto 8px;border-radius:50%;display:grid;place-items:center;border:1px solid var(--line);background:radial-gradient(circle,var(--accent-soft),transparent 68%),var(--surface-2);box-shadow:inset 0 0 0 9px color-mix(in srgb,var(--surface-strong) 52%,transparent)}.session-start-mark svg{width:34px;height:34px;fill:none;stroke:var(--accent);stroke-width:1.35;stroke-linecap:round;stroke-linejoin:round}
.session-live-grid{display:grid;grid-template-columns:repeat(3,1fr);gap:8px;margin-top:20px}.session-live-grid>div{padding:13px;border:1px solid var(--line);border-radius:14px;background:var(--surface-2)}.session-live-grid small,.session-live-grid b{display:block}.session-live-grid small{font-size:8px;color:var(--muted);text-transform:uppercase;letter-spacing:.08em}.session-live-grid b{font-size:17px;margin-top:5px;font-variant-numeric:tabular-nums}
.session-analysis-card{margin:12px 0 14px;padding:18px;min-width:0}.session-card-head{margin-bottom:14px}.session-stats-grid{display:grid;grid-template-columns:repeat(6,minmax(0,1fr));gap:8px}.session-stat{min-width:0;padding:12px;border-radius:14px;background:var(--surface-2);border:1px solid var(--line)}.session-stat b,.session-stat span{display:block;overflow:hidden;text-overflow:ellipsis}.session-stat b{font-size:16px;white-space:nowrap;font-variant-numeric:tabular-nums}.session-stat span{font-size:8px;color:var(--muted);margin-top:4px;text-transform:uppercase;letter-spacing:.06em;white-space:nowrap}.session-empty{grid-column:1/-1;padding:18px;border:1px dashed var(--line);border-radius:14px;color:var(--muted);font-size:10px;line-height:1.55;text-align:center}
.session-analysis-layout{display:grid;grid-template-columns:minmax(0,1.35fr) minmax(280px,.65fr);gap:14px;margin-top:14px}.session-analysis-layout>div{min-width:0;border:1px solid var(--line);border-radius:15px;background:color-mix(in srgb,var(--surface-2) 78%,transparent);padding:13px}.session-subhead{display:flex;align-items:baseline;justify-content:space-between;gap:8px;margin-bottom:10px}.session-subhead b{font-size:10px}.session-subhead span{font-size:8px;color:var(--muted)}
.session-day-chart{min-height:164px;overflow:hidden}.session-day-bars{height:164px;display:grid;grid-template-columns:repeat(14,minmax(12px,1fr));gap:5px;align-items:end}.session-day-col{height:100%;min-width:0;display:grid;grid-template-rows:22px 1fr 16px;align-items:end;text-align:center}.session-day-col>span{font-size:6.5px;color:var(--muted);white-space:nowrap;overflow:hidden}.session-day-slot{height:116px;display:flex;align-items:flex-end;justify-content:center;border-bottom:1px solid var(--line)}.session-day-slot i{display:block;width:min(16px,72%);min-height:2px;border-radius:4px 4px 1px 1px;background:var(--accent);opacity:.82}.session-day-col.negative .session-day-slot i{background:var(--danger);opacity:.7}.session-day-col small{font-size:7px;color:var(--muted);padding-top:4px}
.session-recent-list{max-height:164px;overflow:auto;display:flex;flex-direction:column;gap:5px;padding-right:2px}.session-recent-row{display:grid;grid-template-columns:minmax(0,1fr) auto auto;gap:9px;align-items:center;padding:8px 9px;border:1px solid var(--line);border-radius:11px;background:var(--surface-2)}.session-recent-row>div{min-width:0}.session-recent-row b,.session-recent-row span{display:block;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.session-recent-row b{font-size:8px}.session-recent-row span,.session-recent-row small{font-size:7px;color:var(--muted)}.session-recent-row strong{font-size:10px;color:var(--accent);font-variant-numeric:tabular-nums}.session-recent-row strong.negative{color:var(--danger)}
@media(max-width:1120px){.session-stats-grid{grid-template-columns:repeat(3,1fr)}.session-analysis-layout{grid-template-columns:1fr}}
@media(max-width:900px){.session-trigger{display:inline-flex!important;width:34px;min-width:34px;padding:0}.session-trigger span{display:none}.session-analysis-card{padding:14px}.session-stats-grid{grid-template-columns:repeat(3,1fr)}.session-analysis-layout{grid-template-columns:1fr}.session-day-bars{gap:3px}.session-day-slot i{width:min(14px,80%)}}
@media(max-width:700px){.session-live-grid{grid-template-columns:1fr 1fr}.session-live-grid>div:last-child{grid-column:1/-1}.session-stats-grid{grid-template-columns:repeat(2,1fr)}.session-analysis-card{padding:12px}.session-day-chart{overflow-x:auto}.session-day-bars{min-width:520px}.session-recent-list{max-height:220px}}
@media(prefers-reduced-motion:reduce){.session-trigger.active svg{animation:none}}

.session-analysis-card.empty-session-card .session-analysis-layout{display:none}.session-analysis-card.empty-session-card{padding-bottom:18px}
@media (pointer:coarse) and (min-width:561px) and (max-width:1100px){.session-trigger{width:34px;min-width:34px;padding:0}.session-trigger span{display:none}.cloud-btn{width:34px!important;padding:0!important;justify-content:center}.cloud-btn-label{display:none!important}}


/* MM-Writer 1.01 — Saghe / Serie */
.home-heading-actions{display:flex;align-items:center;gap:8px;flex-wrap:wrap;justify-content:flex-end}
.book-library-stack{display:flex;flex-direction:column;gap:18px;min-width:0}
.saga-shelf{padding:13px;border-radius:25px;background:linear-gradient(145deg,color-mix(in srgb,var(--surface) 66%,transparent),color-mix(in srgb,var(--surface-2) 54%,transparent));}
.saga-shelf-head{display:flex;align-items:center;justify-content:space-between;gap:12px;padding:4px 5px 13px}
.saga-title-wrap{display:flex;align-items:center;gap:11px;min-width:0}.saga-title-wrap>div{min-width:0}
.saga-title-wrap small,.loose-books-head small{display:block;font-size:8px;letter-spacing:.11em;color:var(--muted);font-weight:700}
.saga-title-wrap h2{margin:3px 0 0;font:400 17px/1.25 "Libre Baskerville",Georgia,serif;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.saga-mark{display:grid;place-items:center;width:35px;height:35px;flex:0 0 auto;border-radius:12px;background:var(--accent-soft);color:var(--accent);border:1px solid color-mix(in srgb,var(--accent) 18%,var(--line))}
.saga-mark svg{width:17px;height:17px;fill:none;stroke:currentColor;stroke-width:1.55;stroke-linecap:round;stroke-linejoin:round}
.saga-shelf .book-library-grid{gap:11px}
.saga-shelf .book-card{background:linear-gradient(145deg,color-mix(in srgb,var(--surface-strong) 43%,transparent),color-mix(in srgb,var(--surface-2) 74%,transparent))}
.loose-books-section{min-width:0}.loose-books-head{padding:2px 3px 9px}
.book-state-chip.saga-chip{color:var(--accent);border-color:color-mix(in srgb,var(--accent) 20%,var(--line));background:color-mix(in srgb,var(--accent-soft) 72%,transparent)}
.saga-modal-head small{font-size:8px;letter-spacing:.12em;color:var(--accent);font-weight:700}.saga-modal-head h2{margin:4px 0 6px}.saga-modal-head p{margin:0 0 15px}
.saga-book-picker{margin-top:14px;max-height:330px;overflow:auto;padding-right:3px;display:flex;flex-direction:column;gap:6px}
.saga-book-picker>small{font-size:8px;letter-spacing:.1em;color:var(--muted);margin:0 0 3px}
.saga-book-choice{display:grid;grid-template-columns:18px minmax(0,1fr) 58px;align-items:center;gap:10px;padding:9px 10px;border:1px solid var(--line);border-radius:13px;background:var(--surface-2);transition:.16s ease}
.saga-book-choice:hover,.saga-book-choice.selected{background:var(--accent-soft);border-color:color-mix(in srgb,var(--accent) 24%,var(--line))}
.saga-book-choice>input[type="checkbox"]{accent-color:var(--accent)}
.saga-book-choice>span{min-width:0}.saga-book-choice b,.saga-book-choice small{display:block;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.saga-book-choice b{font-size:10px}.saga-book-choice small{font-size:8px;color:var(--muted);margin-top:2px}
.saga-order-input{width:54px!important;height:30px!important;text-align:center;padding:0 5px!important}
@media(max-width:820px){.home-heading{align-items:flex-start}.home-heading-actions{width:100%;justify-content:flex-start}.saga-shelf{padding:10px}.saga-shelf-head{padding:3px 3px 10px}.saga-book-choice{grid-template-columns:18px minmax(0,1fr) 52px}}

/* MM-Writer 1.01 — Spotify transport + playlist */
.radio-transport{display:flex;align-items:center;gap:6px}
.radio-skip{width:27px;height:27px;border-radius:50%;border:1px solid color-mix(in srgb,var(--line) 72%,#756b59);background:color-mix(in srgb,var(--surface-strong) 64%,#30352f 36%);color:#d8d3c6;display:grid;place-items:center;box-shadow:inset 0 1px rgba(255,255,255,.035),0 2px 5px rgba(0,0,0,.16);transition:.16s ease}
.radio-skip svg{width:13px;height:13px;fill:none;stroke:currentColor;stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round}.radio-skip:hover:not(:disabled){transform:translateY(-1px);background:color-mix(in srgb,var(--surface-strong) 76%,var(--accent) 24%)}.radio-skip:disabled{opacity:.3}
.radio-search-results{max-height:245px}
.radio-result-section{position:sticky;top:0;z-index:1;padding:7px 5px 4px;background:color-mix(in srgb,var(--surface-strong) 90%,transparent);backdrop-filter:blur(10px);font:700 6.5px Inter,sans-serif;letter-spacing:.13em;color:var(--accent)}
.radio-result-kind{display:inline-flex;margin-bottom:3px;padding:2px 4px;border-radius:999px;background:var(--surface-2);border:1px solid var(--line);font:700 5.5px Inter,sans-serif;letter-spacing:.08em;color:var(--muted)}
.radio-result-kind.playlist{color:var(--accent);background:var(--accent-soft)}
@media(max-width:900px){.radio-controls{gap:7px}.radio-transport{gap:4px}.radio-volume-wrap input{width:68px}}

/* MM-Writer 1.01 — Nature. Solo CSS, nessuna immagine o asset utente. */













/* Nature nel selettore temi */
.theme-grid{display:block;margin-top:12px}.theme-special-group{padding:11px;border:1px solid color-mix(in srgb,var(--accent) 18%,var(--line));border-radius:17px;background:linear-gradient(145deg,color-mix(in srgb,var(--accent-soft) 55%,var(--surface-2)),var(--surface-2));margin-bottom:12px}
.theme-special-head{display:flex;align-items:baseline;justify-content:space-between;gap:12px;margin:0 2px 9px}.theme-special-head span{font:500 14px "Libre Baskerville",Georgia,serif}.theme-special-head small{font-size:8px;color:var(--muted);text-align:right}
.theme-special-grid,.theme-standard-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:10px}
.theme-card.exclusive-theme{background:color-mix(in srgb,var(--surface-strong) 38%,var(--surface-2));border-color:color-mix(in srgb,var(--accent) 16%,var(--line))}
.theme-exclusive-label{display:inline-block;font-style:normal;font-size:6px;letter-spacing:.12em;color:var(--accent);margin-bottom:2px}
.sylva-theme-group{border-color:rgba(255,122,31,.22);background:linear-gradient(145deg,rgba(47,52,39,.16),color-mix(in srgb,var(--surface-2) 92%,transparent))}
.sylva-theme-group .theme-special-head span{font-family:"Allura",cursive;font-size:27px;line-height:.9;color:#b59c70}
.sylva-theme-card .theme-preview{background:linear-gradient(135deg,#2f3427 0 52%,#f3eee5 52% 100%)}
.sylva-theme-card .theme-preview:after{background:#ff7a1f;width:8px;height:8px;border-radius:50%;top:7px;right:7px}
.sylva-theme-card .theme-preview:before{background:#ded8cb;box-shadow:inset 0 0 0 1px rgba(173,153,118,.38)}
.nature-theme-card .theme-preview{border-radius:12px;background:
  radial-gradient(ellipse 10px 5px at 10px 9px,var(--preview-accent) 0 45%,transparent 48%),
  radial-gradient(ellipse 9px 4px at 38px 27px,var(--preview-accent) 0 45%,transparent 48%),
  var(--preview-bg)}
@media(max-width:620px){.theme-special-grid,.theme-standard-grid{grid-template-columns:1fr}.theme-special-head{display:block}.theme-special-head small{display:block;text-align:left;margin-top:4px}}



/* MM-Writer 1.02 — rinomina inline struttura */
.tree-title{cursor:text;border-radius:6px;padding:2px 4px;margin:-2px -4px;transition:background .16s ease,color .16s ease}
.tree-title:hover{background:color-mix(in srgb,var(--accent-soft) 64%,transparent);color:var(--text)}
.tree-row.renaming{background:color-mix(in srgb,var(--accent-soft) 72%,transparent);color:var(--text)}
.tree-title-input{flex:1;min-width:0;width:0;border:1px solid color-mix(in srgb,var(--accent) 38%,var(--line));background:color-mix(in srgb,var(--surface-strong) 94%,transparent);color:var(--text);border-radius:7px;padding:4px 6px;margin:-4px -6px;font:inherit;line-height:1.25;outline:none;box-shadow:0 0 0 2px color-mix(in srgb,var(--accent) 10%,transparent)}
.tree-title-input::selection{background:color-mix(in srgb,var(--accent) 35%,transparent)}
@media(max-width:1120px){.tree-title{min-height:24px;display:flex;align-items:center}.tree-title-input{min-height:28px;font-size:13px;padding:5px 7px}}



/* =========================================================================
   Sylva — tema ufficiale
   Verde foglia della marca + carta crema del logo + punto arancio come accento.
   ========================================================================= */
html[data-theme="sylva"] .scene-sheet{
  color:var(--sylva-ink);
  border:1px solid color-mix(in srgb,var(--leaf-stroke,#ad9976) 34%,transparent);
  background:linear-gradient(96deg,var(--sylva-paper-low),var(--sylva-paper-hi) 5%,var(--paper) 14% 88%,var(--sylva-paper-low));
  box-shadow:0 24px 58px rgba(10,13,9,.27),inset 0 1px rgba(255,255,255,.72);
}
html[data-theme="sylva"] .scene-editor{color:var(--sylva-ink);caret-color:#747660}
html[data-theme="sylva"] .scene-label{color:var(--sylva-paper-muted)}
html[data-theme="sylva"] .reader-document{
  color:var(--sylva-ink);
  background:linear-gradient(96deg,var(--sylva-paper-low),var(--sylva-paper-hi) 4%,var(--paper) 12% 90%,var(--sylva-paper-low));
  border-color:rgba(173,153,118,.28);
  box-shadow:0 28px 68px rgba(10,13,9,.29);
}
html[data-theme="sylva"] .reader-editor,html[data-theme="sylva"] .reader-separator h2{color:var(--sylva-ink)}
html[data-theme="sylva"] .reader-scene-label,html[data-theme="sylva"] .reader-separator small{color:var(--sylva-paper-muted)}
html[data-theme="sylva"] .reader-separator{border-color:rgba(116,108,92,.18)}
html[data-theme="sylva"] .review-original-sheet,html[data-theme="sylva"] .review-edit-sheet{background:var(--paper);color:var(--sylva-ink);border-color:rgba(173,153,118,.25)}
html[data-theme="sylva"] .review-original-copy,html[data-theme="sylva"] .review-scene-editor{color:var(--sylva-ink)}
html[data-theme="sylva"] .review-scene-head{background:color-mix(in srgb,var(--paper) 88%,var(--sylva-paper-low));border-color:rgba(116,108,92,.16)}
html[data-theme="sylva"] .review-scene-head>span,html[data-theme="sylva"] .review-scene-head>small{color:var(--sylva-paper-muted)}
html[data-theme="sylva"] .review-scene-head>small.changed{color:var(--sylva-ink)}
html[data-theme="sylva"] .primary-btn{background:#f06f16;color:#fff8f1;border-color:color-mix(in srgb,#ff7a1f 76%,#7b4b2b)}
html[data-theme="sylva"] .primary-btn:hover{background:#ff7a1f}
html[data-theme="sylva"] .rail-btn.active,html[data-theme="sylva"] .rail-btn:hover{background:color-mix(in srgb,var(--accent) 13%,transparent);color:#ffd7bb}
html[data-theme="sylva"] .theme-card.active{border-color:color-mix(in srgb,var(--accent) 52%,var(--line))}

/* ==========================================================================
   MM-Writer 1.03 — Nature Material
   Pelle SOLO sul fondale; superfici pulite; carta nel manoscritto.
   Nessuna immagine raster: solo CSS e SVG inline.
   ========================================================================== */
.theme-icon-nature{display:none}




/* Typography: UI editoriale, testo del manoscritto resta configurabile per libro. */





/* Niente foglie decorative: il materiale vive solo nel fondale. */






/* UI: niente effetto pelle su rail/topbar/card. Superfici matte e leggere. */











/* Writer: vera carta chiara su pelle, in entrambe le varianti. */











/* Reader: un unico foglio editoriale, non una serie di decorazioni. */








/* Tutte le altre sezioni: palette Nature e superfici pulite, NON pelle. */







/* Controlli: oliva, avorio e linee più sottili. */






/* Login: stessa lingua Nature quando il progetto/tema attivo lo richiede. */









/* Preview del tema: pelle + foglio, niente foglioline decorative. */
.nature-theme-card .theme-preview{background:linear-gradient(145deg,var(--preview-bg),color-mix(in srgb,var(--preview-bg) 76%,#000))!important}
.nature-theme-card .theme-preview:before{left:8px;top:6px;width:28px;height:24px;border-radius:5px;background:var(--preview-surface);box-shadow:0 4px 10px rgba(0,0,0,.16)}
.nature-theme-card .theme-preview:after{right:6px;top:9px;width:6px;height:18px;border-radius:3px;background:var(--preview-accent)}

/* Tablet: la carta sfrutta lo spazio ma non crea overflow. */
@media(max-width:900px){
  
  
}

/* ==========================================================================
   MM-Writer 1.1 — riordino gerarchico + marker note a spaziatura neutra
   ========================================================================== */
.tree-drag-handle{
  width:20px;height:28px;flex:0 0 20px;margin:-5px -3px -5px -5px;padding:0;
  border:0;background:transparent;color:color-mix(in srgb,var(--muted) 62%,transparent);
  display:grid;place-items:center;border-radius:7px;cursor:grab;touch-action:none;
  opacity:.42;transition:opacity .16s ease,color .16s ease,background .16s ease,transform .16s ease;
}
.tree-drag-handle svg{width:13px;height:13px;fill:currentColor;stroke:none}
.tree-row:hover .tree-drag-handle,.tree-row:focus-within .tree-drag-handle{opacity:.9}
.tree-drag-handle:hover{background:color-mix(in srgb,var(--accent-soft) 75%,transparent);color:var(--accent)}
.tree-drag-handle:active{cursor:grabbing;transform:scale(.94)}
body.structure-is-dragging,body.structure-is-dragging *{cursor:grabbing!important;user-select:none!important}
.tree-row.structure-drag-source{opacity:.28;filter:saturate(.65)}
.tree-row.drop-before,.tree-row.drop-after,.tree-row.drop-inside{position:relative}
.tree-row.drop-before::before,.tree-row.drop-after::after{
  content:"";position:absolute;left:5px;right:5px;height:2px;border-radius:2px;background:var(--accent);
  box-shadow:0 0 0 3px color-mix(in srgb,var(--accent) 12%,transparent);pointer-events:none;
}
.tree-row.drop-before::before{top:-4px}.tree-row.drop-after::after{bottom:-4px}
.tree-row.drop-inside{background:color-mix(in srgb,var(--accent-soft) 92%,transparent)!important;box-shadow:inset 0 0 0 1px color-mix(in srgb,var(--accent) 42%,transparent)!important;color:var(--text)}
.structure-drag-ghost{
  position:fixed;z-index:260;pointer-events:none;left:0;top:0;transform:translate3d(13px,13px,0);max-width:min(300px,70vw);
  padding:8px 11px;border-radius:11px;background:color-mix(in srgb,var(--surface-strong) 95%,var(--accent-soft));
  border:1px solid color-mix(in srgb,var(--accent) 28%,var(--line));box-shadow:var(--shadow);opacity:.96;
  display:flex;align-items:baseline;gap:8px;white-space:nowrap;overflow:hidden;
}
.structure-drag-ghost span{font-size:7px;letter-spacing:.12em;color:var(--accent);font-weight:700}
.structure-drag-ghost b{font-size:11px;overflow:hidden;text-overflow:ellipsis}
@media(max-width:1366px) and (pointer:coarse){
  .tree-drag-handle{width:28px;flex-basis:28px;height:36px;margin:-6px -4px -6px -7px;opacity:.72}
  .tree-drag-handle svg{width:15px;height:15px}
  .tree-row{min-height:42px}
}

/* Il marker resta cliccabile/trascinabile ma non aggiunge larghezza tra le parole. */
.bookmark-anchor{
  display:inline-block!important;width:0!important;height:0!important;margin:0!important;padding:0!important;
  vertical-align:baseline!important;line-height:0!important;overflow:visible!important;border-radius:0!important;
  position:relative!important;cursor:grab;
}
.bookmark-anchor:hover{background:transparent!important;transform:none!important}
.bookmark-anchor:active,.bookmark-anchor.dragging{transform:none!important}
.bookmark-icon{
  position:absolute!important;left:0!important;top:-1.18em!important;transform:translateX(-50%);
  width:18px;height:18px;display:grid!important;place-items:center;border-radius:6px;
  background:transparent;color:var(--bookmark-color);
  font:700 11px/1 system-ui,sans-serif!important;text-shadow:0 1px 3px rgba(0,0,0,.18);
  pointer-events:auto!important;
}
.bookmark-anchor:hover .bookmark-icon{background:color-mix(in srgb,var(--bookmark-color) 13%,var(--surface-strong));transform:translateX(-50%) translateY(-1px)}
.reader-editor .bookmark-anchor{cursor:pointer}


/* MM-Writer 1.1.1 — paragrafi coerenti + rimozione evidenziatore */
.highlight-clear{
  width:23px!important;min-width:23px!important;height:23px!important;padding:2px!important;margin-left:2px;
  display:inline-grid!important;place-items:center;border:1px solid var(--line)!important;border-radius:7px!important;
  background:transparent!important;color:var(--muted)!important;
}
.highlight-clear:hover{background:var(--accent-soft)!important;color:var(--text)!important}
.highlight-clear svg{width:14px;height:14px;fill:none;stroke:currentColor;stroke-width:1.55;stroke-linecap:round;stroke-linejoin:round}
.reader-highlights .reader-highlight-clear{
  width:23px;height:23px;border-radius:7px;background:transparent!important;color:var(--muted);display:grid;place-items:center;margin-left:2px;
}
.reader-highlights .reader-highlight-clear:hover{background:var(--accent-soft)!important;color:var(--text)}
.reader-highlight-clear svg{width:14px;height:14px;fill:none;stroke:currentColor;stroke-width:1.55;stroke-linecap:round;stroke-linejoin:round}
/* Enter crea un <p> con lo spazio scelto; Shift+Enter resta un semplice <br> nello stesso paragrafo. */
.scene-editor p,.reader-editor p{margin-top:0}


/* ==========================================================================
   MM-Writer 1.1.2 — tablet navigation fixes
   ========================================================================== */
@media (max-width:900px), (pointer:coarse) and (min-width:561px) and (max-width:1366px){
  
  
  
  .topbar-left{padding-left:44px;min-width:0}
}

@media (pointer:coarse){
  .tree-row{padding-right:5px}
  .tree-row .tree-title{min-width:0}
  .tree-row .tree-menu{
    opacity:1!important;
    width:36px;height:36px;flex:0 0 36px;
    display:grid;place-items:center;
    padding:0;border-radius:9px;
    font-size:18px;line-height:1;
    color:var(--muted);
    background:color-mix(in srgb,var(--surface-2) 72%,transparent);
    touch-action:manipulation;
    -webkit-tap-highlight-color:transparent;
  }
  .tree-row .tree-menu:active{background:var(--accent-soft);color:var(--text);transform:scale(.94)}
}

/* ==========================================================================
   MM-Writer 1.2 — selected-text bookmarks + high-refresh rendering
   ========================================================================== */
.bookmark-anchor.bookmark-highlight{
  display:inline!important;width:auto!important;height:auto!important;margin:0!important;padding:0!important;
  line-height:inherit!important;vertical-align:baseline!important;overflow:visible!important;position:relative!important;
  cursor:pointer!important;border-radius:.16em!important;
  background:color-mix(in srgb,var(--bookmark-color) 26%,transparent)!important;
  box-shadow:inset 0 -.08em 0 color-mix(in srgb,var(--bookmark-color) 58%,transparent)!important;
  -webkit-box-decoration-break:clone;box-decoration-break:clone;
  transition:background-color .16s ease,box-shadow .16s ease!important;
}
.bookmark-anchor.bookmark-highlight:hover{
  background:color-mix(in srgb,var(--bookmark-color) 38%,transparent)!important;
  box-shadow:inset 0 -.11em 0 color-mix(in srgb,var(--bookmark-color) 76%,transparent)!important;
}
.bookmark-anchor.bookmark-legacy-anchor{
  display:inline-block!important;width:0!important;height:0!important;overflow:hidden!important;
  margin:0!important;padding:0!important;line-height:0!important;pointer-events:none!important;background:none!important;box-shadow:none!important;
}
.bookmark-icon{display:none!important}
.bookmark-selection-preview{
  margin:11px 0 15px;padding:10px 12px;border:1px solid var(--line);border-radius:12px;
  background:color-mix(in srgb,var(--surface-2) 78%,transparent);color:var(--muted);
  font-family:var(--editor-font);font-size:11px;line-height:1.55;font-style:italic;
}
.bookmark-item blockquote{margin:7px 0 2px;padding:7px 9px;border-left:2px solid var(--bookmark-color);border-radius:0 8px 8px 0;background:color-mix(in srgb,var(--bookmark-color) 7%,transparent);font:italic 9px/1.45 var(--editor-font);color:var(--muted)}
.bm-mini-icon,.note-bubble-title i{width:10px!important;height:10px!important;border-radius:3px!important;background:var(--bookmark-color)!important;box-shadow:inset 0 0 0 1px rgba(255,255,255,.16);display:inline-block!important;flex:0 0 10px;color:transparent!important}
.note-bubble{position:fixed!important;will-change:transform,opacity;contain:layout paint style}
.note-bubble-empty{color:var(--muted);font-style:italic}
.note-bubble.pinned{box-shadow:0 22px 65px rgba(0,0,0,.28),inset 0 0 0 1px color-mix(in srgb,var(--bookmark-color) 8%,transparent)}
.bookmark-jump{animation:bookmarkRangePulse .88s ease-out}
@keyframes bookmarkRangePulse{0%{box-shadow:inset 0 -.08em 0 color-mix(in srgb,var(--bookmark-color) 58%,transparent),0 0 0 0 color-mix(in srgb,var(--bookmark-color) 0%,transparent)}38%{box-shadow:inset 0 -.11em 0 color-mix(in srgb,var(--bookmark-color) 82%,transparent),0 0 0 5px color-mix(in srgb,var(--bookmark-color) 18%,transparent)}100%{box-shadow:inset 0 -.08em 0 color-mix(in srgb,var(--bookmark-color) 58%,transparent),0 0 0 9px color-mix(in srgb,var(--bookmark-color) 0%,transparent)}}

.editor-viewport,.reader-viewport,.structure-panel,.codex-grid,.content-view{overscroll-behavior:contain}
/* Same motion as before, compositor-friendly on tablet. */
@media (max-width:900px), (pointer:coarse) and (min-width:561px) and (max-width:1366px){
  
  
  
  
}


/* ==========================================================================\n   MM-WRITER 1.2.1 · COMPOSITING / RETINA PERFORMANCE\n   Nessuna modifica allo stato finale dei temi: durante il moto, i pannelli\n   usano una superficie precomposta; a fine animazione torna il vero vetro.\n   ========================================================================== */
.rail,.structure-panel,.bookmark-panel,.spotify-radio,.modal{backface-visibility:hidden;-webkit-font-smoothing:antialiased}
.rail.perf-moving,.structure-panel.perf-moving,.bookmark-panel.perf-moving,.spotify-radio-rig.perf-moving .spotify-radio{
  will-change:transform,opacity;
  contain:layout paint style;
}
/* Il colore usa le variabili del tema corrente: vale per tutti i temi. */
.rail.perf-moving,.structure-panel.perf-moving,.bookmark-panel.perf-moving{
  backdrop-filter:none!important;-webkit-backdrop-filter:none!important;
  background:color-mix(in srgb,var(--surface-strong) 72%,var(--surface) 28%)!important;
}
.spotify-radio-rig.perf-moving .spotify-radio{
  backdrop-filter:none!important;-webkit-backdrop-filter:none!important;
  background:linear-gradient(145deg,color-mix(in srgb,var(--surface-strong) 90%,#736348 10%),color-mix(in srgb,var(--surface-strong) 94%,#2d352b 6%))!important;
}
/* Lo stato fermo non viene alterato: torna la definizione originale del tema. */
.perf-diagnostics{width:min(760px,94vw)}
.perf-diag-grid{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:8px;margin:16px 0}
.perf-diag-card{padding:12px;border:1px solid var(--line);border-radius:13px;background:var(--surface-2);min-width:0}
.perf-diag-card small,.perf-diag-card b{display:block}.perf-diag-card small{font-size:8px;color:var(--muted);letter-spacing:.06em;text-transform:uppercase}.perf-diag-card b{font-size:17px;font-weight:500;margin-top:5px;font-variant-numeric:tabular-nums}
.perf-diag-section{margin-top:15px;padding-top:14px;border-top:1px solid var(--line)}
.perf-diag-section h3{font-size:12px;font-weight:500;margin:0 0 8px}.perf-diag-note{font-size:9px!important;color:var(--muted);line-height:1.55!important}
.perf-meter{height:7px;background:var(--surface-2);border:1px solid var(--line);border-radius:999px;overflow:hidden;margin-top:7px}.perf-meter i{display:block;height:100%;width:0;background:linear-gradient(90deg,var(--accent),var(--accent-2));transition:width .3s ease}
@media(max-width:900px){.perf-diag-grid{grid-template-columns:repeat(2,minmax(0,1fr))}}
.modal-backdrop.perf-moving .modal{
  backdrop-filter:none!important;-webkit-backdrop-filter:none!important;
  background:color-mix(in srgb,var(--surface-strong) 78%,var(--surface) 22%)!important;
  will-change:opacity;contain:layout paint style;
}

/* 1.6 · Narrative planning */
.scene-narrative-pills{display:flex;flex-wrap:wrap;gap:4px;margin-top:1px}
.narrative-pill{--pill-color:var(--accent);display:inline-flex;align-items:center;min-height:18px;padding:3px 6px;border:1px solid color-mix(in srgb,var(--pill-color) 28%,var(--line));border-radius:999px;background:color-mix(in srgb,var(--pill-color) 10%,var(--surface-2));color:color-mix(in srgb,var(--pill-color) 62%,var(--text));font-size:7px;font-weight:650;line-height:1;white-space:nowrap}
.narrative-pill.status::before,.narrative-pill.plot::before{content:"";width:5px;height:5px;border-radius:50%;background:var(--pill-color);margin-right:5px}
.narrative-pill.target{--pill-color:var(--muted);font-variant-numeric:tabular-nums}
.scene-card-btn{color:var(--accent)}
.scene-card-modal{width:min(780px,calc(100vw - 30px));max-height:min(91dvh,960px)}
.scene-card-head small{display:block;font-size:8px;letter-spacing:.14em;color:var(--accent);font-weight:700;margin-bottom:6px}.scene-card-head h2{margin:0;font-size:25px;font-weight:520}.scene-card-head p{margin:7px 0 0}
.scene-card-grid{display:grid;grid-template-columns:1fr 1fr;gap:13px;margin-top:18px}.scene-card-grid .span-2{grid-column:1/-1}
.form-label-actions{display:flex;align-items:center;justify-content:space-between;gap:10px}.tiny-text-btn{border:0;background:transparent;color:var(--accent);font:650 8px Inter,sans-serif;padding:3px 0}.tiny-text-btn:hover{text-decoration:underline}
.narrative-check-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:6px;padding:7px;border:1px solid var(--line);border-radius:12px;background:color-mix(in srgb,var(--surface-2) 75%,transparent);max-height:150px;overflow:auto}
.narrative-check{display:flex;align-items:center;gap:7px;min-height:31px;padding:5px 7px;border-radius:8px;color:var(--text);font-size:9px}.narrative-check:hover{background:var(--surface-3)}.narrative-check input{width:14px;height:14px;margin:0}.narrative-check i{width:7px;height:7px;border-radius:50%;background:var(--check-color);flex:0 0 auto}.narrative-check span{min-width:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.narrative-empty-inline{grid-column:1/-1;padding:10px;color:var(--muted);font-size:8px;line-height:1.5}
.scene-card-word-preview{border:1px solid var(--line);border-radius:12px;background:var(--surface-2);padding:10px 12px;align-self:end}.scene-card-word-preview small,.scene-card-word-preview b{display:block}.scene-card-word-preview small{font-size:7px;text-transform:uppercase;letter-spacing:.08em;color:var(--muted)}.scene-card-word-preview b{font-size:18px;margin-top:4px;font-variant-numeric:tabular-nums}
.plotline-modal{width:min(650px,calc(100vw - 28px))}.plotline-manager{display:flex;flex-direction:column;gap:5px;margin-top:16px}.plotline-row{display:grid;grid-template-columns:12px minmax(0,1fr) 30px 30px;align-items:center;gap:8px;padding:9px 10px;border:1px solid var(--line);border-radius:12px;background:var(--surface-2)}.plotline-row>i{width:8px;height:8px;border-radius:50%;background:var(--plot-color)}.plotline-row>b{font-size:10px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.narrative-analysis-grid{margin-top:12px}.narrative-plotline-card{margin:12px 0 14px}.book-goal-analysis{min-height:112px;display:flex;align-items:center;gap:18px}.book-goal-ring{--goal:0;width:82px;height:82px;flex:0 0 82px;border-radius:50%;display:grid;place-items:center;background:conic-gradient(var(--accent) calc(var(--goal)*1%),color-mix(in srgb,var(--muted) 15%,transparent) 0);position:relative}.book-goal-ring::after{content:"";position:absolute;inset:8px;border-radius:50%;background:var(--surface-2);border:1px solid var(--line)}.book-goal-ring b{z-index:1;font-size:16px}.book-goal-copy{flex:1;min-width:0}.book-goal-copy strong,.book-goal-copy span{display:block}.book-goal-copy strong{font-size:14px}.book-goal-copy span{font-size:8px;color:var(--muted);margin-top:4px}.goal-track{height:5px;border-radius:99px;background:color-mix(in srgb,var(--muted) 15%,transparent);overflow:hidden;margin-top:12px}.goal-track i{display:block;height:100%;border-radius:inherit;background:var(--accent)}
.narrative-stat-list{display:flex;flex-direction:column;gap:5px}.narrative-stat-row{display:grid;grid-template-columns:8px minmax(0,1fr) 28px 36px;align-items:center;gap:8px;padding:8px 9px;border-radius:10px;background:var(--surface-2);border:1px solid color-mix(in srgb,var(--line) 70%,transparent)}.narrative-stat-row>i{width:7px;height:7px;border-radius:50%;background:var(--stat-color)}.narrative-stat-row b{font-size:9px}.narrative-stat-row span,.narrative-stat-row em{font:600 8px Inter,sans-serif;font-style:normal;color:var(--muted);text-align:right}
.narrative-mini-bars{display:flex;flex-direction:column;gap:7px}.mini-meta-bar{position:relative;overflow:hidden;border:1px solid var(--line);border-radius:10px;background:var(--surface-2);min-height:40px}.mini-meta-bar>div{position:relative;z-index:1;display:grid;grid-template-columns:8px minmax(0,1fr) auto;align-items:center;gap:7px;padding:9px 10px}.mini-meta-bar>div i{width:7px;height:7px;border-radius:50%;background:var(--meta-color)}.mini-meta-bar b{font-size:9px}.mini-meta-bar span{font-size:7px;color:var(--muted)}.mini-meta-bar>em{position:absolute;left:0;bottom:0;height:2px;background:var(--accent);opacity:.7}
.plotline-analysis-list{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:7px}.plotline-analysis-row{display:grid;grid-template-columns:9px minmax(0,1fr) auto;gap:8px;align-items:center;padding:10px 11px;border:1px solid var(--line);border-radius:11px;background:var(--surface-2)}.plotline-analysis-row>i{width:8px;height:8px;border-radius:50%;background:var(--plot-color)}.plotline-analysis-row b,.plotline-analysis-row span{display:block}.plotline-analysis-row b{font-size:9px}.plotline-analysis-row span{font-size:7px;color:var(--muted);margin-top:2px}.plotline-analysis-row em{font:600 8px Inter,sans-serif;font-style:normal;color:var(--muted)}

@media(max-width:900px){.scene-card-grid{grid-template-columns:1fr}.scene-card-grid .span-2{grid-column:auto}.narrative-check-grid{grid-template-columns:1fr}.plotline-analysis-list{grid-template-columns:1fr}.outline-scene .outline-node-actions{gap:2px}.outline-scene .outline-icon-btn{width:34px;height:34px;padding:8px}}
.tree-narrative-status{width:6px;height:6px;border-radius:50%;background:var(--scene-status);box-shadow:0 0 0 2px color-mix(in srgb,var(--scene-status) 13%,transparent);flex:0 0 auto;margin-right:-2px}
.diff-single.narrative-change{background:color-mix(in srgb,var(--accent) 8%,transparent);border:1px solid color-mix(in srgb,var(--accent) 20%,var(--line));margin-bottom:8px}


/* MM-Writer 1.8 — tablet structure panel close regression retained */
@media (max-width:900px), (pointer:coarse) and (min-width:561px) and (max-width:1366px){
  .structure-panel.collapsed{
    transform:translate3d(calc(-100% - 15px),0,0)!important;
    opacity:0!important;
    pointer-events:none!important;
  }
  .structure-panel.mobile-open:not(.collapsed){
    transform:translate3d(0,0,0)!important;
    opacity:1!important;
    pointer-events:auto!important;
  }
}

/* MM-Writer 1.8 — Personaggi 2.0 / worldbuilding / relazioni */
#codexWorldOverview:empty{display:none}
.codex-world-overview{margin:0 0 16px 268px;border-radius:18px;padding:14px 16px;background:color-mix(in srgb,var(--surface) 82%,transparent)}
.codex-world-head{display:flex;align-items:flex-end;justify-content:space-between;gap:16px;margin-bottom:10px}
.codex-world-head small{display:block;font:650 7px Inter,sans-serif;letter-spacing:.14em;color:var(--accent)}
.codex-world-head h3{font-size:16px;font-weight:520;margin:4px 0 0}.codex-world-head>span{font:550 8px Inter,sans-serif;color:var(--muted)}
.location-tree{display:grid;grid-template-columns:repeat(auto-fit,minmax(220px,1fr));gap:5px 12px;max-height:310px;overflow:auto;padding:2px}
.location-tree-node>div{margin-left:13px;border-left:1px solid color-mix(in srgb,var(--line) 85%,transparent);padding-left:4px}
.location-tree-node>button{width:100%;min-height:34px;display:grid;grid-template-columns:8px minmax(0,1fr) 20px;align-items:center;gap:8px;text-align:left;padding:6px 8px 6px calc(8px + min(var(--location-depth),3)*5px);border:1px solid transparent;border-radius:9px;background:transparent;color:var(--text);transition:.16s ease}
.location-tree-node>button:hover{background:var(--surface-2);border-color:var(--line)}.location-tree-node>button>i{width:6px;height:6px;border-radius:50%;background:var(--location-color)}.location-tree-node>button>span{min-width:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;font-size:9px}.location-tree-node>button>em{font:600 7px Inter,sans-serif;color:var(--muted);font-style:normal;text-align:right}
.codex-card-worldmeta{display:flex;align-items:center;justify-content:space-between;gap:7px;margin:11px 0 -8px}.codex-card-worldmeta span{display:inline-flex;align-items:center;gap:5px;font:650 7px Inter,sans-serif;letter-spacing:.03em;color:var(--accent)}.codex-card-worldmeta em{font:550 7px Inter,sans-serif;font-style:normal;color:var(--muted)}
.codex-card-detail{font-size:9px;color:color-mix(in srgb,var(--text) 78%,var(--muted));margin:-2px 0 8px}.codex-card-parent{font:520 7px Inter,sans-serif;color:var(--muted);margin:-3px 0 7px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.codex-entry-modal{width:min(900px,calc(100vw - 28px))}.codex-entry-head{display:flex;align-items:flex-start;justify-content:space-between;gap:18px}.codex-entry-head>div{min-width:0}.codex-entry-head small{font:650 7px Inter,sans-serif;letter-spacing:.14em;color:var(--accent)}.codex-entry-head h2{margin:5px 0 4px}.codex-entry-head p{margin:0}.world-template-badge{display:inline-flex;align-items:center;gap:7px;flex:0 0 auto;padding:7px 10px;border:1px solid color-mix(in srgb,var(--accent) 24%,var(--line));border-radius:999px;background:var(--accent-soft);color:var(--accent);font:650 8px Inter,sans-serif}.world-template-badge svg{width:15px;height:15px}
.worldbuilding-section{margin:20px 0 3px;padding:18px;border:1px solid var(--line);border-radius:17px;background:color-mix(in srgb,var(--surface-2) 68%,transparent)}.worldbuilding-section-head,.world-custom-head{display:flex;justify-content:space-between;align-items:flex-end;gap:14px}.worldbuilding-section-head small{display:block;font:650 7px Inter,sans-serif;letter-spacing:.14em;color:var(--accent)}.worldbuilding-section-head h3{font-size:17px;font-weight:520;margin:4px 0 0}.worldbuilding-section-head>span{font:550 7px Inter,sans-serif;color:var(--muted)}
.world-template-grid{display:grid;grid-template-columns:1fr 1fr;gap:12px;margin-top:15px}.world-template-grid .span-2{grid-column:1/-1}.world-template-grid textarea{min-height:82px}.world-template-empty{margin-top:14px;padding:15px;border:1px dashed var(--line);border-radius:12px;color:var(--muted);font-size:9px;line-height:1.55}
.world-custom-head{margin-top:18px;padding-top:15px;border-top:1px solid var(--line);align-items:center}.world-custom-head b,.world-custom-head small{display:block}.world-custom-head b{font-size:10px}.world-custom-head small{font-size:7px;color:var(--muted);margin-top:2px}.world-custom-fields{display:flex;flex-direction:column;gap:6px;margin-top:9px}.world-custom-row{display:grid;grid-template-columns:minmax(120px,.6fr) minmax(0,1.4fr) 32px;gap:7px;align-items:start}.world-custom-row input,.world-custom-row textarea{min-width:0}.world-custom-row textarea{min-height:40px;resize:vertical}.world-custom-row .outline-icon-btn{width:32px;height:32px}
.codex-relations{margin:18px 0 3px;border-top:1px solid var(--line);padding-top:17px}.entry-relation-list{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:6px;margin-top:10px}.entry-relation-chip{display:grid;grid-template-columns:7px minmax(0,1fr) 22px;gap:8px;align-items:center;padding:9px 10px;border:1px solid var(--line);border-radius:11px;background:var(--surface-2)}.entry-relation-chip>i{width:7px;height:7px;border-radius:50%;background:var(--relation-color)}.entry-relation-chip b,.entry-relation-chip small{display:block}.entry-relation-chip b{font-size:9px}.entry-relation-chip small{font-size:7px;color:var(--muted);margin-top:2px}.entry-relation-chip em{font:600 10px Inter,sans-serif;color:var(--muted);font-style:normal;text-align:right}



.relationship-editor-modal{width:min(720px,calc(100vw - 26px))}.relationship-editor-grid{display:grid;grid-template-columns:1fr 1fr;gap:12px}.relationship-editor-grid .span-2{grid-column:1/-1}.revision-world-change{display:flex;align-items:center;gap:10px;padding:10px 16px;border-bottom:1px solid var(--line);background:color-mix(in srgb,var(--accent) 7%,var(--surface))}.revision-world-change>i{width:7px;height:26px;border-radius:5px;background:var(--accent)}.revision-world-change b,.revision-world-change span{display:block}.revision-world-change b{font-size:9px}.revision-world-change span{font-size:7px;color:var(--muted);margin-top:2px}


@media(max-width:1000px){.codex-world-overview{margin-left:0}.location-tree{grid-template-columns:1fr}}
@media(max-width:900px){.world-template-grid{grid-template-columns:1fr}.world-template-grid .span-2{grid-column:auto}.entry-relation-list{grid-template-columns:1fr}.relationship-editor-grid{grid-template-columns:1fr}.relationship-editor-grid .span-2{grid-column:auto}.world-custom-row{grid-template-columns:1fr 38px}.world-custom-row textarea{grid-column:1/-1;grid-row:2}.world-custom-row .outline-icon-btn{grid-column:2;grid-row:1}.codex-entry-head{flex-direction:column}.world-template-badge{align-self:flex-start}}
@media(max-width:700px){.worldbuilding-section{padding:13px}.codex-entry-modal{width:calc(100vw - 16px)}}


/* MM-Writer 1.94.1 — Timeline, calendar & continuity · theme stabilization */
.timeline-view{padding-bottom:90px}.timeline-heading{align-items:flex-start}.timeline-stats{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:1px;padding:1px;margin:0 0 14px;background:var(--line);overflow:hidden;border-radius:18px}.timeline-stats>div{background:var(--surface-2);padding:16px 18px;display:flex;flex-direction:column;gap:3px}.timeline-stats b{font-family:var(--ui-serif,inherit);font-size:24px;font-weight:500}.timeline-stats span{font-size:11px;color:var(--muted);text-transform:uppercase;letter-spacing:.08em}.timeline-tools{display:flex;gap:12px;align-items:center;padding:10px 12px;margin-bottom:14px;position:sticky;top:72px;z-index:7}.timeline-tools .search-wrap{flex:1}.timeline-tools select{width:auto;min-width:170px}.timeline-list{position:relative;display:flex;flex-direction:column;gap:12px;margin-top:16px;padding-left:12px}.timeline-list:before{content:"";position:absolute;left:34px;top:18px;bottom:20px;width:1px;background:linear-gradient(var(--line),color-mix(in srgb,var(--accent) 32%,var(--line)),var(--line))}.timeline-event-card{position:relative;display:grid;grid-template-columns:46px minmax(0,1fr);gap:14px;padding:0 0 4px}.timeline-axis{position:relative;z-index:1;display:grid;place-items:start center;padding-top:18px}.timeline-axis i{position:absolute;top:23px;width:11px;height:11px;border:3px solid var(--surface);border-radius:50%;background:var(--event-color);box-shadow:0 0 0 1px color-mix(in srgb,var(--event-color) 55%,var(--line))}.timeline-axis span{display:none}.timeline-event-main{border:1px solid var(--line);border-radius:18px;padding:16px 18px;background:color-mix(in srgb,var(--surface-2) 94%,var(--event-color) 6%);box-shadow:0 10px 35px color-mix(in srgb,#000 8%,transparent)}.timeline-event-date{display:flex;align-items:center;gap:12px;margin-bottom:8px}.timeline-event-date b{font-size:12px;color:color-mix(in srgb,var(--event-color) 58%,var(--text));letter-spacing:.04em}.timeline-event-date span{font-size:10px;text-transform:uppercase;letter-spacing:.09em;color:var(--muted)}.timeline-event-head{display:flex;gap:14px;justify-content:space-between;align-items:flex-start}.timeline-event-head h3{margin:0;font-family:var(--ui-serif,inherit);font-size:21px;font-weight:500}.timeline-event-actions{display:flex;gap:4px}.timeline-event-main>p{margin:9px 0 0;color:var(--muted);line-height:1.55;white-space:pre-wrap}.timeline-scene-link{display:block;margin:4px 0 0;padding:0;border:0;background:none;color:var(--muted);font-size:11px;text-align:left;cursor:pointer}.timeline-scene-link:hover{color:var(--accent)}.timeline-event-pills{display:flex;gap:6px;flex-wrap:wrap;margin-top:11px}.timeline-pill{display:inline-flex;align-items:center;min-height:24px;padding:3px 9px;border-radius:999px;font-size:10px;border:1px solid color-mix(in srgb,var(--event-color) 38%,var(--line));background:color-mix(in srgb,var(--event-color) 11%,var(--surface-2));color:var(--text)}.timeline-pill.plot:before{content:"";width:5px;height:5px;border-radius:50%;background:var(--event-color);margin-right:5px}.timeline-empty{display:grid;place-items:center;text-align:center;min-height:330px;border:1px dashed var(--line);border-radius:22px;padding:35px}.timeline-empty-icon{font-size:40px;color:var(--muted)}.timeline-empty h3{margin:7px 0 3px;font-family:var(--ui-serif,inherit);font-weight:500}.timeline-empty p{margin:0 0 18px;color:var(--muted)}
.continuity-summary{display:grid;grid-template-columns:auto minmax(0,1fr) auto;align-items:center;gap:14px;border:1px solid var(--line);border-radius:18px;padding:12px 14px;background:var(--surface-2)}.continuity-score{width:50px;height:50px;border-radius:15px;display:grid;place-items:center;background:color-mix(in srgb,#4ba885 12%,var(--surface-strong));border:1px solid color-mix(in srgb,#4ba885 35%,var(--line))}.continuity-score b{font-size:18px}.continuity-score span{display:none}.continuity-score.has-errors{background:color-mix(in srgb,#d15d70 13%,var(--surface-strong));border-color:color-mix(in srgb,#d15d70 40%,var(--line))}.continuity-score.has-warnings{background:color-mix(in srgb,#d49549 13%,var(--surface-strong));border-color:color-mix(in srgb,#d49549 40%,var(--line))}.continuity-copy{display:flex;flex-direction:column;gap:3px}.continuity-copy b{font-weight:560}.continuity-copy span{font-size:11px;color:var(--muted)}

.timeline-event-modal{width:min(840px,calc(100vw - 28px))}.timeline-editor-grid{display:grid;grid-template-columns:1fr 1fr;gap:12px}.timeline-editor-grid .span-2{grid-column:1/-1}.event-codex-picker{display:flex;flex-wrap:wrap;gap:7px;max-height:120px;overflow:auto}.event-codex-picker label{display:flex;align-items:center;gap:6px;border:1px solid var(--line);border-radius:10px;padding:6px 8px;font-size:11px;background:var(--surface-2)}.switch-row{display:flex!important;flex-direction:row!important;justify-content:space-between;align-items:center}.switch-row input{width:18px!important;height:18px}
.continuity-report-modal{width:min(760px,calc(100vw - 28px))}.continuity-report-list{display:flex;flex-direction:column;gap:7px;max-height:58vh;overflow:auto;margin-top:15px}.continuity-issue{display:grid;grid-template-columns:10px minmax(0,1fr) auto;gap:12px;text-align:left;border:1px solid var(--line);border-radius:14px;background:var(--surface-2);padding:11px 13px;color:var(--text);cursor:pointer}.continuity-issue>i{width:8px;height:8px;border-radius:50%;margin-top:5px;background:#788f7d}.continuity-issue.error>i{background:#d15d70}.continuity-issue.warn>i{background:#d49549}.continuity-issue.info>i{background:#4c91d8}.continuity-issue span{display:flex;flex-direction:column;gap:3px}.continuity-issue small{color:var(--muted);line-height:1.4}.continuity-issue em{font-style:normal;color:var(--muted)}.continuity-clean{text-align:center;padding:35px 10px}.continuity-clean>b{display:inline-grid;place-items:center;width:55px;height:55px;border-radius:50%;background:color-mix(in srgb,#4ba885 14%,var(--surface-2));font-size:24px;color:#4ba885}.continuity-clean h3{font-family:var(--ui-serif,inherit);font-weight:500;margin:12px 0 5px}.continuity-clean p{color:var(--muted);margin:0}.timeline-analysis-metrics{display:grid;grid-template-columns:repeat(4,1fr);gap:8px}.timeline-analysis-metrics>div{padding:10px;border:1px solid var(--line);border-radius:12px;display:flex;flex-direction:column;gap:2px}.timeline-analysis-metrics b{font-size:19px;font-weight:500}.timeline-analysis-metrics span{font-size:9px;text-transform:uppercase;letter-spacing:.06em;color:var(--muted)}.analysis-jump-timeline{margin-top:10px;width:100%}.continuity-analysis-score{display:flex;gap:8px;align-items:baseline}.continuity-analysis-score b{font-size:30px;font-weight:500}.continuity-analysis-score span{font-size:11px;color:var(--muted)}.continuity-analysis-score.has-errors b{color:#d15d70}.continuity-analysis-score.has-warnings b{color:#d49549}.continuity-analysis-score.clean b{color:#4ba885}.continuity-analysis-copy{display:flex;justify-content:space-between;align-items:center;margin-top:12px;border-top:1px solid var(--line);padding-top:10px}.continuity-analysis-copy b{font-size:11px;color:var(--muted)}
@media(max-width:900px){.timeline-heading{display:block}.timeline-heading .heading-actions{margin-top:12px;display:flex;flex-wrap:wrap}.timeline-stats{grid-template-columns:repeat(2,1fr)}.timeline-tools{top:65px}.timeline-event-main{padding:14px}.timeline-editor-grid{grid-template-columns:1fr}.timeline-editor-grid .span-2{grid-column:auto}.timeline-analysis-metrics{grid-template-columns:repeat(2,1fr)}}
@media(max-width:640px){.timeline-stats{grid-template-columns:1fr 1fr}.timeline-tools{align-items:stretch;flex-direction:column}.timeline-tools select{width:100%}.continuity-summary{grid-template-columns:auto 1fr}.continuity-summary>button{grid-column:1/-1}.timeline-list{padding-left:0}.timeline-list:before{left:24px}.timeline-event-card{grid-template-columns:32px minmax(0,1fr);gap:8px}.timeline-axis i{width:9px;height:9px}.timeline-event-date{align-items:flex-start;flex-direction:column;gap:2px}.timeline-event-head h3{font-size:18px}}

/* MM-Writer 1.95 — narrative workspace UX refactor */
.rail-nav{min-height:0;overflow-y:auto;overflow-x:hidden;scrollbar-width:none;padding-bottom:4px}
.rail-nav::-webkit-scrollbar{display:none}

/* Shared product-grade metrics */
.planning-stats,.relationship-page-stats,.calendar-summary{display:grid;grid-template-columns:repeat(5,minmax(0,1fr));gap:1px;padding:1px;border-radius:18px;overflow:hidden;background:var(--line);margin:0 0 16px}
.relationship-page-stats,.calendar-summary{grid-template-columns:repeat(4,minmax(0,1fr))}
.planning-stats>div,.relationship-page-stats>div,.calendar-summary>div{background:var(--surface-2);padding:15px 17px;display:flex;flex-direction:column;gap:3px;min-width:0}
.planning-stats b,.relationship-page-stats b,.calendar-summary b{font-family:var(--ui-serif,inherit);font-size:23px;font-weight:500;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.planning-stats span,.relationship-page-stats span,.calendar-summary span{font-size:9px;line-height:1.2;text-transform:uppercase;letter-spacing:.08em;color:var(--muted)}

/* Planning workspace */
.planning-view{padding-bottom:92px}.planning-heading{align-items:flex-start}
.planning-workspace{display:grid;grid-template-columns:minmax(290px,360px) minmax(0,1fr);gap:14px;min-height:650px}
.planning-scenes-panel,.planning-detail{border:1px solid var(--line);border-radius:20px;background:color-mix(in srgb,var(--surface-2) 82%,transparent)}
.planning-scenes-panel{padding:12px;display:flex;flex-direction:column;min-height:0;position:sticky;top:76px;height:calc(100dvh - 116px);max-height:790px}
.planning-filter-row{display:grid;grid-template-columns:minmax(0,1fr) 138px;gap:8px;padding-bottom:10px;border-bottom:1px solid var(--line)}
.planning-filter-row input,.planning-filter-row select{height:38px;font-size:12px}
.planning-scene-list{overflow:auto;min-height:0;padding:8px 1px 2px;display:flex;flex-direction:column;gap:5px}
.planning-scene-row{width:100%;display:grid;grid-template-columns:7px minmax(0,1fr) 48px;gap:10px;align-items:center;text-align:left;padding:10px 10px;border:1px solid transparent;border-radius:13px;background:transparent;color:var(--text);transition:.16s ease}
.planning-scene-row:hover{background:var(--surface-2);border-color:var(--line)}
.planning-scene-row.active{background:var(--accent-soft);border-color:color-mix(in srgb,var(--accent) 30%,var(--line));box-shadow:inset 3px 0 var(--accent)}
.planning-scene-row>i{width:7px;height:34px;border-radius:999px;background:var(--scene-status-color)}
.planning-scene-row>span{min-width:0}.planning-scene-row>span small,.planning-scene-row>span b,.planning-scene-row>span em{display:block;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.planning-scene-row>span small{font-size:8px;color:var(--muted);margin-bottom:3px}.planning-scene-row>span b{font-size:12px;font-weight:600}.planning-scene-row>span em{font-size:9px;font-style:normal;color:var(--muted);margin-top:3px}
.planning-scene-row>strong{text-align:right;font-weight:500}.planning-scene-row>strong b,.planning-scene-row>strong small{display:block}.planning-scene-row>strong b{font-size:12px}.planning-scene-row>strong small{font-size:7px;color:var(--muted);text-transform:uppercase;letter-spacing:.06em}
.planning-detail{padding:18px 19px;min-width:0;align-self:start}
.planning-detail-head{display:flex;justify-content:space-between;gap:16px;align-items:flex-start;padding-bottom:15px;border-bottom:1px solid var(--line)}
.planning-detail-head>div:first-child small{font-size:8px;letter-spacing:.14em;color:var(--accent);font-weight:700}.planning-detail-head h2{margin:4px 0 3px;font-size:27px;font-weight:500;letter-spacing:-.03em}.planning-detail-head p{margin:0;color:var(--muted);font-size:10px}.planning-detail-head>div:last-child{display:flex;align-items:center;gap:9px}.planning-detail-head>div:last-child>span{font-size:8px;color:var(--muted)}
.planning-detail-grid{display:grid;grid-template-columns:.94fr .94fr 1.12fr;gap:12px;margin-top:14px}
.planning-card-block{min-width:0;border:1px solid var(--line);border-radius:17px;padding:14px;background:color-mix(in srgb,var(--surface) 56%,var(--surface-2))}
.planning-block-head{margin-bottom:12px}.planning-block-head small{font-size:8px;color:var(--accent);letter-spacing:.12em;font-weight:700}.planning-block-head h3{font-size:16px;font-weight:520;margin:4px 0 0}
.planning-field-grid{display:grid;grid-template-columns:1fr 1fr;gap:9px}.planning-field-grid .form-row{gap:4px}.planning-field-grid .form-row input,.planning-field-grid .form-row select{padding:8px 9px;font-size:12px;min-height:36px}
.planning-word-box{border:1px solid var(--line);border-radius:11px;padding:7px 9px;background:var(--surface-2);display:flex;justify-content:space-between;align-items:center}.planning-word-box small{font-size:8px;color:var(--muted);text-transform:uppercase;letter-spacing:.06em}.planning-word-box b{font-size:17px;font-weight:500}
.planning-linked-event{width:100%;margin-top:10px;padding:10px 11px;border:1px solid var(--line);border-radius:12px;background:var(--surface-2);color:var(--text);display:flex;justify-content:space-between;align-items:center;text-align:left}.planning-linked-event:hover,.planning-linked-event.has-event{border-color:color-mix(in srgb,var(--accent) 34%,var(--line));background:var(--accent-soft)}.planning-linked-event span small,.planning-linked-event span b{display:block}.planning-linked-event span small{font-size:7px;letter-spacing:.12em;color:var(--muted)}.planning-linked-event span b{font-size:10px;margin-top:2px}.planning-linked-event em{font-size:16px;font-style:normal;color:var(--accent)}
.planning-picker-block+.planning-picker-block{margin-top:13px;padding-top:13px;border-top:1px solid var(--line)}.planning-picker-head{display:flex;justify-content:space-between;align-items:center;margin-bottom:7px}.planning-picker-head b{font-size:10px}.planning-picker-head>span{font-size:9px;color:var(--muted)}
.planning-check-list{display:flex;flex-direction:column;gap:5px;max-height:180px;overflow:auto;padding-right:2px}.planning-check-list .narrative-check{min-height:34px;padding:7px 8px;font-size:10px}
.planning-story-fields{display:grid;gap:9px}.planning-story-fields textarea{min-height:86px;max-height:180px;padding:9px 10px;font-size:12px;line-height:1.45}

/* Scene quick card — wide, horizontal, no modal scrolling in normal desktop use */
.modal.scene-card-modal{width:min(1180px,calc(100vw - 34px));max-width:none;max-height:calc(100dvh - 30px);overflow:hidden;padding:20px 21px}
.scene-card-head-v2{display:flex;justify-content:space-between;gap:18px;align-items:flex-start;padding-bottom:14px;border-bottom:1px solid var(--line)}
.scene-card-head-v2>div:first-child{min-width:0}.scene-card-head-v2 small{font-size:8px;letter-spacing:.14em;color:var(--accent);font-weight:700}.scene-card-head-v2 h2{margin:4px 0 3px;font-size:27px;font-weight:500}.scene-card-head-v2 p{margin:0;color:var(--muted);font-size:10px;max-width:620px}.scene-card-head-meta{display:flex;align-items:center;gap:9px;white-space:nowrap}.scene-card-head-meta>span{font-size:9px;color:var(--muted)}
.scene-card-v2-grid{display:grid;grid-template-columns:.95fr 1fr 1.2fr;gap:11px;margin-top:13px}.scene-card-section{min-width:0;border:1px solid var(--line);border-radius:16px;padding:13px;background:color-mix(in srgb,var(--surface) 55%,var(--surface-2))}.scene-card-section-head{margin-bottom:10px}.scene-card-section-head small{font-size:7px;letter-spacing:.12em;color:var(--accent);font-weight:700}.scene-card-section-head h3{font-size:15px;font-weight:520;margin:3px 0 0}.scene-card-compact-grid{display:grid;grid-template-columns:1fr 1fr;gap:8px}.scene-card-compact-grid .form-row{gap:4px}.scene-card-compact-grid input,.scene-card-compact-grid select{min-height:35px;padding:7px 8px;font-size:11px}.scene-card-word-preview{border:1px solid var(--line);background:var(--surface-2);border-radius:10px;padding:7px 8px;display:flex;align-items:center;justify-content:space-between}.scene-card-word-preview small{font-size:7px;color:var(--muted);text-transform:uppercase}.scene-card-word-preview b{font-size:16px;font-weight:500}.scene-card-timeline-box{margin-top:9px;border:1px solid var(--line);border-radius:11px;padding:8px;display:flex;align-items:center;justify-content:space-between;gap:8px;background:var(--surface-2)}.scene-card-timeline-box small,.scene-card-timeline-box b{display:block}.scene-card-timeline-box small{font-size:7px;color:var(--muted)}.scene-card-timeline-box b{font-size:9px;margin-top:2px;max-width:170px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.scene-card-timeline-box .soft-btn{padding:6px 8px;font-size:9px}
.scene-card-connection-group+.scene-card-connection-group{margin-top:10px;padding-top:10px;border-top:1px solid var(--line)}.scene-card-check-scroll{max-height:145px;overflow:auto;grid-template-columns:1fr 1fr!important;gap:5px!important}.scene-card-check-scroll .narrative-check{padding:6px 7px;min-height:32px;font-size:9px}.scene-card-story-fields{display:grid;gap:8px}.scene-card-story-fields textarea{min-height:76px;max-height:120px;padding:8px 9px;font-size:11px;line-height:1.42;resize:vertical}.scene-card-actions{margin-top:13px;padding-top:12px;border-top:1px solid var(--line)}

/* Relationships as a real workspace */
.relationships-view{padding-bottom:92px}.relationships-heading{align-items:flex-start}
.relationship-page-toolbar{display:grid;grid-template-columns:minmax(250px,330px) minmax(0,1fr);gap:12px;align-items:end;padding:12px 13px;border:1px solid var(--line);border-radius:16px;margin-bottom:13px}.relationship-page-toolbar label>span{display:block;font-size:9px;font-weight:700;letter-spacing:.08em;text-transform:uppercase;color:var(--muted);margin-bottom:5px}.relationship-page-toolbar select,.relationship-page-toolbar input{height:40px;font-size:13px!important;padding:8px 10px!important}
.relationship-page-list-panel{border:1px solid var(--line);border-radius:19px;background:color-mix(in srgb,var(--surface-2) 76%,transparent)}.relationship-page-list-panel{padding:14px}.relationship-page-section-head{display:flex;justify-content:space-between;align-items:flex-end;gap:12px;margin-bottom:10px}.relationship-page-section-head small{font-size:8px;color:var(--accent);letter-spacing:.12em;font-weight:700}.relationship-page-section-head h3{font-size:17px;font-weight:520;margin:3px 0 0}.relationship-page-section-head>span{font-size:8px;color:var(--muted)}

.relationship-page-list{display:flex;flex-direction:column;gap:7px;max-height:545px;overflow:auto}



/* Calendar as a dedicated world-time editor */
.calendar-view{padding-bottom:92px}.calendar-heading{align-items:flex-start}.calendar-layout{display:grid;grid-template-columns:minmax(300px,.78fr) minmax(0,1.7fr);gap:13px;align-items:start}.calendar-foundation,.calendar-months-section{border:1px solid var(--line);border-radius:20px;padding:16px;background:color-mix(in srgb,var(--surface-2) 78%,transparent)}.calendar-foundation{position:sticky;top:76px}.calendar-section-head{display:flex;justify-content:space-between;gap:12px;align-items:flex-end;padding-bottom:11px;border-bottom:1px solid var(--line);margin-bottom:12px}.calendar-section-head small{font-size:8px;color:var(--accent);letter-spacing:.12em;font-weight:700}.calendar-section-head h3{font-size:18px;font-weight:520;margin:3px 0 0}.calendar-section-head>span{font-size:8px;color:var(--muted)}.calendar-foundation-grid{display:grid;grid-template-columns:1fr 1fr;gap:10px}.calendar-foundation-grid .span-2{grid-column:1/-1}.calendar-foundation-grid input{font-size:13px!important;min-height:40px}.calendar-foundation-grid .form-row>small{font-size:8px;color:var(--muted);line-height:1.4}.weekday-preview{display:flex;flex-wrap:wrap;gap:6px;margin-top:12px}.weekday-preview>span{display:inline-flex;align-items:center;gap:6px;border:1px solid var(--line);border-radius:999px;background:var(--surface-2);padding:6px 9px;font-size:9px}.weekday-preview>span b{display:grid;place-items:center;width:17px;height:17px;border-radius:50%;background:var(--accent-soft);color:var(--accent);font-size:8px}.weekday-preview>span.empty{border-style:dashed;color:var(--muted)}
.calendar-month-grid{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:9px}

/* Nature: keep material language in every new workspace */


@media(max-width:1180px){
  .planning-detail-grid{grid-template-columns:1fr 1fr}.planning-card-block.narrative-function{grid-column:1/-1}.planning-story-fields{grid-template-columns:repeat(3,1fr)}
  .scene-card-v2-grid{grid-template-columns:1fr 1fr}.scene-card-section.narrative{grid-column:1/-1}.scene-card-story-fields{grid-template-columns:repeat(3,1fr)}
  
  .calendar-month-grid{grid-template-columns:repeat(2,minmax(0,1fr))}
}
@media(max-width:900px){
  .planning-stats{grid-template-columns:repeat(3,1fr)}.planning-workspace{grid-template-columns:1fr}.planning-scenes-panel{position:relative;top:auto;height:auto;max-height:none}.planning-scene-list{max-height:310px}.planning-detail-grid{grid-template-columns:1fr 1fr}.planning-story-fields{grid-template-columns:1fr 1fr 1fr}
  .modal.scene-card-modal{overflow:auto}.scene-card-head-v2{flex-direction:column}.scene-card-head-meta{width:100%;justify-content:space-between}.scene-card-v2-grid{grid-template-columns:1fr 1fr}.scene-card-section.narrative{grid-column:1/-1}.scene-card-story-fields{grid-template-columns:repeat(3,1fr)}
  .relationship-page-stats,.calendar-summary{grid-template-columns:repeat(2,1fr)}.relationship-page-list{max-height:330px}.relationship-page-toolbar{grid-template-columns:1fr 1fr}
  .calendar-layout{grid-template-columns:1fr}.calendar-foundation{position:relative;top:auto}.calendar-month-grid{grid-template-columns:repeat(2,minmax(0,1fr))}
}
@media(max-width:700px){
  .planning-stats{grid-template-columns:repeat(2,1fr)}.planning-filter-row{grid-template-columns:1fr}.planning-detail{padding:13px}.planning-detail-head{flex-direction:column}.planning-detail-head>div:last-child{width:100%;justify-content:space-between}.planning-detail-grid{grid-template-columns:1fr}.planning-card-block.narrative-function{grid-column:auto}.planning-story-fields{grid-template-columns:1fr}.planning-field-grid{grid-template-columns:1fr 1fr}
  .scene-card-v2-grid{grid-template-columns:1fr}.scene-card-section.narrative{grid-column:auto}.scene-card-story-fields{grid-template-columns:1fr}.scene-card-check-scroll{grid-template-columns:1fr!important}
  .relationship-page-toolbar{grid-template-columns:1fr}
  .calendar-foundation-grid{grid-template-columns:1fr}.calendar-foundation-grid .span-2{grid-column:auto}.calendar-month-grid{grid-template-columns:1fr}
}

@media(max-height:900px){.rail-nav{gap:4px;margin-top:12px}.rail-btn{padding:6px 3px;gap:2px}.rail-btn small{font-size:8px}.rail-icon-wrap{width:22px;height:22px}.rail-icon{width:18px;height:18px}.rail-bottom{gap:4px}.rail{padding-top:9px;padding-bottom:9px}}
.relationship-intensity{display:grid;grid-template-columns:minmax(0,1fr) 42px;gap:9px;align-items:center;min-height:40px;padding:0 9px;border:1px solid var(--line);border-radius:11px;background:var(--surface-2)}
.relationship-intensity input{width:100%;accent-color:var(--accent)}.relationship-intensity b{font-size:10px;font-weight:600;text-align:right;color:var(--muted)}

.modal.relationship-editor-modal{width:min(820px,calc(100vw - 28px))}


/* MM-Writer 1.97 — performance + airy workspace polish
   More breathing room and stronger hierarchy without changing theme identity. */

/* Shared spatial rhythm for the content-heavy workspaces */
.content-view{width:min(1260px,96%);padding:46px 20px 104px}
.content-view.wide{width:min(1460px,97%)}
.view-heading{gap:28px;margin-bottom:34px}
.view-heading h1{font-size:38px;line-height:1.08;margin:7px 0 7px}
.view-heading p{font-size:14px;line-height:1.65;max-width:760px}
.view-heading small{font-size:10px;letter-spacing:.17em}
.heading-actions{gap:10px}
.heading-actions .soft-btn,.heading-actions .primary-btn{min-height:42px;padding-left:15px;padding-right:15px}

/* Library — calmer shelves and cards */
.home-view{max-width:1260px}
.home-heading{margin-bottom:38px}
.home-heading-actions{gap:10px}
.book-library-stack{gap:28px}
.saga-shelf{padding:20px;border-radius:28px}
.saga-shelf-head{padding:5px 6px 18px}
.saga-title-wrap{gap:14px}
.saga-mark{width:42px;height:42px;border-radius:14px}
.saga-mark svg{width:20px;height:20px}
.saga-title-wrap small,.loose-books-head small{font-size:9px;letter-spacing:.13em}
.saga-title-wrap h2{font-size:20px;margin-top:5px}
.loose-books-head{padding:5px 5px 14px}
.book-library-grid{grid-template-columns:repeat(auto-fill,minmax(360px,1fr));gap:20px}
.saga-shelf .book-library-grid{gap:18px}
.book-card{min-height:245px;padding:24px;border-radius:25px}
.book-card-identity{gap:15px}
.book-card-mark{width:48px;height:48px;border-radius:15px}
.book-card-mark svg{width:24px;height:24px}
.book-card h2{font-size:20px;line-height:1.35;margin-top:10px}
.book-status-line{gap:7px}
.book-card .book-version,.book-state-chip{font-size:9px;padding:5px 8px}
.book-card-actions{gap:7px}.book-icon-btn{width:36px;height:36px;padding:8px;border-radius:11px}
.book-card-meta{margin-top:28px;padding:15px 12px;border-radius:16px}
.book-meta-cell{gap:10px;padding:2px 10px!important}.book-meta-cell b{font-size:14px}.book-meta-cell span{font-size:9px;margin-top:2px}.meta-icon{width:19px;height:19px}
.book-card-footer{padding-top:20px;margin-top:0}.book-card-footer small{font-size:10px}.book-open-btn{min-height:38px;padding-left:13px;padding-right:13px}
.home-actions{gap:18px;margin-top:24px}.big-action{min-height:136px;padding:21px;border-radius:22px}.big-action .action-icon{width:29px;height:29px;margin-bottom:8px}.big-action b{font-size:13px}.big-action small{font-size:9px;line-height:1.5;margin-top:4px}
.empty-library{padding:58px 30px}.empty-library h2{font-size:21px}.empty-library p{font-size:12px;line-height:1.6}

/* Shared metrics — stop looking like compressed dashboard counters */
.planning-stats,.relationship-page-stats,.calendar-summary,.timeline-stats{gap:10px;padding:0;background:transparent;border-radius:0;margin-bottom:24px;overflow:visible}
.planning-stats>div,.relationship-page-stats>div,.calendar-summary>div,.timeline-stats>div{border:1px solid var(--line);border-radius:17px;background:color-mix(in srgb,var(--surface-2) 86%,transparent);padding:19px 20px;min-height:86px;justify-content:center}
.planning-stats b,.relationship-page-stats b,.calendar-summary b,.timeline-stats b{font-size:27px}
.planning-stats span,.relationship-page-stats span,.calendar-summary span,.timeline-stats span{font-size:10px;line-height:1.35;margin-top:2px}

/* Planning — the most spacious workspace */
.planning-view{padding-bottom:110px}
.planning-workspace{grid-template-columns:minmax(330px,390px) minmax(0,1fr);gap:24px;min-height:690px}
.planning-scenes-panel,.planning-detail{border-radius:24px}
.planning-scenes-panel{padding:18px;top:84px;height:calc(100dvh - 136px);max-height:830px}
.planning-filter-row{grid-template-columns:minmax(0,1fr) 155px;gap:10px;padding-bottom:15px}
.planning-filter-row input,.planning-filter-row select{height:44px;font-size:13px;padding-left:12px;padding-right:12px}
.planning-scene-list{padding:13px 2px 3px;gap:8px}
.planning-scene-row{grid-template-columns:8px minmax(0,1fr) 54px;gap:12px;padding:13px 12px;border-radius:15px;min-height:68px}
.planning-scene-row>i{width:8px;height:42px}
.planning-scene-row>span small{font-size:9px;margin-bottom:4px}.planning-scene-row>span b{font-size:13px}.planning-scene-row>span em{font-size:10px;margin-top:4px}
.planning-scene-row>strong b{font-size:13px}.planning-scene-row>strong small{font-size:8px;margin-top:2px}
.planning-detail{padding:27px 28px}
.planning-detail-head{gap:22px;padding-bottom:22px}
.planning-detail-head>div:first-child small{font-size:9px}.planning-detail-head h2{font-size:31px;margin:6px 0 5px}.planning-detail-head p{font-size:12px;line-height:1.55}.planning-detail-head>div:last-child{gap:11px}.planning-detail-head>div:last-child>span{font-size:9px}
.planning-detail-grid{grid-template-columns:.95fr .95fr 1.1fr;gap:18px;margin-top:22px}
.planning-card-block{border-radius:20px;padding:20px}
.planning-block-head{margin-bottom:16px}.planning-block-head small{font-size:9px}.planning-block-head h3{font-size:18px;margin-top:5px}
.planning-field-grid{gap:12px}.planning-field-grid .form-row{gap:6px}.planning-field-grid .form-row label{font-size:9px}.planning-field-grid .form-row input,.planning-field-grid .form-row select{padding:10px 11px;font-size:13px;min-height:42px}
.planning-word-box{border-radius:13px;padding:10px 11px}.planning-word-box small{font-size:9px}.planning-word-box b{font-size:19px}
.planning-linked-event{margin-top:13px;padding:13px 14px;border-radius:14px}.planning-linked-event span small{font-size:8px}.planning-linked-event span b{font-size:11px;margin-top:3px}
.planning-picker-block+.planning-picker-block{margin-top:17px;padding-top:17px}.planning-picker-head{margin-bottom:10px}.planning-picker-head b{font-size:12px}.planning-picker-head>span{font-size:10px}
.planning-check-list{gap:7px;max-height:230px}.planning-check-list .narrative-check{min-height:40px;padding:9px 10px;font-size:11px;border-radius:11px}
.planning-story-fields{gap:12px}.planning-story-fields textarea{min-height:112px;max-height:230px;padding:12px 13px;font-size:13px;line-height:1.55}

/* Quick scene card gets the same breathing room */
.modal.scene-card-modal{width:min(1280px,calc(100vw - 38px));padding:26px 27px}
.scene-card-head-v2{gap:24px;padding-bottom:19px}.scene-card-head-v2 small{font-size:9px}.scene-card-head-v2 h2{font-size:31px;margin:6px 0 5px}.scene-card-head-v2 p{font-size:12px;line-height:1.55}
.scene-card-v2-grid{gap:17px;margin-top:20px}.scene-card-section{border-radius:19px;padding:18px}.scene-card-section-head{margin-bottom:14px}.scene-card-section-head small{font-size:8px}.scene-card-section-head h3{font-size:17px;margin-top:4px}
.scene-card-compact-grid{gap:11px}.scene-card-compact-grid .form-row{gap:6px}.scene-card-compact-grid input,.scene-card-compact-grid select{min-height:41px;padding:9px 10px;font-size:12px}
.scene-card-word-preview{padding:10px 11px;border-radius:12px}.scene-card-word-preview small{font-size:8px}.scene-card-word-preview b{font-size:18px}
.scene-card-timeline-box{margin-top:12px;padding:11px;border-radius:13px}.scene-card-timeline-box small{font-size:8px}.scene-card-timeline-box b{font-size:10px}.scene-card-timeline-box .soft-btn{padding:7px 10px;font-size:10px}
.scene-card-connection-group+.scene-card-connection-group{margin-top:14px;padding-top:14px}.scene-card-check-scroll{max-height:185px;gap:7px!important}.scene-card-check-scroll .narrative-check{padding:8px 9px;min-height:37px;font-size:10px}
.scene-card-story-fields{gap:10px}.scene-card-story-fields textarea{min-height:94px;max-height:150px;padding:10px 11px;font-size:12px;line-height:1.5}.scene-card-actions{margin-top:18px;padding-top:16px}

/* Codex — more atlas, less dense database */
.codex-layout{grid-template-columns:280px minmax(0,1fr);gap:26px}
.codex-categories{padding:19px;border-radius:25px}.codex-categories .search-wrap{margin-bottom:15px}.codex-categories .search-wrap input{height:45px;border-radius:14px;font-size:13px;padding-left:13px}
.category-item,.category-main{grid-template-columns:36px minmax(0,1fr) auto;gap:11px;min-height:49px;padding:8px 10px;border-radius:13px}.category-row{grid-template-columns:minmax(0,1fr) 31px;gap:4px;margin-top:5px}.category-icon{width:34px;height:34px;border-radius:11px}.category-icon svg{width:18px;height:18px}.category-count{font-size:10px}.category-edit{font-size:9px}
.codex-grid{grid-template-columns:repeat(auto-fill,minmax(285px,1fr));gap:20px}.codex-card{min-height:245px;padding:22px 22px 20px;border-radius:24px}.codex-card-symbol{width:48px;height:48px;border-radius:15px}.codex-card-symbol svg{width:25px;height:25px}.codex-card-more{width:34px;height:34px;font-size:10px}.codex-card h3{font-size:20px;margin:19px 0 10px}.codex-card-categories{gap:7px}.codex-card-categories span{padding:6px 9px;font-size:9px}.codex-card p{font-size:12px;line-height:1.7;margin:16px 0 24px}.codex-card-foot{gap:8px;font-size:9px}.codex-card-worldmeta{margin:14px 0 -5px}.codex-card-worldmeta span,.codex-card-worldmeta em{font-size:8px}.codex-card-detail{font-size:10px;line-height:1.5}.codex-card-parent{font-size:8px}
.codex-world-overview{margin-bottom:22px}
.location-tree-node>button{min-height:40px;padding-top:8px;padding-bottom:8px}.location-tree-node>button>span{font-size:10px}.location-tree-node>button>em{font-size:8px}

/* Timeline — larger event rhythm and controls */
.timeline-view{padding-bottom:110px}
.timeline-tools{gap:14px;padding:14px 16px;margin-bottom:22px;top:80px;border-radius:17px}.timeline-tools input,.timeline-tools select{min-height:43px;font-size:13px}.timeline-tools select{min-width:190px}
.timeline-list{gap:18px;margin-top:24px;padding-left:15px}.timeline-list:before{left:38px}.timeline-event-card{grid-template-columns:50px minmax(0,1fr);gap:17px}.timeline-axis{padding-top:23px}.timeline-axis i{top:28px;width:12px;height:12px}
.timeline-event-main{border-radius:21px;padding:21px 23px;box-shadow:0 14px 38px color-mix(in srgb,#000 8%,transparent)}
.timeline-event-date{gap:14px;margin-bottom:11px}.timeline-event-date b{font-size:13px}.timeline-event-date span{font-size:10px}.timeline-event-head{gap:18px}.timeline-event-head h3{font-size:24px}.timeline-event-actions{gap:6px}.timeline-event-main>p{font-size:13px;line-height:1.65;margin-top:12px}.timeline-scene-link{font-size:12px;margin-top:6px}.timeline-event-pills{gap:8px;margin-top:15px}.timeline-pill{min-height:28px;padding:4px 11px;font-size:11px}
.timeline-empty{min-height:390px;padding:46px}.timeline-empty h3{font-size:21px}.timeline-empty p{font-size:12px;line-height:1.6}

/* Calendar — generous world-time editor */
.calendar-view{padding-bottom:110px}
.calendar-layout{grid-template-columns:minmax(340px,.8fr) minmax(0,1.8fr);gap:24px}
.calendar-foundation,.calendar-months-section{border-radius:24px;padding:24px}.calendar-foundation{top:84px}
.calendar-section-head{gap:16px;padding-bottom:16px;margin-bottom:18px}.calendar-section-head small{font-size:9px}.calendar-section-head h3{font-size:21px;margin-top:5px}.calendar-section-head>span{font-size:9px}
.calendar-foundation-grid{gap:15px}.calendar-foundation-grid .form-row{gap:7px}.calendar-foundation-grid .form-row label{font-size:9px}.calendar-foundation-grid input{font-size:14px!important;min-height:46px;padding:10px 12px!important}.calendar-foundation-grid .form-row>small{font-size:9px;line-height:1.55}
.weekday-preview{gap:8px;margin-top:18px}.weekday-preview>span{gap:7px;padding:8px 11px;font-size:10px}.weekday-preview>span b{width:21px;height:21px;font-size:9px}
.calendar-month-grid{gap:15px}


/* Relationships: keep the same airy language while we are here */
.relationship-page-toolbar{grid-template-columns:minmax(280px,360px) minmax(0,1fr);gap:16px;padding:16px 17px;border-radius:19px;margin-bottom:20px}.relationship-page-toolbar label>span{font-size:10px;margin-bottom:7px}.relationship-page-toolbar select,.relationship-page-toolbar input{height:44px;font-size:13px!important}
.relationship-page-list-panel{border-radius:22px}.relationship-page-list-panel{padding:19px}.relationship-page-section-head{margin-bottom:15px}.relationship-page-section-head small{font-size:9px}.relationship-page-section-head h3{font-size:19px;margin-top:4px}.relationship-page-section-head>span{font-size:9px}.relationship-page-list{gap:9px}

/* Responsive: preserve breathing room without forcing desktop density onto tablets */
@media(max-width:1180px){
  .content-view{width:min(100%,1160px);padding:36px 18px 90px}.content-view.wide{width:100%}
  .view-heading{margin-bottom:28px}.view-heading h1{font-size:35px}
  .book-library-grid{grid-template-columns:repeat(2,minmax(0,1fr))}
  .planning-workspace{grid-template-columns:minmax(300px,350px) minmax(0,1fr);gap:18px}.planning-detail{padding:23px}.planning-detail-grid{gap:15px}.planning-card-block{padding:17px}
  .codex-layout{grid-template-columns:250px minmax(0,1fr);gap:20px}.codex-grid{grid-template-columns:repeat(2,minmax(0,1fr));gap:16px}
  .calendar-layout{grid-template-columns:minmax(310px,.85fr) minmax(0,1.55fr);gap:18px}.calendar-foundation,.calendar-months-section{padding:20px}.calendar-month-grid{grid-template-columns:repeat(2,minmax(0,1fr))}
}
@media(max-width:900px){
  .content-view{padding:30px 18px 82px}.view-heading{margin-bottom:26px;gap:20px}.view-heading h1{font-size:33px}.view-heading p{font-size:13px}
  .book-library-stack{gap:24px}.saga-shelf{padding:17px}.book-card{min-height:232px;padding:21px}
  .planning-stats,.relationship-page-stats,.calendar-summary,.timeline-stats{gap:8px}.planning-stats>div,.relationship-page-stats>div,.calendar-summary>div,.timeline-stats>div{padding:16px;min-height:78px}.planning-stats b,.relationship-page-stats b,.calendar-summary b,.timeline-stats b{font-size:24px}
  .planning-workspace{grid-template-columns:1fr;gap:20px}.planning-scenes-panel{padding:16px;height:auto;max-height:none}.planning-scene-list{max-height:360px}.planning-detail{padding:22px}.planning-detail-grid{gap:14px}.planning-card-block{padding:17px}
  .codex-layout{grid-template-columns:1fr;gap:20px}.codex-categories{padding:16px;position:static}.codex-grid{grid-template-columns:repeat(2,minmax(0,1fr));gap:15px}.codex-card{min-height:225px;padding:19px}
  .timeline-tools{top:72px;padding:13px}.timeline-event-main{padding:18px 20px}.timeline-event-head h3{font-size:22px}
  .calendar-layout{grid-template-columns:1fr;gap:20px}.calendar-foundation{position:relative;top:auto}.calendar-foundation,.calendar-months-section{padding:20px}.calendar-month-grid{grid-template-columns:repeat(2,minmax(0,1fr));gap:13px}
  .relationship-page-list-panel{padding:17px}
  .modal.scene-card-modal{padding:22px}.scene-card-v2-grid{gap:14px}.scene-card-section{padding:16px}
}
@media(max-width:700px){
  .content-view{padding:26px 14px 76px}.view-heading{margin-bottom:22px}.view-heading h1{font-size:30px}.view-heading p{font-size:12px;line-height:1.6}.heading-actions{width:100%}
  .book-library-grid{grid-template-columns:1fr;gap:16px}.saga-shelf{padding:14px;border-radius:23px}.saga-shelf-head{padding-bottom:14px}.book-card{min-height:220px;padding:19px}.book-card h2{font-size:19px}.book-card-meta{margin-top:23px}.home-actions{grid-template-columns:1fr;gap:13px}.big-action{min-height:112px}
  .planning-stats,.relationship-page-stats,.calendar-summary,.timeline-stats{grid-template-columns:repeat(2,1fr);gap:7px}.planning-stats>div,.relationship-page-stats>div,.calendar-summary>div,.timeline-stats>div{min-height:72px;padding:14px}.planning-stats b,.relationship-page-stats b,.calendar-summary b,.timeline-stats b{font-size:22px}.planning-stats span,.relationship-page-stats span,.calendar-summary span,.timeline-stats span{font-size:9px}
  .planning-scenes-panel{padding:14px}.planning-filter-row{grid-template-columns:1fr}.planning-scene-row{min-height:64px}.planning-detail{padding:18px}.planning-detail-head h2{font-size:27px}.planning-detail-grid{grid-template-columns:1fr;gap:13px}.planning-card-block{padding:16px}.planning-story-fields textarea{min-height:100px}
  .codex-grid{grid-template-columns:1fr;gap:14px}.codex-card{min-height:215px}.category-item,.category-main{min-height:46px}
  .timeline-tools{position:relative;top:auto;padding:12px;margin-bottom:18px}.timeline-list{gap:15px;padding-left:0}.timeline-list:before{left:25px}.timeline-event-card{grid-template-columns:34px minmax(0,1fr);gap:10px}.timeline-event-main{padding:16px 17px}.timeline-event-head h3{font-size:20px}.timeline-event-main>p{font-size:12px}.timeline-pill{font-size:10px}
  .calendar-foundation,.calendar-months-section{padding:17px}.calendar-month-grid{grid-template-columns:1fr;gap:12px}.calendar-section-head{margin-bottom:15px;padding-bottom:14px}.weekday-preview{margin-top:14px}
  .relationship-page-toolbar{grid-template-columns:1fr;padding:14px}.relationship-page-list-panel{padding:15px}
  .modal.scene-card-modal{width:calc(100vw - 16px);padding:18px}.scene-card-head-v2 h2{font-size:27px}.scene-card-v2-grid{grid-template-columns:1fr}.scene-card-section{padding:15px}
}
@media(max-width:900px){.book-library-grid{grid-template-columns:1fr}}


/* ==========================================================================
   MM-WRITER 1.97 · PERFORMANCE PASS — zero visual downgrade
   Skip layout/paint for offscreen repeated content while preserving its size.
   ========================================================================== */
.scene-sheet,.book-card,.codex-card,.timeline-event-card,.planning-scene-row,.outline-node{
  content-visibility:auto;
  contain:layout paint style;
}
.scene-sheet{contain-intrinsic-size:auto 760px}
.book-card{contain-intrinsic-size:auto 245px}
.codex-card{contain-intrinsic-size:auto 245px}
.timeline-event-card{contain-intrinsic-size:auto 190px}

.planning-scene-row{contain-intrinsic-size:auto 68px}

.outline-node{contain-intrinsic-size:auto 100px}
/* Independent scroll areas do not invalidate the whole application. */
#multiSceneEditor,#structureTree,#planningSceneList,#codexGrid,#timelineList,#calendarMonthGrid,#relationshipPageList,.book-library-stack{contain:style}
/* Promote only active animations. Final glass/blur/shadows are unchanged. */
.perf-moving{transform:translateZ(0)}
.spotify-radio-rig.perf-moving,.modal-backdrop.perf-moving{isolation:isolate}
@media (pointer:coarse){
  .scene-sheet:hover,.book-card:hover,.codex-card:hover{transform:none}
}
/* During overlay motion the application canvas is kept on a stable compositor layer.
   This does not change blur, colors, shadows or final geometry. */
html.ui-motion-active .main-area{will-change:transform;transform:translateZ(0);backface-visibility:hidden}
.reader-sheet{content-visibility:auto;contain:layout paint style;contain-intrinsic-size:auto 720px}


/* ==========================================================================
   MM-Writer 1.98 — smartphone limited access + stable tablet menu
   ========================================================================== */
.phone-access{display:none}
html.phone-only:not(.workspace-entered) #app{visibility:hidden;pointer-events:none}
html.phone-only.workspace-entered body{overflow:auto!important;overscroll-behavior-y:auto;background:linear-gradient(145deg,var(--bg),var(--bg2))}
html.phone-only.workspace-entered #app{display:none!important}
html.phone-only.workspace-entered #modalBackdrop{display:none!important}
html.phone-only.workspace-entered .phone-access{
  position:fixed;inset:0;z-index:900;display:block;overflow-y:auto;overflow-x:hidden;
  padding:max(20px,env(safe-area-inset-top)) max(16px,env(safe-area-inset-right)) max(28px,calc(env(safe-area-inset-bottom) + 20px)) max(16px,env(safe-area-inset-left));
  background:linear-gradient(155deg,color-mix(in srgb,var(--bg) 96%,transparent),var(--bg2));
  -webkit-overflow-scrolling:touch;overscroll-behavior-y:contain;
}
.phone-access-shell{width:min(100%,560px);margin:0 auto;display:flex;flex-direction:column;gap:18px}
.phone-access-header{padding:8px 2px 0}.phone-access-brand{display:flex;align-items:center;gap:9px;margin-bottom:28px;color:var(--text)}
.phone-access-brand span{font:700 22px/1 Inter,sans-serif;letter-spacing:-.05em}.phone-access-brand span::first-letter{letter-spacing:-.04em}.phone-access-brand b{font:500 10px/1 Inter,sans-serif;letter-spacing:.2em;color:var(--muted)}
.phone-access-header>small{display:block;font-size:9px;font-weight:700;letter-spacing:.16em;color:var(--accent);margin-bottom:8px}
.phone-access-header h1{font-family:var(--ui-serif,Georgia,serif);font-size:clamp(30px,9vw,42px);font-weight:500;line-height:1.02;letter-spacing:-.025em;margin:0 0 13px}
.phone-access-header>p{font-size:13px;line-height:1.65;color:var(--muted);margin:0;max-width:48ch}
.phone-access-account{margin-top:22px;border-radius:20px;padding:15px;display:flex;flex-direction:column;gap:13px}
#phoneCloudStatus{display:flex;flex-direction:column;gap:3px;min-width:0}#phoneCloudStatus b{font-size:13px;font-weight:600;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}#phoneCloudStatus span{font-size:10px;color:var(--muted);line-height:1.45;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.phone-account-actions{display:grid;grid-template-columns:minmax(0,1fr) auto;gap:8px}.phone-account-actions button{min-height:42px}
.phone-limited-note{border-top:1px solid var(--line);border-bottom:1px solid var(--line);padding:15px 2px;display:flex;flex-direction:column;gap:4px}.phone-limited-note b{font-size:11px}.phone-limited-note span{font-size:10px;color:var(--muted);line-height:1.5}
.phone-library{display:grid;gap:13px}.phone-book-card{border-radius:22px;padding:18px;min-width:0}.phone-book-head{display:grid;grid-template-columns:minmax(0,1fr) auto;gap:14px;align-items:start}.phone-book-head>div{min-width:0}.phone-book-head small{display:block;font-size:8px;letter-spacing:.09em;color:var(--accent);text-transform:uppercase;margin-bottom:6px}.phone-book-head h2{font-family:var(--ui-serif,Georgia,serif);font-size:23px;font-weight:500;line-height:1.12;margin:0;overflow-wrap:anywhere}.phone-book-head>span{font-size:16px;font-weight:600;text-align:right}.phone-book-head>span small{font-size:7px;color:var(--muted);margin:3px 0 0;letter-spacing:.08em}
.phone-book-meta{display:grid;grid-template-columns:auto auto minmax(0,1fr);gap:10px 16px;margin-top:17px;padding-top:14px;border-top:1px solid var(--line);align-items:center}.phone-book-meta span{font-size:9px;color:var(--muted);min-width:0}.phone-book-meta span b{font-size:12px;color:var(--text);margin-right:4px}.phone-book-meta span:last-child{text-align:right;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.phone-book-exports{display:grid;grid-template-columns:.72fr .9fr 1.35fr;gap:8px;margin-top:15px}.phone-book-exports button{min-height:43px;font-size:11px}.phone-empty{border-radius:22px;padding:28px 20px;text-align:center}.phone-empty h2{font-size:20px;margin:0 0 7px}.phone-empty p{font-size:11px;line-height:1.55;color:var(--muted);margin:0}.phone-access-footer{text-align:center;padding:8px 0 2px;font-size:8px;letter-spacing:.12em;color:var(--muted)}
html.phone-only.workspace-entered .toast-container{display:flex!important;right:12px;left:12px;bottom:max(12px,env(safe-area-inset-bottom));width:auto}.phone-only .toast{width:100%;max-width:none}

/* Menu tablet: stessa posizione sia aperto sia chiuso. Il rail si dispone sotto il pulsante. */
@media (max-width:900px), (pointer:coarse) and (min-width:561px) and (max-width:1366px){
  
  
  #rail{padding-top:58px!important;overflow-y:auto!important;overflow-x:hidden!important;scrollbar-width:none}
  #rail::-webkit-scrollbar{display:none}
  #rail .brand{flex:0 0 auto}
  #rail .rail-nav,#rail .rail-bottom{flex-shrink:0}
  .topbar-left{padding-left:48px!important}
}



/* MM-Writer 1.99 — data safety/export consolidation: no visual changes. */

/* MM-Writer 1.99 — tablet topbar visibility fix only. */
@media (max-width:900px), (pointer:coarse) and (min-width:561px) and (max-width:1366px){
  .topbar{
    grid-template-columns:minmax(0,1fr) auto auto;
    z-index:90;
  }
  .topbar-left{min-width:0}
  .topbar-left>div{min-width:0}
  .book-title-top{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
  .topbar-center{
    display:flex!important;
    justify-self:center;
    padding:3px;
    border-radius:12px;
    flex:0 0 auto;
  }
  .topbar-center .scope-btn{
    padding:6px 7px;
    font-size:10px;
    white-space:nowrap;
  }
  .topbar-actions{min-width:0}
}

@media (pointer:coarse) and (min-width:561px) and (max-width:700px){
  .topbar-center .scope-btn{padding:5px 6px;font-size:9px}
}

/* MM-Writer 2.00 — interventi circoscritti: stato libro, lettura, Codex navigabile e tablet. */
.book-status-center{
  margin:0 0 28px;padding:22px 24px;border-radius:25px;
  display:grid;grid-template-columns:minmax(220px,1.15fr) minmax(360px,1.85fr) auto;
  grid-template-areas:"copy metrics actions" "progress progress actions";
  gap:16px 24px;align-items:center;
}
.book-status-center[hidden]{display:none!important}
.book-status-copy{grid-area:copy;min-width:0}.book-status-copy>small{display:block;font-size:8px;font-weight:700;letter-spacing:.13em;color:var(--accent)}
.book-status-copy h2{font-family:var(--ui-serif,Georgia,serif);font-size:25px;font-weight:520;letter-spacing:-.025em;margin:5px 0 6px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.book-status-copy p{margin:0;color:var(--muted);font-size:10px;line-height:1.45;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.book-status-copy p b{color:var(--text);font-weight:600}
.book-status-metrics{grid-area:metrics;display:grid;grid-template-columns:repeat(4,minmax(88px,1fr));gap:8px}
.book-status-metrics>div{min-width:0;padding:10px 12px;border:1px solid var(--line);border-radius:13px;background:color-mix(in srgb,var(--surface-2) 76%,transparent)}
.book-status-metrics span{display:block;color:var(--muted);font-size:7px;text-transform:uppercase;letter-spacing:.08em;margin-bottom:4px}.book-status-metrics b{display:block;font-size:13px;font-weight:620;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.book-status-progress{grid-area:progress;height:5px;border-radius:999px;background:var(--line);overflow:hidden}.book-status-progress i{display:block;height:100%;border-radius:inherit;background:var(--accent)}
.book-status-actions{grid-area:actions;align-self:stretch;display:flex;flex-direction:column;justify-content:center;align-items:flex-end;gap:10px;min-width:154px}.book-status-actions>span{display:flex;align-items:center;gap:6px;color:var(--muted);font-size:8px;white-space:nowrap}.book-status-actions>span i{width:7px;height:7px;border-radius:50%;background:var(--accent)}.book-status-actions .primary-btn{white-space:nowrap}

/* I riferimenti Codex nel manoscritto sono veri collegamenti, senza cambiare il testo salvato. */
.scene-editor .codex-mark{cursor:pointer;transition:box-shadow .16s ease,background .16s ease}
.scene-editor .codex-mark:hover{background:color-mix(in srgb,var(--codex-color) 27%,transparent);box-shadow:inset 0 -2px 0 var(--codex-color),0 0 0 2px color-mix(in srgb,var(--codex-color) 10%,transparent)}

/* Lettura: pagina editoriale dedicata, sempre coerente con le variabili del tema attivo. */
.reader-bar{opacity:.9;box-shadow:0 10px 34px color-mix(in srgb,var(--bg) 34%,transparent)}
.reader-document{background:var(--paper,var(--surface-strong));border:1px solid var(--line);border-radius:18px;box-shadow:0 24px 62px color-mix(in srgb,var(--bg) 58%,transparent);overflow:hidden}
.reader-editor{cursor:text;user-select:text;-webkit-user-select:text}
.reader-notes-toggle{position:relative}.reader-notes-toggle>span{position:absolute;right:2px;top:1px;min-width:14px;height:14px;padding:0 3px;border-radius:999px;display:grid;place-items:center;background:var(--accent);color:var(--bg);font:700 7px/1 Inter,sans-serif;border:2px solid var(--surface-strong)}
.reader-notes-panel{position:absolute;z-index:86;right:max(14px,env(safe-area-inset-right));top:max(74px,calc(env(safe-area-inset-top) + 68px));bottom:max(14px,env(safe-area-inset-bottom));width:min(360px,calc(100vw - 28px));padding:16px;border-radius:22px;display:flex;flex-direction:column;transform:translateX(calc(100% + 28px));opacity:0;pointer-events:none;transition:transform .24s ease,opacity .2s ease;box-shadow:0 24px 70px color-mix(in srgb,var(--bg) 62%,transparent)}
.reader-notes-panel.open{transform:none;opacity:1;pointer-events:auto}.reader-notes-head{display:flex;align-items:center;justify-content:space-between;gap:12px;padding:2px 2px 13px;border-bottom:1px solid var(--line)}.reader-notes-head small{display:block;font:700 7px Inter,sans-serif;letter-spacing:.13em;color:var(--accent)}.reader-notes-head h2{font-size:18px;font-weight:520;margin:4px 0 0}.reader-notes-head .reader-icon-btn{font-size:20px}
.reader-notes-list{flex:1;min-height:0;overflow:auto;padding:10px 1px 2px;display:flex;flex-direction:column;gap:7px}.reader-note-item{width:100%;display:grid;grid-template-columns:7px minmax(0,1fr);gap:10px;text-align:left;padding:11px;border:1px solid var(--line);border-radius:14px;background:var(--surface-2);color:var(--text)}.reader-note-item:hover{background:var(--accent-soft)}.reader-note-item>i{width:7px;height:100%;min-height:46px;border-radius:99px;background:var(--reader-note-color)}.reader-note-item>span{min-width:0}.reader-note-item small,.reader-note-item b,.reader-note-item em{display:block}.reader-note-item small{font-size:7px;color:var(--muted);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.reader-note-item b{font-size:11px;margin:4px 0}.reader-note-item em{font-size:9px;line-height:1.45;color:var(--muted);font-style:normal;display:-webkit-box;-webkit-line-clamp:3;-webkit-box-orient:vertical;overflow:hidden}.reader-notes-empty{padding:24px 14px;text-align:center;color:var(--muted)}.reader-notes-empty b{display:block;color:var(--text);font-size:11px;margin-bottom:6px}.reader-notes-empty span{font-size:9px;line-height:1.5}

/* Gerarchia luoghi: usa l'intera larghezza del Codex e lascia scorrere la pagina, non un riquadro compresso. */
.codex-world-overview{margin-left:0!important;width:100%;padding:17px 18px}
.location-tree{grid-template-columns:repeat(auto-fit,minmax(245px,1fr));max-height:none!important;overflow:visible!important;gap:7px 16px}

/* Tablet: ricerca sempre raggiungibile, lettura touch e gerarchia non compressa. */
@media (pointer:coarse) and (min-width:561px) and (max-width:1366px){
  .topbar-actions .global-search-trigger{display:inline-flex!important;width:34px;min-width:34px;height:34px;padding:0!important;justify-content:center}
  .topbar-actions .global-search-trigger>span{display:none!important}.topbar-actions .global-search-trigger svg{margin:0!important}
  .reader-bar{opacity:1;max-width:calc(100vw - 22px)}
  .reader-notes-panel{width:min(350px,calc(100vw - 24px));right:12px;top:max(68px,calc(env(safe-area-inset-top) + 62px));bottom:12px}
  .location-tree{grid-template-columns:repeat(2,minmax(0,1fr));gap:7px 12px}
  .codex-world-overview{padding:16px}
}
@media(max-width:1000px){.codex-world-overview{margin-left:0!important}}
@media(max-width:760px){.location-tree{grid-template-columns:1fr}.book-status-center{grid-template-columns:1fr;grid-template-areas:"copy" "metrics" "progress" "actions"}.book-status-actions{align-items:stretch}.book-status-actions>span{justify-content:flex-start}}
@media(max-width:1180px){.book-status-center{grid-template-columns:minmax(210px,.9fr) minmax(320px,1.4fr);grid-template-areas:"copy metrics" "progress progress" "actions actions"}.book-status-actions{flex-direction:row;align-items:center;justify-content:space-between;min-width:0}}
@media(max-width:900px){.book-status-center{padding:18px;margin-bottom:22px}.book-status-metrics{grid-template-columns:repeat(2,minmax(0,1fr))}.reader-document{border-radius:14px}.reader-notes-panel{border-radius:18px}}
@media(max-width:760px){
  .book-status-center{grid-template-columns:1fr;grid-template-areas:"copy" "metrics" "progress" "actions"}
  .book-status-actions{flex-direction:column;align-items:stretch}.book-status-actions>span{justify-content:flex-start}
  .location-tree{grid-template-columns:1fr}
}

/* ==========================================================================
   MM-Writer 2.0 — Informazioni, privacy, contatti e supporto.
   Pagina autonoma: nessuna modifica ai layout di scrittura/moduli esistenti.
   ========================================================================== */
.entry-legal-link{border:0;background:transparent;color:inherit;padding:0;font:inherit;letter-spacing:inherit;text-transform:inherit;text-decoration:underline;text-decoration-color:transparent;text-underline-offset:3px}
.entry-legal-link:hover{color:#a29b91;text-decoration-color:currentColor}
.phone-access-footer{display:flex;align-items:center;justify-content:center;gap:10px;flex-wrap:wrap}
.phone-access-footer button{border:0;background:transparent;color:var(--accent);padding:4px 0;font:inherit;letter-spacing:.08em;text-transform:uppercase}
.phone-access-footer button:hover{text-decoration:underline;text-underline-offset:3px}

.legal-page{position:fixed;inset:0;z-index:1400;display:block;overflow:auto;overscroll-behavior:contain;background:linear-gradient(145deg,var(--bg),var(--bg2));opacity:0;visibility:hidden;pointer-events:none;transition:opacity .22s ease,visibility 0s linear .22s;-webkit-overflow-scrolling:touch}
.legal-page.open{opacity:1;visibility:visible;pointer-events:auto;transition:opacity .22s ease}
.legal-page-shell{min-height:100%;position:relative}
.legal-page-topbar{position:sticky;top:0;z-index:6;min-height:66px;padding:max(12px,env(safe-area-inset-top)) max(22px,env(safe-area-inset-right)) 10px max(22px,env(safe-area-inset-left));display:grid;grid-template-columns:1fr auto 1fr;align-items:center;border-bottom:1px solid color-mix(in srgb,var(--line) 86%,transparent);background:color-mix(in srgb,var(--bg) 86%,transparent);backdrop-filter:blur(22px);-webkit-backdrop-filter:blur(22px)}
.legal-back{justify-self:start;border:0;background:transparent;color:var(--muted);display:inline-flex;align-items:center;gap:7px;padding:8px 4px;border-radius:10px;font-size:10px}
.legal-back:hover{color:var(--text)}.legal-back svg{width:17px;height:17px;fill:none;stroke:currentColor;stroke-width:1.7;stroke-linecap:round;stroke-linejoin:round}
.legal-brand{display:flex;align-items:center;gap:8px}.legal-brand b{font-size:18px;letter-spacing:-.055em}.legal-brand span{font-size:8px;letter-spacing:.2em;color:var(--muted)}
.legal-version{justify-self:end;font-size:8px;letter-spacing:.1em;color:var(--muted);text-transform:uppercase}
.legal-main{width:min(1180px,calc(100% - 48px));margin:0 auto;padding:76px 0 max(100px,calc(env(safe-area-inset-bottom) + 72px))}
.legal-hero{display:grid;grid-template-columns:minmax(0,1.5fr) minmax(260px,.7fr);gap:54px;align-items:end;padding:26px 0 68px}
.legal-hero>div:first-child>small,.legal-section-kicker small{font-size:8px;font-weight:700;letter-spacing:.18em;color:var(--accent)}
.legal-hero h1{font-family:var(--ui-serif,Georgia,serif);font-size:clamp(42px,6.2vw,78px);font-weight:450;line-height:.98;letter-spacing:-.045em;margin:12px 0 24px}.legal-hero h1 em{font-weight:400;color:var(--accent);font-style:italic}
.legal-hero p{max-width:66ch;margin:0;color:var(--muted);font-size:13px;line-height:1.75}
.legal-hero-badges{display:flex;flex-direction:column;gap:10px;padding:20px;border:1px solid var(--line);border-radius:20px;background:color-mix(in srgb,var(--surface-2) 70%,transparent)}
.legal-hero-badges span{display:flex;align-items:center;gap:9px;font-size:10px}.legal-hero-badges i{width:7px;height:7px;border-radius:50%;background:var(--accent);box-shadow:0 0 0 5px var(--accent-soft)}
.legal-jump{display:grid;grid-template-columns:repeat(6,minmax(0,1fr));gap:8px;margin-bottom:56px}
.legal-jump button{min-width:0;min-height:104px;border:1px solid var(--line);border-radius:17px;background:color-mix(in srgb,var(--surface-2) 70%,transparent);color:var(--text);padding:13px;text-align:left;display:flex;flex-direction:column;align-items:flex-start;transition:.18s ease}
.legal-jump button:hover{transform:translateY(-2px);background:var(--surface);border-color:color-mix(in srgb,var(--accent) 28%,var(--line))}.legal-jump span{font-size:7px;color:var(--accent);letter-spacing:.08em}.legal-jump b{font-size:11px;margin-top:auto}.legal-jump small{font-size:8px;color:var(--muted);margin-top:3px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:100%}
.legal-section{scroll-margin-top:84px;padding:72px 0;border-top:1px solid var(--line)}
.legal-section-kicker{display:flex;align-items:center;gap:10px;margin-bottom:18px}.legal-section-kicker span{width:28px;height:28px;border:1px solid color-mix(in srgb,var(--accent) 26%,var(--line));border-radius:9px;display:grid;place-items:center;font-size:8px;color:var(--accent)}
.legal-section h2{font-family:var(--ui-serif,Georgia,serif);font-size:clamp(29px,4vw,48px);font-weight:470;line-height:1.04;letter-spacing:-.035em;margin:0 0 15px}.legal-section h3{font-size:13px;margin:0 0 8px}.legal-section p{font-size:11px;line-height:1.72;color:var(--muted)}.legal-section p b,.legal-section li b{color:var(--text);font-weight:620}.legal-lead{font-size:14px!important;line-height:1.68!important;color:var(--text)!important}
.legal-story-grid{display:grid;grid-template-columns:minmax(0,1.25fr) minmax(320px,.75fr);gap:50px;align-items:center}.legal-story-grid blockquote{margin:0;padding:30px 32px;border-left:2px solid var(--accent);background:color-mix(in srgb,var(--accent-soft) 64%,transparent);border-radius:0 20px 20px 0}.legal-story-grid blockquote p{margin:0;font-family:var(--ui-serif,Georgia,serif);font-size:20px;line-height:1.55;color:var(--text);font-style:italic}
.legal-copy-columns{display:grid;grid-template-columns:repeat(3,1fr);gap:26px;margin-top:40px}.legal-copy-columns p{margin:0}
.legal-ai-note,.legal-change-warning{margin-top:34px;padding:18px 20px;border:1px solid color-mix(in srgb,var(--accent) 22%,var(--line));border-radius:16px;background:color-mix(in srgb,var(--accent-soft) 42%,transparent);display:grid;grid-template-columns:150px 1fr;gap:18px;align-items:start}.legal-ai-note b,.legal-change-warning b{font-size:10px;letter-spacing:.08em;text-transform:uppercase}.legal-ai-note p,.legal-change-warning p{margin:0}
.legal-title-row{display:flex;justify-content:space-between;gap:28px;align-items:flex-start;margin-bottom:28px}.legal-title-row p{margin:0}.legal-law-badge{flex:0 0 auto;border:1px solid var(--line);border-radius:999px;padding:8px 11px;font-size:8px;color:var(--muted);letter-spacing:.08em}
.legal-privacy-summary{display:grid;grid-template-columns:repeat(3,1fr);gap:10px;margin-bottom:12px}.legal-privacy-summary article{padding:18px;border-radius:17px;background:var(--surface);border:1px solid var(--line)}.legal-privacy-summary small{display:block;font-size:7px;color:var(--accent);letter-spacing:.12em;margin-bottom:7px}.legal-privacy-summary b{display:block;font-size:16px}.legal-privacy-summary p{margin:6px 0 0;font-size:9px}
.legal-policy-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:10px}.legal-policy-card{padding:20px;border:1px solid var(--line);border-radius:18px;background:color-mix(in srgb,var(--surface-2) 67%,transparent)}.legal-policy-card.span-2{grid-column:1/-1}.legal-policy-card p{margin:0}.legal-policy-card ul{margin:8px 0 0;padding-left:18px;display:grid;gap:7px;color:var(--muted);font-size:10px;line-height:1.55}.legal-email-text{color:var(--text);font-weight:600;white-space:nowrap}
.legal-thirdparty-links{display:flex;flex-wrap:wrap;gap:7px;margin-top:14px}.legal-thirdparty-links a{border:1px solid var(--line);border-radius:999px;padding:8px 10px;text-decoration:none;color:var(--muted);font-size:8px}.legal-thirdparty-links a:hover{color:var(--text);background:var(--accent-soft)}
.legal-cookie-layout{display:grid;grid-template-columns:minmax(0,1.45fr) minmax(300px,.55fr);gap:44px;align-items:start}.legal-cookie-layout>div:first-child>p{max-width:74ch}.legal-cookie-status{border:1px solid var(--line);border-radius:20px;padding:18px;background:var(--surface)}.legal-cookie-status>small{font-size:7px;letter-spacing:.13em;color:var(--accent);display:block;margin-bottom:12px}.legal-cookie-status>div{display:flex;align-items:center;justify-content:space-between;gap:14px;padding:10px 0;border-top:1px solid var(--line);font-size:9px;color:var(--muted)}.legal-cookie-status b{font-size:8px;color:var(--text)}
.legal-terms-list{display:grid;grid-template-columns:repeat(2,1fr);gap:10px}.legal-terms-list article{display:grid;grid-template-columns:38px 1fr;gap:13px;padding:19px;border:1px solid var(--line);border-radius:18px;background:color-mix(in srgb,var(--surface-2) 65%,transparent)}.legal-terms-list article>span{width:30px;height:30px;border-radius:9px;background:var(--accent-soft);display:grid;place-items:center;font-size:8px;color:var(--accent)}.legal-terms-list h3{margin-top:4px}.legal-terms-list p{margin:0}
.legal-support-card{display:grid;grid-template-columns:minmax(0,1.25fr) minmax(310px,.75fr);gap:40px;padding:32px;border-radius:26px;background:linear-gradient(135deg,color-mix(in srgb,var(--surface) 95%,var(--accent) 5%),var(--surface-2));border:1px solid color-mix(in srgb,var(--accent) 22%,var(--line))}.legal-support-copy>small{font-size:8px;color:var(--accent);letter-spacing:.15em}.legal-support-copy h2{margin-top:9px}.legal-support-legal{margin-top:20px;padding:13px 15px;border-radius:13px;background:color-mix(in srgb,var(--bg) 28%,transparent);display:grid;gap:4px}.legal-support-legal b{font-size:9px}.legal-support-legal span{font-size:9px;line-height:1.55;color:var(--muted)}
.legal-paypal-box{align-self:stretch;border:1px solid var(--line);border-radius:20px;padding:22px;background:color-mix(in srgb,var(--surface-strong) 76%,transparent);display:flex;flex-direction:column;justify-content:center}.legal-paypal-wordmark{font:bold 28px/1 Arial,sans-serif;letter-spacing:-.07em;margin-bottom:22px}.legal-paypal-wordmark span{opacity:.62}.legal-paypal-btn{min-height:46px;border:0;border-radius:13px;background:var(--accent);color:var(--bg);font-size:11px;font-weight:700;padding:0 15px}.legal-paypal-btn:disabled{cursor:not-allowed;opacity:.45}.legal-paypal-box small{margin-top:10px;color:var(--muted);font-size:8px;line-height:1.5}
.legal-contact-grid{display:grid;grid-template-columns:minmax(0,.75fr) minmax(420px,1.25fr);gap:48px;align-items:start}.legal-contact-grid>div>p{max-width:52ch}.legal-contact-address{margin-top:24px;padding:16px;border:1px solid var(--line);border-radius:15px;display:grid;grid-template-columns:1fr auto;gap:5px 12px;align-items:center}.legal-contact-address small{grid-column:1/-1;font-size:7px;color:var(--accent);letter-spacing:.12em}.legal-contact-address b{font-size:12px;overflow-wrap:anywhere}.legal-contact-address button{border:1px solid var(--line);border-radius:9px;background:var(--surface-2);padding:7px 9px;font-size:8px;color:var(--muted)}.legal-contact-privacy{margin-top:12px;padding:14px 15px;border-radius:14px;background:var(--accent-soft)}.legal-contact-privacy b{font-size:9px}.legal-contact-privacy p{margin:5px 0 0;font-size:9px}
.legal-contact-form{border:1px solid var(--line);border-radius:22px;padding:22px;background:var(--surface);display:grid;grid-template-columns:1fr 1fr;gap:14px}.legal-form-row{display:grid;gap:6px;min-width:0}.legal-form-row:nth-of-type(3),.legal-form-row:nth-of-type(4),.legal-form-row.legal-human{grid-column:1/-1}.legal-form-row label{font-size:8px;font-weight:700;letter-spacing:.08em;text-transform:uppercase;color:var(--muted)}.legal-form-row label small{font-weight:400;letter-spacing:0;text-transform:none}.legal-form-row input,.legal-form-row select,.legal-form-row textarea{width:100%;border:1px solid var(--line);border-radius:11px;background:var(--surface-2);padding:10px 11px;outline:none}.legal-form-row textarea{min-height:150px;resize:vertical}.legal-form-row input:focus,.legal-form-row select:focus,.legal-form-row textarea:focus{border-color:color-mix(in srgb,var(--accent) 45%,var(--line))}.legal-human{grid-template-columns:minmax(0,1fr) 90px;align-items:center}.legal-human label{grid-column:1}.legal-human input{grid-column:2;grid-row:1}.legal-human small{grid-column:1/-1;color:var(--muted);font-size:8px}.legal-form-honeypot{position:absolute!important;left:-9999px!important;width:1px!important;height:1px!important;overflow:hidden!important}.legal-form-error{grid-column:1/-1;margin:0!important;padding:10px 12px;border-radius:10px;background:var(--danger-soft);color:var(--danger)!important;font-size:9px!important}.legal-send{grid-column:1/-1;min-height:45px}.legal-send span{margin-left:5px}.legal-form-foot{grid-column:1/-1;color:var(--muted);font-size:8px;line-height:1.5;text-align:center}
.legal-footer{display:flex;align-items:center;justify-content:space-between;gap:20px;padding:42px 0 8px;border-top:1px solid var(--line)}.legal-footer>div{display:flex;flex-direction:column;gap:4px}.legal-footer b{font-size:10px}.legal-footer span{font-size:8px;color:var(--muted)}.legal-footer button{border:0;background:transparent;color:var(--muted);font-size:9px}.legal-footer button:hover{color:var(--text)}
.legal-contact-fab{position:fixed;right:max(20px,calc(env(safe-area-inset-right) + 12px));bottom:max(20px,calc(env(safe-area-inset-bottom) + 12px));z-index:9;width:48px;height:48px;border:1px solid color-mix(in srgb,var(--accent) 26%,var(--line));border-radius:16px;background:var(--surface-strong);box-shadow:var(--shadow);color:var(--accent);display:grid;place-items:center;transition:.18s ease}.legal-contact-fab:hover{transform:translateY(-2px);background:color-mix(in srgb,var(--surface-strong) 88%,var(--accent) 12%)}.legal-contact-fab svg{width:20px;height:20px;fill:none;stroke:currentColor;stroke-width:1.6;stroke-linecap:round;stroke-linejoin:round}
html.legal-page-open body{overflow:hidden!important}

@media(max-width:1000px){
  .legal-main{width:min(100% - 34px,900px);padding-top:54px}.legal-hero{grid-template-columns:1fr;gap:24px}.legal-hero-badges{display:grid;grid-template-columns:repeat(3,1fr)}.legal-jump{grid-template-columns:repeat(3,1fr)}
  .legal-story-grid,.legal-cookie-layout,.legal-support-card,.legal-contact-grid{grid-template-columns:1fr}.legal-story-grid blockquote{max-width:620px}.legal-copy-columns{grid-template-columns:1fr 1fr}.legal-support-card{gap:24px}.legal-paypal-box{min-height:210px}.legal-contact-grid{gap:24px}
}

@media (pointer:coarse) and (min-width:561px) and (max-width:1366px){
  .legal-page-topbar{min-height:72px}.legal-main{width:min(100% - 42px,1040px);padding-top:56px}.legal-jump button{min-height:96px}.legal-section{scroll-margin-top:90px;padding-top:62px;padding-bottom:62px}.legal-policy-card{padding:18px}.legal-contact-form input,.legal-contact-form select{min-height:44px}.legal-contact-form textarea{min-height:180px}.legal-contact-fab{width:52px;height:52px;border-radius:17px}
}

@media(max-width:700px){
  .entry-footer{gap:8px;flex-wrap:wrap}.entry-footer .entry-legal-link{order:3;width:100%;text-align:left}
  .legal-page-topbar{grid-template-columns:1fr auto;padding-left:max(14px,env(safe-area-inset-left));padding-right:max(14px,env(safe-area-inset-right))}.legal-brand{display:none}.legal-version{font-size:7px}.legal-back span{display:none}
  .legal-main{width:calc(100% - 28px);padding-top:34px;padding-bottom:max(94px,calc(env(safe-area-inset-bottom) + 80px))}.legal-hero{padding:18px 0 42px}.legal-hero h1{font-size:clamp(34px,11vw,50px);margin-bottom:17px}.legal-hero p{font-size:11px}.legal-hero-badges{grid-template-columns:1fr;padding:15px}.legal-jump{grid-template-columns:1fr 1fr;gap:7px;margin-bottom:40px}.legal-jump button{min-height:86px}.legal-section{scroll-margin-top:75px;padding:48px 0}.legal-section h2{font-size:31px}.legal-section p{font-size:10px}.legal-lead{font-size:12px!important}.legal-story-grid{gap:22px}.legal-story-grid blockquote{padding:22px}.legal-story-grid blockquote p{font-size:16px}.legal-copy-columns{grid-template-columns:1fr;gap:10px;margin-top:24px}.legal-ai-note,.legal-change-warning{grid-template-columns:1fr;gap:6px;margin-top:24px}.legal-title-row{display:block}.legal-law-badge{display:inline-flex;margin-top:12px}.legal-privacy-summary{grid-template-columns:1fr}.legal-policy-grid{grid-template-columns:1fr}.legal-policy-card.span-2{grid-column:auto}.legal-thirdparty-links{display:grid;grid-template-columns:1fr 1fr}.legal-thirdparty-links a{text-align:center}.legal-terms-list{grid-template-columns:1fr}.legal-support-card{padding:20px;border-radius:20px}.legal-contact-grid{gap:18px}.legal-contact-form{grid-template-columns:1fr;padding:17px}.legal-contact-form .legal-form-row,.legal-form-row:nth-of-type(3),.legal-form-row:nth-of-type(4),.legal-form-row.legal-human{grid-column:1}.legal-human{grid-template-columns:minmax(0,1fr) 76px}.legal-contact-address{grid-template-columns:1fr}.legal-contact-address button{justify-self:start}.legal-footer{align-items:flex-start;flex-direction:column}.legal-contact-fab{right:max(14px,calc(env(safe-area-inset-right) + 8px));bottom:max(14px,calc(env(safe-area-inset-bottom) + 8px));width:46px;height:46px;border-radius:15px}
}

/* MM-Writer 2.0 — Revisione comparata. Isolata dal Writer normale. */
.document-meta-actions{display:flex;align-items:center;gap:10px;min-width:0}.revision-draft-trigger{height:28px;display:inline-flex;align-items:center;gap:6px;border:1px solid var(--line);border-radius:10px;background:color-mix(in srgb,var(--surface-2) 76%,transparent);color:var(--muted);padding:0 9px;font:650 8px Inter,sans-serif;white-space:nowrap}.revision-draft-trigger:hover,.revision-draft-trigger.has-draft{color:var(--text);border-color:color-mix(in srgb,var(--accent) 32%,var(--line));background:var(--accent-soft)}.revision-draft-trigger svg{width:14px;height:14px;fill:none;stroke:currentColor;stroke-width:1.5}.revision-draft-trigger i{min-width:16px;height:16px;padding:0 4px;border-radius:999px;background:var(--accent);color:var(--bg);display:grid;place-items:center;font-size:7px;font-style:normal}
.review-start-modal>small{display:block;font:650 8px Inter,sans-serif;letter-spacing:.15em;color:var(--accent);margin-bottom:7px}.review-start-modal>h2{margin:0 0 8px}.review-start-modal>p{max-width:68ch;margin:0 0 20px;color:var(--muted)}.review-start-grid{display:grid;grid-template-columns:1fr 1fr;gap:10px}.review-start-card{min-height:112px;text-align:left;border:1px solid var(--line);border-radius:16px;background:var(--surface-2);color:var(--text);padding:16px;display:flex;flex-direction:column;align-items:flex-start}.review-start-card:hover{border-color:color-mix(in srgb,var(--accent) 36%,var(--line));background:var(--accent-soft)}.review-start-card>span{font:650 7px Inter,sans-serif;letter-spacing:.14em;color:var(--accent)}.review-start-card>b{font-size:14px;font-weight:550;margin:9px 0 6px}.review-start-card>small{font-size:8px;color:var(--muted)}.review-pending-head{display:flex;align-items:center;justify-content:space-between;margin:22px 0 8px}.review-pending-head b{font-size:9px}.review-pending-head span{font-size:8px;color:var(--muted)}.review-pending-list{display:grid;gap:6px;max-height:210px;overflow:auto}.review-pending-list>button{display:flex;align-items:center;justify-content:space-between;gap:12px;text-align:left;border:1px solid var(--line);border-radius:12px;background:transparent;color:var(--text);padding:10px 12px}.review-pending-list>button:hover{background:var(--surface-2)}.review-pending-list span small,.review-pending-list span b{display:block}.review-pending-list span small{font:650 6px Inter,sans-serif;letter-spacing:.11em;color:var(--accent);margin-bottom:3px}.review-pending-list span b{font-size:9px}.review-pending-list em{font:500 7px Inter,sans-serif;font-style:normal;color:var(--muted)}.review-pending-empty{border:1px dashed var(--line);border-radius:12px;padding:15px;color:var(--muted);font-size:8px}
#writerView.review-mode .structure-panel,#writerView.review-mode .edge-handle,#writerView.review-mode .bookmark-panel{display:none!important}#writerView.review-mode .editor-stage{width:100%}.editor-viewport.review-active{padding:10px 14px 16px;overflow:hidden}.multi-scene-editor.review-host{width:100%!important;max-width:none!important;height:100%;margin:0;gap:0}.review-workspace{height:100%;min-height:0;width:100%;display:flex;flex-direction:column;border:1px solid var(--line);border-radius:19px;background:color-mix(in srgb,var(--surface) 76%,transparent);overflow:hidden;box-shadow:0 18px 50px rgba(0,0,0,.08)}.review-workspace-head{display:flex;align-items:center;justify-content:space-between;gap:18px;padding:14px 16px;border-bottom:1px solid var(--line);background:color-mix(in srgb,var(--surface-strong) 82%,transparent)}.review-workspace-head>div:first-child{min-width:0}.review-workspace-head small{font:650 7px Inter,sans-serif;letter-spacing:.15em;color:var(--accent)}.review-workspace-head h2{margin:3px 0 4px;font-size:16px;font-weight:550;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.review-live-summary{display:flex;align-items:center;gap:9px;flex-wrap:wrap;font:550 7px Inter,sans-serif;color:var(--muted)}.review-live-summary span{white-space:nowrap}.review-workspace-actions{display:flex;align-items:center;gap:7px;flex:0 0 auto}.review-workspace-actions button{min-height:34px}.review-column-labels{display:grid;grid-template-columns:1fr 1fr;border-bottom:1px solid var(--line);background:var(--surface-2)}.review-column-labels>div{display:flex;align-items:center;justify-content:space-between;padding:8px 13px}.review-column-labels>div:first-child{border-right:1px solid var(--line)}.review-column-labels span{font:700 7px Inter,sans-serif;letter-spacing:.14em;color:var(--muted)}.review-column-labels small{font-size:7px;color:var(--muted);opacity:.7}.review-panes{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1fr);min-height:0;flex:1}.review-pane{min-width:0;min-height:0;overflow:auto;padding:13px;background:color-mix(in srgb,var(--bg) 54%,transparent);overscroll-behavior:contain}.review-original-pane{border-right:1px solid var(--line);background:color-mix(in srgb,var(--surface-2) 64%,transparent)}.review-original-sheet,.review-edit-sheet{background:var(--paper,var(--surface-strong));border:1px solid color-mix(in srgb,var(--line) 85%,transparent);border-radius:14px;margin:0 auto 12px;max-width:780px;box-shadow:0 8px 24px rgba(0,0,0,.06);overflow:hidden}.review-scene-head{height:36px;display:flex;align-items:center;justify-content:space-between;gap:10px;padding:0 13px;border-bottom:1px solid var(--line);background:color-mix(in srgb,var(--surface-2) 66%,transparent)}.review-scene-head>span{font:650 8px Inter,sans-serif;color:var(--muted);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.review-scene-head>small{font:550 7px Inter,sans-serif;color:var(--muted);white-space:nowrap}.review-scene-head>small.changed{color:var(--text)}.review-scene-head>small.changed span+span{margin-left:5px}.review-original-copy,.review-scene-editor{min-height:360px;padding:38px clamp(24px,4.2vw,54px) 54px;font-family:var(--editor-font);font-size:var(--editor-size,17px);line-height:var(--editor-line-height,1.82);color:var(--text);outline:none}.review-original-copy{user-select:text;color:color-mix(in srgb,var(--text) 84%,var(--muted));cursor:text}.review-original-copy p,.review-scene-editor p{margin:0 0 var(--editor-paragraph-spacing,.9em);text-indent:var(--editor-indent,0)}.review-original-copy h1,.review-original-copy h2,.review-original-copy h3,.review-scene-editor h1,.review-scene-editor h2,.review-scene-editor h3{line-height:1.25}.review-scene-editor:focus{box-shadow:inset 3px 0 0 color-mix(in srgb,var(--accent) 56%,transparent)}.review-edit-sheet:has(.review-scene-editor:focus){border-color:color-mix(in srgb,var(--accent) 32%,var(--line))}.review-original-copy .codex-mark,.review-scene-editor .codex-mark{cursor:pointer}

@media (max-width:1180px){.review-workspace-head{align-items:flex-start;flex-direction:column}.review-workspace-actions{width:100%;justify-content:flex-end}.review-original-copy,.review-scene-editor{padding-left:clamp(20px,3vw,36px);padding-right:clamp(20px,3vw,36px)}}
@media (pointer:coarse) and (min-width:561px) and (max-width:1366px){.editor-viewport.review-active{padding:8px 10px 12px}.review-workspace{border-radius:16px}.review-workspace-head{padding:11px 12px;gap:10px}.review-workspace-actions{display:grid;grid-template-columns:1fr auto auto;gap:6px}.review-workspace-actions button{min-height:40px}.review-column-labels>div{padding:8px 10px}.review-pane{padding:9px}.review-original-sheet,.review-edit-sheet{border-radius:12px;margin-bottom:9px}.review-original-copy,.review-scene-editor{min-height:300px;padding:28px clamp(16px,2.8vw,30px) 40px;font-size:clamp(13px,1.65vw,var(--editor-size,17px));line-height:max(1.62,var(--editor-line-height,1.82))}.revision-draft-trigger{height:30px;min-width:30px}.revision-draft-trigger span{display:none}.document-meta-actions{gap:7px}}
@media (max-width:760px){.review-start-grid{grid-template-columns:1fr}.review-column-labels{display:none}.review-panes{grid-template-columns:1fr;overflow:auto}.review-pane{overflow:visible}.review-original-pane{border-right:0;border-bottom:1px solid var(--line)}.review-workspace{overflow:auto}.review-workspace-actions{grid-template-columns:1fr 1fr}.review-workspace-actions #reviewSaveLater{grid-column:1/-1}.review-original-copy,.review-scene-editor{min-height:260px}.revision-draft-trigger span{display:none}}
/* Revisione comparata — parità tipografica + segnali diff non distruttivi. */
.multi-scene-editor.review-host[data-align="justify"] .review-original-copy{text-align:justify;text-justify:inter-word}
.multi-scene-editor.review-host[data-align="left"] .review-original-copy{text-align:left}
.multi-scene-editor.review-host[data-chicago="true"] .review-original-copy p:first-child,
.multi-scene-editor.review-host[data-chicago="true"] .review-original-copy h1 + p,
.multi-scene-editor.review-host[data-chicago="true"] .review-original-copy h2 + p,
.multi-scene-editor.review-host[data-chicago="true"] .review-original-copy h3 + p{text-indent:0}
.review-original-copy .review-diff-removed,.review-original-copy .review-diff-modified,.review-scene-editor .review-diff-added,.review-scene-editor .review-diff-modified{position:relative;border-radius:4px;transition:background .16s ease,box-shadow .16s ease}
.review-original-copy .review-diff-removed{background:color-mix(in srgb,var(--danger-soft) 72%,transparent);box-shadow:inset 2px 0 0 color-mix(in srgb,var(--danger) 70%,transparent)}
.review-original-copy .review-diff-modified{background:color-mix(in srgb,var(--accent-soft) 65%,transparent);box-shadow:inset 2px 0 0 color-mix(in srgb,var(--accent) 62%,transparent)}
.review-scene-editor .review-diff-added{background:color-mix(in srgb,var(--accent-soft) 82%,transparent);box-shadow:inset 2px 0 0 color-mix(in srgb,var(--accent) 72%,transparent)}
.review-scene-editor .review-diff-modified{background:color-mix(in srgb,var(--accent-soft) 60%,transparent);box-shadow:inset 2px 0 0 color-mix(in srgb,var(--accent) 54%,transparent)}
.review-original-copy.review-diff-coarse,.review-scene-editor.review-diff-coarse{box-shadow:inset 3px 0 0 color-mix(in srgb,var(--accent) 58%,transparent)}

/* 2.0 RC — accessibilità e tastiera, senza cambiare il layout funzionale. */
a:focus-visible,summary:focus-visible,[tabindex]:focus-visible,.tree-row:focus-visible,.codex-card:focus-visible{outline:2px solid color-mix(in srgb,var(--accent) 64%,transparent);outline-offset:3px}
.tree-row:focus-visible,.codex-card:focus-visible{border-radius:12px}
.scene-sheet:focus-within{box-shadow:0 15px 55px rgba(0,0,0,.10),0 0 0 2px color-mix(in srgb,var(--accent) 24%,transparent)}
.review-edit-sheet:focus-within{box-shadow:0 8px 24px rgba(0,0,0,.06),0 0 0 2px color-mix(in srgb,var(--accent) 26%,transparent)}
.modal[role="dialog"]:focus{outline:none}
.shortcut-head>small{display:block;font:650 8px Inter,sans-serif;letter-spacing:.15em;color:var(--accent);margin-bottom:7px}.shortcut-head h2{margin:0 0 8px}.shortcut-head p{margin:0;color:var(--muted);max-width:68ch}.shortcut-list{display:grid;gap:7px;margin:20px 0}.shortcut-row{display:grid;grid-template-columns:minmax(116px,.32fr) 1fr;gap:14px;align-items:center;padding:11px 12px;border:1px solid var(--line);border-radius:12px;background:var(--surface-2)}.shortcut-row kbd,.global-search-empty kbd{font:650 9px/1.2 Inter,system-ui,sans-serif;white-space:nowrap;color:var(--text);background:var(--surface-strong);border:1px solid var(--line);border-bottom-width:2px;border-radius:7px;padding:6px 8px;justify-self:start}.shortcut-row span{font-size:10px;color:var(--muted);line-height:1.45}.shortcut-note{display:grid;gap:4px;padding:12px 14px;border-radius:12px;background:var(--accent-soft);border:1px solid color-mix(in srgb,var(--accent) 18%,var(--line))}.shortcut-note b{font-size:9px}.shortcut-note span{font-size:9px;color:var(--muted);line-height:1.5}.global-replace.review-locked{padding:15px 16px}.global-replace.review-locked b{font-size:10px}.global-replace.review-locked p{margin:6px 0 0}
@media (max-width:620px){.shortcut-row{grid-template-columns:1fr;gap:7px}}
@media (pointer:coarse) and (min-width:561px) and (max-width:1366px){
  .rail-btn,.icon-btn,.soft-btn,.primary-btn,.mini-btn,.session-trigger,.reader-icon-btn,.reader-note-btn,.revision-draft-trigger,.tree-row{min-height:42px}
  .tree-drag-handle,.tree-menu{min-width:38px;min-height:38px}
  .floating-toolbar button,.floating-toolbar select{min-height:38px}
  .highlight-dot{width:28px!important;min-width:28px!important;height:28px!important}
  .reader-highlights button{min-width:34px;min-height:34px}
  .review-workspace-actions button{min-height:42px}
}


/* Beta 0.830 — interventi circoscritti: allineamento gerarchie Writer + Codex read-only. */
.manuscript-separator{
  width:min(var(--manuscript-width,850px),calc(100% - 34px));
  padding-left:clamp(32px,7vw,82px);
  padding-right:clamp(32px,7vw,82px);
}
.writer-codex-preview[hidden]{display:none!important}
.writer-codex-preview{
  --writer-codex-color:var(--accent);
  position:absolute;
  z-index:46;
  right:14px;
  top:14px;
  bottom:14px;
  width:min(370px,calc(100% - 28px));
  display:flex;
  flex-direction:column;
  overflow:hidden;
  border:1px solid color-mix(in srgb,var(--writer-codex-color) 24%,var(--line));
  border-radius:20px;
  background:color-mix(in srgb,var(--surface-strong) 98%,var(--bg) 2%);
  box-shadow:0 20px 55px rgba(0,0,0,.18);
  animation:writerCodexIn .16s ease-out;
}
@keyframes writerCodexIn{from{opacity:0;transform:translateX(12px)}to{opacity:1;transform:none}}
.writer-codex-preview-head{display:flex;align-items:flex-start;justify-content:space-between;gap:14px;padding:18px 18px 14px;border-bottom:1px solid var(--line)}
.writer-codex-preview-head>div{min-width:0}
.writer-codex-preview-head small{display:block;font-size:10px;font-weight:750;letter-spacing:.14em;color:var(--writer-codex-color);margin-bottom:5px}
.writer-codex-preview-head h2{font-size:22px;line-height:1.18;margin:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.writer-codex-preview-head .icon-btn{flex:0 0 auto;width:38px;height:38px}
.writer-codex-preview-body{min-height:0;overflow:auto;padding:17px 18px 20px;overscroll-behavior:contain}
.writer-codex-identity{display:flex;align-items:center;gap:12px;margin-bottom:15px}
.writer-codex-symbol{width:42px;height:42px;display:grid;place-items:center;border-radius:13px;background:color-mix(in srgb,var(--writer-codex-color) 12%,var(--surface-2));color:var(--writer-codex-color);flex:0 0 auto}
.writer-codex-symbol svg{width:23px;height:23px;stroke:currentColor;fill:none}
.writer-codex-identity>div{min-width:0}.writer-codex-identity small{font-size:12px;color:var(--muted);font-weight:650}
.writer-codex-chips{display:flex;flex-wrap:wrap;gap:5px;margin-top:5px}.writer-codex-chips span{font-size:11px;padding:4px 7px;border-radius:999px;background:var(--surface-2);border:1px solid var(--line);color:var(--muted)}
.writer-codex-description{font-size:14px;line-height:1.65;margin:0 0 16px;white-space:pre-line}.writer-codex-description.muted{color:var(--muted)}
.writer-codex-parent{display:flex;justify-content:space-between;gap:12px;padding:10px 0;border-top:1px solid var(--line);border-bottom:1px solid var(--line);font-size:11px}.writer-codex-parent span{color:var(--muted)}.writer-codex-parent b{text-align:right}
.writer-codex-facts{display:grid;gap:0;margin-top:8px}.writer-codex-facts>div{display:grid;grid-template-columns:minmax(105px,.8fr) minmax(0,1.2fr);gap:12px;padding:10px 0;border-bottom:1px solid color-mix(in srgb,var(--line) 72%,transparent)}.writer-codex-facts span{font-size:11px;line-height:1.4;color:var(--muted)}.writer-codex-facts b{font-size:13px;line-height:1.5;font-weight:600;white-space:pre-line;overflow-wrap:anywhere}
.writer-codex-mini-section{margin-top:17px}.writer-codex-mini-section>small{display:block;font-size:10px;font-weight:750;letter-spacing:.12em;color:var(--muted);margin-bottom:7px}.writer-codex-mini-section>div{padding:8px 0;border-bottom:1px solid color-mix(in srgb,var(--line) 65%,transparent)}.writer-codex-mini-section>div span{font-size:11px;color:var(--muted)}.writer-codex-mini-section>div p,.writer-codex-mini-section.aliases p{font-size:12px;line-height:1.55;margin:3px 0 0;white-space:pre-line;overflow-wrap:anywhere}
.writer-codex-preview-meta{display:flex;justify-content:space-between;gap:8px;margin-top:18px;padding-top:11px;border-top:1px solid var(--line);font-size:10px;color:var(--muted)}
.writer-codex-preview-actions{padding:12px 18px calc(12px + env(safe-area-inset-bottom));border-top:1px solid var(--line);background:var(--surface-2)}
.writer-codex-preview-actions .soft-btn{width:100%;min-height:40px}
@media(max-width:1366px) and (pointer:coarse){
  .manuscript-separator{width:min(var(--manuscript-width,850px),calc(100vw - 38px));padding-left:clamp(26px,5.5vw,58px);padding-right:clamp(26px,5.5vw,58px)}
  .writer-codex-preview-head .icon-btn,.writer-codex-preview-actions .soft-btn{min-height:44px}
  .writer-codex-preview-body{padding:18px 20px 22px}
  .writer-codex-description{font-size:14px}.writer-codex-facts b{font-size:13px}.writer-codex-facts span{font-size:11px}
}
@media(max-width:900px){
  .manuscript-separator{width:min(var(--manuscript-width,850px),calc(100vw - 26px));padding-left:clamp(22px,5vw,44px);padding-right:clamp(22px,5vw,44px)}
  .writer-codex-preview{left:10px;right:10px;top:auto;bottom:max(10px,env(safe-area-inset-bottom));width:auto;max-height:min(54dvh,560px);border-radius:20px}
  .writer-codex-preview-head{padding:14px 16px 11px}.writer-codex-preview-head h2{font-size:20px}
  .writer-codex-preview-body{padding:14px 16px 17px}.writer-codex-facts{grid-template-columns:1fr 1fr;column-gap:18px}.writer-codex-facts>div{display:block}.writer-codex-facts b,.writer-codex-facts span{display:block}.writer-codex-facts b{margin-top:3px}
  .writer-codex-preview-actions{padding:10px 16px calc(10px + env(safe-area-inset-bottom))}
}
@media(max-width:620px){
  .writer-codex-preview{left:7px;right:7px;bottom:max(7px,env(safe-area-inset-bottom));max-height:62dvh;border-radius:17px}
  .writer-codex-facts{grid-template-columns:1fr}.writer-codex-preview-head h2{font-size:19px}.writer-codex-description{font-size:14px}
}

/* Beta 0.830 — Sylva branding + Codex read-only responsive width. */
.sylva-symbol-svg{display:block;width:100%;height:100%;overflow:visible}
.sylva-wordmark{
  font-family:"Allura",cursive;
  font-weight:400;
  line-height:.87;
  color:#2d2923;
  white-space:nowrap;
}

/* Splash leggero: compare ad ogni apertura/ricarica senza bloccare l'avvio reale. */
.app-splash{
  position:fixed;
  inset:0;
  z-index:2000;
  display:grid;
  place-items:center;
  background:
    radial-gradient(circle at 50% 42%,rgba(181,156,112,.10),transparent 33%),
    linear-gradient(145deg,#f3eee5 0%,#e9e1d4 100%);
  opacity:1;
  visibility:visible;
  transition:opacity .38s ease,visibility .38s ease;
}
.app-splash.is-leaving{opacity:0;visibility:hidden;pointer-events:none}
.sylva-splash-lockup{display:flex;flex-direction:column;align-items:center;text-align:center;transform:translateY(-2vh)}
.sylva-splash-symbol{width:clamp(184px,18vw,244px);aspect-ratio:202/170}
.sylva-wordmark-splash{font-size:clamp(88px,9vw,114px);margin-top:-18px}
.sylva-splash-lockup>small{margin-top:14px;font:600 9px/1 Inter,sans-serif;letter-spacing:.28em;color:#747660}

/* Login principale: simbolo ufficiale + wordmark Sylva. */
.writer-logo.sylva-login-lockup{
  display:inline-flex;
  align-items:center;
  gap:9px;
  width:max-content;
  height:auto;
  min-height:92px;
  margin:0 0 7px;
  padding:4px 20px 4px 6px;
  border:1px solid rgba(173,153,118,.22);
  border-radius:24px;
  background:rgba(243,238,229,.96);
  box-shadow:0 18px 50px rgba(0,0,0,.14);
  isolation:isolate;
}
.sylva-login-symbol{display:block;width:108px;height:91px;flex:0 0 auto}
.sylva-wordmark-login{font-size:86px;transform:translateY(4px)}

/* Logo compatto nella modalità smartphone. */
.phone-access-brand.sylva-phone-brand{display:inline-flex;align-items:center;gap:5px;width:max-content;margin-bottom:24px;padding:2px 12px 2px 3px;border-radius:16px;background:#f3eee5;border:1px solid rgba(173,153,118,.18)}
.phone-access-brand.sylva-phone-brand .sylva-phone-symbol{display:block;width:58px;height:49px;flex:0 0 auto}
.phone-access-brand.sylva-phone-brand .sylva-wordmark{font:400 43px/.87 "Allura",cursive;letter-spacing:0;color:#2d2923;transform:translateY(2px)}

/* Marchio compatto nella pagina informazioni/legale. */
.legal-brand.sylva-legal-brand{display:inline-flex;align-items:center;gap:2px;padding:1px 9px 1px 2px;border-radius:12px;background:#f3eee5;border:1px solid rgba(173,153,118,.16)}
.legal-brand.sylva-legal-brand .sylva-legal-symbol{display:block;width:38px;height:32px}
.legal-brand.sylva-legal-brand .sylva-wordmark{font:400 29px/.87 "Allura",cursive;letter-spacing:0;color:#2d2923;transform:translateY(1px)}

/* Il primo pulsante del rail usa il simbolo ufficiale, non più il libro. */
.brand.sylva-brand-button{
  display:grid;
  place-items:center;
  padding:2px;
  background:#f3eee5!important;
  border-color:rgba(173,153,118,.28)!important;
  color:#2d2923;
  overflow:hidden;
}
.brand.sylva-brand-button .sylva-symbol-svg{width:43px;height:37px;transition:transform .18s ease}
.brand.sylva-brand-button:hover .sylva-symbol-svg{transform:translateY(-1px) scale(1.035)}
.brand.sylva-brand-button:active .sylva-symbol-svg{transform:scale(.96)}

/* Dove c'è spazio, la scheda Codex in sola lettura diventa più ampia. */
@media(min-width:901px){
  .writer-codex-preview{width:clamp(420px,32vw,600px)}
  .writer-codex-preview-body{padding-left:20px;padding-right:20px}
  .writer-codex-facts{grid-template-columns:1fr 1fr;column-gap:22px}
  .writer-codex-facts>div{display:block}
  .writer-codex-facts b,.writer-codex-facts span{display:block}
  .writer-codex-facts b{margin-top:4px}
}
@media(min-width:1500px){
  .writer-codex-preview{width:min(610px,33vw)}
  .writer-codex-preview-head{padding:20px 22px 16px}
  .writer-codex-preview-body{padding:20px 22px 24px}
  .writer-codex-preview-actions{padding-left:22px;padding-right:22px}
}
@media(min-width:901px) and (max-width:1180px){
  .writer-codex-preview{width:min(440px,43vw)}
}
@media(min-width:901px) and (max-width:1366px) and (pointer:coarse){
  .writer-codex-preview{width:min(480px,47vw)}
}

@media(max-width:900px){
  .writer-logo.sylva-login-lockup{min-height:78px;padding-right:16px;border-radius:20px}
  .sylva-login-symbol{width:91px;height:77px}
  .sylva-wordmark-login{font-size:72px}
  .sylva-splash-symbol{width:clamp(164px,30vw,214px)}
  .sylva-wordmark-splash{font-size:clamp(78px,16vw,104px)}
}
@media(max-width:620px){
  .writer-logo.sylva-login-lockup{min-height:68px;padding:2px 13px 2px 3px;border-radius:17px}
  .sylva-login-symbol{width:78px;height:66px}
  .sylva-wordmark-login{font-size:61px}
  .sylva-splash-symbol{width:164px}
  .sylva-wordmark-splash{font-size:82px;margin-top:-14px}
  .sylva-splash-lockup>small{font-size:7px;letter-spacing:.22em}
}
@media(prefers-reduced-motion:reduce){
  .app-splash,.brand.sylva-brand-button .sylva-symbol-svg{transition:none!important}
}

/* MM.Sylva Beta 0.832 — Leggibilità UI
   Passata circoscritta alle aree segnalate: Codex, Struttura, Cerca,
   Revisione comparata e pagina Privacy/Supporto. */

/* ---------- CODEX: schede e modal editor ---------- */
.codex-card-worldmeta span,
.codex-card-worldmeta em{font-size:10px;line-height:1.35}
.codex-card-detail{font-size:12px;line-height:1.55}
.codex-card-parent{font-size:10px;line-height:1.45}
.codex-card-categories span{font-size:10px}
.codex-card-foot{font-size:10px}

.codex-entry-modal{width:min(980px,calc(100vw - 32px))}
.codex-entry-head small,
.codex-world-head small,
.worldbuilding-section-head small{font-size:10px;line-height:1.35}
.codex-entry-head p{font-size:13px;line-height:1.55}
.world-template-badge{font-size:10px;min-height:36px;padding:8px 12px}
.worldbuilding-section{padding:22px;border-radius:19px}
.worldbuilding-section-head h3{font-size:20px}
.worldbuilding-section-head>span{font-size:10px}
.world-template-grid{gap:15px;margin-top:18px}
.world-template-grid .form-row>label,
.codex-entry-form .form-row>label{font-size:12px;line-height:1.4}
.world-template-grid .form-row>small,
.codex-entry-form .form-row>small{font-size:11px;line-height:1.5}
.world-template-grid input,
.world-template-grid select,
.world-template-grid textarea,
.codex-entry-form input,
.codex-entry-form select,
.codex-entry-form textarea{font-size:14px}
.world-template-grid input,
.world-template-grid select,
.codex-entry-form input,
.codex-entry-form select{min-height:42px}
.world-template-grid textarea{min-height:104px;line-height:1.5}
.world-template-empty{font-size:12px;line-height:1.6;padding:18px}

.world-custom-head{margin-top:24px;padding-top:20px}
.world-custom-head b{font-size:14px}
.world-custom-head small{font-size:11px;line-height:1.45;margin-top:4px}
.world-custom-fields{gap:10px;margin-top:14px}
.world-custom-row{grid-template-columns:minmax(180px,.72fr) minmax(0,1.28fr) 42px;gap:10px;align-items:stretch;padding:10px;border:1px solid color-mix(in srgb,var(--line) 78%,transparent);border-radius:13px;background:color-mix(in srgb,var(--surface-strong) 38%,transparent)}
.world-custom-row input,
.world-custom-row textarea{font-size:14px;line-height:1.45;border-radius:10px}
.world-custom-row input{min-height:42px}
.world-custom-row textarea{min-height:68px;padding-top:10px;padding-bottom:10px}
.world-custom-row .outline-icon-btn{width:42px;height:42px;align-self:start}
.world-custom-head .soft-btn,
.world-custom-head button{min-height:38px;font-size:11px}

.entry-relation-chip{padding:11px 12px;gap:10px}
.entry-relation-chip b{font-size:12px}
.entry-relation-chip small{font-size:10px;line-height:1.4}
.entry-relation-chip em{font-size:11px}








.location-tree-node>button{min-height:40px;padding-top:8px;padding-bottom:8px}
.location-tree-node>button>span{font-size:11px}
.location-tree-node>button>em{font-size:9px}
.codex-world-head h3{font-size:19px}
.codex-world-head>span{font-size:10px}

/* ---------- STRUTTURA: pannello Writer + modulo Struttura ---------- */
.structure-panel{width:294px;min-width:294px}
.tree-row{min-height:38px;font-size:14px;padding:9px 10px;gap:8px}

.tree-row .tree-menu{min-width:28px;min-height:28px}
.outline-node-meta{font-size:10px;line-height:1.4}
.outline-act-head .outline-title-button span{font-size:21px}
.outline-chapter-head .outline-title-button span{font-size:16px}
.outline-scene .outline-title-button span{font-size:13px;line-height:1.4}
.outline-act-head .outline-title-input{font-size:21px}
.outline-chapter-head .outline-title-input{font-size:16px}
.outline-scene .outline-title-input{font-size:13px}
.outline-add-tag{font-size:11px;min-height:34px;padding-left:10px;padding-right:10px}
.outline-tag-pill,.narrative-pill{font-size:10px;line-height:1.35}
.outline-scene{padding:14px 15px}
.outline-chapter-head{padding:16px}
.outline-act-head{padding:21px 22px}

/* ---------- CERCA GLOBALE ---------- */
.global-search-head small{font-size:10px}
.global-search-head h2{font-size:25px}
.global-search-box{height:58px}
.global-search-box input{font-size:16px!important}
.global-search-box>span{font-size:10px}
.global-search-filter{font-size:10px;padding:9px 13px;min-height:36px}
.global-result{grid-template-columns:74px minmax(0,1fr) 24px;gap:14px;padding:13px 14px;min-height:66px}
.global-result-kind{font-size:9px}
.global-result-copy>b{font-size:14px}
.global-result-copy>small{font-size:10px;line-height:1.4;margin:4px 0 6px}
.global-result-copy>span{font-size:12px;line-height:1.45}
.global-search-empty b{font-size:14px}
.global-search-empty span{font-size:12px}
.global-search-empty kbd{font-size:9px}
.global-replace summary{font-size:11px;padding:15px 0}
.global-replace-grid label span{font-size:10px}
.global-replace-grid input,
.global-replace-grid select,
.global-replace-grid button{height:42px;font-size:13px}
.global-replace>p{font-size:10px;line-height:1.45}

/* ---------- REVISIONE COMPARATA ---------- */
.review-start-modal>small{font-size:10px}
.review-start-card>span{font-size:9px}
.review-start-card>b{font-size:16px}
.review-start-card>small{font-size:11px;line-height:1.45}
.review-pending-head b{font-size:12px}
.review-pending-head span{font-size:10px}
.review-pending-list span small{font-size:9px}
.review-pending-list span b{font-size:12px}
.review-pending-list em{font-size:10px}
.review-pending-empty{font-size:11px}
.review-workspace-head{padding:16px 18px}
.review-workspace-head small{font-size:10px;line-height:1.3}
.review-workspace-head h2{font-size:20px;margin-top:5px}
.review-live-summary{font-size:10px;gap:12px;line-height:1.4}
.review-workspace-actions button{min-height:40px;font-size:11px}
.review-column-labels>div{padding:10px 15px}
.review-column-labels span{font-size:10px}
.review-column-labels small{font-size:9px;opacity:.82}
.review-scene-head{height:44px;padding:0 15px}
.review-scene-head>span{font-size:11px}
.review-scene-head>small{font-size:10px}

/* Anche il confronto revisioni storico deve restare leggibile. */
.revision-compare-title small{font-size:10px}
.revision-compare-title p{font-size:12px;line-height:1.45}
.revision-compare-summary span{font-size:10px}
.revision-change-item b{font-size:12px}
.revision-change-item small{font-size:10px}
.revision-change-item em{font-size:9px}
.revision-diff-head small{font-size:9px}
.revision-diff-head p{font-size:11px}
.revision-delta{font-size:10px}
.diff-line p,.diff-single p,.diff-change-pair p{font-size:13px}
.diff-line small,.diff-single small,.diff-change-pair small{font-size:9px}
.revision-identical span,.revision-loading p{font-size:11px}

/* ---------- PRIVACY / CONTATTI / DONAZIONI ---------- */
.legal-version{font-size:10px}
.legal-hero p{font-size:14px;line-height:1.65}
.legal-section p{font-size:14px;line-height:1.7}
.legal-lead{font-size:16px!important;line-height:1.65!important}
.legal-jump button{font-size:12px}
.legal-jump button small{font-size:10px;line-height:1.35}
.legal-policy-card p,
.legal-policy-card ul{font-size:13px;line-height:1.65}
.legal-policy-card h3{font-size:17px}
.legal-thirdparty-links a{font-size:11px;padding:9px 12px}
.legal-cookie-status>small{font-size:10px}
.legal-cookie-status>div{font-size:12px;line-height:1.45}
.legal-cookie-status b{font-size:11px}
.legal-terms-list article>span{font-size:10px}
.legal-terms-list h3{font-size:16px}
.legal-support-copy>small{font-size:10px}
.legal-support-legal b{font-size:12px}
.legal-support-legal span{font-size:12px;line-height:1.6}
.legal-paypal-box small{font-size:11px;line-height:1.55}
.legal-paypal-btn{font-size:13px;min-height:48px}
.legal-contact-address small{font-size:10px}
.legal-contact-address b{font-size:14px}
.legal-contact-address button{font-size:11px;min-height:36px}
.legal-contact-privacy b{font-size:12px}
.legal-contact-privacy p{font-size:12px}
.legal-form-row label{font-size:11px}
.legal-form-row label small{font-size:10px}
.legal-form-row input,
.legal-form-row select,
.legal-form-row textarea{font-size:14px;line-height:1.5}
.legal-human small{font-size:11px}
.legal-form-error{font-size:12px!important}
.legal-form-foot{font-size:11px;line-height:1.55}
.legal-footer b{font-size:12px}
.legal-footer span{font-size:11px}
.legal-footer button{font-size:11px;min-height:34px}

/* ---------- TABLET ---------- */
@media (pointer:coarse) and (min-width:561px) and (max-width:1366px){
  .structure-panel{width:min(78vw,370px);min-width:0}
  .structure-panel.collapsed{width:min(78vw,370px)}
  .tree-row{min-height:46px;font-size:15px;padding:10px 11px}
  .outline-act-head .outline-title-button span{font-size:22px}
  .outline-chapter-head .outline-title-button span{font-size:17px}
  .outline-scene .outline-title-button span{font-size:14px}
  .outline-node-meta{font-size:11px}
  .outline-icon-btn{min-width:40px;min-height:40px}

  .codex-entry-modal{width:min(1040px,calc(100vw - 22px))}
  .worldbuilding-section{padding:20px}
  .world-custom-row{grid-template-columns:minmax(190px,.72fr) minmax(0,1.28fr) 44px;gap:10px}
  .world-custom-row input,.world-custom-row textarea{font-size:15px}
  .world-custom-row input{min-height:46px}
  .world-custom-row textarea{min-height:76px}
  .world-custom-row .outline-icon-btn{width:44px;height:44px}

  .global-search-filter{min-height:42px;font-size:11px;padding-left:15px;padding-right:15px}
  .global-result{min-height:72px;padding:14px 12px}
  .global-result-copy>b{font-size:15px}
  .global-result-copy>small{font-size:11px}
  .global-result-copy>span{font-size:13px}

  .review-workspace-head{padding:15px 16px;gap:12px}
  .review-workspace-head small{font-size:11px}
  .review-workspace-head h2{font-size:21px}
  .review-live-summary{font-size:11px}
  .review-column-labels span{font-size:11px}
  .review-column-labels small{font-size:10px}
  .review-scene-head>span{font-size:12px}
  .review-scene-head>small{font-size:11px}
  .review-workspace-actions button{min-height:44px;font-size:12px}

  .legal-hero p,.legal-section p{font-size:15px}
  .legal-policy-card p,.legal-policy-card ul{font-size:14px}
  .legal-jump button{font-size:13px}
  .legal-contact-form input,.legal-contact-form select,.legal-contact-form textarea{font-size:15px}
  .legal-form-row label{font-size:12px}
  .legal-thirdparty-links a{font-size:12px;min-height:40px;display:inline-flex;align-items:center}
}

/* ---------- TABLET stretto / smartphone per le aree disponibili ---------- */
@media(max-width:900px){
  .world-custom-row{grid-template-columns:minmax(0,1fr) 44px;padding:11px;gap:9px}
  .world-custom-row input{grid-column:1;grid-row:1}
  .world-custom-row textarea{grid-column:1/-1;grid-row:2;min-height:82px}
  .world-custom-row .outline-icon-btn{grid-column:2;grid-row:1;width:44px;height:44px}
  .global-result{grid-template-columns:62px minmax(0,1fr) 22px}
  .revision-compare-layout{grid-template-columns:minmax(210px,34vw) minmax(0,1fr)}
}

@media(max-width:700px){
  .legal-version{font-size:9px}
  .legal-hero p{font-size:14px}
  .legal-section p{font-size:14px}
  .legal-lead{font-size:15px!important}
  .legal-jump button{font-size:12px}
  .legal-policy-card p,.legal-policy-card ul{font-size:13px}
  .legal-policy-card h3{font-size:17px}
  .legal-cookie-status>div{font-size:12px}
  .legal-contact-address b{font-size:13px}
  .legal-form-row label{font-size:11px}
  .legal-form-row input,.legal-form-row select,.legal-form-row textarea{font-size:16px} /* evita zoom automatico iOS */
  .legal-form-foot,.legal-human small{font-size:11px}
  .legal-footer span,.legal-footer button{font-size:11px}
}

/* Beta 0.832 — Codex: sezione "Dove appare" / controlli minuti della scheda */
.codex-appearance-head small{font-size:10px;line-height:1.35}
.codex-appearance-head h3{font-size:20px}
.codex-appearance-head>span{font-size:10px;line-height:1.4}
.codex-appearance-range{gap:10px;margin:13px 0}
.codex-appearance-range>div{padding:12px 14px;border-radius:12px}
.codex-appearance-range small{font-size:9px}
.codex-appearance-range b{font-size:11px;line-height:1.45;margin-top:5px}
.codex-appearance-list{gap:7px;max-height:330px}
.codex-appearance-jump{grid-template-columns:minmax(0,1fr) 38px 22px;gap:10px;padding:11px 12px;min-height:66px}
.codex-appearance-jump b{font-size:12px}
.codex-appearance-jump small{font-size:9px;line-height:1.4;margin-top:3px}
.codex-appearance-jump em{font-size:10px;line-height:1.45;margin-top:5px}
.codex-appearance-jump>strong{font-size:10px}
.codex-appearance-empty{font-size:11px;line-height:1.5;padding:15px}
.codex-entry-modal .tiny-text-btn{font-size:11px;min-height:36px;padding:7px 10px}
.codex-entry-modal .modal-actions button{min-height:42px;font-size:12px}
.codex-card p{font-size:13px}

@media (pointer:coarse) and (min-width:561px) and (max-width:1366px){
  .codex-appearance-head small{font-size:11px}
  .codex-appearance-head>span{font-size:11px}
  .codex-appearance-range b{font-size:12px}
  .codex-appearance-jump{min-height:74px;padding:13px 14px}
  .codex-appearance-jump b{font-size:13px}
  .codex-appearance-jump small{font-size:10px}
  .codex-appearance-jump em{font-size:11px}
  .codex-entry-modal .tiny-text-btn{min-height:42px;font-size:12px}
}

/* ========================================================================== 
   Beta 0.832 — Tablet responsive stabilization
   SOLO tablet/coarse pointer. Nessuna modifica al layout desktop.
   ========================================================================== */
@media (pointer:coarse) and (min-width:561px) and (max-width:1366px){
  /* --- Shell / topbar: una sola metrica per tutti i controlli --- */
  .app-shell{
    grid-template-rows:64px minmax(0,1fr)!important;
    padding:8px!important;
    gap:8px!important;
  }
  .topbar{
    min-height:64px!important;
    height:64px!important;
    grid-template-columns:minmax(250px,1fr) auto auto!important;
    align-items:center!important;
    padding:0 10px!important;
    gap:8px!important;
    border-radius:20px!important;
  }
  .topbar-left{
    padding-left:0!important;
    gap:10px!important;
    min-width:0!important;
  }
  .topbar-left>div{min-width:0!important}
  .book-title-top{font-size:15px!important;line-height:1.15!important}
  .save-lines{margin-top:3px!important;gap:7px!important}
  .save-state,.cloud-state{font-size:9px!important;line-height:1.15!important}

  /* Il pulsante menu resta nel punto naturale della topbar; non galleggia nel viewport. */
  
  
  

  /* Rail moduli: allineato sotto la topbar, touch e scorribile. */
  #rail{
    left:8px!important;
    top:80px!important;
    bottom:8px!important;
    width:80px!important;
    padding:10px 7px!important;
    border-radius:20px!important;
    transform:translate3d(-96px,0,0)!important;
    overflow-y:auto!important;
    overflow-x:hidden!important;
    scrollbar-width:none!important;
    z-index:88!important;
  }
  #rail.open{transform:translate3d(0,0,0)!important}
  #rail::-webkit-scrollbar{display:none!important}
  #rail .brand{margin-bottom:8px!important;flex:0 0 auto!important}
  #rail .rail-nav{gap:3px!important;margin-top:2px!important;flex-shrink:0!important}
  #rail .rail-bottom{gap:3px!important;flex-shrink:0!important}
  #rail .rail-btn{
    width:64px!important;
    min-height:52px!important;
    padding:6px 3px!important;
    gap:3px!important;
    border-radius:13px!important;
  }
  #rail .rail-btn small{font-size:9px!important;line-height:1.05!important}
  #rail .rail-icon-wrap{width:23px!important;height:23px!important}
  #rail .rail-icon{width:20px!important;height:20px!important}

  /* Scope e azioni: stessa altezza, nessun bottone gigante o più basso degli altri. */
  .topbar-center{
    height:44px!important;
    min-height:44px!important;
    display:flex!important;
    align-items:center!important;
    padding:4px!important;
    gap:1px!important;
    border-radius:13px!important;
  }
  .topbar-center .scope-btn{
    height:36px!important;
    min-height:36px!important;
    padding:0 9px!important;
    font-size:10px!important;
    line-height:1!important;
    border-radius:9px!important;
  }
  .topbar-actions{gap:6px!important;align-items:center!important;min-width:0!important}
  .topbar-actions .global-search-trigger,
  .topbar-actions .session-trigger,
  .topbar-actions .cloud-btn,
  .topbar-actions .music-radio-trigger{
    width:44px!important;
    min-width:44px!important;
    height:44px!important;
    min-height:44px!important;
    padding:0!important;
    border-radius:12px!important;
    display:inline-flex!important;
    align-items:center!important;
    justify-content:center!important;
    flex:0 0 44px!important;
  }
  .topbar-actions .global-search-trigger>span,
  .topbar-actions .session-trigger>span,
  .topbar-actions .cloud-btn-label{display:none!important}
  .topbar-actions .global-search-trigger svg,
  .topbar-actions .session-trigger svg,
  .topbar-actions .music-radio-trigger svg{width:18px!important;height:18px!important;margin:0!important}
  .topbar-actions .cloud-dot{margin:0!important}
  .topbar-actions #saveBtn{
    height:44px!important;
    min-height:44px!important;
    min-width:84px!important;
    padding:0 16px!important;
    border-radius:12px!important;
    font-size:12px!important;
    display:inline-flex!important;
    align-items:center!important;
    justify-content:center!important;
  }

  /* --- Writer toolbar --- */
  .floating-toolbar{
    top:80px!important;
    min-height:48px!important;
    height:48px!important;
    padding:5px 7px!important;
    gap:3px!important;
    border-radius:14px!important;
    align-items:center!important;
  }
  .floating-toolbar button:not(.highlight-dot),
  .floating-toolbar select{
    height:38px!important;
    min-height:38px!important;
    flex:0 0 auto!important;
  }
  .floating-toolbar .highlight-menu{
    display:flex!important;
    align-items:center!important;
    gap:5px!important;
    height:38px!important;
    flex:0 0 auto!important;
  }
  .floating-toolbar .highlight-dot{
    width:28px!important;
    min-width:28px!important;
    max-width:28px!important;
    height:28px!important;
    min-height:28px!important;
    max-height:28px!important;
    flex:0 0 28px!important;
    padding:0!important;
    border-radius:50%!important;
    aspect-ratio:1/1!important;
  }
  .floating-toolbar .highlight-clear{
    width:36px!important;
    min-width:36px!important;
    height:36px!important;
    min-height:36px!important;
    padding:0!important;
  }

  /* --- Cerca: su tablet niente pillole/cerchi di filtro sopra i risultati. --- */
  .modal.global-search-modal{width:calc(100vw - 34px)!important;max-height:88dvh!important}
  .global-search-shell{max-height:88dvh!important;min-height:min(720px,82dvh)!important}
  .global-search-filters{display:none!important}
  .global-search-box{margin-bottom:12px!important}
  .global-search-results{padding-top:4px!important}

  /* --- Timeline: ricerca e filtro restano ancorati all'inizio dell'area scrollabile. --- */
  .timeline-tools{
    position:sticky!important;
    top:0!important;
    z-index:24!important;
    margin-top:0!important;
    margin-bottom:20px!important;
    background:color-mix(in srgb,var(--surface-strong) 94%,transparent)!important;
    border:1px solid var(--line)!important;
    box-shadow:0 10px 28px rgba(0,0,0,.08)!important;
    backdrop-filter:none!important;
  }
  .timeline-tools .search-wrap,
  .timeline-tools input{min-width:0!important}
  .timeline-tools input,.timeline-tools select{height:46px!important;min-height:46px!important}

  /* --- Struttura Writer: pannello e linguetta non devono vagare sullo schermo. --- */
  #writerView .structure-panel{
    top:8px!important;
    bottom:8px!important;
    height:auto!important;
    width:min(72vw,370px)!important;
    max-width:370px!important;
    border-radius:18px!important;
  }
  #writerView .structure-panel.mobile-open{transform:translateX(0)!important;opacity:1!important}
  #writerView .structure-panel.collapsed{width:min(72vw,370px)!important}
  #writerView .edge-handle{
    left:8px!important;
    top:50%!important;
    transform:translateY(-50%)!important;
    width:18px!important;
    min-width:18px!important;
    height:78px!important;
    min-height:78px!important;
    border-radius:0 12px 12px 0!important;
    z-index:52!important;
  }
}

/* Tablet portrait / stretto: scope su una seconda riga, sempre visibile senza comprimere i comandi. */
@media (pointer:coarse) and (min-width:561px) and (max-width:900px){
  .app-shell{grid-template-rows:108px minmax(0,1fr)!important}
  .topbar{
    height:108px!important;
    min-height:108px!important;
    grid-template-columns:minmax(0,1fr) auto!important;
    grid-template-rows:58px 42px!important;
    grid-template-areas:"left actions" "scope scope"!important;
    align-content:center!important;
    padding:4px 10px 6px!important;
  }
  .topbar-left{grid-area:left!important}
  .topbar-actions{grid-area:actions!important}
  .topbar-center{
    grid-area:scope!important;
    justify-self:center!important;
    height:40px!important;
    min-height:40px!important;
    max-width:100%!important;
  }
  .topbar-center .scope-btn{height:32px!important;min-height:32px!important;padding:0 12px!important}
  #rail{top:124px!important}
  .floating-toolbar{top:124px!important;max-width:calc(100vw - 22px)!important}
  .document-meta{padding-top:46px!important}
}

/* === SYLVA 2026 EDITORIAL FOREST THEME — isolated override === */
/* === SYLVA 2026 EDITORIAL FOREST THEME — isolated override ===
   Tema-only override. Non modifica breakpoint, geometrie tablet/mobile, salvataggi o logica app.
   ========================================================================== */
html[data-theme="sylva"]{
  --sylva-ui:"Instrument Sans",Inter,system-ui,sans-serif;
  --bg:#0b110d;--bg2:#152016;
  --surface:rgba(22,30,24,.92);--surface-2:rgba(31,42,34,.66);--surface-strong:#182119;
  --paper:#e7dcc7;--sylva-paper-hi:#eee5d5;--sylva-paper-low:#d8c8ac;--sylva-paper-edge:#b9a17e;
  --sylva-ink:#302c25;--sylva-paper-muted:#766d60;
  --text:#eee6d9;--muted:#9ba69a;--line:rgba(234,225,209,.10);--shadow:0 24px 68px rgba(0,0,0,.31);
  --accent:#8b9a80;--accent-2:#b58c60;--accent-soft:rgba(139,154,128,.13);
  --danger:#b66f62;--danger-soft:rgba(182,111,98,.12);
  --sylva-orange:#ff7a1f;
  --ambient-opacity:0;
  --ui-font:var(--sylva-ui);
  --ui-serif:var(--sylva-ui);
}

/* App typography: Instrument Sans. Manuscript/revision text keeps the book's configured editor font. */
html[data-theme="sylva"] body,
html[data-theme="sylva"] button,
html[data-theme="sylva"] input,
html[data-theme="sylva"] textarea,
html[data-theme="sylva"] select{font-family:var(--sylva-ui)}
html[data-theme="sylva"] .view-heading h1,
html[data-theme="sylva"] .panel-head h2,
html[data-theme="sylva"] .book-card h2,
html[data-theme="sylva"] .codex-card h3,
html[data-theme="sylva"] .timeline-event-head h3,
html[data-theme="sylva"] .timeline-stats b,
html[data-theme="sylva"] .planning-stats b,
html[data-theme="sylva"] .relationship-page-stats b,
html[data-theme="sylva"] .calendar-summary b,
html[data-theme="sylva"] .phone-access-header h1,
html[data-theme="sylva"] .phone-book-head h2,
html[data-theme="sylva"] .book-status-copy h2{font-family:var(--sylva-ui)!important}
html[data-theme="sylva"] .scene-editor,
html[data-theme="sylva"] .scene-editor *,
html[data-theme="sylva"] .reader-editor,
html[data-theme="sylva"] .reader-editor *,
html[data-theme="sylva"] .review-original-copy,
html[data-theme="sylva"] .review-original-copy *,
html[data-theme="sylva"] .review-scene-editor,
html[data-theme="sylva"] .review-scene-editor *{font-family:var(--editor-font)!important}
html[data-theme="sylva"] .sylva-wordmark{font-family:"Allura",cursive!important}
html[data-theme="sylva"] .google-g{font-family:Inter,system-ui,sans-serif!important}
html[data-theme="sylva"] .tool-emoji{font-family:"Segoe UI Emoji","Apple Color Emoji","Noto Color Emoji",system-ui,sans-serif!important}

/* Forest atmosphere: static, GPU-light and intentionally subtle. */
html[data-theme="sylva"] .ambient{display:none!important}
html[data-theme="sylva"] body{
  position:relative;
  background:
    radial-gradient(760px 460px at 57% 10%,rgba(160,177,147,.10),transparent 58%),
    radial-gradient(900px 620px at 78% 105%,rgba(42,66,47,.28),transparent 68%),
    radial-gradient(760px 560px at 5% 55%,rgba(28,48,34,.22),transparent 70%),
    linear-gradient(145deg,#090e0b 0%,#101812 36%,#152016 66%,#0b110d 100%)!important;
}
html[data-theme="sylva"] body::before{
  content:"";position:fixed;inset:-7%;z-index:0;pointer-events:none;opacity:.17;filter:blur(2.5px);
  background:url("assets/sylva-canopy.svg") center/cover no-repeat;
  mix-blend-mode:screen;transform:scale(1.04);will-change:auto;
}
html[data-theme="sylva"] body::after{
  content:"";position:fixed;inset:0;z-index:0;pointer-events:none;opacity:.72;
  background:
    radial-gradient(330px 240px at 54% 17%,rgba(219,225,202,.055),transparent 72%),
    radial-gradient(500px 320px at 63% 74%,rgba(112,135,98,.05),transparent 72%),
    radial-gradient(circle at 20% 30%,rgba(255,255,255,.11) 0 1px,transparent 1.2px),
    radial-gradient(circle at 74% 64%,rgba(255,255,255,.07) 0 1px,transparent 1.1px),
    radial-gradient(90% 120% at 50% 22%,transparent 52%,rgba(0,0,0,.25) 100%);
  background-size:auto,auto,23px 23px,29px 29px,auto;mix-blend-mode:soft-light;
}
html[data-theme="sylva"] .app-shell,
html[data-theme="sylva"] .entry-gate,
html[data-theme="sylva"] #phoneAccess,
html[data-theme="sylva"] #legalView{position:relative;z-index:1}

/* Matte forest shell. No geometry changes: tablet/mobile sizing remains exactly in existing responsive rules. */
html[data-theme="sylva"] .rail,
html[data-theme="sylva"] .topbar{
  background:linear-gradient(180deg,rgba(22,30,24,.965),rgba(13,19,15,.95))!important;
  border-color:rgba(234,225,209,.095)!important;
  box-shadow:0 16px 46px rgba(0,0,0,.19),inset 0 1px rgba(255,255,255,.018)!important;
}
html[data-theme="sylva"] .glass,
html[data-theme="sylva"] .glass-lite{backdrop-filter:blur(15px) saturate(.76);-webkit-backdrop-filter:blur(15px) saturate(.76)}
html[data-theme="sylva"] .brand.sylva-brand-button{background:rgba(255,255,255,.025)!important;border-color:rgba(234,225,209,.09)!important;box-shadow:none!important}
html[data-theme="sylva"] .rail-btn{position:relative;color:#aab5a8}
html[data-theme="sylva"] .rail-btn:hover,
html[data-theme="sylva"] .rail-btn.active{background:rgba(232,224,208,.065)!important;color:#f1e9dc!important}
html[data-theme="sylva"] .rail-btn.active::after{content:"";position:absolute;right:6px;top:9px;width:4px;height:4px;border-radius:50%;background:var(--sylva-orange);box-shadow:0 0 0 3px rgba(255,122,31,.07)}
html[data-theme="sylva"] .rail-btn small{font-weight:500;letter-spacing:.005em}

/* Sylva illustrated rail icons. Existing SVGs stay in DOM as fallback for every other theme. */
html[data-theme="sylva"] #rail .rail-icon-wrap{background-repeat:no-repeat;background-position:center;background-size:contain}
html[data-theme="sylva"] #rail .rail-icon-wrap>.rail-icon{visibility:hidden!important}
html[data-theme="sylva"] #rail .rail-btn[data-route="writer"] .rail-icon-wrap{background-image:url("assets/sylva-icons/scrivi-line-light.png")}
html[data-theme="sylva"] #rail .rail-btn[data-route="reader"] .rail-icon-wrap{background-image:url("assets/sylva-icons/libri-line-light.png")}
html[data-theme="sylva"] #rail .rail-btn[data-route="outline"] .rail-icon-wrap{background-image:url("assets/sylva-icons/albero.png")}
html[data-theme="sylva"] #rail .rail-btn[data-route="planning"] .rail-icon-wrap{background-image:url("assets/sylva-icons/mappa.png")}
html[data-theme="sylva"] #rail .rail-btn[data-route="codex"] .rail-icon-wrap{background-image:url("assets/sylva-icons/codex-line-light.png")}
html[data-theme="sylva"] #rail .rail-btn[data-route="relationships"] .rail-icon-wrap{background-image:url("assets/sylva-icons/condividi.png")}
html[data-theme="sylva"] #rail .rail-btn[data-route="timeline"] .rail-icon-wrap{background-image:url("assets/sylva-icons/timeline-line-light.png")}
html[data-theme="sylva"] #rail .rail-btn[data-route="calendar"] .rail-icon-wrap{background-image:url("assets/sylva-icons/tempo.png")}
html[data-theme="sylva"] #rail .rail-btn[data-route="analysis"] .rail-icon-wrap{background-image:url("assets/sylva-icons/cerca.png")}
html[data-theme="sylva"] #rail .rail-btn[data-route="revisions"] .rail-icon-wrap{background-image:url("assets/sylva-icons/note.png")}
html[data-theme="sylva"] #rail #themeToggle .rail-icon-wrap{background-image:url("assets/sylva-icons/tema-line-light.png")}
html[data-theme="sylva"] #rail #settingsBtn .rail-icon-wrap{background-image:url("assets/sylva-icons/impostazioni.png")}
html[data-theme="sylva"] #rail .rail-btn:hover .rail-icon-wrap,
html[data-theme="sylva"] #rail .rail-btn.active .rail-icon-wrap{transform:translateY(-1px) scale(1.055)}

/* Codex: illustrated PNG for mapped icons, original vector stays as fallback for every other theme. */
.sylva-codex-icon{display:none!important;object-fit:contain}
html[data-theme="sylva"] .sylva-codex-icon{display:inline-block!important}
html[data-theme="sylva"] .codex-icon-default.sylva-has-alt{display:none!important}
html[data-theme="sylva"] .codex-card-symbol{background:rgba(232,224,208,.055);border-color:rgba(232,224,208,.08)}
html[data-theme="sylva"] .codex-card-symbol .codex-symbol{width:34px;height:34px}
html[data-theme="sylva"] .codex-icon-choice .codex-symbol{width:27px;height:27px}
/* Mini category glyphs deliberately remain vector for legibility at 10px. */

/* Aged paper: edge staining stays outside the reading core; no bitmap texture needed. */
html[data-theme="sylva"] .scene-sheet,
html[data-theme="sylva"] .reader-document,
html[data-theme="sylva"] .review-original-sheet,
html[data-theme="sylva"] .review-edit-sheet{
  color:var(--sylva-ink)!important;
  border-color:rgba(128,104,75,.20)!important;
  background:
    radial-gradient(130px 82px at 5% 6%,rgba(139,111,79,.14),transparent 72%),
    radial-gradient(160px 95px at 95% 8%,rgba(139,111,79,.12),transparent 73%),
    radial-gradient(150px 90px at 7% 94%,rgba(139,111,79,.13),transparent 73%),
    radial-gradient(180px 110px at 96% 92%,rgba(139,111,79,.16),transparent 74%),
    linear-gradient(90deg,rgba(182,159,125,.15),transparent 8%,transparent 92%,rgba(182,159,125,.15)),
    linear-gradient(180deg,rgba(255,255,255,.12),transparent 12%,transparent 92%,rgba(182,159,125,.12)),
    radial-gradient(circle at 18% 12%,rgba(73,62,47,.055) 0 .65px,transparent .85px),
    radial-gradient(circle at 67% 72%,rgba(73,62,47,.04) 0 .55px,transparent .75px),
    linear-gradient(180deg,var(--paper),#dfd1b8)!important;
  background-size:auto,auto,auto,auto,auto,auto,14px 14px,19px 19px,auto!important;
  box-shadow:0 28px 66px rgba(0,0,0,.30),0 6px 18px rgba(0,0,0,.08),inset 0 0 0 1px rgba(255,255,255,.08),inset 0 0 30px rgba(126,103,76,.045)!important;
}
html[data-theme="sylva"] .scene-sheet{border-radius:18px!important}
html[data-theme="sylva"] .reader-document{border-radius:18px!important}
html[data-theme="sylva"] .review-original-sheet,html[data-theme="sylva"] .review-edit-sheet{border-radius:14px!important}
html[data-theme="sylva"] .scene-editor,
html[data-theme="sylva"] .reader-editor,
html[data-theme="sylva"] .review-original-copy,
html[data-theme="sylva"] .review-scene-editor{color:var(--sylva-ink)!important;caret-color:#55644f}
html[data-theme="sylva"] .scene-label,
html[data-theme="sylva"] .reader-scene-label,
html[data-theme="sylva"] .reader-separator small,
html[data-theme="sylva"] .review-scene-head>span,
html[data-theme="sylva"] .review-scene-head>small{color:var(--sylva-paper-muted)!important}
html[data-theme="sylva"] .review-scene-head{background:rgba(213,198,172,.50)!important;border-color:rgba(128,104,75,.13)!important}
html[data-theme="sylva"] .reader-separator{border-color:rgba(128,104,75,.14)!important}

/* Buttons and controls: forest first, bronze/orange only as restrained detail. */
html[data-theme="sylva"] .primary-btn{background:linear-gradient(180deg,#354735,#2b392c)!important;color:#f3ebdf!important;border-color:rgba(169,189,158,.15)!important;box-shadow:inset 0 1px rgba(255,255,255,.04)}
html[data-theme="sylva"] .primary-btn:hover{background:linear-gradient(180deg,#40543f,#314131)!important;border-color:rgba(181,204,170,.22)!important}
html[data-theme="sylva"] input:focus,
html[data-theme="sylva"] textarea:focus,
html[data-theme="sylva"] select:focus{border-color:color-mix(in srgb,var(--accent) 42%,var(--line))!important;box-shadow:0 0 0 2px rgba(139,154,128,.08)}
html[data-theme="sylva"] ::selection{background:rgba(139,154,128,.25);color:inherit}

/* Theme picker preview mirrors the actual new Sylva theme. */
.sylva-theme-group{border-color:rgba(139,154,128,.20)!important;background:linear-gradient(145deg,rgba(15,21,17,.28),color-mix(in srgb,var(--surface-2) 92%,transparent))!important}
.sylva-theme-card .theme-preview{background:linear-gradient(135deg,#0f1511 0 52%,#e7dcc7 52% 100%)!important}
.sylva-theme-card .theme-preview:before{background:#d8c8ac!important;box-shadow:inset 0 0 0 1px rgba(128,104,75,.25)!important}
.sylva-theme-card .theme-preview:after{background:#ff7a1f!important}

/* Tablet/coarse pointer: keep the existing navigation geometry untouched and reduce paint cost. */
@media (pointer:coarse) and (min-width:561px) and (max-width:1366px){
  html[data-theme="sylva"] body::before{filter:blur(1.5px);opacity:.145}
  html[data-theme="sylva"] body::after{opacity:.58}
  html[data-theme="sylva"] .rail,html[data-theme="sylva"] .topbar{backdrop-filter:none!important;-webkit-backdrop-filter:none!important}
}
@media (prefers-reduced-motion:reduce){
  html[data-theme="sylva"] #rail .rail-icon-wrap{transition:none!important}
}

/* === SYLVA 2026 HYBRID PAPER MEDALLION UI V3 === */
/* Dark forest shell + selective paper controls. All geometry and app logic stay untouched. */
html[data-theme="sylva"]{
  --sylva-ivory:#ece4d7;
  --sylva-ivory-2:#e2d7c5;
  --sylva-control-ink:#273628;
  --sylva-sage-paper:#dce5d6;
  --sylva-sage-line:#9cad94;
  --sylva-paper-shadow:0 7px 18px rgba(0,0,0,.19),inset 0 1px rgba(255,255,255,.48);
}

html[data-theme="sylva"] #rail{
  background:linear-gradient(180deg,rgba(22,30,24,.975),rgba(12,18,14,.965))!important;
  border-color:rgba(234,225,209,.095)!important;
}
html[data-theme="sylva"] #rail .rail-nav{gap:3px;margin-top:12px}
html[data-theme="sylva"] #rail .rail-bottom{gap:3px}
html[data-theme="sylva"] #rail .rail-btn{
  background:transparent!important;color:#adb7ab!important;padding:6px 3px;gap:2px;border-radius:14px;
}
html[data-theme="sylva"] #rail .rail-btn:hover,
html[data-theme="sylva"] #rail .rail-btn.active{background:transparent!important;color:#f0e8dc!important}
html[data-theme="sylva"] #rail .rail-icon-wrap{
  width:44px!important;height:44px!important;flex:0 0 44px;border-radius:14px;
  background-color:var(--sylva-ivory)!important;background-repeat:no-repeat!important;background-position:center!important;background-size:84% auto!important;
  border:1px solid rgba(118,106,88,.25);box-shadow:var(--sylva-paper-shadow);
  transition:transform .17s ease,background-color .17s ease,border-color .17s ease,box-shadow .17s ease!important;
}
html[data-theme="sylva"] #rail .rail-btn:hover .rail-icon-wrap{
  transform:translateY(-1px) scale(1.035)!important;background-color:#f2ebdf!important;border-color:rgba(139,126,105,.31);
  box-shadow:0 9px 21px rgba(0,0,0,.24),inset 0 1px rgba(255,255,255,.60)!important;
}
html[data-theme="sylva"] #rail .rail-btn.active .rail-icon-wrap{
  transform:none!important;background-color:var(--sylva-sage-paper)!important;border-color:var(--sylva-sage-line)!important;
  box-shadow:0 8px 22px rgba(0,0,0,.24),0 0 0 2px rgba(156,173,148,.10),inset 0 1px rgba(255,255,255,.52)!important;
}
html[data-theme="sylva"] #rail .rail-btn.active::after{right:5px;top:7px;width:5px;height:5px;background:var(--sylva-orange);box-shadow:0 0 0 3px rgba(255,122,31,.075)}
html[data-theme="sylva"] #rail .rail-btn small{font-size:8.5px;font-weight:600;line-height:1.05;color:inherit}

/* Dark illustrated variants on paper medallions. */
html[data-theme="sylva"] #rail .rail-btn[data-route="writer"] .rail-icon-wrap{background-image:url("assets/sylva-icons/scrivi-line.png")!important}
html[data-theme="sylva"] #rail .rail-btn[data-route="reader"] .rail-icon-wrap{background-image:url("assets/sylva-icons/libri-line.png")!important}
html[data-theme="sylva"] #rail .rail-btn[data-route="codex"] .rail-icon-wrap{background-image:url("assets/sylva-icons/codex-line.png")!important}
html[data-theme="sylva"] #rail .rail-btn[data-route="timeline"] .rail-icon-wrap{background-image:url("assets/sylva-icons/timeline-line.png")!important}
html[data-theme="sylva"] #rail #themeToggle .rail-icon-wrap{background-image:url("assets/sylva-icons/tema-line.png")!important}

html[data-theme="sylva"] #rail .brand.sylva-brand-button{
  width:50px;height:50px;background:linear-gradient(180deg,#efe7da,#e3d8c6)!important;
  border-color:rgba(118,106,88,.24)!important;box-shadow:0 7px 18px rgba(0,0,0,.19),inset 0 1px rgba(255,255,255,.52)!important;
}
html[data-theme="sylva"] #rail .brand.sylva-brand-button:hover{transform:translateY(-1px)}

/* Dark topbar + paper controls. */
html[data-theme="sylva"] .topbar{background:linear-gradient(180deg,rgba(20,29,22,.97),rgba(13,19,15,.96))!important}
html[data-theme="sylva"] .topbar-center{
  background:linear-gradient(180deg,#ece4d7,#e2d8c8)!important;border-color:rgba(118,106,88,.22)!important;
  box-shadow:0 5px 15px rgba(0,0,0,.15),inset 0 1px rgba(255,255,255,.48)!important;
}
html[data-theme="sylva"] .topbar-center .scope-btn{color:#687165!important;background:transparent!important}
html[data-theme="sylva"] .topbar-center .scope-btn:hover{color:#29382a!important;background:rgba(113,137,104,.09)!important}
html[data-theme="sylva"] .topbar-center .scope-btn.active{
  color:#253426!important;background:#d7e1d2!important;
  box-shadow:inset 0 0 0 1px rgba(111,135,102,.18),0 2px 7px rgba(62,75,57,.08)!important;
}
html[data-theme="sylva"] .topbar-actions .soft-btn,
html[data-theme="sylva"] .topbar-actions .session-trigger,
html[data-theme="sylva"] .topbar-actions .music-radio-trigger,
html[data-theme="sylva"] .topbar-actions .cloud-btn{
  background:linear-gradient(180deg,#ece4d7,#e2d8c8)!important;color:#304030!important;
  border:1px solid rgba(118,106,88,.21)!important;box-shadow:0 4px 13px rgba(0,0,0,.13),inset 0 1px rgba(255,255,255,.45)!important;
}
html[data-theme="sylva"] .topbar-actions .soft-btn:hover,
html[data-theme="sylva"] .topbar-actions .session-trigger:hover,
html[data-theme="sylva"] .topbar-actions .music-radio-trigger:hover,
html[data-theme="sylva"] .topbar-actions .cloud-btn:hover{background:#f1eadf!important;color:#263526!important;border-color:rgba(126,112,91,.30)!important}
html[data-theme="sylva"] .topbar-actions .soft-btn.active{background:#d8e2d3!important;color:#263526!important;border-color:#a5b59d!important}
html[data-theme="sylva"] .topbar-actions #saveBtn{
  background:linear-gradient(180deg,#3a4e3a,#2e3e30)!important;color:#f2eadf!important;border-color:rgba(177,197,167,.16)!important;box-shadow:inset 0 1px rgba(255,255,255,.05)!important;
}
html[data-theme="sylva"] .topbar-actions #saveBtn:hover{background:linear-gradient(180deg,#455c44,#344735)!important}

/* Writer structure: dark panel, light active row and light action chips. */
html[data-theme="sylva"] .structure-panel{
  background:linear-gradient(180deg,rgba(23,33,26,.96),rgba(16,24,19,.96))!important;border-color:rgba(234,225,209,.09)!important;
}
html[data-theme="sylva"] .structure-sticky-tools{background:linear-gradient(to bottom,rgba(24,34,27,.99) 0%,rgba(24,34,27,.96) 80%,rgba(24,34,27,.84) 100%)!important}
html[data-theme="sylva"] .structure-panel .structure-actions .mini-btn{
  background:linear-gradient(180deg,#ebe3d6,#e0d5c4)!important;color:#304030!important;border-color:rgba(118,106,88,.20)!important;
}
html[data-theme="sylva"] .structure-panel .structure-actions .mini-btn:hover{background:#f0e9dd!important;color:#263526!important}
html[data-theme="sylva"] .structure-panel .tree-row:hover{background:rgba(232,224,208,.075)!important;color:#eee6d9!important}
html[data-theme="sylva"] .structure-panel .tree-row.active{
  background:linear-gradient(180deg,#e8e0d3,#dce4d7)!important;color:#2d3b2d!important;
  box-shadow:inset 3px 0 #8da083,0 4px 12px rgba(0,0,0,.10)!important;
}

html[data-theme="sylva"] .structure-panel .tree-row.active .tree-menu{color:#687365!important}

/* Codex: keep dark cards, give the illustrated icons room and a paper stage. */
html[data-theme="sylva"] .codex-card-symbol{
  width:56px!important;height:56px!important;border-radius:16px!important;
  background:linear-gradient(180deg,#eee6d9,#e1d6c3)!important;border-color:rgba(118,106,88,.22)!important;
  box-shadow:0 6px 16px rgba(0,0,0,.15),inset 0 1px rgba(255,255,255,.50)!important;
}
html[data-theme="sylva"] .codex-card-symbol .codex-symbol,
html[data-theme="sylva"] .codex-card-symbol .sylva-codex-icon{width:43px!important;height:43px!important;object-fit:contain!important}
html[data-theme="sylva"] .codex-icon-choice{background:linear-gradient(180deg,#ebe3d6,#ded2bf)!important;color:#31402f!important;border-color:rgba(118,106,88,.20)!important}
html[data-theme="sylva"] .category-row.active .category-main,
html[data-theme="sylva"] .category-item.active{background:linear-gradient(180deg,#e7dfd2,#d9e3d4)!important;color:#2b392c!important}
html[data-theme="sylva"] .category-row.active .category-icon,
html[data-theme="sylva"] .category-item.active .category-icon{background:#f0e9dc!important;color:#40513f!important}

/* Selective light state elsewhere, without turning whole pages into a light theme. */
html[data-theme="sylva"] .planning-scene-row.active{
  background:linear-gradient(180deg,#e7dfd2,#d9e3d4)!important;color:#2c3a2d!important;border-color:#a7b69f!important;
}
html[data-theme="sylva"] .planning-scene-row.active *{color:inherit}

/* Height safety: always larger than the previous tiny icons. */
@media(max-height:900px) and (min-width:901px){
  html[data-theme="sylva"] #rail .rail-nav{gap:2px;margin-top:7px}
  html[data-theme="sylva"] #rail .rail-btn{padding:4px 2px;gap:1px;min-height:52px}
  html[data-theme="sylva"] #rail .rail-icon-wrap{width:36px!important;height:36px!important;flex-basis:36px;background-size:84% auto!important;border-radius:12px}
  html[data-theme="sylva"] #rail .rail-btn small{font-size:8px}
  html[data-theme="sylva"] #rail .brand.sylva-brand-button{width:44px;height:44px}
}

/* Tablet: existing overlay/menu positioning is kept; only visual sizing changes. */
@media (pointer:coarse) and (min-width:561px) and (max-width:1366px){
  html[data-theme="sylva"] #rail{width:82px!important;padding-left:7px!important;padding-right:7px!important}
  html[data-theme="sylva"] #rail .rail-btn{width:66px!important;min-height:62px!important;padding:5px 2px!important;gap:2px!important}
  html[data-theme="sylva"] #rail .rail-icon-wrap{width:43px!important;height:43px!important;flex:0 0 43px!important;background-size:84% auto!important;border-radius:14px!important}
  html[data-theme="sylva"] #rail .rail-btn small{font-size:8.5px!important}
  html[data-theme="sylva"] #rail .brand.sylva-brand-button{width:48px!important;height:48px!important}
  html[data-theme="sylva"] .topbar-center{box-shadow:none!important}
}
@media(max-width:900px){
  html[data-theme="sylva"] #rail{width:80px!important}
  html[data-theme="sylva"] #rail .rail-btn{width:64px!important;min-height:60px!important}
  html[data-theme="sylva"] #rail .rail-icon-wrap{width:42px!important;height:42px!important;flex-basis:42px!important}
}
@media(prefers-reduced-motion:reduce){html[data-theme="sylva"] #rail .rail-icon-wrap{transition:none!important}}

/* === SYLVA HYBRID V3.1 — tablet/icon audit ===
   No layout/data logic changes. Normalized PNG artwork + touch-safe interaction. */
html[data-theme="sylva"] #rail .rail-icon-wrap{
  background-size:92% auto!important;
}
html[data-theme="sylva"] #rail .rail-icon-wrap,
html[data-theme="sylva"] .codex-card-symbol .sylva-codex-icon{
  image-rendering:auto;
}

/* Short desktop: keep the compact rail but no longer collapse the artwork. */
@media(max-height:900px) and (min-width:901px){
  html[data-theme="sylva"] #rail .rail-icon-wrap{
    width:38px!important;height:38px!important;flex-basis:38px!important;
    background-size:92% auto!important;
  }
}

/* Tablet/coarse pointer: large touch targets, real 44px medallions and scroll-safe rail. */
@media (pointer:coarse) and (min-width:561px) and (max-width:1366px){
  html[data-theme="sylva"] #rail{
    overscroll-behavior:contain!important;
    -webkit-overflow-scrolling:touch;
    touch-action:pan-y;
  }
  html[data-theme="sylva"] #rail .rail-icon-wrap{
    width:44px!important;height:44px!important;flex:0 0 44px!important;
    background-size:92% auto!important;
  }
  /* Touch browsers can keep :hover after a tap. Neutralize it and use :active instead. */
  html[data-theme="sylva"] #rail .rail-btn:not(.active):hover .rail-icon-wrap{
    transform:none!important;
    background-color:var(--sylva-ivory)!important;
    border-color:rgba(118,106,88,.25)!important;
    box-shadow:var(--sylva-paper-shadow)!important;
  }
  html[data-theme="sylva"] #rail .rail-btn.active:hover .rail-icon-wrap{
    transform:none!important;
    background-color:var(--sylva-sage-paper)!important;
    border-color:var(--sylva-sage-line)!important;
    box-shadow:0 8px 22px rgba(0,0,0,.24),0 0 0 2px rgba(156,173,148,.10),inset 0 1px rgba(255,255,255,.52)!important;
  }
  html[data-theme="sylva"] #rail .rail-btn:active .rail-icon-wrap{
    transform:scale(.965)!important;
  }
}
@media(max-width:900px){
  html[data-theme="sylva"] #rail .rail-icon-wrap{
    width:44px!important;height:44px!important;flex-basis:44px!important;
    background-size:92% auto!important;
  }
}


/* ==========================================================================
   SYLVA HOME + QUIET WRITER — visual refactor 2026-08-14
   Home is the app entry point. Writer chrome is summoned by the Sylva mark.
   ========================================================================== */
.writer-nav-toggle{display:none}

/* Home owns the full viewport: no application chrome around the landing page. */
html[data-route="home"] .app-shell{display:grid;grid-template-columns:1fr;grid-template-rows:1fr;gap:0;padding:0}
html[data-route="home"] #rail,html[data-route="home"] .topbar{display:none!important}
html[data-route="home"] .main-area{grid-column:1;grid-row:1;width:100%;height:100dvh;min-height:0}
html[data-route="home"] #homeView{display:flex;min-height:0}
html[data-route="home"] .ambient{opacity:.045}
.home-view{width:min(1440px,100%);max-width:none!important;padding:44px clamp(24px,5vw,76px) 70px!important;scrollbar-gutter:stable both-edges}
.home-hero{min-height:320px;display:flex;flex-direction:column;align-items:center;justify-content:flex-start;text-align:center;padding:8px 16px 62px;border-bottom:1px solid color-mix(in srgb,var(--line) 78%,transparent)}
.home-logo-lockup{display:flex;flex-direction:column;align-items:center;justify-content:center;margin:0 0 18px;padding:14px 44px 22px;line-height:1;border-radius:44px;background:radial-gradient(ellipse at 50% 48%,rgba(243,238,229,.98) 0 58%,rgba(243,238,229,.78) 64%,transparent 73%)}
.home-logo-symbol{width:clamp(118px,10vw,156px);height:auto;display:block;filter:drop-shadow(0 12px 24px rgba(0,0,0,.08))}
.home-logo-wordmark{font:400 clamp(62px,6.4vw,92px)/.68 "Allura",cursive;letter-spacing:0;color:#2d2923;margin-top:-17px}
.home-hero>small,.home-section-head small{font:650 9px/1.2 Inter,sans-serif;letter-spacing:.19em;color:var(--accent);text-transform:uppercase}
.home-hero h1{font-family:var(--ui-serif,Georgia,serif);font-size:clamp(31px,3.2vw,48px);font-weight:430;line-height:1.08;letter-spacing:-.035em;margin:18px 0 12px;max-width:760px}
.home-hero p{max-width:680px;margin:0;color:var(--muted);font-size:13px;line-height:1.7}
.home-section{padding:56px 0 4px}
.home-section+.home-section{margin-top:22px;border-top:1px solid color-mix(in srgb,var(--line) 72%,transparent)}
.home-section-head{display:flex;align-items:flex-end;justify-content:space-between;gap:30px;margin-bottom:28px}
.home-section-head.compact{margin-bottom:22px}
.home-section-head>div:first-child{max-width:720px}
.home-section-head h2{font-family:var(--ui-serif,Georgia,serif);font-size:clamp(25px,2.2vw,34px);font-weight:470;letter-spacing:-.025em;margin:7px 0 7px}
.home-section-head p{font-size:11px;line-height:1.6;color:var(--muted);margin:0}
.home-heading-actions{display:flex;align-items:center;justify-content:flex-end;flex-wrap:wrap}
.home-library-section .book-library-stack{gap:34px}
.home-library-section .saga-shelf{padding:22px;border-radius:28px}
.home-library-section .saga-shelf-head{margin-bottom:16px}
.home-library-section .book-library-grid{grid-template-columns:repeat(auto-fill,minmax(330px,1fr));gap:18px}
.home-library-section .book-card{min-height:250px;padding:24px;border-radius:26px}
.home-library-section .book-card:hover{transform:translateY(-3px)}
.home-export-actions{grid-template-columns:repeat(4,minmax(0,1fr));gap:14px;margin-top:0}
.home-export-actions .big-action{min-height:148px;padding:22px;border-radius:24px}
.home-export-actions .big-action .action-icon{width:30px;height:30px;margin-bottom:12px}
.home-export-actions .big-action b{font-size:13px}
.home-export-actions .big-action small{font-size:9px;line-height:1.5}
.home-import-row{display:flex;align-items:center;gap:14px;margin-top:14px;padding-left:2px;color:var(--muted)}
.home-import-row span{font-size:9px;line-height:1.4}
.home-info-grid{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:14px}
.home-info-card{min-height:148px;text-align:left;border-radius:24px;padding:22px;display:flex;flex-direction:column;align-items:flex-start;transition:transform .22s ease,background .22s ease,border-color .22s ease}
.home-info-card:hover{transform:translateY(-2px);background:var(--surface)}
.home-info-card span{font:650 8px/1 Inter,sans-serif;letter-spacing:.13em;text-transform:uppercase;color:var(--accent)}
.home-info-card b{font-family:var(--ui-serif,Georgia,serif);font-size:18px;font-weight:520;margin:13px 0 7px}
.home-info-card small{font-size:10px;line-height:1.55;color:var(--muted);max-width:34ch}
.home-footer{display:flex;justify-content:space-between;align-items:center;gap:20px;margin-top:60px;padding:25px 2px 5px;border-top:1px solid var(--line);color:var(--muted)}
.home-footer span{font:500 10px Inter,sans-serif;letter-spacing:.16em;text-transform:uppercase;color:var(--text)}
.home-footer small{font-size:9px}

/* Writer: paper first. The permanent rail/topbar become animated overlays. */
html[data-route="writer"] .app-shell{display:grid;grid-template-columns:1fr;grid-template-rows:1fr;gap:0;padding:0;overflow:hidden}
html[data-route="writer"] .main-area{grid-column:1;grid-row:1;width:100%;height:100dvh;min-height:0}
html[data-route="writer"] #writerView{position:relative;width:100%;height:100%;padding:0}
html[data-route="writer"] .writer-nav-toggle{display:grid;place-items:center;position:fixed;left:max(18px,calc(env(safe-area-inset-left) + 12px));top:max(18px,calc(env(safe-area-inset-top) + 12px));width:58px;height:58px;padding:6px;border:1px solid rgba(118,106,88,.24);border-radius:18px;background:linear-gradient(180deg,#f3eee5,#e5dac9);box-shadow:0 10px 34px rgba(0,0,0,.12);backdrop-filter:blur(18px);z-index:180;transition:transform .28s cubic-bezier(.2,.8,.2,1),box-shadow .28s ease,background .28s ease}
html[data-route="writer"] .writer-nav-toggle img{width:47px;height:40px;object-fit:contain;display:block;transition:transform .38s cubic-bezier(.2,.8,.2,1)}
html[data-route="writer"] .writer-nav-toggle:hover{transform:translateY(-1px);box-shadow:0 14px 38px rgba(0,0,0,.16)}
html[data-route="writer"].writer-chrome-open .writer-nav-toggle img{transform:rotate(-8deg) scale(.94)}
html[data-route="writer"] #rail{position:fixed!important;left:12px!important;top:12px!important;bottom:12px!important;width:76px!important;height:auto!important;grid-row:auto!important;transform:translateX(calc(-100% - 34px));opacity:0;pointer-events:none;z-index:150;transition:transform .42s cubic-bezier(.2,.82,.2,1),opacity .25s ease;padding-top:76px!important}
html[data-route="writer"] .topbar{position:fixed!important;left:100px!important;right:12px!important;top:12px!important;height:68px!important;grid-column:auto!important;transform:translateY(calc(-100% - 38px));opacity:0;pointer-events:none;z-index:145;transition:transform .42s cubic-bezier(.2,.82,.2,1),opacity .25s ease}
html[data-route="writer"].writer-chrome-open #rail{transform:translateX(0);opacity:1;pointer-events:auto}
html[data-route="writer"].writer-chrome-open .topbar{transform:translateY(0);opacity:1;pointer-events:auto}

@keyframes sylvaRailItemIn{from{opacity:0;transform:translateX(-8px) scale(.96)}to{opacity:1;transform:none}}
@keyframes sylvaTopItemIn{from{opacity:0;transform:translateY(-6px)}to{opacity:1;transform:none}}
html[data-route="writer"].writer-chrome-open #rail .rail-btn{animation:sylvaRailItemIn .34s cubic-bezier(.2,.8,.2,1) both}
html[data-route="writer"].writer-chrome-open #rail .rail-nav .rail-btn:nth-child(2){animation-delay:.025s}
html[data-route="writer"].writer-chrome-open #rail .rail-nav .rail-btn:nth-child(3){animation-delay:.05s}
html[data-route="writer"].writer-chrome-open #rail .rail-nav .rail-btn:nth-child(4){animation-delay:.075s}
html[data-route="writer"].writer-chrome-open #rail .rail-nav .rail-btn:nth-child(5){animation-delay:.10s}
html[data-route="writer"].writer-chrome-open #rail .rail-nav .rail-btn:nth-child(6){animation-delay:.125s}
html[data-route="writer"].writer-chrome-open #rail .rail-nav .rail-btn:nth-child(n+7){animation-delay:.15s}
html[data-route="writer"].writer-chrome-open .topbar>div{animation:sylvaTopItemIn .38s .08s cubic-bezier(.2,.8,.2,1) both}
html[data-route="writer"] #rail .brand{display:none!important}

html[data-route="writer"] .structure-panel,html[data-route="writer"] #structureHandle{display:none!important}
html[data-route="writer"] .editor-stage{width:100%;height:100%;min-width:0}
html[data-route="writer"] .document-meta{display:none!important}
html[data-route="writer"] .editor-viewport{padding-top:86px!important;padding-left:clamp(20px,5vw,84px)!important;padding-right:clamp(20px,5vw,84px)!important}
html[data-route="writer"] .floating-toolbar{z-index:80}

/* Smartphone: same homepage, limited to library/export. No separate phone microsite. */
html.phone-only.workspace-entered body{overflow:hidden!important}
html.phone-only.workspace-entered #app{display:grid!important;visibility:visible!important;pointer-events:auto!important}
html.phone-only.workspace-entered .phone-access{display:none!important}
html.phone-only.workspace-entered #modalBackdrop{display:flex!important}
html.phone-only[data-route="home"] .home-view{padding:max(22px,env(safe-area-inset-top)) 15px max(36px,calc(env(safe-area-inset-bottom) + 22px))!important}
html.phone-only[data-route="home"] .home-hero{min-height:auto;padding:4px 6px 38px}
html.phone-only[data-route="home"] .home-logo-symbol{width:100px}
html.phone-only[data-route="home"] .home-logo-wordmark{font-size:58px;margin-top:-14px}
html.phone-only[data-route="home"] .home-hero h1{font-size:30px;margin-top:15px}
html.phone-only[data-route="home"] .home-hero p{font-size:12px}
html.phone-only[data-route="home"] .home-section{padding-top:38px}
html.phone-only[data-route="home"] .home-section-head{align-items:flex-start;flex-direction:column;gap:16px;margin-bottom:20px}
html.phone-only[data-route="home"] .home-heading-actions,html.phone-only[data-route="home"] #openProjectBtn{display:none!important}
html.phone-only[data-route="home"] .home-import-row span{font-size:9px}
html.phone-only[data-route="home"] .book-library-grid{grid-template-columns:1fr!important}
html.phone-only[data-route="home"] .saga-shelf{padding:12px;border-radius:22px}
html.phone-only[data-route="home"] .book-card{min-height:0;padding:18px;border-radius:22px}
html.phone-only[data-route="home"] .book-card-actions{display:none!important}
html.phone-only[data-route="home"] .book-open-btn{pointer-events:auto;opacity:.55}
html.phone-only[data-route="home"] .home-export-actions{grid-template-columns:1fr 1fr;gap:10px}
html.phone-only[data-route="home"] .home-export-actions .big-action{min-height:118px;padding:17px;border-radius:20px}
html.phone-only[data-route="home"] .home-info-grid{grid-template-columns:1fr}
html.phone-only[data-route="home"] .home-info-card{min-height:112px;padding:18px}

@media (max-width:1050px){
  .home-export-actions{grid-template-columns:repeat(2,minmax(0,1fr))}
  .home-info-grid{grid-template-columns:1fr 1fr}.home-info-card:last-child{grid-column:1/-1}
}
@media (max-width:900px), (pointer:coarse) and (min-width:561px) and (max-width:1366px){
  .home-view{padding:34px 24px 62px!important}.home-hero{min-height:280px;padding-bottom:48px}
  .home-section{padding-top:46px}.home-section-head{gap:20px}.home-library-section .book-library-grid{grid-template-columns:repeat(2,minmax(0,1fr));gap:14px}
  html[data-route="writer"] .writer-nav-toggle{width:54px;height:54px;border-radius:17px;left:max(14px,calc(env(safe-area-inset-left) + 8px));top:max(14px,calc(env(safe-area-inset-top) + 8px))}
  html[data-route="writer"] .writer-nav-toggle img{width:44px;height:37px}
  html[data-route="writer"] #rail{left:10px!important;top:10px!important;bottom:10px!important;padding-top:68px!important}
  html[data-route="writer"] .topbar{left:98px!important;right:10px!important;top:10px!important;height:auto!important;min-height:64px!important}
  html[data-route="writer"] .editor-viewport{padding-top:82px!important;padding-left:22px!important;padding-right:22px!important}
}
@media (max-width:680px){
  .home-view{padding:24px 15px 46px!important}.home-hero{padding:0 4px 38px}.home-logo-symbol{width:104px}.home-logo-wordmark{font-size:60px;margin-top:-14px}
  .home-hero h1{font-size:31px}.home-section{padding-top:38px}.home-section-head{align-items:flex-start;flex-direction:column;gap:16px;margin-bottom:20px}.home-heading-actions{width:100%;justify-content:flex-start}
  .home-library-section .book-library-grid{grid-template-columns:1fr}.home-export-actions{grid-template-columns:1fr 1fr}.home-info-grid{grid-template-columns:1fr}.home-info-card:last-child{grid-column:auto}.home-footer{align-items:flex-start;flex-direction:column;gap:7px;margin-top:42px}
}
@media(prefers-reduced-motion:reduce){
  html[data-route="writer"] #rail,html[data-route="writer"] .topbar,html[data-route="writer"] .writer-nav-toggle,html[data-route="writer"] .writer-nav-toggle img{transition:none!important}
}

.book-mobile-exports{display:none}
html.phone-only[data-route="home"] .book-mobile-exports{display:grid;grid-template-columns:.72fr .9fr 1.35fr;gap:8px;margin-top:14px;padding-top:14px;border-top:1px solid var(--line)}
html.phone-only[data-route="home"] .book-mobile-exports button{min-height:42px;font-size:10px}

html.phone-only[data-route="home"] #bookStatusCenter{display:none!important}

html.phone-only[data-route="home"] .home-import-row{display:none!important}


/* ==========================================================================\n   SYLVA 0.833 — SINGLE THEME / QUIET EDITOR\n   One coherent visual language: warm paper, forest ink, restrained gold.\n   ========================================================================== */
html[data-theme="sylva"]{
  color-scheme:light!important;
  --bg:#f1ece3!important;--bg2:#ebe5db!important;
  --surface:rgba(255,253,249,.88)!important;--surface-2:#f5f0e8!important;--surface-strong:#fffdfa!important;
  --paper:#fffefa!important;--text:#222923!important;--muted:#80796f!important;--line:rgba(67,72,63,.12)!important;
  --accent:#214737!important;--accent-2:#bc8d50!important;--accent-soft:rgba(33,71,55,.08)!important;
  --danger:#a9554e!important;--danger-soft:rgba(169,85,78,.08)!important;--shadow:0 18px 50px rgba(76,66,51,.08)!important;
  --sylva-ink:#26362d!important;--sylva-paper-muted:#7d776e!important;--sylva-orange:#bc8d50!important;
  --ui-serif:Georgia,"Times New Roman",serif!important;
}
html[data-theme="sylva"] body{background:linear-gradient(135deg,#f0ebe3 0%,#f7f3ec 46%,#eee8de 100%)!important;color:var(--text)!important}
html[data-theme="sylva"] body::before,html[data-theme="sylva"] body::after{display:none!important}
html[data-theme="sylva"] .ambient{display:none!important}
html[data-theme="sylva"] .glass,html[data-theme="sylva"] .glass-lite{backdrop-filter:none!important;-webkit-backdrop-filter:none!important}

/* Home */
html[data-route="home"] .app-shell{background:transparent!important}
.home-view{width:min(1260px,100%)!important;padding:32px clamp(18px,4vw,56px) 48px!important;margin:auto}
.home-hero{min-height:250px!important;padding:18px 12px 46px!important;border:0!important}
.home-logo-lockup{width:min(610px,82vw)!important;height:auto!important;margin:0 auto 6px!important;padding:0!important;border:0!important;background:transparent!important;border-radius:0!important;box-shadow:none!important}
.home-logo-full{display:block;width:100%;height:auto;object-fit:contain;filter:none!important}
.home-hero>small{color:#a37945!important;margin-top:8px}
.home-hero h1{font-family:Georgia,"Times New Roman",serif!important;color:#25382e!important;font-size:clamp(27px,3vw,39px)!important;font-weight:400!important;letter-spacing:-.035em!important;margin:14px 0 7px!important}
.home-hero p{font-size:12px!important;color:#80796f!important;max-width:600px!important}
.home-section{padding:32px 0 0!important;margin:0!important;border:0!important}
.home-section+.home-section{margin-top:18px!important;border-top:1px solid rgba(70,72,64,.10)!important}
.home-section-head{margin-bottom:18px!important;align-items:center!important}
.home-section-head h2{font-family:Georgia,"Times New Roman",serif!important;font-size:25px!important;font-weight:400!important;color:#26362d!important;margin:5px 0!important}
.home-section-head p{font-size:10px!important}
.home-heading-actions{gap:8px!important}
.home-heading-actions .soft-btn,.home-heading-actions .primary-btn{min-height:40px!important;border-radius:12px!important;padding:0 14px!important}
.book-status-center{display:none!important}
.book-library-stack{display:flex!important;flex-direction:column!important;gap:30px!important}
.home-shelf{display:block}
.home-shelf-head{display:flex;align-items:flex-end;justify-content:space-between;gap:16px;margin:0 0 14px;padding:0 2px}
.home-shelf-head small{font:650 8px/1 Inter,sans-serif;letter-spacing:.16em;color:#a37945}
.home-shelf-head h2{margin:5px 0 0;font:400 21px/1.1 Georgia,serif;color:#25382e}
.home-shelf-head>span{font:500 9px Inter,sans-serif;color:#8c857b}
.home-library-section .book-library-grid,.book-library-grid{display:grid!important;grid-template-columns:repeat(4,minmax(0,1fr))!important;gap:14px!important}
.sylva-book-card{display:grid!important;grid-template-columns:112px minmax(0,1fr)!important;min-height:160px!important;padding:0!important;overflow:hidden!important;border:1px solid rgba(62,68,60,.11)!important;border-radius:16px!important;background:rgba(255,253,249,.72)!important;box-shadow:0 7px 24px rgba(82,71,54,.04)!important;transition:transform .2s ease,box-shadow .2s ease,border-color .2s ease!important}
.sylva-book-card:hover{transform:translateY(-2px)!important;box-shadow:0 12px 26px rgba(82,71,54,.08)!important;border-color:rgba(64,91,74,.20)!important}
.sylva-book-card.active-book{border-color:rgba(33,71,55,.27)!important}
.book-cover-button{position:relative;display:block;width:112px;height:160px;border:0;padding:0;margin:0;background:#eee7dc;overflow:hidden;cursor:pointer}
.book-cover{width:100%;height:100%;display:block;object-fit:cover}
.book-cover-shade{position:absolute;inset:0;box-shadow:inset -12px 0 22px rgba(26,43,34,.04);pointer-events:none}
.book-card-body{position:relative;min-width:0;padding:15px 13px 11px;display:flex;flex-direction:column}
.book-card-title-row{display:flex;align-items:flex-start;justify-content:space-between;gap:10px}
.book-card-title-row small{font:650 7px/1.2 Inter,sans-serif;letter-spacing:.12em;color:#9a7a51;text-transform:uppercase}
.book-card-title-row h3{font:500 14px/1.17 Georgia,serif!important;color:#26362d!important;margin:6px 0 0;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden}
.book-sync-dot{width:8px;height:8px;border-radius:50%;flex:0 0 auto;margin-top:2px;background:#d75d58;box-shadow:0 0 0 3px rgba(215,93,88,.07)}
.book-sync-dot.syncing,.book-sync-dot.pending{background:#4b91d6;box-shadow:0 0 0 3px rgba(75,145,214,.08)}
.book-sync-dot.synced{background:#58ad66;box-shadow:0 0 0 3px rgba(88,173,102,.08)}
.book-sync-dot.local{background:#c8a36a;box-shadow:0 0 0 3px rgba(200,163,106,.08)}
.book-card-facts{display:flex;gap:8px;flex-wrap:wrap;margin-top:10px;font:500 8px Inter,sans-serif;color:#847d73}
.book-card-facts span+span::before{content:"·";margin-right:8px;color:#b4aa9c}
.book-card-actions.compact{position:absolute!important;right:8px!important;bottom:8px!important;display:flex!important;gap:2px!important}
.sylva-book-card .book-icon-btn{width:30px!important;height:30px!important;min-height:30px!important;border-radius:9px!important;color:#756e65!important}
.sylva-book-card .book-mobile-exports{display:none}
.saga-home-grid{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:12px}
.sylva-saga-card{position:relative;min-height:118px;padding:17px 43px 17px 17px;border:1px solid rgba(62,68,60,.10);border-radius:16px;background:linear-gradient(135deg,#efe3d9,#f3eee7 45%,#e7e8dd);overflow:hidden}
.sylva-saga-card:nth-child(3n+2){background:linear-gradient(135deg,#e9e4d8,#f4f0e8 48%,#dde1d4)}
.sylva-saga-card:nth-child(3n+3){background:linear-gradient(135deg,#e6e3da,#f5f0e8 48%,#d9ded4)}
.saga-botanical{position:absolute;right:-18px;bottom:-28px;width:130px;height:130px;opacity:.20;background:url("assets/sylva-symbol-green.png") center/contain no-repeat;filter:saturate(.65)}
.sylva-saga-card small{font:650 7px Inter,sans-serif;letter-spacing:.14em;color:#98754a}
.sylva-saga-card h3{position:relative;margin:8px 0 6px;font:500 14px/1.2 Georgia,serif;color:#2b392f}
.sylva-saga-card p{position:relative;margin:0;font:500 8px Inter,sans-serif;color:#756f66}
.sylva-saga-card .saga-edit-btn{position:absolute;right:9px;top:9px}
.saga-empty-card{min-height:90px;border:1px dashed rgba(62,68,60,.15);border-radius:16px;display:grid;place-items:center;padding:20px;text-align:center;font:500 9px Inter,sans-serif;color:#8d857a}
.sylva-empty{padding:46px!important;background:rgba(255,253,249,.58)!important;border:1px dashed rgba(62,68,60,.14)!important;border-radius:18px!important}
.sylva-empty img{width:64px;height:64px;object-fit:contain;opacity:.65;margin-bottom:8px}
.home-export-actions{grid-template-columns:repeat(4,minmax(0,1fr))!important;gap:10px!important}
.home-export-actions .big-action{min-height:104px!important;padding:15px!important;border-radius:15px!important;background:rgba(255,253,249,.66)!important;border:1px solid rgba(62,68,60,.10)!important;text-align:left!important}
.home-export-actions .big-action .action-icon{width:25px!important;height:25px!important;margin-bottom:9px!important;color:#355d47!important}
.home-export-actions .big-action b{font-size:11px!important;color:#2f3b33!important}.home-export-actions .big-action small{font-size:8px!important}
.home-info-grid{gap:10px!important}.home-info-card{min-height:110px!important;border-radius:15px!important;padding:16px!important;background:rgba(255,253,249,.66)!important;border:1px solid rgba(62,68,60,.10)!important}.home-info-card b{font:500 14px Georgia,serif!important;color:#2c3931!important;margin:9px 0 5px!important}.home-info-card small{font-size:8px!important}.home-footer{margin-top:38px!important;padding-top:18px!important}

/* Desktop/tablet editor: expanded menu stays visible. */
html[data-route="writer"] .app-shell{display:grid!important;grid-template-columns:224px minmax(0,1fr)!important;grid-template-rows:72px minmax(0,1fr)!important;gap:0!important;padding:0!important;background:#fffdfa!important}
html[data-route="writer"] #rail{display:flex!important;position:relative!important;left:auto!important;top:auto!important;bottom:auto!important;grid-column:1!important;grid-row:1/3!important;width:224px!important;height:100dvh!important;transform:none!important;opacity:1!important;pointer-events:auto!important;z-index:30!important;padding:18px 12px!important;border:0!important;border-right:1px solid rgba(65,68,61,.10)!important;border-radius:0!important;background:linear-gradient(180deg,#f8f4ed,#f2ede5)!important;box-shadow:none!important;overflow-y:auto!important}
html[data-route="writer"] #rail .brand{display:flex!important;width:100%!important;height:82px!important;min-height:82px!important;padding:6px 10px 16px!important;margin:0 0 8px!important;border:0!important;background:transparent!important;box-shadow:none!important;justify-content:flex-start!important}
html[data-route="writer"] #rail .brand img{width:126px!important;height:auto!important;max-height:58px!important;object-fit:contain!important;object-position:left center!important}
html[data-route="writer"] #rail .rail-nav{display:flex!important;flex-direction:column!important;gap:3px!important;width:100%!important;margin:0!important}
html[data-route="writer"] #rail .rail-bottom{margin-top:auto!important;width:100%!important;padding-top:12px!important;border-top:1px solid rgba(65,68,61,.10)!important}
html[data-route="writer"] #rail .rail-btn{display:grid!important;grid-template-columns:38px minmax(0,1fr)!important;align-items:center!important;justify-content:start!important;width:100%!important;min-height:47px!important;height:auto!important;padding:5px 10px!important;gap:8px!important;border-radius:11px!important;background:transparent!important;color:#46564c!important;text-align:left!important}
html[data-route="writer"] #rail .rail-btn:hover{background:rgba(33,71,55,.055)!important;color:#214737!important}
html[data-route="writer"] #rail .rail-btn.active{background:rgba(33,71,55,.085)!important;color:#214737!important}
html[data-route="writer"] #rail .rail-btn.active::after{display:none!important}
html[data-route="writer"] #rail .rail-icon-wrap{display:grid!important;place-items:center!important;width:34px!important;height:34px!important;flex:0 0 34px!important;background:none!important;border:0!important;border-radius:9px!important;transform:none!important}
html[data-route="writer"] #rail .rail-icon-wrap>.rail-icon.theme-icon-default{display:block!important;visibility:visible!important;width:22px!important;height:22px!important;stroke:currentColor!important;fill:none!important;stroke-width:1.7!important}
html[data-route="writer"] #rail .rail-icon-wrap>.rail-icon.theme-icon-nature{display:none!important}
html[data-route="writer"] #rail .rail-btn small{display:block!important;font:540 11px/1.1 Inter,sans-serif!important;color:inherit!important;white-space:nowrap!important}
html[data-route="writer"] .topbar{position:relative!important;left:auto!important;right:auto!important;top:auto!important;grid-column:2!important;grid-row:1!important;width:100%!important;height:72px!important;min-height:72px!important;transform:none!important;opacity:1!important;pointer-events:auto!important;z-index:25!important;border:0!important;border-bottom:1px solid rgba(65,68,61,.10)!important;border-radius:0!important;background:rgba(255,253,249,.96)!important;box-shadow:none!important;padding:0 22px!important}
html[data-route="writer"] .main-area{grid-column:2!important;grid-row:2!important;width:100%!important;height:calc(100dvh - 72px)!important;background:#fffdfa!important;overflow:hidden!important}
html[data-route="writer"] .writer-nav-toggle{display:none!important}
html[data-route="writer"] .topbar-left{min-width:0!important;display:flex!important;align-items:center!important}
html[data-route="writer"] .book-title-top{font-family:var(--editor-font,Georgia,serif)!important;font-size:20px!important;line-height:1.05!important;font-weight:600!important;letter-spacing:-.015em!important;color:#27352d!important;max-width:min(48vw,620px)!important}
html[data-route="writer"] .save-lines{height:12px!important;margin-top:4px!important;display:flex!important;align-items:center!important;gap:0!important}
html[data-route="writer"] .save-state{display:none!important}
html[data-route="writer"] .cloud-state{display:block!important;width:8px!important;height:8px!important;min-width:8px!important;max-width:8px!important;padding:0!important;border:0!important;border-radius:50%!important;overflow:hidden!important;text-indent:-9999px!important;background:#d85b57!important;box-shadow:0 0 0 3px rgba(216,91,87,.07)!important}
html[data-route="writer"] .cloud-state[data-state="syncing"],html[data-route="writer"] .cloud-state[data-state="pending"]{background:#4d96dc!important;box-shadow:0 0 0 3px rgba(77,150,220,.08)!important}
html[data-route="writer"] .cloud-state[data-state="synced"]{background:#58af68!important;box-shadow:0 0 0 3px rgba(88,175,104,.08)!important}
html[data-route="writer"] .topbar-center,html[data-route="writer"] .topbar-actions{display:none!important}
html[data-route="writer"] #writerView{height:100%!important;padding:0!important;background:#fffdfa!important}
html[data-route="writer"] .editor-stage{height:100%!important;background:#fffdfa!important}
html[data-route="writer"] .editor-viewport{height:100%!important;padding:74px clamp(28px,6vw,88px) 44px!important;background:#fffdfa!important}
html[data-route="writer"] .multi-scene-editor{max-width:980px!important;margin:0 auto!important}
html[data-route="writer"] .scene-sheet{background:transparent!important;border:0!important;border-radius:0!important;box-shadow:none!important;padding:48px clamp(20px,5vw,68px) 74px!important;min-height:72vh!important}
html[data-route="writer"] .scene-editor{color:#282d29!important;caret-color:#2e4e3d!important}
html[data-route="writer"] .floating-toolbar{position:absolute!important;top:18px!important;left:50%!important;right:auto!important;transform:translateX(-50%)!important;width:max-content!important;max-width:calc(100% - 40px)!important;min-height:42px!important;padding:4px 7px!important;border:1px solid rgba(62,68,60,.10)!important;border-radius:11px!important;background:#fbf8f2!important;box-shadow:0 4px 14px rgba(79,69,52,.04)!important;overflow-x:auto!important;scrollbar-width:none!important}
html[data-route="writer"] .floating-toolbar::-webkit-scrollbar{display:none}
html[data-route="writer"] .floating-toolbar button,html[data-route="writer"] .floating-toolbar select{min-height:32px!important;height:32px!important;border-radius:8px!important;color:#5b5c56!important}
html[data-route="writer"] .document-meta,html[data-route="writer"] .structure-panel,html[data-route="writer"] #structureHandle{display:none!important}

/* Cover editor */
.book-cover-editor{display:grid;grid-template-columns:94px minmax(0,1fr);gap:16px;align-items:center;padding:14px;margin:14px 0 18px;border:1px solid var(--line);border-radius:14px;background:var(--surface-2)}
.cover-preview{width:78px;height:104px;border-radius:10px;overflow:hidden;background:#ece6dc;border:1px solid var(--line)}.cover-preview img{width:100%;height:100%;object-fit:cover}.book-cover-editor>div:last-child{display:flex;flex-direction:column;align-items:flex-start;gap:7px}.book-cover-editor b{font-size:11px}.book-cover-editor small{font-size:8px;line-height:1.45;color:var(--muted)}.cover-editor-actions{display:flex;gap:7px;flex-wrap:wrap}.cover-editor-actions button{min-height:34px!important}

/* Narrow tablet / mobile editor: sidebar becomes a drawer summoned by logo. */
@media(max-width:980px){
 html[data-route="writer"] .app-shell{grid-template-columns:1fr!important;grid-template-rows:66px minmax(0,1fr)!important}
 html[data-route="writer"] .topbar{grid-column:1!important;grid-row:1!important;height:66px!important;min-height:66px!important;padding-left:78px!important;padding-right:16px!important}
 html[data-route="writer"] .main-area{grid-column:1!important;grid-row:2!important;height:calc(100dvh - 66px)!important}
 html[data-route="writer"] .writer-nav-toggle{display:grid!important;position:fixed!important;left:max(10px,calc(env(safe-area-inset-left) + 8px))!important;top:max(10px,calc(env(safe-area-inset-top) + 8px))!important;width:48px!important;height:48px!important;padding:6px!important;border:1px solid rgba(62,68,60,.13)!important;border-radius:12px!important;background:#f8f4ed!important;box-shadow:0 5px 18px rgba(79,69,52,.08)!important;z-index:80!important}
 html[data-route="writer"] .writer-nav-toggle img{width:36px!important;height:36px!important;object-fit:contain!important}
 html[data-route="writer"] #rail{position:fixed!important;left:0!important;top:0!important;bottom:0!important;width:min(280px,82vw)!important;height:100dvh!important;z-index:75!important;transform:translateX(-104%)!important;opacity:0!important;pointer-events:none!important;box-shadow:14px 0 42px rgba(58,51,42,.13)!important;transition:transform .27s cubic-bezier(.2,.8,.2,1),opacity .2s ease!important;padding-top:72px!important}
 html[data-route="writer"].writer-chrome-open #rail{transform:translateX(0)!important;opacity:1!important;pointer-events:auto!important}
 html[data-route="writer"] #rail .brand{display:none!important}
 html[data-route="writer"] .book-title-top{font-size:18px!important;max-width:62vw!important}
 html[data-route="writer"] .editor-viewport{padding:70px 18px 30px!important}
 html[data-route="writer"] .scene-sheet{padding:35px 10px 60px!important}
 html[data-route="writer"] .floating-toolbar{top:14px!important;max-width:calc(100% - 24px)!important}
}

/* Home tablet */
@media(max-width:1100px){.home-library-section .book-library-grid,.book-library-grid{grid-template-columns:repeat(2,minmax(0,1fr))!important}.saga-home-grid{grid-template-columns:repeat(2,minmax(0,1fr))}.home-export-actions{grid-template-columns:repeat(2,minmax(0,1fr))!important}}
@media(max-width:700px){
 .home-view{padding:20px 14px 34px!important}.home-hero{padding-bottom:30px!important}.home-logo-lockup{width:min(460px,94vw)!important}.home-hero h1{font-size:26px!important}.home-hero>small{font-size:7px!important}
 .home-section-head{align-items:flex-start!important;flex-direction:column!important;gap:12px!important}.home-heading-actions{width:100%!important}.home-heading-actions button{flex:1!important}
 .home-library-section .book-library-grid,.book-library-grid{grid-template-columns:1fr!important}.sylva-book-card{grid-template-columns:92px minmax(0,1fr)!important;min-height:132px!important}.book-cover-button{width:92px;height:132px}.book-card-body{padding:12px 11px 9px}.book-card-title-row h3{font-size:14px!important}
 .saga-home-grid{grid-template-columns:1fr!important}.home-export-actions{grid-template-columns:1fr 1fr!important}.home-info-grid{grid-template-columns:1fr!important}.home-import-row{align-items:flex-start!important;flex-direction:column!important}
 html.phone-only .sylva-book-card .book-mobile-exports{display:flex!important;margin-top:auto!important;gap:5px!important;padding-right:60px!important}.book-mobile-exports button{min-height:29px!important;padding:0 8px!important;font-size:8px!important}
 html.phone-only .sylva-book-card .book-card-facts{display:none!important}
}
@media(max-width:440px){.home-export-actions{grid-template-columns:1fr!important}.home-logo-lockup{width:96vw!important}.home-hero h1{font-size:23px!important}}
/* Brand image cleanup across splash/access/legal. */
.sylva-image-lockup img{display:block;width:min(360px,70vw);height:auto;object-fit:contain}
.sylva-login-lockup{display:block!important}.sylva-login-full{display:block;width:min(360px,82%);height:auto;object-fit:contain}
.sylva-phone-brand img{display:block;width:132px;height:auto;object-fit:contain}
.sylva-legal-brand img{display:block;width:118px;height:auto;object-fit:contain}
html[data-theme="sylva"] .app-splash{background:#f5f0e8!important;color:#26362d!important}
html[data-theme="sylva"] .entry-gate{background:linear-gradient(135deg,#f0ebe3,#f8f4ed)!important;color:#26362d!important}
html[data-theme="sylva"] .entry-access{background:rgba(255,253,249,.90)!important;border-color:rgba(62,68,60,.12)!important}
/* 0.833 finishing pass */
html[data-route="writer"] #rail .rail-btn[hidden]{display:none!important}
html[data-route="writer"] #rail .brand.sylva-brand-button{border-radius:0!important;background:transparent!important;box-shadow:none!important;outline:0!important}
html[data-route="writer"] #rail .rail-icon-wrap{box-shadow:none!important;background:transparent!important}
html[data-route="writer"] #rail .rail-btn.active .rail-icon-wrap{background:rgba(33,71,55,.07)!important}
html[data-route="writer"] .topbar-left>div{display:flex!important;align-items:center!important;gap:10px!important;min-width:0!important}
html[data-route="writer"] .save-lines{margin:0!important;height:auto!important;flex:0 0 auto!important}
html[data-route="writer"] .floating-toolbar{opacity:1!important;color:#52574f!important}
html[data-route="writer"] .floating-toolbar button,html[data-route="writer"] .floating-toolbar select{opacity:1!important;color:#565b53!important;background:transparent!important}
html[data-route="writer"] .floating-toolbar button:hover{background:rgba(33,71,55,.06)!important;color:#214737!important}
html[data-route="writer"] .floating-toolbar .separator{opacity:.55!important}


/* 0.833 final product polish */
@media(max-width:440px){
  .home-logo-lockup{width:100%!important;max-width:355px!important;}
  .home-logo-full{max-width:100%!important;}
}
/* Sync semantics are deliberately only three states:
   red = not synchronized, blue = currently synchronizing, green = synchronized. */
html[data-route="writer"] .cloud-state,
html[data-route="writer"] .cloud-state[data-state="login"],
html[data-route="writer"] .cloud-state[data-state="pending"],
html[data-route="writer"] .cloud-state[data-state="offline"],
html[data-route="writer"] .cloud-state[data-state="error"]{background:#d85b57!important;box-shadow:0 0 0 3px rgba(216,91,87,.07)!important}
html[data-route="writer"] .cloud-state[data-state="syncing"]{background:#4d96dc!important;box-shadow:0 0 0 3px rgba(77,150,220,.08)!important}
html[data-route="writer"] .cloud-state[data-state="synced"]{background:#58af68!important;box-shadow:0 0 0 3px rgba(88,175,104,.08)!important}
.book-sync-dot,.book-sync-dot.local,.book-sync-dot.pending{background:#d75d58!important;box-shadow:0 0 0 3px rgba(215,93,88,.07)!important}
.book-sync-dot.syncing{background:#4b91d6!important;box-shadow:0 0 0 3px rgba(75,145,214,.08)!important}
.book-sync-dot.synced{background:#58ad66!important;box-shadow:0 0 0 3px rgba(88,173,102,.08)!important}

/* Entry/access is part of the same Sylva visual system. */
html[data-theme="sylva"] .entry-gate{background:linear-gradient(135deg,#f0ebe3 0%,#f8f4ed 54%,#eee8df 100%)!important;color:#26362d!important}
html[data-theme="sylva"] .entry-orbit{border-color:rgba(33,71,55,.055)!important}
html[data-theme="sylva"] .entry-access{background:rgba(255,253,249,.84)!important;border:1px solid rgba(62,68,60,.11)!important;box-shadow:0 24px 70px rgba(79,69,52,.09)!important}
html[data-theme="sylva"] .entry-access h2{color:#26362d!important}
html[data-theme="sylva"] .entry-access p,html[data-theme="sylva"] .entry-lead{color:#77736b!important}
html[data-theme="sylva"] .entry-access small,html[data-theme="sylva"] .entry-status{color:#8a8175!important}
html[data-theme="sylva"] .entry-login-btn{background:#214737!important;color:#fffdfa!important;border-color:#214737!important}
html[data-theme="sylva"] .entry-guest-btn{border-color:rgba(33,71,55,.14)!important;color:#506055!important}
html[data-theme="sylva"] .entry-guest-btn:hover{background:rgba(33,71,55,.05)!important;color:#214737!important}
html[data-theme="sylva"] .entry-features span{background:rgba(255,253,249,.46)!important;border-color:rgba(33,71,55,.10)!important;color:#6e766e!important}
html[data-theme="sylva"] .entry-footer{color:#91887b!important}
@media(max-width:980px){
  html[data-route="writer"] #rail{z-index:200!important}
  html[data-route="writer"] .writer-nav-toggle{z-index:210!important}
  html[data-route="writer"].writer-chrome-open .app-shell::after{content:"";position:fixed;inset:0;background:rgba(37,45,39,.10);z-index:150;pointer-events:none}
}


/* --- 0.834 · Tema Sylva Scuro + radio rinnovata --- */
html[data-theme="sylva-dark"] body,
html[data-theme="sylva-dark"] button,
html[data-theme="sylva-dark"] input,
html[data-theme="sylva-dark"] textarea,
html[data-theme="sylva-dark"] select{font-family:var(--sylva-ui,Inter,system-ui,sans-serif)}
html[data-theme="sylva-dark"] .scene-editor,
html[data-theme="sylva-dark"] .scene-editor *,
html[data-theme="sylva-dark"] .reader-editor,
html[data-theme="sylva-dark"] .reader-editor *,
html[data-theme="sylva-dark"] .review-original-copy,
html[data-theme="sylva-dark"] .review-original-copy *,
html[data-theme="sylva-dark"] .review-scene-editor,
html[data-theme="sylva-dark"] .review-scene-editor *{font-family:var(--editor-font)!important}
html[data-theme="sylva-dark"] body{background:radial-gradient(circle at top left,rgba(115,120,96,.12),transparent 24%),radial-gradient(circle at bottom right,rgba(255,154,61,.08),transparent 20%),linear-gradient(135deg,#111813 0%,#172019 45%,#101612 100%)!important;color:var(--text)!important}
html[data-theme="sylva-dark"] body::before,html[data-theme="sylva-dark"] body::after,html[data-theme="sylva-dark"] .ambient{display:none!important}
html[data-theme="sylva-dark"] .glass,html[data-theme="sylva-dark"] .glass-lite{background:rgba(20,28,22,.86)!important;border:1px solid rgba(237,227,208,.09)!important;backdrop-filter:blur(14px) saturate(.92)!important;-webkit-backdrop-filter:blur(14px) saturate(.92)!important;box-shadow:0 18px 54px rgba(0,0,0,.26)!important}
html[data-theme="sylva-dark"] .rail,
html[data-theme="sylva-dark"] .topbar,
html[data-theme="sylva-dark"] .structure-panel,
html[data-theme="sylva-dark"] .bookmark-panel,
html[data-theme="sylva-dark"] .codex-categories,
html[data-theme="sylva-dark"] .analysis-card,
html[data-theme="sylva-dark"] .revision-item,
html[data-theme="sylva-dark"] .book-card,
html[data-theme="sylva-dark"] .saga-shelf,
html[data-theme="sylva-dark"] .outline-act,
html[data-theme="sylva-dark"] .outline-chapter,
html[data-theme="sylva-dark"] .outline-legend,
html[data-theme="sylva-dark"] .modal,
html[data-theme="sylva-dark"] .codex-card,
html[data-theme="sylva-dark"] .big-action,
html[data-theme="sylva-dark"] .stat-card,
html[data-theme="sylva-dark"] .planning-stats,
html[data-theme="sylva-dark"] .planning-board,
html[data-theme="sylva-dark"] .timeline-shell,
html[data-theme="sylva-dark"] .home-section,
html[data-theme="sylva-dark"] .home-shelf,
html[data-theme="sylva-dark"] .home-export-card,
html[data-theme="sylva-dark"] .home-info-card{background:rgba(21,29,24,.84)!important;border-color:rgba(235,224,205,.10)!important;color:var(--text)!important;box-shadow:0 14px 36px rgba(0,0,0,.22)!important}
html[data-theme="sylva-dark"] .entry-gate{background:linear-gradient(135deg,#121813,#18211a 52%,#111612 100%)!important;color:#ebe4d8!important}
html[data-theme="sylva-dark"] .entry-access{background:rgba(20,27,22,.88)!important;border-color:rgba(237,227,208,.09)!important;box-shadow:0 24px 70px rgba(0,0,0,.25)!important}
html[data-theme="sylva-dark"] .entry-access h2,html[data-theme="sylva-dark"] .entry-brand-block h1,html[data-theme="sylva-dark"] .view-heading h1,html[data-theme="sylva-dark"] .panel-head h2,html[data-theme="sylva-dark"] .book-card h2,html[data-theme="sylva-dark"] .codex-card h3,html[data-theme="sylva-dark"] .timeline-event-head h3{color:#f5efe5!important;font-family:var(--sylva-ui)!important}
html[data-theme="sylva-dark"] .entry-access p,html[data-theme="sylva-dark"] .entry-lead,html[data-theme="sylva-dark"] .home-subtitle,html[data-theme="sylva-dark"] .book-status-copy small,html[data-theme="sylva-dark"] .muted{color:#a89f90!important}
html[data-theme="sylva-dark"] .scene-sheet,html[data-theme="sylva-dark"] .reader-document{background:linear-gradient(180deg,var(--paper),#ece2d5)!important;border:1px solid rgba(168,146,116,.16)!important;box-shadow:0 18px 54px rgba(0,0,0,.26)!important}
html[data-theme="sylva-dark"] .scene-editor,html[data-theme="sylva-dark"] .reader-editor,html[data-theme="sylva-dark"] .reader-separator h2{color:var(--sylva-ink)!important}
html[data-theme="sylva-dark"] .scene-label,html[data-theme="sylva-dark"] .reader-scene-label,html[data-theme="sylva-dark"] .reader-separator small{color:var(--sylva-paper-muted)!important}
html[data-theme="sylva-dark"] .reader-separator{border-color:rgba(116,108,92,.18)!important}
html[data-theme="sylva-dark"] .brand.sylva-brand-button{background:rgba(255,255,255,.02)!important;border-color:rgba(234,225,209,.09)!important;box-shadow:none!important}
html[data-theme="sylva-dark"] .rail-btn{position:relative;color:#aab5a8}
html[data-theme="sylva-dark"] .rail-btn:hover,html[data-theme="sylva-dark"] .rail-btn.active{background:rgba(232,224,208,.065)!important;color:#f1e9dc!important}
html[data-theme="sylva-dark"] .rail-btn.active::after{content:"";position:absolute;right:6px;top:9px;width:4px;height:4px;border-radius:50%;background:var(--accent);box-shadow:0 0 0 3px rgba(255,154,61,.07)}
html[data-theme="sylva-dark"] #rail .rail-icon-wrap{background-repeat:no-repeat;background-position:center;background-size:contain}
html[data-theme="sylva-dark"] #rail .rail-icon-wrap>.rail-icon{visibility:hidden!important}
html[data-theme="sylva-dark"] #rail .rail-btn[data-route="writer"] .rail-icon-wrap{background-image:url("assets/sylva-icons/scrivi-line-light.png")}
html[data-theme="sylva-dark"] #rail .rail-btn[data-route="reader"] .rail-icon-wrap{background-image:url("assets/sylva-icons/libri-line-light.png")}
html[data-theme="sylva-dark"] #rail .rail-btn[data-route="outline"] .rail-icon-wrap{background-image:url("assets/sylva-icons/albero.png")}
html[data-theme="sylva-dark"] #rail .rail-btn[data-route="planning"] .rail-icon-wrap{background-image:url("assets/sylva-icons/mappa.png")}
html[data-theme="sylva-dark"] #rail .rail-btn[data-route="codex"] .rail-icon-wrap{background-image:url("assets/sylva-icons/codex-line-light.png")}
html[data-theme="sylva-dark"] #rail .rail-btn[data-route="relationships"] .rail-icon-wrap{background-image:url("assets/sylva-icons/condividi.png")}
html[data-theme="sylva-dark"] #rail .rail-btn[data-route="timeline"] .rail-icon-wrap{background-image:url("assets/sylva-icons/timeline-line-light.png")}
html[data-theme="sylva-dark"] #rail .rail-btn[data-route="calendar"] .rail-icon-wrap{background-image:url("assets/sylva-icons/tempo.png")}
html[data-theme="sylva-dark"] #rail .rail-btn[data-route="analysis"] .rail-icon-wrap{background-image:url("assets/sylva-icons/cerca.png")}
html[data-theme="sylva-dark"] #rail .rail-btn[data-route="revisions"] .rail-icon-wrap{background-image:url("assets/sylva-icons/note.png")}
html[data-theme="sylva-dark"] #rail #themeToggle .rail-icon-wrap{background-image:url("assets/sylva-icons/tema-line-light.png")}
html[data-theme="sylva-dark"] #rail #settingsBtn .rail-icon-wrap{background-image:url("assets/sylva-icons/impostazioni.png")}
html[data-theme="sylva-dark"] .topbar{background:linear-gradient(180deg,rgba(20,29,22,.97),rgba(13,19,15,.96))!important}
html[data-theme="sylva-dark"] .topbar-center{background:#f3eee5!important;border-color:rgba(124,112,92,.20)!important}
html[data-theme="sylva-dark"] .topbar-center .scope-btn{color:#687165!important;background:transparent!important}
html[data-theme="sylva-dark"] .topbar-center .scope-btn:hover{color:#29382a!important;background:rgba(113,137,104,.09)!important}
html[data-theme="sylva-dark"] .topbar-center .scope-btn.active{background:#d8e2d3!important;color:#263526!important;border-color:#a5b59d!important}
html[data-theme="sylva-dark"] .topbar-actions .soft-btn,html[data-theme="sylva-dark"] .topbar-actions .session-trigger,html[data-theme="sylva-dark"] .topbar-actions .music-radio-trigger,html[data-theme="sylva-dark"] .topbar-actions .cloud-btn{background:#fffaf2!important;color:#31402f!important;border-color:rgba(126,112,91,.20)!important}
html[data-theme="sylva-dark"] .topbar-actions .soft-btn:hover,html[data-theme="sylva-dark"] .topbar-actions .session-trigger:hover,html[data-theme="sylva-dark"] .topbar-actions .music-radio-trigger:hover,html[data-theme="sylva-dark"] .topbar-actions .cloud-btn:hover{background:#f1eadf!important;color:#263526!important;border-color:rgba(126,112,91,.30)!important}
html[data-theme="sylva-dark"] .topbar-actions #saveBtn{background:linear-gradient(180deg,#51674f,#3e533f)!important;color:#fffaf0!important;border-color:#51674f!important}
html[data-theme="sylva-dark"] .soft-btn,html[data-theme="sylva-dark"] .mini-btn,html[data-theme="sylva-dark"] .scope-btn.active,html[data-theme="sylva-dark"] input,html[data-theme="sylva-dark"] textarea,html[data-theme="sylva-dark"] select{border-color:rgba(234,225,209,.11)}
html[data-theme="sylva-dark"] .primary-btn{background:#f06f16!important;color:#fff8f1!important;border-color:color-mix(in srgb,#ff7a1f 76%,#7b4b2b)!important}
html[data-theme="sylva-dark"] .primary-btn:hover{background:#ff7a1f!important}
html[data-theme="sylva-dark"] .home-hero,html[data-theme="sylva-dark"] .phone-access-header{background:linear-gradient(180deg,rgba(20,30,24,.84),rgba(20,30,24,.48))!important;border-color:rgba(235,224,205,.10)!important}
html[data-theme="sylva-dark"] .home-logo-wordmark,html[data-theme="sylva-dark"] .home-hero h1,html[data-theme="sylva-dark"] .phone-access-header h1{color:#f2ecdf!important}
html[data-theme="sylva-dark"] .home-logo-subline,html[data-theme="sylva-dark"] .home-hero p,html[data-theme="sylva-dark"] .phone-access-header p{color:#b7b0a1!important}
html[data-theme="sylva-dark"] .book-card-progress i,html[data-theme="sylva-dark"] .saga-progress i,html[data-theme="sylva-dark"] .progress-bar i{background:linear-gradient(90deg,#7f9775,#d0ab71)!important}
html[data-theme="sylva-dark"] .home-footer{color:#a89f90!important}
html[data-theme="sylva-dark"] .book-cover-placeholder,html[data-theme="sylva-dark"] .cover-placeholder{background:linear-gradient(145deg,#223026,#1a241d)!important;border-color:rgba(237,227,208,.11)!important}

.spotify-radio-rig{position:fixed;top:84px;right:16px;width:min(420px,calc(100vw - 32px));z-index:70;pointer-events:none;opacity:0;transform:translateY(-10px) scale(.98);transition:opacity .24s ease,transform .24s ease}
.spotify-radio-rig.open{pointer-events:auto;opacity:1;transform:none}
.spotify-radio{border-radius:24px;border:1px solid var(--line);background:color-mix(in srgb,var(--surface-strong) 92%,var(--bg) 8%);box-shadow:0 22px 70px rgba(0,0,0,.22);overflow:hidden}
.radio-shell{padding:16px}
.radio-header{display:flex;align-items:flex-start;justify-content:space-between;gap:12px;margin-bottom:14px}
.radio-branding{display:flex;align-items:center;gap:12px;min-width:0}.radio-branding strong{display:block;font-size:15px;line-height:1.1}.radio-branding small{display:block;font-size:11px;line-height:1.35;color:var(--muted);margin-top:3px}
.radio-chip{display:inline-flex;align-items:center;justify-content:center;height:30px;padding:0 12px;border-radius:999px;background:var(--accent-soft);border:1px solid color-mix(in srgb,var(--accent) 24%,var(--line));color:var(--accent);font-size:12px;font-weight:700;letter-spacing:.02em}
.radio-close{width:32px;height:32px;border-radius:12px;border:1px solid var(--line);background:var(--surface-2);color:var(--muted);font-size:20px;line-height:1}.radio-close:hover{background:var(--accent-soft);color:var(--text)}
.radio-now-playing{display:grid;grid-template-columns:72px 1fr;gap:14px;padding:14px;border:1px solid var(--line);border-radius:18px;background:linear-gradient(180deg,color-mix(in srgb,var(--surface-2) 86%,transparent),color-mix(in srgb,var(--surface-2) 36%,transparent))}
.radio-cover-art{width:72px;height:72px;border-radius:18px;background:linear-gradient(145deg,color-mix(in srgb,var(--paper) 84%,var(--surface-strong)),color-mix(in srgb,var(--accent-soft) 32%,var(--surface-strong)));display:grid;place-items:center;border:1px solid color-mix(in srgb,var(--accent) 18%,var(--line))}.radio-cover-art img{width:48px;height:48px;object-fit:contain;opacity:.94}
.radio-main-copy{min-width:0;display:flex;flex-direction:column;justify-content:center}.radio-main-copy small{font-size:11px;letter-spacing:.08em;color:var(--accent);font-weight:700;margin-bottom:6px}.radio-main-copy a{display:block;min-width:0;text-decoration:none;color:inherit}.radio-main-copy strong,.radio-main-copy span{display:block;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.radio-main-copy strong{font:600 17px var(--editor-font,serif);color:var(--text)}.radio-main-copy span{font-size:13px;color:var(--muted);margin-top:4px}
.radio-controls-card{margin-top:12px;padding:14px;border:1px solid var(--line);border-radius:18px;background:var(--surface-2)}
.radio-controls-row{display:flex;align-items:center;justify-content:space-between;gap:14px}.radio-transport{display:flex;align-items:center;gap:8px}
.radio-skip{width:38px;height:38px;border-radius:50%;border:1px solid var(--line);background:var(--surface-strong);color:var(--text);display:grid;place-items:center;transition:.18s ease}.radio-skip svg{width:17px;height:17px;fill:none;stroke:currentColor;stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round}.radio-skip:hover:not(:disabled){transform:translateY(-1px);background:var(--accent-soft)}.radio-skip:disabled{opacity:.35}
.radio-knob{width:46px;height:46px;border-radius:50%;border:1px solid color-mix(in srgb,var(--accent) 30%,var(--line));background:linear-gradient(180deg,color-mix(in srgb,var(--accent) 18%,var(--paper) 82%),color-mix(in srgb,var(--accent) 44%,var(--surface-strong)));position:relative;box-shadow:inset 0 1px rgba(255,255,255,.55),0 10px 20px rgba(0,0,0,.12)}.radio-knob:disabled{opacity:.45}.radio-play span{position:absolute;left:18px;top:14px;width:0;height:0;border-top:9px solid transparent;border-bottom:9px solid transparent;border-left:13px solid color-mix(in srgb,var(--text) 92%,white)}.radio-play.paused span{left:16px;top:14px;width:14px;height:18px;border:0;border-left:4px solid color-mix(in srgb,var(--text) 92%,white);border-right:4px solid color-mix(in srgb,var(--text) 92%,white)}
.radio-volume-wrap{display:flex;align-items:center;gap:10px;min-width:150px}.radio-volume-wrap label{font-size:12px;font-weight:600;color:var(--muted)}.radio-volume-wrap input{width:100%;accent-color:var(--accent)}
.radio-setup,.radio-connected{margin-top:12px;padding:14px;border-top:0;border:1px solid var(--line);border-radius:18px;background:color-mix(in srgb,var(--surface-2) 80%,transparent)}
.radio-setup p{font-size:12px;color:var(--muted);line-height:1.5;margin:0 0 10px}.radio-client-row{display:flex;gap:8px}.radio-client-row input,.radio-search-form input{min-width:0;flex:1;height:40px;border:1px solid var(--line);border-radius:12px;background:var(--surface-strong);color:var(--text);padding:0 12px;font-size:13px}.radio-client-row button{height:40px;border:1px solid color-mix(in srgb,var(--accent) 28%,var(--line));border-radius:12px;background:var(--accent-soft);color:var(--text);padding:0 14px;font-size:12px;font-weight:700}.radio-setup>small{display:block;margin-top:8px;color:var(--muted);font-size:11px;line-height:1.45}.radio-setup code{user-select:all;color:var(--text)}
.radio-search-form{display:flex;gap:8px}.radio-search-form button{width:40px;height:40px;border:1px solid var(--line);border-radius:12px;background:var(--surface-strong);color:var(--muted)}.radio-search-form svg{width:16px;height:16px;fill:none;stroke:currentColor;stroke-width:1.7}
.radio-search-results{margin-top:10px;max-height:255px;overflow:auto;display:flex;flex-direction:column;gap:6px;padding-right:2px}.radio-empty{font-size:12px;color:var(--muted);padding:10px 4px;margin:0}.radio-result{display:grid;grid-template-columns:1fr 36px;align-items:center;gap:8px;border:1px solid transparent;border-radius:14px;padding:8px 8px 8px 10px;transition:.18s}.radio-result:hover{background:var(--surface-strong);border-color:var(--line)}.radio-result>a{min-width:0;color:inherit;text-decoration:none}.radio-result b,.radio-result small{display:block;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.radio-result b{font-size:13px}.radio-result small{font-size:11px;color:var(--muted);margin-top:3px}.radio-result-play{width:32px;height:32px;border-radius:50%;border:1px solid var(--line);background:var(--surface-strong);position:relative}.radio-result-play span{position:absolute;left:12px;top:9px;border-top:6px solid transparent;border-bottom:6px solid transparent;border-left:8px solid var(--text)}.radio-result-kind{display:inline-flex;margin-bottom:4px;padding:3px 6px;border-radius:999px;background:var(--surface-2);border:1px solid var(--line);font:700 9px Inter,sans-serif;letter-spacing:.07em;color:var(--muted)}.radio-result-kind.playlist{color:var(--accent);background:var(--accent-soft)}
.radio-footer{display:flex;align-items:center;justify-content:space-between;border-top:1px solid var(--line);margin-top:10px;padding-top:10px}.radio-footer img{display:block;width:88px;height:auto}.radio-footer button{border:0;background:transparent;color:var(--muted);font-size:12px}.radio-footer button:hover{color:var(--text)}
@media(max-width:1100px){.spotify-radio-rig{top:74px;right:12px;width:min(390px,calc(100vw - 24px))}}
@media(max-width:900px){.spotify-radio-rig{top:76px;right:12px;width:min(420px,calc(100vw - 24px))}.radio-controls-row{flex-direction:column;align-items:stretch}.radio-volume-wrap{min-width:0;width:100%}}
@media(max-width:620px){.spotify-radio-rig{width:calc(100vw - 20px);right:10px}.radio-now-playing{grid-template-columns:60px 1fr}.radio-cover-art{width:60px;height:60px}.radio-cover-art img{width:40px;height:40px}}
@media(max-width:520px){.spotify-radio-rig{display:none}.music-radio-trigger{display:none}}

/* ========================================================================== 
   SYLVA 0.834 QA FINAL — shell coerente, dark completo, tablet drawer
   ========================================================================== */
.tablet-home-link{display:none!important}

/* Il linguaggio del writer diventa il guscio comune di tutte le viste. */
@media (min-width:1101px){
  html[data-route]:not([data-route="home"]) .app-shell{
    grid-template-columns:224px minmax(0,1fr)!important;
    grid-template-rows:72px minmax(0,1fr)!important;
    gap:0!important;padding:0!important;background:transparent!important;
  }
  html[data-route]:not([data-route="home"]) #rail{
    position:relative!important;grid-column:1!important;grid-row:1/3!important;
    left:auto!important;top:auto!important;bottom:auto!important;
    width:224px!important;height:100dvh!important;min-height:0!important;
    transform:none!important;opacity:1!important;pointer-events:auto!important;
    padding:14px 12px 13px!important;border-radius:0!important;overflow-y:auto!important;overflow-x:hidden!important;
    scrollbar-width:none!important;box-shadow:none!important;display:flex!important;align-items:stretch!important;
  }
  html[data-route]:not([data-route="home"]) #rail::-webkit-scrollbar{display:none!important}
  html[data-route]:not([data-route="home"]) #rail .brand.sylva-brand-button{
    display:flex!important;width:100%!important;height:78px!important;min-height:78px!important;margin:0 0 10px!important;padding:11px 16px!important;
    align-items:center!important;justify-content:flex-start!important;border:0!important;border-radius:14px!important;background:transparent!important;
  }
  html[data-route]:not([data-route="home"]) #rail .brand.sylva-brand-button img{display:block!important;width:152px!important;max-width:100%!important;height:auto!important;object-fit:contain!important}
  html[data-route]:not([data-route="home"]) #rail .rail-nav{width:100%!important;display:flex!important;flex-direction:column!important;gap:3px!important;margin:4px 0 0!important;flex:0 0 auto!important}
  html[data-route]:not([data-route="home"]) #rail .rail-bottom{width:100%!important;display:flex!important;flex-direction:column!important;gap:3px!important;margin-top:auto!important;padding-top:12px!important;flex:0 0 auto!important}
  html[data-route]:not([data-route="home"]) #rail .rail-btn{
    width:100%!important;min-height:43px!important;padding:5px 8px!important;border-radius:12px!important;
    display:grid!important;grid-template-columns:34px minmax(0,1fr)!important;align-items:center!important;justify-items:start!important;gap:10px!important;
    color:#687469!important;background:transparent!important;text-align:left!important;
  }
  html[data-route]:not([data-route="home"]) #rail .rail-btn:hover{background:rgba(33,71,55,.055)!important;color:#294333!important}
  html[data-route]:not([data-route="home"]) #rail .rail-btn.active{background:rgba(33,71,55,.085)!important;color:#214737!important}
  html[data-route]:not([data-route="home"]) #rail .rail-btn.active::after{right:8px!important;top:50%!important;transform:translateY(-50%)!important;width:5px!important;height:5px!important;background:#c89b5b!important}
  html[data-route]:not([data-route="home"]) #rail .rail-icon-wrap{
    width:34px!important;height:34px!important;flex:0 0 34px!important;display:grid!important;place-items:center!important;
    background:none!important;border-radius:10px!important;box-shadow:none!important;transform:none!important;
  }
  html[data-route]:not([data-route="home"]) #rail .rail-btn.active .rail-icon-wrap{background:rgba(33,71,55,.065)!important}
  html[data-route]:not([data-route="home"]) #rail .rail-icon{width:22px!important;height:22px!important;fill:none!important;stroke:currentColor!important;stroke-width:1.55!important;visibility:visible!important}
  html[data-route]:not([data-route="home"]) #rail .theme-icon-default{display:block!important;visibility:visible!important}
  html[data-route]:not([data-route="home"]) #rail .theme-icon-nature{display:none!important;visibility:hidden!important}
  html[data-route]:not([data-route="home"]) #rail .rail-btn small{display:block!important;font:550 12px/1.15 Inter,system-ui,sans-serif!important;color:inherit!important;white-space:nowrap!important}
  html[data-route]:not([data-route="home"]) .topbar{
    grid-column:2!important;grid-row:1!important;height:72px!important;min-height:72px!important;border-radius:0!important;
    padding:0 18px!important;border-top:0!important;border-right:0!important;
  }
  html[data-route]:not([data-route="home"]) .main-area{grid-column:2!important;grid-row:2!important;height:calc(100dvh - 72px)!important;min-height:0!important}
  html[data-route]:not([data-route="home"]) .writer-nav-toggle{display:none!important}
}

/* Chiaro: carta e verde su tutto il guscio, non solo nello Scrivi. */
html[data-theme="sylva"][data-route]:not([data-route="home"]) #rail{
  background:linear-gradient(180deg,#f7f3ec 0%,#f1ece3 100%)!important;border-right:1px solid rgba(57,70,60,.10)!important;color:#314238!important;
}
html[data-theme="sylva"][data-route]:not([data-route="home"]) .topbar{
  background:rgba(250,247,241,.97)!important;border-bottom:1px solid rgba(57,70,60,.10)!important;color:#29382f!important;box-shadow:none!important;
}
html[data-theme="sylva"][data-route]:not([data-route="home"]) .main-area,
html[data-theme="sylva"][data-route]:not([data-route="home"]) .view{background:#f5f1ea!important}

/* Scuro: stessa geometria, palette Sylva notturna e logo corretto. */
html[data-theme="sylva-dark"] .sylva-image-lockup img,
html[data-theme="sylva-dark"] .sylva-login-full,
html[data-theme="sylva-dark"] .sylva-phone-brand img,
html[data-theme="sylva-dark"] .sylva-legal-brand img,
html[data-theme="sylva-dark"] .home-logo-full,
html[data-theme="sylva-dark"] #rail .brand img{content:url("assets/sylva-logo-ivory.png")!important}
html[data-theme="sylva-dark"] #writerNavToggle img,
html[data-theme="sylva-dark"] .radio-cover-art img{content:url("assets/sylva-symbol-ivory.png")!important}
html[data-theme="sylva-dark"][data-route]:not([data-route="home"]) #rail{
  background:linear-gradient(180deg,#172019 0%,#111813 100%)!important;border-right:1px solid rgba(235,225,207,.085)!important;color:#d9d2c5!important;
}
html[data-theme="sylva-dark"][data-route]:not([data-route="home"]) #rail .rail-btn{color:#aeb6a9!important}
html[data-theme="sylva-dark"][data-route]:not([data-route="home"]) #rail .rail-btn:hover{background:rgba(239,231,216,.055)!important;color:#eee7db!important}
html[data-theme="sylva-dark"][data-route]:not([data-route="home"]) #rail .rail-btn.active{background:rgba(239,231,216,.075)!important;color:#f3ecdf!important}
html[data-theme="sylva-dark"][data-route]:not([data-route="home"]) #rail .rail-btn.active .rail-icon-wrap{background:rgba(239,231,216,.055)!important}
html[data-theme="sylva-dark"][data-route]:not([data-route="home"]) .topbar{
  background:rgba(17,24,19,.97)!important;border-bottom:1px solid rgba(235,225,207,.085)!important;color:#eee7da!important;box-shadow:none!important;
}
html[data-theme="sylva-dark"][data-route]:not([data-route="home"]) .main-area,
html[data-theme="sylva-dark"][data-route]:not([data-route="home"]) .view{background:#121a14!important;color:#e9e2d6!important}
html[data-theme="sylva-dark"] .book-title-top{color:#f0e8dc!important}
html[data-theme="sylva-dark"] .save-state{color:#a49c8f!important}

/* Dark writer: vero ambiente notturno, toolbar vecchia preservata. */
html[data-theme="sylva-dark"][data-route="writer"] .app-shell,
html[data-theme="sylva-dark"][data-route="writer"] .main-area,
html[data-theme="sylva-dark"][data-route="writer"] #writerView,
html[data-theme="sylva-dark"][data-route="writer"] .editor-stage,
html[data-theme="sylva-dark"][data-route="writer"] .editor-viewport{background:#121a14!important}
html[data-theme="sylva-dark"][data-route="writer"] .scene-sheet{background:transparent!important;border:0!important;box-shadow:none!important}
html[data-theme="sylva-dark"][data-route="writer"] .scene-sheet:hover{box-shadow:none!important}
html[data-theme="sylva-dark"][data-route="writer"] .scene-editor{color:#eee7da!important;caret-color:#d2aa72!important}
html[data-theme="sylva-dark"][data-route="writer"] .scene-label{color:#8e978b!important}
html[data-theme="sylva-dark"][data-route="writer"] .floating-toolbar{
  background:rgba(29,39,31,.96)!important;border-color:rgba(235,225,207,.12)!important;color:#e8e0d4!important;box-shadow:0 10px 30px rgba(0,0,0,.22)!important;
}
html[data-theme="sylva-dark"][data-route="writer"] .floating-toolbar button,
html[data-theme="sylva-dark"][data-route="writer"] .floating-toolbar select{color:#d8d1c5!important;background:transparent!important;border-color:transparent!important}
html[data-theme="sylva-dark"][data-route="writer"] .floating-toolbar button:hover{background:rgba(237,226,207,.075)!important;color:#fff7ea!important}
html[data-theme="sylva-dark"][data-route="writer"] .floating-toolbar select option{background:#1c261f!important;color:#ece4d8!important}

/* Lettura/revisione seguono il tema scuro invece di riaprire un foglio bianco. */
html[data-theme="sylva-dark"] .reader-document,
html[data-theme="sylva-dark"] .reader-sheet,
html[data-theme="sylva-dark"] .review-original-sheet,
html[data-theme="sylva-dark"] .review-edit-sheet{background:#18221b!important;color:#eee7da!important;border-color:rgba(235,225,207,.10)!important;box-shadow:0 16px 44px rgba(0,0,0,.22)!important}
html[data-theme="sylva-dark"] .reader-editor,
html[data-theme="sylva-dark"] .reader-separator h2,
html[data-theme="sylva-dark"] .review-original-copy,
html[data-theme="sylva-dark"] .review-scene-editor{color:#eee7da!important}
html[data-theme="sylva-dark"] .reader-scene-label,
html[data-theme="sylva-dark"] .reader-separator small,
html[data-theme="sylva-dark"] .review-scene-head>span,
html[data-theme="sylva-dark"] .review-scene-head>small{color:#9d968a!important}
html[data-theme="sylva-dark"] .review-scene-head{background:#202b23!important;border-color:rgba(235,225,207,.09)!important}

/* Home scura: override dei componenti finali chiari con la stessa gerarchia. */
html[data-theme="sylva-dark"][data-route="home"] .home-view{background:transparent!important;color:#eee7db!important}
html[data-theme="sylva-dark"][data-route="home"] .home-hero{background:transparent!important;border:0!important}
html[data-theme="sylva-dark"][data-route="home"] .home-hero h1,
html[data-theme="sylva-dark"][data-route="home"] .home-section-head h2,
html[data-theme="sylva-dark"][data-route="home"] .home-shelf-head h2{color:#f1eadf!important}
html[data-theme="sylva-dark"][data-route="home"] .home-hero p,
html[data-theme="sylva-dark"][data-route="home"] .home-section-head p,
html[data-theme="sylva-dark"][data-route="home"] .home-shelf-head>span,
html[data-theme="sylva-dark"][data-route="home"] .home-shelf-head small{color:#aaa294!important}
html[data-theme="sylva-dark"][data-route="home"] .home-hero>small,
html[data-theme="sylva-dark"][data-route="home"] .home-section-head>small{color:#d0a368!important}
html[data-theme="sylva-dark"][data-route="home"] .sylva-book-card{
  background:linear-gradient(180deg,#1c271f,#172019)!important;border-color:rgba(235,225,207,.10)!important;box-shadow:0 8px 26px rgba(0,0,0,.20)!important;
}
html[data-theme="sylva-dark"][data-route="home"] .sylva-book-card:hover{border-color:rgba(190,165,124,.22)!important;box-shadow:0 13px 34px rgba(0,0,0,.28)!important}
html[data-theme="sylva-dark"][data-route="home"] .book-card-title-row h3{color:#eee6da!important}
html[data-theme="sylva-dark"][data-route="home"] .book-card-facts,
html[data-theme="sylva-dark"][data-route="home"] .book-card-facts span,
html[data-theme="sylva-dark"][data-route="home"] .sylva-book-card .book-icon-btn{color:#9f988d!important}
html[data-theme="sylva-dark"][data-route="home"] .sylva-saga-card,
html[data-theme="sylva-dark"][data-route="home"] .sylva-saga-card:nth-child(3n+2),
html[data-theme="sylva-dark"][data-route="home"] .sylva-saga-card:nth-child(3n+3){background:linear-gradient(135deg,#1d2921,#202b23 48%,#162019)!important;border-color:rgba(235,225,207,.10)!important}
html[data-theme="sylva-dark"][data-route="home"] .sylva-saga-card h3{color:#eee6da!important}
html[data-theme="sylva-dark"][data-route="home"] .sylva-saga-card p{color:#a69e91!important}
html[data-theme="sylva-dark"][data-route="home"] .sylva-saga-card small{color:#d0a368!important}
html[data-theme="sylva-dark"][data-route="home"] .saga-botanical{background-image:url("assets/sylva-symbol-ivory.png")!important;opacity:.08!important;filter:none!important}
html[data-theme="sylva-dark"][data-route="home"] .home-export-actions .big-action,
html[data-theme="sylva-dark"][data-route="home"] .home-info-card{background:#1b251e!important;border-color:rgba(235,225,207,.10)!important;box-shadow:none!important}
html[data-theme="sylva-dark"][data-route="home"] .home-export-actions .big-action:hover,
html[data-theme="sylva-dark"][data-route="home"] .home-info-card:hover{background:#202c23!important;border-color:rgba(190,165,124,.20)!important}
html[data-theme="sylva-dark"][data-route="home"] .home-export-actions .big-action b,
html[data-theme="sylva-dark"][data-route="home"] .home-info-card b{color:#eee6da!important}
html[data-theme="sylva-dark"][data-route="home"] .home-export-actions .big-action small,
html[data-theme="sylva-dark"][data-route="home"] .home-info-card small{color:#a69e91!important}
html[data-theme="sylva-dark"][data-route="home"] .home-export-actions .big-action .action-icon{color:#b9c8b4!important}
html[data-theme="sylva-dark"][data-route="home"] .home-footer{border-color:rgba(235,225,207,.09)!important;color:#9e978c!important}
html[data-theme="sylva-dark"][data-route="home"] .home-footer span{color:#d8d0c3!important}

/* Radio: palette coerente per entrambe le modalità. */
html[data-theme="sylva"] .spotify-radio{background:#fbf7f0!important;border-color:rgba(57,70,60,.12)!important;color:#2c3931!important}
html[data-theme="sylva"] .radio-now-playing,html[data-theme="sylva"] .radio-controls-card,html[data-theme="sylva"] .radio-setup,html[data-theme="sylva"] .radio-connected{background:#f2ede5!important;border-color:rgba(57,70,60,.11)!important}
html[data-theme="sylva"] .radio-cover-art{background:#fffaf2!important}
html[data-theme="sylva-dark"] .spotify-radio{background:#172019!important;border-color:rgba(235,225,207,.11)!important;color:#eee7da!important}
html[data-theme="sylva-dark"] .radio-now-playing,html[data-theme="sylva-dark"] .radio-controls-card,html[data-theme="sylva-dark"] .radio-setup,html[data-theme="sylva-dark"] .radio-connected{background:#1d2921!important;border-color:rgba(235,225,207,.09)!important}
html[data-theme="sylva-dark"] .radio-cover-art{background:#233027!important;border-color:rgba(207,171,112,.18)!important}
html[data-theme="sylva-dark"] .radio-main-copy strong{color:#f1eadf!important}
html[data-theme="sylva-dark"] .radio-client-row input,html[data-theme="sylva-dark"] .radio-search-form input,html[data-theme="sylva-dark"] .radio-search-form button,html[data-theme="sylva-dark"] .radio-skip{background:#131c16!important;color:#e9e1d5!important}
html[data-theme="sylva-dark"] .radio-footer img{filter:brightness(0) invert(1);opacity:.82}

/* Tablet: drawer grande e leggibile in TUTTE le sezioni dell'app. */
@media (max-width:1100px), (pointer:coarse) and (min-width:561px) and (max-width:1366px){
  html[data-route]:not([data-route="home"]) .app-shell{grid-template-columns:1fr!important;grid-template-rows:66px minmax(0,1fr)!important;gap:0!important;padding:0!important}
  html[data-route]:not([data-route="home"]) .topbar{grid-column:1!important;grid-row:1!important;height:66px!important;min-height:66px!important;border-radius:0!important;padding-left:76px!important;padding-right:12px!important}
  html[data-route]:not([data-route="home"]) .main-area{grid-column:1!important;grid-row:2!important;height:calc(100dvh - 66px)!important;min-height:0!important}
  
  html[data-route]:not([data-route="home"]) .writer-nav-toggle{
    display:grid!important;place-items:center!important;position:fixed!important;left:max(10px,calc(env(safe-area-inset-left) + 8px))!important;top:max(9px,calc(env(safe-area-inset-top) + 7px))!important;
    width:48px!important;height:48px!important;padding:6px!important;border-radius:13px!important;z-index:210!important;transition:transform .18s ease,background .18s ease!important;
  }
  html[data-theme="sylva"][data-route]:not([data-route="home"]) .writer-nav-toggle{background:#f8f4ed!important;border:1px solid rgba(57,70,60,.13)!important;box-shadow:0 5px 18px rgba(79,69,52,.08)!important}
  html[data-theme="sylva-dark"][data-route]:not([data-route="home"]) .writer-nav-toggle{background:#1b271f!important;border:1px solid rgba(235,225,207,.12)!important;box-shadow:0 8px 22px rgba(0,0,0,.24)!important}
  html[data-route]:not([data-route="home"]) .writer-nav-toggle:active{transform:scale(.96)!important}
  html[data-route]:not([data-route="home"]) .writer-nav-toggle img{display:block!important;width:36px!important;height:36px!important;object-fit:contain!important}
  html[data-route]:not([data-route="home"]) #rail{
    position:fixed!important;left:0!important;top:0!important;bottom:0!important;width:min(292px,84vw)!important;height:100dvh!important;
    z-index:200!important;transform:translate3d(-104%,0,0)!important;opacity:0!important;pointer-events:none!important;
    padding:18px 13px 16px!important;border-radius:0 22px 22px 0!important;overflow-y:auto!important;overflow-x:hidden!important;scrollbar-width:none!important;
    transition:transform .26s cubic-bezier(.2,.8,.2,1),opacity .18s ease!important;display:flex!important;align-items:stretch!important;
  }
  html[data-route]:not([data-route="home"]) #rail::-webkit-scrollbar{display:none!important}
  html[data-route]:not([data-route="home"]).writer-chrome-open #rail{transform:translate3d(0,0,0)!important;opacity:1!important;pointer-events:auto!important}
  html[data-route]:not([data-route="home"]) #rail .brand{display:none!important}
  html[data-route]:not([data-route="home"]) #rail .rail-nav{width:100%!important;display:flex!important;flex-direction:column!important;gap:4px!important;margin:56px 0 0!important;flex:0 0 auto!important}
  html[data-route]:not([data-route="home"]) #rail .rail-bottom{width:100%!important;display:flex!important;flex-direction:column!important;gap:4px!important;margin-top:auto!important;padding-top:12px!important;flex:0 0 auto!important}
  html[data-route]:not([data-route="home"]) #rail .tablet-home-link{display:grid!important}
  html[data-route]:not([data-route="home"]) #rail .rail-btn{
    width:100%!important;min-height:46px!important;padding:5px 8px!important;border-radius:12px!important;display:grid!important;grid-template-columns:36px minmax(0,1fr)!important;align-items:center!important;justify-items:start!important;gap:11px!important;text-align:left!important;
  }
  html[data-route]:not([data-route="home"]) #rail .rail-icon-wrap{width:36px!important;height:36px!important;flex:0 0 36px!important;display:grid!important;place-items:center!important;background:none!important;border-radius:10px!important;box-shadow:none!important}
  html[data-route]:not([data-route="home"]) #rail .rail-icon{width:22px!important;height:22px!important;fill:none!important;stroke:currentColor!important;stroke-width:1.55!important;visibility:visible!important}
  html[data-route]:not([data-route="home"]) #rail .theme-icon-default{display:block!important;visibility:visible!important}
  html[data-route]:not([data-route="home"]) #rail .theme-icon-nature{display:none!important;visibility:hidden!important}
  html[data-route]:not([data-route="home"]) #rail .rail-btn small{display:block!important;font:550 12.5px/1.15 Inter,system-ui,sans-serif!important;color:inherit!important;white-space:nowrap!important}
  html[data-route]:not([data-route="home"]).writer-chrome-open .app-shell::after{content:""!important;position:fixed!important;inset:0!important;background:rgba(8,13,10,.30)!important;z-index:150!important;pointer-events:none!important}
  html[data-route]:not([data-route="home"]) .book-title-top{max-width:44vw!important;white-space:nowrap!important;overflow:hidden!important;text-overflow:ellipsis!important}
  html[data-route]:not([data-route="home"]) .topbar-center{max-width:34vw!important;overflow:auto!important;scrollbar-width:none!important}
  html[data-route]:not([data-route="home"]) .topbar-center::-webkit-scrollbar{display:none!important}
}

/* Tablet largo: la barra alta resta leggibile e non collide con le azioni. */
@media (max-width:1240px), (pointer:coarse) and (min-width:561px) and (max-width:1366px){
  html[data-route]:not([data-route="home"]) .topbar-actions{gap:5px!important}
  html[data-route]:not([data-route="home"]) .topbar-actions .global-search-trigger>span,
  html[data-route]:not([data-route="home"]) .topbar-actions .session-trigger>span,
  html[data-route]:not([data-route="home"]) .topbar-actions .cloud-btn-label{display:none!important}
  html[data-route]:not([data-route="home"]) .topbar-actions .global-search-trigger,
  html[data-route]:not([data-route="home"]) .topbar-actions .session-trigger,
  html[data-route]:not([data-route="home"]) .topbar-actions .cloud-btn,
  html[data-route]:not([data-route="home"]) .topbar-actions .music-radio-trigger{width:40px!important;min-width:40px!important;height:40px!important;min-height:40px!important;padding:0!important;display:grid!important;place-items:center!important}
}

/* Smartphone: home soltanto; la nuova shell non interferisce. */
@media(max-width:560px){
  html.phone-only[data-route="home"] .writer-nav-toggle,html.phone-only[data-route="home"] #rail,html.phone-only[data-route="home"] .topbar{display:none!important}
}

/* Radio 0.834 QA: niente cavo/oscillazione legacy, semplice pannello Sylva. */
.spotify-radio-rig{
  position:fixed!important;top:82px!important;right:16px!important;width:min(420px,calc(100vw - 32px))!important;height:auto!important;
  z-index:240!important;pointer-events:none!important;opacity:0!important;visibility:hidden!important;transform:translateY(-8px) scale(.985)!important;
  transition:opacity .20s ease,transform .20s ease,visibility 0s linear .20s!important;
}
.spotify-radio-rig.open{pointer-events:auto!important;opacity:1!important;visibility:visible!important;transform:none!important;transition:opacity .20s ease,transform .20s ease,visibility 0s!important}
.spotify-radio-rig .spotify-radio,
.spotify-radio-rig.open .spotify-radio{
  position:relative!important;top:auto!important;right:auto!important;width:100%!important;padding:0!important;
  opacity:1!important;pointer-events:auto!important;transform:none!important;transform-origin:center!important;animation:none!important;transition:none!important;backdrop-filter:none!important;-webkit-backdrop-filter:none!important;
}
@media(max-width:1100px), (pointer:coarse) and (min-width:561px) and (max-width:1366px){
  .spotify-radio-rig{top:76px!important;right:12px!important;width:min(420px,calc(100vw - 24px))!important}
}

/* ========================================================================== 
   0.835 · Final Sylva polish — access, writer utilities, toolbar, goals
   ========================================================================== */

/* Access/login: one coherent Sylva composition, without the legacy logo slab. */
.entry-gate{isolation:isolate!important;padding:max(18px,env(safe-area-inset-top)) max(18px,env(safe-area-inset-right)) max(18px,env(safe-area-inset-bottom)) max(18px,env(safe-area-inset-left))!important}
html[data-theme="sylva"] .entry-gate{
  background:radial-gradient(circle at 13% 15%,rgba(184,159,116,.13),transparent 31%),radial-gradient(circle at 86% 78%,rgba(70,103,81,.09),transparent 29%),linear-gradient(135deg,#eee8df 0%,#f7f3ec 52%,#ebe5dc 100%)!important;
  color:#26362d!important;
}
html[data-theme="sylva-dark"] .entry-gate{
  background:radial-gradient(circle at 13% 15%,rgba(202,160,99,.12),transparent 31%),radial-gradient(circle at 86% 78%,rgba(67,99,76,.15),transparent 30%),linear-gradient(135deg,#111713 0%,#182019 53%,#101511 100%)!important;
  color:#eee6da!important;
}
html[data-theme="sylva"] .entry-gate::before,
html[data-theme="sylva-dark"] .entry-gate::before{
  content:""!important;position:absolute!important;inset:0!important;z-index:0!important;pointer-events:none!important;
  background:linear-gradient(90deg,transparent 0 49.96%,color-mix(in srgb,currentColor 4%,transparent) 50%,transparent 50.04%)!important;opacity:.5!important;
}
html[data-theme="sylva"] .entry-gate::after,
html[data-theme="sylva-dark"] .entry-gate::after{display:none!important}
.entry-shell{
  width:min(1180px,calc(100vw - 52px))!important;min-height:0!important;max-height:calc(100dvh - 42px)!important;
  grid-template-columns:minmax(0,1.25fr) minmax(340px,410px)!important;gap:clamp(46px,7vw,104px)!important;
  align-items:center!important;padding:clamp(28px,4vw,58px)!important;overflow:auto!important;scrollbar-width:none!important;
}
.entry-shell::-webkit-scrollbar{display:none!important}
.entry-brand-block{padding:0!important;align-self:center!important;min-width:0!important}
.writer-logo.sylva-login-lockup{
  display:block!important;width:min(330px,54vw)!important;max-width:100%!important;height:auto!important;min-height:0!important;
  margin:0 0 26px!important;padding:0!important;border:0!important;border-radius:0!important;background:transparent!important;box-shadow:none!important;overflow:visible!important;
}
.sylva-login-full{display:block!important;width:100%!important;max-width:100%!important;height:auto!important;object-fit:contain!important;object-position:left center!important}
.entry-kicker{margin:0 0 18px!important;font-size:9px!important;letter-spacing:.22em!important;font-weight:700!important}
html[data-theme="sylva"] .entry-kicker{color:#82796c!important}html[data-theme="sylva-dark"] .entry-kicker{color:#aaa194!important}
.entry-brand-block h1{font-family:var(--ui-serif,Georgia,serif)!important;font-size:clamp(45px,5.6vw,76px)!important;font-weight:430!important;line-height:1.02!important;letter-spacing:-.048em!important;max-width:760px!important}
html[data-theme="sylva"] .entry-brand-block h1{color:#203f31!important}html[data-theme="sylva"] .entry-brand-block h1 em{color:#7c725f!important}
html[data-theme="sylva-dark"] .entry-brand-block h1{color:#e9e2d5!important}html[data-theme="sylva-dark"] .entry-brand-block h1 em{color:#c8bda9!important}
.entry-lead{max-width:570px!important;margin-top:22px!important;font-size:13px!important;line-height:1.7!important}
.entry-features{margin-top:25px!important;gap:7px!important}.entry-features span{padding:7px 11px!important;border-radius:999px!important;font-size:8px!important}
html[data-theme="sylva"] .entry-features span{background:rgba(255,253,249,.56)!important;border-color:rgba(33,71,55,.09)!important;color:#6b766e!important}
html[data-theme="sylva-dark"] .entry-features span{background:rgba(237,229,215,.045)!important;border-color:rgba(237,229,215,.085)!important;color:#aca497!important}
.entry-access{align-self:center!important;border-radius:26px!important;padding:32px!important;backdrop-filter:blur(18px) saturate(.9)!important;-webkit-backdrop-filter:blur(18px) saturate(.9)!important}
html[data-theme="sylva"] .entry-access{background:rgba(255,253,249,.78)!important;border:1px solid rgba(57,70,60,.11)!important;box-shadow:0 24px 64px rgba(73,62,45,.10)!important}
html[data-theme="sylva-dark"] .entry-access{background:rgba(24,32,26,.80)!important;border:1px solid rgba(237,227,210,.10)!important;box-shadow:0 28px 70px rgba(0,0,0,.27)!important}
.entry-access h2{font-family:var(--ui-serif,Georgia,serif)!important;font-size:27px!important;line-height:1.1!important;margin:11px 0 11px!important}
.entry-access p{font-size:11px!important;line-height:1.62!important}.entry-login-btn,.entry-guest-btn{height:48px!important;border-radius:13px!important}
html[data-theme="sylva"] .entry-login-btn{background:#214737!important;color:#fffdfa!important;border-color:#214737!important;box-shadow:0 8px 20px rgba(33,71,55,.12)!important}
html[data-theme="sylva-dark"] .entry-login-btn{background:#ebe3d6!important;color:#23362b!important;border-color:#ebe3d6!important;box-shadow:0 9px 22px rgba(0,0,0,.20)!important}
html[data-theme="sylva-dark"] .entry-guest-btn{border-color:rgba(237,227,210,.10)!important;color:#b7aea0!important}.entry-status{margin-top:18px!important}
.entry-footer{bottom:2px!important;left:0!important;right:0!important;padding:0 clamp(6px,1vw,12px)!important}
.entry-legal-link{border:0!important;background:transparent!important;color:inherit!important;font-size:inherit!important;letter-spacing:inherit!important;text-transform:inherit!important}

@media(max-width:900px){
  .entry-gate{overflow:auto!important;display:block!important}
  .entry-shell{width:min(720px,100%)!important;max-height:none!important;min-height:100dvh!important;grid-template-columns:1fr!important;gap:28px!important;padding:44px 26px 30px!important;margin:0 auto!important}
  .entry-brand-block{text-align:center!important;display:flex!important;flex-direction:column!important;align-items:center!important}
  .writer-logo.sylva-login-lockup{width:min(270px,62vw)!important;margin-bottom:22px!important}.sylva-login-full{object-position:center!important}
  .entry-brand-block h1{font-size:clamp(38px,8vw,56px)!important}.entry-lead{font-size:12px!important}.entry-features{justify-content:center!important}
  .entry-access{width:min(520px,100%)!important;justify-self:center!important;margin:0 auto!important;padding:27px!important}.entry-footer{position:static!important;order:3!important;flex-wrap:wrap!important;justify-content:center!important;gap:9px 18px!important;text-align:center!important;padding:6px 0 0!important}
}
@media(max-width:520px){
  .entry-shell{padding:34px 16px 24px!important;gap:22px!important}.writer-logo.sylva-login-lockup{width:min(220px,70vw)!important;margin-bottom:18px!important}.entry-kicker{font-size:8px!important;margin-bottom:13px!important}.entry-brand-block h1{font-size:37px!important}.entry-lead{margin-top:16px!important}.entry-features{display:none!important}.entry-access{padding:23px 19px!important;border-radius:21px!important}.entry-access h2{font-size:24px!important}.entry-footer{font-size:7px!important}
}

/* Writer project bar: feature-rich but visually quiet. */
html[data-route="writer"] .topbar{grid-template-columns:minmax(220px,1fr) auto!important;gap:14px!important;padding-left:22px!important;padding-right:18px!important}
html[data-route="writer"] .topbar-center{display:none!important}
html[data-route="writer"] .topbar-actions.writer-project-actions{display:flex!important;align-items:center!important;justify-content:flex-end!important;gap:6px!important;min-width:0!important;overflow:visible!important}
html[data-route="writer"] .writer-project-actions .project-action-btn,
html[data-route="writer"] .writer-project-actions .music-radio-trigger{
  min-height:38px!important;height:38px!important;display:inline-flex!important;align-items:center!important;justify-content:center!important;gap:7px!important;
  border-radius:11px!important;padding:0 10px!important;white-space:nowrap!important;font-size:10px!important;font-weight:650!important;line-height:1!important;
}
html[data-route="writer"] .writer-project-actions svg{width:16px!important;height:16px!important;fill:none!important;stroke:currentColor!important;stroke-width:1.65!important;stroke-linecap:round!important;stroke-linejoin:round!important;flex:0 0 auto!important}
html[data-route="writer"] .writer-project-actions .global-search-trigger{width:38px!important;min-width:38px!important;padding:0!important}html[data-route="writer"] .writer-project-actions .global-search-trigger>span{display:none!important}
html[data-route="writer"] .writer-project-actions .music-radio-trigger{width:38px!important;min-width:38px!important;padding:0!important}
html[data-route="writer"] .writer-project-actions .revision-draft-trigger{height:38px!important;background:transparent!important;padding:0 10px!important;font:650 10px/1 Inter,sans-serif!important}
html[data-route="writer"] .writer-project-actions .revision-draft-trigger i{position:static!important}
html[data-route="writer"] .writer-project-actions .cloud-btn{padding:0 10px!important}.writer-project-actions .cloud-dot{width:8px!important;height:8px!important;min-width:8px!important}
html[data-route="writer"] .writer-project-actions .backup-project-btn{padding:0 12px!important}
html[data-route="writer"] .goals-trigger{position:relative;overflow:hidden!important}.goals-trigger::after{content:"";position:absolute;left:0;bottom:0;height:2px;width:var(--goal-progress,0%);background:#73a37a;opacity:.7;transition:width .2s ease}.goals-trigger.goal-done::after{background:#5fb46c;opacity:1}

/* Keep every core project action reachable on tablets; labels collapse, not functions. */
@media(max-width:1240px), (pointer:coarse) and (min-width:561px) and (max-width:1366px){
  html[data-route="writer"] .topbar{grid-template-columns:minmax(170px,38vw) minmax(0,1fr)!important;padding-right:10px!important}
  html[data-route="writer"] .topbar-actions.writer-project-actions{max-width:100%!important;overflow-x:auto!important;overflow-y:hidden!important;scrollbar-width:none!important;justify-content:flex-end!important;padding:2px 0!important}
  html[data-route="writer"] .topbar-actions.writer-project-actions::-webkit-scrollbar{display:none!important}
  html[data-route="writer"] .writer-project-actions .project-action-btn,
  html[data-route="writer"] .writer-project-actions .music-radio-trigger{width:40px!important;min-width:40px!important;height:40px!important;min-height:40px!important;padding:0!important;flex:0 0 40px!important}
  html[data-route="writer"] .writer-project-actions .project-action-btn>span,
  html[data-route="writer"] .writer-project-actions .cloud-btn-label{display:none!important}
  html[data-route="writer"] .writer-project-actions .revision-draft-trigger i{position:absolute!important;right:-2px!important;top:-3px!important}
}

/* Old formatting toolbar: visible enough at rest, fully present on hover/focus. */
@media(pointer:fine){
  html[data-route="writer"] .floating-toolbar{opacity:.24!important;transition:opacity .28s ease,box-shadow .28s ease,background .28s ease!important}
  html[data-route="writer"] .floating-toolbar:hover,
  html[data-route="writer"] .floating-toolbar:focus-within,
  html[data-route="writer"] .floating-toolbar.focused{opacity:1!important}
}
@media(pointer:coarse){html[data-route="writer"] .floating-toolbar{opacity:.96!important}}
html[data-route="writer"] .floating-toolbar .highlight-dot{border:1px solid rgba(45,48,43,.13)!important;box-shadow:inset 0 0 0 1px rgba(255,255,255,.36)!important;padding:0!important}
html[data-route="writer"] .floating-toolbar .highlight-dot[data-highlight="#fff09a"]{background:#fff09a!important}
html[data-route="writer"] .floating-toolbar .highlight-dot[data-highlight="#ffd2dc"]{background:#ffd2dc!important}
html[data-route="writer"] .floating-toolbar .highlight-dot[data-highlight="#ccebdc"]{background:#ccebdc!important}
html[data-route="writer"] .floating-toolbar .highlight-dot[data-highlight="#cfdcf8"]{background:#cfdcf8!important}
html[data-route="writer"] .floating-toolbar .highlight-dot[data-highlight="#e3d2f3"]{background:#e3d2f3!important}
html[data-route="writer"] .floating-toolbar .highlight-clear{background:transparent!important}
html[data-theme="sylva-dark"][data-route="writer"] .floating-toolbar .highlight-dot{border-color:rgba(255,255,255,.15)!important;box-shadow:inset 0 0 0 1px rgba(0,0,0,.08)!important}

/* Goals UI. */
.goals-modal{width:min(720px,calc(100vw - 28px))!important}.goals-modal-head>small{font-size:9px;font-weight:750;letter-spacing:.16em;color:var(--accent)}.goals-modal-head h2{margin:7px 0 7px;font-family:var(--ui-serif,Georgia,serif);font-size:27px}.goals-modal-head p{margin:0;color:var(--muted);font-size:11px;line-height:1.6;max-width:64ch}
.goals-progress-grid{display:grid;grid-template-columns:1fr 1fr;gap:12px;margin:20px 0}.goal-progress-card{display:grid;grid-template-columns:76px minmax(0,1fr);align-items:center;gap:14px;padding:15px;border:1px solid var(--line);border-radius:18px;background:var(--surface-2)}.goal-progress-card.complete{border-color:color-mix(in srgb,#65aa70 35%,var(--line));background:color-mix(in srgb,#65aa70 7%,var(--surface-2))}.goal-progress-ring{--goal:0;width:70px;height:70px;border-radius:50%;display:grid;place-items:center;background:conic-gradient(var(--accent) calc(var(--goal)*1%),color-mix(in srgb,var(--muted) 14%,transparent) 0);position:relative}.goal-progress-ring::after{content:"";position:absolute;inset:7px;border-radius:50%;background:var(--surface-strong);border:1px solid var(--line)}.goal-progress-ring b{position:relative;z-index:1;font-size:14px}.goal-progress-card small,.goal-progress-card strong,.goal-progress-card span{display:block}.goal-progress-card small{font-size:8px;letter-spacing:.12em;color:var(--accent);font-weight:750}.goal-progress-card strong{font-size:17px;margin-top:4px}.goal-progress-card span{font-size:9px;color:var(--muted);margin-top:4px}.goals-inputs{margin-top:2px}
@media(max-width:620px){.goals-progress-grid{grid-template-columns:1fr}.goal-progress-card{grid-template-columns:64px 1fr}.goal-progress-ring{width:58px;height:58px}.goals-inputs{grid-template-columns:1fr!important}}

/* Small global coherence pass: secondary workspaces inherit the same restrained radius. */
html[data-theme="sylva"] .view-heading h1,html[data-theme="sylva-dark"] .view-heading h1{font-family:var(--ui-serif,Georgia,serif)!important;font-weight:520!important;letter-spacing:-.025em!important}
html[data-theme="sylva"] .modal,html[data-theme="sylva-dark"] .modal{border-radius:22px!important}
html[data-theme="sylva"] .soft-btn,html[data-theme="sylva-dark"] .soft-btn,html[data-theme="sylva"] .mini-btn,html[data-theme="sylva-dark"] .mini-btn{border-radius:10px!important}
/* Toolbar idle state defaults to translucent; touch overrides it below. */
html[data-route="writer"] .floating-toolbar{opacity:.24!important}
html[data-route="writer"] .floating-toolbar:hover,
html[data-route="writer"] .floating-toolbar:focus-within,
html[data-route="writer"] .floating-toolbar.focused{opacity:1!important}
@media(pointer:coarse){html[data-route="writer"] .floating-toolbar{opacity:.96!important}}

/* 0.835 QA final: niente ghost del contenitore modale dopo la chiusura. */
.modal-backdrop[aria-hidden="true"]:not(.open) .modal{visibility:hidden!important}
.modal-backdrop.open .modal{visibility:visible!important}

/* Ambito: feature storica nuovamente raggiungibile senza ingombrare la topbar. */
html[data-route="writer"] .writer-project-actions .scope-quick-trigger{width:38px!important;min-width:38px!important;padding:0!important}
html[data-route="writer"] .writer-project-actions .scope-quick-trigger>span{display:none!important}
.scope-modal-head>small{font-size:9px;font-weight:750;letter-spacing:.16em;color:var(--accent)}
.scope-modal-head h2{font-family:var(--ui-serif,Georgia,serif);font-size:27px;margin:7px 0 7px}
.scope-modal-head p{margin:0;max-width:58ch}
.scope-modal-grid{display:grid;grid-template-columns:1fr 1fr;gap:9px;margin-top:18px}
.scope-modal-choice{position:relative;display:grid;gap:4px;text-align:left;padding:14px 42px 14px 14px;border:1px solid var(--line);border-radius:15px;background:var(--surface-2);color:var(--text)}
.scope-modal-choice:hover,.scope-modal-choice.active{border-color:color-mix(in srgb,var(--accent) 32%,var(--line));background:var(--accent-soft)}
.scope-modal-choice span{font-size:13px;font-weight:700}.scope-modal-choice small{font-size:9px;line-height:1.4;color:var(--muted)}.scope-modal-choice i{position:absolute;right:14px;top:50%;transform:translateY(-50%);font-style:normal;color:var(--accent)}
@media(max-width:520px){.scope-modal-grid{grid-template-columns:1fr}}

/* Project bar più discreta: niente fila di pulsanti avorio aggressivi nel tema scuro. */
html[data-theme="sylva"][data-route="writer"] .writer-project-actions .project-action-btn,
html[data-theme="sylva"][data-route="writer"] .writer-project-actions .music-radio-trigger{
  background:rgba(255,253,249,.54)!important;color:#405047!important;border:1px solid rgba(57,70,60,.10)!important;box-shadow:none!important;
}
html[data-theme="sylva"][data-route="writer"] .writer-project-actions .project-action-btn:hover,
html[data-theme="sylva"][data-route="writer"] .writer-project-actions .music-radio-trigger:hover{background:#fffaf2!important;color:#26382e!important;border-color:rgba(57,70,60,.17)!important}
html[data-theme="sylva-dark"][data-route="writer"] .writer-project-actions .project-action-btn,
html[data-theme="sylva-dark"][data-route="writer"] .writer-project-actions .music-radio-trigger{
  background:rgba(236,226,209,.055)!important;color:#b9b2a5!important;border:1px solid rgba(236,226,209,.085)!important;box-shadow:none!important;
}
html[data-theme="sylva-dark"][data-route="writer"] .writer-project-actions .project-action-btn:hover,
html[data-theme="sylva-dark"][data-route="writer"] .writer-project-actions .music-radio-trigger:hover{background:rgba(236,226,209,.11)!important;color:#f0e8dc!important;border-color:rgba(236,226,209,.15)!important}
html[data-theme="sylva-dark"][data-route="writer"] .writer-project-actions #codexToggle.active{background:rgba(110,139,107,.16)!important;color:#d9e3d3!important;border-color:rgba(146,172,137,.18)!important}
html[data-theme="sylva"][data-route="writer"] .writer-project-actions #codexToggle.active{background:#e6eee2!important;color:#29402f!important;border-color:#cbd9c7!important}
html[data-theme="sylva-dark"][data-route="writer"] .writer-project-actions .backup-project-btn{background:rgba(79,107,78,.22)!important;color:#dce7d6!important;border-color:rgba(126,157,119,.20)!important}
html[data-theme="sylva"][data-route="writer"] .writer-project-actions .backup-project-btn{background:#e7eee3!important;color:#29412e!important;border-color:#cad8c6!important}


/* ===== SYLVA 0.836 · regression repair ===== */
html:not(.workspace-entered) #app{visibility:hidden!important;opacity:0!important;pointer-events:none!important}
html.workspace-entered #app{visibility:visible!important;opacity:1!important;pointer-events:auto!important}
.entry-gate{z-index:220!important}

html[data-route]:not([data-route="writer"]) .writer-project-actions,
html[data-route]:not([data-route="writer"]) #scopeGroup,
html[data-route]:not([data-route="writer"]) .topbar-actions{display:none!important}
html[data-route]:not([data-route="writer"]) .topbar{grid-template-columns:minmax(0,1fr)!important}

html[data-route="writer"] #musicRadioBtn{display:none!important}
html[data-route="writer"] .save-lines{display:none!important}
.writer-project-actions #cloudBtn .cloud-dot{background:#d85b57!important;box-shadow:0 0 0 3px rgba(216,91,87,.08)!important;animation:none!important}
.writer-project-actions #cloudBtn[data-state="syncing"] .cloud-dot{background:#4d96dc!important;box-shadow:0 0 0 3px rgba(77,150,220,.09)!important;animation:cloudPulse 1.1s ease-in-out infinite!important}
.writer-project-actions #cloudBtn[data-state="synced"] .cloud-dot{background:#58af68!important;box-shadow:0 0 0 3px rgba(88,175,104,.09)!important}
.writer-project-actions #cloudBtn[data-state="pending"] .cloud-dot,.writer-project-actions #cloudBtn[data-state="offline"] .cloud-dot,.writer-project-actions #cloudBtn[data-state="error"] .cloud-dot,.writer-project-actions #cloudBtn[data-state="login"] .cloud-dot{background:#d85b57!important}
.book-sync-dot.local,.book-sync-dot.pending{background:#d85b57!important;box-shadow:0 0 0 3px rgba(216,91,87,.08)!important}.book-sync-dot.syncing{background:#4d96dc!important}.book-sync-dot.synced{background:#58af68!important}

html[data-route="writer"] .document-meta,html[data-route="writer"] .multi-scene-editor{width:min(var(--manuscript-width,850px),calc(100% - 56px))!important;max-width:none!important}
html[data-route="writer"] .multi-scene-editor.review-host{width:100%!important;max-width:none!important}
@media(max-width:980px){html[data-route="writer"] .document-meta,html[data-route="writer"] .multi-scene-editor{width:min(var(--manuscript-width,850px),calc(100vw - 34px))!important}}

html[data-route="writer"] .multi-scene-editor[data-scene-divider="boxes"] .scene-sheet{
 background:radial-gradient(circle at 16% 9%,rgba(180,143,86,.055),transparent 24%),radial-gradient(circle at 88% 76%,rgba(101,86,62,.035),transparent 31%),repeating-linear-gradient(0deg,rgba(86,72,50,.018) 0,rgba(86,72,50,.018) 1px,transparent 1px,transparent 4px),linear-gradient(180deg,#fbf5e9 0%,#f5ecdd 52%,#f8f0e3 100%)!important;
 border:1px solid rgba(137,114,80,.16)!important;border-radius:15px!important;box-shadow:0 18px 48px rgba(63,51,36,.11),inset 0 1px rgba(255,255,255,.72)!important;padding:54px clamp(30px,5.6vw,78px) 78px!important
}
html[data-route="writer"] .multi-scene-editor[data-scene-divider="boxes"] .scene-editor{color:#302b24!important;caret-color:#365542!important}
html[data-route="writer"] .multi-scene-editor[data-scene-divider="boxes"] .scene-label{color:#887b69!important}
html[data-theme="sylva-dark"][data-route="writer"] .multi-scene-editor[data-scene-divider="boxes"] .scene-sheet{background:radial-gradient(circle at 15% 8%,rgba(186,146,86,.06),transparent 25%),repeating-linear-gradient(0deg,rgba(82,66,45,.019) 0,rgba(82,66,45,.019) 1px,transparent 1px,transparent 4px),linear-gradient(180deg,#f5eddf,#eee3d2 54%,#f3e9d9)!important;border-color:rgba(201,174,132,.18)!important;box-shadow:0 22px 64px rgba(0,0,0,.30),inset 0 1px rgba(255,255,255,.62)!important}
html[data-theme="sylva-dark"][data-route="writer"] .multi-scene-editor[data-scene-divider="boxes"] .scene-editor{color:#302b24!important;caret-color:#365542!important}
html[data-theme="sylva-dark"][data-route="writer"] .multi-scene-editor[data-scene-divider="boxes"] .scene-label{color:#827562!important}
@media(max-width:980px){html[data-route="writer"] .multi-scene-editor[data-scene-divider="boxes"] .scene-sheet{padding:42px clamp(24px,5vw,50px) 64px!important;border-radius:13px!important}}

html[data-route="reader"] #toolbar{display:none!important}
.reader-bar{background:rgba(250,246,238,.93)!important;border:1px solid rgba(82,73,61,.13)!important;box-shadow:0 8px 24px rgba(64,54,40,.07)!important;border-radius:12px!important;height:46px!important;padding:4px 7px!important}
html[data-theme="sylva-dark"] .reader-bar{background:rgba(27,36,29,.94)!important;border-color:rgba(232,220,201,.12)!important;box-shadow:0 10px 28px rgba(0,0,0,.24)!important}

.modal.review-start-dialog{width:min(880px,calc(100vw - 36px))!important;max-height:min(88dvh,900px)!important;padding:clamp(24px,3vw,36px)!important}
.review-start-modal>h2{font-size:clamp(25px,2.7vw,34px)!important;font-family:var(--ui-serif,Georgia,serif)!important;font-weight:500!important}.review-start-modal>p{font-size:12px!important;line-height:1.65!important;max-width:74ch!important}.review-start-grid{gap:14px!important;margin-top:22px!important}.review-start-card{min-height:150px!important;padding:22px!important}.review-start-card>b{font-size:18px!important}.review-start-card>small{font-size:11px!important;line-height:1.5!important}
#writerView.review-mode .editor-stage{position:fixed!important;inset:12px!important;z-index:95!important;width:auto!important;height:auto!important;background:var(--bg)!important;border-radius:20px!important;box-shadow:0 24px 80px rgba(0,0,0,.24)!important;overflow:hidden!important}
#writerView.review-mode .editor-viewport.review-active{padding:0!important;width:100%!important;height:100%!important;background:var(--bg)!important}
#writerView.review-mode .review-toolbar-row{display:flex;align-items:center;justify-content:center;min-width:0;flex:0 0 auto;padding:8px 12px;border-bottom:1px solid var(--line);background:color-mix(in srgb,var(--surface-2) 72%,transparent);overflow:hidden}
html[data-route="writer"] #writerView.review-mode .review-toolbar-row .floating-toolbar{display:flex!important;position:static!important;top:auto!important;left:auto!important;right:auto!important;transform:none!important;width:max-content!important;max-width:100%!important;min-height:42px!important;margin:0 auto!important;opacity:1!important;overflow-x:auto!important;overflow-y:hidden!important;scrollbar-width:none!important;overscroll-behavior-x:contain;touch-action:pan-x;z-index:2!important}
html[data-route="writer"] #writerView.review-mode .review-toolbar-row .floating-toolbar::-webkit-scrollbar{display:none!important}.review-workspace-head{padding:18px 20px!important;min-height:76px!important}.review-workspace-head h2{font-size:20px!important}.review-pane{padding:clamp(14px,2.1vw,26px)!important}.review-original-sheet,.review-edit-sheet{max-width:920px!important;margin-bottom:18px!important}.review-original-copy,.review-scene-editor{min-height:420px!important;padding:clamp(42px,4.2vw,68px) clamp(32px,5vw,76px) 72px!important}
html[data-theme="sylva-dark"] .review-original-sheet,html[data-theme="sylva-dark"] .review-edit-sheet{background:linear-gradient(180deg,#f4ecde,#eee2d1)!important;color:#302b24!important;border-color:rgba(201,174,132,.18)!important}html[data-theme="sylva-dark"] .review-original-copy,html[data-theme="sylva-dark"] .review-scene-editor{color:#302b24!important}html[data-theme="sylva-dark"] .review-scene-head{background:#e9dece!important}html[data-theme="sylva-dark"] .review-scene-head>span,html[data-theme="sylva-dark"] .review-scene-head>small{color:#776b5d!important}
@media(max-width:900px){#writerView.review-mode .editor-stage{inset:8px!important}.review-workspace-head{padding:14px!important;align-items:flex-start!important;flex-direction:column!important}.review-workspace-actions{width:100%!important;display:grid!important;grid-template-columns:1fr 1fr 1fr!important}.review-workspace-actions button{min-height:42px!important}.review-pane{padding:12px!important}.review-original-copy,.review-scene-editor{padding:36px clamp(22px,4vw,44px) 58px!important;min-height:360px!important}}
@media(max-width:680px){.review-panes{grid-template-columns:1fr!important;overflow:auto!important}.review-original-pane{border-right:0!important;border-bottom:1px solid var(--line)!important}.review-workspace{overflow:auto!important}.review-pane{overflow:visible!important}.review-workspace-actions{grid-template-columns:1fr!important}}

.home-library-section .book-library-grid,.book-library-grid{grid-template-columns:repeat(3,minmax(0,1fr))!important;gap:18px!important}.sylva-book-card{grid-template-columns:148px minmax(0,1fr)!important;min-height:210px!important;border-radius:18px!important}.book-cover-button{width:148px!important;height:210px!important}.book-card-body{padding:20px 17px 15px!important}.book-card-title-row h3{font-size:18px!important;line-height:1.2!important;margin-top:8px!important}.book-card-facts{font-size:10px!important;gap:10px!important;margin-top:14px!important}.sylva-book-card .book-icon-btn{width:34px!important;height:34px!important;min-height:34px!important}.book-card-actions.compact{right:11px!important;bottom:11px!important;gap:5px!important}
@media(max-width:1120px){.home-library-section .book-library-grid,.book-library-grid{grid-template-columns:repeat(2,minmax(0,1fr))!important}}@media(max-width:700px){.home-library-section .book-library-grid,.book-library-grid{grid-template-columns:1fr!important}.sylva-book-card{grid-template-columns:110px minmax(0,1fr)!important;min-height:158px!important}.book-cover-button{width:110px!important;height:158px!important}.book-card-body{padding:14px 12px 10px!important}.book-card-title-row h3{font-size:16px!important}.book-card-facts{font-size:9px!important;margin-top:9px!important}}
/* Reader is a dedicated full-screen workspace: no shell remnants. */

html[data-route="reader"] .main-area{position:fixed!important;inset:0!important;grid-column:1/-1!important;grid-row:1/-1!important;width:100vw!important;height:100dvh!important;z-index:70!important}
html[data-route="reader"] .reader-view{width:100%!important;height:100%!important}
/* Specificity guard against the desktop shell's !important rail rule. */



/* ===== SYLVA 0.837 · Search layout repair + palette collection ===== */
/* Search modal: fixed zones cannot collapse into each other inside the flex shell. */
.global-search-head,.global-search-box,.global-search-filters,.global-replace{flex:0 0 auto!important}
.global-search-results{flex:1 1 auto!important;min-height:0!important;position:relative!important;border-top:1px solid color-mix(in srgb,var(--line) 72%,transparent)!important;padding-top:14px!important;scroll-padding-top:14px!important}
.global-search-filters{position:relative!important;z-index:2!important;background:color-mix(in srgb,var(--surface-strong) 96%,transparent)!important;padding-bottom:13px!important}
@media(max-width:900px){.global-search-results{padding-top:12px!important}.global-search-filters{display:none!important}.global-search-box{margin-bottom:12px!important}}

/* Theme picker grows into a proper palette gallery. */
.modal.theme-picker-modal{width:min(930px,calc(100vw - 32px))!important;max-height:min(88dvh,900px)!important;overflow:auto!important}
.theme-picker-modal .theme-special-grid{grid-template-columns:repeat(3,minmax(0,1fr))!important;gap:11px!important}
.theme-picker-modal .theme-card{min-height:84px!important;padding:12px!important}
.theme-picker-modal .theme-preview{width:54px!important;height:54px!important;border-radius:15px!important;background:linear-gradient(135deg,var(--preview-bg) 0 58%,var(--preview-surface) 58% 100%)!important;position:relative!important;overflow:hidden!important}
.theme-picker-modal .theme-preview::before{content:""!important;position:absolute!important;left:9px!important;bottom:8px!important;width:28px!important;height:18px!important;border-radius:8px!important;background:color-mix(in srgb,var(--preview-surface) 86%,white 14%)!important;box-shadow:none!important}
.theme-picker-modal .theme-preview::after{content:""!important;position:absolute!important;right:7px!important;top:7px!important;width:9px!important;height:9px!important;border-radius:50%!important;background:var(--preview-accent)!important;box-shadow:0 0 0 4px color-mix(in srgb,var(--preview-accent) 15%,transparent)!important}
.theme-picker-modal .theme-copy b{font-size:13px!important}.theme-picker-modal .theme-copy small{font-size:9px!important;line-height:1.35!important}
@media(max-width:820px){.theme-picker-modal .theme-special-grid{grid-template-columns:repeat(2,minmax(0,1fr))!important}}
@media(max-width:560px){.theme-picker-modal .theme-special-grid{grid-template-columns:1fr!important}}

/* Keep highlight colors independent from the interface palette. */
html[data-palette] .highlight-swatch:nth-of-type(1){--swatch:#fff09a}html[data-palette] .highlight-swatch:nth-of-type(2){--swatch:#ffd2dc}html[data-palette] .highlight-swatch:nth-of-type(3){--swatch:#ccebdc}html[data-palette] .highlight-swatch:nth-of-type(4){--swatch:#cfdcf8}html[data-palette] .highlight-swatch:nth-of-type(5){--swatch:#e3d2f3}

/* ========================================================================== 
   Sylva 0.838 · product polish: invisible scrollbars, goal history, roadmap
   ========================================================================== */
/* Scroll is still enabled everywhere; only the chrome is hidden. */
html,body,*{scrollbar-width:none;-ms-overflow-style:none}
html::-webkit-scrollbar,body::-webkit-scrollbar,*::-webkit-scrollbar{width:0!important;height:0!important;display:none!important;background:transparent!important}

/* A small, explicit native spell-check status. The browser still owns the
   actual spelling underlines and context-menu suggestions. */
.spell-state{display:inline-flex;align-items:center;min-height:18px;padding:0 7px;border-radius:999px;border:1px solid var(--line);font:650 7px/1 Inter,system-ui,sans-serif;letter-spacing:.05em;color:var(--muted);background:var(--surface-2);white-space:nowrap}
.spell-state.on::before{content:"";width:5px;height:5px;border-radius:50%;background:#6ba874;margin-right:5px;box-shadow:0 0 0 2px color-mix(in srgb,#6ba874 14%,transparent)}
.spell-state.off{opacity:.58}.spell-state.off::before{content:"";width:5px;height:5px;border-radius:50%;background:#a66b64;margin-right:5px}
html[data-theme="sylva-dark"] .spell-state{background:rgba(235,225,207,.055);border-color:rgba(235,225,207,.10);color:#aaa296}
@media(max-width:1000px){.spell-state{display:none!important}}

/* Home metadata: saga + version are intentionally readable at a glance. */
.book-version-fact{font-weight:700!important;color:color-mix(in srgb,var(--accent) 72%,var(--text))!important}
.book-card-title-row>div>small{max-width:32ch;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}

/* Four information cards on wide screens, with graceful tablet/mobile flow. */
.home-info-grid{grid-template-columns:repeat(4,minmax(0,1fr))!important}
.home-info-card:last-child{grid-column:auto!important}
.roadmap-home-card{position:relative;overflow:hidden}
.roadmap-home-card::after{content:"1.00";position:absolute;right:14px;bottom:4px;font:500 36px/1 Georgia,serif;color:color-mix(in srgb,var(--accent) 9%,transparent);pointer-events:none}
@media(max-width:1180px){.home-info-grid{grid-template-columns:repeat(2,minmax(0,1fr))!important}}
@media(max-width:700px){.home-info-grid{grid-template-columns:1fr!important}}

/* Daily goal history */
.daily-goal-history-card{margin:12px 0 14px;padding:18px}
.daily-goal-history{display:grid;gap:16px;margin-top:14px}
.daily-goal-summary{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:8px}
.daily-goal-summary>div{padding:13px;border:1px solid var(--line);border-radius:14px;background:var(--surface-2)}
.daily-goal-summary b,.daily-goal-summary span{display:block}.daily-goal-summary b{font-size:18px;font-variant-numeric:tabular-nums}.daily-goal-summary span{margin-top:4px;font-size:8px;letter-spacing:.04em;color:var(--muted)}
.daily-goal-subhead{display:flex;align-items:center;justify-content:space-between;gap:12px;margin-top:2px}.daily-goal-subhead b{font-size:10px}.daily-goal-subhead span{font-size:8px;color:var(--muted)}
.daily-goal-calendar{display:grid;grid-template-columns:repeat(7,minmax(0,1fr));gap:6px}
.daily-goal-day{position:relative;min-height:48px;padding:7px;border:1px solid var(--line);border-radius:11px;background:var(--surface-2);display:flex;flex-direction:column;align-items:center;justify-content:center;gap:4px}
.daily-goal-day small{font-size:7px;color:var(--muted);text-transform:uppercase}.daily-goal-day b{font-size:11px;font-variant-numeric:tabular-nums}.daily-goal-day i{width:6px;height:6px;border-radius:50%;background:color-mix(in srgb,var(--muted) 24%,transparent)}
.daily-goal-day.met{background:color-mix(in srgb,#6d9c73 12%,var(--surface-2));border-color:color-mix(in srgb,#6d9c73 28%,var(--line))}.daily-goal-day.met i{background:#6d9c73}
.daily-goal-day.missed{background:color-mix(in srgb,#ad795b 10%,var(--surface-2));border-color:color-mix(in srgb,#ad795b 24%,var(--line))}.daily-goal-day.missed i{background:#ad795b}
.daily-goal-day.no-goal{opacity:.52}.daily-goal-day.today{box-shadow:inset 0 0 0 1px color-mix(in srgb,var(--accent) 64%,transparent)}
.daily-goal-list{display:grid;grid-template-columns:1fr 1fr;gap:6px}
.daily-goal-row{display:grid;grid-template-columns:minmax(0,1fr) auto auto;align-items:center;gap:10px;padding:9px 11px;border:1px solid var(--line);border-radius:12px;background:var(--surface-2)}
.daily-goal-row>span{display:flex;align-items:center;min-width:0;gap:7px}.daily-goal-row>span i{width:7px;height:7px;border-radius:50%;background:#ad795b;flex:0 0 auto}.daily-goal-row.met>span i{background:#6d9c73}.daily-goal-row b{font-size:9px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.daily-goal-row strong{font-size:9px;font-variant-numeric:tabular-nums}.daily-goal-row em{font-size:7px;color:var(--muted);font-style:normal;text-transform:uppercase;letter-spacing:.04em}
@media(max-width:900px){.daily-goal-summary{grid-template-columns:1fr 1fr}.daily-goal-list{grid-template-columns:1fr}.daily-goal-calendar{gap:4px}.daily-goal-day{min-height:44px;padding:5px}}
@media(max-width:540px){.daily-goal-history-card{padding:13px}.daily-goal-calendar{grid-template-columns:repeat(7,1fr)}.daily-goal-day{min-height:38px;border-radius:8px}.daily-goal-day small{display:none}.daily-goal-summary>div{padding:10px}.daily-goal-subhead span{display:none}}

/* Roadmap page */
.legal-roadmap{padding-bottom:90px}
.roadmap-hero{display:grid;grid-template-columns:minmax(0,1.35fr) minmax(250px,.65fr);gap:42px;align-items:end;padding:28px 0 34px}
.roadmap-hero>div>small{font-size:8px;letter-spacing:.15em;color:var(--accent);font-weight:700}.roadmap-hero h2{margin:9px 0 12px}.roadmap-hero p{max-width:70ch}.roadmap-hero-actions{display:flex;flex-direction:column;gap:9px}.roadmap-hero-actions button{min-height:44px}
.roadmap-version-card{padding:28px;border:1px solid color-mix(in srgb,var(--accent) 20%,var(--line));border-radius:24px;background:linear-gradient(145deg,color-mix(in srgb,var(--surface) 94%,var(--accent) 6%),var(--surface-2))}
.roadmap-version-head{display:flex;justify-content:space-between;align-items:flex-end;gap:16px;padding-bottom:18px;border-bottom:1px solid var(--line)}.roadmap-version-head small{font-size:8px;letter-spacing:.14em;color:var(--accent)}.roadmap-version-head h3{font:500 clamp(30px,4vw,48px)/1 Georgia,serif;margin:7px 0 0}.roadmap-version-head>span{font-size:9px;color:var(--muted)}
.roadmap-grid{display:grid;grid-template-columns:1fr 1fr;gap:9px;margin-top:18px}.roadmap-grid article{display:grid;grid-template-columns:34px minmax(0,1fr) auto;gap:12px;align-items:start;padding:15px;border:1px solid var(--line);border-radius:15px;background:color-mix(in srgb,var(--surface-2) 78%,transparent)}.roadmap-grid article>i{width:30px;height:30px;border-radius:9px;display:grid;place-items:center;background:var(--accent-soft);color:var(--accent);font:700 8px Inter,sans-serif;font-style:normal}.roadmap-grid b{display:block;font-size:11px}.roadmap-grid p{font-size:9px!important;margin:5px 0 0!important;line-height:1.5}.roadmap-grid article>span{font:700 6px/1 Inter,sans-serif;letter-spacing:.08em;color:var(--muted);padding:5px 7px;border-radius:99px;border:1px solid var(--line)}.roadmap-note{margin:17px 0 0!important;padding-top:16px;border-top:1px solid var(--line);font-size:9px!important;color:var(--muted)}
@media(max-width:900px){.roadmap-hero{grid-template-columns:1fr;gap:18px}.roadmap-hero-actions{flex-direction:row}.roadmap-grid{grid-template-columns:1fr}}
@media(max-width:560px){.roadmap-version-card{padding:18px}.roadmap-hero-actions{flex-direction:column}.roadmap-grid article{grid-template-columns:30px minmax(0,1fr)}.roadmap-grid article>span{grid-column:2;justify-self:start}.roadmap-version-head{align-items:flex-start;flex-direction:column}}

/* Support callout: voluntary contribution is not the subscription. */
.legal-support-card::before{content:"Contributi volontari · separati da Sync Online";position:absolute;left:32px;top:-10px;padding:4px 9px;border-radius:999px;background:var(--surface-strong);border:1px solid var(--line);font:700 7px/1 Inter,sans-serif;letter-spacing:.07em;color:var(--accent)}
.legal-support-card{position:relative}
@media(max-width:560px){.legal-support-card::before{left:18px}}

.legal-plan-grid{display:grid;grid-template-columns:1fr 1fr;gap:12px;margin:28px 0 0}.legal-plan-card{padding:22px;border:1px solid var(--line);border-radius:20px;background:var(--surface-2)}.legal-plan-card.cloud{border-color:color-mix(in srgb,var(--accent) 28%,var(--line));background:linear-gradient(145deg,color-mix(in srgb,var(--accent) 7%,var(--surface)),var(--surface-2))}.legal-plan-card>small{font:700 7px/1 Inter,sans-serif;letter-spacing:.14em;color:var(--accent)}.legal-plan-card h3{font:500 clamp(30px,4vw,46px)/1 Georgia,serif;margin:11px 0 8px}.legal-plan-card h3 em{font:500 12px/1 Inter,sans-serif;color:var(--muted);font-style:normal}.legal-plan-card>b{display:block;font-size:11px;margin-bottom:8px}.legal-plan-card p{font-size:9px!important;margin:0!important;line-height:1.55}.legal-plan-card>span{display:inline-flex;margin-top:14px;padding:5px 8px;border:1px solid var(--line);border-radius:999px;font:650 7px/1 Inter,sans-serif;color:var(--muted)}@media(max-width:700px){.legal-plan-grid{grid-template-columns:1fr}.legal-plan-card{padding:18px}}

/* 0.838 · native spelling feedback stays visible without replacing the browser dictionary. */
.scene-editor::spelling-error,.review-scene-editor::spelling-error{
  text-decoration-line:underline;
  text-decoration-style:wavy;
  text-decoration-color:#c65f59;
  text-decoration-thickness:1.25px;
  text-underline-offset:2px;
}
@media(max-width:1000px){
  .spell-state{display:inline-flex!important;padding:0 5px;font-size:6px;letter-spacing:.025em}
}


/* ===== 0.839 icon-only fix: restore simple in-app rail icons + clean codex symbols ===== */
html[data-route]:not([data-route="home"]) #rail .rail-btn{
  flex-direction:row!important;justify-content:flex-start!important;align-items:center!important;gap:10px!important;
  width:100%!important;padding:10px 12px!important;border-radius:14px!important;background:transparent!important;text-align:left!important
}
html[data-route]:not([data-route="home"]) #rail .rail-btn:hover,
html[data-route]:not([data-route="home"]) #rail .rail-btn.active{background:var(--accent-soft)!important;color:var(--text)!important}
html[data-route]:not([data-route="home"]) #rail .rail-btn .rail-icon-wrap{
  width:18px!important;height:18px!important;min-width:18px!important;flex:0 0 18px!important;display:inline-grid!important;place-items:center!important;
  background:none!important;background-image:none!important;border:0!important;border-radius:0!important;box-shadow:none!important;padding:0!important;transform:none!important
}
html[data-route]:not([data-route="home"]) #rail .rail-btn:hover .rail-icon-wrap,
html[data-route]:not([data-route="home"]) #rail .rail-btn.active .rail-icon-wrap{background:none!important;border:0!important;box-shadow:none!important;transform:none!important}
html[data-route]:not([data-route="home"]) #rail .rail-icon{width:18px!important;height:18px!important;stroke:currentColor!important;fill:none!important;stroke-width:1.65!important;visibility:visible!important}
html[data-route]:not([data-route="home"]) #rail .theme-icon-default{display:block!important;visibility:visible!important}
html[data-route]:not([data-route="home"]) #rail .theme-icon-nature{display:none!important;visibility:hidden!important}
html[data-route]:not([data-route="home"]) #rail .rail-btn small{font-size:13px!important;font-weight:600!important;line-height:1.1!important;letter-spacing:0!important;color:inherit!important}

.mini-codex-emoji{display:inline-flex;align-items:center;justify-content:center;min-width:1em;font-size:14px;line-height:1;vertical-align:-.08em}
.codex-card-categories .mini-codex-emoji,.codex-card-worldmeta .mini-codex-emoji{margin-right:4px}
.codex-icon-choice .codex-symbol,.codex-card-symbol .codex-symbol,.writer-codex-symbol .codex-symbol,.picker-cat-icon .codex-symbol{display:block!important;opacity:1!important;visibility:visible!important}
.codex-icon-choice .codex-symbol{width:20px!important;height:20px!important}
.codex-card-symbol .codex-symbol,.writer-codex-symbol .codex-symbol{width:24px!important;height:24px!important}
.picker-cat-icon .codex-symbol{width:16px!important;height:16px!important}

/* ===== final cleanup · only two default themes / clean nav glyphs ===== */
html[data-route]:not([data-route="home"]) #rail .rail-btn[data-route="reader"] .rail-icon-wrap,
html[data-route]:not([data-route="home"]) #rail .rail-btn[data-route="codex"] .rail-icon-wrap,
html[data-route]:not([data-route="home"]) #rail #themeToggle .rail-icon-wrap{background:none!important;background-image:none!important;border:0!important;box-shadow:none!important}
html[data-route]:not([data-route="home"]) #rail .rail-btn[data-route="reader"] .rail-icon,
html[data-route]:not([data-route="home"]) #rail .rail-btn[data-route="codex"] .rail-icon,
html[data-route]:not([data-route="home"]) #rail #themeToggle .rail-icon{width:19px!important;height:19px!important;stroke-width:1.6!important;visibility:visible!important}
html[data-route]:not([data-route="home"]) #rail .rail-btn[data-route="reader"] .theme-icon-default,
html[data-route]:not([data-route="home"]) #rail .rail-btn[data-route="codex"] .theme-icon-default,
html[data-route]:not([data-route="home"]) #rail #themeToggle .theme-icon-default{display:block!important}
html[data-route]:not([data-route="home"]) #rail .rail-btn[data-route="reader"] .theme-icon-nature,
html[data-route]:not([data-route="home"]) #rail .rail-btn[data-route="codex"] .theme-icon-nature,
html[data-route]:not([data-route="home"]) #rail #themeToggle .theme-icon-nature{display:none!important}

/* ========================================================================== 
   0.839 HOTFIX · tablet nav/sync + smartphone home only
   Surgical responsive fixes: no desktop/tablet visual system changes.
   ========================================================================== */

/* Tablet Android: browser chrome/safe-area was double-offsetting the Sylva
   navigation button. Anchor it to the CSS viewport itself. */
@media (pointer:coarse) and (min-width:561px) and (max-width:1366px){
  html[data-route]:not([data-route="home"]) .writer-nav-toggle{
    left:10px!important;
    top:9px!important;
  }

  /* When the Sync label collapses on tablet, the dot must remain a real box. */
  html[data-route="writer"] .writer-project-actions #cloudBtn .cloud-dot{
    display:block!important;
    width:10px!important;
    height:10px!important;
    min-width:10px!important;
    min-height:10px!important;
    flex:0 0 10px!important;
    border-radius:50%!important;
  }
}

/* Smartphone: force the normal Sylva Home to own the viewport after login.
   This only resolves conflicting legacy phone rules; editing remains blocked
   by the existing phoneLimitedMode routing logic. */
@media(max-width:560px){
  html.phone-only.workspace-entered,
  html.phone-only.workspace-entered body{
    width:100%!important;
    height:100%!important;
    min-height:100%!important;
    overflow:hidden!important;
  }
  html.phone-only.workspace-entered[data-route="home"] #app{
    display:grid!important;
    grid-template-columns:1fr!important;
    grid-template-rows:1fr!important;
    width:100vw!important;
    height:100dvh!important;
    min-height:100dvh!important;
    max-height:100dvh!important;
    padding:0!important;
    margin:0!important;
    overflow:hidden!important;
    visibility:visible!important;
    opacity:1!important;
    pointer-events:auto!important;
  }
  html.phone-only.workspace-entered[data-route="home"] .main-area{
    display:block!important;
    grid-column:1!important;
    grid-row:1!important;
    position:relative!important;
    width:100%!important;
    height:100dvh!important;
    min-height:0!important;
    overflow:hidden!important;
  }
  html.phone-only.workspace-entered[data-route="home"] #homeView{
    display:flex!important;
    flex-direction:column!important;
    width:100%!important;
    max-width:none!important;
    height:100%!important;
    min-height:0!important;
    margin:0!important;
    overflow-x:hidden!important;
    overflow-y:auto!important;
    visibility:visible!important;
    opacity:1!important;
    background:var(--bg)!important;
    -webkit-overflow-scrolling:touch!important;
  }
  html.phone-only.workspace-entered[data-route="home"] .phone-access{
    display:none!important;
  }
  html.phone-only.workspace-entered[data-route="home"] #modalBackdrop:not(.open){
    display:none!important;
  }
}


/* ===== Tablet/Mobile hotfix 2: portrait Home viewport only =====
   Do not touch Writer or desktop/tablet landscape. On phones and portrait
   coarse-pointer screens the normal Sylva Home owns the viewport directly. */
@media (orientation:portrait) and (max-width:900px){
  html.workspace-entered[data-route="home"],
  html.workspace-entered[data-route="home"] body{
    width:100%!important;
    min-width:0!important;
    height:100%!important;
    min-height:100%!important;
    overflow:hidden!important;
    background:var(--bg)!important;
  }
  html.workspace-entered[data-route="home"] #app{
    display:block!important;
    position:fixed!important;
    inset:0!important;
    width:100vw!important;
    height:100dvh!important;
    min-height:100dvh!important;
    max-height:none!important;
    margin:0!important;
    padding:0!important;
    overflow:hidden!important;
    visibility:visible!important;
    opacity:1!important;
    pointer-events:auto!important;
    background:var(--bg)!important;
  }
  html.workspace-entered[data-route="home"] .main-area{
    display:block!important;
    position:absolute!important;
    inset:0!important;
    width:auto!important;
    height:auto!important;
    min-width:0!important;
    min-height:0!important;
    overflow:hidden!important;
  }
  html.workspace-entered[data-route="home"] #homeView,
  html.workspace-entered[data-route="home"] #homeView.view.active{
    display:block!important;
    position:absolute!important;
    inset:0!important;
    width:auto!important;
    max-width:none!important;
    height:auto!important;
    min-height:100%!important;
    margin:0!important;
    padding-left:max(15px,env(safe-area-inset-left))!important;
    padding-right:max(15px,env(safe-area-inset-right))!important;
    overflow-x:hidden!important;
    overflow-y:auto!important;
    visibility:visible!important;
    opacity:1!important;
    -webkit-overflow-scrolling:touch!important;
    overscroll-behavior-y:contain!important;
    background:var(--bg)!important;
  }
  html.workspace-entered[data-route="home"] #rail,
  html.workspace-entered[data-route="home"] .topbar,
  html.workspace-entered[data-route="home"] .writer-nav-toggle,
  html.workspace-entered[data-route="home"] .phone-access{
    display:none!important;
  }
  html.workspace-entered[data-route="home"] #modalBackdrop:not(.open){display:none!important}
}


/* Sylva help · standalone tutorial launcher */
.sylva-help-fab{
  position:fixed;
  right:max(16px,env(safe-area-inset-right));
  bottom:max(16px,env(safe-area-inset-bottom));
  z-index:120;
  width:46px;
  height:46px;
  display:grid;
  place-items:center;
  border-radius:50%;
  border:1px solid color-mix(in srgb,var(--accent) 22%,var(--line));
  background:color-mix(in srgb,var(--surface-strong) 94%,var(--accent) 6%);
  color:var(--text);
  box-shadow:0 10px 28px rgba(0,0,0,.18),inset 0 1px rgba(255,255,255,.08);
  text-decoration:none;
  -webkit-tap-highlight-color:transparent;
  transition:transform .18s ease,background .18s ease,border-color .18s ease,box-shadow .18s ease;
}
.sylva-help-fab svg{width:24px;height:24px;fill:none;stroke:currentColor;stroke-width:1.7;stroke-linecap:round;stroke-linejoin:round}
.sylva-help-fab .help-leaf{stroke:var(--accent)}
.sylva-help-fab:hover,.sylva-help-fab:focus-visible{
  transform:translateY(-2px);
  background:color-mix(in srgb,var(--surface-strong) 86%,var(--accent) 14%);
  border-color:color-mix(in srgb,var(--accent) 42%,var(--line));
  box-shadow:0 14px 34px rgba(0,0,0,.22),inset 0 1px rgba(255,255,255,.10);
  outline:none;
}
.sylva-help-fab:active{transform:translateY(0) scale(.96)}
@media(max-width:900px){
  .sylva-help-fab{right:max(12px,env(safe-area-inset-right));bottom:max(12px,env(safe-area-inset-bottom));width:44px;height:44px}
}
@media(max-width:560px){
  .sylva-help-fab{width:42px;height:42px}
  .sylva-help-fab svg{width:22px;height:22px}
}
@media(prefers-reduced-motion:reduce){.sylva-help-fab{transition:none}}

/* ========================================================================== 
   Sylva Beta 0.846 · Codex avanzato · QA leggibilità/responsive
   Solo UI Codex: analisi locale, alias univoci, contesto narrativo e suggerimenti.
   ========================================================================== */
.codex-advanced{margin:0 0 22px;padding:24px 25px;border-radius:24px;overflow:hidden}
.codex-advanced-head{display:flex;align-items:flex-start;justify-content:space-between;gap:24px}
.codex-advanced-head>div:first-child{min-width:0}
.codex-advanced-head small,.codex-insight-modal-head small{display:block;font:700 11px/1.3 Inter,sans-serif;letter-spacing:.14em;color:var(--accent)}
.codex-advanced-head h3{margin:7px 0 7px;font-size:22px;line-height:1.2;font-weight:560;letter-spacing:-.025em}
.codex-advanced-head p{margin:0;max-width:68ch;font-size:12px;line-height:1.65;color:var(--muted)}
.codex-advanced-actions{display:flex;align-items:center;justify-content:flex-end;gap:9px;flex-wrap:wrap;flex:0 0 auto}
.codex-advanced-actions .soft-btn{min-height:40px}
.codex-alias-warning{color:#b36f61!important;border-color:color-mix(in srgb,#b36f61 32%,var(--line))!important;background:color-mix(in srgb,#b36f61 8%,var(--surface-2))!important}
.codex-advanced-stats{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:10px;margin:20px 0 18px}
.codex-advanced-stats>div{min-width:0;padding:15px 16px;border:1px solid var(--line);border-radius:15px;background:color-mix(in srgb,var(--surface-2) 78%,transparent)}
.codex-advanced-stats b,.codex-advanced-stats span{display:block;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.codex-advanced-stats b{font-size:22px;line-height:1.15;font-weight:570;font-variant-numeric:tabular-nums}
.codex-advanced-stats span{margin-top:6px;font:650 11px/1.3 Inter,sans-serif;letter-spacing:.055em;text-transform:uppercase;color:var(--muted)}
.codex-advanced-stats .warn b{color:#b36f61}
.codex-advanced-top{padding-top:17px;border-top:1px solid var(--line)}
.codex-advanced-subhead{display:flex;align-items:center;justify-content:space-between;gap:12px;margin-bottom:12px}
.codex-advanced-subhead b{font-size:12px}.codex-advanced-subhead span{font-size:11px;color:var(--muted)}
.codex-top-list{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:8px}
.codex-top-entry{display:grid;grid-template-columns:8px minmax(0,1fr);align-items:center;gap:11px;min-width:0;min-height:50px;text-align:left;padding:11px 12px;border:1px solid var(--line);border-radius:13px;background:var(--surface-2);color:var(--text)}
.codex-top-entry:hover{background:var(--accent-soft);border-color:color-mix(in srgb,var(--accent) 22%,var(--line))}
.codex-top-entry>i{width:8px;height:8px;border-radius:50%;background:var(--entry-color)}
.codex-top-entry b,.codex-top-entry small{display:block;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.codex-top-entry b{font-size:12px;line-height:1.25}.codex-top-entry small{font-size:11px;line-height:1.35;color:var(--muted);margin-top:4px}
.codex-advanced-empty{grid-column:1/-1;color:var(--muted);font-size:11px;line-height:1.55;padding:8px 2px}
.codex-card-foot{flex-wrap:wrap}.codex-card-foot>span{min-width:0;flex:1;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.codex-card-foot>em{font-style:normal;font-size:11px;line-height:1.35;white-space:nowrap;color:color-mix(in srgb,var(--muted) 82%,transparent)}

.codex-alias-hint{margin-top:9px;padding:11px 12px;border:1px solid var(--line);border-radius:11px;background:color-mix(in srgb,var(--surface-2) 78%,transparent)}
.codex-alias-hint b,.codex-alias-hint span{display:block}.codex-alias-hint b{font-size:11px;line-height:1.3;font-weight:650}.codex-alias-hint span{margin-top:4px;font-size:11px;line-height:1.55;color:var(--muted)}
.codex-alias-hint.conflict{border-color:color-mix(in srgb,#b36f61 38%,var(--line));background:color-mix(in srgb,#b36f61 8%,var(--surface-2))}.codex-alias-hint.conflict b{color:#b36f61}

.codex-context{margin:22px 0 4px;border-top:1px solid var(--line);padding-top:21px}
.codex-context-grid{display:grid;grid-template-columns:1fr 1fr;gap:11px;margin-top:14px}
.codex-context-block{min-width:0;padding:15px;border:1px solid var(--line);border-radius:14px;background:color-mix(in srgb,var(--surface-2) 72%,transparent)}
.codex-context-block.span-2{grid-column:1/-1}
.codex-context-title{display:flex;align-items:baseline;justify-content:space-between;gap:10px;margin-bottom:11px}.codex-context-title b{font-size:12px;line-height:1.35}.codex-context-title small{font-size:11px;line-height:1.4;color:var(--muted);text-align:right}
.codex-co-list{display:grid;grid-template-columns:1fr 1fr;gap:7px}
.codex-co-list button{display:grid;grid-template-columns:7px minmax(0,1fr) auto;align-items:center;gap:9px;min-width:0;min-height:42px;padding:9px 10px;border:1px solid var(--line);border-radius:11px;background:var(--surface-2);color:var(--text);text-align:left}
.codex-co-list button:hover{background:var(--accent-soft)}.codex-co-list i{width:7px;height:7px;border-radius:50%;background:var(--entry-color)}.codex-co-list span{font-size:11px;line-height:1.35;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.codex-co-list strong{font-size:11px;color:var(--muted);font-variant-numeric:tabular-nums}
.codex-context-links,.codex-timeline-links{display:flex;flex-direction:column;gap:6px}
.codex-context-links button,.codex-timeline-links button{display:grid;grid-template-columns:minmax(0,1fr) 18px;align-items:center;gap:9px;width:100%;min-height:44px;padding:9px 10px;border:1px solid transparent;border-radius:11px;background:transparent;color:var(--text);text-align:left}
.codex-context-links button:hover,.codex-timeline-links button:hover{background:var(--surface-2);border-color:var(--line)}
.codex-context-links b,.codex-context-links small,.codex-timeline-links b,.codex-timeline-links small{display:block;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.codex-context-links b,.codex-timeline-links b{font-size:11px;line-height:1.35}.codex-context-links small,.codex-timeline-links small{font-size:11px;line-height:1.4;color:var(--muted);margin-top:3px}.codex-context-links em,.codex-timeline-links em{font-style:normal;color:var(--muted)}
.codex-appearance-empty.compact{margin-top:0;padding:12px;font-size:11px;line-height:1.5}

.modal.codex-insight-modal{width:min(880px,calc(100vw - 28px));max-height:min(90dvh,920px)}
.codex-insight-modal-head h2{margin:7px 0 7px}.codex-insight-modal-head p{margin:0 0 18px;font-size:12px;line-height:1.6}
.codex-suggestion-summary{display:flex;align-items:center;gap:9px;margin:8px 0 13px}.codex-suggestion-summary span{padding:7px 10px;border:1px solid var(--line);border-radius:999px;background:var(--surface-2);font-size:11px;color:var(--muted)}.codex-suggestion-summary b{color:var(--text)}
.codex-suggestion-list{display:flex;flex-direction:column;gap:9px;max-height:58dvh;overflow:auto;padding-right:2px}
.codex-suggestion-list article{display:grid;grid-template-columns:minmax(0,1fr) auto;gap:16px;align-items:center;padding:15px 16px;border:1px solid var(--line);border-radius:14px;background:var(--surface-2)}
.codex-suggestion-list article>div:first-child{min-width:0}.codex-suggestion-list h3{margin:0 0 6px;font-size:14px;line-height:1.3}.codex-suggestion-list p{margin:0!important;font-size:11px!important;line-height:1.5!important;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.codex-suggestion-list small{display:block;margin-top:6px;font-size:11px;line-height:1.4;color:var(--muted)}.codex-suggestion-list article>div:last-child{display:flex;gap:7px;align-items:center}.codex-suggestion-list button{min-height:38px;white-space:nowrap}
.codex-suggestion-empty{min-height:210px;display:flex;flex-direction:column;align-items:center;justify-content:center;text-align:center;border:1px dashed var(--line);border-radius:15px;color:var(--muted);gap:7px}.codex-suggestion-empty b{color:var(--text);font-size:13px}.codex-suggestion-empty span{font-size:11px;line-height:1.5}
.codex-alias-report{display:flex;flex-direction:column;gap:9px;max-height:58dvh;overflow:auto}.codex-alias-report-row{display:grid;grid-template-columns:190px minmax(0,1fr);gap:14px;align-items:center;padding:13px 14px;border:1px solid var(--line);border-radius:13px;background:var(--surface-2)}.codex-alias-report-row>span b,.codex-alias-report-row>span small{display:block}.codex-alias-report-row>span b{font-size:12px;line-height:1.3}.codex-alias-report-row>span small{font-size:11px;line-height:1.4;color:var(--muted);margin-top:4px}.codex-alias-report-row>div{display:flex;gap:6px;flex-wrap:wrap}.codex-alias-report-row button{border:1px solid var(--line);border-radius:999px;background:var(--surface);color:var(--text);padding:7px 10px;font-size:11px;line-height:1.3}.codex-alias-report-row button:hover{background:var(--accent-soft)}

@media(max-width:1000px){
  .codex-advanced{padding:20px}.codex-top-list{grid-template-columns:1fr 1fr}.codex-context-grid{grid-template-columns:1fr}.codex-context-block.span-2{grid-column:auto}
}
@media(max-width:900px){
  .codex-advanced-head{flex-direction:column;gap:17px}.codex-advanced-actions{width:100%;justify-content:flex-start}.codex-advanced-stats{grid-template-columns:1fr 1fr}.codex-advanced-stats>div{padding:14px 15px}
}
@media(max-width:700px){
  .codex-advanced{padding:17px;border-radius:20px}.codex-top-list{grid-template-columns:1fr}.codex-co-list{grid-template-columns:1fr}.codex-context-title{align-items:flex-start;flex-direction:column}.codex-context-title small{text-align:left}.codex-suggestion-list article{grid-template-columns:1fr}.codex-suggestion-list article>div:last-child{justify-content:flex-end}.codex-alias-report-row{grid-template-columns:1fr}.modal.codex-insight-modal{width:calc(100vw - 16px)}
}
@media(pointer:coarse) and (min-width:561px) and (max-width:1366px){
  .codex-advanced-actions .soft-btn,.codex-top-entry,.codex-co-list button,.codex-context-links button,.codex-timeline-links button{min-height:44px}.codex-suggestion-list button{min-height:44px}.codex-alias-report-row button{min-height:40px}
}

/* ========================================================================== 
   Sylva 0.847 · Controllo narrativa locale
   ========================================================================== */
.narrative-check-card{padding:22px!important}
.narrative-check-summary{display:grid;grid-template-columns:minmax(0,1.35fr) minmax(360px,.65fr);gap:18px;align-items:stretch;margin-top:14px}
.narrative-check-status{display:flex;align-items:center;gap:16px;padding:18px;border:1px solid var(--line);border-radius:18px;background:var(--surface-2)}
.narrative-check-status>span{width:52px;height:52px;flex:0 0 52px;border-radius:16px;display:grid;place-items:center;font-size:24px;font-weight:700;background:color-mix(in srgb,#4ba885 13%,var(--surface-strong));border:1px solid color-mix(in srgb,#4ba885 30%,var(--line));color:#4ba885}
.narrative-check-summary.has-errors .narrative-check-status>span{background:color-mix(in srgb,#d15d70 13%,var(--surface-strong));border-color:color-mix(in srgb,#d15d70 36%,var(--line));color:#d15d70}
.narrative-check-summary.has-warnings .narrative-check-status>span{background:color-mix(in srgb,#d49549 13%,var(--surface-strong));border-color:color-mix(in srgb,#d49549 36%,var(--line));color:#d49549}
.narrative-check-summary.has-info .narrative-check-status>span{background:color-mix(in srgb,#4c91d8 12%,var(--surface-strong));border-color:color-mix(in srgb,#4c91d8 32%,var(--line));color:#4c91d8}
.narrative-check-status small{display:block;font-size:11px;font-weight:700;letter-spacing:.1em;color:var(--muted)}
.narrative-check-status h3{font-size:22px;font-weight:560;margin:5px 0 6px}
.narrative-check-status p{font-size:13px;line-height:1.55;color:var(--muted);margin:0}
.narrative-check-counts{display:grid;grid-template-columns:1fr 1fr;gap:8px}
.narrative-check-counts>div{min-height:82px;padding:14px;border:1px solid var(--line);border-radius:16px;background:var(--surface-2);display:flex;flex-direction:column;justify-content:center}
.narrative-check-counts b{font-size:24px;font-weight:520;line-height:1}
.narrative-check-counts span{font-size:11px;color:var(--muted);margin-top:7px;text-transform:uppercase;letter-spacing:.06em}
.narrative-check-coverage{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:10px;margin-top:12px}
.narrative-check-coverage>div{padding:13px 14px;border:1px solid var(--line);border-radius:15px;background:var(--surface-2)}
.narrative-check-coverage>div>span{display:flex;align-items:center;justify-content:space-between;gap:10px;margin-bottom:9px}
.narrative-check-coverage b{font-size:12px}.narrative-check-coverage em{font-size:12px;font-style:normal;color:var(--muted);font-variant-numeric:tabular-nums}
.narrative-check-coverage i{display:block;height:5px;border-radius:99px;background:color-mix(in srgb,var(--muted) 13%,transparent);overflow:hidden}
.narrative-check-coverage u{display:block;height:100%;border-radius:inherit;background:linear-gradient(90deg,var(--accent),color-mix(in srgb,var(--accent) 62%,var(--accent-2)));text-decoration:none}
.narrative-check-actions{display:flex;align-items:center;justify-content:space-between;gap:18px;margin-top:14px;padding-top:14px;border-top:1px solid var(--line)}
.narrative-check-actions p{max-width:72ch;margin:0;font-size:12px;line-height:1.55;color:var(--muted)}
.narrative-check-actions button{min-height:42px;white-space:nowrap}

.narrative-check-modal{width:min(940px,calc(100vw - 34px))!important;max-height:min(88vh,900px)!important}
.narrative-report-head small{display:block;font-size:11px;font-weight:700;letter-spacing:.12em;color:var(--accent)}
.narrative-report-head h2{font-size:27px;margin:7px 0 8px;font-weight:550}
.narrative-report-head p{font-size:13px;line-height:1.58;color:var(--muted);margin:0;max-width:78ch}
.narrative-report-stats{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:8px;margin:18px 0 12px}
.narrative-report-stats>div{padding:13px 14px;border:1px solid var(--line);border-radius:14px;background:var(--surface-2)}
.narrative-report-stats b{display:block;font-size:23px;font-weight:520}.narrative-report-stats span{display:block;margin-top:5px;font-size:11px;text-transform:uppercase;letter-spacing:.06em;color:var(--muted)}
.narrative-report-stats .error b{color:#d15d70}.narrative-report-stats .warn b{color:#d49549}.narrative-report-stats .info b{color:#4c91d8}
.narrative-report-filters{display:flex;align-items:center;gap:6px;flex-wrap:wrap;padding:8px;border:1px solid var(--line);border-radius:14px;background:var(--surface-2);margin-bottom:12px}
.narrative-report-filters button{min-height:36px;padding:0 13px;border:0;border-radius:10px;background:transparent;color:var(--muted);font-size:12px;font-weight:650}
.narrative-report-filters button:hover,.narrative-report-filters button.active{background:var(--accent-soft);color:var(--text)}
.narrative-report-list{display:flex;flex-direction:column;gap:9px;max-height:52vh;overflow:auto;padding-right:2px}
.narrative-report-issue{display:grid;grid-template-columns:10px minmax(0,1fr) auto;gap:14px;align-items:start;padding:15px;border:1px solid var(--line);border-radius:16px;background:var(--surface-2)}
.narrative-report-issue>i{width:9px;height:9px;border-radius:50%;margin-top:8px;background:#4c91d8;box-shadow:0 0 0 4px color-mix(in srgb,#4c91d8 10%,transparent)}
.narrative-report-issue.error>i{background:#d15d70;box-shadow:0 0 0 4px color-mix(in srgb,#d15d70 10%,transparent)}
.narrative-report-issue.warn>i{background:#d49549;box-shadow:0 0 0 4px color-mix(in srgb,#d49549 10%,transparent)}
.narrative-report-copy small{display:block;font-size:11px;font-weight:700;letter-spacing:.07em;text-transform:uppercase;color:var(--muted)}
.narrative-report-copy h3{font-size:15px;font-weight:620;margin:4px 0 6px}
.narrative-report-copy p{font-size:12px;line-height:1.55;color:var(--muted);margin:0;max-width:74ch}
.narrative-report-actions{display:flex;align-items:center;justify-content:flex-end;gap:6px;flex-wrap:wrap;max-width:300px}
.narrative-report-actions .soft-btn,.narrative-report-actions .primary-btn{min-height:36px;padding:0 11px;font-size:11px}
.narrative-ignore-btn{min-height:36px;padding:0 10px;border:1px solid transparent;border-radius:10px;background:transparent;color:var(--muted);font-size:11px;font-weight:600}
.narrative-ignore-btn:hover{border-color:var(--line);background:var(--surface);color:var(--text)}
.narrative-report-clean{text-align:center;padding:42px 18px;border:1px solid var(--line);border-radius:18px;background:var(--surface-2)}
.narrative-report-clean>b{display:inline-grid;place-items:center;width:58px;height:58px;border-radius:18px;background:color-mix(in srgb,#4ba885 13%,var(--surface-strong));color:#4ba885;font-size:26px}
.narrative-report-clean h3{font-size:19px;margin:12px 0 6px}.narrative-report-clean p{font-size:12px;line-height:1.55;color:var(--muted);margin:0}

@media(max-width:1100px){
  .narrative-check-summary{grid-template-columns:1fr}
  .narrative-check-counts{grid-template-columns:repeat(4,minmax(0,1fr))}
  .narrative-check-counts>div{min-height:74px}
}
@media(max-width:820px){
  .narrative-check-card{padding:18px!important}
  .narrative-check-counts{grid-template-columns:1fr 1fr}
  .narrative-check-coverage{grid-template-columns:1fr}
  .narrative-check-actions{align-items:stretch;flex-direction:column}
  .narrative-check-actions button{width:100%;min-height:44px}
  .narrative-report-issue{grid-template-columns:10px minmax(0,1fr)}
  .narrative-report-actions{grid-column:2;justify-content:flex-start;max-width:none}
  .narrative-report-actions .soft-btn,.narrative-report-actions .primary-btn,.narrative-ignore-btn{min-height:42px}
}
@media(max-width:560px){
  .narrative-check-status{align-items:flex-start;padding:15px}.narrative-check-status>span{width:44px;height:44px;flex-basis:44px;border-radius:14px;font-size:21px}
  .narrative-check-status h3{font-size:19px}.narrative-check-status p{font-size:12px}
  .narrative-report-stats{grid-template-columns:1fr 1fr}
  .narrative-report-head h2{font-size:23px}
  .narrative-report-list{max-height:48vh}
  .narrative-report-actions{gap:5px}
}


/* ===== Sylva 0.848 · Codex backup / import / reset ===== */
.codex-advanced-actions .soft-btn.danger{border-color:color-mix(in srgb,var(--danger) 26%,var(--line));color:color-mix(in srgb,var(--danger) 82%,var(--text));background:color-mix(in srgb,var(--danger-soft) 74%,transparent)}
.codex-advanced-actions .soft-btn.danger:hover{background:var(--danger-soft);border-color:color-mix(in srgb,var(--danger) 38%,var(--line))}
.codex-reset-head small,.codex-import-warning small{display:block;font-size:11px;font-weight:750;letter-spacing:.12em;color:var(--danger);margin-bottom:7px}
.codex-import-warning small{color:var(--accent)}
.codex-reset-head h2,.codex-import-warning h2{margin:0 0 10px;font-size:24px;line-height:1.15}
.codex-reset-head p,.codex-import-warning p{margin:0 0 16px;font-size:12px;line-height:1.6;color:var(--muted)}
.codex-import-note{padding:12px 14px;border:1px solid var(--line);border-radius:12px;background:var(--surface-2);font-size:12px;line-height:1.55;color:var(--muted)}
.codex-reset-modal .danger-copy,.codex-import-modal .danger-copy{font-size:12px;line-height:1.6;padding:14px 15px}
@media(max-width:900px){.codex-advanced-actions{justify-content:flex-start}.codex-advanced-actions .soft-btn{min-height:44px;padding-left:13px;padding-right:13px}.codex-reset-head h2,.codex-import-warning h2{font-size:22px}}
@media(max-width:560px){.codex-advanced-actions{display:grid;grid-template-columns:1fr 1fr;width:100%}.codex-advanced-actions .soft-btn{width:100%}.codex-advanced-actions #codexDiscoverTerms{grid-column:1/-1}}


/* ===== Sylva 0.849 · DOCX home integration ===== */
@media(min-width:1400px){.home-export-actions{grid-template-columns:repeat(5,minmax(0,1fr))!important}}
@media(min-width:1101px) and (max-width:1399px){.home-export-actions{grid-template-columns:repeat(3,minmax(0,1fr))!important}}
.home-import-row{flex-wrap:wrap}.home-import-row>span{flex:1 1 260px}
.docx-import-head small{font-size:10px;letter-spacing:.12em;color:var(--accent);font-weight:700}.docx-import-head h2{margin:6px 0 8px}.docx-import-head p{margin:0;color:var(--muted);font-size:12px;line-height:1.55}.docx-import-stats{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:9px;margin:18px 0}.docx-import-stats span{padding:12px;border:1px solid var(--line);border-radius:13px;background:var(--surface-2);font-size:11px;color:var(--muted)}.docx-import-stats b{display:block;font-size:20px;color:var(--text);margin-bottom:3px}.phone-book-exports{grid-template-columns:repeat(4,minmax(0,1fr))}.book-mobile-exports{grid-template-columns:repeat(4,minmax(0,1fr))!important}
@media(max-width:700px){.docx-import-stats{grid-template-columns:1fr 1fr}.home-import-row>button{width:100%}.home-import-row>span{flex-basis:100%}}


/* ===== Sylva 0.849 QA · latest feature readability / responsive ===== */
.home-export-actions .big-action{min-height:116px!important;padding:17px!important}
.home-export-actions .big-action b{font-size:12.5px!important;line-height:1.25!important}
.home-export-actions .big-action small{font-size:10.5px!important;line-height:1.5!important;margin-top:5px!important}
.home-import-row{gap:10px 12px!important;margin-top:16px!important}
.home-import-row>button{min-height:42px!important;padding-left:14px!important;padding-right:14px!important}
.home-import-row>span{font-size:10.5px!important;line-height:1.55!important;min-width:220px}
.docx-import-head small{font-size:11px!important}
.docx-import-head h2{font-size:24px!important;line-height:1.2!important}
.docx-import-head p{font-size:12.5px!important}
.docx-import-stats span{font-size:11.5px!important;line-height:1.4!important;padding:14px!important}
.docx-import-stats b{font-size:21px!important}
@media(max-width:1100px){
  .home-export-actions .big-action{min-height:110px!important}
}
@media(max-width:700px){
  .home-import-row{width:100%!important}
  .home-import-row>button{width:100%!important;min-height:46px!important}
  .home-import-row>span{font-size:11px!important;min-width:0!important}
  .docx-import-stats{gap:8px!important}.docx-import-stats span{min-height:72px!important}
}

@media(max-width:700px){
  html.phone-only .sylva-book-card .book-mobile-exports{display:grid!important;grid-template-columns:repeat(2,minmax(0,1fr))!important;gap:7px!important;padding-right:0!important;width:100%!important}
  html.phone-only .sylva-book-card .book-mobile-exports button{min-height:38px!important;padding:0 9px!important;font-size:10.5px!important}
}

/* ===== Sylva 0.850 · stabilità / diagnostica ===== */
.modal.technical-diagnostics{width:min(820px,calc(100vw - 34px));max-height:min(88vh,900px)}
.technical-diag-loading{margin:20px 0;padding:18px;border:1px solid var(--line);border-radius:16px;background:var(--surface-2);font-size:12px;color:var(--muted)}
.technical-diag-head small{display:block;font-size:11px;font-weight:750;letter-spacing:.12em;color:var(--accent)}
.technical-diag-head h2{margin:6px 0 8px;font-size:26px;line-height:1.18}
.technical-diag-head p{margin:0;color:var(--muted);font-size:12.5px;line-height:1.58}
.tech-diag-grid{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:9px;margin:18px 0 12px}
.tech-diag-card{min-height:86px;padding:14px;border:1px solid var(--line);border-radius:15px;background:var(--surface-2);display:flex;flex-direction:column;justify-content:center}
.tech-diag-card small{font-size:11px;line-height:1.35;color:var(--muted)}
.tech-diag-card b{margin-top:7px;font-size:18px;font-weight:620}
.tech-diag-card.ok b{color:#4ba885}.tech-diag-card.warn b{color:#d49549}
.tech-diag-facts{display:grid;grid-template-columns:1fr 1fr;gap:8px;margin:0 0 12px}
.tech-diag-facts>div{display:flex;align-items:center;justify-content:space-between;gap:16px;padding:12px 13px;border:1px solid var(--line);border-radius:13px;background:color-mix(in srgb,var(--surface-2) 78%,transparent)}
.tech-diag-facts span{font-size:11.5px;color:var(--muted)}.tech-diag-facts b{font-size:12px;text-align:right;word-break:break-word}
.tech-diag-note{padding:15px 16px;border:1px solid color-mix(in srgb,var(--accent) 18%,var(--line));border-radius:15px;background:color-mix(in srgb,var(--accent-soft) 45%,var(--surface-2))}
.tech-diag-note b{font-size:12.5px}.tech-diag-note p{margin:6px 0 0;font-size:11.5px;line-height:1.58;color:var(--muted)}
.modal.technical-diagnostics .modal-actions{margin-top:16px}.modal.technical-diagnostics .modal-actions button{min-height:42px}
@media(max-width:900px){.tech-diag-grid{grid-template-columns:1fr 1fr}.tech-diag-card{min-height:80px}.modal.technical-diagnostics .modal-actions button{min-height:44px}}
@media(max-width:560px){.modal.technical-diagnostics{width:calc(100vw - 16px)}.technical-diag-head h2{font-size:23px}.tech-diag-facts{grid-template-columns:1fr}.tech-diag-facts>div{align-items:flex-start}.tech-diag-facts b{max-width:55%}}

/* ========================================================================== 
   Sylva 0.851 · Reader book view
   Physical proportions: 13×20, 14×21, 15×23. Classic reader remains intact.
   ========================================================================== */
.reader-classic-view{display:block;min-height:100%}
.reader-book-view{display:none;width:100%;height:100%;min-height:0;flex-direction:column;padding:72px clamp(12px,2.2vw,30px) max(12px,env(safe-area-inset-bottom));overflow:hidden}
.reader-mode-book .reader-classic-view{display:none!important}
.reader-mode-book .reader-book-view{display:flex!important}
.reader-mode-book .reader-viewport{padding:0!important;overflow:hidden!important;scroll-behavior:auto!important}
.reader-mode-classic .reader-book-view{display:none!important}
.reader-mode-classic .reader-classic-view{display:block!important}
.reader-mode-classic .reader-viewport{overflow-y:auto!important;overflow-x:hidden!important;padding:90px 0 14vh!important;scroll-behavior:smooth!important;scrollbar-width:none!important}
.reader-mode-classic .reader-viewport::-webkit-scrollbar{width:0!important;height:0!important;display:none!important}

.reader-view-toggle{position:relative;flex:0 0 auto}
.reader-view-icon{position:absolute;width:18px!important;height:18px!important;inset:50% auto auto 50%;transform:translate(-50%,-50%);transition:opacity .18s ease,transform .18s ease}
.reader-view-icon-classic{opacity:0;transform:translate(-50%,-50%) scale(.78)}
.reader-view-toggle.is-classic .reader-view-icon-book{opacity:0;transform:translate(-50%,-50%) scale(.78)}
.reader-view-toggle.is-classic .reader-view-icon-classic{opacity:1;transform:translate(-50%,-50%) scale(1)}
.reader-book-format{height:34px;min-width:76px;padding:0 24px 0 9px;border:0;border-radius:9px;background:transparent;color:var(--muted);font-size:10px;font-weight:650;letter-spacing:.01em}
.reader-book-format:hover,.reader-book-format:focus{background:var(--accent-soft);color:var(--text);outline:none}
.reader-mode-classic .reader-book-format{display:none}

/* The reader toolbar can become wider than a portrait tablet. It remains one
   line and scrolls horizontally without displaying browser scroll chrome. */
.reader-bar{width:max-content!important;max-width:calc(100vw - 24px)!important;overflow-x:auto!important;overflow-y:hidden!important;scrollbar-width:none!important;overscroll-behavior-x:contain!important}
.reader-bar::-webkit-scrollbar{display:none!important;width:0!important;height:0!important}

.reader-book-stage{flex:1;min-height:0;width:100%;display:flex;align-items:center;justify-content:center;gap:clamp(10px,2vw,26px);position:relative;touch-action:pan-y;user-select:none}
.reader-book-spread{position:relative;display:grid;grid-template-columns:var(--reader-page-w) var(--reader-page-w);grid-template-rows:var(--reader-page-h);height:var(--reader-page-h);width:max-content;perspective:2400px;transform-style:preserve-3d;filter:drop-shadow(0 28px 38px rgba(0,0,0,.28));isolation:isolate}
.reader-book-spread.single-page{grid-template-columns:var(--reader-page-w)}
.reader-book-spread.single-page .reader-book-page-right{display:none!important}
.reader-book-spread::before{content:"";position:absolute;z-index:14;pointer-events:none;left:50%;top:1.2%;bottom:1.2%;width:18px;transform:translateX(-50%);background:linear-gradient(90deg,transparent,rgba(63,49,34,.12),rgba(255,255,255,.18),rgba(64,49,34,.10),transparent);opacity:.86}
.reader-book-spread.single-page::before{display:none}
.reader-book-page{width:var(--reader-page-w);height:var(--reader-page-h);position:relative;overflow:hidden;color:#302c26;background:
  radial-gradient(150px 100px at 7% 6%,rgba(137,105,69,.095),transparent 72%),
  radial-gradient(180px 110px at 94% 91%,rgba(137,105,69,.085),transparent 74%),
  repeating-linear-gradient(0deg,rgba(74,58,39,.017) 0,rgba(74,58,39,.017) 1px,transparent 1px,transparent 4px),
  linear-gradient(180deg,#f8f1e6 0%,#f2e8d9 52%,#eadcc8 100%);
  border:1px solid rgba(124,99,68,.19);box-shadow:inset 0 1px rgba(255,255,255,.68)}
.reader-book-page-left{border-radius:13px 2px 2px 13px;box-shadow:inset -24px 0 38px rgba(86,65,41,.075),inset 0 1px rgba(255,255,255,.68)}
.reader-book-page-right{border-radius:2px 13px 13px 2px;box-shadow:inset 24px 0 38px rgba(86,65,41,.065),inset 0 1px rgba(255,255,255,.68)}
.reader-book-spread.single-page .reader-book-page-left{border-radius:13px;box-shadow:inset 0 0 34px rgba(86,65,41,.045),inset 0 1px rgba(255,255,255,.68)}
.reader-book-page.is-blank{background:linear-gradient(180deg,#f4ebdc,#e9dbc6)}
.reader-book-page-inner{height:100%;min-height:0;display:flex;flex-direction:column;padding:clamp(30px,5.3vh,52px) clamp(28px,4.3vw,54px) clamp(25px,4vh,40px)}
.reader-book-heading{flex:0 0 auto;min-height:43px;margin-bottom:17px;color:#7c7060}
.reader-book-heading small,.reader-book-heading b{display:block;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.reader-book-heading small{font:700 9px/1.25 Inter,system-ui,sans-serif;letter-spacing:.12em;text-transform:uppercase;color:#8b7d69}
.reader-book-heading b{margin-top:5px;font:500 13px/1.3 Georgia,serif;color:#5a5145}
.reader-book-copy{flex:1;min-height:0;overflow:hidden;outline:none;color:#302c26!important;font-family:var(--editor-font)!important;font-size:var(--reader-book-font-size,12.8px)!important;line-height:var(--reader-book-line-height,1.5)!important;text-align:justify!important;text-justify:inter-word;hyphens:auto;-webkit-hyphens:auto;word-break:normal;overflow-wrap:normal;font-kerning:normal;font-variant-ligatures:common-ligatures;text-rendering:optimizeLegibility;user-select:text;-webkit-user-select:text;cursor:text}
.reader-book-copy p{margin:0 0 var(--editor-paragraph-spacing,.9em)!important;text-align:justify!important;text-justify:inter-word;hyphens:auto;-webkit-hyphens:auto}
.reader-book-copy p:first-child{text-indent:var(--editor-indent,0)}
.reader-book-copy .user-highlight{border-radius:3px;padding:0 .04em;color:#20231f!important;text-shadow:none!important;box-decoration-break:clone;-webkit-box-decoration-break:clone}
.reader-book-page-number{flex:0 0 auto;min-height:18px;margin-top:12px;text-align:center;color:#8d806e;font:500 10px/1.2 Georgia,serif}
.reader-book-page-empty{display:grid;place-items:center}
.reader-book-empty-mark{font:500 22px/1 Georgia,serif;color:rgba(83,70,53,.15);letter-spacing:.06em}

/* Off-screen physical page used only to measure pagination with the exact same
   typography and dimensions as the visible page. */
.reader-book-measure{position:fixed!important;left:-12000px!important;top:0!important;z-index:-100!important;visibility:hidden!important;pointer-events:none!important;contain:layout style paint!important}
.reader-book-measure .reader-book-page-inner{height:100%}
.reader-book-measure-copy{overflow:hidden!important}

.reader-book-nav{flex:0 0 44px;width:44px;height:58px;border:1px solid var(--line);border-radius:15px;background:color-mix(in srgb,var(--surface-strong) 88%,transparent);color:var(--text);display:grid;place-items:center;font:300 31px/1 Georgia,serif;backdrop-filter:blur(12px);box-shadow:0 8px 24px rgba(0,0,0,.13);transition:transform .18s ease,background .18s ease,opacity .18s ease}
.reader-book-nav:hover:not(:disabled){transform:translateY(-1px);background:color-mix(in srgb,var(--accent) 11%,var(--surface-strong))}
.reader-book-nav:disabled{opacity:.22;cursor:default;box-shadow:none}
.reader-book-status{flex:0 0 28px;display:flex;align-items:center;justify-content:center;gap:11px;color:var(--muted);font-size:10px;font-weight:600;letter-spacing:.01em;padding-top:5px}
.reader-book-progress{width:min(280px,34vw);height:3px;border-radius:999px;overflow:hidden;background:color-mix(in srgb,var(--text) 8%,transparent)}
.reader-book-progress>i{display:block;height:100%;width:0;border-radius:inherit;background:linear-gradient(90deg,var(--accent),var(--accent-2));transition:width .25s ease}

/* Page turn without mirrored text. Instead of rotating one DOM face through
   180°, Sylva closes the outgoing leaf to the spine and opens the incoming
   leaf from the spine. The visible text therefore never enters a mirrored
   back-face state. */
.reader-book-turn{position:absolute;z-index:30;top:0;left:0;width:calc(var(--reader-page-w) * 2);height:var(--reader-page-h);opacity:0;pointer-events:none;perspective:2400px;transform-style:preserve-3d}
.reader-book-turn-front,.reader-book-turn-back{position:absolute;top:0;width:var(--reader-page-w);height:var(--reader-page-h);overflow:hidden;color:#302c26;background:
  radial-gradient(150px 100px at 7% 6%,rgba(137,105,69,.095),transparent 72%),
  repeating-linear-gradient(0deg,rgba(74,58,39,.017) 0,rgba(74,58,39,.017) 1px,transparent 1px,transparent 4px),
  linear-gradient(180deg,#f8f1e6,#f2e8d9 52%,#eadcc8);border:1px solid rgba(124,99,68,.19);will-change:transform,opacity,filter;transform-style:preserve-3d}
.reader-book-turn.turn-next,.reader-book-turn.turn-prev,.reader-book-turn.turn-single-next,.reader-book-turn.turn-single-prev{opacity:1}
.reader-book-turn.turn-next .reader-book-turn-front{left:var(--reader-page-w);transform-origin:left center;border-radius:2px 13px 13px 2px;animation:readerLeafOutNext .72s cubic-bezier(.32,.02,.16,1) both}
.reader-book-turn.turn-next .reader-book-turn-back{left:0;transform-origin:right center;border-radius:13px 2px 2px 13px;animation:readerLeafInNext .72s cubic-bezier(.18,.72,.16,1) both}
.reader-book-turn.turn-prev .reader-book-turn-front{left:0;transform-origin:right center;border-radius:13px 2px 2px 13px;animation:readerLeafOutPrev .72s cubic-bezier(.32,.02,.16,1) both}
.reader-book-turn.turn-prev .reader-book-turn-back{left:var(--reader-page-w);transform-origin:left center;border-radius:2px 13px 13px 2px;animation:readerLeafInPrev .72s cubic-bezier(.18,.72,.16,1) both}
.reader-book-spread.single-page .reader-book-turn{width:var(--reader-page-w)}
.reader-book-turn.turn-single-next .reader-book-turn-front,.reader-book-turn.turn-single-prev .reader-book-turn-front,
.reader-book-turn.turn-single-next .reader-book-turn-back,.reader-book-turn.turn-single-prev .reader-book-turn-back{left:0;border-radius:13px}
.reader-book-turn.turn-single-next .reader-book-turn-front{transform-origin:left center;animation:readerLeafOutNext .72s cubic-bezier(.32,.02,.16,1) both}
.reader-book-turn.turn-single-next .reader-book-turn-back{transform-origin:right center;animation:readerLeafInNext .72s cubic-bezier(.18,.72,.16,1) both}
.reader-book-turn.turn-single-prev .reader-book-turn-front{transform-origin:right center;animation:readerLeafOutPrev .72s cubic-bezier(.32,.02,.16,1) both}
.reader-book-turn.turn-single-prev .reader-book-turn-back{transform-origin:left center;animation:readerLeafInPrev .72s cubic-bezier(.18,.72,.16,1) both}
.reader-book-spread.is-flipping .reader-book-page{pointer-events:none}
@keyframes readerLeafOutNext{0%{transform:rotateY(0);opacity:1;filter:brightness(1);box-shadow:0 0 0 rgba(45,34,22,0)}46%{transform:rotateY(-82deg);opacity:1;filter:brightness(.88);box-shadow:-18px 7px 28px rgba(45,34,22,.22)}50%,100%{transform:rotateY(-88deg);opacity:0;filter:brightness(.86)}}
@keyframes readerLeafInNext{0%,49%{transform:rotateY(88deg);opacity:0;filter:brightness(.86)}50%{transform:rotateY(82deg);opacity:1;filter:brightness(.88);box-shadow:18px 7px 28px rgba(45,34,22,.20)}100%{transform:rotateY(0);opacity:1;filter:brightness(1);box-shadow:0 0 0 rgba(45,34,22,0)}}
@keyframes readerLeafOutPrev{0%{transform:rotateY(0);opacity:1;filter:brightness(1);box-shadow:0 0 0 rgba(45,34,22,0)}46%{transform:rotateY(82deg);opacity:1;filter:brightness(.88);box-shadow:18px 7px 28px rgba(45,34,22,.22)}50%,100%{transform:rotateY(88deg);opacity:0;filter:brightness(.86)}}
@keyframes readerLeafInPrev{0%,49%{transform:rotateY(-88deg);opacity:0;filter:brightness(.86)}50%{transform:rotateY(-82deg);opacity:1;filter:brightness(.88);box-shadow:-18px 7px 28px rgba(45,34,22,.20)}100%{transform:rotateY(0);opacity:1;filter:brightness(1);box-shadow:0 0 0 rgba(45,34,22,0)}}

/* Tablet landscape: book remains the default when two readable physical pages
   fit. Portrait defaults to classic in JS; forcing Book shows one page. */
@media (pointer:coarse) and (min-width:561px) and (max-width:1366px){
  .reader-book-view{padding-left:10px;padding-right:10px;padding-top:68px}
  .reader-book-stage{gap:10px}
  .reader-book-nav{width:40px;flex-basis:40px;height:54px;border-radius:13px}
  .reader-book-page-inner{padding-left:clamp(26px,4.2vw,44px);padding-right:clamp(26px,4.2vw,44px)}
  .reader-book-copy{line-height:var(--reader-book-line-height,1.5)!important}
  .reader-book-heading b{font-size:12px}.reader-book-heading small{font-size:8.5px}
  .reader-book-status{font-size:10px}
}
@media (orientation:portrait) and (max-width:980px){
  .reader-book-view{padding-top:66px;padding-left:8px;padding-right:8px}
  .reader-book-stage{gap:8px}
  .reader-book-nav{position:absolute;z-index:22;top:50%;transform:translateY(-50%);background:color-mix(in srgb,var(--surface-strong) 78%,transparent)}
  .reader-book-nav:hover:not(:disabled){transform:translateY(calc(-50% - 1px))}
  .reader-book-nav-prev{left:4px}.reader-book-nav-next{right:4px}
  .reader-book-spread.single-page .reader-book-page-inner{padding-left:clamp(34px,7vw,58px);padding-right:clamp(34px,7vw,58px)}
  .reader-book-progress{width:min(220px,40vw)}
}
@media(max-width:720px){
  .reader-position{min-width:95px;max-width:135px}.reader-scope{max-width:76px}.reader-book-format{min-width:68px;padding-left:7px;padding-right:18px}
  .reader-book-view{padding-top:62px}.reader-book-status{gap:7px}.reader-book-progress{width:34vw}
}
@media(prefers-reduced-motion:reduce){
  .reader-book-turn.turn-next>*,.reader-book-turn.turn-prev>*,.reader-book-turn.turn-single-next>*,.reader-book-turn.turn-single-prev>*{animation-duration:.01ms!important}
}
/* The physical book intentionally stays on light paper in both Sylva themes. */
html[data-theme="sylva-dark"] .reader-book-copy,
html[data-theme="sylva-dark"] .reader-book-copy *{color:#302c26!important}
html[data-theme="sylva-dark"] .reader-book-copy .user-highlight,
html[data-theme="sylva-dark"] .reader-book-copy .user-highlight *{color:#20231f!important}
html[data-theme="sylva"] .reader-book-copy,
html[data-theme="sylva"] .reader-book-copy *{color:#302c26!important}
/* Reader chrome stays compact, but never drops to the old 7–9px text scale. */
#readerView .reader-position small{font-size:9px!important}
#readerView .reader-position b{font-size:11px!important}
#readerView .reader-scope,#readerView .reader-book-format{font-size:10.5px!important}
#readerView .reader-note-btn{font-size:10.5px!important}
@media (pointer:coarse) and (min-width:561px) and (max-width:1366px){
  #readerView .reader-position small{font-size:9px!important}
  #readerView .reader-position b{font-size:11px!important}
  #readerView .reader-scope,#readerView .reader-book-format,#readerView .reader-note-btn{font-size:10px!important}
}

/* ========================================================================== 
   Sylva Beta 0.851.1 · Ripristino navigatore manoscritto nel Writer
   Il restyle paper-first aveva nascosto la struttura con display:none.
   La logica originale è rimasta intatta: qui viene solo reintegrata nella UI.
   ========================================================================== */

/* Desktop: pannello Atti > Capitoli > Scene di nuovo accanto al manoscritto. */
html[data-route="writer"] #writerView:not(.review-mode) .structure-panel{
  display:block!important;
  position:relative!important;
  inset:auto!important;
  flex:0 0 292px!important;
  width:292px!important;
  min-width:292px!important;
  max-width:292px!important;
  height:100%!important;
  margin:0!important;
  padding:18px 15px!important;
  overflow-x:hidden!important;
  overflow-y:auto!important;
  opacity:1!important;
  transform:none!important;
  pointer-events:auto!important;
  border:0!important;
  border-right:1px solid rgba(65,68,61,.10)!important;
  border-radius:0!important;
  background:linear-gradient(180deg,#f8f4ed 0%,#f4efe7 100%)!important;
  box-shadow:none!important;
  z-index:42!important;
  scrollbar-width:thin;
  scrollbar-color:rgba(91,105,91,.28) transparent;
}
html[data-route="writer"] #writerView:not(.review-mode) .structure-panel::-webkit-scrollbar{width:7px}
html[data-route="writer"] #writerView:not(.review-mode) .structure-panel::-webkit-scrollbar-track{background:transparent}
html[data-route="writer"] #writerView:not(.review-mode) .structure-panel::-webkit-scrollbar-thumb{background:rgba(91,105,91,.24);border-radius:99px}
html[data-route="writer"] #writerView:not(.review-mode) .structure-panel::-webkit-scrollbar-thumb:hover{background:rgba(91,105,91,.38)}

html[data-route="writer"] #writerView:not(.review-mode) .structure-panel.collapsed{
  display:block!important;
  flex-basis:0!important;
  width:0!important;
  min-width:0!important;
  max-width:0!important;
  padding:0!important;
  border:0!important;
  opacity:0!important;
  transform:translateX(-18px)!important;
  pointer-events:none!important;
  overflow:hidden!important;
}

/* Il blocco strumenti resta leggibile e coerente col Writer attuale. */
html[data-route="writer"] #writerView:not(.review-mode) .structure-sticky-tools{
  top:-18px!important;
  margin:-18px -15px 10px!important;
  padding:18px 15px 12px!important;
  border-radius:0!important;
  border-bottom:1px solid rgba(65,68,61,.10)!important;
  background:linear-gradient(180deg,rgba(248,244,237,.99),rgba(248,244,237,.96))!important;
  backdrop-filter:blur(12px)!important;
}
html[data-route="writer"] #writerView:not(.review-mode) .structure-panel .panel-head small{
  font-size:10px!important;
  letter-spacing:.14em!important;
}
html[data-route="writer"] #writerView:not(.review-mode) .structure-panel .panel-head h2{
  margin:5px 0 0!important;
  font-family:var(--ui-serif,Georgia,serif)!important;
  font-size:21px!important;
  font-weight:500!important;
  color:#2c3931!important;
}
html[data-route="writer"] #writerView:not(.review-mode) .structure-panel .structure-actions{
  display:grid!important;
  grid-template-columns:repeat(3,minmax(0,1fr))!important;
  gap:6px!important;
  margin-top:14px!important;
}
html[data-route="writer"] #writerView:not(.review-mode) .structure-panel .structure-actions .mini-btn{
  min-width:0!important;
  min-height:36px!important;
  padding:7px 5px!important;
  font-size:10px!important;
  white-space:nowrap!important;
  border:1px solid rgba(65,68,61,.11)!important;
  background:rgba(255,253,249,.64)!important;
  color:#465349!important;
}
html[data-route="writer"] #writerView:not(.review-mode) .structure-panel .tree-row{
  min-height:40px!important;
  padding:9px 9px!important;
  border-radius:10px!important;
  font-size:13px!important;
}
html[data-route="writer"] #writerView:not(.review-mode) .structure-panel .tree-row.active{
  background:rgba(71,105,84,.11)!important;
  color:#264535!important;
}
html[data-route="writer"] #writerView:not(.review-mode) .structure-panel .tree-row:hover{
  background:rgba(71,105,84,.065)!important;
}
html[data-route="writer"] #writerView:not(.review-mode) .structure-panel #structureCollapse{
  width:36px!important;
  height:36px!important;
  min-width:36px!important;
  border:1px solid rgba(65,68,61,.10)!important;
  background:rgba(255,253,249,.62)!important;
  color:#59645b!important;
}

/* Linguetta dedicata per riaprire il navigatore quando è chiuso. */
html[data-route="writer"] #writerView:not(.review-mode) #structureHandle{
  position:absolute!important;
  display:flex!important;
  align-items:center!important;
  justify-content:center!important;
  left:0!important;
  top:50%!important;
  transform:translateY(-50%)!important;
  width:34px!important;
  min-width:34px!important;
  height:82px!important;
  min-height:82px!important;
  padding:0!important;
  border:1px solid rgba(65,68,61,.12)!important;
  border-left:0!important;
  border-radius:0 14px 14px 0!important;
  background:#f8f4ed!important;
  color:#526056!important;
  box-shadow:6px 8px 22px rgba(64,57,46,.08)!important;
  z-index:58!important;
}
html[data-route="writer"] #writerView:not(.review-mode) #structureHandle svg{
  width:19px!important;
  height:19px!important;
  fill:none!important;
  stroke:currentColor!important;
  stroke-width:1.65!important;
  stroke-linecap:round!important;
}
html[data-route="writer"] #writerView:not(.review-mode) #structureHandle:hover{
  background:#f1ebe1!important;
  color:#294c38!important;
}
html[data-route="writer"] #writerView:not(.review-mode) #structureHandle.hidden{display:none!important}

/* Laptop più stretto: il pannello resta desktop ma occupa meno spazio. */
@media (min-width:901px) and (max-width:1180px) and (pointer:fine){
  html[data-route="writer"] #writerView:not(.review-mode) .structure-panel{
    flex-basis:246px!important;
    width:246px!important;
    min-width:246px!important;
    max-width:246px!important;
  }
  html[data-route="writer"] #writerView:not(.review-mode) .structure-panel.collapsed{
    flex-basis:0!important;width:0!important;min-width:0!important;max-width:0!important
  }
  html[data-route="writer"] #writerView:not(.review-mode) .structure-panel .structure-actions{
    grid-template-columns:1fr 1fr!important;
  }
  html[data-route="writer"] #writerView:not(.review-mode) .structure-panel #addScene{grid-column:1/-1!important}
}

/* Tablet: non comprimere il foglio. Il navigatore diventa un drawer sovrapposto
   aperto dalla linguetta dedicata e chiuso dalla freccia interna. */
@media (max-width:900px), (pointer:coarse) and (min-width:561px) and (max-width:1366px){
  html[data-route="writer"] #writerView:not(.review-mode) .structure-panel,
  html[data-route="writer"] #writerView:not(.review-mode) .structure-panel.collapsed{
    display:block!important;
    position:absolute!important;
    left:0!important;
    top:0!important;
    bottom:0!important;
    right:auto!important;
    flex:none!important;
    width:min(78vw,360px)!important;
    min-width:0!important;
    max-width:360px!important;
    height:100%!important;
    padding:18px 15px!important;
    border:0!important;
    border-right:1px solid rgba(65,68,61,.12)!important;
    border-radius:0 18px 18px 0!important;
    background:linear-gradient(180deg,#f8f4ed,#f2ece3)!important;
    box-shadow:18px 0 48px rgba(54,48,39,.15)!important;
    transform:translate3d(calc(-100% - 18px),0,0)!important;
    opacity:0!important;
    pointer-events:none!important;
    z-index:72!important;
    transition:transform .30s cubic-bezier(.2,.8,.2,1),opacity .20s ease!important;
  }
  html[data-route="writer"] #writerView:not(.review-mode) .structure-panel.mobile-open:not(.collapsed){
    transform:translate3d(0,0,0)!important;
    opacity:1!important;
    pointer-events:auto!important;
  }
  html[data-route="writer"] #writerView:not(.review-mode) #structureHandle,
  html[data-route="writer"] #writerView:not(.review-mode) #structureHandle.hidden{
    display:flex!important;
    left:0!important;
    top:50%!important;
    width:38px!important;
    min-width:38px!important;
    height:88px!important;
    min-height:88px!important;
    z-index:71!important;
    touch-action:manipulation!important;
  }
  html[data-route="writer"] #writerView:not(.review-mode) .structure-panel.mobile-open + #structureHandle{
    display:none!important;
  }
  html[data-route="writer"] #writerView:not(.review-mode) .structure-panel .tree-row{
    min-height:46px!important;
    font-size:15px!important;
    padding:10px 11px!important;
  }
  html[data-route="writer"] #writerView:not(.review-mode) .structure-panel .tree-menu{
    opacity:1!important;
    min-width:36px!important;
    min-height:36px!important;
  }
  html[data-route="writer"] #writerView:not(.review-mode) .structure-panel #structureCollapse{
    width:42px!important;height:42px!important;min-width:42px!important;touch-action:manipulation!important
  }
  html[data-route="writer"] #writerView:not(.review-mode) .structure-panel .structure-actions .mini-btn{
    min-height:42px!important;
    font-size:11px!important;
    touch-action:manipulation!important;
  }
}

/* Tema scuro: stessa struttura, senza introdurre una terza estetica. */
html[data-theme="sylva-dark"][data-route="writer"] #writerView:not(.review-mode) .structure-panel,
html[data-theme="sylva-dark"][data-route="writer"] #writerView:not(.review-mode) #structureHandle{
  background:linear-gradient(180deg,#18231b,#131c16)!important;
  color:#ded8cd!important;
  border-color:rgba(231,222,205,.10)!important;
}
html[data-theme="sylva-dark"][data-route="writer"] #writerView:not(.review-mode) .structure-sticky-tools{
  background:linear-gradient(180deg,rgba(24,35,27,.99),rgba(24,35,27,.96))!important;
  border-color:rgba(231,222,205,.10)!important;
}
html[data-theme="sylva-dark"][data-route="writer"] #writerView:not(.review-mode) .structure-panel .panel-head h2{color:#eee7dc!important}
html[data-theme="sylva-dark"][data-route="writer"] #writerView:not(.review-mode) .structure-panel .structure-actions .mini-btn,
html[data-theme="sylva-dark"][data-route="writer"] #writerView:not(.review-mode) .structure-panel #structureCollapse{
  background:rgba(238,230,216,.055)!important;
  border-color:rgba(238,230,216,.10)!important;
  color:#d8d1c6!important;
}
html[data-theme="sylva-dark"][data-route="writer"] #writerView:not(.review-mode) .structure-panel .tree-row.active{
  background:rgba(130,158,126,.15)!important;
  color:#edf0e7!important;
}
html[data-theme="sylva-dark"][data-route="writer"] #writerView:not(.review-mode) .structure-panel .tree-row:hover{background:rgba(238,230,216,.055)!important}

/* La modalità revisione continua volutamente a usare tutto lo spazio. */
html[data-route="writer"] #writerView.review-mode .structure-panel,
html[data-route="writer"] #writerView.review-mode #structureHandle{display:none!important}


/* ========================================================================== 
   Sylva Beta 0.851.2 · Reader + Writer structure QA polish
   ========================================================================== */
/* Reader chrome: no microscopic labels and a more stable, less ghosted bar. */
#readerView .reader-bar{opacity:.76;min-height:50px;padding:6px 8px;box-shadow:0 12px 34px rgba(30,34,29,.10)}
#readerView .reader-bar:hover,#readerView .reader-bar:focus-within{opacity:1}
#readerView .reader-position small{font-size:10.5px!important;line-height:1.2!important}
#readerView .reader-position b{font-size:12px!important;line-height:1.25!important;margin-top:3px!important}
#readerView .reader-scope,#readerView .reader-book-format{font-size:11px!important;min-height:36px}
#readerView .reader-note-btn{font-size:11px!important;min-width:42px}
#readerView .reader-book-heading small{font-size:10.5px!important}
#readerView .reader-book-heading b{font-size:13.5px!important}
#readerView .reader-book-page-number,#readerView .reader-book-status{font-size:11px!important}
#readerView .reader-highlights button{width:20px;height:20px}
#readerView .reader-highlight-clear{min-width:32px;min-height:32px}
.reader-classic-view{width:100%;min-height:100%}
.reader-mode-classic .reader-classic-view{min-height:max(100%,calc(100dvh - 1px))}

/* Structure navigator: denser than a settings panel, but still large enough
   for long writing sessions. */
html[data-route="writer"] #writerView:not(.review-mode) .structure-panel{
  flex-basis:300px!important;width:300px!important;min-width:300px!important;max-width:300px!important;padding:19px 16px!important
}
html[data-route="writer"] #writerView:not(.review-mode) .structure-sticky-tools{top:-19px!important;margin:-19px -16px 11px!important;padding:19px 16px 13px!important}
html[data-route="writer"] #writerView:not(.review-mode) .structure-panel .panel-head small{font-size:11px!important}
html[data-route="writer"] #writerView:not(.review-mode) .structure-panel .panel-head h2{font-size:22px!important;line-height:1.15!important}
html[data-route="writer"] #writerView:not(.review-mode) .structure-panel .structure-actions{gap:7px!important}
html[data-route="writer"] #writerView:not(.review-mode) .structure-panel .structure-actions .mini-btn{min-height:39px!important;font-size:11.5px!important;padding:8px 6px!important;border-radius:10px!important}
html[data-route="writer"] #writerView:not(.review-mode) .structure-panel .tree-row{min-height:43px!important;padding:8px 9px!important;font-size:14px!important;gap:7px!important}


html[data-route="writer"] #writerView:not(.review-mode) .structure-panel .tree-drag-handle{opacity:.48;min-width:28px!important;height:32px!important}
html[data-route="writer"] #writerView:not(.review-mode) .structure-panel .tree-menu{min-width:32px!important;min-height:32px!important;font-size:16px!important;border-radius:8px!important}
html[data-route="writer"] #writerView:not(.review-mode) .structure-panel .tree-row:hover .tree-menu,
html[data-route="writer"] #writerView:not(.review-mode) .structure-panel .tree-row:focus-within .tree-menu{opacity:1!important;background:rgba(67,91,75,.055)!important}
html[data-route="writer"] #writerView:not(.review-mode) #structureHandle{width:36px!important;min-width:36px!important;height:86px!important;min-height:86px!important}

@media (min-width:901px) and (max-width:1180px) and (pointer:fine){
  html[data-route="writer"] #writerView:not(.review-mode) .structure-panel{flex-basis:258px!important;width:258px!important;min-width:258px!important;max-width:258px!important}
  html[data-route="writer"] #writerView:not(.review-mode) .structure-panel.collapsed{flex-basis:0!important;width:0!important;min-width:0!important;max-width:0!important}
}
@media (max-width:900px), (pointer:coarse) and (min-width:561px) and (max-width:1366px){
  #readerView .reader-bar{opacity:.92;min-height:52px}
  #readerView .reader-position small{font-size:10px!important}
  #readerView .reader-position b{font-size:11.5px!important}
  #readerView .reader-scope,#readerView .reader-book-format,#readerView .reader-note-btn{font-size:10.5px!important}
  #readerView .reader-icon-btn{min-width:40px;min-height:40px}
  #readerView .reader-highlights button{width:22px;height:22px}
  html[data-route="writer"] #writerView:not(.review-mode) .structure-panel .panel-head small{font-size:11px!important}
  html[data-route="writer"] #writerView:not(.review-mode) .structure-panel .panel-head h2{font-size:23px!important}
  html[data-route="writer"] #writerView:not(.review-mode) .structure-panel .structure-actions .mini-btn{min-height:44px!important;font-size:12px!important}
  html[data-route="writer"] #writerView:not(.review-mode) .structure-panel .tree-row{min-height:48px!important;font-size:15px!important;padding:10px!important}
  
  html[data-route="writer"] #writerView:not(.review-mode) .structure-panel .tree-drag-handle,
  html[data-route="writer"] #writerView:not(.review-mode) .structure-panel .tree-menu{min-width:40px!important;min-height:40px!important}
}


@media (max-width:900px), (pointer:coarse) and (min-width:561px) and (max-width:1366px){
  html[data-route="writer"] #writerView:not(.review-mode) .structure-panel,
  html[data-route="writer"] #writerView:not(.review-mode) .structure-panel.collapsed{
    width:min(78vw,360px)!important;min-width:0!important;max-width:360px!important;padding:18px 15px!important
  }
}


/* ========================================================================== 
   Sylva Beta 0.851.4 · Reader print typography
   I tre preset simulano un corpo da narrativa proporzionato alla pagina
   renderizzata. La vista Libro usa sempre giustificazione + sillabazione;
   la vista Classica e il Writer conservano invece le impostazioni esistenti.
   ========================================================================== */
.reader-book-spread{
  --reader-book-font-size:12.8px;
  --reader-book-line-height:1.5;
}
.reader-book-copy{
  font-size:var(--reader-book-font-size,12.8px)!important;
  line-height:var(--reader-book-line-height,1.5)!important;
  text-align:justify!important;
  text-justify:inter-word;
  hyphens:auto;
  -webkit-hyphens:auto;
}
@media (pointer:coarse) and (min-width:561px) and (max-width:1366px){
  .reader-book-copy{
    font-size:var(--reader-book-font-size,12.8px)!important;
    line-height:var(--reader-book-line-height,1.5)!important;
    text-align:justify!important;
  }
}

/* ========================================================================== 
   Sylva Beta 0.851.5 · Writer structure layering fix
   When the manuscript structure navigator is open it must sit above the
   formatting toolbar, so its close control and tree actions remain reachable.
   ========================================================================== */
html[data-route="writer"] #writerView:not(.review-mode) .structure-panel:not(.collapsed){
  z-index:110!important;
}
/* Desktop/laptop: an uncollapsed panel is visibly open. */
@media (min-width:901px) and (pointer:fine), (min-width:1367px){
  html[data-route="writer"] #writerView:not(.review-mode) .structure-panel:not(.collapsed) ~ .editor-stage .floating-toolbar{
    z-index:36!important;
  }
}
/* Tablet: only lower the toolbar while the overlay drawer is actually open. */
@media (max-width:900px), (pointer:coarse) and (min-width:561px) and (max-width:1366px){
  html[data-route="writer"] #writerView:not(.review-mode) .structure-panel.mobile-open:not(.collapsed){
    z-index:120!important;
  }
  html[data-route="writer"] #writerView:not(.review-mode) .structure-panel.mobile-open:not(.collapsed) ~ .editor-stage .floating-toolbar{
    z-index:34!important;
  }
}


/* Sylva 0.852.1 — private Beta access gate. Scoped to the entry card only. */
.entry-beta-access[hidden]{display:none!important}
.entry-beta-form{margin-top:20px}
.entry-beta-label{display:block;margin:0 0 7px;font-size:8px;font-weight:700;letter-spacing:.12em;text-transform:uppercase;color:var(--muted,#8f897f)}
.entry-beta-field{display:grid;grid-template-columns:minmax(0,1fr) auto;align-items:center;gap:7px;padding:6px 7px 6px 13px;border:1px solid color-mix(in srgb,currentColor 12%,transparent);border-radius:13px;background:color-mix(in srgb,var(--surface,#fff) 74%,transparent);transition:border-color .18s ease,box-shadow .18s ease,background .18s ease}
.entry-beta-field:focus-within{border-color:color-mix(in srgb,var(--accent,#6f876f) 58%,transparent);box-shadow:0 0 0 3px color-mix(in srgb,var(--accent,#6f876f) 12%,transparent)}
.entry-beta-field input{width:100%;min-width:0;height:34px;border:0!important;outline:0!important;background:transparent!important;color:inherit!important;font:500 12px/1.2 var(--ui-sans,Inter,sans-serif);letter-spacing:.035em;box-shadow:none!important}
.entry-beta-field input::placeholder{color:color-mix(in srgb,currentColor 42%,transparent)}
.entry-beta-visibility{height:32px;min-width:58px;padding:0 10px;border:1px solid color-mix(in srgb,currentColor 11%,transparent);border-radius:9px;background:transparent;color:inherit;font:600 8px/1 var(--ui-sans,Inter,sans-serif);letter-spacing:.06em;text-transform:uppercase;opacity:.7}
.entry-beta-visibility:hover{opacity:1;background:color-mix(in srgb,currentColor 5%,transparent)}
.entry-beta-help{display:block!important;margin-top:8px!important;font-size:8px!important;line-height:1.5!important;letter-spacing:0!important;color:color-mix(in srgb,currentColor 54%,transparent)!important}
.entry-beta-submit{margin-top:18px!important}
.entry-beta-key{width:22px;height:22px;display:grid;place-items:center;border-radius:50%;font-size:8px;background:color-mix(in srgb,currentColor 8%,transparent)}
.entry-beta-status{min-height:18px}
.entry-beta-status[data-state="working"] i{animation:cloudPulse 1s ease infinite}
.entry-beta-status[data-state="ok"]{color:#7d9a7f!important}.entry-beta-status[data-state="ok"] i{background:#7d9a7f!important}
.entry-beta-status[data-state="error"]{color:#bd756c!important}.entry-beta-status[data-state="error"] i{background:#bd756c!important}
.entry-beta-access.is-unlocking{animation:betaUnlock .28s ease both}
@keyframes betaUnlock{to{opacity:0;transform:translateY(-5px)}}
html[data-theme="sylva"] .entry-beta-field{background:rgba(255,253,249,.70);border-color:rgba(33,71,55,.13)}
html[data-theme="sylva-dark"] .entry-beta-field{background:rgba(235,227,214,.035);border-color:rgba(235,227,214,.11)}
@media(max-width:520px){
  .entry-beta-form{margin-top:17px}.entry-beta-field{padding-left:11px}.entry-beta-visibility{min-width:54px;padding:0 8px}.entry-beta-help{font-size:7.5px!important}.entry-beta-submit{margin-top:15px!important}
}


/* ==========================================================================
   Sylva Beta 0.853.1 · Writer Codex stacking + explicit structure jump
   ========================================================================== */
/* La scheda Codex del Writer deve stare davanti alla toolbar anche nei layout
   touch, dove la toolbar viene portata a z-index 70. */
html[data-route="writer"] #writerView:not(.review-mode) .writer-codex-preview{z-index:76!important}

.tree-row .tree-jump{
  width:28px;height:28px;min-width:28px;min-height:28px;flex:0 0 28px;padding:0;
  display:grid;place-items:center;border:0;border-radius:8px;background:transparent;
  color:var(--muted);opacity:.38;transition:opacity .16s ease,background .16s ease,color .16s ease,transform .16s ease;
}
.tree-row .tree-jump svg{width:15px;height:15px;fill:none;stroke:currentColor;stroke-width:1.7;stroke-linecap:round;stroke-linejoin:round}
.tree-row:hover .tree-jump,.tree-row:focus-within .tree-jump{opacity:.9}
.tree-row .tree-jump:hover{background:var(--accent-soft);color:var(--accent)}
.tree-row .tree-jump:active{transform:scale(.93)}
html[data-route="writer"] #writerView:not(.review-mode) .structure-panel .tree-jump{min-width:30px!important;min-height:30px!important}
@media (pointer:coarse){
  .tree-row .tree-jump{opacity:1;width:36px;height:36px;min-width:36px!important;min-height:36px!important;background:color-mix(in srgb,var(--surface-2) 58%,transparent);touch-action:manipulation}
}
@media (max-width:900px), (pointer:coarse) and (min-width:561px) and (max-width:1366px){
  html[data-route="writer"] #writerView:not(.review-mode) .structure-panel .tree-jump{width:40px!important;height:40px!important;min-width:40px!important;min-height:40px!important}
}

/* ===== v10 planning workspace responsive rebuild ===== */
.planning-view{
  padding-bottom:120px;
}
.planning-workspace{
  grid-template-columns:minmax(340px,420px) minmax(0,1fr);
  gap:28px;
  align-items:start;
  min-height:720px;
}
.planning-scenes-panel,
.planning-detail{
  border-radius:26px;
}
.planning-scenes-panel{
  padding:18px;
  top:84px;
  height:calc(100dvh - 136px);
  max-height:860px;
}
.planning-filter-row{
  grid-template-columns:minmax(0,1fr) 180px;
  gap:12px;
  padding-bottom:16px;
}
.planning-filter-row input,
.planning-filter-row select{
  height:48px;
  font-size:14px;
  padding-inline:14px;
}
.planning-scene-list{
  padding:14px 2px 3px;
  gap:10px;
}
.planning-scene-row{
  grid-template-columns:10px minmax(0,1fr) 64px;
  gap:14px;
  min-height:78px;
  padding:15px 14px;
  border-radius:17px;
}
.planning-scene-row>i{
  width:10px;
  height:48px;
}
.planning-scene-row>span small{
  font-size:10px;
  margin-bottom:5px;
}
.planning-scene-row>span b{
  font-size:15px;
  line-height:1.3;
}
.planning-scene-row>span em{
  font-size:11px;
  margin-top:5px;
}
.planning-scene-row>strong b{
  font-size:15px;
}
.planning-scene-row>strong small{
  font-size:9px;
  margin-top:3px;
}
.planning-detail{
  padding:30px;
}
.planning-detail-head{
  gap:22px;
  padding-bottom:22px;
}
.planning-detail-head>div:first-child small{
  font-size:10px;
}
.planning-detail-head h2{
  font-size:34px;
  line-height:1.12;
  margin:6px 0 7px;
}
.planning-detail-head p{
  font-size:13px;
  line-height:1.6;
}
.planning-detail-head>div:last-child{
  gap:12px;
  flex-wrap:wrap;
}
.planning-detail-head>div:last-child>span{
  font-size:10px;
}
.planning-detail-grid{
  grid-template-columns:minmax(300px,1fr) minmax(320px,1.2fr);
  gap:20px;
  margin-top:22px;
  align-items:start;
}
.planning-card-block{
  border-radius:22px;
  padding:22px;
}
.planning-card-block.narrative-function{
  grid-column:1 / -1;
}
.planning-block-head{
  margin-bottom:18px;
}
.planning-block-head small{
  font-size:10px;
  letter-spacing:.14em;
}
.planning-block-head h3{
  font-size:20px;
  line-height:1.18;
  margin-top:6px;
}
.planning-field-grid{
  grid-template-columns:1fr 1fr;
  gap:14px;
}
.planning-field-grid .form-row{
  gap:7px;
}
.planning-field-grid .form-row label,
.planning-story-fields .form-row label,
.planning-picker-head b,
.planning-picker-head>span{
  font-size:11px;
}
.planning-field-grid .form-row input,
.planning-field-grid .form-row select{
  min-height:46px;
  padding:11px 13px;
  font-size:14px;
}
.planning-word-box{
  min-height:46px;
  border-radius:14px;
  padding:11px 13px;
}
.planning-word-box small{
  font-size:10px;
}
.planning-word-box b{
  font-size:21px;
}
.planning-linked-event{
  margin-top:14px;
  padding:14px 15px;
  border-radius:15px;
}
.planning-linked-event span small{
  font-size:9px;
}
.planning-linked-event span b{
  font-size:13px;
  line-height:1.35;
}
.planning-picker-block + .planning-picker-block{
  margin-top:18px;
  padding-top:18px;
}
.planning-picker-head{
  margin-bottom:11px;
}
.planning-check-list{
  gap:9px;
  max-height:260px;
}
.planning-check-list .narrative-check{
  min-height:44px;
  padding:10px 12px;
  font-size:12px;
  border-radius:12px;
}
.planning-story-fields{
  grid-template-columns:repeat(3,minmax(0,1fr));
  gap:14px;
}
.planning-story-fields textarea{
  min-height:132px;
  max-height:260px;
  padding:13px 14px;
  font-size:14px;
  line-height:1.6;
}

@media (max-width: 1280px){
  .planning-workspace{
    grid-template-columns:minmax(320px,380px) minmax(0,1fr);
    gap:22px;
  }
  .planning-detail{
    padding:26px;
  }
  .planning-detail-grid{
    gap:18px;
  }
  .planning-card-block{
    padding:19px;
  }
  .planning-story-fields{
    grid-template-columns:1fr;
  }
}

@media (max-width: 1100px){
  .planning-workspace{
    grid-template-columns:1fr;
    gap:20px;
  }
  .planning-scenes-panel{
    position:relative;
    top:auto;
    height:auto;
    max-height:none;
    padding:17px;
  }
  .planning-scene-list{
    max-height:360px;
  }
  .planning-detail{
    padding:24px;
  }
  .planning-detail-grid{
    grid-template-columns:1fr 1fr;
  }
  .planning-card-block.narrative-function{
    grid-column:1 / -1;
  }
}

@media (max-width: 880px){
  .planning-view{
    padding-bottom:104px;
  }
  .planning-filter-row{
    grid-template-columns:1fr;
  }
  .planning-detail{
    padding:20px;
  }
  .planning-detail-head{
    flex-direction:column;
    align-items:flex-start;
    gap:14px;
  }
  .planning-detail-head h2{
    font-size:30px;
  }
  .planning-detail-head>div:last-child{
    width:100%;
    justify-content:space-between;
  }
  .planning-detail-grid,
  .planning-field-grid,
  .planning-story-fields{
    grid-template-columns:1fr;
  }
  .planning-card-block{
    padding:18px;
  }
}

@media (max-width: 640px){
  .planning-scenes-panel{
    padding:14px;
    border-radius:22px;
  }
  .planning-detail{
    padding:16px;
    border-radius:22px;
  }
  .planning-filter-row input,
  .planning-filter-row select,
  .planning-field-grid .form-row input,
  .planning-field-grid .form-row select{
    min-height:44px;
    font-size:15px;
  }
  .planning-scene-row{
    grid-template-columns:8px minmax(0,1fr) 58px;
    min-height:74px;
    padding:14px 12px;
  }
  .planning-scene-row>span b{
    font-size:14px;
  }
  .planning-scene-row>span em,
  .planning-check-list .narrative-check,
  .planning-picker-head b,
  .planning-picker-head>span,
  .planning-detail-head p,
  .planning-story-fields textarea,
  .planning-field-grid .form-row label{
    font-size:13px;
  }
  .planning-block-head h3{
    font-size:19px;
  }
  .planning-detail-head h2{
    font-size:27px;
  }
  .planning-word-box b{
    font-size:19px;
  }
  .planning-story-fields textarea{
    min-height:118px;
  }
}


/* ===== v11 relationships responsive + network refinement ===== */
.relationships-view{padding-bottom:112px}.relationships-heading{align-items:flex-start}
.relationship-page-toolbar{grid-template-columns:minmax(230px,320px) minmax(260px,1fr) minmax(180px,220px) minmax(170px,210px);gap:14px;padding:16px 18px;border-radius:22px;margin-bottom:18px}
.relationship-page-toolbar label>span{display:block;font-size:10px;font-weight:700;letter-spacing:.08em;text-transform:uppercase;color:var(--muted);margin-bottom:6px}
.relationship-page-toolbar select,.relationship-page-toolbar input{height:46px;font-size:14px!important;padding:10px 12px!important}

.relationship-page-list-panel{border-radius:24px;background:color-mix(in srgb,var(--surface-2) 84%,transparent)}
.relationship-page-list-panel{padding:18px}
.relationship-page-section-head{display:flex;justify-content:space-between;align-items:flex-end;gap:14px;margin-bottom:14px}
.relationship-page-section-head small{font-size:10px;letter-spacing:.14em;font-weight:700;color:var(--accent)}
.relationship-page-section-head h3{font-size:24px;font-weight:530;line-height:1.12;margin:5px 0 0}
.relationship-page-section-head>span{font-size:11px;color:var(--muted)}










.relationship-page-list{display:flex;flex-direction:column;gap:10px;max-height:700px;overflow:auto;padding-right:2px}








@media (max-width: 1280px){.relationship-page-toolbar{grid-template-columns:minmax(220px,300px) minmax(240px,1fr) minmax(160px,1fr) minmax(160px,1fr)}}
@media (max-width: 1100px){.relationship-page-toolbar{grid-template-columns:1fr 1fr}.relationship-page-list{max-height:none}}
@media (max-width: 820px){.relationships-view{padding-bottom:102px}.relationship-page-toolbar{grid-template-columns:1fr;gap:12px;padding:14px}.relationship-page-list-panel{padding:16px;border-radius:22px}.relationship-page-section-head h3{font-size:21px}}
@media (max-width: 620px){.relationship-page-stats{grid-template-columns:repeat(2,minmax(0,1fr))}.relationship-page-stats>div{min-height:76px;padding:15px}.relationship-page-toolbar select,.relationship-page-toolbar input{height:44px;font-size:15px!important}}


/* ========================================================================== 
   Sylva Beta 0.980 · Writer layering contract + toolbar responsive QA
   The toolbar belongs to the editor stage. Structure, Codex and bookmark
   panels always own the foreground and can never be covered by formatting UI.
   ========================================================================== */
html[data-route="writer"] #writerView:not(.review-mode){isolation:isolate}
html[data-route="writer"] #writerView:not(.review-mode) .editor-stage{position:relative;isolation:isolate;z-index:1}
html[data-route="writer"] #writerView:not(.review-mode) .floating-toolbar{z-index:42!important;max-width:calc(100% - 24px);box-sizing:border-box}
html[data-route="writer"] #writerView:not(.review-mode) .structure-panel:not(.collapsed){z-index:180!important}
html[data-route="writer"] #writerView:not(.review-mode) .writer-codex-preview{z-index:170!important}
html[data-route="writer"] #writerView:not(.review-mode) .bookmark-panel{z-index:160!important}
html[data-route="writer"] #writerView:not(.review-mode) #structureHandle{z-index:90!important}

/* Large desktop: use the free writing area when a right-side sheet is open. */
@media (min-width:1281px) and (pointer:fine){
  html[data-route="writer"] #writerView:not(.review-mode):has(.writer-codex-preview.open) .floating-toolbar{
    left:clamp(34%,calc(50% - 180px),50%)!important;
    max-width:min(720px,calc(100% - 430px))!important;
    overflow-x:auto!important;scrollbar-width:none
  }
  html[data-route="writer"] #writerView:not(.review-mode):has(.bookmark-panel.open) .floating-toolbar{
    left:clamp(38%,calc(50% - 120px),50%)!important;
    max-width:min(760px,calc(100% - 330px))!important;
    overflow-x:auto!important;scrollbar-width:none
  }
  html[data-route="writer"] #writerView:not(.review-mode):has(.writer-codex-preview.open) .floating-toolbar::-webkit-scrollbar,
  html[data-route="writer"] #writerView:not(.review-mode):has(.bookmark-panel.open) .floating-toolbar::-webkit-scrollbar{display:none}
}
/* Laptop: don't compress the toolbar underneath a side sheet. */
@media (min-width:901px) and (max-width:1280px) and (pointer:fine){
  html[data-route="writer"] #writerView:not(.review-mode):has(.writer-codex-preview.open) .floating-toolbar,
  html[data-route="writer"] #writerView:not(.review-mode):has(.bookmark-panel.open) .floating-toolbar{opacity:.12!important;pointer-events:none!important}
}

/* Tablet/coarse pointer: the old viewport-fixed toolbar was the source of
   cross-panel collisions. Anchor it to editor-stage instead. */
@media (max-width:900px), (pointer:coarse) and (min-width:561px) and (max-width:1366px){
  html[data-route="writer"] #writerView:not(.review-mode) .floating-toolbar{
    position:absolute!important;top:6px!important;left:50%!important;right:auto!important;
    width:max-content!important;max-width:calc(100% - 24px)!important;margin:0!important;
    transform:translateX(-50%)!important;opacity:.98!important;
    overflow-x:auto!important;overflow-y:hidden!important;scrollbar-width:none!important;
    overscroll-behavior-x:contain;touch-action:pan-x
  }
  html[data-route="writer"] #writerView:not(.review-mode) .floating-toolbar::-webkit-scrollbar{display:none!important}
  html[data-route="writer"] #writerView:not(.review-mode) .floating-toolbar:hover,
  html[data-route="writer"] #writerView:not(.review-mode) .floating-toolbar.focused{transform:translateX(-50%)!important;opacity:1!important}
  html[data-route="writer"] #writerView:not(.review-mode) .floating-toolbar button{
    min-width:44px!important;height:44px!important;min-height:44px!important;padding-inline:9px!important;font-size:13px!important;flex:0 0 auto
  }
  html[data-route="writer"] #writerView:not(.review-mode) .floating-toolbar select{
    height:44px!important;min-height:44px!important;min-width:92px;max-width:128px!important;font-size:13px!important;flex:0 0 auto
  }
  html[data-route="writer"] #writerView:not(.review-mode) .floating-toolbar .writer-width-btn{width:44px!important;min-width:44px!important;height:44px!important}
  html[data-route="writer"] #writerView:not(.review-mode) .floating-toolbar .highlight-dot{width:28px!important;min-width:28px!important;height:28px!important;align-self:center}
  html[data-route="writer"] #writerView:not(.review-mode) .document-meta{padding-top:54px!important;height:88px!important}
  html[data-route="writer"] #writerView:not(.review-mode):has(.structure-panel.mobile-open:not(.collapsed)) .floating-toolbar,
  html[data-route="writer"] #writerView:not(.review-mode):has(.writer-codex-preview.open) .floating-toolbar,
  html[data-route="writer"] #writerView:not(.review-mode):has(.bookmark-panel.open) .floating-toolbar{opacity:.10!important;pointer-events:none!important}
}
@media (max-width:700px){
  html[data-route="writer"] #writerView:not(.review-mode) .floating-toolbar{max-width:calc(100% - 16px)!important;padding:6px!important;gap:4px!important}
  html[data-route="writer"] #writerView:not(.review-mode) .floating-toolbar button{min-width:44px!important;height:44px!important;min-height:44px!important}
  html[data-route="writer"] #writerView:not(.review-mode) .floating-toolbar select{height:44px!important;min-height:44px!important;font-size:14px!important}
}

/* ===== 0.963 stability: relationship clusters + readable legacy chrome ===== */








/* Reader / Radio / Legal / phone UI: minimum readable sizes aligned with the newer modules. */
#readerView .reader-position small{font-size:10px!important}
#readerView .reader-scope,#readerView .reader-note-btn{font-size:11px!important}
#readerView .reader-note-item small{font-size:10px!important}
#readerView .reader-note-item em,#readerView .reader-notes-empty span{font-size:11px!important}
.radio-setup p{font-size:12px!important;line-height:1.55}.radio-setup>small{font-size:10px!important}
.radio-client-row input,.radio-search-form input{font-size:13px!important;min-height:42px}.radio-client-row button{font-size:11px!important;min-height:40px}
.radio-empty{font-size:11px!important}.radio-result b{font-size:12px!important}.radio-result small{font-size:10px!important}.radio-footer button{font-size:10px!important;min-height:38px}
.legal-brand span,.legal-version,.legal-hero>div:first-child>small,.legal-section-kicker small,.legal-section-kicker span,.legal-law-badge,.legal-privacy-summary small,.legal-thirdparty-links a,.legal-cookie-status>small,.legal-terms-list article>span,.legal-support-copy>small,.legal-paypal-box small,.legal-contact-address small,.legal-contact-address button,.legal-form-row label,.legal-human small,.legal-form-foot,.legal-footer span{font-size:10px!important}
.legal-jump span{font-size:10px!important}.legal-jump small,.legal-cookie-status>div,.legal-cookie-status b,.legal-privacy-summary p,.legal-support-legal b,.legal-support-legal span,.legal-contact-privacy b,.legal-contact-privacy p,.legal-form-error,.legal-footer button{font-size:11px!important;line-height:1.5}
.phone-access-header>small,.phone-book-head small,.phone-book-head>span small,.phone-book-meta span,.phone-access-footer,.book-status-copy>small,.book-status-metrics span,.book-status-actions>span{font-size:10px!important;line-height:1.4}
.stat-card span,.planning-stats span,.relationship-page-stats span,.calendar-summary span,.timeline-stats span{font-size:10px!important;line-height:1.35}
.spell-state{font-size:10px!important}
.save-state,.cloud-state{font-size:10px!important}
.codex-card-categories span,.codex-card-foot,.codex-card-worldmeta span,.codex-card-worldmeta em,.codex-card-parent{font-size:10px!important}
.codex-appearance-jump small,.codex-appearance-range small,.codex-appearance-empty{font-size:10px!important}
.codex-appearance-jump b,.codex-appearance-range b{font-size:11px!important}

@media (pointer:coarse){
  .reader-note-btn,.radio-footer button,.legal-jump,.legal-footer button,.legal-contact-address button{min-height:44px}
  
}
@media (max-width:820px){
  
  
  .legal-privacy-summary p,.legal-contact-privacy p,.radio-setup p{font-size:13px!important}
}

/* 0.963 stability · readable legacy metadata across the remaining app. */
.bookmark-item small,.scene-value,.scene-axis-label,.scene-chart-legend,.heat-cell,.book-meta-cell span,.stacked-label span,.compact-col>span,.compact-col>small,
.storage-fact small,.cloud-panel-status small,.entry-footer,.sync-detail-grid small,.sync-settings small,.outline-legend-label,.outline-node-meta,.outline-tag,.outline-tag.legend,
.book-state-chip,.big-action small,.category-edit,.global-replace>p,.revision-change-item small,.revision-diff-head p,
.session-modal-head small,.session-live-grid small,.session-stat span,.session-subhead span,.session-day-col small,.session-recent-row b,.session-recent-row span,.session-recent-row small,
.saga-title-wrap small,.loose-books-head small,.saga-modal-head small,.saga-book-picker>small,.saga-book-choice small,.theme-special-head small,.theme-exclusive-label,
.perf-diag-card small,.narrative-pill,.scene-card-head small,.narrative-empty-inline,.scene-card-word-preview small,.book-goal-copy span,.mini-meta-bar span,.plotline-analysis-row span,
.world-custom-head small,.entry-relation-chip small,.revision-world-change span,
.planning-scene-row>span small,.planning-scene-row>strong small,.planning-detail-head>div:first-child small,.planning-detail-head>div:last-child>span,.planning-block-head small,.planning-word-box small,
.planning-linked-event span small,.scene-card-head-v2 small,.scene-card-section-head small,.scene-card-timeline-box small,
.calendar-section-head small,.calendar-section-head>span,.calendar-foundation-grid .form-row>small,.weekday-preview>span b,
.rail-btn small,.location-tree-node>button>em,.review-start-card>small,.review-pending-head span,.review-pending-empty,.review-column-labels small,
.sylva-splash-lockup>small,.home-export-actions .big-action small,.home-info-card small,.book-cover-editor small,.home-hero>small,.book-mobile-exports button,
.entry-features span,.entry-kicker,.entry-beta-label,.entry-beta-help,.entry-beta-key,.goal-progress-card small,.daily-goal-summary span,.daily-goal-subhead span,.daily-goal-day small,.daily-goal-row em,
.roadmap-hero>div>small,.roadmap-version-head small{font-size:10px!important;line-height:1.4}

.outline-node-meta,.outline-tag,.book-state-chip,.narrative-pill,.entry-relation-chip small,.revision-world-change span,
.global-replace>p,.revision-diff-head p,.review-pending-empty,.entry-features span,.entry-beta-help{font-size:11px!important;line-height:1.5}

@media (pointer:coarse){
  .category-edit,.book-mobile-exports button,.outline-tag,.book-state-chip{min-height:42px}
  .rail-btn{min-height:48px}
}
@media (max-width:820px){
  .home-info-card small,.book-cover-editor small,.entry-features span,.goal-progress-card small,.daily-goal-summary span,.roadmap-version-head small{font-size:11px!important}
}

/* ==========================================================================
   SYLVA BETA 0.964 — NARRATIVE THEME SYSTEM
   Four complete atmospheres. No layout/feature changes: only semantic tokens,
   typography, surfaces and component chrome. Manuscript typography settings
   remain controlled by the book; themes only define paper/ink atmosphere.
   ========================================================================== */
html[data-theme="modern"]{
  color-scheme:light;
  --bg:#edf1f5;--bg2:#e6ebf0;
  --surface:rgba(255,255,255,.90);--surface-2:#f5f7f9;--surface-strong:#ffffff;
  --paper:#ffffff;--text:#202832;--muted:#697685;--line:rgba(34,51,67,.12);
  --shadow:0 18px 46px rgba(34,51,67,.09);--blur:18px;
  --accent:#3f6386;--accent-2:#7e92a5;--accent-soft:rgba(63,99,134,.10);
  --danger:#b6555a;--danger-soft:rgba(182,85,90,.10);
  --ambient-a:#9bb1c6;--ambient-b:#bac6d2;--ambient-c:#91a8bd;--ambient-opacity:.10;
  --radius:18px;--radius-sm:12px;
  --ui-font:"Instrument Sans",Inter,system-ui,sans-serif;--ui-serif:"Source Serif 4",Georgia,serif;
  --theme-display:"Source Serif 4",Georgia,serif;--theme-ui:"Instrument Sans",Inter,system-ui,sans-serif;
  --theme-paper:#ffffff;--theme-paper-ink:#222a33;--theme-paper-muted:#75808b;
  --theme-chrome:#ffffff;--theme-chrome-soft:#f4f6f8;--theme-entry:#edf1f5;
  --theme-primary:#355d82;--theme-primary-text:#f9fcff;--theme-control-radius:12px;
}
html[data-theme="fantasy"]{
  color-scheme:dark;
  --bg:#151711;--bg2:#211f17;
  --surface:rgba(38,37,27,.90);--surface-2:rgba(74,69,49,.30);--surface-strong:#2b2a20;
  --paper:#f2e7d0;--text:#eee5d3;--muted:#b3a78f;--line:rgba(226,205,164,.14);
  --shadow:0 22px 60px rgba(4,5,3,.32);--blur:18px;
  --accent:#c19a55;--accent-2:#7f9060;--accent-soft:rgba(193,154,85,.13);
  --danger:#bd6d5e;--danger-soft:rgba(189,109,94,.12);
  --ambient-a:#4b5035;--ambient-b:#67553a;--ambient-c:#837049;--ambient-opacity:.10;
  --radius:16px;--radius-sm:10px;
  --ui-font:"Source Sans 3",Inter,system-ui,sans-serif;--ui-serif:Cinzel,Georgia,serif;
  --theme-display:Cinzel,Georgia,serif;--theme-ui:"Source Sans 3",Inter,system-ui,sans-serif;
  --theme-paper:#f2e7d0;--theme-paper-ink:#332c22;--theme-paper-muted:#7b6e5a;
  --theme-chrome:#29281e;--theme-chrome-soft:#343225;--theme-entry:#161812;
  --theme-primary:#b68d49;--theme-primary-text:#17150f;--theme-control-radius:10px;
}
html[data-theme="thriller"]{
  color-scheme:dark;
  --bg:#101214;--bg2:#181b1e;
  --surface:rgba(28,31,34,.92);--surface-2:rgba(66,70,73,.25);--surface-strong:#202326;
  --paper:#f1f0ec;--text:#eceeef;--muted:#9ca2a7;--line:rgba(236,239,240,.11);
  --shadow:0 22px 62px rgba(0,0,0,.38);--blur:16px;
  --accent:#d9656a;--accent-2:#899199;--accent-soft:rgba(198,75,80,.13);
  --danger:#df6767;--danger-soft:rgba(223,103,103,.12);
  --ambient-a:#4b2427;--ambient-b:#353a3d;--ambient-c:#5c2c2f;--ambient-opacity:.075;
  --radius:12px;--radius-sm:8px;
  --ui-font:"IBM Plex Sans",Inter,system-ui,sans-serif;--ui-serif:"IBM Plex Sans",Inter,system-ui,sans-serif;
  --theme-display:"IBM Plex Sans",Inter,system-ui,sans-serif;--theme-ui:"IBM Plex Sans",Inter,system-ui,sans-serif;
  --theme-paper:#f1f0ec;--theme-paper-ink:#202224;--theme-paper-muted:#707477;
  --theme-chrome:#1d2023;--theme-chrome-soft:#25292c;--theme-entry:#111315;
  --theme-primary:#b94247;--theme-primary-text:#fff9f9;--theme-control-radius:8px;
}
html[data-theme="cyberpunk"]{
  color-scheme:dark;
  --bg:#060a10;--bg2:#0b111a;
  --surface:rgba(12,20,29,.93);--surface-2:rgba(24,50,64,.34);--surface-strong:#0e1923;
  --paper:#0b141c;--text:#daf8fb;--muted:#83a6b0;--line:rgba(0,217,237,.18);
  --shadow:0 22px 66px rgba(0,0,0,.44);--blur:14px;
  --accent:#00d9ed;--accent-2:#f34fc9;--accent-soft:rgba(0,217,237,.12);
  --danger:#ff637b;--danger-soft:rgba(255,99,123,.12);
  --ambient-a:#004d5f;--ambient-b:#4c1245;--ambient-c:#064d66;--ambient-opacity:.11;
  --radius:10px;--radius-sm:6px;
  --ui-font:"IBM Plex Sans",Inter,system-ui,sans-serif;--ui-serif:Orbitron,"IBM Plex Sans",sans-serif;
  --theme-display:Orbitron,"IBM Plex Sans",sans-serif;--theme-ui:"IBM Plex Sans",Inter,system-ui,sans-serif;
  --theme-paper:#0b141c;--theme-paper-ink:#dcf9fb;--theme-paper-muted:#7ca3ad;
  --theme-chrome:#0b151e;--theme-chrome-soft:#101e29;--theme-entry:#060a10;
  --theme-primary:#00c7da;--theme-primary-text:#031015;--theme-control-radius:6px;
}

/* Shared contract for the four narrative themes. */
html[data-theme="modern"] body,html[data-theme="modern"] button,html[data-theme="modern"] input,html[data-theme="modern"] select,html[data-theme="modern"] textarea,
html[data-theme="fantasy"] body,html[data-theme="fantasy"] button,html[data-theme="fantasy"] input,html[data-theme="fantasy"] select,html[data-theme="fantasy"] textarea,
html[data-theme="thriller"] body,html[data-theme="thriller"] button,html[data-theme="thriller"] input,html[data-theme="thriller"] select,html[data-theme="thriller"] textarea,
html[data-theme="cyberpunk"] body,html[data-theme="cyberpunk"] button,html[data-theme="cyberpunk"] input,html[data-theme="cyberpunk"] select,html[data-theme="cyberpunk"] textarea{font-family:var(--theme-ui)!important}

html[data-theme="modern"] :is(.scene-editor,.scene-editor *,.reader-editor,.reader-editor *,.reader-book-copy,.review-original-copy,.review-original-copy *,.review-scene-editor,.review-scene-editor *),
html[data-theme="fantasy"] :is(.scene-editor,.scene-editor *,.reader-editor,.reader-editor *,.reader-book-copy,.review-original-copy,.review-original-copy *,.review-scene-editor,.review-scene-editor *),
html[data-theme="thriller"] :is(.scene-editor,.scene-editor *,.reader-editor,.reader-editor *,.reader-book-copy,.review-original-copy,.review-original-copy *,.review-scene-editor,.review-scene-editor *),
html[data-theme="cyberpunk"] :is(.scene-editor,.scene-editor *,.reader-editor,.reader-editor *,.reader-book-copy,.review-original-copy,.review-original-copy *,.review-scene-editor,.review-scene-editor *){font-family:var(--editor-font)!important}

html[data-theme="modern"] :is(.view-heading h1,.panel-head h2,.home-hero h1,.home-section-head h2,.home-shelf-head h2,.legal-hero h1,.legal-section h2,.modal>h2,.goals-modal-head h2,.scope-modal-head h2),
html[data-theme="fantasy"] :is(.view-heading h1,.panel-head h2,.home-hero h1,.home-section-head h2,.home-shelf-head h2,.legal-hero h1,.legal-section h2,.modal>h2,.goals-modal-head h2,.scope-modal-head h2),
html[data-theme="thriller"] :is(.view-heading h1,.panel-head h2,.home-hero h1,.home-section-head h2,.home-shelf-head h2,.legal-hero h1,.legal-section h2,.modal>h2,.goals-modal-head h2,.scope-modal-head h2),
html[data-theme="cyberpunk"] :is(.view-heading h1,.panel-head h2,.home-hero h1,.home-section-head h2,.home-shelf-head h2,.legal-hero h1,.legal-section h2,.modal>h2,.goals-modal-head h2,.scope-modal-head h2){font-family:var(--theme-display)!important;color:var(--text)!important}

html[data-theme="fantasy"] :is(.view-heading h1,.panel-head h2,.home-hero h1,.home-section-head h2,.home-shelf-head h2){letter-spacing:.005em!important;font-weight:500!important}
html[data-theme="thriller"] :is(.view-heading h1,.panel-head h2,.home-hero h1,.home-section-head h2){letter-spacing:-.035em!important;font-weight:520!important}
html[data-theme="cyberpunk"] :is(.view-heading h1,.panel-head h2,.home-hero h1,.home-section-head h2,.home-shelf-head h2){letter-spacing:.035em!important;font-weight:500!important}

html[data-theme="modern"] body{background:radial-gradient(circle at 8% 5%,rgba(103,136,165,.12),transparent 26%),linear-gradient(145deg,#f0f3f6,#e8edf2 58%,#edf1f5)!important}
html[data-theme="fantasy"] body{background:radial-gradient(circle at 8% 4%,rgba(122,139,82,.12),transparent 25%),radial-gradient(circle at 93% 12%,rgba(193,154,85,.09),transparent 25%),linear-gradient(145deg,#141610,#1c1c14 55%,#151711)!important}
html[data-theme="thriller"] body{background:radial-gradient(circle at 88% 8%,rgba(155,48,53,.09),transparent 22%),linear-gradient(150deg,#0e1012,#16191c 56%,#111315)!important}
html[data-theme="cyberpunk"] body{background:linear-gradient(rgba(0,217,237,.025) 1px,transparent 1px),linear-gradient(90deg,rgba(0,217,237,.025) 1px,transparent 1px),radial-gradient(circle at 8% 8%,rgba(0,217,237,.11),transparent 24%),radial-gradient(circle at 92% 18%,rgba(243,79,201,.09),transparent 22%),linear-gradient(145deg,#05090f,#0a1018 58%,#060a10)!important;background-size:34px 34px,34px 34px,auto,auto,auto!important}

html[data-theme="modern"] :is(.glass,.glass-lite),html[data-theme="fantasy"] :is(.glass,.glass-lite),html[data-theme="thriller"] :is(.glass,.glass-lite),html[data-theme="cyberpunk"] :is(.glass,.glass-lite){border-color:var(--line)!important;color:var(--text)}
html[data-theme="modern"] .glass{background:rgba(255,255,255,.90)!important;backdrop-filter:blur(16px) saturate(.96)!important}
html[data-theme="fantasy"] .glass{background:rgba(40,39,29,.90)!important;backdrop-filter:blur(15px) saturate(.88)!important}
html[data-theme="thriller"] .glass{background:rgba(29,32,35,.92)!important;backdrop-filter:blur(14px) saturate(.82)!important}
html[data-theme="cyberpunk"] .glass{background:rgba(10,19,28,.92)!important;backdrop-filter:blur(13px) saturate(1.08)!important}

html[data-theme="modern"] :is(.soft-btn,.mini-btn,.scope-btn,.icon-btn,.form-row input:not([type="checkbox"]):not([type="radio"]):not([type="range"]),.form-row textarea,.form-row select),
html[data-theme="fantasy"] :is(.soft-btn,.mini-btn,.scope-btn,.icon-btn,.form-row input:not([type="checkbox"]):not([type="radio"]):not([type="range"]),.form-row textarea,.form-row select),
html[data-theme="thriller"] :is(.soft-btn,.mini-btn,.scope-btn,.icon-btn,.form-row input:not([type="checkbox"]):not([type="radio"]):not([type="range"]),.form-row textarea,.form-row select),
html[data-theme="cyberpunk"] :is(.soft-btn,.mini-btn,.scope-btn,.icon-btn,.form-row input:not([type="checkbox"]):not([type="radio"]):not([type="range"]),.form-row textarea,.form-row select){border-radius:var(--theme-control-radius)!important}
html[data-theme="modern"] .primary-btn,html[data-theme="fantasy"] .primary-btn,html[data-theme="thriller"] .primary-btn,html[data-theme="cyberpunk"] .primary-btn{background:var(--theme-primary)!important;color:var(--theme-primary-text)!important;border:1px solid color-mix(in srgb,var(--theme-primary) 70%,var(--line))!important;border-radius:var(--theme-control-radius)!important;box-shadow:0 7px 20px color-mix(in srgb,var(--theme-primary) 18%,transparent)!important}
html[data-theme="cyberpunk"] .primary-btn{box-shadow:0 0 0 1px rgba(0,217,237,.12),0 8px 24px rgba(0,217,237,.10)!important}
html[data-theme="thriller"] .primary-btn{box-shadow:0 8px 24px rgba(0,0,0,.24)!important}

/* Home: override the historical Sylva-only hardcoded palette without changing layout. */
html[data-theme="modern"] :is(.home-hero>small,.home-shelf-head small,.book-card-title-row small,.sylva-saga-card small),
html[data-theme="fantasy"] :is(.home-hero>small,.home-shelf-head small,.book-card-title-row small,.sylva-saga-card small),
html[data-theme="thriller"] :is(.home-hero>small,.home-shelf-head small,.book-card-title-row small,.sylva-saga-card small),
html[data-theme="cyberpunk"] :is(.home-hero>small,.home-shelf-head small,.book-card-title-row small,.sylva-saga-card small){color:var(--accent)!important}
html[data-theme="modern"] :is(.home-hero p,.home-section-head p,.home-shelf-head>span,.book-card-facts,.sylva-saga-card p,.home-info-card small),
html[data-theme="fantasy"] :is(.home-hero p,.home-section-head p,.home-shelf-head>span,.book-card-facts,.sylva-saga-card p,.home-info-card small),
html[data-theme="thriller"] :is(.home-hero p,.home-section-head p,.home-shelf-head>span,.book-card-facts,.sylva-saga-card p,.home-info-card small),
html[data-theme="cyberpunk"] :is(.home-hero p,.home-section-head p,.home-shelf-head>span,.book-card-facts,.sylva-saga-card p,.home-info-card small){color:var(--muted)!important}
html[data-theme="modern"] :is(.home-hero h1,.home-section-head h2,.home-shelf-head h2,.book-card-title-row h3,.sylva-saga-card h3,.home-export-actions .big-action b,.home-info-card b),
html[data-theme="fantasy"] :is(.home-hero h1,.home-section-head h2,.home-shelf-head h2,.book-card-title-row h3,.sylva-saga-card h3,.home-export-actions .big-action b,.home-info-card b),
html[data-theme="thriller"] :is(.home-hero h1,.home-section-head h2,.home-shelf-head h2,.book-card-title-row h3,.sylva-saga-card h3,.home-export-actions .big-action b,.home-info-card b),
html[data-theme="cyberpunk"] :is(.home-hero h1,.home-section-head h2,.home-shelf-head h2,.book-card-title-row h3,.sylva-saga-card h3,.home-export-actions .big-action b,.home-info-card b){color:var(--text)!important}
html[data-theme="modern"] :is(.book-card-title-row h3,.sylva-saga-card h3,.home-info-card b),html[data-theme="fantasy"] :is(.book-card-title-row h3,.sylva-saga-card h3,.home-info-card b),html[data-theme="thriller"] :is(.book-card-title-row h3,.sylva-saga-card h3,.home-info-card b),html[data-theme="cyberpunk"] :is(.book-card-title-row h3,.sylva-saga-card h3,.home-info-card b){font-family:var(--theme-display)!important}
html[data-theme="modern"] .home-section+.home-section,html[data-theme="fantasy"] .home-section+.home-section,html[data-theme="thriller"] .home-section+.home-section,html[data-theme="cyberpunk"] .home-section+.home-section{border-color:var(--line)!important}
html[data-theme="modern"] :is(.sylva-book-card,.home-export-actions .big-action,.home-info-card,.sylva-empty),html[data-theme="fantasy"] :is(.sylva-book-card,.home-export-actions .big-action,.home-info-card,.sylva-empty),html[data-theme="thriller"] :is(.sylva-book-card,.home-export-actions .big-action,.home-info-card,.sylva-empty),html[data-theme="cyberpunk"] :is(.sylva-book-card,.home-export-actions .big-action,.home-info-card,.sylva-empty){background:var(--surface)!important;border-color:var(--line)!important;color:var(--text)!important;box-shadow:var(--shadow)!important}
html[data-theme="modern"] .sylva-book-card:hover,html[data-theme="fantasy"] .sylva-book-card:hover,html[data-theme="thriller"] .sylva-book-card:hover,html[data-theme="cyberpunk"] .sylva-book-card:hover{border-color:color-mix(in srgb,var(--accent) 35%,var(--line))!important}
html[data-theme="modern"] .sylva-book-card.active-book,html[data-theme="fantasy"] .sylva-book-card.active-book,html[data-theme="thriller"] .sylva-book-card.active-book,html[data-theme="cyberpunk"] .sylva-book-card.active-book{border-color:color-mix(in srgb,var(--accent) 58%,var(--line))!important}
html[data-theme="modern"] .book-cover-button{background:#dce2e8!important}html[data-theme="fantasy"] .book-cover-button{background:#463f2e!important}html[data-theme="thriller"] .book-cover-button{background:#282b2e!important}html[data-theme="cyberpunk"] .book-cover-button{background:#0d1b25!important}
html[data-theme="modern"] .sylva-saga-card,html[data-theme="modern"] .sylva-saga-card:nth-child(n){background:linear-gradient(135deg,#f6f8fa,#edf2f6)!important;border-color:var(--line)!important}
html[data-theme="fantasy"] .sylva-saga-card,html[data-theme="fantasy"] .sylva-saga-card:nth-child(n){background:linear-gradient(135deg,#322f22,#24251b 62%,#343021)!important;border-color:rgba(193,154,85,.17)!important}
html[data-theme="thriller"] .sylva-saga-card,html[data-theme="thriller"] .sylva-saga-card:nth-child(n){background:linear-gradient(135deg,#24272a,#1c1f22 65%,#282124)!important;border-color:var(--line)!important}
html[data-theme="cyberpunk"] .sylva-saga-card,html[data-theme="cyberpunk"] .sylva-saga-card:nth-child(n){background:linear-gradient(135deg,#0e1d27,#0a141d 62%,#181329)!important;border-color:rgba(0,217,237,.18)!important}
html[data-theme="modern"] .home-export-actions .big-action .action-icon{color:var(--accent)!important}html[data-theme="fantasy"] .home-export-actions .big-action .action-icon{color:var(--accent)!important}html[data-theme="thriller"] .home-export-actions .big-action .action-icon{color:var(--accent)!important}html[data-theme="cyberpunk"] .home-export-actions .big-action .action-icon{color:var(--accent)!important}

/* Writer/Reader: retain the existing layout, change only chrome and paper/ink. */
html[data-theme="modern"][data-route="writer"] :is(.main-area,#writerView,.editor-stage,.editor-viewport),html[data-theme="fantasy"][data-route="writer"] :is(.main-area,#writerView,.editor-stage,.editor-viewport),html[data-theme="thriller"][data-route="writer"] :is(.main-area,#writerView,.editor-stage,.editor-viewport),html[data-theme="cyberpunk"][data-route="writer"] :is(.main-area,#writerView,.editor-stage,.editor-viewport){background:var(--theme-paper)!important}
html[data-theme="modern"][data-route="writer"] #rail,html[data-theme="fantasy"][data-route="writer"] #rail,html[data-theme="thriller"][data-route="writer"] #rail,html[data-theme="cyberpunk"][data-route="writer"] #rail{background:var(--theme-chrome)!important;border-color:var(--line)!important;color:var(--text)!important}
html[data-theme="modern"][data-route="writer"] .topbar,html[data-theme="fantasy"][data-route="writer"] .topbar,html[data-theme="thriller"][data-route="writer"] .topbar,html[data-theme="cyberpunk"][data-route="writer"] .topbar{background:var(--theme-chrome)!important;border-color:var(--line)!important;color:var(--text)!important}
html[data-theme="modern"][data-route="writer"] .book-title-top,html[data-theme="fantasy"][data-route="writer"] .book-title-top,html[data-theme="thriller"][data-route="writer"] .book-title-top,html[data-theme="cyberpunk"][data-route="writer"] .book-title-top{color:var(--text)!important}
html[data-theme="modern"][data-route="writer"] .scene-editor,html[data-theme="fantasy"][data-route="writer"] .scene-editor,html[data-theme="thriller"][data-route="writer"] .scene-editor,html[data-theme="cyberpunk"][data-route="writer"] .scene-editor{color:var(--theme-paper-ink)!important;caret-color:var(--accent)!important}
html[data-theme="modern"][data-route="writer"] .scene-label,html[data-theme="fantasy"][data-route="writer"] .scene-label,html[data-theme="thriller"][data-route="writer"] .scene-label,html[data-theme="cyberpunk"][data-route="writer"] .scene-label{color:var(--theme-paper-muted)!important}
html[data-theme="modern"][data-route="writer"] .floating-toolbar,html[data-theme="fantasy"][data-route="writer"] .floating-toolbar,html[data-theme="thriller"][data-route="writer"] .floating-toolbar,html[data-theme="cyberpunk"][data-route="writer"] .floating-toolbar{background:color-mix(in srgb,var(--theme-chrome) 95%,transparent)!important;border-color:var(--line)!important;box-shadow:0 7px 24px color-mix(in srgb,var(--bg) 30%,transparent)!important}
html[data-theme="modern"][data-route="writer"] .floating-toolbar :is(button,select),html[data-theme="fantasy"][data-route="writer"] .floating-toolbar :is(button,select),html[data-theme="thriller"][data-route="writer"] .floating-toolbar :is(button,select),html[data-theme="cyberpunk"][data-route="writer"] .floating-toolbar :is(button,select){color:var(--text)!important}
html[data-theme="modern"][data-route="writer"] .writer-nav-toggle,html[data-theme="fantasy"][data-route="writer"] .writer-nav-toggle,html[data-theme="thriller"][data-route="writer"] .writer-nav-toggle,html[data-theme="cyberpunk"][data-route="writer"] .writer-nav-toggle{background:var(--theme-chrome)!important;border-color:var(--line)!important}

html[data-theme="modern"] :is(.reader-view,.reader-viewport),html[data-theme="fantasy"] :is(.reader-view,.reader-viewport),html[data-theme="thriller"] :is(.reader-view,.reader-viewport),html[data-theme="cyberpunk"] :is(.reader-view,.reader-viewport){background:var(--bg)!important}
html[data-theme="modern"] .reader-document,html[data-theme="fantasy"] .reader-document,html[data-theme="thriller"] .reader-document,html[data-theme="cyberpunk"] .reader-document{background:var(--theme-paper)!important;border-color:color-mix(in srgb,var(--theme-paper-ink) 13%,transparent)!important}
html[data-theme="modern"] :is(.reader-editor,.reader-book-copy,.reader-separator h2),html[data-theme="fantasy"] :is(.reader-editor,.reader-book-copy,.reader-separator h2),html[data-theme="thriller"] :is(.reader-editor,.reader-book-copy,.reader-separator h2),html[data-theme="cyberpunk"] :is(.reader-editor,.reader-book-copy,.reader-separator h2){color:var(--theme-paper-ink)!important}
html[data-theme="modern"] :is(.reader-scene-label,.reader-separator small),html[data-theme="fantasy"] :is(.reader-scene-label,.reader-separator small),html[data-theme="thriller"] :is(.reader-scene-label,.reader-separator small),html[data-theme="cyberpunk"] :is(.reader-scene-label,.reader-separator small){color:var(--theme-paper-muted)!important}
html[data-theme="modern"] :is(.review-original-sheet,.review-edit-sheet),html[data-theme="fantasy"] :is(.review-original-sheet,.review-edit-sheet),html[data-theme="thriller"] :is(.review-original-sheet,.review-edit-sheet),html[data-theme="cyberpunk"] :is(.review-original-sheet,.review-edit-sheet){background:var(--theme-paper)!important;color:var(--theme-paper-ink)!important;border-color:color-mix(in srgb,var(--theme-paper-ink) 13%,transparent)!important}
html[data-theme="modern"] :is(.review-original-copy,.review-scene-editor),html[data-theme="fantasy"] :is(.review-original-copy,.review-scene-editor),html[data-theme="thriller"] :is(.review-original-copy,.review-scene-editor),html[data-theme="cyberpunk"] :is(.review-original-copy,.review-scene-editor){color:var(--theme-paper-ink)!important}

/* Access/login and legal share the active atmosphere. */
html[data-theme="modern"] .entry-gate{background:linear-gradient(145deg,#e9eef3,#f6f8fa 55%,#e8edf2)!important;color:var(--text)!important}
html[data-theme="fantasy"] .entry-gate{background:radial-gradient(circle at 12% 10%,rgba(119,135,75,.13),transparent 25%),linear-gradient(145deg,#12140e,#1d1c14 58%,#15160f)!important;color:var(--text)!important}
html[data-theme="thriller"] .entry-gate{background:radial-gradient(circle at 88% 12%,rgba(171,50,55,.09),transparent 23%),linear-gradient(145deg,#0d0f11,#191c1f 60%,#101214)!important;color:var(--text)!important}
html[data-theme="cyberpunk"] .entry-gate{background:linear-gradient(rgba(0,217,237,.035) 1px,transparent 1px),linear-gradient(90deg,rgba(0,217,237,.035) 1px,transparent 1px),radial-gradient(circle at 90% 12%,rgba(243,79,201,.12),transparent 24%),linear-gradient(145deg,#05080d,#09121b 60%,#05090f)!important;background-size:32px 32px,32px 32px,auto,auto!important;color:var(--text)!important}
html[data-theme="modern"] .entry-access,html[data-theme="fantasy"] .entry-access,html[data-theme="thriller"] .entry-access,html[data-theme="cyberpunk"] .entry-access{background:color-mix(in srgb,var(--surface-strong) 91%,transparent)!important;border-color:var(--line)!important;color:var(--text)!important;box-shadow:var(--shadow)!important}
html[data-theme="modern"] :is(.entry-access h2,.entry-brand-block h1),html[data-theme="fantasy"] :is(.entry-access h2,.entry-brand-block h1),html[data-theme="thriller"] :is(.entry-access h2,.entry-brand-block h1),html[data-theme="cyberpunk"] :is(.entry-access h2,.entry-brand-block h1){font-family:var(--theme-display)!important;color:var(--text)!important}
html[data-theme="modern"] :is(.entry-access p,.entry-lead,.entry-access small,.entry-status,.entry-footer),html[data-theme="fantasy"] :is(.entry-access p,.entry-lead,.entry-access small,.entry-status,.entry-footer),html[data-theme="thriller"] :is(.entry-access p,.entry-lead,.entry-access small,.entry-status,.entry-footer),html[data-theme="cyberpunk"] :is(.entry-access p,.entry-lead,.entry-access small,.entry-status,.entry-footer){color:var(--muted)!important}
html[data-theme="modern"] .entry-login-btn,html[data-theme="fantasy"] .entry-login-btn,html[data-theme="thriller"] .entry-login-btn,html[data-theme="cyberpunk"] .entry-login-btn{background:var(--theme-primary)!important;color:var(--theme-primary-text)!important;border-color:color-mix(in srgb,var(--theme-primary) 72%,var(--line))!important}
html[data-theme="modern"] .entry-guest-btn,html[data-theme="fantasy"] .entry-guest-btn,html[data-theme="thriller"] .entry-guest-btn,html[data-theme="cyberpunk"] .entry-guest-btn{color:var(--muted)!important;border-color:var(--line)!important}
html[data-theme="modern"] .entry-features span,html[data-theme="fantasy"] .entry-features span,html[data-theme="thriller"] .entry-features span,html[data-theme="cyberpunk"] .entry-features span{background:var(--surface-2)!important;color:var(--muted)!important;border-color:var(--line)!important}

/* Component signatures: recognizable without changing geometry. */
html[data-theme="modern"] :is(.rail,.topbar,.modal,.codex-card,.planning-scenes-panel,.planning-detail,.relationship-page-list-panel,.calendar-foundation,.calendar-months-section,.timeline-event-card){border-color:var(--line)!important}
html[data-theme="fantasy"] :is(.rail,.topbar,.modal,.codex-card,.planning-scenes-panel,.planning-detail,.relationship-page-list-panel,.calendar-foundation,.calendar-months-section,.timeline-event-card){border-color:rgba(215,190,140,.15)!important}
html[data-theme="thriller"] :is(.rail,.topbar,.modal,.codex-card,.planning-scenes-panel,.planning-detail,.relationship-page-list-panel,.calendar-foundation,.calendar-months-section,.timeline-event-card){border-color:rgba(238,240,241,.10)!important}
html[data-theme="cyberpunk"] :is(.rail,.topbar,.modal,.codex-card,.planning-scenes-panel,.planning-detail,.relationship-page-list-panel,.calendar-foundation,.calendar-months-section,.timeline-event-card){border-color:rgba(0,217,237,.18)!important;box-shadow:0 0 0 1px rgba(243,79,201,.025),var(--shadow)!important}
html[data-theme="fantasy"] :is(.planning-block-head small,.relationship-page-section-head small,.calendar-section-head small,.codex-world-head small,.timeline-section-head small){color:var(--accent)!important;font-family:var(--theme-ui)!important}
html[data-theme="thriller"] :is(.planning-block-head small,.relationship-page-section-head small,.calendar-section-head small,.codex-world-head small,.timeline-section-head small){color:var(--accent)!important;letter-spacing:.13em!important}
html[data-theme="cyberpunk"] :is(.planning-block-head small,.relationship-page-section-head small,.calendar-section-head small,.codex-world-head small,.timeline-section-head small){color:var(--accent)!important;letter-spacing:.15em!important;text-shadow:0 0 12px rgba(0,217,237,.22)}

/* Theme picker — readable, touch-friendly and visually descriptive. */
.theme-picker-modal{width:min(900px,calc(100vw - 28px))!important}
.theme-special-group{padding:16px!important;border-radius:20px!important;margin-bottom:14px!important}
.narrative-theme-group{background:color-mix(in srgb,var(--surface-2) 88%,transparent)!important;border-color:var(--line)!important}
.theme-special-head{align-items:flex-start!important;margin-bottom:12px!important}.theme-special-head span{font-family:var(--ui-serif,Georgia,serif);font-size:18px!important;line-height:1.15}.theme-special-head small{font-size:11px!important;line-height:1.5!important;max-width:52ch}
.theme-special-grid,.theme-standard-grid{gap:12px!important}.theme-card{grid-template-columns:64px minmax(0,1fr) auto!important;gap:13px!important;min-height:76px!important;padding:12px 13px!important;border-radius:15px!important}.theme-preview{width:64px!important;height:46px!important;border-radius:11px!important}.theme-preview:before{left:8px!important;top:8px!important;width:32px!important;height:28px!important}.theme-preview:after{right:8px!important;top:9px!important;height:27px!important}.theme-copy b{font-size:14px!important;line-height:1.2}.theme-copy small{display:block;font-size:11px!important;line-height:1.42;margin-top:3px}.theme-exclusive-label{font-size:9px!important;line-height:1.1!important;margin-bottom:3px!important}.theme-check{font-size:13px!important}
.theme-modern .theme-preview{background:linear-gradient(135deg,#edf1f5 0 45%,#dfe6ec 45% 100%)!important}.theme-modern .theme-preview:before{background:#fff!important;box-shadow:inset 0 0 0 1px rgba(55,82,104,.11)}.theme-modern .theme-preview:after{background:#3f6386!important}
.theme-fantasy .theme-preview{background:linear-gradient(135deg,#171812 0 52%,#3a3425 52% 100%)!important}.theme-fantasy .theme-preview:before{background:#f2e7d0!important;box-shadow:inset 0 0 0 1px rgba(99,75,40,.22)}.theme-fantasy .theme-preview:after{background:#c19a55!important}
.theme-thriller .theme-preview{background:linear-gradient(135deg,#101214 0 56%,#25282b 56% 100%)!important}.theme-thriller .theme-preview:before{background:#f1f0ec!important}.theme-thriller .theme-preview:after{background:#c64b50!important;width:5px!important;border-radius:2px!important}
.theme-cyberpunk .theme-preview{background:linear-gradient(rgba(0,217,237,.08) 1px,transparent 1px),linear-gradient(90deg,rgba(0,217,237,.08) 1px,transparent 1px),#070b11!important;background-size:10px 10px!important}.theme-cyberpunk .theme-preview:before{background:#101a24!important;box-shadow:inset 0 0 0 1px rgba(0,217,237,.25)}.theme-cyberpunk .theme-preview:after{background:linear-gradient(#00d9ed 0 48%,#f34fc9 48% 100%)!important;width:7px!important;border-radius:2px!important}

@media(max-width:820px){
  .theme-picker-modal{width:calc(100vw - 18px)!important}.theme-special-group{padding:14px!important}.theme-special-grid,.theme-standard-grid{grid-template-columns:1fr 1fr!important}.theme-card{grid-template-columns:58px minmax(0,1fr) auto!important;min-height:78px!important}.theme-preview{width:58px!important;height:44px!important}
}
@media(max-width:620px){
  .theme-special-grid,.theme-standard-grid{grid-template-columns:1fr!important}.theme-special-head{display:block!important}.theme-special-head small{margin-top:6px!important}.theme-card{min-height:74px!important;grid-template-columns:56px minmax(0,1fr) auto!important}.theme-preview{width:56px!important;height:42px!important}
}
@media(pointer:coarse){.theme-card{min-height:82px!important}.theme-check{min-width:24px;min-height:44px;display:grid;place-items:center}}

/* 0.964 theme picker specificity consolidation: override older modal rules. */
.theme-picker-modal .theme-special-grid,.theme-picker-modal .theme-standard-grid{grid-template-columns:repeat(2,minmax(0,1fr))!important;gap:12px!important}
.theme-picker-modal .theme-copy b{font-size:14px!important;line-height:1.2!important}
.theme-picker-modal .theme-copy small{display:block!important;font-size:11px!important;line-height:1.42!important;margin-top:3px!important}
.theme-picker-modal .theme-exclusive-label{font-size:10px!important;line-height:1.1!important;margin-bottom:3px!important}
@media(max-width:620px){.theme-picker-modal .theme-special-grid,.theme-picker-modal .theme-standard-grid{grid-template-columns:1fr!important}}

/* Theme Pack 0.964 · logo contrast on narrative dark themes.
   Keep the original green lockup on light/Modern surfaces; use the official ivory
   lockup wherever the selected atmosphere has dark chrome. */
html[data-theme="fantasy"] :is(.sylva-splash-symbol img,.sylva-login-full,.sylva-phone-brand img,.sylva-legal-brand img,.home-logo-full,#rail .brand img),
html[data-theme="thriller"] :is(.sylva-splash-symbol img,.sylva-login-full,.sylva-phone-brand img,.sylva-legal-brand img,.home-logo-full,#rail .brand img),
html[data-theme="cyberpunk"] :is(.sylva-splash-symbol img,.sylva-login-full,.sylva-phone-brand img,.sylva-legal-brand img,.home-logo-full,#rail .brand img){
  content:url("assets/sylva-logo-ivory.png")!important;
}
html[data-theme="modern"] :is(.sylva-splash-symbol img,.sylva-login-full,.sylva-phone-brand img,.sylva-legal-brand img,.home-logo-full,#rail .brand img){
  content:url("assets/sylva-logo-green.png")!important;
}

/* ==========================================================================
   SYLVA BETA 0.965 — NARRATIVE THEME AUDIT / POLISH PASS
   Extends the 0.964 theme system to cover physical reader pages, manuscript
   sheets, menus, progress visuals and secondary analysis surfaces.
   ========================================================================== */
html[data-theme="modern"]{
  --theme-stage-bg:radial-gradient(circle at 8% 5%,rgba(108,137,168,.12),transparent 26%),radial-gradient(circle at 92% 12%,rgba(113,145,176,.09),transparent 22%),linear-gradient(145deg,#f0f4f8,#e9eef3 58%,#eef3f7);
  --theme-paper:#fcfdff;--theme-paper-ink:#24303b;--theme-paper-muted:#778290;
  --theme-paper-page:linear-gradient(180deg,#fefefe 0%,#f9fbfd 54%,#edf2f7 100%);
  --theme-paper-grain:repeating-linear-gradient(0deg,rgba(48,73,98,.012) 0,rgba(48,73,98,.012) 1px,transparent 1px,transparent 4px);
  --theme-paper-line:rgba(55,85,112,.14);
  --theme-book-spine:linear-gradient(90deg,transparent,rgba(78,103,126,.10),rgba(255,255,255,.26),rgba(78,103,126,.08),transparent);
  --theme-page-shadow-left:inset -24px 0 38px rgba(71,91,112,.06),inset 0 1px rgba(255,255,255,.72);
  --theme-page-shadow-right:inset 24px 0 38px rgba(71,91,112,.055),inset 0 1px rgba(255,255,255,.72);
  --theme-sheet-shadow:0 18px 56px rgba(35,52,70,.10), inset 0 1px rgba(255,255,255,.55);
  --theme-sheet-border:rgba(55,85,112,.11);
}
html[data-theme="fantasy"]{
  --theme-stage-bg:radial-gradient(circle at 12% 6%,rgba(122,139,82,.15),transparent 24%),radial-gradient(circle at 92% 11%,rgba(193,154,85,.11),transparent 23%),linear-gradient(145deg,#141610,#1c1c14 55%,#151711);
  --theme-paper:#efe2c8;--theme-paper-ink:#382f22;--theme-paper-muted:#84735d;
  --theme-paper-page:radial-gradient(circle at 12% 10%,rgba(194,158,92,.08),transparent 22%),repeating-linear-gradient(0deg,rgba(101,79,47,.018) 0,rgba(101,79,47,.018) 1px,transparent 1px,transparent 4px),linear-gradient(180deg,#f4ead7 0%,#ecdfc7 54%,#dfcfb1 100%);
  --theme-paper-grain:repeating-linear-gradient(0deg,rgba(96,74,43,.018) 0,rgba(96,74,43,.018) 1px,transparent 1px,transparent 4px);
  --theme-paper-line:rgba(108,83,46,.16);
  --theme-book-spine:linear-gradient(90deg,transparent,rgba(113,89,53,.12),rgba(255,247,229,.16),rgba(113,89,53,.09),transparent);
  --theme-page-shadow-left:inset -24px 0 38px rgba(95,73,43,.08),inset 0 1px rgba(255,249,236,.72);
  --theme-page-shadow-right:inset 24px 0 38px rgba(95,73,43,.07),inset 0 1px rgba(255,249,236,.72);
  --theme-sheet-shadow:0 22px 62px rgba(0,0,0,.26), inset 0 1px rgba(255,246,228,.22);
  --theme-sheet-border:rgba(170,138,86,.20);
}
html[data-theme="thriller"]{
  --theme-stage-bg:radial-gradient(circle at 86% 8%,rgba(171,50,55,.10),transparent 22%),radial-gradient(circle at 18% 84%,rgba(103,109,114,.06),transparent 22%),linear-gradient(150deg,#0e1012,#16191c 56%,#111315);
  --theme-paper:#ece9e2;--theme-paper-ink:#242628;--theme-paper-muted:#75797d;
  --theme-paper-page:radial-gradient(circle at 90% 11%,rgba(201,88,93,.04),transparent 20%),repeating-linear-gradient(0deg,rgba(88,92,96,.016) 0,rgba(88,92,96,.016) 1px,transparent 1px,transparent 4px),linear-gradient(180deg,#f1efea 0%,#e7e4de 58%,#d8d3cb 100%);
  --theme-paper-grain:repeating-linear-gradient(0deg,rgba(86,90,93,.016) 0,rgba(86,90,93,.016) 1px,transparent 1px,transparent 4px);
  --theme-paper-line:rgba(77,81,85,.15);
  --theme-book-spine:linear-gradient(90deg,transparent,rgba(75,79,83,.14),rgba(255,255,255,.18),rgba(75,79,83,.12),transparent);
  --theme-page-shadow-left:inset -24px 0 38px rgba(63,66,69,.085),inset 0 1px rgba(255,255,255,.66);
  --theme-page-shadow-right:inset 24px 0 38px rgba(63,66,69,.075),inset 0 1px rgba(255,255,255,.66);
  --theme-sheet-shadow:0 22px 58px rgba(0,0,0,.22), inset 0 1px rgba(255,255,255,.46);
  --theme-sheet-border:rgba(89,94,98,.16);
}
html[data-theme="cyberpunk"]{
  --theme-stage-bg:
    radial-gradient(circle at 12% 8%,rgba(0,217,237,.10),transparent 24%),
    radial-gradient(circle at 88% 12%,rgba(243,79,201,.08),transparent 22%),
    linear-gradient(rgba(0,217,237,.028) 1px,transparent 1px),
    linear-gradient(90deg,rgba(0,217,237,.028) 1px,transparent 1px),
    linear-gradient(145deg,#05090f,#0a1018 58%,#060a10);
  --theme-paper:#0e1721;--theme-paper-ink:#daf8fb;--theme-paper-muted:#86a6af;
  --theme-paper-page:radial-gradient(circle at 16% 10%,rgba(0,217,237,.10),transparent 18%),radial-gradient(circle at 86% 12%,rgba(243,79,201,.07),transparent 16%),linear-gradient(rgba(0,217,237,.042) 1px,transparent 1px),linear-gradient(90deg,rgba(0,217,237,.042) 1px,transparent 1px),linear-gradient(180deg,#0f1a25 0%,#0b151d 60%,#081018 100%);
  --theme-paper-grain:linear-gradient(rgba(0,217,237,.038) 1px,transparent 1px),linear-gradient(90deg,rgba(0,217,237,.038) 1px,transparent 1px);
  --theme-paper-line:rgba(0,217,237,.20);
  --theme-book-spine:linear-gradient(90deg,transparent,rgba(0,217,237,.14),rgba(243,79,201,.09),rgba(0,217,237,.14),transparent);
  --theme-page-shadow-left:inset -24px 0 44px rgba(0,0,0,.18),inset 0 0 0 1px rgba(0,217,237,.12);
  --theme-page-shadow-right:inset 24px 0 44px rgba(0,0,0,.18),inset 0 0 0 1px rgba(0,217,237,.12);
  --theme-sheet-shadow:0 20px 62px rgba(0,0,0,.34),0 0 0 1px rgba(0,217,237,.10),inset 0 0 0 1px rgba(243,79,201,.045);
  --theme-sheet-border:rgba(0,217,237,.18);
}
html[data-theme="cyberpunk"] body{background:var(--theme-stage-bg)!important;background-size:auto,auto,28px 28px,28px 28px,auto!important}
html[data-theme="cyberpunk"] body::before{
  content:"";position:fixed;inset:0;pointer-events:none;z-index:0;opacity:.55;
  background:radial-gradient(circle at 15% 12%,rgba(0,217,237,.06),transparent 22%),radial-gradient(circle at 86% 18%,rgba(243,79,201,.05),transparent 19%),linear-gradient(transparent 0,rgba(0,217,237,.016) 52%,transparent 100%);
  mix-blend-mode:screen;
}
html[data-theme="cyberpunk"] .app-shell,html[data-theme="cyberpunk"] #app{position:relative;z-index:1}

html[data-theme="modern"][data-route="writer"] :is(.main-area,#writerView,.editor-stage,.editor-viewport),
html[data-theme="fantasy"][data-route="writer"] :is(.main-area,#writerView,.editor-stage,.editor-viewport),
html[data-theme="thriller"][data-route="writer"] :is(.main-area,#writerView,.editor-stage,.editor-viewport),
html[data-theme="cyberpunk"][data-route="writer"] :is(.main-area,#writerView,.editor-stage,.editor-viewport){background:var(--theme-stage-bg)!important}

html[data-theme="modern"][data-route="writer"] .scene-sheet,
html[data-theme="fantasy"][data-route="writer"] .scene-sheet,
html[data-theme="thriller"][data-route="writer"] .scene-sheet,
html[data-theme="cyberpunk"][data-route="writer"] .scene-sheet,
html[data-theme="modern"] :is(.review-original-sheet,.review-edit-sheet),
html[data-theme="fantasy"] :is(.review-original-sheet,.review-edit-sheet),
html[data-theme="thriller"] :is(.review-original-sheet,.review-edit-sheet),
html[data-theme="cyberpunk"] :is(.review-original-sheet,.review-edit-sheet){
  background:var(--theme-paper-page)!important;
  border:1px solid var(--theme-sheet-border)!important;
  box-shadow:var(--theme-sheet-shadow)!important;
}
html[data-theme="modern"][data-route="writer"] .scene-sheet:hover,
html[data-theme="fantasy"][data-route="writer"] .scene-sheet:hover,
html[data-theme="thriller"][data-route="writer"] .scene-sheet:hover,
html[data-theme="cyberpunk"][data-route="writer"] .scene-sheet:hover{box-shadow:0 24px 70px rgba(0,0,0,.16), inset 0 1px rgba(255,255,255,.18)!important}
html[data-theme="modern"] .document-meta,
html[data-theme="fantasy"] .document-meta,
html[data-theme="thriller"] .document-meta,
html[data-theme="cyberpunk"] .document-meta{
  background:color-mix(in srgb,var(--surface-strong) 84%,transparent)!important;border:1px solid var(--line)!important;box-shadow:var(--shadow)!important
}
html[data-theme="cyberpunk"] .document-meta{backdrop-filter:blur(14px) saturate(1.05)!important}

html[data-theme="modern"] :is(.floating-toolbar,.reader-bar,.reader-book-nav,.reader-notes-sheet,.review-workspace,.review-workspace-head,.review-column-labels,.review-column-labels>div,.review-pane,.timeline-event-card,.session-analysis-card,.goal-progress-card,.heatmap-card),
html[data-theme="fantasy"] :is(.floating-toolbar,.reader-bar,.reader-book-nav,.reader-notes-sheet,.review-workspace,.review-workspace-head,.review-column-labels,.review-column-labels>div,.review-pane,.timeline-event-card,.session-analysis-card,.goal-progress-card,.heatmap-card),
html[data-theme="thriller"] :is(.floating-toolbar,.reader-bar,.reader-book-nav,.reader-notes-sheet,.review-workspace,.review-workspace-head,.review-column-labels,.review-column-labels>div,.review-pane,.timeline-event-card,.session-analysis-card,.goal-progress-card,.heatmap-card),
html[data-theme="cyberpunk"] :is(.floating-toolbar,.reader-bar,.reader-book-nav,.reader-notes-sheet,.review-workspace,.review-workspace-head,.review-column-labels,.review-column-labels>div,.review-pane,.timeline-event-card,.session-analysis-card,.goal-progress-card,.heatmap-card){border-color:var(--line)!important}
html[data-theme="cyberpunk"] :is(.floating-toolbar,.reader-bar,.reader-book-nav,.review-workspace,.timeline-event-card,.session-analysis-card,.goal-progress-card){box-shadow:0 0 0 1px rgba(243,79,201,.035),var(--shadow)!important}

/* Progress, charts and analytics surfaces. */
html[data-theme="modern"] :is(.book-card-progress i,.saga-progress i,.progress-bar i,.reader-book-progress>i,.session-day-slot i),
html[data-theme="fantasy"] :is(.book-card-progress i,.saga-progress i,.progress-bar i,.reader-book-progress>i,.session-day-slot i),
html[data-theme="thriller"] :is(.book-card-progress i,.saga-progress i,.progress-bar i,.reader-book-progress>i,.session-day-slot i),
html[data-theme="cyberpunk"] :is(.book-card-progress i,.saga-progress i,.progress-bar i,.reader-book-progress>i,.session-day-slot i){background:linear-gradient(90deg,var(--accent),var(--accent-2))!important}
html[data-theme="modern"] .goals-trigger::after,
html[data-theme="fantasy"] .goals-trigger::after,
html[data-theme="thriller"] .goals-trigger::after,
html[data-theme="cyberpunk"] .goals-trigger::after{background:linear-gradient(90deg,var(--accent),var(--accent-2))!important;opacity:.86!important}
html[data-theme="modern"] .goals-trigger.goal-done::after,
html[data-theme="fantasy"] .goals-trigger.goal-done::after,
html[data-theme="thriller"] .goals-trigger.goal-done::after,
html[data-theme="cyberpunk"] .goals-trigger.goal-done::after{background:linear-gradient(90deg,var(--accent-2),var(--accent))!important;opacity:1!important}
html[data-theme="modern"] .goal-progress-card.complete,
html[data-theme="fantasy"] .goal-progress-card.complete,
html[data-theme="thriller"] .goal-progress-card.complete,
html[data-theme="cyberpunk"] .goal-progress-card.complete{border-color:color-mix(in srgb,var(--accent) 34%,var(--line))!important;background:color-mix(in srgb,var(--accent-soft) 56%,var(--surface-2))!important}
html[data-theme="modern"] .scene-chart-inner,
html[data-theme="fantasy"] .scene-chart-inner,
html[data-theme="thriller"] .scene-chart-inner,
html[data-theme="cyberpunk"] .scene-chart-inner{background:linear-gradient(to top,color-mix(in srgb,var(--line) 55%,transparent) 1px,transparent 1px),color-mix(in srgb,var(--surface-2) 78%,transparent)!important;background-size:100% 25%,auto!important}




html[data-theme="cyberpunk"] .svg-chart{background:linear-gradient(rgba(0,217,237,.028) 1px,transparent 1px),linear-gradient(90deg,rgba(0,217,237,.028) 1px,transparent 1px),color-mix(in srgb,var(--surface-2) 85%,transparent)!important;background-size:24px 24px,24px 24px,auto!important}
html[data-theme="cyberpunk"] .chart-grid line{stroke:rgba(0,217,237,.14)!important}
html[data-theme="cyberpunk"] .chart-area{fill:rgba(0,217,237,.08)!important}
html[data-theme="cyberpunk"] .chart-line{stroke:var(--accent)!important;filter:drop-shadow(0 0 6px rgba(0,217,237,.18))}
html[data-theme="cyberpunk"] .svg-chart circle{fill:var(--accent-2)!important;stroke:rgba(0,217,237,.28)!important}
html[data-theme="cyberpunk"] .session-day-slot{border-bottom-color:rgba(0,217,237,.18)!important}

/* Physical reader pages now inherit the active narrative theme. */
html[data-theme="modern"] .reader-book-spread,
html[data-theme="fantasy"] .reader-book-spread,
html[data-theme="thriller"] .reader-book-spread,
html[data-theme="cyberpunk"] .reader-book-spread{filter:drop-shadow(0 28px 38px rgba(0,0,0,.28))}
html[data-theme="modern"] .reader-book-spread::before,
html[data-theme="fantasy"] .reader-book-spread::before,
html[data-theme="thriller"] .reader-book-spread::before,
html[data-theme="cyberpunk"] .reader-book-spread::before{background:var(--theme-book-spine)!important}
html[data-theme="modern"] :is(.reader-book-page,.reader-book-turn-front,.reader-book-turn-back),
html[data-theme="fantasy"] :is(.reader-book-page,.reader-book-turn-front,.reader-book-turn-back),
html[data-theme="thriller"] :is(.reader-book-page,.reader-book-turn-front,.reader-book-turn-back),
html[data-theme="cyberpunk"] :is(.reader-book-page,.reader-book-turn-front,.reader-book-turn-back){
  color:var(--theme-paper-ink)!important;
  background:var(--theme-paper-page)!important;
  background-size:auto,auto,24px 24px,24px 24px,auto!important;
  border:1px solid var(--theme-paper-line)!important;
}
html[data-theme="modern"] .reader-book-page-left,html[data-theme="modern"] .reader-book-turn.turn-prev .reader-book-turn-front,html[data-theme="modern"] .reader-book-turn.turn-next .reader-book-turn-back,
html[data-theme="fantasy"] .reader-book-page-left,html[data-theme="fantasy"] .reader-book-turn.turn-prev .reader-book-turn-front,html[data-theme="fantasy"] .reader-book-turn.turn-next .reader-book-turn-back,
html[data-theme="thriller"] .reader-book-page-left,html[data-theme="thriller"] .reader-book-turn.turn-prev .reader-book-turn-front,html[data-theme="thriller"] .reader-book-turn.turn-next .reader-book-turn-back,
html[data-theme="cyberpunk"] .reader-book-page-left,html[data-theme="cyberpunk"] .reader-book-turn.turn-prev .reader-book-turn-front,html[data-theme="cyberpunk"] .reader-book-turn.turn-next .reader-book-turn-back{box-shadow:var(--theme-page-shadow-left)!important}
html[data-theme="modern"] .reader-book-page-right,html[data-theme="modern"] .reader-book-turn.turn-next .reader-book-turn-front,html[data-theme="modern"] .reader-book-turn.turn-prev .reader-book-turn-back,
html[data-theme="fantasy"] .reader-book-page-right,html[data-theme="fantasy"] .reader-book-turn.turn-next .reader-book-turn-front,html[data-theme="fantasy"] .reader-book-turn.turn-prev .reader-book-turn-back,
html[data-theme="thriller"] .reader-book-page-right,html[data-theme="thriller"] .reader-book-turn.turn-next .reader-book-turn-front,html[data-theme="thriller"] .reader-book-turn.turn-prev .reader-book-turn-back,
html[data-theme="cyberpunk"] .reader-book-page-right,html[data-theme="cyberpunk"] .reader-book-turn.turn-next .reader-book-turn-front,html[data-theme="cyberpunk"] .reader-book-turn.turn-prev .reader-book-turn-back{box-shadow:var(--theme-page-shadow-right)!important}
html[data-theme="modern"] .reader-book-spread.single-page .reader-book-page-left,
html[data-theme="fantasy"] .reader-book-spread.single-page .reader-book-page-left,
html[data-theme="thriller"] .reader-book-spread.single-page .reader-book-page-left,
html[data-theme="cyberpunk"] .reader-book-spread.single-page .reader-book-page-left{box-shadow:0 10px 30px rgba(0,0,0,.10),inset 0 0 0 1px color-mix(in srgb,var(--theme-paper-line) 80%,transparent)!important}
html[data-theme="modern"] .reader-book-page.is-blank,
html[data-theme="fantasy"] .reader-book-page.is-blank,
html[data-theme="thriller"] .reader-book-page.is-blank,
html[data-theme="cyberpunk"] .reader-book-page.is-blank{background:linear-gradient(180deg,color-mix(in srgb,var(--theme-paper) 96%,white),color-mix(in srgb,var(--theme-paper) 88%,var(--bg2)))!important}
html[data-theme="modern"] :is(.reader-book-heading,.reader-book-heading small,.reader-book-heading b,.reader-book-page-number,.reader-book-empty-mark,.reader-book-copy),
html[data-theme="fantasy"] :is(.reader-book-heading,.reader-book-heading small,.reader-book-heading b,.reader-book-page-number,.reader-book-empty-mark,.reader-book-copy),
html[data-theme="thriller"] :is(.reader-book-heading,.reader-book-heading small,.reader-book-heading b,.reader-book-page-number,.reader-book-empty-mark,.reader-book-copy),
html[data-theme="cyberpunk"] :is(.reader-book-heading,.reader-book-heading small,.reader-book-heading b,.reader-book-page-number,.reader-book-empty-mark,.reader-book-copy){color:var(--theme-paper-ink)!important}
html[data-theme="modern"] .reader-book-heading small,html[data-theme="fantasy"] .reader-book-heading small,html[data-theme="thriller"] .reader-book-heading small,html[data-theme="cyberpunk"] .reader-book-heading small,
html[data-theme="modern"] .reader-book-page-number,html[data-theme="fantasy"] .reader-book-page-number,html[data-theme="thriller"] .reader-book-page-number,html[data-theme="cyberpunk"] .reader-book-page-number{color:var(--theme-paper-muted)!important}
html[data-theme="cyberpunk"] .reader-book-heading b{letter-spacing:.015em}

/* Generic chips / menus / tabs that still used neutral leftovers. */
html[data-theme="modern"] :is(.chip,.pill,.tag,.badge,.choice-btn,.radio-chip,.filter-chip,.goal-chip,.scope-chip,.book-status-pill,.timeline-inline-chip),
html[data-theme="fantasy"] :is(.chip,.pill,.tag,.badge,.choice-btn,.radio-chip,.filter-chip,.goal-chip,.scope-chip,.book-status-pill,.timeline-inline-chip),
html[data-theme="thriller"] :is(.chip,.pill,.tag,.badge,.choice-btn,.radio-chip,.filter-chip,.goal-chip,.scope-chip,.book-status-pill,.timeline-inline-chip),
html[data-theme="cyberpunk"] :is(.chip,.pill,.tag,.badge,.choice-btn,.radio-chip,.filter-chip,.goal-chip,.scope-chip,.book-status-pill,.timeline-inline-chip){border-color:var(--line)!important;background:color-mix(in srgb,var(--surface-2) 88%,transparent)!important;color:var(--text)!important}
html[data-theme="modern"] :is(.chip.active,.pill.active,.tag.active,.badge.active,.choice-btn.active),
html[data-theme="fantasy"] :is(.chip.active,.pill.active,.tag.active,.badge.active,.choice-btn.active),
html[data-theme="thriller"] :is(.chip.active,.pill.active,.tag.active,.badge.active,.choice-btn.active),
html[data-theme="cyberpunk"] :is(.chip.active,.pill.active,.tag.active,.badge.active,.choice-btn.active){background:color-mix(in srgb,var(--accent-soft) 72%,var(--surface-2))!important;border-color:color-mix(in srgb,var(--accent) 36%,var(--line))!important;color:var(--text)!important}
html[data-theme="cyberpunk"] :is(.soft-btn,.mini-btn,.scope-btn,.icon-btn,.choice-btn,.chip,.pill,.tag,.badge){box-shadow:0 0 0 1px rgba(243,79,201,.028)!important}

/* ==========================================================================
   SYLVA BETA 0.966 — NARRATIVE THEME READABILITY TUNING
   Goal: themed paper in writer/reader with stronger readability and softer tint.
   ========================================================================== */
html[data-theme="modern"]{
  --theme-paper:#fbfdff;
  --theme-paper-ink:#22303a;
  --theme-paper-muted:#6f7f8d;
  --theme-paper-page:
    radial-gradient(circle at 14% 10%,rgba(122,148,177,.035),transparent 18%),
    linear-gradient(180deg,#ffffff 0%,#fbfdff 58%,#f2f6fb 100%);
  --theme-paper-line:rgba(61,90,117,.11);
  --theme-sheet-border:rgba(61,90,117,.10);
}
html[data-theme="fantasy"]{
  --theme-paper:#f5ead4;
  --theme-paper-ink:#382c1f;
  --theme-paper-muted:#82715c;
  --theme-paper-page:
    radial-gradient(circle at 12% 9%,rgba(194,158,92,.055),transparent 19%),
    radial-gradient(circle at 88% 88%,rgba(168,129,72,.040),transparent 22%),
    linear-gradient(180deg,#f7eddc 0%,#f2e6cf 58%,#e7d7ba 100%);
  --theme-paper-line:rgba(118,89,46,.14);
  --theme-sheet-border:rgba(166,130,79,.17);
}
html[data-theme="thriller"]{
  --theme-paper:#f3eeea;
  --theme-paper-ink:#262427;
  --theme-paper-muted:#746d72;
  --theme-paper-page:
    radial-gradient(circle at 90% 10%,rgba(168,71,77,.030),transparent 18%),
    linear-gradient(180deg,#f5f1ed 0%,#efe9e4 58%,#e2dbd4 100%);
  --theme-paper-line:rgba(79,80,84,.13);
  --theme-sheet-border:rgba(88,89,93,.13);
}
html[data-theme="cyberpunk"]{
  --theme-paper:#eef9fc;
  --theme-paper-ink:#17313b;
  --theme-paper-muted:#5f7d87;
  --theme-paper-page:
    radial-gradient(circle at 12% 8%,rgba(0,217,237,.055),transparent 17%),
    radial-gradient(circle at 89% 12%,rgba(243,79,201,.030),transparent 14%),
    linear-gradient(180deg,#f5feff 0%,#eef9fc 58%,#e2f2f7 100%);
  --theme-paper-line:rgba(42,130,145,.13);
  --theme-sheet-border:rgba(0,217,237,.13);
  --theme-page-shadow-left:inset -24px 0 34px rgba(16,67,81,.06),inset 0 0 0 1px rgba(0,217,237,.08);
  --theme-page-shadow-right:inset 24px 0 34px rgba(16,67,81,.06),inset 0 0 0 1px rgba(0,217,237,.08);
}

/* Writer manuscript sheet: always themed, always readable. */
html[data-theme="modern"][data-route="writer"] .scene-sheet,
html[data-theme="fantasy"][data-route="writer"] .scene-sheet,
html[data-theme="thriller"][data-route="writer"] .scene-sheet,
html[data-theme="cyberpunk"][data-route="writer"] .scene-sheet{
  background:var(--theme-paper-page)!important;
  color:var(--theme-paper-ink)!important;
  border:1px solid var(--theme-sheet-border)!important;
}
html[data-theme="modern"][data-route="writer"] .scene-editor,
html[data-theme="fantasy"][data-route="writer"] .scene-editor,
html[data-theme="thriller"][data-route="writer"] .scene-editor,
html[data-theme="cyberpunk"][data-route="writer"] .scene-editor,
html[data-theme="modern"] .review-original-copy,
html[data-theme="modern"] .review-scene-editor,
html[data-theme="fantasy"] .review-original-copy,
html[data-theme="fantasy"] .review-scene-editor,
html[data-theme="thriller"] .review-original-copy,
html[data-theme="thriller"] .review-scene-editor,
html[data-theme="cyberpunk"] .review-original-copy,
html[data-theme="cyberpunk"] .review-scene-editor{
  color:var(--theme-paper-ink)!important;
}
html[data-theme="modern"][data-route="writer"] .scene-label,
html[data-theme="fantasy"][data-route="writer"] .scene-label,
html[data-theme="thriller"][data-route="writer"] .scene-label,
html[data-theme="cyberpunk"][data-route="writer"] .scene-label{color:var(--theme-paper-muted)!important}

/* Reader classic document paper. */
html[data-theme="modern"] .reader-document,
html[data-theme="fantasy"] .reader-document,
html[data-theme="thriller"] .reader-document,
html[data-theme="cyberpunk"] .reader-document{
  background:var(--theme-paper-page)!important;
  color:var(--theme-paper-ink)!important;
  border-color:var(--theme-sheet-border)!important;
}
html[data-theme="modern"] :is(.reader-editor,.reader-book-copy,.reader-separator h2),
html[data-theme="fantasy"] :is(.reader-editor,.reader-book-copy,.reader-separator h2),
html[data-theme="thriller"] :is(.reader-editor,.reader-book-copy,.reader-separator h2),
html[data-theme="cyberpunk"] :is(.reader-editor,.reader-book-copy,.reader-separator h2){
  color:var(--theme-paper-ink)!important;
}
html[data-theme="modern"] :is(.reader-scene-label,.reader-separator small,.reader-book-heading small,.reader-book-page-number),
html[data-theme="fantasy"] :is(.reader-scene-label,.reader-separator small,.reader-book-heading small,.reader-book-page-number),
html[data-theme="thriller"] :is(.reader-scene-label,.reader-separator small,.reader-book-heading small,.reader-book-page-number),
html[data-theme="cyberpunk"] :is(.reader-scene-label,.reader-separator small,.reader-book-heading small,.reader-book-page-number){
  color:var(--theme-paper-muted)!important;
}

/* Physical book pages: keep a theme hint, reduce visual noise, maximize contrast. */
html[data-theme="modern"] :is(.reader-book-page,.reader-book-turn-front,.reader-book-turn-back),
html[data-theme="fantasy"] :is(.reader-book-page,.reader-book-turn-front,.reader-book-turn-back),
html[data-theme="thriller"] :is(.reader-book-page,.reader-book-turn-front,.reader-book-turn-back),
html[data-theme="cyberpunk"] :is(.reader-book-page,.reader-book-turn-front,.reader-book-turn-back){
  background:var(--theme-paper-page)!important;
  color:var(--theme-paper-ink)!important;
}
html[data-theme="modern"] .reader-book-copy,
html[data-theme="fantasy"] .reader-book-copy,
html[data-theme="thriller"] .reader-book-copy,
html[data-theme="cyberpunk"] .reader-book-copy{color:var(--theme-paper-ink)!important;text-shadow:none!important}

/* ==========================================================================
   SYLVA BETA 0.967 — THEME SYSTEMIC PASS
   Login gate + Writer structure tree fully themed.
   ========================================================================== */

/* Login / entry gate follows the active narrative theme. */
html[data-theme="modern"] .entry-gate{
  background:linear-gradient(145deg,#edf2f7,#e8eef4 58%,#e4ebf2)!important;
  color:#24303b!important;
}
html[data-theme="modern"] .entry-gate::before{
  background:radial-gradient(circle at 14% 18%,rgba(109,139,171,.13),transparent 36%),radial-gradient(circle at 83% 78%,rgba(127,155,180,.10),transparent 34%),linear-gradient(130deg,#edf2f7 0%,#e8eef4 45%,#e4ebf2 100%)!important;
}
html[data-theme="modern"] .entry-gate::after{opacity:.12!important;background-image:linear-gradient(rgba(44,72,97,.018) 1px,transparent 1px),linear-gradient(90deg,rgba(44,72,97,.014) 1px,transparent 1px)!important}

html[data-theme="fantasy"] .entry-gate{
  background:linear-gradient(145deg,#14160f,#1a1b13 58%,#12140f)!important;
  color:#f0e5d2!important;
}
html[data-theme="fantasy"] .entry-gate::before{
  background:radial-gradient(circle at 14% 18%,rgba(193,154,85,.14),transparent 36%),radial-gradient(circle at 83% 78%,rgba(109,137,82,.12),transparent 34%),linear-gradient(130deg,#14160f 0%,#1b1c14 45%,#12140f 100%)!important;
}
html[data-theme="fantasy"] .entry-gate::after{opacity:.12!important;background-image:linear-gradient(rgba(255,248,230,.016) 1px,transparent 1px),linear-gradient(90deg,rgba(255,248,230,.012) 1px,transparent 1px)!important}

html[data-theme="thriller"] .entry-gate{
  background:linear-gradient(145deg,#101214,#17191b 58%,#0f1113)!important;
  color:#f1ece6!important;
}
html[data-theme="thriller"] .entry-gate::before{
  background:radial-gradient(circle at 14% 18%,rgba(166,67,73,.12),transparent 36%),radial-gradient(circle at 83% 78%,rgba(108,114,118,.10),transparent 34%),linear-gradient(130deg,#101214 0%,#17191b 45%,#0f1113 100%)!important;
}
html[data-theme="thriller"] .entry-gate::after{opacity:.10!important;background-image:linear-gradient(rgba(255,255,255,.014) 1px,transparent 1px),linear-gradient(90deg,rgba(255,255,255,.010) 1px,transparent 1px)!important}

html[data-theme="cyberpunk"] .entry-gate{
  background:linear-gradient(145deg,#05090f,#09111a 58%,#060a10)!important;
  color:#d8f8fb!important;
}
html[data-theme="cyberpunk"] .entry-gate::before{
  background:
    radial-gradient(circle at 12% 14%,rgba(0,217,237,.12),transparent 28%),
    radial-gradient(circle at 84% 22%,rgba(243,79,201,.09),transparent 24%),
    linear-gradient(rgba(0,217,237,.028) 1px,transparent 1px),
    linear-gradient(90deg,rgba(0,217,237,.028) 1px,transparent 1px),
    linear-gradient(130deg,#05090f 0%,#09111a 45%,#060a10 100%)!important;
  background-size:auto,auto,36px 36px,36px 36px,auto!important;
}
html[data-theme="cyberpunk"] .entry-gate::after{opacity:.18!important;background-image:linear-gradient(rgba(243,79,201,.012) 1px,transparent 1px),linear-gradient(90deg,rgba(0,217,237,.014) 1px,transparent 1px)!important}

html[data-theme="modern"] :is(.entry-brand-kicker,.entry-copy,.entry-footer,.entry-footer .entry-legal-link,.entry-chip,.entry-phone-copy,.phone-access-footer, .phone-access-footer button),
html[data-theme="fantasy"] :is(.entry-brand-kicker,.entry-copy,.entry-footer,.entry-footer .entry-legal-link,.entry-chip,.entry-phone-copy,.phone-access-footer, .phone-access-footer button),
html[data-theme="thriller"] :is(.entry-brand-kicker,.entry-copy,.entry-footer,.entry-footer .entry-legal-link,.entry-chip,.entry-phone-copy,.phone-access-footer, .phone-access-footer button),
html[data-theme="cyberpunk"] :is(.entry-brand-kicker,.entry-copy,.entry-footer,.entry-footer .entry-legal-link,.entry-chip,.entry-phone-copy,.phone-access-footer, .phone-access-footer button){color:inherit!important}
html[data-theme="modern"] .entry-card,
html[data-theme="fantasy"] .entry-card,
html[data-theme="thriller"] .entry-card,
html[data-theme="cyberpunk"] .entry-card,
html[data-theme="modern"] .phone-access-card,
html[data-theme="fantasy"] .phone-access-card,
html[data-theme="thriller"] .phone-access-card,
html[data-theme="cyberpunk"] .phone-access-card{
  background:color-mix(in srgb,var(--surface) 84%,transparent)!important;
  border-color:color-mix(in srgb,var(--accent) 28%,var(--line))!important;
  box-shadow:0 20px 56px rgba(0,0,0,.22),inset 0 0 0 1px color-mix(in srgb,var(--accent) 10%,transparent)!important;
}
html[data-theme="cyberpunk"] .entry-card,
html[data-theme="cyberpunk"] .phone-access-card{backdrop-filter:blur(16px) saturate(1.08)!important}
html[data-theme="modern"] .entry-main-title,
html[data-theme="fantasy"] .entry-main-title,
html[data-theme="thriller"] .entry-main-title,
html[data-theme="cyberpunk"] .entry-main-title{color:inherit!important}
html[data-theme="modern"] .entry-main-title i{color:#78889a!important}
html[data-theme="fantasy"] .entry-main-title i{color:#c5a774!important}
html[data-theme="thriller"] .entry-main-title i{color:#b09b8f!important}
html[data-theme="cyberpunk"] .entry-main-title i{color:#a7cdd5!important;text-shadow:0 0 22px rgba(0,217,237,.12)}
html[data-theme="modern"] .entry-main-title strong,
html[data-theme="fantasy"] .entry-main-title strong,
html[data-theme="thriller"] .entry-main-title strong,
html[data-theme="cyberpunk"] .entry-main-title strong{color:inherit!important}
html[data-theme="modern"] .entry-chip,
html[data-theme="fantasy"] .entry-chip,
html[data-theme="thriller"] .entry-chip,
html[data-theme="cyberpunk"] .entry-chip{background:color-mix(in srgb,var(--surface-2) 84%,transparent)!important;border-color:var(--line)!important}
html[data-theme="modern"] .entry-form .google-login-btn,
html[data-theme="fantasy"] .entry-form .google-login-btn,
html[data-theme="thriller"] .entry-form .google-login-btn,
html[data-theme="cyberpunk"] .entry-form .google-login-btn{box-shadow:0 12px 28px rgba(0,0,0,.12)!important}
html[data-theme="modern"] .entry-form .soft-btn,
html[data-theme="fantasy"] .entry-form .soft-btn,
html[data-theme="thriller"] .entry-form .soft-btn,
html[data-theme="cyberpunk"] .entry-form .soft-btn{background:color-mix(in srgb,var(--surface-2) 76%,transparent)!important;border-color:var(--line)!important}

/* Writer structure panel gets explicit theme treatment. */
html[data-theme="modern"] .structure-panel{
  background:linear-gradient(180deg,#fdfefe 0%,#f6f9fc 100%)!important;
  border:1px solid rgba(67,94,120,.10)!important;
  box-shadow:0 18px 40px rgba(44,60,78,.08), inset 0 1px rgba(255,255,255,.7)!important;
}
html[data-theme="fantasy"] .structure-panel{
  background:linear-gradient(180deg,#f4ead8 0%,#ecdfc8 100%)!important;
  border:1px solid rgba(158,125,76,.18)!important;
  box-shadow:0 18px 40px rgba(49,37,22,.14), inset 0 1px rgba(255,247,230,.5)!important;
}
html[data-theme="thriller"] .structure-panel{
  background:linear-gradient(180deg,#f0ece6 0%,#e6e0d9 100%)!important;
  border:1px solid rgba(95,97,101,.14)!important;
  box-shadow:0 18px 40px rgba(0,0,0,.12), inset 0 1px rgba(255,255,255,.5)!important;
}
html[data-theme="cyberpunk"] .structure-panel{
  background:linear-gradient(180deg,#0c141d 0%,#101923 100%)!important;
  border:1px solid rgba(0,217,237,.18)!important;
  box-shadow:0 18px 50px rgba(0,0,0,.34), 0 0 0 1px rgba(243,79,201,.04), inset 0 1px rgba(255,255,255,.03)!important;
}
html[data-theme="modern"] .structure-sticky-tools,
html[data-theme="fantasy"] .structure-sticky-tools,
html[data-theme="thriller"] .structure-sticky-tools,
html[data-theme="cyberpunk"] .structure-sticky-tools{
  border-bottom-color:var(--line)!important;
}
html[data-theme="modern"] .structure-sticky-tools{background:linear-gradient(to bottom,rgba(251,253,255,.98) 0%,rgba(248,251,254,.95) 78%,rgba(245,249,252,.88) 100%)!important}
html[data-theme="fantasy"] .structure-sticky-tools{background:linear-gradient(to bottom,rgba(244,235,218,.98) 0%,rgba(240,229,206,.95) 78%,rgba(236,223,200,.88) 100%)!important}
html[data-theme="thriller"] .structure-sticky-tools{background:linear-gradient(to bottom,rgba(242,237,232,.98) 0%,rgba(235,229,223,.95) 78%,rgba(228,222,216,.88) 100%)!important}
html[data-theme="cyberpunk"] .structure-sticky-tools{background:linear-gradient(to bottom,rgba(11,19,27,.98) 0%,rgba(12,21,31,.95) 78%,rgba(12,20,29,.88) 100%)!important}

html[data-theme="modern"] .structure-panel :is(.panel-head h3,.panel-head small,.tree-row,.tree-row i,.tree-row b,.tree-row span,.tree-row em),
html[data-theme="fantasy"] .structure-panel :is(.panel-head h3,.panel-head small,.tree-row,.tree-row i,.tree-row b,.tree-row span,.tree-row em),
html[data-theme="thriller"] .structure-panel :is(.panel-head h3,.panel-head small,.tree-row,.tree-row i,.tree-row b,.tree-row span,.tree-row em),
html[data-theme="cyberpunk"] .structure-panel :is(.panel-head h3,.panel-head small,.tree-row,.tree-row i,.tree-row b,.tree-row span,.tree-row em){color:inherit}
html[data-theme="modern"] .structure-panel{color:#24303b!important}
html[data-theme="fantasy"] .structure-panel{color:#392d1f!important}
html[data-theme="thriller"] .structure-panel{color:#262528!important}
html[data-theme="cyberpunk"] .structure-panel{color:#d7f7fb!important}
html[data-theme="modern"] .structure-panel .soft-btn,
html[data-theme="fantasy"] .structure-panel .soft-btn,
html[data-theme="thriller"] .structure-panel .soft-btn,
html[data-theme="cyberpunk"] .structure-panel .soft-btn,
html[data-theme="modern"] .structure-actions .soft-btn,
html[data-theme="fantasy"] .structure-actions .soft-btn,
html[data-theme="thriller"] .structure-actions .soft-btn,
html[data-theme="cyberpunk"] .structure-actions .soft-btn{
  background:color-mix(in srgb,var(--surface-2) 84%,transparent)!important;
  border-color:var(--line)!important;
}
html[data-theme="modern"] .tree-row,
html[data-theme="fantasy"] .tree-row,
html[data-theme="thriller"] .tree-row,
html[data-theme="cyberpunk"] .tree-row{
  border-radius:14px!important;
  border:1px solid transparent!important;
}
html[data-theme="modern"] .tree-row:hover,
html[data-theme="fantasy"] .tree-row:hover,
html[data-theme="thriller"] .tree-row:hover,
html[data-theme="cyberpunk"] .tree-row:hover{background:color-mix(in srgb,var(--accent-soft) 74%,transparent)!important}
html[data-theme="modern"] .tree-row.active,
html[data-theme="fantasy"] .tree-row.active,
html[data-theme="thriller"] .tree-row.active,
html[data-theme="cyberpunk"] .tree-row.active{
  background:color-mix(in srgb,var(--accent-soft) 94%,transparent)!important;
  border-color:color-mix(in srgb,var(--accent) 24%,var(--line))!important;
}
html[data-theme="modern"] .tree-row.context-active,
html[data-theme="fantasy"] .tree-row.context-active,
html[data-theme="thriller"] .tree-row.context-active,
html[data-theme="cyberpunk"] .tree-row.context-active{
  background:color-mix(in srgb,var(--accent-soft) 56%,transparent)!important;
  border-color:color-mix(in srgb,var(--accent) 18%,var(--line))!important;
}

/* ==========================================================================
   SYLVA BETA 0.968 — STRONG THEME PASS
   Stronger visible theme colors for Writer structure and manuscript paper.
   ========================================================================== */

/* Stronger theme paper, still highly readable. */
html[data-theme="modern"]{
  --theme-paper:#f8fbff;
  --theme-paper-ink:#23303a;
  --theme-paper-muted:#6f7f8d;
  --theme-paper-page:
    radial-gradient(circle at 12% 9%,rgba(106,137,168,.045),transparent 16%),
    linear-gradient(180deg,#fbfdff 0%,#f7fbff 56%,#edf4fb 100%);
}
html[data-theme="fantasy"]{
  --theme-paper:#f2e6cf;
  --theme-paper-ink:#372b1e;
  --theme-paper-muted:#7f6c56;
  --theme-paper-page:
    radial-gradient(circle at 14% 10%,rgba(194,158,92,.075),transparent 18%),
    radial-gradient(circle at 88% 84%,rgba(126,150,87,.045),transparent 18%),
    linear-gradient(180deg,#f5ead6 0%,#efdfc3 56%,#e2cfad 100%);
}
html[data-theme="thriller"]{
  --theme-paper:#efe7e3;
  --theme-paper-ink:#272427;
  --theme-paper-muted:#756d71;
  --theme-paper-page:
    radial-gradient(circle at 85% 12%,rgba(169,69,76,.055),transparent 18%),
    linear-gradient(180deg,#f2ece9 0%,#ebe3df 56%,#ddd3cf 100%);
}
html[data-theme="cyberpunk"]{
  --theme-paper:#ebf6fb;
  --theme-paper-ink:#19343d;
  --theme-paper-muted:#607f89;
  --theme-paper-page:
    radial-gradient(circle at 10% 10%,rgba(0,217,237,.070),transparent 18%),
    radial-gradient(circle at 90% 12%,rgba(181,130,255,.055),transparent 15%),
    linear-gradient(180deg,#f3fbff 0%,#ebf6fb 56%,#dcecf5 100%);
}

/* Writer paper – explicit and visible. */
html[data-theme="modern"] :is(.scene-sheet,.review-original-sheet,.review-edit-sheet),
html[data-theme="fantasy"] :is(.scene-sheet,.review-original-sheet,.review-edit-sheet),
html[data-theme="thriller"] :is(.scene-sheet,.review-original-sheet,.review-edit-sheet),
html[data-theme="cyberpunk"] :is(.scene-sheet,.review-original-sheet,.review-edit-sheet){
  background:var(--theme-paper-page)!important;
  color:var(--theme-paper-ink)!important;
  border-color:var(--theme-sheet-border)!important;
}
html[data-theme="modern"] :is(.scene-editor,.review-original-copy,.review-scene-editor),
html[data-theme="fantasy"] :is(.scene-editor,.review-original-copy,.review-scene-editor),
html[data-theme="thriller"] :is(.scene-editor,.review-original-copy,.review-scene-editor),
html[data-theme="cyberpunk"] :is(.scene-editor,.review-original-copy,.review-scene-editor){
  color:var(--theme-paper-ink)!important;
}
html[data-theme="modern"] .scene-sheet .codex-mark,
html[data-theme="fantasy"] .scene-sheet .codex-mark,
html[data-theme="thriller"] .scene-sheet .codex-mark,
html[data-theme="cyberpunk"] .scene-sheet .codex-mark{filter:saturate(.95)}

/* Structure panel: force each theme visually, including row cards. */
html[data-theme="modern"] .structure-panel{
  background:linear-gradient(180deg,#f8fbff 0%,#f3f8fd 100%)!important;
  color:#24313b!important;
  border:1px solid rgba(78,109,139,.14)!important;
}
html[data-theme="fantasy"] .structure-panel{
  background:linear-gradient(180deg,#f4ead7 0%,#ecdfc7 100%)!important;
  color:#392d1f!important;
  border:1px solid rgba(165,131,81,.21)!important;
}
html[data-theme="thriller"] .structure-panel{
  background:linear-gradient(180deg,#f1ebe7 0%,#e7dfda 100%)!important;
  color:#282528!important;
  border:1px solid rgba(104,96,100,.18)!important;
}
html[data-theme="cyberpunk"] .structure-panel{
  background:linear-gradient(180deg,#0c141d 0%,#121c28 100%)!important;
  color:#daf7fb!important;
  border:1px solid rgba(0,217,237,.22)!important;
}
html[data-theme="modern"] .structure-panel .panel-head small{color:#7b8b98!important}
html[data-theme="fantasy"] .structure-panel .panel-head small{color:#a28a69!important}
html[data-theme="thriller"] .structure-panel .panel-head small{color:#8f8187!important}
html[data-theme="cyberpunk"] .structure-panel .panel-head small{color:#7bcfe0!important}
html[data-theme="modern"] .structure-panel .panel-head h3{color:#24313b!important}
html[data-theme="fantasy"] .structure-panel .panel-head h3{color:#392d1f!important}
html[data-theme="thriller"] .structure-panel .panel-head h3{color:#282528!important}
html[data-theme="cyberpunk"] .structure-panel .panel-head h3{color:#e6fbff!important}

html[data-theme="modern"] .structure-actions .soft-btn{
  background:#ffffff!important;border-color:rgba(78,109,139,.14)!important;color:#33424f!important;
}
html[data-theme="fantasy"] .structure-actions .soft-btn{
  background:#f7efe0!important;border-color:rgba(165,131,81,.20)!important;color:#4a3c2b!important;
}
html[data-theme="thriller"] .structure-actions .soft-btn{
  background:#f4eeea!important;border-color:rgba(104,96,100,.16)!important;color:#413c40!important;
}
html[data-theme="cyberpunk"] .structure-actions .soft-btn{
  background:#13202c!important;border-color:rgba(0,217,237,.20)!important;color:#dff9fc!important;
}

html[data-theme="modern"] .tree-row{
  background:rgba(255,255,255,.66)!important;
  color:#33424f!important;
  border:1px solid rgba(78,109,139,.12)!important;
}
html[data-theme="fantasy"] .tree-row{
  background:rgba(249,241,225,.58)!important;
  color:#4a3c2b!important;
  border:1px solid rgba(165,131,81,.16)!important;
}
html[data-theme="thriller"] .tree-row{
  background:rgba(245,239,235,.58)!important;
  color:#413c40!important;
  border:1px solid rgba(104,96,100,.14)!important;
}
html[data-theme="cyberpunk"] .tree-row{
  background:linear-gradient(180deg,rgba(20,34,46,.96),rgba(15,26,37,.96))!important;
  color:#d8f8fb!important;
  border:1px solid rgba(0,217,237,.16)!important;
  box-shadow:inset 0 1px rgba(255,255,255,.02),0 0 0 1px rgba(243,79,201,.018)!important;
}
html[data-theme="modern"] .tree-row:hover{background:#f2f8fd!important;border-color:rgba(89,120,149,.18)!important}
html[data-theme="fantasy"] .tree-row:hover{background:#f4e7cf!important;border-color:rgba(174,141,90,.22)!important}
html[data-theme="thriller"] .tree-row:hover{background:#ede3df!important;border-color:rgba(126,104,111,.20)!important}
html[data-theme="cyberpunk"] .tree-row:hover{background:linear-gradient(180deg,rgba(22,40,54,.98),rgba(16,30,43,.98))!important;border-color:rgba(0,217,237,.22)!important}

html[data-theme="modern"] .tree-row.active{background:#eaf4fb!important;border-color:rgba(73,138,193,.28)!important;box-shadow:inset 2px 0 0 rgba(73,138,193,.72)!important}
html[data-theme="fantasy"] .tree-row.active{background:#e7dcc2!important;border-color:rgba(184,149,91,.30)!important;box-shadow:inset 2px 0 0 rgba(184,149,91,.76)!important}
html[data-theme="thriller"] .tree-row.active{background:#e7d9d7!important;border-color:rgba(165,88,99,.28)!important;box-shadow:inset 2px 0 0 rgba(165,88,99,.72)!important}
html[data-theme="cyberpunk"] .tree-row.active{background:linear-gradient(180deg,rgba(17,46,58,.98),rgba(14,33,47,.98))!important;border-color:rgba(0,217,237,.36)!important;box-shadow:inset 2px 0 0 rgba(0,217,237,.86),0 0 0 1px rgba(243,79,201,.05)!important}

html[data-theme="modern"] .tree-row.context-active{background:#f2f8fd!important}
html[data-theme="fantasy"] .tree-row.context-active{background:#f0e4cf!important}
html[data-theme="thriller"] .tree-row.context-active{background:#efe4e1!important}
html[data-theme="cyberpunk"] .tree-row.context-active{background:linear-gradient(180deg,rgba(18,38,52,.98),rgba(16,31,44,.98))!important}

html[data-theme="modern"] .tree-row :is(i,b,span,em),
html[data-theme="fantasy"] .tree-row :is(i,b,span,em),
html[data-theme="thriller"] .tree-row :is(i,b,span,em),
html[data-theme="cyberpunk"] .tree-row :is(i,b,span,em){color:inherit!important}

/* ==========================================================================
   SYLVA BETA 0.969 — THEME ROOT FIX
   Overrides the legacy Writer rules at their actual specificity.
   ========================================================================== */

/* ---------- Writer paper: override the legacy fixed beige boxes ---------- */
html[data-theme="modern"][data-route="writer"] #writerView:not(.review-mode) .multi-scene-editor[data-scene-divider="boxes"] .scene-sheet{
  background:radial-gradient(circle at 13% 9%,rgba(78,126,170,.050),transparent 19%),linear-gradient(180deg,#fbfdff 0%,#f5faff 58%,#eaf2fa 100%)!important;
  border-color:rgba(60,103,139,.14)!important;
  box-shadow:0 18px 50px rgba(48,75,98,.10),inset 0 1px rgba(255,255,255,.78)!important;
}
html[data-theme="fantasy"][data-route="writer"] #writerView:not(.review-mode) .multi-scene-editor[data-scene-divider="boxes"] .scene-sheet{
  background:radial-gradient(circle at 13% 9%,rgba(183,144,75,.085),transparent 20%),radial-gradient(circle at 90% 82%,rgba(102,132,72,.040),transparent 20%),linear-gradient(180deg,#f5ead4 0%,#eedfbe 58%,#dfccaa 100%)!important;
  border-color:rgba(157,119,61,.20)!important;
  box-shadow:0 20px 56px rgba(52,39,22,.15),inset 0 1px rgba(255,249,235,.72)!important;
}
html[data-theme="thriller"][data-route="writer"] #writerView:not(.review-mode) .multi-scene-editor[data-scene-divider="boxes"] .scene-sheet{
  background:radial-gradient(circle at 87% 10%,rgba(158,54,65,.070),transparent 19%),linear-gradient(180deg,#f3e9e9 0%,#ecdfdf 58%,#dfd1d2 100%)!important;
  border-color:rgba(125,77,84,.18)!important;
  box-shadow:0 20px 54px rgba(31,23,25,.13),inset 0 1px rgba(255,255,255,.68)!important;
}
html[data-theme="cyberpunk"][data-route="writer"] #writerView:not(.review-mode) .multi-scene-editor[data-scene-divider="boxes"] .scene-sheet{
  background:radial-gradient(circle at 11% 9%,rgba(0,185,220,.090),transparent 19%),radial-gradient(circle at 90% 11%,rgba(143,82,214,.060),transparent 16%),linear-gradient(180deg,#f0f9ff 0%,#e6f2fb 58%,#d9e8f5 100%)!important;
  border-color:rgba(0,149,184,.20)!important;
  box-shadow:0 20px 58px rgba(0,20,30,.20),0 0 0 1px rgba(137,74,207,.035),inset 0 1px rgba(255,255,255,.70)!important;
}
html[data-theme="modern"][data-route="writer"] #writerView:not(.review-mode) .multi-scene-editor[data-scene-divider="boxes"] .scene-editor{color:#22313c!important;caret-color:#3f6386!important}
html[data-theme="fantasy"][data-route="writer"] #writerView:not(.review-mode) .multi-scene-editor[data-scene-divider="boxes"] .scene-editor{color:#392d20!important;caret-color:#8b6c36!important}
html[data-theme="thriller"][data-route="writer"] #writerView:not(.review-mode) .multi-scene-editor[data-scene-divider="boxes"] .scene-editor{color:#2b2528!important;caret-color:#a33f4b!important}
html[data-theme="cyberpunk"][data-route="writer"] #writerView:not(.review-mode) .multi-scene-editor[data-scene-divider="boxes"] .scene-editor{color:#183640!important;caret-color:#008fa8!important}
html[data-theme="modern"][data-route="writer"] #writerView:not(.review-mode) .multi-scene-editor[data-scene-divider="boxes"] .scene-label{color:#6c7f8e!important}
html[data-theme="fantasy"][data-route="writer"] #writerView:not(.review-mode) .multi-scene-editor[data-scene-divider="boxes"] .scene-label{color:#806e56!important}
html[data-theme="thriller"][data-route="writer"] #writerView:not(.review-mode) .multi-scene-editor[data-scene-divider="boxes"] .scene-label{color:#796b70!important}
html[data-theme="cyberpunk"][data-route="writer"] #writerView:not(.review-mode) .multi-scene-editor[data-scene-divider="boxes"] .scene-label{color:#65818d!important}

/* Theme the continuous Writer modes too: the sheet is transparent by design,
   therefore the stage itself becomes the readable themed paper field. */
html[data-theme="modern"][data-route="writer"] #writerView:not(.review-mode) .editor-viewport{background:linear-gradient(180deg,#eef4fa,#e7eff7)!important}
html[data-theme="fantasy"][data-route="writer"] #writerView:not(.review-mode) .editor-viewport{background:linear-gradient(180deg,#e9dcc2,#dcc9a7)!important}
html[data-theme="thriller"][data-route="writer"] #writerView:not(.review-mode) .editor-viewport{background:linear-gradient(180deg,#e9dede,#d9cbcd)!important}
html[data-theme="cyberpunk"][data-route="writer"] #writerView:not(.review-mode) .editor-viewport{background:radial-gradient(circle at 90% 8%,rgba(133,78,200,.05),transparent 20%),linear-gradient(180deg,#e5f1fa,#d8e8f3)!important}

/* ---------- Structure navigator: beat the old hard-coded beige/green block ---------- */
html[data-theme="modern"][data-route="writer"] #writerView:not(.review-mode) .structure-panel{
  background:linear-gradient(180deg,#edf4fa 0%,#e6eff7 100%)!important;
  color:#263640!important;border-right-color:rgba(56,101,138,.18)!important;
  scrollbar-color:rgba(63,99,134,.32) transparent!important;
}
html[data-theme="fantasy"][data-route="writer"] #writerView:not(.review-mode) .structure-panel{
  background:linear-gradient(180deg,#dac9a9 0%,#cdb993 100%)!important;
  color:#3c3022!important;border-right-color:rgba(127,91,47,.24)!important;
  scrollbar-color:rgba(142,105,54,.38) transparent!important;
}
html[data-theme="thriller"][data-route="writer"] #writerView:not(.review-mode) .structure-panel{
  background:linear-gradient(180deg,#ddcfd0 0%,#cfbec1 100%)!important;
  color:#30272b!important;border-right-color:rgba(128,65,74,.22)!important;
  scrollbar-color:rgba(164,65,78,.34) transparent!important;
}
html[data-theme="cyberpunk"][data-route="writer"] #writerView:not(.review-mode) .structure-panel{
  background:linear-gradient(rgba(0,217,237,.025) 1px,transparent 1px),linear-gradient(90deg,rgba(0,217,237,.025) 1px,transparent 1px),linear-gradient(180deg,#0a1924 0%,#0d2230 100%)!important;
  background-size:28px 28px,28px 28px,auto!important;
  color:#ddf8fb!important;border-right-color:rgba(0,217,237,.24)!important;
  scrollbar-color:rgba(0,217,237,.36) transparent!important;
}

html[data-theme="modern"][data-route="writer"] #writerView:not(.review-mode) .structure-sticky-tools{background:linear-gradient(180deg,rgba(237,244,250,.995),rgba(232,241,248,.97))!important;border-bottom-color:rgba(56,101,138,.16)!important}
html[data-theme="fantasy"][data-route="writer"] #writerView:not(.review-mode) .structure-sticky-tools{background:linear-gradient(180deg,rgba(218,201,169,.995),rgba(210,191,154,.97))!important;border-bottom-color:rgba(127,91,47,.22)!important}
html[data-theme="thriller"][data-route="writer"] #writerView:not(.review-mode) .structure-sticky-tools{background:linear-gradient(180deg,rgba(221,207,208,.995),rgba(213,197,199,.97))!important;border-bottom-color:rgba(128,65,74,.20)!important}
html[data-theme="cyberpunk"][data-route="writer"] #writerView:not(.review-mode) .structure-sticky-tools{background:linear-gradient(180deg,rgba(9,24,34,.995),rgba(11,31,43,.97))!important;border-bottom-color:rgba(0,217,237,.21)!important}

html[data-theme="modern"][data-route="writer"] #writerView:not(.review-mode) .structure-panel .panel-head h2{color:#263640!important}
html[data-theme="fantasy"][data-route="writer"] #writerView:not(.review-mode) .structure-panel .panel-head h2{color:#3c3022!important}
html[data-theme="thriller"][data-route="writer"] #writerView:not(.review-mode) .structure-panel .panel-head h2{color:#30272b!important}
html[data-theme="cyberpunk"][data-route="writer"] #writerView:not(.review-mode) .structure-panel .panel-head h2{color:#e4fbff!important}
html[data-theme="modern"][data-route="writer"] #writerView:not(.review-mode) .structure-panel .panel-head small{color:#66869f!important}
html[data-theme="fantasy"][data-route="writer"] #writerView:not(.review-mode) .structure-panel .panel-head small{color:#876b43!important}
html[data-theme="thriller"][data-route="writer"] #writerView:not(.review-mode) .structure-panel .panel-head small{color:#915963!important}
html[data-theme="cyberpunk"][data-route="writer"] #writerView:not(.review-mode) .structure-panel .panel-head small{color:#57ccde!important}

html[data-theme="modern"][data-route="writer"] #writerView:not(.review-mode) .structure-panel .structure-actions .mini-btn,
html[data-theme="modern"][data-route="writer"] #writerView:not(.review-mode) .structure-panel #structureCollapse{background:rgba(255,255,255,.68)!important;border-color:rgba(56,101,138,.16)!important;color:#385164!important}
html[data-theme="fantasy"][data-route="writer"] #writerView:not(.review-mode) .structure-panel .structure-actions .mini-btn,
html[data-theme="fantasy"][data-route="writer"] #writerView:not(.review-mode) .structure-panel #structureCollapse{background:rgba(244,232,208,.58)!important;border-color:rgba(127,91,47,.21)!important;color:#52412b!important}
html[data-theme="thriller"][data-route="writer"] #writerView:not(.review-mode) .structure-panel .structure-actions .mini-btn,
html[data-theme="thriller"][data-route="writer"] #writerView:not(.review-mode) .structure-panel #structureCollapse{background:rgba(245,233,233,.58)!important;border-color:rgba(128,65,74,.19)!important;color:#4c353b!important}
html[data-theme="cyberpunk"][data-route="writer"] #writerView:not(.review-mode) .structure-panel .structure-actions .mini-btn,
html[data-theme="cyberpunk"][data-route="writer"] #writerView:not(.review-mode) .structure-panel #structureCollapse{background:rgba(15,43,57,.82)!important;border-color:rgba(0,217,237,.22)!important;color:#d8f8fb!important}

html[data-theme="modern"][data-route="writer"] #writerView:not(.review-mode) .structure-panel .tree-row{background:rgba(255,255,255,.42)!important;color:#304653!important;border:1px solid rgba(56,101,138,.10)!important}
html[data-theme="fantasy"][data-route="writer"] #writerView:not(.review-mode) .structure-panel .tree-row{background:rgba(244,232,208,.32)!important;color:#493a27!important;border:1px solid rgba(127,91,47,.12)!important}
html[data-theme="thriller"][data-route="writer"] #writerView:not(.review-mode) .structure-panel .tree-row{background:rgba(245,233,233,.31)!important;color:#49343a!important;border:1px solid rgba(128,65,74,.11)!important}
html[data-theme="cyberpunk"][data-route="writer"] #writerView:not(.review-mode) .structure-panel .tree-row{background:rgba(14,39,53,.80)!important;color:#d9f7fb!important;border:1px solid rgba(0,217,237,.13)!important}
html[data-theme="modern"][data-route="writer"] #writerView:not(.review-mode) .structure-panel .tree-row:hover{background:rgba(255,255,255,.68)!important}
html[data-theme="fantasy"][data-route="writer"] #writerView:not(.review-mode) .structure-panel .tree-row:hover{background:rgba(247,235,209,.50)!important}
html[data-theme="thriller"][data-route="writer"] #writerView:not(.review-mode) .structure-panel .tree-row:hover{background:rgba(248,235,236,.48)!important}
html[data-theme="cyberpunk"][data-route="writer"] #writerView:not(.review-mode) .structure-panel .tree-row:hover{background:rgba(15,49,65,.92)!important}
html[data-theme="modern"][data-route="writer"] #writerView:not(.review-mode) .structure-panel .tree-row.active{background:#d8eaf7!important;color:#244657!important;box-shadow:inset 3px 0 0 #4e8db6!important;border-color:rgba(78,141,182,.26)!important}
html[data-theme="fantasy"][data-route="writer"] #writerView:not(.review-mode) .structure-panel .tree-row.active{background:#e8d9b9!important;color:#42311d!important;box-shadow:inset 3px 0 0 #a57a3c!important;border-color:rgba(165,122,60,.30)!important}
html[data-theme="thriller"][data-route="writer"] #writerView:not(.review-mode) .structure-panel .tree-row.active{background:#e5cfd2!important;color:#492b31!important;box-shadow:inset 3px 0 0 #a84956!important;border-color:rgba(168,73,86,.28)!important}
html[data-theme="cyberpunk"][data-route="writer"] #writerView:not(.review-mode) .structure-panel .tree-row.active{background:linear-gradient(90deg,rgba(0,217,237,.16),rgba(21,52,68,.94))!important;color:#effdff!important;box-shadow:inset 3px 0 0 #00d9ed,0 0 0 1px rgba(190,90,238,.05)!important;border-color:rgba(0,217,237,.34)!important}

/* Legacy tree-kind and menu were hardcoded green: theme them explicitly. */








html[data-theme="cyberpunk"][data-route="writer"] #writerView:not(.review-mode) .structure-panel .tree-row:focus-within .tree-menu{background:rgba(0,217,237,.08)!important;color:#dffbff!important}
html[data-theme="fantasy"][data-route="writer"] #writerView:not(.review-mode) .structure-panel .tree-row:focus-within .tree-menu{background:rgba(151,112,55,.10)!important;color:#5c452a!important}
html[data-theme="thriller"][data-route="writer"] #writerView:not(.review-mode) .structure-panel .tree-row:focus-within .tree-menu{background:rgba(167,67,81,.08)!important;color:#713942!important}
html[data-theme="modern"][data-route="writer"] #writerView:not(.review-mode) .structure-panel .tree-row:focus-within .tree-menu{background:rgba(63,99,134,.08)!important;color:#3e5e76!important}

/* Re-open handle follows the theme as well. */
html[data-theme="modern"][data-route="writer"] #writerView:not(.review-mode) #structureHandle{background:#e7f0f7!important;color:#3e5f76!important;border-color:rgba(56,101,138,.17)!important}
html[data-theme="fantasy"][data-route="writer"] #writerView:not(.review-mode) #structureHandle{background:#d7c5a3!important;color:#55412a!important;border-color:rgba(127,91,47,.23)!important}
html[data-theme="thriller"][data-route="writer"] #writerView:not(.review-mode) #structureHandle{background:#d8c8ca!important;color:#5d3840!important;border-color:rgba(128,65,74,.22)!important}
html[data-theme="cyberpunk"][data-route="writer"] #writerView:not(.review-mode) #structureHandle{background:#0b2230!important;color:#8be9f4!important;border-color:rgba(0,217,237,.25)!important;box-shadow:6px 8px 24px rgba(0,0,0,.28),0 0 0 1px rgba(190,90,238,.035)!important}

/* ---------- Login centering: tablet centred, phone scroll-safe ---------- */
@media (min-width:561px) and (max-width:900px){
  .entry-gate{display:grid!important;place-items:center!important;overflow:auto!important;min-height:100dvh!important}
  .entry-shell{width:min(760px,calc(100vw - 34px))!important;min-height:auto!important;max-height:calc(100dvh - 28px)!important;margin:auto!important;padding:30px 24px!important;overflow:auto!important;align-self:center!important}
}
@media (min-width:901px){
  .entry-gate{display:grid!important;place-items:center!important;min-height:100dvh!important}
  .entry-shell{margin:auto!important;align-self:center!important}
}
@media (max-width:560px){
  .entry-gate{display:block!important;overflow:auto!important}
  .entry-shell{min-height:100dvh!important;margin:0 auto!important;padding-top:max(30px,env(safe-area-inset-top))!important;padding-bottom:max(26px,env(safe-area-inset-bottom))!important}
}

/* ==========================================================================
   SYLVA BETA 0.971 — THEME RECOVERY
   Data-theme is again the only theme state. Sylva base themes are untouched.
   Narrative themes: dark/distinct environment + restrained readable paper.
   ========================================================================== */

/* Restrained manuscript paper. Tint is intentionally subtle. */
html[data-theme="modern"]{
  --theme-paper:#fbfcfd;--theme-paper-ink:#202b34;--theme-paper-muted:#6d7983;
  --theme-paper-page:linear-gradient(180deg,#fdfefe 0%,#fafcfe 60%,#f4f7fa 100%);
}
html[data-theme="fantasy"]{
  --theme-paper:#f5f0e6;--theme-paper-ink:#312b23;--theme-paper-muted:#756d61;
  --theme-paper-page:radial-gradient(circle at 12% 9%,rgba(166,128,68,.025),transparent 18%),linear-gradient(180deg,#f8f4ec 0%,#f4eee3 60%,#ece3d4 100%);
}
html[data-theme="thriller"]{
  --theme-paper:#f4f1f1;--theme-paper-ink:#292629;--theme-paper-muted:#777176;
  --theme-paper-page:radial-gradient(circle at 88% 10%,rgba(150,55,67,.018),transparent 18%),linear-gradient(180deg,#f7f4f4 0%,#f2eeee 60%,#e9e3e4 100%);
}
html[data-theme="cyberpunk"]{
  --theme-paper:#f1f6f8;--theme-paper-ink:#20343b;--theme-paper-muted:#687c83;
  --theme-paper-page:radial-gradient(circle at 11% 9%,rgba(0,173,199,.025),transparent 17%),radial-gradient(circle at 90% 10%,rgba(133,88,190,.018),transparent 15%),linear-gradient(180deg,#f7fafb 0%,#f1f6f8 60%,#e7eef1 100%);
}

/* Writer environment and paper are intentionally different layers. */
html[data-theme="modern"][data-route="writer"] #writerView:not(.review-mode) :is(.main-area,.editor-stage,.editor-viewport){background:linear-gradient(145deg,#e3e9ef,#dbe3ea 60%,#e5ebf1)!important}
html[data-theme="fantasy"][data-route="writer"] #writerView:not(.review-mode) :is(.main-area,.editor-stage,.editor-viewport){background:radial-gradient(circle at 12% 7%,rgba(193,154,85,.08),transparent 24%),linear-gradient(145deg,#171812,#201e15 58%,#151710)!important}
html[data-theme="thriller"][data-route="writer"] #writerView:not(.review-mode) :is(.main-area,.editor-stage,.editor-viewport){background:radial-gradient(circle at 88% 8%,rgba(179,62,70,.065),transparent 22%),linear-gradient(145deg,#101214,#191b1e 58%,#101214)!important}
html[data-theme="cyberpunk"][data-route="writer"] #writerView:not(.review-mode) :is(.main-area,.editor-stage,.editor-viewport){background:linear-gradient(rgba(0,217,237,.022) 1px,transparent 1px),linear-gradient(90deg,rgba(0,217,237,.022) 1px,transparent 1px),radial-gradient(circle at 12% 7%,rgba(0,217,237,.07),transparent 22%),radial-gradient(circle at 88% 12%,rgba(243,79,201,.05),transparent 20%),linear-gradient(145deg,#05090f,#0a1119 58%,#060a10)!important;background-size:30px 30px,30px 30px,auto,auto,auto!important}

html[data-theme="modern"][data-route="writer"] #writerView:not(.review-mode) .multi-scene-editor[data-scene-divider="boxes"] .scene-sheet,
html[data-theme="fantasy"][data-route="writer"] #writerView:not(.review-mode) .multi-scene-editor[data-scene-divider="boxes"] .scene-sheet,
html[data-theme="thriller"][data-route="writer"] #writerView:not(.review-mode) .multi-scene-editor[data-scene-divider="boxes"] .scene-sheet,
html[data-theme="cyberpunk"][data-route="writer"] #writerView:not(.review-mode) .multi-scene-editor[data-scene-divider="boxes"] .scene-sheet{
  background:var(--theme-paper-page)!important;color:var(--theme-paper-ink)!important;
  border:1px solid color-mix(in srgb,var(--theme-paper-ink) 10%,transparent)!important;
  box-shadow:0 20px 58px rgba(0,0,0,.16),inset 0 1px rgba(255,255,255,.52)!important;
}
html[data-theme="modern"][data-route="writer"] #writerView:not(.review-mode) .scene-editor,
html[data-theme="fantasy"][data-route="writer"] #writerView:not(.review-mode) .scene-editor,
html[data-theme="thriller"][data-route="writer"] #writerView:not(.review-mode) .scene-editor,
html[data-theme="cyberpunk"][data-route="writer"] #writerView:not(.review-mode) .scene-editor{color:var(--theme-paper-ink)!important;text-shadow:none!important}
html[data-theme="modern"][data-route="writer"] #writerView:not(.review-mode) .scene-label,
html[data-theme="fantasy"][data-route="writer"] #writerView:not(.review-mode) .scene-label,
html[data-theme="thriller"][data-route="writer"] #writerView:not(.review-mode) .scene-label,
html[data-theme="cyberpunk"][data-route="writer"] #writerView:not(.review-mode) .scene-label{color:var(--theme-paper-muted)!important}

/* Reader environment remains separate from the paper as well. */
html[data-theme="modern"] :is(.reader-view,.reader-viewport,.reader-book-view){background:linear-gradient(145deg,#e3e9ef,#dbe3ea 60%,#e5ebf1)!important}
html[data-theme="fantasy"] :is(.reader-view,.reader-viewport,.reader-book-view){background:linear-gradient(145deg,#151711,#1e1d14 60%,#141610)!important}
html[data-theme="thriller"] :is(.reader-view,.reader-viewport,.reader-book-view){background:linear-gradient(145deg,#0f1113,#181a1d 60%,#101214)!important}
html[data-theme="cyberpunk"] :is(.reader-view,.reader-viewport,.reader-book-view){background:linear-gradient(rgba(0,217,237,.018) 1px,transparent 1px),linear-gradient(90deg,rgba(0,217,237,.018) 1px,transparent 1px),linear-gradient(145deg,#05090f,#09111a 60%,#060a10)!important;background-size:30px 30px,30px 30px,auto!important}
html[data-theme="modern"] :is(.reader-document,.reader-book-page,.reader-book-turn-front,.reader-book-turn-back),
html[data-theme="fantasy"] :is(.reader-document,.reader-book-page,.reader-book-turn-front,.reader-book-turn-back),
html[data-theme="thriller"] :is(.reader-document,.reader-book-page,.reader-book-turn-front,.reader-book-turn-back),
html[data-theme="cyberpunk"] :is(.reader-document,.reader-book-page,.reader-book-turn-front,.reader-book-turn-back){background:var(--theme-paper-page)!important;color:var(--theme-paper-ink)!important;border-color:color-mix(in srgb,var(--theme-paper-ink) 11%,transparent)!important}
html[data-theme="modern"] :is(.reader-editor,.reader-book-copy,.reader-book-heading b,.reader-separator h2),
html[data-theme="fantasy"] :is(.reader-editor,.reader-book-copy,.reader-book-heading b,.reader-separator h2),
html[data-theme="thriller"] :is(.reader-editor,.reader-book-copy,.reader-book-heading b,.reader-separator h2),
html[data-theme="cyberpunk"] :is(.reader-editor,.reader-book-copy,.reader-book-heading b,.reader-separator h2){color:var(--theme-paper-ink)!important;text-shadow:none!important}

/* Structure panel stays unmistakably part of the environment, not part of paper. */
html[data-theme="modern"][data-route="writer"] #writerView:not(.review-mode) .structure-panel{background:linear-gradient(180deg,#e7edf3,#dce5ed)!important;color:#273743!important;border-right-color:rgba(63,99,134,.18)!important}
html[data-theme="fantasy"][data-route="writer"] #writerView:not(.review-mode) .structure-panel{background:linear-gradient(180deg,#302b20,#3b3324 58%,#29251b)!important;color:#eee2cb!important;border-right-color:rgba(193,154,85,.22)!important}
html[data-theme="thriller"][data-route="writer"] #writerView:not(.review-mode) .structure-panel{background:linear-gradient(180deg,#282124,#34262b 58%,#211c1f)!important;color:#eee5e7!important;border-right-color:rgba(217,101,106,.20)!important}
html[data-theme="cyberpunk"][data-route="writer"] #writerView:not(.review-mode) .structure-panel{background:linear-gradient(rgba(0,217,237,.025) 1px,transparent 1px),linear-gradient(90deg,rgba(0,217,237,.025) 1px,transparent 1px),linear-gradient(180deg,#08131d,#0d1b27)!important;background-size:28px 28px,28px 28px,auto!important;color:#ddf8fb!important;border-right-color:rgba(0,217,237,.22)!important}
html[data-theme="fantasy"][data-route="writer"] #writerView:not(.review-mode) .structure-sticky-tools{background:linear-gradient(to bottom,#302b20 0%,rgba(48,43,32,.98) 82%,rgba(48,43,32,.90) 100%)!important}
html[data-theme="thriller"][data-route="writer"] #writerView:not(.review-mode) .structure-sticky-tools{background:linear-gradient(to bottom,#282124 0%,rgba(40,33,36,.98) 82%,rgba(40,33,36,.90) 100%)!important}
html[data-theme="cyberpunk"][data-route="writer"] #writerView:not(.review-mode) .structure-sticky-tools{background:linear-gradient(to bottom,#08131d 0%,rgba(8,19,29,.98) 82%,rgba(8,19,29,.90) 100%)!important}

html[data-theme="fantasy"][data-route="writer"] #writerView:not(.review-mode) .structure-panel .tree-row{background:#423927!important;color:#eee1c7!important;border-color:rgba(193,154,85,.14)!important}
html[data-theme="thriller"][data-route="writer"] #writerView:not(.review-mode) .structure-panel .tree-row{background:#392a2f!important;color:#eee4e6!important;border-color:rgba(217,101,106,.13)!important}
html[data-theme="cyberpunk"][data-route="writer"] #writerView:not(.review-mode) .structure-panel .tree-row{background:#102432!important;color:#dcf8fb!important;border-color:rgba(0,217,237,.15)!important}
html[data-theme="fantasy"][data-route="writer"] #writerView:not(.review-mode) .structure-panel .tree-row.active{background:linear-gradient(90deg,#65502e,#51452e)!important;color:#fff4dc!important;box-shadow:inset 3px 0 0 #c19a55!important;border-color:rgba(193,154,85,.34)!important}
html[data-theme="thriller"][data-route="writer"] #writerView:not(.review-mode) .structure-panel .tree-row.active{background:linear-gradient(90deg,#59323a,#453037)!important;color:#fff1f2!important;box-shadow:inset 3px 0 0 #d9656a!important;border-color:rgba(217,101,106,.32)!important}
html[data-theme="cyberpunk"][data-route="writer"] #writerView:not(.review-mode) .structure-panel .tree-row.active{background:linear-gradient(90deg,#123b49,#12303e)!important;color:#effdff!important;box-shadow:inset 3px 0 0 #00d9ed!important;border-color:rgba(0,217,237,.36)!important}

/* Tablet login stays centred. Phone remains scroll-safe. */
@media (min-width:561px) and (max-width:900px){
  .entry-gate{display:grid!important;place-items:center!important;overflow:auto!important;min-height:100dvh!important}
  .entry-shell{width:min(760px,calc(100vw - 34px))!important;min-height:auto!important;max-height:calc(100dvh - 28px)!important;margin:auto!important;padding:30px 24px!important;overflow:auto!important;align-self:center!important}
}
@media (min-width:901px){.entry-gate{display:grid!important;place-items:center!important;min-height:100dvh!important}.entry-shell{margin:auto!important;align-self:center!important}}
@media (max-width:560px){.entry-gate{display:block!important;overflow:auto!important}.entry-shell{min-height:100dvh!important;margin:0 auto!important;padding-top:max(30px,env(safe-area-inset-top))!important;padding-bottom:max(26px,env(safe-area-inset-bottom))!important}}

/* ==========================================================================
   SYLVA BETA 0.973 — ENTRY GATE ROOT FIX
   The light Sylva theme had a legacy rule that changed .entry-gate from fixed
   to relative. Combined with responsive display:grid!important, the hidden
   gate still occupied 100dvh after login and pushed #app below the viewport.
   ========================================================================== */
html[data-theme="sylva"] .entry-gate,
html[data-theme="sylva-dark"] .entry-gate,
html[data-theme="modern"] .entry-gate,
html[data-theme="fantasy"] .entry-gate,
html[data-theme="thriller"] .entry-gate,
html[data-theme="cyberpunk"] .entry-gate{
  position:fixed!important;
  inset:0!important;
}
.entry-gate.hidden-gate{
  display:none!important;
  position:fixed!important;
  inset:0!important;
}

/* ==========================================================================
   SYLVA BETA 0.974 — THEME TYPOGRAPHY SYSTEM
   UI follows the active theme; Writer keeps the user's font; Reader content
   uses a neutral editorial face for consistent legibility.
   ========================================================================== */
html[data-theme="sylva"],html[data-theme="sylva-dark"]{
  --theme-ui:"Instrument Sans","Segoe UI",Arial,system-ui,sans-serif;
  --theme-display:"Cormorant Garamond",Georgia,"Times New Roman",serif;
  --theme-label:"Instrument Sans","Segoe UI",Arial,system-ui,sans-serif;
  --theme-mono:"IBM Plex Mono",Consolas,"Courier New",monospace;
  --reading-font:"Source Serif 4","Merriweather",Georgia,"Times New Roman",serif;
}
html[data-theme="modern"]{
  --theme-ui:"Instrument Sans","Segoe UI",Arial,system-ui,sans-serif;
  --theme-display:"Source Serif 4",Georgia,"Times New Roman",serif;
  --theme-label:"Instrument Sans","Segoe UI",Arial,system-ui,sans-serif;
  --theme-mono:"IBM Plex Mono",Consolas,"Courier New",monospace;
  --reading-font:"Source Serif 4","Merriweather",Georgia,"Times New Roman",serif;
}
html[data-theme="fantasy"]{
  --theme-ui:"Source Sans 3","Trebuchet MS","Segoe UI",system-ui,sans-serif;
  --theme-display:Cinzel,"Palatino Linotype",Georgia,serif;
  --theme-label:"Source Sans 3","Trebuchet MS","Segoe UI",system-ui,sans-serif;
  --theme-mono:"IBM Plex Mono",Consolas,"Courier New",monospace;
  --reading-font:"Source Serif 4","Merriweather",Georgia,"Times New Roman",serif;
}
html[data-theme="thriller"]{
  --theme-ui:"IBM Plex Sans","Segoe UI",Arial,system-ui,sans-serif;
  --theme-display:"Libre Baskerville",Georgia,"Times New Roman",serif;
  --theme-label:"IBM Plex Mono",Consolas,"Courier New",monospace;
  --theme-mono:"IBM Plex Mono",Consolas,"Courier New",monospace;
  --reading-font:"Source Serif 4","Merriweather",Georgia,"Times New Roman",serif;
}
html[data-theme="cyberpunk"]{
  --theme-ui:Rajdhani,"Arial Narrow","Segoe UI",Arial,sans-serif;
  --theme-display:Orbitron,"Arial Black","Segoe UI",sans-serif;
  --theme-label:"IBM Plex Mono",Consolas,"Courier New",monospace;
  --theme-mono:"IBM Plex Mono",Consolas,"Courier New",monospace;
  --reading-font:"Source Serif 4","Merriweather",Georgia,"Times New Roman",serif;
}

/* Whole UI: this intentionally beats the many legacy Inter/Georgia shorthands. */
html[data-theme="sylva"] body *,html[data-theme="sylva-dark"] body *,html[data-theme="modern"] body *,html[data-theme="fantasy"] body *,html[data-theme="thriller"] body *,html[data-theme="cyberpunk"] body *{font-family:var(--theme-ui)!important}

/* Major headings carry the identity. */
html[data-theme="sylva"] :is(.view-heading h1,.view-heading h2,.panel-head h2,.panel-head h3,.home-hero h1,.home-section-head h2,.home-shelf-head h2,.book-card-title-row h3,.sylva-saga-card h3,.modal h2,.modal h3,.entry-brand-block h1,.entry-main-title,.legal-hero h1,.legal-section h2,.legal-section h3,.planning-block-head h2,.planning-block-head h3,.relationship-page-section-head h2,.relationship-page-section-head h3,.calendar-section-head h2,.calendar-section-head h3,.timeline-section-head h2,.timeline-section-head h3,.epub-heading h1,.epub-preview-head h2),
html[data-theme="sylva-dark"] :is(.view-heading h1,.view-heading h2,.panel-head h2,.panel-head h3,.home-hero h1,.home-section-head h2,.home-shelf-head h2,.book-card-title-row h3,.sylva-saga-card h3,.modal h2,.modal h3,.entry-brand-block h1,.entry-main-title,.legal-hero h1,.legal-section h2,.legal-section h3,.planning-block-head h2,.planning-block-head h3,.relationship-page-section-head h2,.relationship-page-section-head h3,.calendar-section-head h2,.calendar-section-head h3,.timeline-section-head h2,.timeline-section-head h3,.epub-heading h1,.epub-preview-head h2),
html[data-theme="modern"] :is(.view-heading h1,.view-heading h2,.panel-head h2,.panel-head h3,.home-hero h1,.home-section-head h2,.home-shelf-head h2,.book-card-title-row h3,.sylva-saga-card h3,.modal h2,.modal h3,.entry-brand-block h1,.entry-main-title,.legal-hero h1,.legal-section h2,.legal-section h3,.planning-block-head h2,.planning-block-head h3,.relationship-page-section-head h2,.relationship-page-section-head h3,.calendar-section-head h2,.calendar-section-head h3,.timeline-section-head h2,.timeline-section-head h3,.epub-heading h1,.epub-preview-head h2),
html[data-theme="fantasy"] :is(.view-heading h1,.view-heading h2,.panel-head h2,.panel-head h3,.home-hero h1,.home-section-head h2,.home-shelf-head h2,.book-card-title-row h3,.sylva-saga-card h3,.modal h2,.modal h3,.entry-brand-block h1,.entry-main-title,.legal-hero h1,.legal-section h2,.legal-section h3,.planning-block-head h2,.planning-block-head h3,.relationship-page-section-head h2,.relationship-page-section-head h3,.calendar-section-head h2,.calendar-section-head h3,.timeline-section-head h2,.timeline-section-head h3,.epub-heading h1,.epub-preview-head h2),
html[data-theme="thriller"] :is(.view-heading h1,.view-heading h2,.panel-head h2,.panel-head h3,.home-hero h1,.home-section-head h2,.home-shelf-head h2,.book-card-title-row h3,.sylva-saga-card h3,.modal h2,.modal h3,.entry-brand-block h1,.entry-main-title,.legal-hero h1,.legal-section h2,.legal-section h3,.planning-block-head h2,.planning-block-head h3,.relationship-page-section-head h2,.relationship-page-section-head h3,.calendar-section-head h2,.calendar-section-head h3,.timeline-section-head h2,.timeline-section-head h3,.epub-heading h1,.epub-preview-head h2),
html[data-theme="cyberpunk"] :is(.view-heading h1,.view-heading h2,.panel-head h2,.panel-head h3,.home-hero h1,.home-section-head h2,.home-shelf-head h2,.book-card-title-row h3,.sylva-saga-card h3,.modal h2,.modal h3,.entry-brand-block h1,.entry-main-title,.legal-hero h1,.legal-section h2,.legal-section h3,.planning-block-head h2,.planning-block-head h3,.relationship-page-section-head h2,.relationship-page-section-head h3,.calendar-section-head h2,.calendar-section-head h3,.timeline-section-head h2,.timeline-section-head h3,.epub-heading h1,.epub-preview-head h2){font-family:var(--theme-display)!important}

/* Technical microcopy can be more distinctive without harming long copy. */
html[data-theme="sylva"] :is(.entry-kicker,.entry-beta-label,.theme-exclusive-label,.view-heading>small,.panel-head>small,.planning-block-head>small,.relationship-page-section-head>small,.calendar-section-head>small,.timeline-section-head>small,.codex-world-head>small,.epub-section-head>small,.epub-subhead,.legal-version,.legal-law-badge,.scene-label),
html[data-theme="sylva-dark"] :is(.entry-kicker,.entry-beta-label,.theme-exclusive-label,.view-heading>small,.panel-head>small,.planning-block-head>small,.relationship-page-section-head>small,.calendar-section-head>small,.timeline-section-head>small,.codex-world-head>small,.epub-section-head>small,.epub-subhead,.legal-version,.legal-law-badge,.scene-label),
html[data-theme="modern"] :is(.entry-kicker,.entry-beta-label,.theme-exclusive-label,.view-heading>small,.panel-head>small,.planning-block-head>small,.relationship-page-section-head>small,.calendar-section-head>small,.timeline-section-head>small,.codex-world-head>small,.epub-section-head>small,.epub-subhead,.legal-version,.legal-law-badge,.scene-label),
html[data-theme="fantasy"] :is(.entry-kicker,.entry-beta-label,.theme-exclusive-label,.view-heading>small,.panel-head>small,.planning-block-head>small,.relationship-page-section-head>small,.calendar-section-head>small,.timeline-section-head>small,.codex-world-head>small,.epub-section-head>small,.epub-subhead,.legal-version,.legal-law-badge,.scene-label),
html[data-theme="thriller"] :is(.entry-kicker,.entry-beta-label,.theme-exclusive-label,.view-heading>small,.panel-head>small,.planning-block-head>small,.relationship-page-section-head>small,.calendar-section-head>small,.timeline-section-head>small,.codex-world-head>small,.epub-section-head>small,.epub-subhead,.legal-version,.legal-law-badge,.scene-label),
html[data-theme="cyberpunk"] :is(.entry-kicker,.entry-beta-label,.theme-exclusive-label,.view-heading>small,.panel-head>small,.planning-block-head>small,.relationship-page-section-head>small,.calendar-section-head>small,.timeline-section-head>small,.codex-world-head>small,.epub-section-head>small,.epub-subhead,.legal-version,.legal-law-badge,.scene-label){font-family:var(--theme-label)!important}

/* SVG graphs/map labels had explicit Inter declarations. */
html[data-theme="sylva"] :is(.chart-grid text,.sylva-map-view svg text),html[data-theme="sylva-dark"] :is(.chart-grid text,.sylva-map-view svg text),html[data-theme="modern"] :is(.chart-grid text,.sylva-map-view svg text),html[data-theme="fantasy"] :is(.chart-grid text,.sylva-map-view svg text),html[data-theme="thriller"] :is(.chart-grid text,.sylva-map-view svg text),html[data-theme="cyberpunk"] :is(.chart-grid text,.sylva-map-view svg text){font-family:var(--theme-ui)!important}
html[data-theme="sylva"] :is(code,pre,kbd,.diagnostic-code),html[data-theme="sylva-dark"] :is(code,pre,kbd,.diagnostic-code),html[data-theme="modern"] :is(code,pre,kbd,.diagnostic-code),html[data-theme="fantasy"] :is(code,pre,kbd,.diagnostic-code),html[data-theme="thriller"] :is(code,pre,kbd,.diagnostic-code),html[data-theme="cyberpunk"] :is(code,pre,kbd,.diagnostic-code){font-family:var(--theme-mono)!important}

/* Semantic font exceptions. */
html[data-theme="sylva"] .sylva-wordmark,html[data-theme="sylva-dark"] .sylva-wordmark,html[data-theme="modern"] .sylva-wordmark,html[data-theme="fantasy"] .sylva-wordmark,html[data-theme="thriller"] .sylva-wordmark,html[data-theme="cyberpunk"] .sylva-wordmark{font-family:"Allura",cursive!important}
html[data-theme="sylva"] .google-g,html[data-theme="sylva-dark"] .google-g,html[data-theme="modern"] .google-g,html[data-theme="fantasy"] .google-g,html[data-theme="thriller"] .google-g,html[data-theme="cyberpunk"] .google-g{font-family:Inter,"Segoe UI",system-ui,sans-serif!important}
html[data-theme="sylva"] .tool-emoji,html[data-theme="sylva-dark"] .tool-emoji,html[data-theme="modern"] .tool-emoji,html[data-theme="fantasy"] .tool-emoji,html[data-theme="thriller"] .tool-emoji,html[data-theme="cyberpunk"] .tool-emoji{font-family:"Segoe UI Emoji","Apple Color Emoji","Noto Color Emoji",system-ui,sans-serif!important}

/* Writer + revision: user's selected manuscript font always wins. */
html[data-theme="sylva"] :is(.scene-editor,.scene-editor *,.review-original-copy,.review-original-copy *,.review-scene-editor,.review-scene-editor *),html[data-theme="sylva-dark"] :is(.scene-editor,.scene-editor *,.review-original-copy,.review-original-copy *,.review-scene-editor,.review-scene-editor *),html[data-theme="modern"] :is(.scene-editor,.scene-editor *,.review-original-copy,.review-original-copy *,.review-scene-editor,.review-scene-editor *),html[data-theme="fantasy"] :is(.scene-editor,.scene-editor *,.review-original-copy,.review-original-copy *,.review-scene-editor,.review-scene-editor *),html[data-theme="thriller"] :is(.scene-editor,.scene-editor *,.review-original-copy,.review-original-copy *,.review-scene-editor,.review-scene-editor *),html[data-theme="cyberpunk"] :is(.scene-editor,.scene-editor *,.review-original-copy,.review-original-copy *,.review-scene-editor,.review-scene-editor *){font-family:var(--editor-font)!important}

/* Reader manuscript: theme-neutral, editorial and consistently legible. */
html[data-theme="sylva"] :is(.reader-editor,.reader-editor *,.reader-book-copy,.reader-book-copy *,.reader-separator h2,.reader-book-heading b),html[data-theme="sylva-dark"] :is(.reader-editor,.reader-editor *,.reader-book-copy,.reader-book-copy *,.reader-separator h2,.reader-book-heading b),html[data-theme="modern"] :is(.reader-editor,.reader-editor *,.reader-book-copy,.reader-book-copy *,.reader-separator h2,.reader-book-heading b),html[data-theme="fantasy"] :is(.reader-editor,.reader-editor *,.reader-book-copy,.reader-book-copy *,.reader-separator h2,.reader-book-heading b),html[data-theme="thriller"] :is(.reader-editor,.reader-editor *,.reader-book-copy,.reader-book-copy *,.reader-separator h2,.reader-book-heading b),html[data-theme="cyberpunk"] :is(.reader-editor,.reader-editor *,.reader-book-copy,.reader-book-copy *,.reader-separator h2,.reader-book-heading b){font-family:var(--reading-font)!important;font-kerning:normal;font-variant-ligatures:common-ligatures;text-rendering:optimizeLegibility}
/* Keep styled spans/emphasis inside themed headings on the heading face rather
   than falling back to the generic UI family set by the global catch-all. */
html[data-theme="sylva"] :is(h1,h2,h3,.entry-main-title) *,html[data-theme="sylva-dark"] :is(h1,h2,h3,.entry-main-title) *,html[data-theme="modern"] :is(h1,h2,h3,.entry-main-title) *,html[data-theme="fantasy"] :is(h1,h2,h3,.entry-main-title) *,html[data-theme="thriller"] :is(h1,h2,h3,.entry-main-title) *,html[data-theme="cyberpunk"] :is(h1,h2,h3,.entry-main-title) *{font-family:inherit!important}

/* ==========================================================================
   SYLVA BETA 0.975 — SUPER QA HARDENING
   Robust book-cover placeholder + coarse-pointer login targets.
   ========================================================================== */
/* A real placeholder is always present behind the <img>. The visible image uses
   the PNG variant; if a stored custom data URL is corrupt, app.js falls back to
   the PNG. If that image cannot decode either, this SVG background remains. */
.book-cover-button::before{
  content:"";position:absolute;inset:0;z-index:0;pointer-events:none;
  background:url("assets/sylva-cover-placeholder.svg") center/cover no-repeat;
}
.book-cover{position:relative;z-index:1;background:transparent}
.book-cover-shade{z-index:2}
.cover-preview{background-image:url("assets/sylva-cover-placeholder.svg")!important;background-position:center!important;background-size:cover!important;background-repeat:no-repeat!important}
.cover-preview img{position:relative;z-index:1;background:transparent}

/* Login is used on touch tablets too: keep secondary controls comfortably
   tappable without changing desktop density. */
@media (pointer:coarse){
  .entry-beta-field input{height:42px!important;font-size:13px!important}
  .entry-beta-visibility{height:42px!important;min-width:68px!important;font-size:10px!important}
  .entry-footer .entry-legal-link{min-height:40px!important;padding:8px 4px!important;display:inline-flex!important;align-items:center!important}
}


/* ==========================================================================
   SYLVA BETA 0.975 — NARRATIVE THEME COMPLETION / TUTORIAL SYNC
   Scope is intentionally limited to the four non-Sylva themes.
   - Expanded Writer rail inherits each narrative theme's UI font and colors.
   - Codex custom fields use semantic theme surfaces instead of native controls.
   Sylva Chiaro / Sylva Scuro are deliberately untouched.
   ========================================================================== */
:is(html[data-theme="modern"],html[data-theme="fantasy"],html[data-theme="thriller"],html[data-theme="cyberpunk"])[data-route] #rail .rail-btn{
  color:var(--muted)!important;
}
:is(html[data-theme="modern"],html[data-theme="fantasy"],html[data-theme="thriller"],html[data-theme="cyberpunk"])[data-route] #rail .rail-btn:hover,
:is(html[data-theme="modern"],html[data-theme="fantasy"],html[data-theme="thriller"],html[data-theme="cyberpunk"])[data-route] #rail .rail-btn.active{
  background:var(--accent-soft)!important;
  color:var(--text)!important;
}
:is(html[data-theme="modern"],html[data-theme="fantasy"],html[data-theme="thriller"],html[data-theme="cyberpunk"])[data-route] #rail .rail-btn small{
  font-family:var(--theme-ui)!important;
  color:inherit!important;
}
:is(html[data-theme="modern"],html[data-theme="fantasy"],html[data-theme="thriller"],html[data-theme="cyberpunk"])[data-route] #rail .rail-bottom{
  border-top-color:var(--line)!important;
}

:is(html[data-theme="modern"],html[data-theme="fantasy"],html[data-theme="thriller"],html[data-theme="cyberpunk"]) .world-custom-row input,
:is(html[data-theme="modern"],html[data-theme="fantasy"],html[data-theme="thriller"],html[data-theme="cyberpunk"]) .world-custom-row textarea{
  border:1px solid var(--line)!important;
  background:var(--surface-strong)!important;
  color:var(--text)!important;
  font-family:var(--theme-ui)!important;
  outline:none!important;
}
:is(html[data-theme="modern"],html[data-theme="fantasy"],html[data-theme="thriller"],html[data-theme="cyberpunk"]) .world-custom-row input::placeholder,
:is(html[data-theme="modern"],html[data-theme="fantasy"],html[data-theme="thriller"],html[data-theme="cyberpunk"]) .world-custom-row textarea::placeholder{
  color:var(--muted)!important;
  opacity:.82;
}
:is(html[data-theme="modern"],html[data-theme="fantasy"],html[data-theme="thriller"],html[data-theme="cyberpunk"]) .world-custom-row input:focus,
:is(html[data-theme="modern"],html[data-theme="fantasy"],html[data-theme="thriller"],html[data-theme="cyberpunk"]) .world-custom-row textarea:focus{
  border-color:color-mix(in srgb,var(--accent) 48%,var(--line))!important;
  box-shadow:0 0 0 3px color-mix(in srgb,var(--accent) 10%,transparent)!important;
}


/* ==========================================================================
   0.975 FINAL THEME BRAND + TABLET NAV HOTFIX · 2026-08-17
   Narrative themes get their approved coordinated logo assets. Sylva light/dark
   retain the original assets. Tablet drawer header keeps brand and toggle apart.
   ========================================================================== */

/* Complete lockup: change the image only for the four narrative themes. */
html[data-theme="modern"] :is(.sylva-splash-symbol img,.sylva-login-full,.sylva-phone-brand img,.sylva-legal-brand img,.home-logo-full,#rail .brand img){content:url("assets/sylva-logo-modern.png")!important}
html[data-theme="fantasy"] :is(.sylva-splash-symbol img,.sylva-login-full,.sylva-phone-brand img,.sylva-legal-brand img,.home-logo-full,#rail .brand img){content:url("assets/sylva-logo-fantasy.png")!important}
html[data-theme="thriller"] :is(.sylva-splash-symbol img,.sylva-login-full,.sylva-phone-brand img,.sylva-legal-brand img,.home-logo-full,#rail .brand img){content:url("assets/sylva-logo-thriller.png")!important}
html[data-theme="cyberpunk"] :is(.sylva-splash-symbol img,.sylva-login-full,.sylva-phone-brand img,.sylva-legal-brand img,.home-logo-full,#rail .brand img){content:url("assets/sylva-logo-cyberpunk.png")!important}

/* Compact navigation mark: coordinated symbol for each narrative theme. */
html[data-theme="modern"] .writer-nav-toggle img{content:url("assets/sylva-symbol-modern.png")!important}
html[data-theme="fantasy"] .writer-nav-toggle img{content:url("assets/sylva-symbol-fantasy.png")!important}
html[data-theme="thriller"] .writer-nav-toggle img{content:url("assets/sylva-symbol-thriller.png")!important}
html[data-theme="cyberpunk"] .writer-nav-toggle img{content:url("assets/sylva-symbol-cyberpunk.png")!important}

/* The toggle itself belongs to the selected atmosphere, not to Sylva green. */
html[data-theme="modern"][data-route]:not([data-route="home"]) .writer-nav-toggle{background:#f7f9fb!important;border-color:rgba(63,99,134,.20)!important;box-shadow:0 6px 20px rgba(34,51,67,.11)!important}
html[data-theme="fantasy"][data-route]:not([data-route="home"]) .writer-nav-toggle{background:#242319!important;border-color:rgba(193,154,85,.25)!important;box-shadow:0 8px 22px rgba(0,0,0,.28)!important}
html[data-theme="thriller"][data-route]:not([data-route="home"]) .writer-nav-toggle{background:#1d2023!important;border-color:rgba(217,101,106,.24)!important;box-shadow:0 8px 22px rgba(0,0,0,.30)!important}
html[data-theme="cyberpunk"][data-route]:not([data-route="home"]) .writer-nav-toggle{background:#0a151e!important;border-color:rgba(0,217,237,.30)!important;box-shadow:0 8px 22px rgba(0,0,0,.34)!important}

@media (max-width:1100px), (pointer:coarse) and (min-width:561px) and (max-width:1366px){
  /* Drawer header: full logo on the left, themed open/close control on the right. */
  html[data-route]:not([data-route="home"]) #rail .brand.sylva-brand-button{
    display:flex!important;width:calc(100% - 54px)!important;height:66px!important;min-height:66px!important;
    margin:0 54px 4px 2px!important;padding:4px 5px!important;align-items:center!important;justify-content:flex-start!important;
    border:0!important;background:transparent!important;box-shadow:none!important;overflow:visible!important;
  }
  html[data-route]:not([data-route="home"]) #rail .brand.sylva-brand-button img{
    display:block!important;width:min(178px,100%)!important;max-width:100%!important;height:auto!important;max-height:54px!important;
    object-fit:contain!important;object-position:left center!important;
  }
  html[data-route]:not([data-route="home"]) #rail .rail-nav{margin:2px 0 0!important}

  /* Closed: the mark stays at the viewport edge. Open: it becomes the drawer's
     close control in the reserved top-right slot, so it never sits on the logo. */
  html[data-route]:not([data-route="home"]) .writer-nav-toggle{
    z-index:220!important;transition:left .24s cubic-bezier(.2,.8,.2,1),transform .18s ease,background .18s ease,border-color .18s ease!important;
  }
  html[data-route]:not([data-route="home"]).writer-chrome-open .writer-nav-toggle{
    left:calc(min(292px,84vw) - 58px)!important;top:10px!important;
  }
  html[data-route]:not([data-route="home"]).writer-chrome-open .writer-nav-toggle img{transform:rotate(-8deg) scale(.94)!important}
}

/* ========================================================================== 
   SYLVA BETA 0.975 · MINOR THEME CONTRAST FIX
   Scope only: Sylva Dark reader paper + Fantasy/Thriller Writer structure head.
   ========================================================================== */
/* Sylva Dark: Reading returns to a warm paper field for long-form legibility.
   Writer and Revision deliberately remain untouched. */
html[data-theme="sylva-dark"][data-route="reader"] .reader-document{
  background:linear-gradient(96deg,var(--sylva-paper-low),var(--sylva-paper-hi) 4%,var(--paper) 12% 90%,var(--sylva-paper-low))!important;
  color:var(--sylva-ink)!important;
  border-color:rgba(173,153,118,.25)!important;
  box-shadow:0 28px 68px rgba(0,0,0,.34)!important;
}
html[data-theme="sylva-dark"][data-route="reader"] .reader-sheet{
  background:transparent!important;
  color:var(--sylva-ink)!important;
  border-color:transparent!important;
  box-shadow:none!important;
}
html[data-theme="sylva-dark"][data-route="reader"] :is(.reader-editor,.reader-separator h2){
  color:var(--sylva-ink)!important;
  text-shadow:none!important;
}
html[data-theme="sylva-dark"][data-route="reader"] :is(.reader-scene-label,.reader-separator small){color:var(--sylva-paper-muted)!important}
html[data-theme="sylva-dark"][data-route="reader"] .reader-separator{border-color:rgba(116,108,92,.18)!important}

/* The final strong-theme pass made these navigators dark, while an older root
   fix still forced dark heading ink. Keep the dark panel; only restore contrast. */
html[data-theme="fantasy"][data-route="writer"] #writerView:not(.review-mode) .structure-panel .panel-head :is(h2,h3){color:#f1e4cc!important}
html[data-theme="fantasy"][data-route="writer"] #writerView:not(.review-mode) .structure-panel .panel-head small{color:#c9ac77!important}
html[data-theme="thriller"][data-route="writer"] #writerView:not(.review-mode) .structure-panel .panel-head :is(h2,h3){color:#f2e7e9!important}
html[data-theme="thriller"][data-route="writer"] #writerView:not(.review-mode) .structure-panel .panel-head small{color:#d58a95!important}


/* ==========================================================================
   SYLVA BUG CATALOG PATCH · 2026-08-17 · SYLVA-001..008
   ========================================================================== */
html[data-route="writer"] #writerView:not(.review-mode) .scene-sheet{content-visibility:visible!important;contain:style!important;contain-intrinsic-size:none!important}
.tree-fold{width:22px;height:28px;flex:0 0 22px;border:0;background:transparent;color:var(--muted);border-radius:7px;display:grid;place-items:center;padding:0;cursor:pointer}.tree-fold:hover{background:var(--accent-soft);color:var(--text)}.tree-fold span{font-size:17px;line-height:1}.tree-fold-spacer{visibility:hidden!important;pointer-events:none!important}@media(max-width:1100px){.tree-fold{width:28px;height:34px;flex-basis:28px}}
.analysis-grid-main{grid-template-columns:minmax(0,1.28fr) minmax(350px,.72fr)!important;align-items:start!important}.analysis-grid-main>.analysis-card{align-self:start!important}.analysis-grid-main #actDonut.donut-wrap{grid-template-columns:132px minmax(0,1fr)!important;gap:16px!important;min-height:148px!important}.analysis-grid-main #actDonut .donut{width:132px!important}
@media(max-width:980px){.analysis-grid-main{grid-template-columns:1fr!important}.analysis-grid-main #actDonut.donut-wrap{grid-template-columns:140px minmax(0,1fr)!important}}@media(max-width:620px){.analysis-grid-main #actDonut.donut-wrap{grid-template-columns:1fr!important;justify-items:center}.analysis-grid-main #actDonut .donut-legend{width:100%}}
.scene-distribution,.compact-columns{overflow-x:auto!important;overflow-y:hidden!important;scrollbar-width:thin!important;scrollbar-color:color-mix(in srgb,var(--accent) 48%,var(--muted)) transparent!important;padding-bottom:10px!important;overscroll-behavior-x:contain}.scene-distribution::-webkit-scrollbar,.compact-columns::-webkit-scrollbar{display:block!important;height:8px!important}.scene-distribution::-webkit-scrollbar-track,.compact-columns::-webkit-scrollbar-track{background:transparent!important}.scene-distribution::-webkit-scrollbar-thumb,.compact-columns::-webkit-scrollbar-thumb{background:color-mix(in srgb,var(--accent) 42%,var(--muted))!important;border-radius:99px!important}.compact-columns .compact-col{flex:0 0 max(34px,calc((100% - 36px)/8))!important}
.relationship-page-toolbar{grid-template-columns:minmax(190px,1.05fr) minmax(240px,1.4fr) minmax(150px,.8fr) minmax(150px,.8fr)!important;gap:12px!important;align-items:end!important}.relationship-page-toolbar>*{min-width:0!important;width:100%!important}.relationship-page-toolbar .search-wrap,.relationship-page-toolbar .search-wrap input,.relationship-page-toolbar label select{width:100%!important;max-width:100%!important;box-sizing:border-box!important}@media(max-width:1100px){.relationship-page-toolbar{grid-template-columns:minmax(0,1fr) minmax(0,1fr)!important}}@media(max-width:720px){.relationship-page-toolbar{grid-template-columns:1fr!important}}
html[data-theme="alba"]{--bg:#eee9df;--surface:#f4efe7;--surface-2:#e8e3da;--surface-strong:#f8f4ec;--paper:#f4efe4;--text:#343a36;--muted:#6e766f;--line:rgba(59,70,63,.15);--accent:#6f8577;--accent-2:#9a8b70;--accent-soft:rgba(111,133,119,.12);--shadow:0 18px 48px rgba(61,67,61,.10);--theme-ui:Inter,system-ui,sans-serif}
html[data-theme="crepuscolo"]{--bg:#202724;--surface:#252d29;--surface-2:#2b3430;--surface-strong:#303a35;--paper:#d8d3c7;--text:#e1ded5;--muted:#a9aea8;--line:rgba(218,222,214,.13);--accent:#91a998;--accent-2:#b6a17d;--accent-soft:rgba(145,169,152,.13);--shadow:0 20px 54px rgba(8,12,10,.28);--theme-ui:Inter,system-ui,sans-serif}
:is(html[data-theme="alba"],html[data-theme="crepuscolo"]) body{background:var(--bg)!important;color:var(--text)!important}:is(html[data-theme="alba"],html[data-theme="crepuscolo"]) :is(.rail,.topbar,.modal,.glass-lite,.stat-card,.analysis-card,.codex-card,.planning-scenes-panel,.planning-detail,.relationship-page-list-panel){background:var(--surface)!important;border-color:var(--line)!important;color:var(--text)!important}:is(html[data-theme="alba"],html[data-theme="crepuscolo"]) :is(input,textarea,select,.soft-btn){background:var(--surface-strong)!important;color:var(--text)!important;border-color:var(--line)!important}:is(html[data-theme="alba"],html[data-theme="crepuscolo"]) :is(.rail-btn,.rail-btn small,.card-head small,.panel-head small){color:var(--muted)!important}:is(html[data-theme="alba"],html[data-theme="crepuscolo"]) .rail-btn:is(:hover,.active){background:var(--accent-soft)!important;color:var(--text)!important}
html[data-theme="alba"][data-route="writer"] .multi-scene-editor[data-scene-divider="boxes"] .scene-sheet{background:#f4efe4!important;color:#343a36!important;border:1px solid rgba(85,94,86,.14)!important;box-shadow:0 16px 44px rgba(65,70,64,.08)!important}html[data-theme="crepuscolo"][data-route="writer"] .multi-scene-editor[data-scene-divider="boxes"] .scene-sheet{background:#d8d3c7!important;color:#303631!important;border:1px solid rgba(220,214,201,.16)!important;box-shadow:0 18px 48px rgba(0,0,0,.25)!important}html[data-theme="alba"][data-route="reader"] .reader-document{background:#f4efe4!important;color:#343a36!important}html[data-theme="crepuscolo"][data-route="reader"] .reader-document{background:#d8d3c7!important;color:#303631!important}:is(html[data-theme="alba"],html[data-theme="crepuscolo"])[data-route="writer"] .scene-editor{color:#343a36!important}html[data-theme="crepuscolo"][data-route="reader"] :is(.reader-editor,.reader-separator h2){color:#303631!important}html[data-theme="alba"][data-route="reader"] :is(.reader-editor,.reader-separator h2){color:#343a36!important}.comfort-theme-group{border-color:color-mix(in srgb,var(--accent) 20%,var(--line));background:linear-gradient(145deg,color-mix(in srgb,var(--accent-soft) 55%,var(--surface-2)),var(--surface-2))}



/* Sylva 0.975 — Revisione comparata: toolbar Writer disponibile anche sulla copia modificabile. */
@media (pointer:coarse) and (min-width:561px) and (max-width:1366px){
  #writerView.review-mode .review-toolbar-row{padding:7px 9px}
  html[data-route="writer"] #writerView.review-mode .review-toolbar-row .floating-toolbar button{min-width:42px!important;height:42px!important;min-height:42px!important;flex:0 0 auto}
  html[data-route="writer"] #writerView.review-mode .review-toolbar-row .floating-toolbar select{height:42px!important;min-height:42px!important;min-width:88px;max-width:126px!important;flex:0 0 auto}
}
@media(max-width:680px){
  #writerView.review-mode .review-toolbar-row{padding:6px 8px;justify-content:flex-start}
  html[data-route="writer"] #writerView.review-mode .review-toolbar-row .floating-toolbar{margin:0!important;max-width:100%!important}
}

/* ==========================================================================
   SYLVA 0.975 · PATCH CONSOLIDAMENTO 2026-08-17
   Solo correzioni emerse dal QA delle patch SYLVA-003/005/007/008 + Revisione.
   ========================================================================== */

/* SYLVA-007 — niente tile vuoti sui manoscritti normali; sui Libri molto grandi
   conserviamo content-visibility, ma senza paint containment e prerenderizziamo
   le scene vicine tramite .scene-render-ready (gestita da app.js). */
html[data-route="writer"] #writerView:not(.review-mode) .multi-scene-editor[data-scene-virtualization="off"] .scene-sheet,
html[data-route="writer"] #writerView:not(.review-mode) .multi-scene-editor[data-scene-virtualization="auto"] .scene-sheet.scene-render-ready{
  content-visibility:visible!important;
  contain:style!important;
  contain-intrinsic-size:none!important;
}
html[data-route="writer"] #writerView:not(.review-mode) .multi-scene-editor[data-scene-virtualization="auto"] .scene-sheet:not(.scene-render-ready){
  content-visibility:auto!important;
  contain:layout style!important;
  contain-intrinsic-size:auto 760px!important;
}

/* SYLVA-003 — a 721–820 px la toolbar non deve tornare a due colonne. */
@media(max-width:820px){
  .relationship-page-toolbar{grid-template-columns:1fr!important;gap:12px!important;padding:14px!important}
}

/* SYLVA-005 — Alba: contrasto AA anche per label/accenti piccoli. */
html[data-theme="alba"]{
  --bg:#eee9df;
  --surface:#f4efe7;
  --surface-2:#e8e3da;
  --surface-strong:#f8f4ec;
  --paper:#f4efe4;
  --text:#303832;
  --muted:#59665e;
  --line:rgba(54,67,59,.18);
  --accent:#55705f;
  --accent-2:#7a6850;
  --accent-soft:rgba(85,112,95,.13);
  --shadow:0 18px 48px rgba(61,67,61,.10);
}

/* Alba e Crepuscolo devono essere temi completi, non semplici root palette.
   Gli override restano intenzionalmente circoscritti ai due comfort theme. */
:is(html[data-theme="alba"],html[data-theme="crepuscolo"]) :is(
  .rail,.topbar,.floating-toolbar,.bookmark-panel,.structure-panel,
  .modal,.glass-lite,.book-card,.stat-card,.analysis-card,.codex-card,
  .planning-scenes-panel,.planning-detail,.planning-card-block,.timeline-tools,
  .calendar-foundation,.calendar-months-section,.relationship-page-list-panel,
  .review-workspace,.review-workspace-head,.review-column-labels,.reader-controls,.reader-notes-panel
){
  border-color:var(--line)!important;
  color:var(--text)!important;
}
:is(html[data-theme="alba"],html[data-theme="crepuscolo"]) :is(
  .card-head small,.panel-head small,.view-head small,.relationship-page-toolbar label>span,.review-workspace-head small,
  .review-column-labels span,.review-column-labels small,.scene-label,.muted
){color:var(--muted)!important}
:is(html[data-theme="alba"],html[data-theme="crepuscolo"]) :is(
  input,textarea,select,.soft-btn,.mini-btn,.tiny-btn,.toolbar-btn
){
  border-color:var(--line)!important;
}
:is(html[data-theme="alba"],html[data-theme="crepuscolo"]) :is(input,textarea)::placeholder{color:var(--muted)!important;opacity:.82}
html[data-theme="alba"] .primary-btn{background:var(--accent)!important;color:#fff!important;border-color:color-mix(in srgb,var(--accent) 72%,#0000)!important}
html[data-theme="crepuscolo"] .primary-btn{background:var(--accent)!important;color:#202724!important;border-color:color-mix(in srgb,var(--accent) 72%,#0000)!important}
:is(html[data-theme="alba"],html[data-theme="crepuscolo"]) :is(a,.tiny-text-btn){color:var(--accent)!important}

html[data-theme="alba"] :is(.rail,.topbar,.floating-toolbar,.bookmark-panel,.modal,.glass-lite,.book-card,.stat-card,.analysis-card,.codex-card,.planning-scenes-panel,.planning-detail,.planning-card-block,.timeline-tools,.calendar-foundation,.calendar-months-section,.relationship-page-list-panel,.reader-controls,.reader-notes-panel){background:var(--surface)!important}
html[data-theme="crepuscolo"] :is(.rail,.topbar,.floating-toolbar,.bookmark-panel,.modal,.glass-lite,.book-card,.stat-card,.analysis-card,.codex-card,.planning-scenes-panel,.planning-detail,.planning-card-block,.timeline-tools,.calendar-foundation,.calendar-months-section,.relationship-page-list-panel,.reader-controls,.reader-notes-panel){background:var(--surface)!important}

/* Struttura Writer comfort themes: header, righe, hover e stato attivo coordinati. */
html[data-theme="alba"][data-route="writer"] #writerView:not(.review-mode) .structure-panel{
  background:linear-gradient(180deg,#e7e1d7 0%,#ddd7cc 100%)!important;
  color:#303832!important;border-right-color:rgba(54,67,59,.20)!important;
}
html[data-theme="crepuscolo"][data-route="writer"] #writerView:not(.review-mode) .structure-panel{
  background:linear-gradient(180deg,#252d29 0%,#202724 100%)!important;
  color:#e1ded5!important;border-right-color:rgba(218,222,214,.14)!important;
}
html[data-theme="alba"][data-route="writer"] #writerView:not(.review-mode) .structure-sticky-tools{background:linear-gradient(to bottom,rgba(231,225,215,.99),rgba(225,219,209,.95))!important;border-bottom-color:var(--line)!important}
html[data-theme="crepuscolo"][data-route="writer"] #writerView:not(.review-mode) .structure-sticky-tools{background:linear-gradient(to bottom,rgba(37,45,41,.99),rgba(32,39,36,.95))!important;border-bottom-color:var(--line)!important}
:is(html[data-theme="alba"],html[data-theme="crepuscolo"])[data-route="writer"] #writerView:not(.review-mode) .structure-panel .panel-head :is(h2,h3){color:inherit!important}
:is(html[data-theme="alba"],html[data-theme="crepuscolo"])[data-route="writer"] #writerView:not(.review-mode) .structure-panel .panel-head small{color:var(--muted)!important}
html[data-theme="alba"][data-route="writer"] #writerView:not(.review-mode) .tree-row{background:rgba(248,244,236,.62)!important;color:#39433d!important;border-color:rgba(54,67,59,.10)!important}
html[data-theme="crepuscolo"][data-route="writer"] #writerView:not(.review-mode) .tree-row{background:rgba(48,58,53,.76)!important;color:#e1ded5!important;border-color:rgba(218,222,214,.08)!important}
:is(html[data-theme="alba"],html[data-theme="crepuscolo"])[data-route="writer"] #writerView:not(.review-mode) .tree-row :is(i,b,span,em){color:inherit!important}
html[data-theme="alba"][data-route="writer"] #writerView:not(.review-mode) .tree-row:hover{background:#f3eee5!important;border-color:rgba(85,112,95,.20)!important}
html[data-theme="crepuscolo"][data-route="writer"] #writerView:not(.review-mode) .tree-row:hover{background:#344039!important;border-color:rgba(145,169,152,.18)!important}
html[data-theme="alba"][data-route="writer"] #writerView:not(.review-mode) .tree-row.active{background:#e2e8df!important;border-color:rgba(85,112,95,.30)!important;box-shadow:inset 2px 0 0 #55705f!important}
html[data-theme="crepuscolo"][data-route="writer"] #writerView:not(.review-mode) .tree-row.active{background:#334139!important;border-color:rgba(145,169,152,.28)!important;box-shadow:inset 2px 0 0 #91a998!important}
html[data-theme="alba"][data-route="writer"] #writerView:not(.review-mode) .tree-row.context-active{background:#ecebe3!important}
html[data-theme="crepuscolo"][data-route="writer"] #writerView:not(.review-mode) .tree-row.context-active{background:#2d3732!important}

/* Carta e modalità continue. Il font Writer resta sempre quello scelto dall'utente. */
html[data-theme="alba"][data-route="writer"] #writerView:not(.review-mode) .editor-viewport{background:linear-gradient(180deg,#e9e3d9,#e2dcd1)!important}
html[data-theme="crepuscolo"][data-route="writer"] #writerView:not(.review-mode) .editor-viewport{background:linear-gradient(180deg,#1d2421,#202724)!important}
html[data-theme="alba"][data-route="writer"] #writerView:not(.review-mode) .multi-scene-editor[data-scene-divider="boxes"] .scene-sheet{background:linear-gradient(180deg,#f8f4ec,#f2ecdf)!important;color:#303832!important;border-color:rgba(54,67,59,.14)!important;box-shadow:0 18px 48px rgba(61,67,61,.10)!important}
html[data-theme="crepuscolo"][data-route="writer"] #writerView:not(.review-mode) .multi-scene-editor[data-scene-divider="boxes"] .scene-sheet{background:linear-gradient(180deg,#ddd8cd,#d4cec1)!important;color:#303631!important;border-color:rgba(220,214,201,.18)!important;box-shadow:0 18px 48px rgba(0,0,0,.24)!important}
html[data-theme="alba"][data-route="writer"] #writerView:not(.review-mode) .multi-scene-editor[data-scene-divider="boxes"] .scene-editor{color:#303832!important;caret-color:#55705f!important}
html[data-theme="crepuscolo"][data-route="writer"] #writerView:not(.review-mode) .multi-scene-editor[data-scene-divider="boxes"] .scene-editor{color:#303631!important;caret-color:#55705f!important}
html[data-theme="alba"][data-route="writer"] #writerView:not(.review-mode) .multi-scene-editor:not([data-scene-divider="boxes"]) .scene-editor{color:#303832!important;caret-color:#55705f!important}
html[data-theme="crepuscolo"][data-route="writer"] #writerView:not(.review-mode) .multi-scene-editor:not([data-scene-divider="boxes"]) .scene-editor{color:#e1ded5!important;caret-color:#91a998!important}
html[data-theme="crepuscolo"][data-route="writer"] #writerView:not(.review-mode) .multi-scene-editor:not([data-scene-divider="boxes"]) .scene-label,
html[data-theme="crepuscolo"][data-route="writer"] #writerView:not(.review-mode) .manuscript-separator :is(h2,.separator-kicker){color:#a9aea8!important}

/* Revisione e Lettura: carta sempre leggibile, indipendente dal chrome chiaro/scuro. */
html[data-theme="alba"] :is(.review-original-sheet,.review-edit-sheet,.reader-document,.reader-sheet){background:#f4efe4!important;color:#303832!important;border-color:rgba(54,67,59,.14)!important}
html[data-theme="crepuscolo"] :is(.review-original-sheet,.review-edit-sheet,.reader-document,.reader-sheet){background:#d8d3c7!important;color:#303631!important;border-color:rgba(220,214,201,.16)!important}
html[data-theme="alba"] :is(.review-original-copy,.review-scene-editor,.reader-editor,.reader-separator h2){color:#303832!important}
html[data-theme="crepuscolo"] :is(.review-original-copy,.review-scene-editor,.reader-editor,.reader-separator h2){color:#303631!important}


/* ========================================================================== 
   Sylva 0.975 · Writer structure expandable width
   Solo pannello Manoscritto: mantiene il drawer attuale, aggiunge una larghezza
   estesa persistente e lascia più spazio ai titoli senza alterare il Writer.
   ========================================================================== */
html[data-route="writer"] #writerView:not(.review-mode) .structure-head-actions{
  display:flex!important;align-items:center!important;gap:6px!important;flex:0 0 auto!important
}
html[data-route="writer"] #writerView:not(.review-mode) #structureExpand{
  width:36px!important;height:36px!important;min-width:36px!important;padding:0!important;
  display:grid!important;place-items:center!important;
  border:1px solid rgba(65,68,61,.10)!important;background:rgba(255,253,249,.62)!important;color:#59645b!important
}
html[data-route="writer"] #writerView:not(.review-mode) #structureExpand svg{
  width:17px!important;height:17px!important;fill:none!important;stroke:currentColor!important;
  stroke-width:1.7!important;stroke-linecap:round!important;stroke-linejoin:round!important
}
html[data-route="writer"] #writerView:not(.review-mode) .structure-panel .tree-title{min-width:0!important}
html[data-route="writer"] #writerView:not(.review-mode) .structure-panel.wide .tree-title{
  white-space:normal!important;overflow:visible!important;text-overflow:clip!important;
  overflow-wrap:anywhere!important;line-height:1.28!important
}

/* Desktop/laptop: la modalità larga resta proporzionata e non divora il foglio. */
@media (min-width:901px) and (pointer:fine){
  html[data-route="writer"] #writerView:not(.review-mode) .structure-panel.wide:not(.collapsed){
    flex-basis:clamp(360px,32vw,480px)!important;
    width:clamp(360px,32vw,480px)!important;
    min-width:clamp(360px,32vw,480px)!important;
    max-width:clamp(360px,32vw,480px)!important
  }
}
@media (min-width:1367px){
  html[data-route="writer"] #writerView:not(.review-mode) .structure-panel.wide:not(.collapsed){
    flex-basis:clamp(390px,30vw,500px)!important;
    width:clamp(390px,30vw,500px)!important;
    min-width:clamp(390px,30vw,500px)!important;
    max-width:clamp(390px,30vw,500px)!important
  }
}

/* Tablet/drawer: il pannello largo rimane sempre dentro il viewport. */
@media (max-width:900px), (pointer:coarse) and (min-width:561px) and (max-width:1366px){
  html[data-route="writer"] #writerView:not(.review-mode) .structure-panel.wide,
  html[data-route="writer"] #writerView:not(.review-mode) .structure-panel.wide.collapsed{
    width:min(92vw,520px)!important;max-width:520px!important
  }
  html[data-route="writer"] #writerView:not(.review-mode) #structureExpand{
    width:42px!important;height:42px!important;min-width:42px!important;touch-action:manipulation!important
  }
}
@media (max-width:560px){
  html[data-route="writer"] #writerView:not(.review-mode) .structure-panel.wide,
  html[data-route="writer"] #writerView:not(.review-mode) .structure-panel.wide.collapsed{
    width:min(92vw,390px)!important;max-width:390px!important
  }
}

/* Il nuovo controllo usa la stessa grammatica cromatica del pulsante Chiudi. */
html[data-theme="sylva-dark"][data-route="writer"] #writerView:not(.review-mode) #structureExpand{
  background:rgba(238,230,216,.055)!important;border-color:rgba(238,230,216,.10)!important;color:#d8d1c6!important
}
html[data-theme="modern"][data-route="writer"] #writerView:not(.review-mode) #structureExpand{background:rgba(255,255,255,.68)!important;border-color:rgba(56,101,138,.16)!important;color:#385164!important}
html[data-theme="fantasy"][data-route="writer"] #writerView:not(.review-mode) #structureExpand{background:rgba(244,232,208,.58)!important;border-color:rgba(127,91,47,.21)!important;color:#52412b!important}
html[data-theme="thriller"][data-route="writer"] #writerView:not(.review-mode) #structureExpand{background:rgba(245,233,233,.58)!important;border-color:rgba(128,65,74,.19)!important;color:#4c353b!important}
html[data-theme="cyberpunk"][data-route="writer"] #writerView:not(.review-mode) #structureExpand{background:rgba(15,43,57,.82)!important;border-color:rgba(0,217,237,.22)!important;color:#d8f8fb!important}
:is(html[data-theme="alba"],html[data-theme="crepuscolo"])[data-route="writer"] #writerView:not(.review-mode) #structureExpand{
  background:var(--surface-strong)!important;border-color:var(--line)!important;color:var(--text)!important
}

/* ==========================================================================
   SYLVA 0.975 · ALBA / CREPUSCOLO COHERENCE HOTFIX · 2026-08-17
   Scope: app rail, Writer structure seam/controls, quick Codex. Manuscript paper
   is deliberately untouched.
   ========================================================================== */

/* The legacy Writer rail has a Sylva-light hardcoded background with a more
   specific selector. Override it only for the two comfort themes. */
html[data-theme="alba"][data-route]:not([data-route="home"]) #rail{
  background:linear-gradient(180deg,#f4efe7 0%,#ebe6dd 100%)!important;
  color:var(--text)!important;
  border-right:1px solid var(--line)!important;
}
html[data-theme="crepuscolo"][data-route]:not([data-route="home"]) #rail{
  background:linear-gradient(180deg,#232b27 0%,#1d2421 100%)!important;
  color:var(--text)!important;
  border-right:1px solid var(--line)!important;
}
:is(html[data-theme="alba"],html[data-theme="crepuscolo"])[data-route]:not([data-route="home"]) #rail .rail-btn{
  color:var(--muted)!important;
}
:is(html[data-theme="alba"],html[data-theme="crepuscolo"])[data-route]:not([data-route="home"]) #rail .rail-btn:hover,
:is(html[data-theme="alba"],html[data-theme="crepuscolo"])[data-route]:not([data-route="home"]) #rail .rail-btn.active{
  background:var(--accent-soft)!important;
  color:var(--text)!important;
}
:is(html[data-theme="alba"],html[data-theme="crepuscolo"])[data-route]:not([data-route="home"]) #rail .rail-btn.active .rail-icon-wrap{
  background:color-mix(in srgb,var(--accent-soft) 74%,transparent)!important;
}
:is(html[data-theme="alba"],html[data-theme="crepuscolo"])[data-route]:not([data-route="home"]) #rail .rail-btn.active::after{
  background:var(--accent)!important;
}
:is(html[data-theme="alba"],html[data-theme="crepuscolo"])[data-route]:not([data-route="home"]) #rail .rail-bottom{
  border-top-color:var(--line)!important;
}

/* Alba keeps the standard green lockup; Crepuscolo uses the existing ivory
   lockup so the brand remains readable on the now-correct dark rail. */
html[data-theme="alba"] :is(.sylva-splash-symbol img,.sylva-login-full,.sylva-phone-brand img,.sylva-legal-brand img,.home-logo-full,#rail .brand img){
  content:url("assets/sylva-logo-green.png")!important;
}
html[data-theme="crepuscolo"] :is(.sylva-splash-symbol img,.sylva-login-full,.sylva-phone-brand img,.sylva-legal-brand img,.home-logo-full,#rail .brand img){
  content:url("assets/sylva-logo-ivory.png")!important;
}
html[data-theme="alba"] .writer-nav-toggle img{content:url("assets/sylva-symbol-green.png")!important}
html[data-theme="crepuscolo"] .writer-nav-toggle img{content:url("assets/sylva-symbol-ivory.png")!important}
html[data-theme="alba"][data-route]:not([data-route="home"]) .writer-nav-toggle{
  background:#f4efe7!important;border-color:rgba(54,67,59,.18)!important;box-shadow:0 6px 20px rgba(61,67,61,.10)!important
}
html[data-theme="crepuscolo"][data-route]:not([data-route="home"]) .writer-nav-toggle{
  background:#252d29!important;border-color:rgba(218,222,214,.14)!important;box-shadow:0 8px 22px rgba(8,12,10,.28)!important
}

/* The 12px Writer flex gap was exposing the old #fffdfa Writer background as a
   vertical white strip beside Structure. Keep geometry unchanged, theme the
   surface underneath instead. */
html[data-theme="alba"][data-route="writer"] #writerView:not(.review-mode),
html[data-theme="alba"][data-route="writer"] #writerView:not(.review-mode) .editor-stage{
  background:#e5dfd5!important;
}
html[data-theme="crepuscolo"][data-route="writer"] #writerView:not(.review-mode),
html[data-theme="crepuscolo"][data-route="writer"] #writerView:not(.review-mode) .editor-stage{
  background:#1d2421!important;
}

/* Structure controls still inherited old light-Sylva button ink/backgrounds. */
html[data-theme="alba"][data-route="writer"] #writerView:not(.review-mode) .structure-panel :is(.structure-actions .mini-btn,#structureCollapse,#structureExpand){
  background:#f4efe7!important;color:#3a4840!important;border-color:rgba(54,67,59,.18)!important;
}
html[data-theme="crepuscolo"][data-route="writer"] #writerView:not(.review-mode) .structure-panel :is(.structure-actions .mini-btn,#structureCollapse,#structureExpand){
  background:#2d3732!important;color:#e1ded5!important;border-color:rgba(218,222,214,.14)!important;
}


html[data-theme="alba"][data-route="writer"] #writerView:not(.review-mode) #structureHandle{
  background:#e8e2d8!important;color:#4f6257!important;border-color:rgba(54,67,59,.18)!important;
}
html[data-theme="crepuscolo"][data-route="writer"] #writerView:not(.review-mode) #structureHandle{
  background:#252d29!important;color:#c8d1ca!important;border-color:rgba(218,222,214,.14)!important;box-shadow:6px 8px 22px rgba(8,12,10,.22)!important;
}

/* Quick Codex: for comfort themes the preview chrome follows the selected UI
   theme, not the arbitrary color stored on the Codex entry. Manuscript Codex
   highlights keep their per-entry colors. */
:is(html[data-theme="alba"],html[data-theme="crepuscolo"])[data-route="writer"] .writer-codex-preview{
  --writer-codex-color:var(--accent)!important;
  background:var(--surface-strong)!important;
  color:var(--text)!important;
  border-color:color-mix(in srgb,var(--accent) 24%,var(--line))!important;
  box-shadow:0 20px 55px color-mix(in srgb,#000 18%,transparent)!important;
}
:is(html[data-theme="alba"],html[data-theme="crepuscolo"])[data-route="writer"] .writer-codex-preview :is(
  .writer-codex-preview-head h2,.writer-codex-description,.writer-codex-parent b,
  .writer-codex-facts b,.writer-codex-mini-section p
){color:var(--text)!important}
:is(html[data-theme="alba"],html[data-theme="crepuscolo"])[data-route="writer"] .writer-codex-preview :is(
  .writer-codex-identity small,.writer-codex-parent span,.writer-codex-facts span,
  .writer-codex-mini-section>small,.writer-codex-mini-section>div span,.writer-codex-preview-meta
){color:var(--muted)!important}
:is(html[data-theme="alba"],html[data-theme="crepuscolo"])[data-route="writer"] .writer-codex-preview-head small{
  color:var(--accent)!important;
}
:is(html[data-theme="alba"],html[data-theme="crepuscolo"])[data-route="writer"] .writer-codex-symbol{
  background:var(--accent-soft)!important;color:var(--accent)!important;
}
:is(html[data-theme="alba"],html[data-theme="crepuscolo"])[data-route="writer"] .writer-codex-chips span{
  background:var(--surface-2)!important;color:var(--muted)!important;border-color:var(--line)!important;
}
:is(html[data-theme="alba"],html[data-theme="crepuscolo"])[data-route="writer"] .writer-codex-preview-actions{
  background:var(--surface-2)!important;border-top-color:var(--line)!important;
}
:is(html[data-theme="alba"],html[data-theme="crepuscolo"])[data-route="writer"] .writer-codex-preview-actions .soft-btn{
  background:var(--surface-strong)!important;color:var(--text)!important;border-color:var(--line)!important;
}

/* ========================================================================== 
   SYLVA 0.975 · CREPUSCOLO FULL CONTRAST CONSOLIDATION · 2026-08-17
   Neutralises historical Sylva-light hardcoded chrome only inside Crepuscolo.
   Manuscript/Reader paper and user-selected Writer typography are untouched.
   ========================================================================== */

/* Core chrome: keep every navigation surface inside the Crepuscolo palette. */
html[data-theme="crepuscolo"] :is(.glass,.glass-lite){
  border-color:var(--line)!important;
  color:var(--text)!important;
}
html[data-theme="crepuscolo"] .glass{
  background:color-mix(in srgb,var(--surface) 96%,transparent)!important;
  backdrop-filter:blur(16px) saturate(.88)!important;
  -webkit-backdrop-filter:blur(16px) saturate(.88)!important;
}
html[data-theme="crepuscolo"] .glass-lite{
  background:color-mix(in srgb,var(--surface-2) 92%,transparent)!important;
}
html[data-theme="crepuscolo"] :is(
  .view-heading h1,.view-heading h2,.panel-head h2,.panel-head h3,
  .card-head h2,.card-head h3,.planning-block-head h2,.planning-block-head h3,
  .relationship-page-section-head h2,.relationship-page-section-head h3,
  .calendar-section-head h2,.calendar-section-head h3,.timeline-section-head h2,
  .timeline-section-head h3,.modal h2,.modal h3
){color:var(--text)!important}
html[data-theme="crepuscolo"] :is(
  .view-heading p,.view-heading small,.card-head p,.card-head small,
  .panel-head p,.panel-head small,.planning-block-head small,
  .relationship-page-section-head small,.calendar-section-head small,
  .timeline-section-head small
){color:var(--muted)!important}

/* Rail: also on Home. The previous hotfix intentionally skipped Home, leaving
   an ivory logo over the old cream Sylva rail. */
html[data-theme="crepuscolo"] #rail{
  background:linear-gradient(180deg,#232b27 0%,#1d2421 100%)!important;
  color:var(--text)!important;
  border-color:var(--line)!important;
}
html[data-theme="crepuscolo"] #rail .brand img{
  content:url("assets/sylva-logo-ivory.png")!important;
  opacity:1!important;
  filter:none!important;
}
html[data-theme="crepuscolo"] #rail .rail-btn{color:var(--muted)!important}
html[data-theme="crepuscolo"] #rail .rail-btn:hover,
html[data-theme="crepuscolo"] #rail .rail-btn.active{
  background:var(--accent-soft)!important;
  color:var(--text)!important;
}
html[data-theme="crepuscolo"] #rail .rail-btn :is(.rail-icon-wrap,small){color:inherit!important}
html[data-theme="crepuscolo"] #rail .rail-btn.active .rail-icon-wrap{
  background:color-mix(in srgb,var(--accent-soft) 78%,transparent)!important;
}
html[data-theme="crepuscolo"] #rail .rail-bottom{border-top-color:var(--line)!important}

/* Home: the historical compact Home pass is intentionally Sylva-coloured and
   uses many !important values. Re-theme it without changing any geometry. */
html[data-theme="crepuscolo"][data-route="home"] .app-shell,
html[data-theme="crepuscolo"][data-route="home"] .main-area,
html[data-theme="crepuscolo"][data-route="home"] .home-view{
  background:var(--bg)!important;
  color:var(--text)!important;
}
html[data-theme="crepuscolo"][data-route="home"] .home-logo-full{
  content:url("assets/sylva-logo-ivory.png")!important;
  opacity:1!important;
  filter:none!important;
}
html[data-theme="crepuscolo"][data-route="home"] :is(
  .home-hero h1,.home-section-head h2,.home-shelf-head h2,
  .book-card-title-row h3,.sylva-saga-card h3,
  .home-export-actions .big-action b,.home-info-card b,.home-footer span
){color:var(--text)!important}
html[data-theme="crepuscolo"][data-route="home"] :is(
  .home-hero p,.home-section-head p,.home-shelf-head>span,
  .book-card-facts,.book-card-facts span,.sylva-saga-card p,
  .home-export-actions .big-action small,.home-info-card small,
  .home-import-row,.home-import-row span,.home-footer,.saga-empty-card
){color:var(--muted)!important}
html[data-theme="crepuscolo"][data-route="home"] :is(
  .home-hero>small,.home-section-head small,.home-shelf-head small,
  .book-card-title-row small,.sylva-saga-card small,.home-info-card span
){color:var(--accent)!important}
html[data-theme="crepuscolo"][data-route="home"] .home-section+.home-section,
html[data-theme="crepuscolo"][data-route="home"] .home-footer{
  border-color:var(--line)!important;
}
html[data-theme="crepuscolo"][data-route="home"] :is(
  .sylva-book-card,.home-export-actions .big-action,.home-info-card,.sylva-empty
){
  background:var(--surface)!important;
  border-color:var(--line)!important;
  color:var(--text)!important;
  box-shadow:var(--shadow)!important;
}
html[data-theme="crepuscolo"][data-route="home"] :is(
  .sylva-book-card:hover,.home-export-actions .big-action:hover,.home-info-card:hover
){
  background:var(--surface-strong)!important;
  border-color:color-mix(in srgb,var(--accent) 32%,var(--line))!important;
}
html[data-theme="crepuscolo"][data-route="home"] .sylva-book-card.active-book{
  border-color:color-mix(in srgb,var(--accent) 45%,var(--line))!important;
  box-shadow:inset 0 0 0 1px color-mix(in srgb,var(--accent) 16%,transparent),var(--shadow)!important;
}
html[data-theme="crepuscolo"][data-route="home"] .book-cover-button{background:var(--surface-2)!important}
html[data-theme="crepuscolo"][data-route="home"] .book-cover-shade{box-shadow:inset -12px 0 22px rgba(0,0,0,.14)!important}
html[data-theme="crepuscolo"][data-route="home"] .sylva-saga-card,
html[data-theme="crepuscolo"][data-route="home"] .sylva-saga-card:nth-child(n){
  background:linear-gradient(135deg,#2c3531,#252d29 62%,#313932)!important;
  border-color:var(--line)!important;
}
html[data-theme="crepuscolo"][data-route="home"] .saga-botanical{
  background-image:url("assets/sylva-symbol-ivory.png")!important;
  opacity:.10!important;
  filter:none!important;
}
html[data-theme="crepuscolo"][data-route="home"] .saga-empty-card{
  background:color-mix(in srgb,var(--surface) 72%,transparent)!important;
  border-color:var(--line)!important;
}
html[data-theme="crepuscolo"][data-route="home"] .home-export-actions .big-action .action-icon{color:var(--accent)!important}
html[data-theme="crepuscolo"][data-route="home"] .sylva-book-card .book-icon-btn{
  background:color-mix(in srgb,var(--surface-2) 80%,transparent)!important;
  color:var(--muted)!important;
  border-color:var(--line)!important;
}
html[data-theme="crepuscolo"][data-route="home"] .sylva-book-card .book-icon-btn:hover{
  background:var(--accent-soft)!important;
  color:var(--text)!important;
}

/* Writer chrome: title + toolbar were still inheriting the old Sylva-light ink. */
html[data-theme="crepuscolo"][data-route="writer"] .topbar{
  background:color-mix(in srgb,var(--surface) 97%,transparent)!important;
  color:var(--text)!important;
  border-color:var(--line)!important;
}
html[data-theme="crepuscolo"][data-route="writer"] .book-title-top{
  color:var(--text)!important;
  text-shadow:none!important;
}
html[data-theme="crepuscolo"][data-route="writer"] .floating-toolbar{
  background:color-mix(in srgb,var(--surface-strong) 97%,transparent)!important;
  color:var(--text)!important;
  border-color:var(--line)!important;
  box-shadow:0 8px 26px rgba(7,11,9,.24)!important;
}
html[data-theme="crepuscolo"][data-route="writer"] .floating-toolbar :is(button,select){
  color:var(--text)!important;
  background:transparent!important;
  border-color:transparent!important;
}
html[data-theme="crepuscolo"][data-route="writer"] .floating-toolbar select option{
  background:#252d29!important;
  color:#e1ded5!important;
}
html[data-theme="crepuscolo"][data-route="writer"] .floating-toolbar :is(button,select):hover,
html[data-theme="crepuscolo"][data-route="writer"] .floating-toolbar button.active,
html[data-theme="crepuscolo"][data-route="writer"] .floating-toolbar .writer-width-btn.active{
  background:var(--accent-soft)!important;
  color:#f0eee7!important;
}
html[data-theme="crepuscolo"][data-route="writer"] .floating-toolbar .separator{background:var(--line)!important;opacity:1!important}

/* Structure: make the selected scene explicit so no older high-specificity
   Sylva selector can make its title/controls disappear again. */
html[data-theme="crepuscolo"][data-route="writer"] #writerView:not(.review-mode) .structure-panel .tree-row.active{
  background:#35443c!important;
  color:#f0eee7!important;
  border-color:rgba(145,169,152,.34)!important;
  box-shadow:inset 3px 0 0 #91a998!important;
}
html[data-theme="crepuscolo"][data-route="writer"] #writerView:not(.review-mode) .structure-panel .tree-row.active :is(
  .tree-title,.tree-fold,.tree-jump,.tree-drag-handle,.tree-menu
){color:#f0eee7!important}

html[data-theme="crepuscolo"][data-route="writer"] #writerView:not(.review-mode) .structure-panel .tree-row.context-active{
  color:#e1ded5!important;
}
html[data-theme="crepuscolo"][data-route="writer"] #writerView:not(.review-mode) .structure-panel .tree-row.context-active :is(
  .tree-title,.tree-fold,.tree-jump,.tree-drag-handle,.tree-menu
){color:inherit!important}

/* Reader chrome: only the controls become dark; the warm reading paper stays
   exactly as defined by the comfort theme. */
html[data-theme="crepuscolo"][data-route="reader"] .reader-bar{
  background:color-mix(in srgb,var(--surface-strong) 97%,transparent)!important;
  color:var(--text)!important;
  border:1px solid var(--line)!important;
  box-shadow:0 12px 34px rgba(7,11,9,.28)!important;
}
html[data-theme="crepuscolo"][data-route="reader"] .reader-position b{color:var(--text)!important}
html[data-theme="crepuscolo"][data-route="reader"] .reader-position small{color:var(--muted)!important}
html[data-theme="crepuscolo"][data-route="reader"] :is(
  .reader-icon-btn,.reader-note-btn,.reader-scope,.reader-book-format,.reader-highlight-clear
){color:var(--muted)!important}
html[data-theme="crepuscolo"][data-route="reader"] :is(.reader-scope,.reader-book-format){
  background:var(--surface-2)!important;
  border-color:var(--line)!important;
}
html[data-theme="crepuscolo"][data-route="reader"] :is(.reader-scope,.reader-book-format) option{
  background:#252d29!important;
  color:#e1ded5!important;
}
html[data-theme="crepuscolo"][data-route="reader"] :is(.reader-icon-btn,.reader-note-btn,.reader-highlight-clear):hover{
  background:var(--accent-soft)!important;
  color:var(--text)!important;
}
html[data-theme="crepuscolo"][data-route="reader"] .reader-bar-separator{background:var(--line)!important}
html[data-theme="crepuscolo"][data-route="reader"] .reader-notes-toggle span{
  background:var(--accent-soft)!important;
  color:var(--text)!important;
  border-color:var(--line)!important;
}


/* ==========================================================================
   0.975 · NARRATIVE THEMES EXPANSION — ARABESCO / MAUVE ORCHID / FORESTA
   These three choices reuse the proven Narrative component contracts through
   data-theme aliases, while data-palette supplies a complete independent
   atmosphere. No layout or feature behavior is changed.
   ========================================================================== */
html[data-palette="arabesque"]{
  color-scheme:dark;
  --bg:#17110d;--bg2:#201711;
  --surface:rgba(43,30,22,.92);--surface-2:rgba(78,56,38,.28);--surface-strong:#2a1d15;
  --paper:#efe0c1;--text:#f1e5d1;--muted:#bba98f;--line:rgba(229,199,148,.16);
  --shadow:0 24px 66px rgba(4,2,1,.38);--blur:18px;
  --accent:#d3a14e;--accent-2:#4f9a91;--accent-soft:rgba(211,161,78,.13);
  --danger:#c96e5e;--danger-soft:rgba(201,110,94,.12);
  --ambient-a:#6f4d28;--ambient-b:#1f665f;--ambient-c:#9b6b35;--ambient-opacity:.11;
  --radius:14px;--radius-sm:9px;
  --ui-font:Alegreya,"Source Sans 3",Inter,system-ui,sans-serif;
  --ui-serif:"Cormorant Garamond",Georgia,serif;
  --theme-display:"Cormorant Garamond",Georgia,serif;--theme-ui:Alegreya,"Source Sans 3",Inter,system-ui,sans-serif;
  --theme-paper:#efe0c1;--theme-paper-ink:#34271a;--theme-paper-muted:#7b6650;
  --theme-chrome:#261a13;--theme-chrome-soft:#33231a;--theme-entry:#15100c;
  --theme-primary:#c89443;--theme-primary-text:#1c1209;--theme-control-radius:9px;
  --theme-stage-bg:radial-gradient(circle at 10% 8%,rgba(211,161,78,.13),transparent 25%),radial-gradient(circle at 88% 12%,rgba(79,154,145,.10),transparent 23%),linear-gradient(145deg,#130d0a,#21150f 58%,#15100c);
  --theme-paper-page:radial-gradient(circle at 15% 9%,rgba(189,133,55,.07),transparent 20%),repeating-linear-gradient(0deg,rgba(90,63,35,.018) 0,rgba(90,63,35,.018) 1px,transparent 1px,transparent 4px),linear-gradient(180deg,#f4e6c9 0%,#ead7b3 58%,#dcc59d 100%);
  --theme-paper-grain:repeating-linear-gradient(0deg,rgba(93,64,36,.018) 0,rgba(93,64,36,.018) 1px,transparent 1px,transparent 4px);
  --theme-paper-line:rgba(111,75,39,.17);--theme-book-spine:linear-gradient(90deg,transparent,rgba(118,80,40,.14),rgba(255,244,214,.18),rgba(50,122,116,.08),transparent);
  --theme-page-shadow-left:inset -24px 0 40px rgba(81,54,30,.09),inset 0 1px rgba(255,247,226,.72);
  --theme-page-shadow-right:inset 24px 0 40px rgba(81,54,30,.08),inset 0 1px rgba(255,247,226,.72);
  --theme-sheet-shadow:0 22px 62px rgba(0,0,0,.27),inset 0 1px rgba(255,244,218,.23);--theme-sheet-border:rgba(171,126,61,.20);
}
html[data-palette="orchidea"]{
  color-scheme:dark;
  --bg:#251a22;--bg2:#2e2028;
  --surface:rgba(57,38,49,.92);--surface-2:rgba(101,67,84,.27);--surface-strong:#3a2732;
  --paper:#f0e4e9;--text:#f2e8ed;--muted:#c2aeb8;--line:rgba(226,191,205,.15);
  --shadow:0 24px 68px rgba(10,4,8,.40);--blur:17px;
  --accent:#b68299;--accent-2:#d4a9b9;--accent-soft:rgba(182,130,153,.14);
  --danger:#dc7e89;--danger-soft:rgba(220,126,137,.12);
  --ambient-a:#6d4057;--ambient-b:#9d6680;--ambient-c:#4d3344;--ambient-opacity:.11;
  --radius:15px;--radius-sm:10px;
  --ui-font:Manrope,Inter,system-ui,sans-serif;--ui-serif:Lora,Georgia,serif;
  --theme-display:Lora,Georgia,serif;--theme-ui:Manrope,Inter,system-ui,sans-serif;
  --theme-paper:#f0e4e9;--theme-paper-ink:#3c2932;--theme-paper-muted:#816b75;
  --theme-chrome:#33222c;--theme-chrome-soft:#402b36;--theme-entry:#21171e;
  --theme-primary:#b68299;--theme-primary-text:#21131a;--theme-control-radius:10px;
  --theme-stage-bg:radial-gradient(circle at 13% 8%,rgba(182,130,153,.13),transparent 24%),radial-gradient(circle at 89% 13%,rgba(213,169,185,.08),transparent 22%),linear-gradient(145deg,#21161e,#33222c 58%,#251a22);
  --theme-paper-page:radial-gradient(circle at 84% 10%,rgba(182,130,153,.045),transparent 18%),repeating-linear-gradient(0deg,rgba(92,63,76,.014) 0,rgba(92,63,76,.014) 1px,transparent 1px,transparent 4px),linear-gradient(180deg,#f5ebef 0%,#ecdee4 58%,#dfccd4 100%);
  --theme-paper-grain:repeating-linear-gradient(0deg,rgba(91,61,75,.015) 0,rgba(91,61,75,.015) 1px,transparent 1px,transparent 4px);
  --theme-paper-line:rgba(102,69,84,.15);--theme-book-spine:linear-gradient(90deg,transparent,rgba(104,68,84,.13),rgba(255,248,251,.20),rgba(104,68,84,.11),transparent);
  --theme-page-shadow-left:inset -24px 0 40px rgba(73,48,59,.08),inset 0 1px rgba(255,255,255,.67);
  --theme-page-shadow-right:inset 24px 0 40px rgba(73,48,59,.075),inset 0 1px rgba(255,255,255,.67);
  --theme-sheet-shadow:0 22px 60px rgba(15,6,11,.25),inset 0 1px rgba(255,255,255,.42);--theme-sheet-border:rgba(128,83,102,.17);
}
html[data-palette="foresta"]{
  color-scheme:dark;
  --bg:#0e1b1b;--bg2:#132524;
  --surface:rgba(22,43,41,.92);--surface-2:rgba(47,83,77,.27);--surface-strong:#18302d;
  --paper:#dbe2dc;--text:#e4eeea;--muted:#a6bbb4;--line:rgba(178,215,204,.14);
  --shadow:0 25px 70px rgba(2,10,9,.43);--blur:18px;
  --accent:#78b4a9;--accent-2:#d3a46a;--accent-soft:rgba(120,180,169,.13);
  --danger:#cf756c;--danger-soft:rgba(207,117,108,.12);
  --ambient-a:#2c6e67;--ambient-b:#789c96;--ambient-c:#c28d5b;--ambient-opacity:.11;
  --radius:17px;--radius-sm:11px;
  --ui-font:"Source Sans 3",Inter,system-ui,sans-serif;--ui-serif:"Libre Baskerville",Georgia,serif;
  --theme-display:"Libre Baskerville",Georgia,serif;--theme-ui:"Source Sans 3",Inter,system-ui,sans-serif;
  --theme-paper:#dbe2dc;--theme-paper-ink:#24332f;--theme-paper-muted:#667a73;
  --theme-chrome:#132624;--theme-chrome-soft:#1a312e;--theme-entry:#0c1818;
  --theme-primary:#78b4a9;--theme-primary-text:#0b1b19;--theme-control-radius:11px;
  --theme-stage-bg:radial-gradient(circle at 15% 12%,rgba(104,166,157,.13),transparent 25%),radial-gradient(circle at 82% 8%,rgba(211,164,106,.07),transparent 20%),radial-gradient(circle at 68% 82%,rgba(106,139,145,.08),transparent 24%),linear-gradient(145deg,#0b1717,#142725 58%,#0e1b1b);
  --theme-paper-page:radial-gradient(circle at 15% 10%,rgba(105,153,145,.055),transparent 19%),repeating-linear-gradient(0deg,rgba(47,75,69,.014) 0,rgba(47,75,69,.014) 1px,transparent 1px,transparent 4px),linear-gradient(180deg,#e2e8e3 0%,#d8e0da 57%,#cad5ce 100%);
  --theme-paper-grain:repeating-linear-gradient(0deg,rgba(47,74,68,.015) 0,rgba(47,74,68,.015) 1px,transparent 1px,transparent 4px);
  --theme-paper-line:rgba(54,85,78,.15);--theme-book-spine:linear-gradient(90deg,transparent,rgba(46,82,75,.13),rgba(244,250,246,.18),rgba(211,164,106,.07),transparent);
  --theme-page-shadow-left:inset -24px 0 42px rgba(40,69,63,.08),inset 0 1px rgba(255,255,255,.63);
  --theme-page-shadow-right:inset 24px 0 42px rgba(40,69,63,.075),inset 0 1px rgba(255,255,255,.63);
  --theme-sheet-shadow:0 23px 64px rgba(0,0,0,.25),inset 0 1px rgba(255,255,255,.34);--theme-sheet-border:rgba(67,108,98,.17);
}

/* Force each palette over the inherited narrative hard-coded atmosphere. */
html[data-palette="arabesque"] body{background:var(--theme-stage-bg)!important}
html[data-palette="orchidea"] body{background:var(--theme-stage-bg)!important}
html[data-palette="foresta"] body{background:var(--theme-stage-bg)!important}
:is(html[data-palette="arabesque"],html[data-palette="orchidea"],html[data-palette="foresta"]) .glass{background:color-mix(in srgb,var(--surface-strong) 92%,transparent)!important;border-color:var(--line)!important}
:is(html[data-palette="arabesque"],html[data-palette="orchidea"],html[data-palette="foresta"]) :is(.rail,.topbar,.modal,.codex-card,.planning-scenes-panel,.planning-detail,.relationship-page-list-panel,.calendar-foundation,.calendar-months-section,.timeline-event-card){border-color:var(--line)!important}
:is(html[data-palette="arabesque"],html[data-palette="orchidea"],html[data-palette="foresta"]) .sylva-saga-card,
:is(html[data-palette="arabesque"],html[data-palette="orchidea"],html[data-palette="foresta"]) .sylva-saga-card:nth-child(n){background:linear-gradient(135deg,var(--surface-strong),var(--surface) 64%,var(--theme-chrome-soft))!important;border-color:var(--line)!important}
:is(html[data-palette="arabesque"],html[data-palette="orchidea"],html[data-palette="foresta"]) .book-cover-button{background:var(--theme-chrome-soft)!important}
:is(html[data-palette="arabesque"],html[data-palette="orchidea"],html[data-palette="foresta"]) .entry-gate{background:var(--theme-stage-bg)!important;color:var(--text)!important}
:is(html[data-palette="arabesque"],html[data-palette="orchidea"],html[data-palette="foresta"]) .entry-main-title i{color:var(--accent-2)!important}


/* Writer + structure: theme-specific but geometry remains untouched. */
:is(html[data-palette="arabesque"],html[data-palette="orchidea"],html[data-palette="foresta"])[data-route="writer"] #writerView:not(.review-mode) :is(.main-area,.editor-stage,.editor-viewport){background:var(--theme-stage-bg)!important}
:is(html[data-palette="arabesque"],html[data-palette="orchidea"],html[data-palette="foresta"])[data-route="writer"] #writerView:not(.review-mode) .multi-scene-editor[data-scene-divider="boxes"] .scene-sheet{background:var(--theme-paper-page)!important;color:var(--theme-paper-ink)!important;border-color:var(--theme-sheet-border)!important;box-shadow:var(--theme-sheet-shadow)!important}
:is(html[data-palette="arabesque"],html[data-palette="orchidea"],html[data-palette="foresta"])[data-route="writer"] #writerView:not(.review-mode) .scene-editor{color:var(--theme-paper-ink)!important;caret-color:var(--accent)!important}
:is(html[data-palette="arabesque"],html[data-palette="orchidea"],html[data-palette="foresta"])[data-route="writer"] #writerView:not(.review-mode) .scene-label{color:var(--theme-paper-muted)!important}
:is(html[data-palette="arabesque"],html[data-palette="orchidea"],html[data-palette="foresta"])[data-route="writer"] #writerView:not(.review-mode) .structure-panel{background:linear-gradient(180deg,var(--theme-chrome),color-mix(in srgb,var(--theme-chrome-soft) 88%,var(--theme-chrome)) 58%,var(--theme-entry))!important;color:var(--text)!important;border-right-color:var(--line)!important}
:is(html[data-palette="arabesque"],html[data-palette="orchidea"],html[data-palette="foresta"])[data-route="writer"] #writerView:not(.review-mode) .structure-sticky-tools{background:linear-gradient(to bottom,var(--theme-chrome) 0%,color-mix(in srgb,var(--theme-chrome) 97%,transparent) 82%,color-mix(in srgb,var(--theme-chrome) 90%,transparent) 100%)!important;border-bottom-color:var(--line)!important}
:is(html[data-palette="arabesque"],html[data-palette="orchidea"],html[data-palette="foresta"])[data-route="writer"] #writerView:not(.review-mode) .structure-panel .panel-head :is(h2,h3){color:var(--text)!important}
:is(html[data-palette="arabesque"],html[data-palette="orchidea"],html[data-palette="foresta"])[data-route="writer"] #writerView:not(.review-mode) .structure-panel .panel-head small{color:var(--accent-2)!important}
:is(html[data-palette="arabesque"],html[data-palette="orchidea"],html[data-palette="foresta"])[data-route="writer"] #writerView:not(.review-mode) .structure-panel :is(.structure-actions .mini-btn,#structureCollapse,#structureExpand){background:var(--theme-chrome-soft)!important;border-color:var(--line)!important;color:var(--text)!important}
:is(html[data-palette="arabesque"],html[data-palette="orchidea"],html[data-palette="foresta"])[data-route="writer"] #writerView:not(.review-mode) .structure-panel .tree-row{background:color-mix(in srgb,var(--theme-chrome-soft) 82%,transparent)!important;color:var(--text)!important;border-color:var(--line)!important}
:is(html[data-palette="arabesque"],html[data-palette="orchidea"],html[data-palette="foresta"])[data-route="writer"] #writerView:not(.review-mode) .structure-panel .tree-row:hover{background:color-mix(in srgb,var(--accent) 10%,var(--theme-chrome-soft))!important}
:is(html[data-palette="arabesque"],html[data-palette="orchidea"],html[data-palette="foresta"])[data-route="writer"] #writerView:not(.review-mode) .structure-panel .tree-row.active{background:linear-gradient(90deg,color-mix(in srgb,var(--accent) 28%,var(--theme-chrome-soft)),color-mix(in srgb,var(--accent) 13%,var(--theme-chrome-soft)))!important;color:var(--text)!important;box-shadow:inset 3px 0 0 var(--accent)!important;border-color:color-mix(in srgb,var(--accent) 36%,var(--line))!important}


:is(html[data-palette="arabesque"],html[data-palette="orchidea"],html[data-palette="foresta"])[data-route="writer"] #writerView:not(.review-mode) #structureHandle{background:var(--theme-chrome-soft)!important;color:var(--text)!important;border-color:var(--line)!important}

/* Reader / review keep long-form contrast while retaining each atmosphere. */
:is(html[data-palette="arabesque"],html[data-palette="orchidea"],html[data-palette="foresta"]) :is(.reader-view,.reader-viewport,.reader-book-view){background:var(--theme-stage-bg)!important}
:is(html[data-palette="arabesque"],html[data-palette="orchidea"],html[data-palette="foresta"]) :is(.reader-document,.review-original-sheet,.review-edit-sheet){background:var(--theme-paper)!important;color:var(--theme-paper-ink)!important;border-color:var(--theme-sheet-border)!important}
:is(html[data-palette="arabesque"],html[data-palette="orchidea"],html[data-palette="foresta"]) :is(.reader-editor,.reader-book-copy,.reader-separator h2,.review-original-copy,.review-scene-editor){color:var(--theme-paper-ink)!important}
:is(html[data-palette="arabesque"],html[data-palette="orchidea"],html[data-palette="foresta"]) :is(.reader-scene-label,.reader-separator small,.reader-book-heading small,.reader-book-page-number){color:var(--theme-paper-muted)!important}

/* Brand contrast: reuse approved existing artwork; no new image assets. */
html[data-palette="arabesque"] :is(.sylva-splash-symbol img,.sylva-login-full,.sylva-phone-brand img,.sylva-legal-brand img,.home-logo-full,#rail .brand img){content:url("assets/sylva-logo-fantasy.png")!important}
html[data-palette="arabesque"] .writer-nav-toggle img{content:url("assets/sylva-symbol-fantasy.png")!important}
:is(html[data-palette="orchidea"],html[data-palette="foresta"]) :is(.sylva-splash-symbol img,.sylva-login-full,.sylva-phone-brand img,.sylva-legal-brand img,.home-logo-full,#rail .brand img){content:url("assets/sylva-logo-ivory.png")!important}
:is(html[data-palette="orchidea"],html[data-palette="foresta"]) .writer-nav-toggle img{content:url("assets/sylva-symbol-ivory.png")!important}
:is(html[data-palette="arabesque"],html[data-palette="orchidea"],html[data-palette="foresta"])[data-route]:not([data-route="home"]) .writer-nav-toggle{background:var(--theme-chrome)!important;border-color:color-mix(in srgb,var(--accent) 28%,var(--line))!important;box-shadow:0 8px 22px rgba(0,0,0,.30)!important}

/* Quick Codex and small labels must never inherit an unrelated entry color. */
:is(html[data-palette="arabesque"],html[data-palette="orchidea"],html[data-palette="foresta"])[data-route="writer"] .writer-codex-preview{background:color-mix(in srgb,var(--theme-chrome-soft) 96%,transparent)!important;border-color:var(--line)!important;color:var(--text)!important}
:is(html[data-palette="arabesque"],html[data-palette="orchidea"],html[data-palette="foresta"])[data-route="writer"] .writer-codex-preview :is(.writer-codex-preview-head small,.writer-codex-symbol){color:var(--accent)!important}
:is(html[data-palette="arabesque"],html[data-palette="orchidea"],html[data-palette="foresta"])[data-route="writer"] .writer-codex-preview :is(h3,h4,b,strong,.writer-codex-field-value){color:var(--text)!important}
:is(html[data-palette="arabesque"],html[data-palette="orchidea"],html[data-palette="foresta"])[data-route="writer"] .writer-codex-preview :is(p,small,label,.writer-codex-field-label){color:var(--muted)!important}

/* ==========================================================================
   0.975 · THREE NARRATIVE THEMES — RESIDUAL COLOR HARDENING
   Prevent inherited Fantasy/Thriller hard-coded colors from leaking into
   Arabesco / Mauve Orchid / Foresta. Geometry and feature logic are untouched.
   ========================================================================== */
:is(html[data-palette="arabesque"],html[data-palette="orchidea"],html[data-palette="foresta"])[data-route="reader"] .reader-bar{
  background:color-mix(in srgb,var(--theme-chrome-soft) 96%,transparent)!important;
  color:var(--text)!important;
  border-color:var(--line)!important;
  box-shadow:0 10px 30px color-mix(in srgb,var(--bg) 42%,transparent)!important;
}
:is(html[data-palette="arabesque"],html[data-palette="orchidea"],html[data-palette="foresta"])[data-route="reader"] .reader-position b{color:var(--text)!important}
:is(html[data-palette="arabesque"],html[data-palette="orchidea"],html[data-palette="foresta"])[data-route="reader"] .reader-position small,
:is(html[data-palette="arabesque"],html[data-palette="orchidea"],html[data-palette="foresta"])[data-route="reader"] :is(.reader-icon-btn,.reader-note-btn,.reader-scope,.reader-book-format,.reader-highlight-clear){color:var(--muted)!important}
:is(html[data-palette="arabesque"],html[data-palette="orchidea"],html[data-palette="foresta"])[data-route="reader"] :is(.reader-scope,.reader-book-format){background:var(--theme-chrome-soft)!important;border-color:var(--line)!important}
:is(html[data-palette="arabesque"],html[data-palette="orchidea"],html[data-palette="foresta"])[data-route="reader"] :is(.reader-icon-btn,.reader-note-btn,.reader-highlight-clear):hover{background:var(--accent-soft)!important;color:var(--text)!important}
:is(html[data-palette="arabesque"],html[data-palette="orchidea"],html[data-palette="foresta"])[data-route="reader"] .reader-bar-separator{background:var(--line)!important}

:is(html[data-palette="arabesque"],html[data-palette="orchidea"],html[data-palette="foresta"])[data-route="writer"] #writerView:not(.review-mode) .structure-panel{
  scrollbar-color:color-mix(in srgb,var(--accent) 38%,var(--muted)) transparent!important;
}
:is(html[data-palette="arabesque"],html[data-palette="orchidea"],html[data-palette="foresta"])[data-route="writer"] #writerView:not(.review-mode) .structure-panel .tree-row.context-active{
  background:color-mix(in srgb,var(--accent) 9%,var(--theme-chrome-soft))!important;
  color:var(--text)!important;
  box-shadow:inset 2px 0 0 color-mix(in srgb,var(--accent) 34%,transparent)!important;
  border-color:color-mix(in srgb,var(--accent) 20%,var(--line))!important;
}
:is(html[data-palette="arabesque"],html[data-palette="orchidea"],html[data-palette="foresta"])[data-route="writer"] #writerView:not(.review-mode) .structure-panel .tree-row.context-active :is(.tree-title,.tree-fold,.tree-jump,.tree-drag-handle,.tree-menu){color:inherit!important}
:is(html[data-palette="arabesque"],html[data-palette="orchidea"],html[data-palette="foresta"])[data-route="writer"] #writerView:not(.review-mode) .structure-panel .tree-row:focus-within .tree-menu{
  background:var(--accent-soft)!important;
  color:var(--text)!important;
}

:is(html[data-palette="arabesque"],html[data-palette="orchidea"],html[data-palette="foresta"]) .entry-gate::before{
  background:
    radial-gradient(circle at 14% 18%,color-mix(in srgb,var(--accent) 14%,transparent),transparent 36%),
    radial-gradient(circle at 83% 78%,color-mix(in srgb,var(--accent-2) 11%,transparent),transparent 34%),
    var(--theme-stage-bg)!important;
}
:is(html[data-palette="arabesque"],html[data-palette="orchidea"],html[data-palette="foresta"]) .entry-gate::after{
  opacity:.09!important;
  background-image:
    linear-gradient(color-mix(in srgb,var(--text) 1.7%,transparent) 1px,transparent 1px),
    linear-gradient(90deg,color-mix(in srgb,var(--text) 1.3%,transparent) 1px,transparent 1px)!important;
}


/* ========================================================================== 
   ARABESCO · ATMOSPHERIC WRITER BACKGROUND
   Fine geometric ornament adapted from the supplied reference to Arabesco's
   actual dark brass / teal palette. Decorative only; Writer geometry is intact.
   ========================================================================== */
.arabesque-theme-bg{display:none}
html[data-palette="arabesque"][data-route="writer"] #writerView:not(.review-mode) .editor-stage{background:var(--theme-stage-bg)!important}
html[data-palette="arabesque"][data-route="writer"] #writerView:not(.review-mode) .editor-viewport{position:relative;z-index:1;background:transparent!important}
html[data-palette="arabesque"][data-route="writer"] #writerView:not(.review-mode) :is(.multi-scene-editor,.document-meta){position:relative;z-index:2}
html[data-palette="arabesque"][data-route="writer"] #writerView:not(.review-mode) .document-meta{color:var(--muted)!important}
html[data-palette="arabesque"][data-route="writer"] #writerView:not(.review-mode) .arabesque-theme-bg{
  display:block;position:absolute;inset:0 0 auto 0;width:100%;height:clamp(980px,132vh,1500px);min-height:100svh;overflow:hidden;pointer-events:none;user-select:none;z-index:0;contain:paint;
  background:
    radial-gradient(ellipse at 50% 0%,rgba(224,182,108,.12) 0%,rgba(211,161,78,.055) 21%,transparent 48%),
    radial-gradient(ellipse at 10% 12%,rgba(79,154,145,.075) 0%,transparent 42%),
    radial-gradient(ellipse at 90% 10%,rgba(211,161,78,.065) 0%,transparent 40%),
    linear-gradient(to bottom,#21150f 0%,#24170f 18%,#1f1510 42%,#1a120e 66%,#17110d 100%);
  -webkit-mask-image:linear-gradient(to bottom,#000 0%,#000 72%,rgba(0,0,0,.96) 81%,rgba(0,0,0,.76) 89%,rgba(0,0,0,.44) 95%,rgba(0,0,0,.16) 98%,transparent 100%);
  mask-image:linear-gradient(to bottom,#000 0%,#000 72%,rgba(0,0,0,.96) 81%,rgba(0,0,0,.76) 89%,rgba(0,0,0,.44) 95%,rgba(0,0,0,.16) 98%,transparent 100%);
}
.arabesque-theme-top-frieze{position:absolute;left:0;right:0;top:0;width:100%;height:13%;opacity:.52;z-index:2}
.arabesque-theme-main-lattice{position:absolute;left:0;right:0;top:14%;width:100%;height:51%;opacity:.44;z-index:1;-webkit-mask-image:linear-gradient(to bottom,#000 0%,#000 53%,rgba(0,0,0,.84) 70%,rgba(0,0,0,.44) 86%,transparent 100%);mask-image:linear-gradient(to bottom,#000 0%,#000 53%,rgba(0,0,0,.84) 70%,rgba(0,0,0,.44) 86%,transparent 100%)}
.arabesque-theme-center-ornament{position:absolute;left:50%;top:21%;width:min(36vw,390px);transform:translateX(-50%);opacity:.10;z-index:1}
.arabesque-theme-specks{position:absolute;inset:0;width:100%;height:100%;opacity:.20}
.arabesque-theme-light-veil{position:absolute;inset:0;background:linear-gradient(to bottom,rgba(255,231,184,.035) 0%,rgba(211,161,78,.018) 25%,transparent 62%),radial-gradient(ellipse at 50% 10%,rgba(224,182,108,.075) 0 14%,rgba(79,154,145,.018) 26%,transparent 44%)}
.arabesque-theme-bottom-fade{position:absolute;left:-5%;right:-5%;bottom:-2%;height:29%;background:linear-gradient(to bottom,rgba(23,17,13,0) 0%,rgba(23,17,13,.07) 18%,rgba(23,17,13,.20) 37%,rgba(23,17,13,.44) 58%,rgba(23,17,13,.70) 78%,rgba(23,17,13,.92) 94%,#17110d 100%);filter:blur(10px)}
@media(max-width:1024px){html[data-palette="arabesque"][data-route="writer"] #writerView:not(.review-mode) .arabesque-theme-bg{height:clamp(900px,122vh,1260px)}.arabesque-theme-main-lattice{opacity:.39}.arabesque-theme-center-ornament{width:min(44vw,340px);opacity:.08}}
@media(max-width:720px){html[data-palette="arabesque"][data-route="writer"] #writerView:not(.review-mode) .arabesque-theme-bg{height:clamp(820px,110vh,1040px)}.arabesque-theme-top-frieze{height:14%;opacity:.42}.arabesque-theme-main-lattice{top:15%;height:50%;opacity:.34}.arabesque-theme-center-ornament{top:22%;opacity:.08}.arabesque-theme-specks{opacity:.13}}

/* ========================================================================== 
   ORCHIDEA · ATMOSPHERIC WRITER BACKGROUND
   Mauve Orchid gets its own vellutato botanical stage, matching the supplied
   reference and staying within the palette already used by the theme.
   ========================================================================== */
.orchid-theme-bg{display:none}

html[data-palette="orchidea"][data-route="writer"] #writerView:not(.review-mode) .editor-stage{
  background:var(--theme-stage-bg)!important;
}
html[data-palette="orchidea"][data-route="writer"] #writerView:not(.review-mode) .editor-viewport{
  position:relative;
  z-index:1;
  background:transparent!important;
}
html[data-palette="orchidea"][data-route="writer"] #writerView:not(.review-mode) .multi-scene-editor,
html[data-palette="orchidea"][data-route="writer"] #writerView:not(.review-mode) .document-meta{
  position:relative;
  z-index:2;
}
html[data-palette="orchidea"][data-route="writer"] #writerView:not(.review-mode) .document-meta{color:var(--muted)!important}
html[data-palette="orchidea"][data-route="writer"] #writerView:not(.review-mode) .orchid-theme-bg{
  display:block;
  position:absolute;
  inset:0 0 auto 0;
  width:100%;
  height:clamp(980px,132vh,1500px);
  min-height:100svh;
  overflow:hidden;
  pointer-events:none;
  user-select:none;
  z-index:0;
  contain:paint;
  background:
    radial-gradient(circle at 14% 8%,rgba(182,130,153,.19),transparent 27%),
    radial-gradient(circle at 87% 12%,rgba(212,169,185,.13),transparent 24%),
    radial-gradient(ellipse at 55% 2%,rgba(121,71,95,.18),transparent 42%),
    linear-gradient(145deg,#21161e 0%,#33222c 55%,#251a22 100%);
  -webkit-mask-image:linear-gradient(to bottom,#000 0%,#000 72%,rgba(0,0,0,.96) 80%,rgba(0,0,0,.84) 88%,rgba(0,0,0,.56) 94%,rgba(0,0,0,.22) 98%,transparent 100%);
  mask-image:linear-gradient(to bottom,#000 0%,#000 72%,rgba(0,0,0,.96) 80%,rgba(0,0,0,.84) 88%,rgba(0,0,0,.56) 94%,rgba(0,0,0,.22) 98%,transparent 100%);
}
.orchid-theme-haze{
  position:absolute;inset:0;
  background:
    radial-gradient(ellipse at 18% 24%,rgba(182,130,153,.13),transparent 35%),
    radial-gradient(ellipse at 70% 18%,rgba(212,169,185,.10),transparent 32%),
    radial-gradient(ellipse at 42% 42%,rgba(111,64,87,.11),transparent 42%);
  filter:blur(18px);
}
.orchid-theme-bloom-glow{
  position:absolute;inset:0;
  background:
    radial-gradient(circle at 11% 18%,rgba(212,169,185,.13) 0 4%,transparent 12%),
    radial-gradient(circle at 29% 33%,rgba(182,130,153,.09) 0 3%,transparent 11%),
    radial-gradient(circle at 72% 25%,rgba(212,169,185,.10) 0 4%,transparent 12%),
    radial-gradient(circle at 90% 16%,rgba(182,130,153,.13) 0 4%,transparent 12%);
  filter:blur(15px);
}
.orchid-theme-botanical{
  position:absolute;inset:0;width:100%;height:72%;opacity:.82;
  -webkit-mask-image:linear-gradient(to bottom,#000 0%,#000 62%,rgba(0,0,0,.82) 76%,rgba(0,0,0,.42) 90%,transparent 100%);
  mask-image:linear-gradient(to bottom,#000 0%,#000 62%,rgba(0,0,0,.82) 76%,rgba(0,0,0,.42) 90%,transparent 100%);
}
.orchid-theme-botanical.far{opacity:.27;filter:blur(1.2px);transform:scale(1.055) translateY(2%);transform-origin:center top}
.orchid-theme-light{position:absolute;inset:0;background:radial-gradient(ellipse at 56% 1%,rgba(242,232,237,.07),transparent 35%),linear-gradient(to bottom,rgba(255,255,255,.025),transparent 55%)}
.orchid-theme-bottom-softener{
  position:absolute;left:-5%;right:-5%;bottom:-2%;height:28%;
  background:linear-gradient(to bottom,rgba(37,26,34,0) 0%,rgba(37,26,34,.08) 18%,rgba(37,26,34,.24) 38%,rgba(37,26,34,.48) 60%,rgba(37,26,34,.74) 80%,rgba(37,26,34,.94) 94%,#251a22 100%);
  filter:blur(13px);
}
@media(max-width:1024px){
  html[data-palette="orchidea"][data-route="writer"] #writerView:not(.review-mode) .orchid-theme-bg{height:clamp(900px,122vh,1260px)}
  .orchid-theme-botanical{opacity:.76}
}
@media(max-width:720px){
  html[data-palette="orchidea"][data-route="writer"] #writerView:not(.review-mode) .orchid-theme-bg{height:clamp(820px,110vh,1040px)}
  .orchid-theme-botanical{opacity:.68}
  .orchid-theme-botanical.far{opacity:.20}
}

/* ========================================================================== 
   FORESTA · ATMOSPHERIC WRITER BACKGROUND
   Same visual language as the supplied misty-forest reference, but anchored
   to Foresta's actual dark teal/forest palette. The atmospheric layer covers
   at least the first full viewport before any fade can become visible.
   ========================================================================== */
.forest-theme-bg{display:none}

html[data-palette="foresta"][data-route="writer"] #writerView:not(.review-mode) .editor-stage{
  background:var(--theme-stage-bg)!important;
}
html[data-palette="foresta"][data-route="writer"] #writerView:not(.review-mode) .editor-viewport{
  position:relative;
  z-index:1;
  background:transparent!important;
}
html[data-palette="foresta"][data-route="writer"] #writerView:not(.review-mode) .multi-scene-editor{
  position:relative;
  z-index:2;
}
html[data-palette="foresta"][data-route="writer"] #writerView:not(.review-mode) .document-meta{
  position:relative;
  z-index:2;
  color:var(--muted)!important;
}
html[data-palette="foresta"][data-route="writer"] #writerView:not(.review-mode) .forest-theme-bg{
  --forest-deep:#0b1717;
  --forest-base:#0e1b1b;
  --forest-mid:#16302d;
  --forest-sage:#73958b;
  --forest-mist:#9eb4ac;
  --forest-warm:#d3a46a;
  display:block;
  position:absolute;
  inset:0 0 auto 0;
  width:100%;
  height:clamp(980px,132vh,1480px);
  min-height:100svh;
  overflow:hidden;
  pointer-events:none;
  user-select:none;
  z-index:0;
  contain:paint;
  background:
    radial-gradient(ellipse at 58% 3%,rgba(211,164,106,.16) 0 8%,rgba(178,174,123,.07) 25%,transparent 52%),
    radial-gradient(ellipse at 14% 11%,rgba(58,111,102,.22) 0 20%,transparent 57%),
    radial-gradient(ellipse at 90% 8%,rgba(42,91,83,.20) 0 19%,transparent 56%),
    radial-gradient(ellipse at 50% 66%,rgba(94,132,121,.10) 0 24%,transparent 60%),
    linear-gradient(to bottom,#102824 0%,#15312d 20%,#17332f 42%,#142b28 66%,#112320 82%,var(--forest-base) 100%);
  -webkit-mask-image:linear-gradient(
    to bottom,
    #000 0%,
    #000 72%,
    rgba(0,0,0,.98) 80%,
    rgba(0,0,0,.90) 86%,
    rgba(0,0,0,.70) 91%,
    rgba(0,0,0,.43) 95%,
    rgba(0,0,0,.18) 98%,
    transparent 100%
  );
  mask-image:linear-gradient(
    to bottom,
    #000 0%,
    #000 72%,
    rgba(0,0,0,.98) 80%,
    rgba(0,0,0,.90) 86%,
    rgba(0,0,0,.70) 91%,
    rgba(0,0,0,.43) 95%,
    rgba(0,0,0,.18) 98%,
    transparent 100%
  );
}
.forest-theme-rays{
  position:absolute;
  inset:-9% 0 37%;
  opacity:.18;
  filter:blur(25px);
  background:
    linear-gradient(106deg,transparent 0 42%,rgba(211,164,106,.20) 46%,rgba(159,184,165,.09) 49%,transparent 54%),
    linear-gradient(101deg,transparent 0 56%,rgba(177,194,174,.13) 59%,transparent 65%);
}
.forest-theme-canopy{
  position:absolute;
  inset:-7% -6% 51%;
  opacity:.58;
  filter:blur(14px);
  background:
    radial-gradient(ellipse at 0% 16%,rgba(4,20,17,.72) 0 13%,transparent 31%),
    radial-gradient(ellipse at 12% 4%,rgba(10,35,30,.67) 0 12%,transparent 30%),
    radial-gradient(ellipse at 25% 8%,rgba(26,61,52,.44) 0 11%,transparent 28%),
    radial-gradient(ellipse at 100% 11%,rgba(4,19,17,.70) 0 13%,transparent 31%),
    radial-gradient(ellipse at 88% 1%,rgba(10,35,30,.63) 0 12%,transparent 30%),
    radial-gradient(ellipse at 77% 7%,rgba(29,67,57,.40) 0 11%,transparent 28%);
}
.forest-theme-edge-foliage{position:absolute;inset:0;opacity:.28;filter:blur(4px)}
.forest-theme-edge-foliage::before,.forest-theme-edge-foliage::after{
  content:"";
  position:absolute;
  top:4%;
  width:21%;
  height:31%;
  background:
    radial-gradient(circle at 10% 20%,rgba(8,31,26,.58) 0 4%,transparent 5%),
    radial-gradient(circle at 22% 10%,rgba(20,55,47,.50) 0 5%,transparent 6%),
    radial-gradient(circle at 30% 22%,rgba(14,44,37,.52) 0 4%,transparent 5%),
    radial-gradient(circle at 40% 12%,rgba(50,89,76,.38) 0 5%,transparent 6%),
    radial-gradient(circle at 18% 34%,rgba(18,52,44,.44) 0 5%,transparent 6%);
}
.forest-theme-edge-foliage::before{left:-2%}
.forest-theme-edge-foliage::after{right:-2%;transform:scaleX(-1)}
.forest-theme-trunk-layer{position:absolute;inset:-1% 0 0;height:116%}
.forest-theme-trunk{
  position:absolute;
  top:var(--top,0%);
  left:var(--left);
  width:var(--w);
  height:var(--h);
  transform:rotate(var(--rot,0deg));
  transform-origin:center top;
  border-radius:48% 52% 18% 20%;
  opacity:var(--o,.4);
  filter:blur(var(--blur,.8px));
  background:linear-gradient(
    to bottom,
    rgba(104,148,136,0) 0%,
    rgba(104,148,136,.16) 3%,
    rgba(109,151,139,.45) 16%,
    rgba(102,145,133,.48) 48%,
    rgba(82,125,113,.30) 73%,
    rgba(60,105,94,.12) 88%,
    rgba(60,105,94,0) 100%
  );
}
.forest-theme-trunk.strong{
  background:linear-gradient(
    to bottom,
    rgba(3,19,16,0) 0%,
    rgba(4,25,21,.23) 3%,
    rgba(7,35,29,.66) 16%,
    rgba(7,35,29,.72) 48%,
    rgba(12,47,39,.48) 74%,
    rgba(22,62,52,.18) 90%,
    rgba(22,62,52,0) 100%
  );
}
.forest-theme-haze{
  position:absolute;
  inset:28% -10% 0;
  background:
    radial-gradient(ellipse at 12% 28%,rgba(113,151,139,.18) 0 18%,transparent 53%),
    radial-gradient(ellipse at 48% 20%,rgba(143,169,158,.20) 0 25%,transparent 55%),
    radial-gradient(ellipse at 84% 34%,rgba(102,143,131,.17) 0 22%,transparent 53%);
  filter:blur(28px);
}
.forest-theme-haze::before,.forest-theme-haze::after{
  content:"";
  position:absolute;
  left:-5%;
  right:-5%;
  border-radius:50%;
}
.forest-theme-haze::before{top:50%;height:14%;background:rgba(118,151,141,.10);filter:blur(30px)}
.forest-theme-haze::after{top:67%;height:25%;background:rgba(76,116,105,.13);filter:blur(44px)}
.forest-theme-bottom-softener{
  position:absolute;
  left:-6%;
  right:-6%;
  bottom:-1%;
  height:27%;
  background:linear-gradient(
    to bottom,
    rgba(14,27,27,0) 0%,
    rgba(14,27,27,.04) 22%,
    rgba(14,27,27,.14) 43%,
    rgba(14,27,27,.34) 64%,
    rgba(14,27,27,.62) 82%,
    rgba(14,27,27,.88) 94%,
    var(--forest-base) 100%
  );
  filter:blur(12px);
}
@media (max-width:1024px){
  html[data-palette="foresta"][data-route="writer"] #writerView:not(.review-mode) .forest-theme-bg{
    height:clamp(900px,125vh,1320px);
  }
}
@media (max-width:720px){
  html[data-palette="foresta"][data-route="writer"] #writerView:not(.review-mode) .forest-theme-bg{
    height:clamp(840px,118vh,1120px);
  }
  .forest-theme-edge-foliage{opacity:.19}
  .forest-theme-rays{opacity:.14}
}


/* ========================================================================== 
   0.975 · THEME BRANDING + SAGA VISIBILITY PATCH · 2026-08-17
   Applies coordinated logo/symbol assets per theme without changing layout.
   Also lifts saga-card mark visibility only where the mark was too faint.
   ========================================================================== */

/* Coordinated full lockups for themes that now have dedicated logo assets. */
html[data-theme="alba"] :is(.sylva-splash-symbol img,.sylva-login-full,.sylva-phone-brand img,.sylva-legal-brand img,.home-logo-full,#rail .brand img){
  content:url("assets/sylva-logo-alba.png")!important;
}
html[data-theme="crepuscolo"] :is(.sylva-splash-symbol img,.sylva-login-full,.sylva-phone-brand img,.sylva-legal-brand img,.home-logo-full,#rail .brand img){
  content:url("assets/sylva-logo-crepuscolo.png")!important;
}
html[data-palette="arabesque"] :is(.sylva-splash-symbol img,.sylva-login-full,.sylva-phone-brand img,.sylva-legal-brand img,.home-logo-full,#rail .brand img){
  content:url("assets/sylva-logo-arabesque.png")!important;
}
/* For Orchidea and Foresta only the dedicated symbol is currently available.
   Keep the readable full lockup already used in app, but swap the symbolized
   contexts below so every theme still shows its own emblem. */

/* Compact emblem contexts: drawer toggle, empty-state symbol and saga mark. */
html[data-theme="alba"] :is(.writer-nav-toggle img,.sylva-empty img,.saga-botanical){
  background-image:url("assets/sylva-symbol-alba.png")!important;
  content:url("assets/sylva-symbol-alba.png")!important;
}
html[data-theme="crepuscolo"] :is(.writer-nav-toggle img,.sylva-empty img,.saga-botanical){
  background-image:url("assets/sylva-symbol-crepuscolo.png")!important;
  content:url("assets/sylva-symbol-crepuscolo.png")!important;
}
html[data-palette="arabesque"] :is(.writer-nav-toggle img,.sylva-empty img,.saga-botanical){
  background-image:url("assets/sylva-symbol-arabesque.png")!important;
  content:url("assets/sylva-symbol-arabesque.png")!important;
}
html[data-palette="orchidea"] :is(.writer-nav-toggle img,.sylva-empty img,.saga-botanical){
  background-image:url("assets/sylva-symbol-orchidea.png")!important;
  content:url("assets/sylva-symbol-orchidea.png")!important;
}
html[data-palette="foresta"] :is(.writer-nav-toggle img,.sylva-empty img,.saga-botanical){
  background-image:url("assets/sylva-symbol-foresta.png")!important;
  content:url("assets/sylva-symbol-foresta.png")!important;
}

/* Keep saga card geometry identical; only improve perceived visibility. */
html[data-theme="alba"] .sylva-saga-card,
html[data-theme="alba"] .sylva-saga-card:nth-child(n){
  border-color:rgba(71,92,78,.12)!important;
}
html[data-theme="crepuscolo"] .sylva-saga-card,
html[data-theme="crepuscolo"] .sylva-saga-card:nth-child(n){
  border-color:rgba(227,221,207,.12)!important;
}
:is(html[data-palette="arabesque"],html[data-palette="orchidea"],html[data-palette="foresta"]) .sylva-saga-card,
:is(html[data-palette="arabesque"],html[data-palette="orchidea"],html[data-palette="foresta"]) .sylva-saga-card:nth-child(n){
  box-shadow:inset 0 1px rgba(255,255,255,.03)!important;
}

/* The mark was nearly disappearing in a few palettes. Increase only the emblem
   opacity slightly and keep its position/size untouched. */
html[data-theme="alba"] .saga-botanical{opacity:.18!important;filter:none!important}
html[data-theme="crepuscolo"] .saga-botanical{opacity:.14!important;filter:none!important}
html[data-palette="arabesque"] .saga-botanical{opacity:.17!important;filter:none!important}
html[data-palette="orchidea"] .saga-botanical{opacity:.18!important;filter:none!important}
html[data-palette="foresta"] .saga-botanical{opacity:.17!important;filter:none!important}

/* Ensure the empty-library emblem preserves its intended sizing after the swap. */
.sylva-empty img{object-fit:contain!important}


/* ========================================================================== 
   0.975 · LOGO QA PATCH · 2026-08-17
   - Arabesco top-left logo no longer looks undersized.
   - Modern logo swapped to a higher-contrast lockup on light surfaces.
   - Tablet responsive button / tutorial brand contexts explicitly covered.
   ========================================================================== */

/* Modern: force the readable high-contrast lockup everywhere the full logo appears. */
html[data-theme="modern"] :is(.sylva-splash-symbol img,.sylva-login-full,.sylva-phone-brand img,.sylva-legal-brand img,.home-logo-full,#rail .brand img){
  content:url("assets/sylva-logo-modern-contrast.png")!important;
  filter:none!important;
}
html[data-theme="modern"] :is(.writer-nav-toggle img,.sylva-empty img,.saga-botanical){
  content:url("assets/sylva-symbol-modern.png")!important;
  background-image:url("assets/sylva-symbol-modern.png")!important;
}

/* Arabesco: same theme logo, but with trimmed canvas + slight size compensation. */
html[data-palette="arabesque"] :is(.sylva-splash-symbol img,.sylva-login-full,.sylva-phone-brand img,.sylva-legal-brand img,.home-logo-full,#rail .brand img){
  content:url("assets/sylva-logo-arabesque-tight.png")!important;
  filter:none!important;
}
html[data-palette="arabesque"] :is(.writer-nav-toggle img,.sylva-empty img,.saga-botanical){
  content:url("assets/sylva-symbol-arabesque.png")!important;
  background-image:url("assets/sylva-symbol-arabesque.png")!important;
}
html[data-palette="arabesque"] #rail .brand img{
  width:144px!important;
  max-height:64px!important;
}
html[data-palette="arabesque"] .sylva-phone-brand img{width:142px!important}
html[data-palette="arabesque"] .sylva-legal-brand img{width:124px!important}
html[data-palette="arabesque"][data-route="home"] .home-logo-full{
  max-width:min(288px,76vw)!important;
}

/* Small visibility polish for the brand mark in the saga card when needed. */
html[data-theme="modern"] .saga-botanical{opacity:.15!important;filter:none!important}
html[data-palette="arabesque"] .saga-botanical{opacity:.18!important;filter:none!important}


/* ========================================================================== 
   0.975 · BRAND LOGO NORMALIZATION · 2026-08-17
   User-approved mapping:
   - Modern     -> Sylva chiaro
   - Alba       -> Sylva chiaro
   - Crepuscolo -> Crepuscolo
   - Orchidea   -> Crepuscolo
   - Arabesco   -> Sylva scuro
   Applies to Home, rail/menu, tablet drawer toggle, saga mark, empty states,
   login/tutorial/phone/legal brand contexts.
   ========================================================================== */

/* FULL LOCKUP CONTEXTS */
:is(html[data-theme="modern"],html[data-theme="alba"]) :is(.sylva-splash-symbol img,.sylva-login-full,.sylva-phone-brand img,.sylva-legal-brand img,.home-logo-full,#rail .brand img){
  content:url("assets/sylva-logo-green.png")!important;
  filter:none!important;
}
html[data-theme="crepuscolo"] :is(.sylva-splash-symbol img,.sylva-login-full,.sylva-phone-brand img,.sylva-legal-brand img,.home-logo-full,#rail .brand img),
html[data-palette="orchidea"] :is(.sylva-splash-symbol img,.sylva-login-full,.sylva-phone-brand img,.sylva-legal-brand img,.home-logo-full,#rail .brand img){
  content:url("assets/sylva-logo-crepuscolo.png")!important;
  filter:none!important;
}
html[data-palette="arabesque"] :is(.sylva-splash-symbol img,.sylva-login-full,.sylva-phone-brand img,.sylva-legal-brand img,.home-logo-full,#rail .brand img){
  content:url("assets/sylva-logo-ivory.png")!important;
  filter:none!important;
}

/* COMPACT SYMBOL CONTEXTS */
:is(html[data-theme="modern"],html[data-theme="alba"]) :is(.writer-nav-toggle img,.sylva-empty img,.saga-botanical,.sylva-map-empty-card img){
  content:url("assets/sylva-symbol-green.png")!important;
  background-image:url("assets/sylva-symbol-green.png")!important;
}
html[data-theme="crepuscolo"] :is(.writer-nav-toggle img,.sylva-empty img,.saga-botanical,.sylva-map-empty-card img),
html[data-palette="orchidea"] :is(.writer-nav-toggle img,.sylva-empty img,.saga-botanical,.sylva-map-empty-card img){
  content:url("assets/sylva-symbol-crepuscolo.png")!important;
  background-image:url("assets/sylva-symbol-crepuscolo.png")!important;
}
html[data-palette="arabesque"] :is(.writer-nav-toggle img,.sylva-empty img,.saga-botanical,.sylva-map-empty-card img){
  content:url("assets/sylva-symbol-ivory.png")!important;
  background-image:url("assets/sylva-symbol-ivory.png")!important;
}

/* Keep saga emblem comfortably visible without changing layout. */
:is(html[data-theme="modern"],html[data-theme="alba"]) .saga-botanical{opacity:.17!important;filter:none!important}
html[data-theme="crepuscolo"] .saga-botanical,
html[data-palette="orchidea"] .saga-botanical{opacity:.16!important;filter:none!important}
html[data-palette="arabesque"] .saga-botanical{opacity:.17!important;filter:none!important}

/* Tablet header sizing polish: Arabesco / Crepuscolo-family lockups need a bit
   more width, while Sylva-chiaro mapping stays readable on light surfaces. */
:is(html[data-theme="modern"],html[data-theme="alba"],html[data-theme="crepuscolo"],html[data-palette="arabesque"],html[data-palette="orchidea"]) #rail .brand img{
  opacity:1!important;
  max-height:64px!important;
}
html[data-palette="arabesque"] #rail .brand img,
html[data-palette="orchidea"] #rail .brand img,
html[data-theme="crepuscolo"] #rail .brand img{width:144px!important}
html[data-theme="modern"] #rail .brand img,
html[data-theme="alba"] #rail .brand img{width:142px!important}


/* ========================================================================== 
   0.977 · COLLAPSIBLE GLOBAL RAIL · 2026-08-18
   Desktop now behaves like tablet: the lateral rail is an overlay drawer.
   Writer uses the existing branded writerNavToggle; other routes use mobileMenu.
   ========================================================================== */
@media (min-width:1367px), (min-width:901px) and (pointer:fine){
  .app-shell{
    grid-template-columns:minmax(0,1fr)!important;
    grid-template-rows:68px minmax(0,1fr)!important;
  }
  .topbar{grid-column:1!important;grid-row:1!important}
  .main-area{grid-column:1!important;grid-row:2!important}
  #rail{
    position:fixed!important;
    left:12px!important;top:12px!important;bottom:12px!important;
    width:76px!important;height:auto!important;
    transform:translate3d(-104px,0,0)!important;
    opacity:0!important;pointer-events:none!important;
    z-index:220!important;
    overflow-y:auto!important;overflow-x:hidden!important;
    scrollbar-width:none!important;
    transition:transform .28s cubic-bezier(.2,.8,.2,1),opacity .18s ease!important;
  }
  #rail::-webkit-scrollbar{display:none!important}
  #rail.open,
  html[data-route="writer"].writer-chrome-open #rail{
    transform:translate3d(0,0,0)!important;
    opacity:1!important;pointer-events:auto!important;
  }
  
  
  html[data-route="writer"] .writer-nav-toggle{
    display:grid!important;
    position:fixed!important;
    left:max(18px,calc(env(safe-area-inset-left) + 12px))!important;
    top:max(18px,calc(env(safe-area-inset-top) + 12px))!important;
    width:52px!important;height:52px!important;padding:6px!important;
    border-radius:14px!important;z-index:230!important;
  }
  html[data-route="writer"] .writer-nav-toggle img{width:40px!important;height:40px!important;object-fit:contain!important}
  html[data-route="writer"] .topbar{padding-left:82px!important}
}


/* Home keeps its clean full-canvas layout, but the lateral menu remains reachable.
   The same branded toggle used by Writer summons the drawer; phone-only mode stays unchanged. */
html[data-route="home"]:not(.phone-only) #rail{display:flex!important}
html[data-route="home"]:not(.phone-only) .writer-nav-toggle{
  display:grid!important;place-items:center!important;
  position:fixed!important;
  left:max(14px,calc(env(safe-area-inset-left) + 10px))!important;
  top:max(14px,calc(env(safe-area-inset-top) + 10px))!important;
  width:52px!important;height:52px!important;padding:6px!important;
  border:1px solid rgba(118,106,88,.22)!important;
  border-radius:14px!important;
  background:linear-gradient(180deg,#f3eee5,#e5dac9)!important;
  box-shadow:0 8px 26px rgba(0,0,0,.12)!important;
  backdrop-filter:blur(16px)!important;
  z-index:230!important;
}
html[data-route="home"]:not(.phone-only) .writer-nav-toggle img{width:40px!important;height:40px!important;object-fit:contain!important}
/* Home navigation button follows the active theme so the mapped symbol always has contrast. */
html[data-theme="sylva-dark"][data-route="home"] .writer-nav-toggle,
html[data-theme="fantasy"][data-route="home"] .writer-nav-toggle,
html[data-theme="thriller"][data-route="home"] .writer-nav-toggle,
html[data-theme="cyberpunk"][data-route="home"] .writer-nav-toggle,
html[data-theme="crepuscolo"][data-route="home"] .writer-nav-toggle,
html[data-palette="arabesque"][data-route="home"] .writer-nav-toggle,
html[data-palette="orchidea"][data-route="home"] .writer-nav-toggle,
html[data-palette="foresta"][data-route="home"] .writer-nav-toggle{
  background:var(--theme-chrome,var(--surface-strong))!important;
  border-color:color-mix(in srgb,var(--accent) 26%,var(--line))!important;
}
html[data-theme="sylva"][data-route="home"] .writer-nav-toggle,
html[data-theme="modern"][data-route="home"] .writer-nav-toggle,
html[data-theme="alba"][data-route="home"] .writer-nav-toggle{
  background:#f8f4ed!important;
  border-color:rgba(62,68,60,.13)!important;
}
/* Writer desktop had a historical 224px permanent column. When that rail becomes a
   drawer, keep its established width/labels but remove the reserved grid column. */
@media (min-width:1367px), (min-width:901px) and (pointer:fine){
  html[data-route="writer"] .app-shell{
    grid-template-columns:minmax(0,1fr)!important;
    grid-template-rows:72px minmax(0,1fr)!important;
  }
  html[data-route="writer"] .topbar{
    grid-column:1!important;grid-row:1!important;
    width:100%!important;
    padding-left:82px!important;
  }
  html[data-route="writer"] .main-area{
    grid-column:1!important;grid-row:2!important;
    width:100%!important;
    height:calc(100dvh - 72px)!important;
  }
  html[data-route="writer"] #rail{
    width:224px!important;
    grid-column:auto!important;grid-row:auto!important;
    padding:18px 12px!important;
  }
}
/* Preserve the established wide desktop rail content; only its presence changes.
   All non-Home views used a 224px labelled rail before this patch. */
@media (min-width:1367px), (min-width:901px) and (pointer:fine){
  html[data-route]:not([data-route="home"]) .app-shell{
    grid-template-columns:minmax(0,1fr)!important;
    grid-template-rows:72px minmax(0,1fr)!important;
    gap:0!important;padding:0!important;
  }
  html[data-route]:not([data-route="home"]) .topbar{
    grid-column:1!important;grid-row:1!important;
  }
  html[data-route]:not([data-route="home"]) .main-area{
    grid-column:1!important;grid-row:2!important;
    width:100%!important;
  }
  html[data-route]:not([data-route="home"]) #rail{
    left:0!important;top:0!important;bottom:0!important;
    width:224px!important;height:100dvh!important;
    grid-column:auto!important;grid-row:auto!important;
    padding:14px 12px 13px!important;
  }
  html[data-route="writer"] #rail{
    padding:74px 12px 13px!important;
  }
  html[data-route="writer"] #rail .brand{display:none!important}
}

/* On Home the drawer is intentionally compact; the external Sylva button is
   already the visual brand/close control, so avoid placing a second logo under it. */
html[data-route="home"]:not(.phone-only) #rail{
  padding-top:74px!important;
  overflow-y:auto!important;overflow-x:hidden!important;
}
html[data-route="home"]:not(.phone-only) #rail .brand{display:none!important}
html[data-theme="sylva-dark"] .writer-nav-toggle img{content:url("assets/sylva-symbol-ivory.png")!important}
/* Desktop close control: the same menu button that opens the drawer stays reachable
   above it. When open it slides into the reserved top-right corner of the 224px rail. */
@media (min-width:1367px), (min-width:901px) and (pointer:fine){
  
  
  html[data-route]:not([data-route="home"]):not([data-route="writer"]) .topbar-left{
    padding-left:56px!important;
  }
}

/* Final desktop drawer correction: the labelled 224px rail must be completely
   off-canvas when closed. The earlier compact-rail offset was only 104px. */
@media (min-width:1367px), (min-width:901px) and (pointer:fine){
  html[data-route]:not([data-route="home"]) #rail:not(.open){
    transform:translate3d(-244px,0,0)!important;
  }
  html[data-route="writer"].writer-chrome-open #rail{
    transform:translate3d(0,0,0)!important;
  }
}


/* ========================================================================== 
   0.977 · DESKTOP DRAWER QA2 · 2026-08-18
   Final normalization after the collapsible-rail pass.
   - One branded menu toggle on desktop, matching tablet behaviour.
   - Prevents the 901–1100px fine-pointer overlap between old tablet rules and
     the new desktop drawer rules.
   - Keeps Reader navigation reachable even though Reader intentionally hides
     the normal topbar.
   - Normalizes the 72px desktop grid so old 66px tablet metrics cannot leak in.
   ========================================================================== */
@media (min-width:1367px), (min-width:901px) and (pointer:fine){
  /* Desktop uses the external Sylva mark, exactly like tablet. The hamburger
     inside the topbar is kept for the smaller/tablet layout only. */
  
  html[data-route]:not([data-route="home"]) .writer-nav-toggle{
    display:grid!important;place-items:center!important;
    position:fixed!important;
    left:max(18px,calc(env(safe-area-inset-left) + 12px))!important;
    top:max(18px,calc(env(safe-area-inset-top) + 12px))!important;
    width:52px!important;height:52px!important;min-width:52px!important;min-height:52px!important;
    padding:6px!important;border-radius:14px!important;
    background:var(--theme-chrome,var(--surface-strong,#f8f4ed))!important;
    color:var(--text)!important;
    border:1px solid color-mix(in srgb,var(--accent) 24%,var(--line))!important;
    box-shadow:0 8px 26px rgba(0,0,0,.14)!important;
    backdrop-filter:blur(16px)!important;
    -webkit-backdrop-filter:blur(16px)!important;
    z-index:230!important;
    transition:left .28s cubic-bezier(.2,.8,.2,1),transform .18s ease,background .18s ease,border-color .18s ease!important;
  }
  html[data-route]:not([data-route="home"]) .writer-nav-toggle img{
    display:block!important;width:40px!important;height:40px!important;object-fit:contain!important;
  }

  /* In Writer the brand is hidden inside the rail and the toggle occupies its
     reserved top-left slot. Other modules keep their full logo, so the close
     toggle moves just outside the 224px drawer instead of covering the lockup. */
  html[data-route]:not([data-route="home"]):not([data-route="writer"]).writer-chrome-open .writer-nav-toggle{
    left:max(236px,calc(env(safe-area-inset-left) + 230px))!important;
  }
  html[data-route]:not([data-route="home"]):not([data-route="writer"]).writer-chrome-open .writer-nav-toggle img{
    transform:rotate(-8deg) scale(.94)!important;
  }

  /* A 901–1100px desktop window also matches historical tablet-width rules.
     Reassert the desktop row metrics after them so there is no 66/72px mismatch
     or extra left padding. */
  html[data-route]:not([data-route="home"]) .topbar{
    height:72px!important;min-height:72px!important;
    padding-left:82px!important;padding-right:16px!important;
  }
  html[data-route]:not([data-route="home"]) .topbar-left{padding-left:0!important}
  html[data-route]:not([data-route="home"]) .main-area{
    height:calc(100dvh - 72px)!important;min-height:0!important;
  }
}

/* ========================================================================== 
   SYLVA 0.977 · TIMELINE ERA + COMPLETE CODEX PICKER · 2026-08-18
   ========================================================================== */

/* Timeline: surface the calendar era instead of hiding it inside formatted dates. */
.timeline-stats{grid-template-columns:repeat(5,minmax(0,1fr))}
.timeline-era-stat b{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.timeline-era-field{min-height:43px;display:flex;align-items:center;justify-content:space-between;gap:12px;padding:9px 11px;border:1px solid var(--line);border-radius:12px;background:var(--surface-2);color:var(--text)}
.timeline-era-field b{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:13px;font-weight:600}
.timeline-era-field small{flex:0 0 auto;color:var(--muted);font-size:9px;line-height:1.3;text-align:right}
.timeline-pill.codex{border-style:dashed;background:color-mix(in srgb,var(--event-color) 8%,var(--surface-2))}

/* Timeline event editor: full, searchable Codex picker. */
.timeline-event-modal{width:min(940px,calc(100vw - 28px))}
.timeline-codex-section{margin-top:3px;padding:17px;border:1px solid var(--line);border-radius:18px;background:color-mix(in srgb,var(--surface-2) 78%,transparent);min-width:0}
.timeline-codex-head{display:flex;align-items:flex-end;justify-content:space-between;gap:18px;margin-bottom:13px}
.timeline-codex-head>div{min-width:0}.timeline-codex-head small{display:block;color:var(--accent);font-size:8px;font-weight:700;letter-spacing:.13em}.timeline-codex-head h3{margin:4px 0 3px;font-family:var(--ui-serif,inherit);font-size:18px;font-weight:550}.timeline-codex-head p{margin:0;color:var(--muted);font-size:10px;line-height:1.45}.timeline-codex-head>span{flex:0 0 auto;color:var(--muted);font-size:9px;white-space:nowrap}
.timeline-codex-search{position:relative;margin-bottom:11px}.timeline-codex-search>span{position:absolute;left:12px;top:50%;transform:translateY(-50%);pointer-events:none;color:var(--muted);font-size:17px}.timeline-codex-search input{width:100%;min-height:43px;padding-left:37px!important;padding-right:12px!important;border-radius:13px!important;font-size:12px!important}
.event-codex-picker{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px;max-height:310px;overflow:auto;overscroll-behavior:contain;padding:2px 4px 2px 2px;scrollbar-gutter:stable}
.event-codex-item{position:relative;display:grid!important;grid-template-columns:18px 36px minmax(0,1fr) 22px;align-items:center;gap:9px;min-width:0;min-height:55px;padding:8px 9px!important;border:1px solid var(--line)!important;border-radius:13px!important;background:var(--surface)!important;color:var(--text);cursor:pointer;transition:border-color .16s ease,background .16s ease,transform .16s ease}
.event-codex-item:hover{border-color:color-mix(in srgb,var(--entry-color) 42%,var(--line))!important;background:color-mix(in srgb,var(--entry-color) 6%,var(--surface))!important}
.event-codex-item:has(input:checked){border-color:color-mix(in srgb,var(--entry-color) 58%,var(--line))!important;background:color-mix(in srgb,var(--entry-color) 10%,var(--surface))!important}
.event-codex-item>input{width:17px!important;height:17px!important;margin:0!important;accent-color:var(--entry-color)}
.event-codex-symbol{display:grid;place-items:center;width:36px;height:36px;border-radius:11px;background:color-mix(in srgb,var(--entry-color) 12%,var(--surface-2));color:var(--entry-color)}.event-codex-symbol svg{width:19px;height:19px;stroke:currentColor}
.event-codex-copy{min-width:0;display:block}.event-codex-copy b,.event-codex-copy small{display:block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.event-codex-copy b{font-size:11px;line-height:1.3}.event-codex-copy small{margin-top:3px;color:var(--muted);font-size:8px;line-height:1.3}
.event-codex-item>i{display:grid;place-items:center;width:20px;height:20px;border-radius:50%;background:var(--entry-color);color:#fff;font:700 10px/1 Inter,system-ui,sans-serif;font-style:normal;opacity:0;transform:scale(.75);transition:.15s ease}.event-codex-item:has(input:checked)>i{opacity:1;transform:scale(1)}
.timeline-codex-empty,.timeline-codex-noentries{margin-top:8px;padding:16px;border:1px dashed var(--line);border-radius:13px;text-align:center;color:var(--muted);font-size:10px}.timeline-codex-empty[hidden]{display:none!important}

@media(max-width:900px){
  .timeline-stats{grid-template-columns:repeat(3,minmax(0,1fr))}
  .timeline-era-stat{grid-column:auto}
  .timeline-event-modal{width:calc(100vw - 18px)}
  .timeline-codex-section{grid-column:auto!important}
  .event-codex-picker{max-height:340px}
}
@media(max-width:700px){
  .timeline-stats{grid-template-columns:repeat(2,minmax(0,1fr))}
  .timeline-era-stat{grid-column:1/-1}
  .timeline-era-stat b{font-size:20px!important}
  .timeline-era-field{min-height:45px}.timeline-era-field small{font-size:8px;max-width:110px}
  .timeline-codex-section{padding:14px;border-radius:16px}
  .timeline-codex-head{align-items:flex-start;flex-direction:column;gap:7px}.timeline-codex-head>span{white-space:normal}
  .event-codex-picker{grid-template-columns:1fr;max-height:min(42dvh,360px);gap:7px}
  .event-codex-item{min-height:56px}
}
@media(max-width:430px){
  .timeline-event-modal{width:calc(100vw - 10px)}
  .timeline-codex-section{padding:12px}
  .event-codex-item{grid-template-columns:17px 32px minmax(0,1fr) 20px;gap:7px;padding:7px!important}
  .event-codex-symbol{width:32px;height:32px}.event-codex-symbol svg{width:17px;height:17px}
}
/* Specificity guard against the legacy .event-codex-picker label rule. */
.event-codex-picker .event-codex-item{gap:9px!important;font-size:11px!important}
@media(max-width:430px){.event-codex-picker .event-codex-item{gap:7px!important}}

/* ========================================================================== 
   0.979 · WRITER DRAWER POSITION + OPEN STATE FIX · 2026-08-18
   Bugfix only: no version increment.
   ========================================================================== */

/* Desktop/fine pointer: one precise 72px header metric. The 52px branded
   toggle gets 10px on every outer side; the title starts after its reserved
   slot and can never sit under the button. */
@media (min-width:901px) and (pointer:fine){
  html[data-route="writer"] .writer-nav-toggle{
    display:grid!important;
    place-items:center!important;
    position:fixed!important;
    left:max(10px,env(safe-area-inset-left))!important;
    top:max(10px,env(safe-area-inset-top))!important;
    width:52px!important;height:52px!important;
    min-width:52px!important;min-height:52px!important;
    margin:0!important;padding:6px!important;
    z-index:260!important;
  }
  html[data-route="writer"] .writer-nav-toggle img{
    width:40px!important;height:40px!important;object-fit:contain!important;
  }
  html[data-route="writer"] .topbar{
    height:72px!important;min-height:72px!important;
    padding-left:max(80px,calc(env(safe-area-inset-left) + 80px))!important;
  }
  html[data-route="writer"] .topbar-left{
    padding-left:0!important;
    min-width:0!important;
  }
  html[data-route="writer"] .topbar-left>div{min-width:0!important}
  html[data-route="writer"] .book-title-top{
    max-width:min(54vw,760px)!important;
    white-space:nowrap!important;
    overflow:hidden!important;
    text-overflow:ellipsis!important;
  }

  /* Explicit drawer state. JS now adds .open as well, but keep the root state
     as a belt-and-braces fallback. */
  html[data-route="writer"] #rail.open,
  html[data-route="writer"].writer-chrome-open #rail{
    transform:translate3d(0,0,0)!important;
    opacity:1!important;
    pointer-events:auto!important;
  }
}

/* Tablet/coarse pointer: preserve the established 48px control but center it
   symmetrically in the 66px topbar and reserve the title slot explicitly. */
@media (max-width:900px), (pointer:coarse) and (min-width:561px) and (max-width:1366px){
  html[data-route="writer"] .writer-nav-toggle{
    left:max(9px,calc(env(safe-area-inset-left) + 9px))!important;
    top:max(9px,calc(env(safe-area-inset-top) + 9px))!important;
    width:48px!important;height:48px!important;
  }
  html[data-route="writer"] .topbar{
    padding-left:max(72px,calc(env(safe-area-inset-left) + 72px))!important;
  }
  html[data-route="writer"] #rail.open,
  html[data-route="writer"].writer-chrome-open #rail{
    transform:translate3d(0,0,0)!important;
    opacity:1!important;
    pointer-events:auto!important;
  }
}


/* ========================================================================== 
   0.979 · RAIL SYSTEM CONSOLIDATION · 2026-08-18
   Bugfix only. One navigation control, no Home toggle, vertically responsive
   drawer, and Writer content is never covered by the desktop rail.
   ========================================================================== */

/* One control only inside the workspace: the branded Sylva toggle. The legacy
   hamburger / X remains in markup for compatibility but is never exposed. */


/* Home remains intentionally clean: no external drawer button and no visible
   rail. Navigation to the workspace modules begins from the normal Home UI. */
html[data-route="home"] .writer-nav-toggle,
html[data-route="home"] #writerNavToggle{
  display:none!important;
  visibility:hidden!important;
  pointer-events:none!important;
}
html[data-route="home"] #rail{
  transform:translate3d(-110%,0,0)!important;
  opacity:0!important;
  pointer-events:none!important;
}

/* All actual workspace routes use the same branded toggle. */
html[data-route]:not([data-route="home"]) .writer-nav-toggle{
  display:grid!important;
  place-items:center!important;
  position:fixed!important;
  margin:0!important;
  z-index:310!important;
}

/* ---------------- DESKTOP / NOTEBOOK WITH FINE POINTER ---------------- */
@media (min-width:901px) and (pointer:fine), (min-width:1367px){
  html[data-route]:not([data-route="home"]) .app-shell{
    grid-template-columns:minmax(0,1fr)!important;
    grid-template-rows:72px minmax(0,1fr)!important;
    gap:0!important;
    padding:0!important;
  }

  /* 72px topbar, 52px button: exactly 10px above/below/left. */
  html[data-route]:not([data-route="home"]) .writer-nav-toggle{
    left:max(10px,env(safe-area-inset-left))!important;
    top:max(10px,env(safe-area-inset-top))!important;
    width:52px!important;height:52px!important;
    min-width:52px!important;min-height:52px!important;
    padding:6px!important;
    border-radius:14px!important;
    transform:none!important;
  }
  html[data-route]:not([data-route="home"]) .writer-nav-toggle img{
    width:40px!important;height:40px!important;
    object-fit:contain!important;
    transform:none!important;
  }

  html[data-route]:not([data-route="home"]) .topbar{
    grid-column:1!important;grid-row:1!important;
    width:100%!important;height:72px!important;min-height:72px!important;
    padding-left:max(78px,calc(env(safe-area-inset-left) + 78px))!important;
    padding-right:16px!important;
  }
  html[data-route]:not([data-route="home"]) .topbar-left{
    min-width:0!important;padding-left:0!important;
  }
  html[data-route]:not([data-route="home"]) .topbar-left>div{min-width:0!important}
  html[data-route]:not([data-route="home"]) .book-title-top{
    min-width:0!important;
    white-space:nowrap!important;
    overflow:hidden!important;
    text-overflow:ellipsis!important;
  }

  html[data-route]:not([data-route="home"]) .main-area{
    grid-column:1!important;grid-row:2!important;
    width:100%!important;
    height:calc(100dvh - 72px)!important;
    min-width:0!important;min-height:0!important;
  }

  /* Drawer begins BELOW the topbar. Its header/logo, scrollable navigation and
     fixed bottom actions share the available vertical space without clipping. */
  html[data-route]:not([data-route="home"]) #rail{
    display:flex!important;
    flex-direction:column!important;
    align-items:stretch!important;
    position:fixed!important;
    left:0!important;top:72px!important;bottom:0!important;
    width:224px!important;height:auto!important;min-height:0!important;
    padding:12px 10px max(10px,env(safe-area-inset-bottom))!important;
    overflow:hidden!important;
    transform:translate3d(-244px,0,0)!important;
    opacity:0!important;pointer-events:none!important;
    z-index:280!important;
  }
  html[data-route]:not([data-route="home"]) #rail.open,
  html[data-route]:not([data-route="home"]).writer-chrome-open #rail{
    transform:translate3d(0,0,0)!important;
    opacity:1!important;
    pointer-events:auto!important;
  }
  html[data-route]:not([data-route="home"]) #rail .brand{
    display:flex!important;
    flex:0 0 auto!important;
    align-self:flex-start!important;
    margin:0 4px 8px!important;
  }
  html[data-route]:not([data-route="home"]) #rail .rail-nav{
    flex:1 1 auto!important;
    min-height:0!important;
    width:100%!important;
    margin-top:4px!important;
    padding:0 3px 4px 0!important;
    overflow-y:auto!important;
    overflow-x:hidden!important;
    overscroll-behavior:contain!important;
    scrollbar-width:thin!important;
  }
  html[data-route]:not([data-route="home"]) #rail .rail-bottom{
    flex:0 0 auto!important;
    width:100%!important;
    margin-top:8px!important;
    padding-top:8px!important;
    border-top:1px solid var(--line)!important;
  }

  /* Writer: the rail PUSHES the manuscript workspace instead of covering the
     Structure/Acts panel or its edge handle. */
  html[data-route="writer"] .main-area{
    margin-left:0!important;
    transition:margin-left .28s cubic-bezier(.2,.8,.2,1),width .28s cubic-bezier(.2,.8,.2,1)!important;
  }
  html[data-route="writer"].writer-chrome-open .main-area{
    margin-left:224px!important;
    width:calc(100% - 224px)!important;
  }
  html[data-route="writer"].writer-chrome-open #writerView.review-mode .editor-stage{
    left:236px!important;
  }
  html[data-route="writer"].writer-chrome-open .app-shell::after{
    display:none!important;
    content:none!important;
  }

  /* Opening the drawer never moves or morphs the branded button. */
  html[data-route]:not([data-route="home"]).writer-chrome-open .writer-nav-toggle,
  html[data-route]:not([data-route="home"]) #rail.open ~ .writer-nav-toggle{
    left:max(10px,env(safe-area-inset-left))!important;
    transform:none!important;
  }
}

/* Short desktop displays: preserve comfortable rows, but let the navigation
   itself scroll. Bottom actions stay reachable at all times. */
@media (min-width:901px) and (max-height:760px) and (pointer:fine),
       (min-width:1367px) and (max-height:760px){
  html[data-route]:not([data-route="home"]) #rail{padding-top:8px!important;padding-bottom:8px!important}
  html[data-route]:not([data-route="home"]) #rail .brand{margin-bottom:4px!important}
  html[data-route]:not([data-route="home"]) #rail .brand img{max-height:48px!important;width:auto!important}
  html[data-route]:not([data-route="home"]) #rail .rail-nav{gap:3px!important;margin-top:2px!important}
  html[data-route]:not([data-route="home"]) #rail .rail-btn{min-height:38px!important;padding:6px 8px!important}
  html[data-route]:not([data-route="home"]) #rail .rail-bottom{gap:3px!important;margin-top:5px!important;padding-top:5px!important}
}

/* ---------------- TABLET / COARSE POINTER ---------------- */
@media (max-width:900px), (pointer:coarse) and (min-width:561px) and (max-width:1366px){
  html[data-route="home"] .writer-nav-toggle{display:none!important}
  
  html[data-route]:not([data-route="home"]) .writer-nav-toggle{
    left:max(9px,calc(env(safe-area-inset-left) + 9px))!important;
    top:max(9px,calc(env(safe-area-inset-top) + 9px))!important;
    width:48px!important;height:48px!important;
    min-width:48px!important;min-height:48px!important;
    margin:0!important;padding:6px!important;
    transform:none!important;
    z-index:310!important;
  }
  html[data-route]:not([data-route="home"]) .writer-nav-toggle img{
    width:36px!important;height:36px!important;transform:none!important;
  }
  html[data-route]:not([data-route="home"]) .topbar{
    padding-left:max(70px,calc(env(safe-area-inset-left) + 70px))!important;
  }
  html[data-route]:not([data-route="home"]) #rail{
    display:flex!important;flex-direction:column!important;
    top:66px!important;bottom:0!important;height:auto!important;min-height:0!important;
    overflow:hidden!important;
  }
  html[data-route]:not([data-route="home"]) #rail.open,
  html[data-route]:not([data-route="home"]).writer-chrome-open #rail{
    transform:translate3d(0,0,0)!important;
    opacity:1!important;pointer-events:auto!important;
  }
  html[data-route]:not([data-route="home"]) #rail .brand{flex:0 0 auto!important}
  html[data-route]:not([data-route="home"]) #rail .rail-nav{
    flex:1 1 auto!important;min-height:0!important;
    overflow-y:auto!important;overflow-x:hidden!important;
    overscroll-behavior:contain!important;
  }
  html[data-route]:not([data-route="home"]) #rail .rail-bottom{
    flex:0 0 auto!important;margin-top:6px!important;
    padding-bottom:max(6px,env(safe-area-inset-bottom))!important;
  }
}

/* Smartphone limited mode keeps its dedicated UI and never inherits workspace
   drawer controls. */
@media (max-width:560px){
  html.phone-only .writer-nav-toggle{display:none!important}
}


/* ========================================================================== 
   0.979 · TABLET TOGGLE STABILITY + REVIEW COMPARISON NAV LOCK · 2026-08-18
   Bugfix only: version stays 0.979.
   ========================================================================== */

/* Tablet only: an older open-state rule had higher selector specificity and
   moved/shrank the branded toggle into the drawer. The button must be visually
   identical whether the rail is open or closed. */
@media (max-width:900px), (pointer:coarse) and (min-width:561px) and (max-width:1366px){
  html[data-route]:not([data-route="home"]).writer-chrome-open .writer-nav-toggle,
  html[data-route]:not([data-route="home"]) #rail.open ~ .writer-nav-toggle{
    left:max(9px,calc(env(safe-area-inset-left) + 9px))!important;
    top:max(9px,calc(env(safe-area-inset-top) + 9px))!important;
    width:48px!important;height:48px!important;
    min-width:48px!important;min-height:48px!important;
    margin:0!important;padding:6px!important;
    transform:none!important;
  }
  html[data-route]:not([data-route="home"]).writer-chrome-open .writer-nav-toggle img,
  html[data-route]:not([data-route="home"]) #rail.open ~ .writer-nav-toggle img{
    width:36px!important;height:36px!important;
    transform:none!important;
  }
}

/* Revisione comparata only: navigation is deliberately unavailable. The JS
   closes the drawer on entry; these rules make the state fail-safe even if an
   old/open class survives a browser repaint or responsive transition. */
html[data-route="writer"].review-comparison-active .writer-nav-toggle,
html[data-route="writer"].review-comparison-active #writerNavToggle{
  display:none!important;
  visibility:hidden!important;
  opacity:0!important;
  pointer-events:none!important;
}
html[data-route="writer"].review-comparison-active #rail,
html[data-route="writer"].review-comparison-active #rail.open,
html[data-route="writer"].review-comparison-active.writer-chrome-open #rail{
  transform:translate3d(-110%,0,0)!important;
  opacity:0!important;
  visibility:hidden!important;
  pointer-events:none!important;
}
html[data-route="writer"].review-comparison-active .main-area{
  margin-left:0!important;
  width:100%!important;
}

/* ========================================================================== 
   0.980 · CUMULATIVE QA · READER FULL-VIEW GUARD · 2026-08-18
   The consolidated desktop drawer assigns a 72px workspace row to normal
   routes. Reader intentionally has no topbar and must remain true full-screen.
   ========================================================================== */
html[data-route="reader"] .main-area{
  position:fixed!important;
  inset:0!important;
  grid-column:1/-1!important;
  grid-row:1/-1!important;
  width:100vw!important;
  height:100dvh!important;
  margin:0!important;
}

/* Modal dialogs must stay above the consolidated rail/toggle (rail 280,
   branded toggle 310). This prevents navigation controls from remaining
   clickable through Timeline/Codex/Settings/confirm dialogs. Legal stays above
   everything at its existing z-index 1400. */
.modal-backdrop{z-index:1200!important}

/* ========================================================================== 
   SYLVA BETA 0.982 · STRUCTURE NAVIGATOR SLIM + CHAPTER COLORS · 2026-08-18
   Solo estetica interna del drawer Struttura + colore capitolo persistente.
   Apertura/chiusura, drag&drop, rename, jump, menu e responsive restano invariati.
   ========================================================================== */
html[data-route="writer"][data-theme] #writerView:not(.review-mode) .structure-sticky-tools{
  margin-bottom:7px!important;padding-bottom:9px!important
}
html[data-route="writer"][data-theme] #writerView:not(.review-mode) .structure-panel .panel-head small{
  font-size:9px!important;letter-spacing:.14em!important
}
html[data-route="writer"][data-theme] #writerView:not(.review-mode) .structure-panel .panel-head h2{
  font-size:18px!important;line-height:1.1!important;margin:3px 0!important
}
html[data-route="writer"][data-theme] #writerView:not(.review-mode) .structure-panel .structure-actions{
  gap:5px!important;margin-top:9px!important
}
html[data-route="writer"][data-theme] #writerView:not(.review-mode) .structure-panel .structure-actions .mini-btn{
  min-height:31px!important;height:31px!important;padding:4px 7px!important;border-radius:8px!important;
  font-size:10.5px!important;font-weight:650!important;box-shadow:none!important
}
html[data-route="writer"][data-theme] #writerView:not(.review-mode) .structure-panel .structure-tree{
  gap:1px!important;padding:1px 0 6px!important
}
html[data-route="writer"][data-theme] #writerView:not(.review-mode) .structure-panel .tree-row{
  position:relative!important;min-height:31px!important;padding:3px 4px!important;gap:4px!important;
  border:1px solid transparent!important;border-radius:8px!important;background:transparent!important;
  color:var(--text)!important;font-size:12.5px!important;box-shadow:none!important
}
html[data-route="writer"][data-theme] #writerView:not(.review-mode) .structure-panel .tree-row[data-type="act"]{
  min-height:29px!important;margin:7px 0 1px!important;padding-top:2px!important;padding-bottom:2px!important;
  color:color-mix(in srgb,var(--text) 84%,var(--muted))!important;font-weight:720!important
}
html[data-route="writer"][data-theme] #writerView:not(.review-mode) .structure-panel .tree-row[data-type="act"]:not(:first-child)::before{
  content:"";position:absolute;left:4px;right:4px;top:-5px;height:1px;background:color-mix(in srgb,var(--line) 76%,transparent);pointer-events:none
}
html[data-route="writer"][data-theme] #writerView:not(.review-mode) .structure-panel .tree-row[data-type="chapter"]{
  margin-left:7px!important;min-height:32px!important;font-weight:650!important
}
html[data-route="writer"][data-theme] #writerView:not(.review-mode) .structure-panel .tree-row[data-type="scene"]{
  margin-left:20px!important;min-height:30px!important;color:color-mix(in srgb,var(--text) 86%,var(--muted))!important
}
html[data-route="writer"][data-theme] #writerView:not(.review-mode) .structure-panel .tree-row:hover{
  background:color-mix(in srgb,var(--surface-2) 76%,transparent)!important;border-color:color-mix(in srgb,var(--line) 70%,transparent)!important
}
html[data-route="writer"][data-theme] #writerView:not(.review-mode) .structure-panel .tree-row.context-active{
  background:color-mix(in srgb,var(--accent-soft) 34%,transparent)!important;border-color:transparent!important;box-shadow:none!important
}
html[data-route="writer"][data-theme] #writerView:not(.review-mode) .structure-panel .tree-row.active{
  background:color-mix(in srgb,var(--accent-soft) 62%,transparent)!important;border-color:color-mix(in srgb,var(--accent) 18%,transparent)!important;
  box-shadow:inset 2px 0 0 color-mix(in srgb,var(--accent) 58%,transparent)!important;color:var(--text)!important
}
html[data-route="writer"][data-theme] #writerView:not(.review-mode) .structure-panel .tree-row[data-type="chapter"].has-chapter-color{
  background:color-mix(in srgb,var(--chapter-color) 5%,transparent)!important
}
html[data-route="writer"][data-theme] #writerView:not(.review-mode) .structure-panel .tree-row[data-type="chapter"].context-active.has-chapter-color{
  background:color-mix(in srgb,var(--chapter-color) 11%,var(--surface-2))!important;
  border-color:color-mix(in srgb,var(--chapter-color) 14%,transparent)!important
}
html[data-route="writer"][data-theme] #writerView:not(.review-mode) .structure-panel .tree-row[data-type="scene"].active.has-chapter-color{
  background:color-mix(in srgb,var(--chapter-color) 13%,var(--surface-2))!important;
  border-color:color-mix(in srgb,var(--chapter-color) 22%,transparent)!important;
  box-shadow:inset 2px 0 0 var(--chapter-color)!important
}


html[data-route="writer"][data-theme] #writerView:not(.review-mode) .structure-panel .tree-fold{
  width:18px!important;min-width:18px!important;height:25px!important;flex-basis:18px!important;border-radius:6px!important
}
html[data-route="writer"][data-theme] #writerView:not(.review-mode) .structure-panel .tree-fold span{font-size:15px!important}
html[data-route="writer"][data-theme] #writerView:not(.review-mode) .structure-panel .tree-drag-handle{
  width:16px!important;min-width:16px!important;height:25px!important;flex-basis:16px!important;margin:0!important;
  opacity:.16!important;border-radius:6px!important
}
html[data-route="writer"][data-theme] #writerView:not(.review-mode) .structure-panel .tree-row:hover .tree-drag-handle,
html[data-route="writer"][data-theme] #writerView:not(.review-mode) .structure-panel .tree-row:focus-within .tree-drag-handle{opacity:.68!important}
html[data-route="writer"][data-theme] #writerView:not(.review-mode) .structure-panel .tree-drag-handle svg{width:11px!important;height:11px!important}
html[data-route="writer"][data-theme] #writerView:not(.review-mode) .structure-panel .tree-title{
  min-width:0!important;line-height:1.18!important
}
html[data-route="writer"][data-theme] #writerView:not(.review-mode) .structure-panel .tree-narrative-status{
  width:5px!important;height:5px!important;margin:0 1px 0 0!important;box-shadow:0 0 0 1.5px color-mix(in srgb,var(--scene-status) 15%,transparent)!important
}
html[data-route="writer"][data-theme] #writerView:not(.review-mode) .structure-panel .tree-chapter-color{
  width:8px!important;min-width:8px!important;height:21px!important;flex:0 0 8px!important;padding:0!important;margin:0 1px!important;
  border-radius:5px!important;border:1px solid color-mix(in srgb,var(--line) 86%,transparent)!important;
  background:var(--chapter-color,transparent)!important;box-shadow:inset 0 0 0 1px color-mix(in srgb,#fff 10%,transparent)!important;
  cursor:pointer!important;transition:transform .15s ease,box-shadow .15s ease,border-color .15s ease!important
}
html[data-route="writer"][data-theme] #writerView:not(.review-mode) .structure-panel .tree-row:not(.has-chapter-color) .tree-chapter-color{
  background:color-mix(in srgb,var(--muted) 8%,transparent)!important;border-style:dashed!important
}
html[data-route="writer"][data-theme] #writerView:not(.review-mode) .structure-panel .tree-chapter-color:hover{
  transform:scaleX(1.25)!important;border-color:color-mix(in srgb,var(--text) 35%,var(--line))!important
}
html[data-route="writer"][data-theme] #writerView:not(.review-mode) .structure-panel .tree-chapter-trace{
  display:none;width:3px;height:15px;min-width:3px;flex:0 0 3px;border-radius:3px;background:var(--chapter-color)
}
html[data-route="writer"][data-theme] #writerView:not(.review-mode) .structure-panel .tree-row.has-chapter-color .tree-chapter-trace{display:block!important}
html[data-route="writer"][data-theme] #writerView:not(.review-mode) .structure-panel .tree-jump{
  width:25px!important;height:25px!important;min-width:25px!important;min-height:25px!important;padding:0!important;border-radius:7px!important;opacity:0!important
}
html[data-route="writer"][data-theme] #writerView:not(.review-mode) .structure-panel .tree-row:hover .tree-jump,
html[data-route="writer"][data-theme] #writerView:not(.review-mode) .structure-panel .tree-row:focus-within .tree-jump{opacity:.66!important}
html[data-route="writer"][data-theme] #writerView:not(.review-mode) .structure-panel .tree-jump svg{width:13px!important;height:13px!important}
html[data-route="writer"][data-theme] #writerView:not(.review-mode) .structure-panel .tree-menu{
  width:25px!important;height:25px!important;min-width:25px!important;min-height:25px!important;padding:0!important;
  border-radius:7px!important;font-size:15px!important;background:transparent!important
}
html[data-route="writer"][data-theme] #writerView:not(.review-mode) .structure-panel .tree-row:hover .tree-menu,
html[data-route="writer"][data-theme] #writerView:not(.review-mode) .structure-panel .tree-row:focus-within .tree-menu{
  background:color-mix(in srgb,var(--surface-2) 72%,transparent)!important
}

.chapter-color-modal>small{font-size:9px;letter-spacing:.14em;color:var(--muted);font-weight:750}
.chapter-color-modal h2{margin:4px 0 6px}
.chapter-color-modal p{margin:0 0 18px;color:var(--muted);font-size:11px;line-height:1.5}
.chapter-color-preview{display:flex;align-items:center;gap:10px;margin:0 0 18px;padding:10px 12px;border:1px solid var(--line);border-radius:11px;background:var(--surface-2)}
.chapter-color-preview i{width:8px;height:28px;border-radius:5px;background:var(--preview-chapter-color);box-shadow:inset 0 0 0 1px rgba(255,255,255,.12)}
.chapter-color-preview b{font-size:12px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.chapter-color-editor{align-items:center}
.chapter-color-edit-btn{display:flex!important;align-items:center!important;justify-content:flex-start!important;gap:9px!important;text-align:left!important}
.chapter-color-edit-btn i{width:8px;height:24px;border-radius:5px;background:var(--chapter-edit-color);border:1px solid var(--line);flex:0 0 auto}

@media (pointer:coarse){
  html[data-route="writer"][data-theme] #writerView:not(.review-mode) .structure-panel .tree-row{
    min-height:39px!important;padding:4px 5px!important;font-size:13.5px!important;gap:5px!important
  }
  html[data-route="writer"][data-theme] #writerView:not(.review-mode) .structure-panel .tree-row[data-type="act"]{min-height:37px!important}
  html[data-route="writer"][data-theme] #writerView:not(.review-mode) .structure-panel .tree-row[data-type="chapter"]{min-height:40px!important}
  html[data-route="writer"][data-theme] #writerView:not(.review-mode) .structure-panel .tree-row[data-type="scene"]{min-height:39px!important}
  html[data-route="writer"][data-theme] #writerView:not(.review-mode) .structure-panel .tree-drag-handle{
    width:25px!important;min-width:25px!important;height:34px!important;flex-basis:25px!important;opacity:.52!important
  }
  html[data-route="writer"][data-theme] #writerView:not(.review-mode) .structure-panel .tree-fold{width:25px!important;min-width:25px!important;height:34px!important;flex-basis:25px!important}
  
  html[data-route="writer"][data-theme] #writerView:not(.review-mode) .structure-panel .tree-chapter-color{width:10px!important;min-width:10px!important;height:26px!important;flex-basis:10px!important}
  html[data-route="writer"][data-theme] #writerView:not(.review-mode) .structure-panel .tree-chapter-trace{width:4px!important;min-width:4px!important;height:19px!important;flex-basis:4px!important}
  html[data-route="writer"][data-theme] #writerView:not(.review-mode) .structure-panel .tree-jump{
    width:34px!important;height:34px!important;min-width:34px!important;min-height:34px!important;opacity:.72!important;background:transparent!important
  }
  html[data-route="writer"][data-theme] #writerView:not(.review-mode) .structure-panel .tree-menu{
    width:34px!important;height:34px!important;min-width:34px!important;min-height:34px!important;background:transparent!important
  }
  html[data-route="writer"][data-theme] #writerView:not(.review-mode) .structure-panel .structure-actions .mini-btn{min-height:38px!important;height:38px!important;font-size:11px!important}
}

/* ========================================================================== 
   SYLVA BETA 0.981 · STRUCTURE NAVIGATOR REFINEMENT · 2026-08-18
   Gerarchia per scala tipografica, titoli allineati, numerazione rimossa,
   chevron pulito e colore capitolo/scena più leggibile.
   ========================================================================== */
html[data-route="writer"][data-theme] #writerView:not(.review-mode) .structure-panel .tree-row{
  margin-left:0!important;
  font-family:inherit!important;
}
html[data-route="writer"][data-theme] #writerView:not(.review-mode) .structure-panel .tree-row[data-type="act"]{
  margin:8px 0 2px!important;
  min-height:31px!important;
  font-size:14.5px!important;
  font-weight:720!important;
  letter-spacing:-.012em!important;
}
html[data-route="writer"][data-theme] #writerView:not(.review-mode) .structure-panel .tree-row[data-type="chapter"]{
  margin-left:0!important;
  min-height:32px!important;
  font-size:13.2px!important;
  font-weight:650!important;
  letter-spacing:-.006em!important;
}
html[data-route="writer"][data-theme] #writerView:not(.review-mode) .structure-panel .tree-row[data-type="scene"]{
  margin-left:0!important;
  min-height:30px!important;
  font-size:12.2px!important;
  font-weight:520!important;
  letter-spacing:0!important;
}
html[data-route="writer"][data-theme] #writerView:not(.review-mode) .structure-panel .tree-title{
  font-family:inherit!important;
  font-size:inherit!important;
  font-weight:inherit!important;
  letter-spacing:inherit!important;
}
html[data-route="writer"][data-theme] #writerView:not(.review-mode) .structure-panel .tree-title-input{
  font-family:inherit!important;
  font-size:inherit!important;
  font-weight:inherit!important;
}

/* Ogni livello usa gli stessi slot prima del titolo: nessun rientro gerarchico. */
html[data-route="writer"][data-theme] #writerView:not(.review-mode) .structure-panel .tree-color-slot{
  width:11px!important;
  min-width:11px!important;
  flex:0 0 11px!important;
  height:27px!important;
  display:grid!important;
  place-items:center!important;
}
html[data-route="writer"][data-theme] #writerView:not(.review-mode) .structure-panel .tree-status-slot{
  width:7px!important;
  min-width:7px!important;
  flex:0 0 7px!important;
  height:25px!important;
  display:grid!important;
  place-items:center!important;
}
html[data-route="writer"][data-theme] #writerView:not(.review-mode) .structure-panel .tree-narrative-status{
  width:5px!important;
  height:5px!important;
  margin:0!important;
  flex:0 0 5px!important;
}
html[data-route="writer"][data-theme] #writerView:not(.review-mode) .structure-panel .tree-narrative-status-spacer{
  visibility:hidden!important;
  box-shadow:none!important;
}

/* Barre colore più presenti senza trasformare le righe in blocchi cromatici. */
html[data-route="writer"][data-theme] #writerView:not(.review-mode) .structure-panel .tree-chapter-color{
  width:7px!important;
  min-width:7px!important;
  height:25px!important;
  flex:0 0 7px!important;
  margin:0!important;
  border-radius:999px!important;
  border:1px solid color-mix(in srgb,var(--chapter-color,var(--line)) 48%,var(--line))!important;
  box-shadow:0 0 0 1px color-mix(in srgb,#fff 9%,transparent),0 0 8px color-mix(in srgb,var(--chapter-color,var(--accent)) 24%,transparent)!important;
}
html[data-route="writer"][data-theme] #writerView:not(.review-mode) .structure-panel .tree-row:not(.has-chapter-color) .tree-chapter-color{
  background:color-mix(in srgb,var(--muted) 11%,transparent)!important;
  border-color:color-mix(in srgb,var(--muted) 34%,var(--line))!important;
  box-shadow:none!important;
}
html[data-route="writer"][data-theme] #writerView:not(.review-mode) .structure-panel .tree-chapter-color:hover{
  transform:scaleX(1.18)!important;
  box-shadow:0 0 0 1px color-mix(in srgb,#fff 12%,transparent),0 0 11px color-mix(in srgb,var(--chapter-color,var(--accent)) 36%,transparent)!important;
}
html[data-route="writer"][data-theme] #writerView:not(.review-mode) .structure-panel .tree-chapter-trace{
  width:5px!important;
  min-width:5px!important;
  height:20px!important;
  flex:0 0 5px!important;
  margin:0!important;
  border-radius:999px!important;
  background:var(--chapter-color)!important;
  box-shadow:0 0 6px color-mix(in srgb,var(--chapter-color) 22%,transparent)!important;
}
html[data-route="writer"][data-theme] #writerView:not(.review-mode) .structure-panel .tree-chapter-trace-spacer{
  visibility:hidden!important;
  box-shadow:none!important;
}
html[data-route="writer"][data-theme] #writerView:not(.review-mode) .structure-panel .tree-row[data-type="chapter"].has-chapter-color{
  background:color-mix(in srgb,var(--chapter-color) 9%,transparent)!important;
  border-color:color-mix(in srgb,var(--chapter-color) 10%,transparent)!important;
}
html[data-route="writer"][data-theme] #writerView:not(.review-mode) .structure-panel .tree-row[data-type="chapter"].context-active.has-chapter-color{
  background:color-mix(in srgb,var(--chapter-color) 16%,var(--surface-2))!important;
  border-color:color-mix(in srgb,var(--chapter-color) 22%,transparent)!important;
}
html[data-route="writer"][data-theme] #writerView:not(.review-mode) .structure-panel .tree-row[data-type="scene"].has-chapter-color{
  background:color-mix(in srgb,var(--chapter-color) 3.5%,transparent)!important;
}
html[data-route="writer"][data-theme] #writerView:not(.review-mode) .structure-panel .tree-row[data-type="scene"].has-chapter-color:hover{
  background:color-mix(in srgb,var(--chapter-color) 8%,var(--surface-2))!important;
  border-color:color-mix(in srgb,var(--chapter-color) 12%,transparent)!important;
}
html[data-route="writer"][data-theme] #writerView:not(.review-mode) .structure-panel .tree-row[data-type="scene"].active.has-chapter-color{
  background:color-mix(in srgb,var(--chapter-color) 16%,var(--surface-2))!important;
  border-color:color-mix(in srgb,var(--chapter-color) 28%,transparent)!important;
  box-shadow:inset 2px 0 0 var(--chapter-color)!important;
}

/* Chevron vettoriale: niente glifi tipografici che cambiano da font a font. */
html[data-route="writer"][data-theme] #writerView:not(.review-mode) .structure-panel .tree-fold{
  color:color-mix(in srgb,var(--text) 62%,var(--muted))!important;
}
html[data-route="writer"][data-theme] #writerView:not(.review-mode) .structure-panel .tree-fold svg{
  width:14px!important;
  height:14px!important;
  fill:none!important;
  stroke:currentColor!important;
  stroke-width:1.65!important;
  stroke-linecap:round!important;
  stroke-linejoin:round!important;
  transition:transform .16s ease,color .16s ease!important;
}
html[data-route="writer"][data-theme] #writerView:not(.review-mode) .structure-panel .tree-fold .tree-fold-chevron.is-collapsed{
  transform:rotate(-90deg)!important;
}
html[data-route="writer"][data-theme] #writerView:not(.review-mode) .structure-panel .tree-fold:hover{
  background:color-mix(in srgb,var(--accent-soft) 54%,transparent)!important;
  color:var(--text)!important;
}

@media (pointer:coarse){
  html[data-route="writer"][data-theme] #writerView:not(.review-mode) .structure-panel .tree-row[data-type="act"]{
    min-height:39px!important;font-size:15.5px!important
  }
  html[data-route="writer"][data-theme] #writerView:not(.review-mode) .structure-panel .tree-row[data-type="chapter"]{
    min-height:40px!important;font-size:14.3px!important
  }
  html[data-route="writer"][data-theme] #writerView:not(.review-mode) .structure-panel .tree-row[data-type="scene"]{
    min-height:39px!important;font-size:13.3px!important
  }
  html[data-route="writer"][data-theme] #writerView:not(.review-mode) .structure-panel .tree-color-slot{
    width:13px!important;min-width:13px!important;flex-basis:13px!important;height:32px!important
  }
  html[data-route="writer"][data-theme] #writerView:not(.review-mode) .structure-panel .tree-status-slot{
    width:8px!important;min-width:8px!important;flex-basis:8px!important;height:32px!important
  }
  html[data-route="writer"][data-theme] #writerView:not(.review-mode) .structure-panel .tree-chapter-color{
    width:8px!important;min-width:8px!important;flex-basis:8px!important;height:29px!important
  }
  html[data-route="writer"][data-theme] #writerView:not(.review-mode) .structure-panel .tree-chapter-trace{
    width:5px!important;min-width:5px!important;flex-basis:5px!important;height:23px!important
  }
  html[data-route="writer"][data-theme] #writerView:not(.review-mode) .structure-panel .tree-fold svg{
    width:16px!important;height:16px!important
  }
}

/* ========================================================================== 
   SYLVA 0.981 · CALENDAR ERAS + COMPACT WORKSPACE · 2026-08-19
   ========================================================================== */

/* The calendar is a direct workspace: base rules + era stack, then compact months. */
.calendar-layout{display:grid;grid-template-columns:minmax(300px,.72fr) minmax(0,1.28fr);gap:16px;align-items:start}
.calendar-foundation,.calendar-eras-section,.calendar-months-section{border:1px solid var(--line);border-radius:20px;padding:17px;background:color-mix(in srgb,var(--surface-2) 78%,transparent);min-width:0}
.calendar-foundation{position:static;top:auto}
.calendar-months-section{grid-column:1/-1}
.calendar-section-head{align-items:center}
.calendar-section-head>div{min-width:0}
.calendar-section-head>div>p{margin:4px 0 0;max-width:640px;color:var(--muted);font-size:9px;line-height:1.45}
.calendar-section-head>.soft-btn{flex:0 0 auto;padding:8px 11px;font-size:10px}
.calendar-foundation-grid{grid-template-columns:1fr;gap:10px}
.calendar-foundation-grid .span-2{grid-column:auto}
.calendar-foundation-grid input{min-height:41px}
.weekday-preview{margin-top:11px;gap:5px}
.weekday-preview>span{padding:5px 8px}

/* Eras: order is structural, while name/suffix/direction are edited inline. */
.calendar-era-list{display:flex;flex-direction:column;gap:8px}
.calendar-era-card{border:1px solid var(--line);border-radius:15px;background:var(--surface-2);padding:11px 12px;min-width:0}
.calendar-era-main{min-width:0}
.calendar-era-heading{display:flex;align-items:center;justify-content:space-between;gap:12px;margin-bottom:9px}
.calendar-era-heading>div:first-child{min-width:0}
.calendar-era-heading small,.calendar-era-heading b{display:block;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.calendar-era-heading small{font-size:7px;letter-spacing:.1em;text-transform:uppercase;color:var(--accent);font-weight:700}
.calendar-era-titleline{display:flex;align-items:center;gap:7px;min-width:0;margin-top:2px}
.calendar-era-heading b{font-size:13px;font-weight:650;color:var(--text)}
.calendar-era-titleline em{flex:0 0 auto;max-width:120px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;border:1px solid color-mix(in srgb,var(--accent) 28%,var(--line));border-radius:999px;background:var(--accent-soft);padding:2px 7px;color:var(--accent);font-size:8px;font-style:normal;font-weight:700;letter-spacing:.04em}
.calendar-era-move{display:flex;align-items:center;gap:4px;flex:0 0 auto}
.calendar-era-move .outline-icon-btn{width:30px;height:30px;min-width:30px;padding:0;font-size:12px}
.calendar-era-fields{display:grid;grid-template-columns:minmax(0,1.35fr) minmax(105px,.55fr) minmax(180px,1fr);gap:8px}
.calendar-era-fields label{display:flex;flex-direction:column;gap:4px;min-width:0}
.calendar-era-fields label>span{font-size:8px;letter-spacing:.04em;color:var(--muted)}
.calendar-era-fields input,.calendar-era-fields select{width:100%;min-width:0;min-height:38px;padding:7px 9px!important;font-size:12px!important}

/* Months no longer need large cards: each month is a single compact row. */
.calendar-month-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px}
.calendar-month-compact{display:grid;grid-template-columns:34px minmax(0,1fr) auto 32px;gap:9px;align-items:end;border:1px solid var(--line);border-radius:14px;padding:9px 10px;background:var(--surface-2);min-width:0;transition:border-color .15s ease,background .15s ease}
.calendar-month-compact:hover{border-color:color-mix(in srgb,var(--accent) 28%,var(--line));background:color-mix(in srgb,var(--accent) 3%,var(--surface-2))}
.calendar-month-order{align-self:center;color:var(--muted);font-size:10px;text-align:center;font-variant-numeric:tabular-nums}
.calendar-month-name{display:flex;flex-direction:column;gap:4px;min-width:0}
.calendar-month-name>span,.calendar-days-compact>span{font-size:7px;letter-spacing:.06em;text-transform:uppercase;color:var(--muted)}
.calendar-month-name input{min-width:0;min-height:36px;padding:7px 9px!important;font-size:12px!important}
.calendar-days-compact{display:grid;grid-template-columns:auto auto;gap:3px 7px;align-items:center}
.calendar-days-compact>span{grid-column:1}
.calendar-days-compact>div{grid-column:2;grid-row:1/3;display:grid;grid-template-columns:29px 52px 29px;border:1px solid var(--line);border-radius:9px;overflow:hidden}
.calendar-days-compact button{border:0;background:var(--surface);color:var(--muted);min-height:34px;font-size:14px}
.calendar-days-compact button:hover{background:var(--accent-soft);color:var(--text)}
.calendar-days-compact input{width:52px;min-height:34px;border:0!important;border-left:1px solid var(--line)!important;border-right:1px solid var(--line)!important;border-radius:0!important;background:var(--surface-2)!important;text-align:center;padding:5px 2px!important;font-size:11px!important}
.calendar-days-compact>small{grid-column:1;color:var(--muted);font-size:8px}
.calendar-month-compact>.outline-icon-btn{align-self:center;width:30px;height:30px;min-width:30px;padding:0}
.timeline-era-select+small{font-size:8px;color:var(--muted);line-height:1.35}

@media(max-width:1180px){
  .calendar-layout{grid-template-columns:minmax(280px,.7fr) minmax(0,1.3fr);gap:14px}
  .calendar-foundation,.calendar-eras-section,.calendar-months-section{padding:15px}
  .calendar-era-fields{grid-template-columns:minmax(0,1.25fr) minmax(95px,.55fr);}
  .calendar-era-fields label:last-child{grid-column:1/-1}
}
@media(max-width:900px){
  .calendar-layout{grid-template-columns:1fr;gap:12px}
  .calendar-months-section{grid-column:auto}
  .calendar-foundation,.calendar-eras-section,.calendar-months-section{padding:16px;border-radius:18px}
  .calendar-era-fields{grid-template-columns:minmax(0,1.25fr) minmax(110px,.65fr) minmax(180px,1fr)}
  .calendar-era-fields label:last-child{grid-column:auto}
  .calendar-month-grid{grid-template-columns:repeat(2,minmax(0,1fr));gap:7px}
  .calendar-month-compact{grid-template-columns:28px minmax(0,1fr) auto 30px;gap:7px;padding:9px}
}
@media(max-width:700px){
  .calendar-section-head{align-items:flex-start}
  .calendar-section-head>.soft-btn{margin-top:1px}
  .calendar-era-fields{grid-template-columns:1fr 1fr}
  .calendar-era-fields label:last-child{grid-column:1/-1}
  .calendar-month-grid{grid-template-columns:1fr}
}
@media(max-width:480px){
  .calendar-section-head{flex-direction:column;align-items:stretch}
  .calendar-section-head>.soft-btn{width:100%;justify-content:center}
  .calendar-era-heading{align-items:flex-start}
  .calendar-era-fields{grid-template-columns:1fr}
  .calendar-era-fields label:last-child{grid-column:auto}
  .calendar-month-compact{grid-template-columns:24px minmax(0,1fr) 30px;align-items:center}
  .calendar-days-compact{grid-column:2;grid-row:2;margin-top:2px;justify-self:start}
  .calendar-month-compact>.outline-icon-btn{grid-column:3;grid-row:1/3}
}
@media(pointer:coarse){
  .calendar-era-fields input,.calendar-era-fields select,.calendar-month-name input{min-height:44px}
  .calendar-era-move .outline-icon-btn,.calendar-month-compact>.outline-icon-btn{width:36px;height:36px;min-width:36px}
  .calendar-days-compact button,.calendar-days-compact input{min-height:40px}
}

/* Calendar multi-era surfaces inherit the exact active theme palette. */
html[data-theme="modern"] .calendar-eras-section{border-color:var(--line)!important}
html[data-theme="fantasy"] .calendar-eras-section{border-color:rgba(215,190,140,.15)!important}
html[data-theme="thriller"] .calendar-eras-section{border-color:rgba(238,240,241,.10)!important}
html[data-theme="cyberpunk"] .calendar-eras-section{border-color:rgba(0,217,237,.18)!important;box-shadow:0 0 0 1px rgba(243,79,201,.025),var(--shadow)!important}
html[data-theme="alba"] .calendar-eras-section,html[data-theme="crepuscolo"] .calendar-eras-section{background:var(--surface)!important}
:is(html[data-palette="arabesque"],html[data-palette="orchidea"],html[data-palette="foresta"]) .calendar-eras-section{border-color:var(--line)!important}

/* ========================================================================== 
   SYLVA BETA 0.99 · RELATIONSHIPS + PLANNING + DESKTOP CHROME · 2026-08-19
   Final consolidation for this cycle. Keep active theme typography/palette.
   ========================================================================== */

/* Desktop workspace chrome: every module uses the same single Sylva control as Writer. */
@media (min-width:901px) and (pointer:fine), (min-width:1367px){
  
  html.workspace-entered[data-route]:not([data-route="home"]) .writer-nav-toggle{
    display:grid!important;place-items:center!important;position:fixed!important;
    left:max(10px,env(safe-area-inset-left))!important;top:max(10px,env(safe-area-inset-top))!important;
    width:52px!important;height:52px!important;min-width:52px!important;min-height:52px!important;
    margin:0!important;padding:6px!important;border-radius:14px!important;transform:none!important;z-index:310!important;
  }
  html.workspace-entered[data-route]:not([data-route="home"]) .writer-nav-toggle img{
    width:40px!important;height:40px!important;object-fit:contain!important;transform:none!important;
  }
  html.workspace-entered[data-route]:not([data-route="home"]) .topbar{
    display:grid!important;grid-template-columns:minmax(0,1fr) auto!important;align-items:center!important;
    width:100%!important;height:72px!important;min-height:72px!important;
    padding:0 16px 0 max(78px,calc(env(safe-area-inset-left) + 78px))!important;
  }
  html.workspace-entered[data-route]:not([data-route="home"]):not([data-route="writer"]) .topbar-center,
  html.workspace-entered[data-route]:not([data-route="home"]):not([data-route="writer"]) .writer-project-actions{
    display:none!important;
  }
  html.workspace-entered[data-route]:not([data-route="home"]) .topbar-left{
    grid-column:1!important;display:flex!important;align-items:center!important;min-width:0!important;padding:0!important;margin:0!important;
  }
  html.workspace-entered[data-route]:not([data-route="home"]).writer-chrome-open .writer-nav-toggle,
  html.workspace-entered[data-route]:not([data-route="home"]) #rail.open ~ .writer-nav-toggle{
    left:max(10px,env(safe-area-inset-left))!important;top:max(10px,env(safe-area-inset-top))!important;transform:none!important;
  }
}

/* Crepuscolo: native popup options must never fall back to the OS light palette. */
html[data-theme="crepuscolo"] select{color-scheme:dark!important;background:#252d29!important;color:#e7e2d7!important;border-color:rgba(231,226,215,.14)!important}
html[data-theme="crepuscolo"] select option,
html[data-theme="crepuscolo"] select optgroup{background:#252d29!important;color:#e7e2d7!important}
html[data-theme="crepuscolo"] select option:disabled{color:#9d9b91!important}

/* Shared searchable choice used by Scene planning and relationship parties. */
.search-choice{position:relative;min-width:0;font-family:inherit}
.search-choice-input{position:relative;min-width:0}
.search-choice-input input{width:100%;padding-right:34px!important;font-family:inherit}
.search-choice-input>span{position:absolute;right:11px;top:50%;transform:translateY(-50%);font-size:15px;color:var(--muted);pointer-events:none}
.search-choice-menu{position:absolute;z-index:90;left:0;right:0;top:calc(100% + 5px);max-height:240px;overflow:auto;padding:5px;border:1px solid var(--line);border-radius:12px;background:var(--surface-strong,var(--surface));box-shadow:var(--shadow);font-family:inherit}
.search-choice-menu button{display:grid;grid-template-columns:9px minmax(0,1fr) auto;align-items:center;gap:8px;width:100%;min-height:36px;padding:7px 8px;border:0;border-radius:8px;background:transparent;color:var(--text);text-align:left;font:inherit;cursor:pointer}
.search-choice-menu button:hover,.search-choice-menu button:focus-visible{background:var(--accent-soft);outline:0}
.search-choice-menu button i{width:7px;height:7px;border-radius:999px;background:var(--choice-color,var(--accent))}
.search-choice-menu button span{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:11px}
.search-choice-menu button small{font-size:8px;color:var(--muted)}
.search-choice-menu button[data-choice-value=""]{grid-template-columns:minmax(0,1fr);color:var(--muted)}
.search-choice-empty{padding:12px;color:var(--muted);font-size:10px;text-align:center}

/* Planning mode switch: dedicated but quiet. */
.planning-modebar{display:grid;grid-template-columns:auto auto 1fr auto;gap:5px;align-items:center;margin:0 0 12px;padding:5px;border:1px solid var(--line);border-radius:14px;background:var(--surface)}
.planning-modebar>button:not(.soft-btn){min-height:36px;padding:7px 14px;border:0;border-radius:10px;background:transparent;color:var(--muted);font:inherit;font-size:10px;font-weight:650;cursor:pointer}
.planning-modebar>button:not(.soft-btn).active{background:var(--accent-soft);color:var(--text);box-shadow:inset 0 0 0 1px color-mix(in srgb,var(--accent) 22%,transparent)}
.planning-modebar .soft-btn{min-height:36px;padding:7px 12px!important;font-size:9px!important}
.planning-inline-search{display:flex;align-items:center;gap:7px;margin:7px 0;padding:0 9px;border:1px solid var(--line);border-radius:10px;background:var(--surface-strong,var(--surface))}
.planning-inline-search>span{color:var(--muted);font-size:14px}
.planning-inline-search input{min-height:34px!important;padding:5px 0!important;border:0!important;background:transparent!important;box-shadow:none!important;font-family:inherit!important;font-size:10px!important}
.planning-linked-event span em{display:block;margin-top:3px;color:var(--muted);font-style:normal;font-size:8px;font-weight:400}
.planning-linked-event>strong{font-size:16px;color:var(--accent);font-weight:500}

/* Scene status manager. */
.scene-status-manager{display:flex;flex-direction:column;gap:6px;margin-top:13px;max-height:min(52vh,520px);overflow:auto}
.scene-status-manager article{display:grid;grid-template-columns:7px minmax(0,1fr) 34px 34px;gap:8px;align-items:center;padding:8px 9px;border:1px solid var(--line);border-radius:11px;background:var(--surface-2)}
.scene-status-manager article>i{width:6px;height:28px;border-radius:999px;background:var(--status-color)}
.scene-status-manager article span b,.scene-status-manager article span small{display:block}
.scene-status-manager article span b{font-size:11px;color:var(--text)}
.scene-status-manager article span small{margin-top:2px;font-size:8px;color:var(--muted)}

/* Trame / archi: no longer a tiny popup-only concept. */
.planning-plotline-workspace{min-height:520px}
.plotline-work-layout{display:grid;grid-template-columns:minmax(230px,.7fr) minmax(0,1.7fr);gap:12px;min-height:520px}
.plotline-work-list,.plotline-work-editor{border:1px solid var(--line);border-radius:18px;background:var(--surface);min-width:0}
.plotline-work-list{padding:10px;display:flex;flex-direction:column;gap:6px}
.plotline-work-list-head{display:flex;align-items:center;justify-content:space-between;gap:10px;padding:4px 3px 8px}
.plotline-work-list-head small,.plotline-work-detail-head small{display:block;color:var(--accent);font-size:7px;letter-spacing:.11em;font-weight:750}
.plotline-work-list-head h3{margin:2px 0 0;font-size:14px;font-family:inherit}
.plotline-work-list-head .primary-btn{width:34px;height:34px;min-width:34px;padding:0!important;border-radius:10px}
.plotline-work-row{display:grid;grid-template-columns:5px minmax(0,1fr) auto;align-items:center;gap:9px;width:100%;padding:9px;border:1px solid transparent;border-radius:11px;background:transparent;color:var(--text);text-align:left;font:inherit;cursor:pointer}
.plotline-work-row:hover{background:var(--surface-2);border-color:var(--line)}
.plotline-work-row.active{background:var(--accent-soft);border-color:color-mix(in srgb,var(--accent) 24%,var(--line))}
.plotline-work-row>i{width:5px;height:31px;border-radius:999px;background:var(--plot-color)}
.plotline-work-row span b,.plotline-work-row span small{display:block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.plotline-work-row span b{font-size:11px}.plotline-work-row span small{margin-top:2px;color:var(--muted);font-size:8px}
.plotline-work-row strong{font-size:10px;color:var(--muted);font-weight:650}
.plotline-work-editor{padding:16px;overflow:hidden}
.plotline-work-empty{display:grid;place-items:center;align-content:center;min-height:440px;text-align:center;padding:30px;color:var(--muted)}
.plotline-work-empty b{font-size:16px;color:var(--text)}.plotline-work-empty p{max-width:420px;font-size:10px;line-height:1.6}
.plotline-work-detail-head{display:flex;align-items:start;justify-content:space-between;gap:12px;padding-bottom:12px;border-bottom:1px solid var(--line)}
.plotline-work-detail-head>div{min-width:0;flex:1}.plotline-work-detail-head input{width:min(540px,100%);margin-top:4px;padding:0!important;border:0!important;background:transparent!important;box-shadow:none!important;color:var(--text)!important;font:inherit!important;font-size:21px!important;font-weight:720!important}
.plotline-work-detail-head span{display:block;margin-top:2px;color:var(--muted);font-size:8px}
.plotline-work-fields{display:grid;grid-template-columns:1fr 1fr 130px;gap:9px;margin:13px 0}
.plotline-work-writing{display:grid;grid-template-columns:1.35fr 1fr 1fr;gap:9px}
.plotline-work-writing textarea{min-height:88px}
.plotline-work-columns{display:grid;grid-template-columns:1fr 1fr;gap:13px;margin-top:14px;padding-top:13px;border-top:1px solid var(--line)}
.plotline-codex-list{max-height:260px;overflow:auto}.plotline-scenes-list{display:flex;flex-direction:column;gap:5px;max-height:310px;overflow:auto}
.plotline-scenes-list button{display:flex;align-items:center;justify-content:space-between;gap:10px;width:100%;padding:8px 9px;border:1px solid var(--line);border-radius:9px;background:var(--surface-2);color:var(--text);text-align:left;font:inherit;cursor:pointer}
.plotline-scenes-list button:hover{border-color:color-mix(in srgb,var(--accent) 28%,var(--line));background:var(--accent-soft)}
.plotline-scenes-list b,.plotline-scenes-list small{display:block}.plotline-scenes-list b{font-size:10px}.plotline-scenes-list small{margin-top:2px;color:var(--muted);font-size:8px}.plotline-scenes-list em{font-style:normal;color:var(--accent)}

/* Timeline linker from Scene planning. */
.timeline-linker-head h2{margin:3px 0 4px;font-family:inherit}.timeline-linker-head>small{color:var(--accent);font-size:7px;letter-spacing:.1em;font-weight:750}.timeline-linker-head p{margin:0;color:var(--muted);font-size:9px;line-height:1.5}
.timeline-link-current{display:grid;grid-template-columns:minmax(0,1fr) auto auto;gap:7px;align-items:center;margin:13px 0;padding:10px;border:1px solid color-mix(in srgb,var(--accent) 25%,var(--line));border-radius:12px;background:var(--accent-soft)}
.timeline-link-current small,.timeline-link-current b,.timeline-link-current em{display:block}.timeline-link-current small{font-size:7px;color:var(--accent);letter-spacing:.08em}.timeline-link-current b{margin-top:2px;font-size:11px}.timeline-link-current em{margin-top:2px;font-size:8px;color:var(--muted);font-style:normal}
.timeline-linker-tools{display:grid;grid-template-columns:minmax(0,1fr) auto;gap:8px;align-items:center}.timeline-linker-tools .planning-inline-search{margin:0}.timeline-linker-list{display:flex;flex-direction:column;gap:5px;max-height:min(48vh,430px);overflow:auto;margin-top:9px}
.timeline-linker-list>button{display:grid;grid-template-columns:5px minmax(0,1fr) auto;gap:9px;align-items:center;width:100%;padding:9px;border:1px solid var(--line);border-radius:10px;background:var(--surface-2);color:var(--text);text-align:left;font:inherit;cursor:pointer}
.timeline-linker-list>button:hover,.timeline-linker-list>button.active{border-color:color-mix(in srgb,var(--accent) 27%,var(--line));background:var(--accent-soft)}
.timeline-linker-list>button>i{width:5px;height:29px;border-radius:999px;background:var(--event-color)}.timeline-linker-list b,.timeline-linker-list small{display:block}.timeline-linker-list b{font-size:10px}.timeline-linker-list small{margin-top:2px;color:var(--muted);font-size:8px}.timeline-linker-list>button>em{font-size:8px;color:var(--accent);font-style:normal}

/* Relationships: a ledger/card view, deliberately no network graph. */
.relationships-view{max-width:1460px}.relationship-page-stats{grid-template-columns:repeat(4,minmax(0,1fr))}
.relationship-ledger{padding:14px!important}.relationship-card-grid{display:grid!important;grid-template-columns:repeat(2,minmax(0,1fr));gap:9px!important;padding:0!important;background:none!important;border:0!important;box-shadow:none!important}
.relationship-card{position:relative;display:flex;flex-direction:column;gap:9px;min-width:0;padding:13px 13px 12px 17px;border:1px solid var(--line);border-radius:15px;background:var(--surface-2);color:var(--text);overflow:hidden}
.relationship-card-accent{position:absolute;left:0;top:12px;bottom:12px;width:5px;border-radius:0 999px 999px 0;background:var(--relation-color)}
.relationship-card header{display:flex;align-items:center;justify-content:space-between;gap:10px}.relationship-card-people{display:flex;align-items:center;gap:6px;min-width:0}.relationship-card-people button{min-width:0;padding:0;border:0;background:none;color:var(--text);font:inherit;font-size:13px;font-weight:720;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;cursor:pointer}.relationship-card-people button:hover{color:var(--accent)}.relationship-card-people>span{flex:0 0 auto;color:var(--muted);font-size:11px}.relationship-card-actions{display:flex;gap:3px;flex:0 0 auto}
.relationship-card-type{display:flex;align-items:center;gap:8px;min-width:0}.relationship-card-type b{font-size:11px}.relationship-card-type span{padding-left:8px;border-left:1px solid var(--line);color:var(--muted);font-size:8px}
.relationship-card-badges{display:flex;flex-wrap:wrap;gap:5px}.relationship-card-badges span{position:relative;padding:4px 8px 4px 13px;border:1px solid color-mix(in srgb,var(--badge-color) 25%,var(--line));border-radius:999px;background:color-mix(in srgb,var(--badge-color) 8%,transparent);font-size:8px}.relationship-card-badges span::before{content:"";position:absolute;left:6px;top:50%;width:4px;height:4px;transform:translateY(-50%);border-radius:999px;background:var(--badge-color)}
.relationship-card-intensity{display:grid;grid-template-columns:auto minmax(90px,1fr) auto;gap:8px;align-items:center}.relationship-card-intensity>span,.relationship-card-intensity>b{font-size:8px;color:var(--muted)}.relationship-card-intensity>div{display:grid;grid-template-columns:repeat(5,1fr);gap:3px}.relationship-card-intensity i{height:5px;border-radius:999px;background:color-mix(in srgb,var(--muted) 18%,transparent)}.relationship-card-intensity i.on{background:var(--relation-color)}
.relationship-card-dates{display:grid;grid-template-columns:1fr auto 1fr;gap:8px;align-items:center;padding:8px 9px;border:1px solid var(--line);border-radius:10px;background:color-mix(in srgb,var(--surface) 72%,transparent)}.relationship-card-dates span small,.relationship-card-dates span b{display:block}.relationship-card-dates span small{font-size:6.5px;letter-spacing:.08em;color:var(--muted)}.relationship-card-dates span b{margin-top:2px;font-size:9px}.relationship-card-dates em{color:var(--muted);font-style:normal}.relationship-card p{margin:0;color:var(--muted);font-size:9px;line-height:1.55}


/* Relationship editor and configurable taxonomies. */
.relationship-editor-modal{width:min(920px,94vw)!important}.relationship-editor-head small,.relationship-options-head small,.relationship-editor-section-head>small{color:var(--accent);font-size:7px;letter-spacing:.1em;font-weight:750}.relationship-editor-head h2,.relationship-options-head h2,.relationship-editor-section-head h3{font-family:inherit}.relationship-editor-head h2,.relationship-options-head h2{margin:2px 0 4px}.relationship-editor-head p,.relationship-options-head p,.relationship-editor-section-head p{margin:0;color:var(--muted);font-size:9px;line-height:1.5}
.relationship-editor-sections{display:grid;grid-template-columns:1.1fr .9fr;gap:10px;margin-top:13px}.relationship-editor-sections>section{padding:12px;border:1px solid var(--line);border-radius:14px;background:var(--surface-2);min-width:0}.relationship-editor-sections>section:first-child,.relationship-editor-sections>section:last-child{grid-row:span 1}.relationship-editor-sections>section:last-child{grid-column:1/-1}.relationship-editor-section-head{margin-bottom:10px}.relationship-editor-section-head h3{margin:2px 0 2px;font-size:13px}.field-with-action{display:grid;grid-template-columns:minmax(0,1fr) auto;gap:5px;align-items:center}.field-with-action .tiny-text-btn{white-space:nowrap}
.relationship-dates-grid{display:grid;grid-template-columns:1fr;gap:8px}.relationship-date-editor{padding:9px;border:1px solid var(--line);border-radius:10px;background:var(--surface)}.relationship-date-toggle{display:flex;gap:8px;align-items:center;cursor:pointer}.relationship-date-toggle input{width:15px;height:15px}.relationship-date-toggle span b,.relationship-date-toggle span small{display:block}.relationship-date-toggle span b{font-size:10px}.relationship-date-toggle span small{margin-top:1px;color:var(--muted);font-size:7px}.relationship-date-fields{display:grid;grid-template-columns:1.15fr .7fr 1fr .55fr;gap:5px;margin-top:8px}.relationship-date-fields :is(select,input){min-width:0;padding:6px!important;font-size:9px!important}
.relationship-linked-picker{margin:10px 0}.relationship-linked-list{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:5px;max-height:190px;overflow:auto}.relationship-linked-list label{display:grid;grid-template-columns:auto 6px minmax(0,1fr);gap:7px;align-items:center;padding:7px;border:1px solid var(--line);border-radius:9px;background:var(--surface);cursor:pointer}.relationship-linked-list label>i{width:6px;height:25px;border-radius:999px;background:var(--linked-color)}.relationship-linked-list span b,.relationship-linked-list span small{display:block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.relationship-linked-list span b{font-size:9px}.relationship-linked-list span small{margin-top:2px;color:var(--muted);font-size:7px}
.relationship-options-modal{width:min(780px,94vw)!important}.relationship-options-grid{display:grid;grid-template-columns:1fr 1fr;gap:10px;margin-top:13px}.relationship-option-block{padding:11px;border:1px solid var(--line);border-radius:13px;background:var(--surface-2)}.relationship-option-head{display:flex;align-items:center;justify-content:space-between;gap:8px}.relationship-option-head small{font-size:6.5px;letter-spacing:.09em;color:var(--accent)}.relationship-option-head h3{margin:2px 0 0;font:inherit;font-size:12px;font-weight:700}.relationship-option-list{display:flex;flex-direction:column;gap:5px;margin-top:9px}.relationship-option-list article{display:grid;grid-template-columns:6px minmax(0,1fr) 31px 31px;gap:6px;align-items:center;padding:7px;border:1px solid var(--line);border-radius:9px;background:var(--surface)}.relationship-option-list article>i{width:6px;height:26px;border-radius:999px;background:var(--option-color)}.relationship-option-list span b,.relationship-option-list span small{display:block}.relationship-option-list span b{font-size:9px}.relationship-option-list span small{font-size:7px;color:var(--muted)}

@media(max-width:1120px){
  .relationship-card-grid{grid-template-columns:1fr!important}
  .plotline-work-writing{grid-template-columns:1fr 1fr}.plotline-work-writing>.form-row:first-child{grid-column:1/-1}
  .relationship-editor-sections{grid-template-columns:1fr}.relationship-editor-sections>section:last-child{grid-column:auto}
}
@media(max-width:900px){
  .planning-modebar{grid-template-columns:1fr 1fr auto}.planning-modebar>span{display:none}.planning-modebar .soft-btn{grid-column:1/-1;justify-self:start}
  .plotline-work-layout{grid-template-columns:1fr;min-height:0}.plotline-work-list{max-height:260px}.plotline-work-editor{padding:13px}.plotline-work-fields{grid-template-columns:1fr 1fr}.plotline-work-fields>.form-row:last-child{grid-column:1/-1}.plotline-work-columns{grid-template-columns:1fr}.plotline-work-writing{grid-template-columns:1fr}
  .relationship-page-toolbar{grid-template-columns:1fr 1fr!important}.relationship-page-toolbar>.search-wrap{grid-column:1/-1}.relationship-page-toolbar label:first-of-type{grid-column:1/-1}
  .relationship-options-grid{grid-template-columns:1fr}.relationship-linked-list{grid-template-columns:1fr}.relationship-date-fields{grid-template-columns:1fr 1fr}
}
@media(pointer:coarse){
  .planning-modebar>button,.search-choice-input input,.search-choice-menu button,.planning-inline-search input,.plotline-work-row,.timeline-linker-list>button,.relationship-card-people button{min-height:44px!important}
  .relationship-card-actions .outline-icon-btn,.relationship-option-list .outline-icon-btn{width:40px!important;height:40px!important;min-width:40px!important}
  .plotline-work-row span b,.relationship-card-people button{font-size:13px}
}


/* ========================================================================== 
   SYLVA BETA 0.99 · READABILITY + SCENE CALENDAR + RELATION CONTEXT · 2026-08-19
   No theme fonts are replaced: all controls inherit the active Sylva theme.
   ========================================================================== */

/* Searchable fields: selected value is separate, the search box stays empty and ready to type. */
.search-choice{display:flex;flex-direction:column;gap:7px}
.search-choice-current{display:flex;align-items:center;gap:9px;min-height:42px;padding:8px 10px;border:1px solid var(--line);border-radius:11px;background:color-mix(in srgb,var(--surface-2) 86%,transparent);font-family:inherit}
.search-choice-current>i{width:6px;height:27px;flex:0 0 6px;border-radius:999px;background:var(--choice-color,var(--accent))}
.search-choice-current>span{min-width:0;flex:1}.search-choice-current>span small,.search-choice-current>span b{display:block;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.search-choice-current>span small{font-size:9.5px;letter-spacing:.07em;color:var(--muted);font-weight:700}.search-choice-current>span b{margin-top:2px;font-size:13px;color:var(--text);font-weight:650}
.search-choice-current>span.empty b{color:var(--muted);font-weight:550}.search-choice-current>button{width:28px;height:28px;min-width:28px;padding:0;border:0;border-radius:8px;background:transparent;color:var(--muted);font:inherit;font-size:17px;cursor:pointer}.search-choice-current>button:hover{background:var(--accent-soft);color:var(--text)}
.search-choice-input input{min-height:42px!important;font-size:13px!important;padding:9px 36px 9px 11px!important}
.search-choice-menu{max-height:290px;padding:7px;border-radius:13px}.search-choice-menu button{min-height:43px;padding:9px 10px;border-radius:9px}.search-choice-menu button span{font-size:13px}.search-choice-menu button small{font-size:10px}

/* Planning navigation now reads as navigation, not as two tiny utility buttons. */
.planning-modebar{grid-template-columns:minmax(230px,auto) minmax(270px,auto) 1fr auto!important;gap:9px!important;padding:8px!important;margin-bottom:18px!important;border-radius:18px!important;align-items:stretch!important}
.planning-modebar .planning-mode-tab{display:flex!important;align-items:center!important;gap:11px!important;min-height:62px!important;padding:10px 14px!important;border:1px solid transparent!important;border-radius:13px!important;background:transparent!important;color:var(--text)!important;text-align:left!important;font:inherit!important;cursor:pointer!important}
.planning-modebar .planning-mode-tab:hover{background:var(--surface-2)!important;border-color:var(--line)!important}.planning-modebar .planning-mode-tab.active{background:var(--accent-soft)!important;border-color:color-mix(in srgb,var(--accent) 30%,var(--line))!important;box-shadow:inset 3px 0 var(--accent)!important}
.planning-mode-icon{display:grid;place-items:center;width:34px;height:34px;flex:0 0 34px;border:1px solid var(--line);border-radius:10px;color:var(--accent);font-size:18px;background:var(--surface)}
.planning-mode-tab>span:last-child b,.planning-mode-tab>span:last-child small{display:block}.planning-mode-tab>span:last-child b{font-size:14px;font-weight:720}.planning-mode-tab>span:last-child small{margin-top:3px;font-size:10.5px;line-height:1.35;color:var(--muted);font-weight:450}
.planning-mode-spacer{min-width:8px}.planning-status-entry{display:flex!important;align-items:center!important;gap:9px!important;min-height:62px!important;padding:9px 13px!important;text-align:left!important}.planning-status-entry>span:first-child{font-size:17px;color:var(--accent)}.planning-status-entry span:last-child b,.planning-status-entry span:last-child small{display:block}.planning-status-entry span:last-child b{font-size:12.5px}.planning-status-entry span:last-child small{font-size:9.5px;margin-top:2px;color:var(--muted)}

/* Scene planning readability. */
.planning-inline-search{min-height:43px;margin:9px 0;padding:0 11px;border-radius:11px}.planning-inline-search>span{font-size:17px}.planning-inline-search input{min-height:41px!important;font-size:13px!important;padding:7px 0!important}
.planning-picker-head b{font-size:13px}.planning-picker-head span,.planning-picker-head .tiny-text-btn{font-size:10.5px!important}.planning-check-list .narrative-check{min-height:38px}.planning-check-list .narrative-check span{font-size:12px}
.planning-linked-event span small{font-size:9.5px!important}.planning-linked-event span b{font-size:13px!important}.planning-linked-event span em{font-size:10.5px!important;line-height:1.4!important}.planning-linked-event>strong{font-size:20px!important}

/* Calendar-backed time for Scene planning. */
.scene-calendar-editor{grid-column:1/-1;margin-top:14px;padding:13px;border:1px solid var(--line);border-radius:14px;background:color-mix(in srgb,var(--surface-2) 84%,transparent)}
.scene-calendar-head{display:flex;align-items:center;justify-content:space-between;gap:12px;margin-bottom:11px}.scene-calendar-head>div b,.scene-calendar-head>div small{display:block}.scene-calendar-head>div b{font-size:13.5px}.scene-calendar-head>div small{margin-top:3px;font-size:10px;line-height:1.4;color:var(--muted)}
.scene-date-toggle{display:flex;align-items:center;gap:7px;flex:0 0 auto;padding:7px 9px;border:1px solid var(--line);border-radius:10px;background:var(--surface);cursor:pointer}.scene-date-toggle input{width:17px;height:17px}.scene-date-toggle span{font-size:11px;font-weight:650;color:var(--text)}
.scene-calendar-grid{display:grid;grid-template-columns:minmax(160px,1.35fr) minmax(80px,.65fr) minmax(145px,1.1fr) minmax(80px,.6fr) minmax(130px,1fr);gap:9px}.scene-calendar-grid label{display:flex;flex-direction:column;gap:5px;min-width:0}.scene-calendar-grid label>span{font-size:10px;letter-spacing:.05em;color:var(--muted);font-weight:700}.scene-calendar-grid :is(select,input){width:100%;min-width:0;min-height:42px!important;padding:8px 9px!important;font:inherit!important;font-size:12.5px!important}.scene-calendar-sync-note{display:block;margin-top:9px;font-size:9.5px;line-height:1.4;color:var(--muted)}
.scene-card-modal .scene-calendar-editor{grid-column:1/-1;margin-top:0}

/* Scene-state manager is an actual readable management screen. */
.scene-status-modal{width:min(760px,94vw)!important}.scene-status-modal .modal-title-row{align-items:flex-start;gap:22px}.scene-status-modal .modal-title-row small{font-size:10px;letter-spacing:.1em;color:var(--accent);font-weight:750}.scene-status-modal .modal-title-row h2{font-size:27px;margin:4px 0 7px}.scene-status-modal .modal-title-row p{max-width:540px;font-size:12px;line-height:1.55;color:var(--muted)}.scene-status-modal .modal-title-row .primary-btn{min-height:44px;padding:10px 14px!important;font-size:12px!important;white-space:nowrap}
.scene-status-manager{gap:9px;margin-top:18px}.scene-status-manager article{grid-template-columns:8px minmax(0,1fr) 40px 40px;gap:10px;min-height:60px;padding:10px 11px;border-radius:13px}.scene-status-manager article>i{width:7px;height:36px}.scene-status-manager article span b{font-size:14px}.scene-status-manager article span small{font-size:10.5px;margin-top:3px}.scene-status-manager .outline-icon-btn{width:38px;height:38px;min-width:38px}

/* Plotline workspace: keep depth, remove miniature typography. */
.planning-plotline-workspace{min-height:570px}.plotline-work-layout{grid-template-columns:minmax(280px,.78fr) minmax(0,1.72fr);gap:16px;min-height:570px}.plotline-work-list{padding:14px;gap:8px}.plotline-work-list-head{padding:5px 4px 11px}.plotline-work-list-head small,.plotline-work-detail-head small{font-size:9.5px!important;letter-spacing:.1em}.plotline-work-list-head h3{font-size:17px;margin-top:4px}.plotline-work-list-head .primary-btn{width:auto!important;height:40px!important;min-width:0!important;padding:8px 12px!important;font-size:11px!important}
.plotline-work-row{grid-template-columns:6px minmax(0,1fr) auto;gap:11px;min-height:61px;padding:11px;border-radius:13px}.plotline-work-row>i{width:6px;height:38px}.plotline-work-row span b{font-size:13.5px}.plotline-work-row span small{margin-top:4px;font-size:10.5px}.plotline-work-row strong{font-size:12px}.plotline-work-editor{padding:20px}.plotline-work-detail-head input{font-size:24px!important}.plotline-work-detail-head span{font-size:10.5px;margin-top:4px}.plotline-work-fields{gap:12px;margin:17px 0}.plotline-work-fields .form-row label,.plotline-work-writing .form-row label{font-size:10.5px!important}.plotline-work-fields :is(select,input),.plotline-work-writing textarea{font-size:13px!important}.plotline-work-writing{gap:12px}.plotline-work-writing textarea{min-height:108px}.plotline-work-columns{gap:16px;margin-top:18px;padding-top:17px}.plotline-scenes-list{gap:7px}.plotline-scenes-list button{min-height:52px;padding:10px 11px;border-radius:11px}.plotline-scenes-list b{font-size:12.5px}.plotline-scenes-list small{font-size:10px;margin-top:3px}.plotline-work-empty b{font-size:19px}.plotline-work-empty p{font-size:12px}

/* Timeline moment presets match Scene planning without removing custom fantasy moments. */
.timeline-moment-presets{display:flex;flex-wrap:wrap;gap:7px;margin-bottom:7px}.timeline-moment-presets button{min-height:34px;padding:6px 10px;border:1px solid var(--line);border-radius:999px;background:var(--surface-2);color:var(--text);font:inherit;font-size:11px;cursor:pointer}.timeline-moment-presets button:hover{background:var(--accent-soft);border-color:color-mix(in srgb,var(--accent) 30%,var(--line))}.timeline-moment-field>small{font-size:10px!important;line-height:1.45!important}

/* Relationship ledger readability. */
.relationship-ledger{padding:20px!important}.relationship-card-grid{gap:14px!important}.relationship-card{gap:12px;padding:17px 17px 16px 22px;border-radius:18px;cursor:pointer}.relationship-card.expanded{grid-column:1/-1;border-color:color-mix(in srgb,var(--relation-color) 42%,var(--line));background:color-mix(in srgb,var(--relation-color) 3%,var(--surface-2))}.relationship-card-accent{top:15px;bottom:15px;width:6px}.relationship-card-people{gap:8px!important}.relationship-card-people button{font-size:15px!important}.relationship-card-people>span{font-size:13px!important}.relationship-card-actions{gap:5px}.relationship-card-type{gap:10px!important}.relationship-card-type b{font-size:13px!important}.relationship-card-type>span{font-size:10.5px!important;padding-left:10px!important}.relationship-related-trigger{margin-left:auto;padding:6px 9px;border:1px solid var(--line);border-radius:9px;background:var(--surface);color:var(--muted);font:inherit;font-size:10.5px;cursor:pointer}.relationship-related-trigger:hover{background:var(--accent-soft);color:var(--text)}
.relationship-card-badges{gap:7px}.relationship-card-badges span{padding:5px 10px 5px 16px!important;font-size:10.5px!important}.relationship-card-badges span::before{left:7px!important;width:5px!important;height:5px!important}.relationship-card-intensity{grid-template-columns:auto minmax(130px,1fr) auto;gap:10px}.relationship-card-intensity>span,.relationship-card-intensity>b{font-size:10.5px!important}.relationship-card-intensity>div{gap:4px}.relationship-card-intensity i{height:6px}.relationship-card-dates{padding:10px 12px;border-radius:12px}.relationship-card-dates span small{font-size:9px!important}.relationship-card-dates span b{font-size:11.5px!important;margin-top:3px!important}.relationship-card p{font-size:11.5px!important;line-height:1.55!important}
.relationship-related-context{margin-top:4px;padding-top:15px;border-top:1px solid var(--line)}.relationship-related-head{display:flex;align-items:flex-start;justify-content:space-between;gap:18px;margin-bottom:13px}.relationship-related-head>div{min-width:0}.relationship-related-head small,.relationship-related-head b,.relationship-related-head p{display:block}.relationship-related-head small{font-size:9px;letter-spacing:.09em;color:var(--accent);font-weight:750}.relationship-related-head b{margin-top:3px;font-size:15px}.relationship-related-head p{margin-top:5px!important;max-width:720px;font-size:10.5px!important;color:var(--muted)}.relationship-related-columns{display:grid;grid-template-columns:1fr 1fr;gap:13px}.relationship-related-columns>section{padding:12px;border:1px solid var(--line);border-radius:13px;background:var(--surface)}.relationship-related-columns h4{margin:0 0 9px;font:inherit;font-size:12.5px;font-weight:700}.relationship-related-mini{display:grid;grid-template-columns:6px minmax(0,1fr) auto;gap:9px;align-items:center;width:100%;min-height:48px;margin-top:6px;padding:8px 9px;border:1px solid var(--line);border-radius:10px;background:var(--surface-2);color:var(--text);text-align:left;font:inherit;cursor:pointer}.relationship-related-mini:hover{background:var(--accent-soft);border-color:color-mix(in srgb,var(--accent) 28%,var(--line))}.relationship-related-mini>i{width:6px;height:30px;border-radius:999px;background:var(--related-color)}.relationship-related-mini span b,.relationship-related-mini span small{display:block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.relationship-related-mini span b{font-size:12px}.relationship-related-mini span small{margin-top:3px;font-size:9.5px;color:var(--muted)}.relationship-related-mini em{font-size:9px;font-style:normal;color:var(--accent)}.relationship-related-empty{font-size:10.5px!important;color:var(--muted)!important}

/* Relationship management/editor: remove the miniature 6–9px typography. */
.relationship-editor-modal{width:min(980px,95vw)!important}.relationship-options-modal{width:min(900px,95vw)!important}.relationship-editor-head small,.relationship-options-head small,.relationship-editor-section-head>small{font-size:9.5px!important}.relationship-editor-head h2,.relationship-options-head h2{font-size:28px!important;margin:4px 0 7px!important}.relationship-editor-head p,.relationship-options-head p,.relationship-editor-section-head p{font-size:11.5px!important;line-height:1.55!important}.relationship-editor-sections{gap:14px;margin-top:17px}.relationship-editor-sections>section{padding:16px;border-radius:16px}.relationship-editor-section-head{margin-bottom:13px}.relationship-editor-section-head h3{font-size:16px!important}.relationship-date-editor{padding:12px;border-radius:12px}.relationship-date-toggle input{width:17px;height:17px}.relationship-date-toggle span b{font-size:12.5px!important}.relationship-date-toggle span small{font-size:10px!important;margin-top:3px!important}.relationship-date-fields{gap:8px;margin-top:10px}.relationship-date-fields :is(select,input){min-height:41px!important;padding:8px!important;font-size:12px!important}.relationship-linked-list{gap:7px;max-height:240px}.relationship-linked-list label{gap:9px;padding:9px;border-radius:11px}.relationship-linked-list label>i{height:31px}.relationship-linked-list span b{font-size:11.5px!important}.relationship-linked-list span small{font-size:9.5px!important}
.relationship-options-grid{gap:14px;margin-top:17px}.relationship-option-block{padding:15px;border-radius:15px}.relationship-option-head small{font-size:9px!important}.relationship-option-head h3{font-size:15px!important}.relationship-option-head .soft-btn{min-height:40px;font-size:11px!important}.relationship-option-list{gap:8px;margin-top:12px}.relationship-option-list article{grid-template-columns:7px minmax(0,1fr) 38px 38px;gap:9px;min-height:56px;padding:9px 10px;border-radius:11px}.relationship-option-list article>i{width:7px;height:34px}.relationship-option-list span b{font-size:12.5px!important}.relationship-option-list span small{font-size:10px!important;margin-top:2px}.relationship-option-list .outline-icon-btn{width:36px;height:36px;min-width:36px}

/* Relationship filters also need room for the explicit reset button. */
.relationship-page-toolbar{grid-template-columns:minmax(220px,1.15fr) minmax(210px,1fr) minmax(150px,.72fr) minmax(150px,.72fr) auto!important;gap:12px!important;align-items:end!important}.relationship-page-toolbar label>span{font-size:10.5px!important}.relationship-page-toolbar select,.relationship-page-toolbar input{height:46px!important;font-size:13px!important}.relationship-show-all{height:46px;white-space:nowrap;padding:9px 13px!important;font-size:11px!important}

/* Calendar readability: preserve compactness, remove 7–9px labels. */
.calendar-section-head small{font-size:10px!important}.calendar-section-head h3{font-size:22px!important}.calendar-section-head>span{font-size:10px!important}.calendar-section-head>div>p{font-size:11.5px!important;line-height:1.55!important;margin-top:6px!important}.calendar-section-head>.soft-btn{min-height:41px;padding:9px 12px!important;font-size:11px!important}.calendar-foundation-grid .form-row label{font-size:10.5px!important}.calendar-foundation-grid input{min-height:45px!important;font-size:13.5px!important}.calendar-foundation-grid .form-row>small{font-size:10px!important}.weekday-preview>span{font-size:10.5px!important;padding:7px 10px!important}.weekday-preview>span b{font-size:9.5px!important}
.calendar-era-card{padding:14px 15px!important;border-radius:17px!important}.calendar-era-heading{margin-bottom:12px!important}.calendar-era-heading small{font-size:9.5px!important}.calendar-era-heading b{font-size:15.5px!important}.calendar-era-titleline em{font-size:10px!important;padding:3px 8px!important}.calendar-era-move .outline-icon-btn{width:36px!important;height:36px!important;min-width:36px!important}.calendar-era-fields{gap:10px!important}.calendar-era-fields label{gap:6px!important}.calendar-era-fields label>span{font-size:10.5px!important}.calendar-era-fields input,.calendar-era-fields select{min-height:43px!important;padding:9px 10px!important;font-size:13px!important}
.calendar-month-grid{gap:11px!important}.calendar-month-compact{grid-template-columns:38px minmax(0,1fr) auto 38px!important;gap:11px!important;padding:12px!important;border-radius:16px!important}.calendar-month-order{font-size:12px!important}.calendar-month-name>span,.calendar-days-compact>span{font-size:9.5px!important}.calendar-month-name input{min-height:42px!important;font-size:13px!important;padding:8px 10px!important}.calendar-days-compact>div{grid-template-columns:34px 58px 34px!important}.calendar-days-compact button{min-height:40px!important;font-size:15px!important}.calendar-days-compact input{width:58px!important;min-height:40px!important;font-size:12.5px!important}.calendar-days-compact>small{font-size:9.5px!important}.calendar-month-compact>.outline-icon-btn{width:36px!important;height:36px!important;min-width:36px!important}

@media(max-width:1120px){
  .planning-modebar{grid-template-columns:1fr 1fr!important}.planning-mode-spacer{display:none}.planning-status-entry{grid-column:1/-1;justify-self:start}
  .scene-calendar-grid{grid-template-columns:1fr 1fr 1fr 1fr}.scene-calendar-daypart{grid-column:1/-1}
  .relationship-page-toolbar{grid-template-columns:1fr 1fr!important}.relationship-page-toolbar>.search-wrap{grid-column:1/-1}.relationship-show-all{justify-self:start}
}
@media(max-width:900px){
  .planning-modebar{grid-template-columns:1fr!important}.planning-status-entry{grid-column:auto!important;width:100%;justify-content:flex-start!important}.planning-mode-tab{width:100%}
  .plotline-work-layout{grid-template-columns:1fr;min-height:0}.plotline-work-list{max-height:330px}.plotline-work-editor{padding:16px}.relationship-related-columns{grid-template-columns:1fr}
  .scene-calendar-grid{grid-template-columns:1fr 1fr}.scene-calendar-daypart{grid-column:1/-1}.scene-calendar-head{align-items:flex-start}
  .relationship-page-toolbar{grid-template-columns:1fr 1fr!important}.relationship-show-all{width:100%;justify-content:center!important}
}
@media(max-width:620px){
  .scene-calendar-head{flex-direction:column}.scene-calendar-grid{grid-template-columns:1fr}.scene-calendar-daypart{grid-column:auto}.scene-date-toggle{width:100%;justify-content:center}
  .relationship-page-toolbar{grid-template-columns:1fr!important}.relationship-page-toolbar>.search-wrap{grid-column:auto}.relationship-related-head{flex-direction:column}.relationship-related-head>.soft-btn{width:100%}
}
@media(pointer:coarse){
  .planning-modebar .planning-mode-tab,.planning-status-entry{min-height:66px!important}.search-choice-input input,.search-choice-menu button{min-height:46px!important}.scene-calendar-grid :is(select,input){min-height:46px!important}.scene-date-toggle{min-height:44px}.relationship-related-mini{min-height:52px}.timeline-moment-presets button{min-height:40px}
}

/* Final readability floor after 0.99 review: these workspaces are used for long sessions. */
.planning-mode-tab>span:last-child small,.planning-status-entry span:last-child small{font-size:11px!important}
.scene-calendar-head>div small,.scene-calendar-grid label>span,.scene-calendar-sync-note{font-size:11px!important}
.timeline-moment-presets button{min-height:38px;font-size:12px!important}.timeline-moment-field>small{font-size:11px!important}
.plotline-work-list-head small,.plotline-work-detail-head small{font-size:10.5px!important}.plotline-work-row span small,.plotline-work-detail-head span,.plotline-scenes-list small{font-size:11px!important}.plotline-work-fields .form-row label,.plotline-work-writing .form-row label{font-size:11px!important}
.relationship-card-type>span,.relationship-related-trigger,.relationship-card-badges span,.relationship-card-intensity>span,.relationship-card-intensity>b{font-size:11.5px!important}
.relationship-card-dates span small,.relationship-related-head small,.relationship-related-mini em{font-size:10.5px!important}.relationship-card-dates span b{font-size:12.5px!important}.relationship-card p{font-size:12px!important}
.relationship-related-head p,.relationship-related-empty{font-size:11.5px!important}.relationship-related-columns h4{font-size:13.5px!important}.relationship-related-mini span b{font-size:12.5px!important}.relationship-related-mini span small{font-size:10.5px!important}
.relationship-editor-head small,.relationship-options-head small,.relationship-editor-section-head>small,.relationship-option-head small{font-size:10.5px!important}.relationship-editor-head p,.relationship-options-head p,.relationship-editor-section-head p{font-size:12px!important}.relationship-date-toggle span small,.relationship-linked-list span small,.relationship-option-list span small{font-size:10.5px!important}.relationship-page-toolbar label>span{font-size:11px!important}.relationship-show-all{font-size:12px!important}
.calendar-section-head small,.calendar-section-head>span,.calendar-foundation-grid .form-row label,.calendar-foundation-grid .form-row>small,.calendar-era-heading small,.calendar-era-titleline em,.calendar-era-fields label>span,.calendar-month-name>span,.calendar-days-compact>span,.calendar-days-compact>small{font-size:11px!important}
.calendar-section-head>div>p{font-size:12px!important}.calendar-section-head>.soft-btn{font-size:12px!important}.weekday-preview>span{font-size:11.5px!important}.weekday-preview>span b{font-size:10.5px!important}
/* The support views opened from Planning use the same readability floor. */
.planning-stats span,.relationship-page-stats span,.calendar-summary span,.timeline-stats span{font-size:11px!important}
.timeline-linker-modal{width:min(780px,94vw)!important}.timeline-linker-head>small{font-size:10.5px!important}.timeline-linker-head h2{font-size:27px!important;margin:4px 0 7px!important}.timeline-linker-head p{font-size:12px!important;line-height:1.55!important}.timeline-linker-list{gap:8px!important;margin-top:12px!important}.timeline-linker-list>button{min-height:57px!important;padding:10px 11px!important;border-radius:12px!important}.timeline-linker-list b{font-size:13px!important}.timeline-linker-list small{font-size:10.5px!important;margin-top:3px!important}.timeline-linker-list>button>em{font-size:10.5px!important}
.timeline-event-modal .form-row>label,.timeline-event-modal .form-row label:not(.narrative-check){font-size:11px!important}.timeline-event-modal .form-row>small{font-size:10.5px!important;line-height:1.45!important}.timeline-event-modal :is(input,select,textarea){font-size:13px!important}.timeline-codex-head small{font-size:10.5px!important}.timeline-codex-head p,.timeline-codex-head>span{font-size:11px!important}.event-codex-picker label{font-size:12px!important;min-height:38px!important}
.timeline-link-current{padding:12px!important;gap:9px!important}.timeline-link-current small{font-size:10.5px!important}.timeline-link-current b{font-size:13.5px!important}.timeline-link-current em{font-size:10.5px!important}.timeline-link-current .soft-btn{min-height:40px;font-size:11px!important}
@media (min-width:621px) and (max-width:900px){
  .planning-modebar{grid-template-columns:1fr 1fr!important}
  .planning-status-entry{grid-column:1/-1!important;width:100%!important;justify-content:flex-start!important}
}

/* 0.99 QA · explicit related-relationship context */
.relationship-explicit-links{margin:14px 0 4px;padding:13px;border:1px solid var(--line);border-radius:14px;background:color-mix(in srgb,var(--surface) 72%,transparent)}
.relationship-explicit-links>h4{margin:0 0 9px;font-size:13.5px;font-weight:700;color:var(--text)}
.relationship-explicit-links>div{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px}
.relationship-related-mini.explicit{background:color-mix(in srgb,var(--accent-soft) 45%,var(--surface-2))}
@media(max-width:900px){.relationship-explicit-links>div{grid-template-columns:1fr}}


/* Sylva Beta 0.996 · conservative legacy cleanup */
.timeline-link-current-list{display:flex;flex-direction:column;gap:8px;margin:15px 0 17px}
.timeline-link-current-head{display:flex;align-items:center;justify-content:space-between;gap:12px;padding:0 2px}
.timeline-link-current-head small{font-size:10.5px;letter-spacing:.1em;color:var(--accent);font-weight:750}
.timeline-link-current-head b{display:grid;place-items:center;min-width:28px;height:28px;padding:0 8px;border:1px solid var(--line);border-radius:999px;background:var(--surface-2);font-size:12px}
.timeline-link-current-list .timeline-link-current{margin:0}
.scene-card-timeline-box em{display:block;margin-top:3px;color:var(--muted);font-size:10px;font-style:normal;line-height:1.35;max-width:260px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.plotline-status-manager article>i{box-shadow:0 0 0 3px color-mix(in srgb,var(--status-color) 12%,transparent)}
@media(max-width:760px){
  .timeline-link-current-list .timeline-link-current{grid-template-columns:minmax(0,1fr) 1fr 1fr}
  .timeline-link-current-list .timeline-link-current>span{grid-column:1/-1}
  .timeline-link-current-list .timeline-link-current .soft-btn{width:100%}
  .scene-card-timeline-box em{max-width:190px}
}

.plotline-state-meta{display:inline-flex;align-items:center;gap:5px;font:inherit;font-style:normal;color:inherit}.plotline-state-meta>i{width:7px;height:7px;border-radius:50%;background:var(--plot-state-color,var(--accent));box-shadow:0 0 0 2px color-mix(in srgb,var(--plot-state-color,var(--accent)) 16%,transparent)}


/* 0.996 · planning / analysis refinement */
.analysis-view{width:min(1400px,98%)}
.analysis-view .view-heading p{font-size:14px;line-height:1.6}
.analysis-view .stats-grid{gap:12px;margin-bottom:18px}
.analysis-view .stat-card{padding:20px;border-radius:20px}
.analysis-view .stat-card b{font-size:27px}
.analysis-view .stat-card span{font-size:10.5px;letter-spacing:.08em}
.analysis-view .analysis-card{padding:22px;border-radius:22px}
.analysis-view .card-head{margin-bottom:17px}
.analysis-view .card-head small{font-size:10px;letter-spacing:.12em}
.analysis-view .card-head h3{font-size:18px;margin-top:4px}
.analysis-view .metric-note{font-size:11px}
.analysis-view .bar-row{grid-template-columns:minmax(110px,180px) 1fr 68px;gap:12px;font-size:12px}
.analysis-view .bar-row strong{font-size:12.5px}
.analysis-view .bar-track{height:10px}
.analysis-view .presence-row{padding:10px 0;font-size:13px}
.analysis-view .donut-wrap{grid-template-columns:170px 1fr;gap:24px;min-height:200px}
.analysis-view .donut{width:170px}
.analysis-view .donut::after{inset:31px}
.analysis-view .donut-center b{font-size:24px}
.analysis-view .donut-center span{font-size:10px}
.analysis-view .legend-row{font-size:11px}
.analysis-view .detail-metrics{gap:11px}
.analysis-view .detail-metric{padding:14px 15px;border-radius:15px}
.analysis-view .detail-metric b{font-size:19px;margin-bottom:5px}
.analysis-view .detail-metric span{font-size:10.5px;line-height:1.45}
.analysis-view .scene-chart-inner{height:240px}
.analysis-view .scene-bar-wrap{width:58px;min-width:58px;grid-template-rows:24px 1fr 34px}
.analysis-view .scene-value{font-size:9.5px}
.analysis-view .scene-column{width:30px}
.analysis-view .scene-axis-label{font-size:9px}
.analysis-view .scene-chart-legend{font-size:9.5px}
.analysis-view .heatmap-head,.analysis-view .heatmap-name{font-size:10px}
.analysis-view .heatmap-name{width:170px}
.analysis-view .heat-cell{width:28px;height:28px;font-size:9px}
.analysis-view .svg-chart svg text{font-size:11px}
.analysis-view .empty-state{font-size:13px}
.analysis-view .session-stat b{font-size:18px}
.analysis-view .session-stat span{font-size:9px}
.analysis-view .daily-goal-summary b{font-size:18px}
.analysis-view .daily-goal-summary span,.analysis-view .daily-goal-subhead span{font-size:10px}
.analysis-view .daily-goal-subhead b{font-size:13px}
.analysis-view .narrative-stat-row b,.analysis-view .plotline-analysis-row b{font-size:13px}
.analysis-view .narrative-stat-row span,.analysis-view .narrative-stat-row em,.analysis-view .plotline-analysis-row span,.analysis-view .plotline-analysis-row em{font-size:10.5px}
.analysis-view .mini-meta-bar b{font-size:12.5px}.analysis-view .mini-meta-bar span{font-size:10.5px}
.analysis-view .book-goal-copy strong{font-size:18px}.analysis-view .book-goal-copy span{font-size:11px}
.analysis-view .timeline-analysis-metrics div b,.analysis-view .continuity-analysis-score b{font-size:19px}
.analysis-view .timeline-analysis-metrics div span,.analysis-view .continuity-analysis-score span,.analysis-view .continuity-analysis-copy b{font-size:11px}

.analysis-coverage-list,.analysis-daypart-list{display:grid;gap:10px}
.analysis-coverage-row,.analysis-daypart-row{display:grid;grid-template-columns:minmax(0,1fr) auto;gap:12px;align-items:center;padding:11px 12px;border:1px solid var(--line);border-radius:14px;background:color-mix(in srgb,var(--surface-2) 82%,transparent)}
.analysis-coverage-copy,.analysis-daypart-row>span{display:grid;gap:8px;min-width:0}
.analysis-coverage-copy>span,.analysis-daypart-row>span{display:flex;justify-content:space-between;gap:10px;align-items:center;min-width:0}
.analysis-coverage-copy b,.analysis-daypart-row b{font-size:12.5px;font-weight:650;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.analysis-coverage-copy em,.analysis-daypart-row em{font-style:normal;font-size:10.5px;color:var(--muted);white-space:nowrap}
.analysis-coverage-copy i,.analysis-daypart-row i{display:block;height:9px;border-radius:999px;background:color-mix(in srgb,var(--line) 80%,transparent);overflow:hidden}
.analysis-coverage-copy u,.analysis-daypart-row u{display:block;height:100%;border-radius:999px;background:linear-gradient(90deg,var(--accent),var(--accent-2))}
.analysis-coverage-row strong,.analysis-daypart-row strong{font-size:12px;color:var(--accent);font-weight:700}
.analysis-daypart-row.undefined strong{color:var(--muted)}

.scene-calendar-editor{padding:16px 16px 14px;border-radius:16px}
.scene-calendar-head{margin-bottom:13px}
.scene-calendar-head>div b{font-size:14px}
.scene-calendar-head>div small{font-size:10.5px;line-height:1.45;max-width:540px}
.scene-date-toggle{padding:8px 11px;border-radius:11px}
.scene-date-toggle span{font-size:11.5px}
.scene-calendar-grid{display:grid;grid-template-columns:repeat(12,minmax(0,1fr));gap:10px}
.scene-calendar-grid label{gap:6px}
.scene-calendar-grid label>span{font-size:10.5px;letter-spacing:.04em}
.scene-calendar-grid :is(select,input){min-height:44px!important;padding:9px 10px!important;font-size:13px!important}
.scene-field-era{grid-column:span 4}.scene-field-year{grid-column:span 2}.scene-field-month{grid-column:span 3}.scene-field-day{grid-column:span 1}.scene-field-daypart{grid-column:span 2}
.scene-calendar-sync-note{margin-top:10px;font-size:10px;line-height:1.5;max-width:640px}

@media(max-width:1120px){
  .analysis-view .stats-grid-rich{grid-template-columns:repeat(4,minmax(0,1fr))}
  .analysis-view .donut-wrap{grid-template-columns:150px 1fr}
  .scene-field-era{grid-column:span 5}.scene-field-year{grid-column:span 2}.scene-field-month{grid-column:span 3}.scene-field-day{grid-column:span 2}.scene-field-daypart{grid-column:1/-1}
}
@media(max-width:900px){
  .analysis-view .analysis-grid,.analysis-view .analysis-grid-main,.analysis-view .narrative-analysis-grid,.analysis-view .chronology-analysis-grid,.analysis-view .planning-analysis-grid{grid-template-columns:1fr!important}
  .analysis-view .stats-grid-rich{grid-template-columns:repeat(2,minmax(0,1fr))}
  .analysis-view .analysis-card{padding:18px}
  .analysis-view .stat-card{padding:16px}
  .analysis-view .stat-card b{font-size:24px}
  .analysis-view .donut-wrap{grid-template-columns:1fr;justify-items:center;text-align:left}
  .analysis-view .donut-legend{width:100%}
  .analysis-view .bar-row{grid-template-columns:minmax(96px,150px) 1fr 58px}
  .analysis-coverage-row,.analysis-daypart-row{grid-template-columns:1fr}
  .analysis-coverage-row strong,.analysis-daypart-row strong{justify-self:start}
  .scene-calendar-grid{grid-template-columns:repeat(6,minmax(0,1fr))}
  .scene-field-era{grid-column:span 3}.scene-field-year{grid-column:span 3}.scene-field-month{grid-column:span 3}.scene-field-day{grid-column:span 1}.scene-field-daypart{grid-column:span 2}
}
@media(max-width:620px){
  .analysis-view .stats-grid-rich{grid-template-columns:1fr 1fr}
  .analysis-view .stat-card b{font-size:22px}
  .analysis-view .card-head h3{font-size:16px}
  .analysis-view .metric-note{font-size:10px}
  .analysis-view .bar-row{grid-template-columns:1fr;gap:8px}
  .analysis-view .bar-row span{text-align:left}
  .analysis-view .presence-row{font-size:12px}
  .analysis-view .detail-metrics{grid-template-columns:1fr}
  .analysis-view .scene-distribution{min-height:220px}
  .analysis-view .scene-chart-inner{height:210px}
  .scene-calendar-head{flex-direction:column;align-items:flex-start}
  .scene-date-toggle{width:100%;justify-content:center}
  .scene-calendar-grid{grid-template-columns:1fr 1fr}
  .scene-field-era,.scene-field-year,.scene-field-month,.scene-field-day,.scene-field-daypart{grid-column:span 1}
}

/* 0.994 · planning / analysis responsive readability */
.analysis-view .stat-card span,
.analysis-view .metric-note,
.analysis-view .legend-row,
.analysis-view .timeline-analysis-metrics div span,
.analysis-view .continuity-analysis-score span,
.analysis-view .continuity-analysis-copy b,
.analysis-view .daily-goal-subhead span,
.analysis-view .daily-goal-summary span,
.analysis-view .narrative-stat-row span,
.analysis-view .narrative-stat-row em,
.analysis-view .plotline-analysis-row span,
.analysis-view .plotline-analysis-row em,
.analysis-view .mini-meta-bar span,
.analysis-view .book-goal-copy span,
.analysis-view .timeline-analysis-metrics div span,
.analysis-view .session-stat span{font-size:11px!important;line-height:1.45}
.analysis-view .card-head small{font-size:10.5px;letter-spacing:.12em}
.analysis-view .card-head h3{font-size:19px}
.analysis-view .presence-row,
.analysis-view .empty-state,
.analysis-view .book-goal-copy strong,
.analysis-view .narrative-stat-row b,
.analysis-view .plotline-analysis-row b,
.analysis-view .mini-meta-bar b{font-size:13px}
.analysis-focus-list{display:grid;gap:10px}
.analysis-focus-row{display:grid;grid-template-columns:minmax(0,1fr) auto;gap:12px;align-items:center;padding:12px 13px;border:1px solid var(--line);border-radius:15px;background:color-mix(in srgb,var(--surface-2) 82%,transparent)}
.analysis-focus-copy{display:grid;gap:4px;min-width:0}
.analysis-focus-copy b{font-size:12.5px;line-height:1.35}
.analysis-focus-copy span{font-size:11px;line-height:1.5;color:var(--muted)}
.analysis-focus-chip{display:inline-flex;align-items:center;justify-content:center;min-width:68px;padding:6px 10px;border-radius:999px;background:var(--accent-soft);color:var(--accent);font-size:11px;font-weight:750;text-align:center}
.scene-calendar-editor{padding:18px 18px 16px!important}
.scene-calendar-head{align-items:flex-start;gap:14px}
.scene-calendar-head>div{min-width:0}
.scene-calendar-head>div b{font-size:15px!important;line-height:1.25}
.scene-calendar-head>div small{font-size:11px!important;line-height:1.55;max-width:58ch}
.scene-date-toggle{min-height:46px;padding:9px 12px!important}
.scene-date-toggle span{font-size:12px!important}
.scene-calendar-grid{gap:12px!important}
.scene-calendar-grid label>span{font-size:11px!important;line-height:1.3}
.scene-calendar-grid :is(select,input){min-height:46px!important;font-size:13.5px!important}
.scene-calendar-sync-note{font-size:10.5px!important;line-height:1.6!important}
@media(max-width:960px){
  .scene-calendar-grid{grid-template-columns:repeat(2,minmax(0,1fr))!important}
  .scene-field-era,.scene-field-month,.scene-field-daypart{grid-column:1/-1!important}
  .scene-field-year,.scene-field-day{grid-column:auto!important}
}
@media(max-width:760px){
  .analysis-view .stats-grid-rich{grid-template-columns:repeat(2,minmax(0,1fr))!important}
  .analysis-view .analysis-card{padding:18px}
  .analysis-view .stat-card{padding:17px}
  .analysis-view .card-head h3{font-size:17px}
  .analysis-focus-row{grid-template-columns:1fr}
  .analysis-focus-chip{justify-self:start}
  .scene-calendar-editor{padding:16px!important}
  .scene-calendar-head{flex-direction:column!important;align-items:stretch!important}
  .scene-date-toggle{width:100%;justify-content:center}
}
@media(max-width:560px){
  .analysis-view .stats-grid-rich{grid-template-columns:1fr!important}
  .analysis-view .stat-card b{font-size:23px}
  .analysis-view .detail-metric b,
  .analysis-view .timeline-analysis-metrics div b,
  .analysis-view .continuity-analysis-score b,
  .analysis-view .daily-goal-summary b{font-size:18px!important}
  .scene-calendar-grid{grid-template-columns:1fr!important}
  .scene-field-era,.scene-field-year,.scene-field-month,.scene-field-day,.scene-field-daypart{grid-column:1/-1!important}
}

/* 0.996 · scene date card truly responsive */
.scene-calendar-editor{
  display:grid!important;
  gap:14px!important;
  padding:18px!important;
  border-radius:18px!important;
}
.scene-calendar-head{
  display:flex!important;
  align-items:flex-start!important;
  justify-content:space-between!important;
  gap:14px!important;
}
.scene-calendar-head>div{min-width:0}
.scene-calendar-head>div b{display:block;font-size:16px!important;line-height:1.25}
.scene-calendar-head>div small{display:block;margin-top:3px;font-size:11px!important;line-height:1.55;max-width:56ch}
.scene-date-toggle{flex:0 0 auto;min-height:46px;padding:10px 13px!important;border-radius:13px!important}
.scene-date-toggle span{font-size:12px!important;font-weight:650}
.scene-calendar-grid{
  display:grid!important;
  grid-template-columns:repeat(2,minmax(0,1fr))!important;
  grid-auto-flow:row!important;
  gap:12px!important;
  align-items:end!important;
}
.scene-calendar-grid label{display:grid!important;gap:6px!important;min-width:0}
.scene-calendar-grid label>span{font-size:11px!important;line-height:1.25;letter-spacing:.04em!important}
.scene-calendar-grid :is(select,input){width:100%!important;min-width:0!important;min-height:46px!important;padding:10px 11px!important;font-size:13.5px!important}
.scene-field-era,.scene-field-month,.scene-field-daypart{grid-column:1/-1!important}
.scene-field-year,.scene-field-day{grid-column:auto!important}
.scene-calendar-sync-note{display:block;font-size:10.5px!important;line-height:1.65!important;max-width:64ch}
@media(max-width:780px){
  .scene-calendar-head{flex-direction:column!important;align-items:stretch!important}
  .scene-date-toggle{width:100%;justify-content:center}
}
@media(max-width:520px){
  .scene-calendar-editor{padding:16px!important;gap:12px!important}
  .scene-calendar-grid{grid-template-columns:1fr!important}
  .scene-field-era,.scene-field-year,.scene-field-month,.scene-field-day,.scene-field-daypart{grid-column:1/-1!important}
}

/* 0.999 — Beta gate: touch keyboard and recovery action. */
.entry-beta-retry{font:inherit;color:var(--text);background:transparent;border:1px solid var(--line);border-radius:8px;padding:10px 14px;min-height:44px;cursor:pointer}
.entry-beta-retry[hidden]{display:none!important}
.entry-beta-retry:focus-visible{outline:2px solid currentColor;outline-offset:3px}
.entry-beta-status{overflow-wrap:anywhere}
@media (pointer:coarse){
  #entryBetaCode{font-size:16px!important;min-height:44px!important;scroll-margin-block:24px}
  #entryBetaVisibility{min-height:44px!important;font-size:12px!important}
}
@media (max-height:600px){
  .entry-gate{overflow:auto!important;place-items:start center!important}
  .entry-shell{max-height:calc(100dvh - 16px)!important;min-height:0!important;overflow:auto!important;margin:8px auto!important}
}
