/* Phoenix — colours come from the phoenix icon: night navy, cream, flame orange, amber, crimson. */
:root {
  --bg: #161b24; --bg2: #1e2430; --panel: #252d3c; --panel2: #2e384b; --line: #38435a;
  --text: #ece6d3; --muted: #9aa3b4; --accent: #f07a1e; --accent2: #f7b32b; --crimson: #8f1d22; --cream: #ede6cf;
  --radius: 8px;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; background: var(--bg); color: var(--text); font: 14px/1.4 "Segoe UI", system-ui, -apple-system, sans-serif; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; background: var(--panel2); border: 1px solid var(--line); border-radius: 6px; padding: 5px 10px; }
button:hover:not(:disabled) { border-color: var(--accent2); }
button:disabled { opacity: .4; cursor: default; }
button.primary { background: var(--accent); border-color: var(--accent); color: #1b1208; font-weight: 600; }
button.primary:hover { background: var(--accent2); border-color: var(--accent2); }
input, select { background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 5px 8px; min-width: 0; }
input:focus, select:focus, button:focus-visible { outline: 2px solid var(--accent2); outline-offset: 1px; }
select option { background: var(--bg2); }
.grow { flex: 1; }
.sm { padding: 2px 8px; font-size: 12px; }

#app { display: flex; flex-direction: column; height: 100vh; }

/* ---------- top bar ---------- */
#top { display: flex; align-items: center; gap: 10px; height: 50px; padding: 0 12px; background: var(--bg2); border-bottom: 1px solid var(--line); position: relative; }
#top .logo { width: 30px; height: 30px; }
#top .brand { font-size: 17px; letter-spacing: .3px; color: var(--cream); }
.ico { background: transparent; border-color: transparent; font-size: 17px; line-height: 1; padding: 6px 9px; }
#tabs { display: flex; gap: 4px; margin-left: 14px; }
.tab { background: transparent; border: none; border-bottom: 2px solid transparent; border-radius: 0; padding: 12px 12px 10px; color: var(--muted); }
.tab.on { color: var(--cream); border-bottom-color: var(--accent); }
.chip { border-radius: 99px; font-size: 12px; padding: 4px 12px; background: var(--panel); }
.chip.ok { color: #b9d9a0; } .chip.warn { color: var(--accent2); border-color: var(--accent2); } .chip.bad { color: #ff9a9a; border-color: var(--crimson); }
#menu { position: absolute; right: 10px; top: 46px; z-index: 30; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 6px; min-width: 240px; box-shadow: 0 10px 30px rgba(0, 0, 0, .5); }
#menu[hidden] { display: none; }
#menu button { display: block; width: 100%; text-align: left; background: transparent; border: none; padding: 8px 10px; border-radius: 6px; }
#menu button:hover { background: var(--panel2); }
#menu hr { border: none; border-top: 1px solid var(--line); margin: 5px 0; }
#menu .danger { color: #ff9a9a; }

/* ---------- layout ---------- */
#main { flex: 1; display: flex; min-height: 0; }
#side { width: 270px; flex: none; background: var(--bg2); border-right: 1px solid var(--line); display: flex; flex-direction: column; }
#side.off { display: none; }
.side-head { padding: 12px; display: flex; flex-direction: column; gap: 8px; }
#docList { flex: 1; overflow: auto; padding: 0 8px 12px; }
.doc { padding: 9px 10px; border-radius: var(--radius); cursor: pointer; border: 1px solid transparent; margin-bottom: 2px; }
.doc { position: relative; }
.doc .dx { position: absolute; right: 6px; top: 6px; display: none; padding: 0 8px; line-height: 20px; background: var(--bg2); color: var(--muted); border-radius: 99px; }
.doc:hover .dx { display: block; } .doc .dx:hover { color: #ff9a9a; border-color: var(--crimson); }
#btnDelDoc { font-size: 12px; padding: 5px 10px; color: #ff9a9a; background: transparent; }
.doc:hover { background: var(--panel); }
.doc.on { background: var(--panel2); border-color: var(--line); box-shadow: inset 3px 0 0 var(--accent); }
.doc .t { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.doc .t.empty { color: var(--muted); font-weight: 400; font-style: italic; }
.doc .m { font-size: 12px; color: var(--muted); margin-top: 1px; }
.doc .m b { color: var(--accent2); font-weight: 600; }
.none { color: var(--muted); padding: 14px 10px; font-size: 13px; }

#work { flex: 1; min-width: 0; display: flex; flex-direction: column; }
#titleRow { display: flex; gap: 8px; align-items: center; padding: 10px 14px 6px; }
#docTitle { flex: 1; font-size: 20px; font-weight: 600; background: transparent; border-color: transparent; padding: 4px 8px; color: var(--cream); font-family: Georgia, serif; }
#docTitle:hover { border-color: var(--line); } #docTitle:focus { background: var(--bg); }

.tog { border-radius: 99px; font-size: 12px; padding: 4px 12px; white-space: nowrap; background: var(--panel); color: var(--muted); }
.tog.on { background: var(--accent2); border-color: var(--accent2); color: #2a1c05; font-weight: 600; }

/* ---------- toolbar ---------- */
#toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; padding: 6px 12px; background: var(--panel); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
#toolbar .sep { width: 1px; height: 22px; background: var(--line); margin: 0 5px; }
#toolbar button { background: transparent; border-color: transparent; min-width: 30px; height: 30px; padding: 0 7px; display: inline-flex; align-items: center; justify-content: center; }
#toolbar button:hover:not(:disabled) { background: var(--panel2); border-color: var(--line); }
#toolbar button.on { background: var(--accent); border-color: var(--accent); color: #1b1208; }
#toolbar svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
#toolbar select { height: 30px; padding: 0 6px; }
#tbStyle { width: 128px; } #tbFont { width: 150px; }
#tbSize { width: 54px; text-align: center; height: 30px; padding: 0 2px; }
#tbSize::-webkit-inner-spin-button { display: none; }

/* ---------- the pages ---------- */
#stage { flex: 1; overflow: auto; padding: 28px 24px 60px; background: radial-gradient(ellipse at top, #1e2634 0, #121720 70%); }
#zoomWrap { position: relative; margin: 0 auto; }
#paper { position: absolute; left: 0; top: 0; transform-origin: 0 0; --sheet: #fbf6e6; --ink: #2a241f; }
#sheets { position: absolute; inset: 0; pointer-events: none; }
.sheet { position: absolute; left: 0; width: 100%; background: var(--sheet); box-shadow: 0 3px 18px rgba(0, 0, 0, .55), 0 0 0 1px rgba(0, 0, 0, .25); border-radius: 2px; }
.pnum { position: absolute; font: 11px Georgia, serif; color: color-mix(in srgb, var(--ink) 55%, var(--sheet)); text-align: center; }
.pnum.left { text-align: left; } .pnum.right { text-align: right; }

.doc-body { position: relative; z-index: 1; outline: none; color: var(--ink); font-family: var(--font), Georgia, serif; font-size: var(--fs); line-height: var(--lh);
  overflow-wrap: break-word; caret-color: var(--accent); }
.doc-body ::selection, .doc-body::selection { background: rgba(240, 122, 30, .38); }
.doc-body p { margin: 0; padding-bottom: var(--ps); }
.doc-body.indent p { text-indent: 1.27cm; }
.doc-body h1, .doc-body h2, .doc-body h3 { margin: 0; line-height: 1.25; font-weight: 700; text-indent: 0; }
.doc-body h1 { font-size: 2em; padding: .5em 0 .35em; }
.doc-body h2 { font-size: 1.5em; padding: .5em 0 .3em; }
.doc-body h3 { font-size: 1.2em; padding: .4em 0 .25em; }
.doc-body blockquote { margin: 0; padding: 0 0 var(--ps) 1.1em; border-left: 3px solid var(--accent2); font-style: italic; text-indent: 0; }
.doc-body ul, .doc-body ol { margin: 0; padding: 0 0 var(--ps) 1.7em; }
.doc-body li { padding: 0; text-indent: 0; }
.pgap { display: block; width: 100%; padding: 0; margin: 0; text-indent: 0; pointer-events: none; user-select: none; }
.pgap.in { display: inline-block; vertical-align: top; font-size: 0; line-height: 0; }

/* pictures: plate = a page of its own, wide = width of the text, small = centred. --C is the height of the text area. */
.doc-body figure.fig { margin: 0; padding: 0 0 var(--ps, .6em); text-align: center; text-indent: 0; position: relative; }
.doc-body figure.fig img { display: block; margin: 0 auto; max-width: 100%; }
.doc-body figure.fig img:not([src]) { background: repeating-linear-gradient(45deg, rgba(128, 128, 128, .14) 0 8px, transparent 8px 16px); outline: 1px dashed rgba(128, 128, 128, .45); }
.doc-body figure.wide img { width: 100%; height: auto; max-height: calc(var(--C, 640px) - 3em); object-fit: contain; }
.doc-body figure.small img { width: 46%; height: auto; max-height: calc(var(--C, 640px) * .6); object-fit: contain; }
.doc-body figure.plate { height: var(--C, 640px); padding: 0; box-sizing: border-box; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.doc-body figure.plate img { flex: 1 1 0; min-height: 0; width: 100%; height: 100%; max-width: none; object-fit: contain; }
.doc-body figcaption { flex: none; font-size: .85em; font-style: italic; opacity: .78; padding-top: .45em; text-indent: 0; line-height: 1.3; }
#editor figure.fig { cursor: pointer; }
#editor figure.fig img { user-select: none; -webkit-user-drag: none; }
#imgSel { position: fixed; z-index: 40; border: 2px solid var(--accent); border-radius: 2px; pointer-events: none; box-shadow: 0 0 0 1px rgba(0, 0, 0, .35); }
#imgBar { position: fixed; z-index: 45; display: flex; align-items: center; gap: 6px; padding: 6px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 10px 30px rgba(0, 0, 0, .55); }
#imgBar .ib-row { display: flex; gap: 2px; }
#imgBar button { padding: 4px 10px; font-size: 12px; background: transparent; }
#imgBar button.on { background: var(--accent); border-color: var(--accent); color: #1b1208; font-weight: 600; }
#imgBar button.danger { color: #ff9a9a; }
#imgBar input { width: 170px; font-size: 12px; padding: 4px 8px; }

/* ---------- comments on the page ---------- */
::highlight(pxc-note) { background-color: rgba(240, 122, 30, .22); }
::highlight(pxc-good) { background-color: rgba(247, 179, 43, .42); }
::highlight(pxc-fix)  { background-color: rgba(143, 29, 34, .22); }
::highlight(pxc-lang) { background-color: rgba(63, 111, 181, .16); text-decoration: underline; text-decoration-color: #3f6fb5; }
[hidden] { display: none !important; }
#side.nov { display: none; }
#ctx { position: fixed; z-index: 60; min-width: 170px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 5px; box-shadow: 0 10px 30px rgba(0, 0, 0, .55); }
#ctx button { display: block; width: 100%; text-align: left; background: transparent; border: none; padding: 7px 10px; border-radius: 6px; }
#ctx button:hover { background: var(--panel2); }
#ctx hr { border: none; border-top: 1px solid var(--line); margin: 4px 0; }
#cQuote { margin: 0 0 12px; padding: 8px 12px; border-left: 3px solid var(--accent2); background: var(--bg); border-radius: 0 6px 6px 0; font: italic 15px/1.5 Georgia, serif; color: var(--cream); max-height: 130px; overflow: auto; }
#cForm label.row1 { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
#cText { width: 100%; resize: vertical; background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; font: 14px/1.5 "Segoe UI", system-ui, sans-serif; color: var(--text); }

/* ---------- Study tab ---------- */
#study { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.study-head { display: flex; align-items: center; gap: 12px; padding: 10px 16px; border-bottom: 1px solid var(--line); background: var(--panel); }
.snav { display: flex; gap: 4px; }
.stab { background: transparent; border: 1px solid transparent; border-radius: 99px; padding: 5px 14px; color: var(--muted); }
.stab.on { background: var(--panel2); border-color: var(--line); color: var(--cream); }
.study-body { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(230px, 300px) 1fr; }
#cmTree { overflow: auto; padding: 10px 8px 30px; border-right: 1px solid var(--line); background: var(--bg2); }
.tdoc { display: flex; align-items: center; gap: 6px; padding: 7px 8px; border-radius: var(--radius); cursor: pointer; border: 1px solid transparent; margin-top: 4px; }
.tdoc:hover, .tkind:hover { background: var(--panel); }
.tdoc.on, .tkind.on { background: var(--panel2); border-color: var(--line); box-shadow: inset 3px 0 0 var(--accent); }
.tdoc .chev { width: 16px; text-align: center; color: var(--muted); font-size: 12px; cursor: pointer; }
.tdoc .chev:hover { color: var(--accent2); }
.tdoc .tt { flex: 1; min-width: 0; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.n { font-size: 12px; color: var(--muted); }
.tkinds { margin: 2px 0 6px 24px; }
.tkind { display: flex; align-items: center; justify-content: space-between; padding: 5px 8px; border-radius: var(--radius); cursor: pointer; border: 1px solid transparent; }
.tkind.zero { opacity: .45; }
#cmPane { min-width: 0; display: flex; flex-direction: column; background: radial-gradient(ellipse at top, #1e2634 0, #121720 70%); }
#cmHead { display: flex; align-items: baseline; gap: 12px; padding: 16px 24px 8px; }
#cmHead .ttl { font: 600 20px Georgia, serif; color: var(--cream); }
#cmHead .sub { color: var(--muted); font-size: 13px; }
#cmHead .hd { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
#cmCards { flex: 1; overflow: auto; padding: 4px 24px 40px; display: grid; grid-template-columns: repeat(auto-fill, minmax(380px, 1fr)); gap: 16px; align-items: start; align-content: start; }
#cmCards .pg { grid-column: 1 / -1; margin: 10px 2px 0; font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--accent2); }
#cmCards .none { grid-column: 1 / -1; }
.k { display: inline-block; font-size: 11px; font-weight: 600; letter-spacing: .03em; padding: 1px 8px; border-radius: 99px; background: var(--panel2); color: var(--cream); }
.k.good { background: var(--accent2); color: #2a1c05; } .k.fix { background: var(--crimson); color: #ffe9e0; } .k.lang { background: #3f6fb5; color: #eef4ff; } .k.note { background: var(--accent); color: #2a1305; }
.none { color: var(--muted); padding: 18px 10px; font-size: 13px; line-height: 1.5; } .none.center { text-align: center; padding-top: 80px; }
.card { background: #fbf6e6; color: #2a241f; border-radius: 6px; padding: 18px 22px 16px; box-shadow: 0 6px 30px rgba(0, 0, 0, .5); border-top: 5px solid var(--accent); }
.card.done { opacity: .6; }
.cmeta { font-size: 12px; color: #7a705f; margin-bottom: 12px; }
.cmeta .k { margin-right: 4px; }
.quote { margin: 0 0 14px; padding: 2px 0 2px 14px; border-left: 4px solid var(--accent2); font: italic 16px/1.55 Georgia, serif; color: #2a241f; }
.ctext { font: 14px/1.6 "Segoe UI", system-ui, sans-serif; white-space: pre-wrap; margin-bottom: 16px; }
.warn { background: #f6e3c7; border: 1px solid #e3b878; color: #6a4513; padding: 7px 11px; border-radius: 6px; font-size: 12px; margin-bottom: 12px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; border-top: 1px solid #e3dac1; padding-top: 12px; }
.actions button:not(.primary) { background: #efe6cc; border-color: #d9ceae; color: #2a241f; }
.actions button.danger { color: #8f1d22; }
@media (max-width: 820px) { .study-body { grid-template-columns: 1fr; grid-template-rows: 32% 68%; } #cmTree { border-right: none; border-bottom: 1px solid var(--line); } #cmCards { grid-template-columns: 1fr; } }

/* ---------- Vocabulary ---------- */
#voTree { overflow: auto; padding: 10px 8px 30px; border-right: 1px solid var(--line); background: var(--bg2); }
#voPane { min-width: 0; display: flex; flex-direction: column; background: radial-gradient(ellipse at top, #1e2634 0, #121720 70%); }
#voHead { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 14px 24px 8px; }
#voHead .ttl { font: 600 20px Georgia, serif; color: var(--cream); }
#voHead .sub { color: var(--muted); font-size: 13px; }
#voHead input { width: 190px; }
#voCards { flex: 1; overflow: auto; padding: 4px 24px 40px; display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 16px; align-items: start; align-content: start; }
#voCards .pg { grid-column: 1 / -1; margin: 10px 2px 0; font: 600 18px Georgia, serif; color: var(--accent2); letter-spacing: 0; text-transform: none; }
#voCards .none { grid-column: 1 / -1; }
.k.lg { background: var(--panel2); color: var(--cream); border: 1px solid var(--line); }
.vcard { background: #fbf6e6; color: #2a241f; border-radius: 6px; padding: 16px 20px 14px; box-shadow: 0 6px 30px rgba(0, 0, 0, .5); border-top: 5px solid var(--accent2); }
.vcard .k.lg { background: #efe6cc; color: #5b5240; border-color: #d9ceae; }
.vtop { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.vword { font: 700 24px Georgia, serif; }
.vpos { font-size: 12px; color: #7a705f; font-style: italic; }
.vdef { font: 14px/1.55 "Segoe UI", system-ui, sans-serif; white-space: pre-wrap; margin-bottom: 8px; }
.vtr { font: 13px "Segoe UI", system-ui, sans-serif; color: #5b5240; margin-bottom: 10px; }
.vnote { font: 13px/1.5 "Segoe UI", system-ui, sans-serif; color: #7a705f; margin: 8px 0; }
.quote.sm { font-size: 14px; margin: 0 0 10px; }
#dlgLook { max-width: 720px; }
.lrow { display: flex; gap: 8px; margin-bottom: 8px; } .lrow input { flex: 1; font-size: 16px; padding: 7px 10px; } .lrow select { width: 120px; }
#lSug { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 8px; min-height: 0; }
#lSug .sl { color: var(--muted); font-size: 12px; }
.sg { padding: 2px 10px; border-radius: 99px; font-size: 13px; background: var(--panel2); }
#lRes { max-height: 230px; overflow: auto; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 6px 12px; margin-bottom: 12px; }
#lRes .none { padding: 10px 0; }
.warn2 { color: var(--accent2); font-size: 13px; padding: 8px 0; }
.ent { margin: 8px 0; } .epos { font-style: italic; color: var(--accent2); font-size: 13px; margin-bottom: 3px; }
.df { display: flex; gap: 8px; align-items: flex-start; padding: 3px 0; font-size: 14px; line-height: 1.45; }
.df .add { flex: none; width: 22px; height: 22px; padding: 0; line-height: 1; border-radius: 99px; background: var(--panel2); }
.df .add:hover { background: var(--accent); color: #1b1208; border-color: var(--accent); }
.trs { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 4px; border-top: 1px solid var(--line); padding-top: 8px; }
.trchip { background: var(--panel2); border-radius: 99px; padding: 2px 12px; font-size: 13px; }
.lf { display: flex; flex-direction: column; gap: 4px; margin-bottom: 9px; font-size: 12px; color: var(--muted); }
.lf textarea, .lf input { width: 100%; font-size: 14px; color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 7px 10px; font-family: "Segoe UI", system-ui, sans-serif; resize: vertical; }
@media (max-width: 820px) { #voCards { grid-template-columns: 1fr; } #voHead input { width: 100%; } }

/* ---------- World ---------- */
#world { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.whint { color: var(--muted); font-size: 13px; }
#wTree { overflow: auto; padding: 10px 8px 30px; border-right: 1px solid var(--line); background: var(--bg2); }
#wPane { min-width: 0; display: flex; flex-direction: column; background: radial-gradient(ellipse at top, #1e2634 0, #121720 70%); }
#wHead { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 14px 24px 8px; }
#wHead .ttl { font: 600 20px Georgia, serif; color: var(--cream); } #wHead .sub { color: var(--muted); font-size: 13px; margin-right: 6px; }
#wHead input { width: 170px; } .wnew { font-size: 13px; padding: 4px 10px; border-radius: 99px; }
#wCards { flex: 1; overflow: auto; padding: 4px 24px 40px; display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; align-items: start; align-content: start; }
#wCards .none { grid-column: 1 / -1; }
.k.wt { background: var(--panel2); } .k.wt.character { background: var(--accent); color: #2a1305; } .k.wt.location { background: #3f6fb5; color: #eef4ff; } .k.wt.race { background: var(--accent2); color: #2a1c05; } .k.wt.item { background: var(--crimson); color: #ffe9e0; } .k.wt.magic { background: #7b4fb0; color: #f3eaff; } .k.wt.spell { background: #2f9a8a; color: #e6fffb; }
.wcard { background: #fbf6e6; color: #2a241f; border-radius: 6px; padding: 14px 18px 14px; box-shadow: 0 6px 24px rgba(0, 0, 0, .45); border-top: 5px solid var(--accent); cursor: pointer; }
.wcard:hover { transform: translateY(-2px); box-shadow: 0 10px 28px rgba(0, 0, 0, .55); }
.wcard.location { border-top-color: #3f6fb5; } .wcard.race { border-top-color: var(--accent2); } .wcard.item { border-top-color: var(--crimson); } .wcard.magic { border-top-color: #7b4fb0; } .wcard.spell { border-top-color: #2f9a8a; }
.wname { font: 700 21px Georgia, serif; margin: 8px 0 2px; } .wsum { font: 13px "Segoe UI", system-ui, sans-serif; color: #5b5240; } .wsnip { font: 13px/1.5 "Segoe UI", system-ui, sans-serif; color: #7a705f; margin-top: 8px; }
#dlgCard { max-width: 780px; max-height: 90vh; padding: 0; overflow: hidden; }
#wcBody { padding: 18px 22px 20px; max-height: 90vh; overflow: auto; }
.wc-top { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
#wcDoc { max-width: 260px; font-size: 13px; }
.wc-name { width: 100%; font: 700 26px Georgia, serif; color: var(--cream); background: transparent; border: 1px solid transparent; border-bottom-color: var(--line); border-radius: 0; padding: 4px 2px; margin-bottom: 14px; }
.wc-name:focus { border-color: var(--accent2); background: var(--bg); border-radius: 6px; padding-left: 8px; }
.wc-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 16px; margin-bottom: 12px; }
.wf { display: flex; flex-direction: column; gap: 4px; min-width: 0; } .wf > span { font-size: 12px; color: var(--muted); }
.wf.long, .wf.wide { grid-column: 1 / -1; } .wf.long { margin-bottom: 10px; }
.wf input, .wf textarea { width: 100%; font: 14px "Segoe UI", system-ui, sans-serif; color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 7px 10px; resize: vertical; }
.lks { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.lks .lkin { flex: 1; min-width: 150px; }
.lkc { display: inline-flex; align-items: center; background: var(--panel2); border: 1px solid var(--line); border-radius: 99px; overflow: hidden; }
.lkc small { color: var(--muted); padding: 0 10px 0 2px; font-size: 11px; }
.lkb { background: transparent; border: none; padding: 3px 4px 3px 12px; color: var(--accent2); font-weight: 600; } .lkb:hover { color: var(--cream); }
.lkx { background: transparent; border: none; padding: 3px 9px 3px 4px; color: var(--muted); } .lkx:hover { color: #ff9a9a; }
.wx { display: flex; gap: 6px; margin-bottom: 6px; } .wx .xl { width: 34%; } .wx button { padding: 2px 10px; }
.addx { align-self: flex-start; font-size: 13px; }
.wc-foot { display: flex; justify-content: flex-end; border-top: 1px solid var(--line); padding-top: 12px; margin-top: 4px; }
.wc-foot .danger { color: #ff9a9a; }
.pkp { color: var(--muted); margin: 0 0 14px; } #pkTypes { display: flex; flex-wrap: wrap; gap: 8px; }
@media (max-width: 820px) { .wc-grid { grid-template-columns: 1fr; } #wHead input { width: 100%; } }

/* ---------- Grammar ---------- */
#grTree { overflow: auto; padding: 10px 8px 30px; border-right: 1px solid var(--line); background: var(--bg2); }
#grPane { min-width: 0; display: flex; flex-direction: column; background: radial-gradient(ellipse at top, #1e2634 0, #121720 70%); }
#grHead { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 14px 24px 8px; }
#grHead .ttl { font: 600 20px Georgia, serif; color: var(--cream); } #grHead .sub { color: var(--muted); font-size: 13px; } #grHead input { width: 180px; }
#grCards { flex: 1; overflow: auto; padding: 4px 24px 40px; display: grid; grid-template-columns: repeat(auto-fill, minmax(380px, 1fr)); gap: 16px; align-items: start; align-content: start; }
#grCards .none { grid-column: 1 / -1; }
.gcat { display: inline-block; font-size: 11px; font-weight: 600; letter-spacing: .03em; padding: 1px 9px; border-radius: 99px; background: var(--panel2); color: var(--cream); border: 1px solid var(--line); }
.gcat.big { font-size: 12px; vertical-align: middle; }
.gcard { background: #fbf6e6; color: #2a241f; border-radius: 6px; padding: 16px 20px 14px; box-shadow: 0 6px 30px rgba(0, 0, 0, .5); border-top: 5px solid #3f6fb5; }
.gcard .gcat { background: #e3ebf6; color: #274a7c; border-color: #bccde6; }
.gtitle { font: 700 19px/1.3 Georgia, serif; margin: 8px 0 6px; }
.grule { font: 14px/1.6 "Segoe UI", system-ui, sans-serif; white-space: pre-wrap; color: #3d362c; margin-bottom: 10px; }
.gex { border-left: 4px solid #3f6fb5; padding: 2px 0 2px 12px; margin: 8px 0; font: 15px/1.5 Georgia, serif; }
.gw { color: #8f1d22; text-decoration: line-through; text-decoration-color: rgba(143, 29, 34, .55); } .gr { color: #2c6b34; } .gt { color: #7a705f; font: italic 13px "Segoe UI", sans-serif; }
.gw b, .gr b { text-decoration: none; display: inline-block; margin-right: 4px; }
.rsrc { margin: 0 0 10px; padding: 8px 12px; border-left: 3px solid var(--accent2); background: var(--bg); border-radius: 0 6px 6px 0; font: italic 14px/1.5 Georgia, serif; color: var(--cream); }
.rrow { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.rrow select, #dlgRule .lf select { width: 100%; padding: 7px 10px; }
.rex { display: flex; gap: 6px; margin-bottom: 6px; } .rex input { flex: 1; } .rex .rdel { padding: 2px 10px; }
#dlgRule { max-width: 680px; }

/* ---------- status bar ---------- */
#status { display: flex; align-items: center; gap: 16px; padding: 5px 14px; background: var(--bg2); border-top: 1px solid var(--line); font-size: 12px; color: var(--muted); }
#status .sm { height: 22px; }
#zoom { width: 130px; padding: 0; accent-color: var(--accent); }
#zVal { min-width: 58px; }

/* ---------- dialog & toast ---------- */
dialog { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 12px; padding: 20px 22px; max-width: 760px; width: calc(100% - 32px); box-shadow: 0 20px 60px rgba(0, 0, 0, .6); }
dialog::backdrop { background: rgba(8, 10, 14, .65); }
dialog h2 { margin: 0 0 12px; font-size: 18px; color: var(--cream); }
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 9px; margin: 0; min-width: 0; }
legend { padding: 0 6px; color: var(--accent2); font-weight: 600; }
fieldset label { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
fieldset label select, fieldset label input[type=number] { width: 150px; }
fieldset label.chk { justify-content: flex-start; }
.row { display: flex; gap: 8px; } .row label { flex: 1; flex-direction: column; align-items: stretch; gap: 3px; font-size: 12px; color: var(--muted); }
.row label input { width: 100% !important; }
.row.m4 label { min-width: 0; }
small { color: var(--muted); font-size: 12px; }
dialog menu { display: flex; justify-content: flex-end; gap: 8px; padding: 0; margin: 16px 0 0; }
#toast { position: fixed; left: 50%; bottom: 40px; transform: translateX(-50%); background: var(--panel2); border: 1px solid var(--accent2); color: var(--text); padding: 9px 16px; border-radius: 99px; z-index: 50; box-shadow: 0 8px 24px rgba(0, 0, 0, .5); max-width: 90vw; }
#toast[hidden] { display: none; }

@media (max-width: 820px) {
  #side { position: absolute; z-index: 20; top: 50px; bottom: 0; box-shadow: 8px 0 30px rgba(0, 0, 0, .5); }
  .cols { grid-template-columns: 1fr; }
  #tabs { display: none; }
  #tbFont { width: 110px; }
}

/* ---------- document types (sidebar, New dialog, row under the title, book overview) ---------- */
.doc .t { display: flex; align-items: center; gap: 7px; }
.doc .ti, .ri .ti { flex: none; width: 17px; height: 17px; color: var(--tc, var(--muted)); display: inline-flex; }
.doc .ti svg, .ri .ti svg, .ni svg, .tbadge svg { width: 100%; height: 100%; }
.doc.ch { margin-left: 22px; padding: 6px 10px; border-left: 2px solid var(--line); border-radius: 0 var(--radius) var(--radius) 0; }
.doc.ch .cn { color: var(--muted); font-weight: 400; font-size: 12px; margin-right: -3px; }
.doc.ch .ti { width: 14px; height: 14px; opacity: .8; }
.doc.ch .m { display: none; }
#newTiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.ntile { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; text-align: left; padding: 14px; border-radius: 10px; background: var(--bg2); border: 1px solid var(--line); transition: transform .12s, border-color .12s, background .12s; }
.ntile:hover { transform: translateY(-2px); border-color: var(--tc); background: var(--panel2); }
.ntile .ni { width: 30px; height: 30px; color: var(--tc); margin-bottom: 4px; }
.ntile b { color: var(--cream); font-size: 15px; }
.ntile small { line-height: 1.35; }
.tbadge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 11px 3px 8px; border-radius: 99px; background: var(--panel); border: 1px solid var(--tc); color: var(--tc); font-size: 12px; font-weight: 600; white-space: nowrap; }
.tbadge .ni { width: 15px; height: 15px; display: inline-flex; }
#metaRow { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; padding: 2px 14px 8px; }
.mf { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12px; }
.mf input, .mf select { padding: 3px 8px; min-width: 150px; color: var(--text); }
.mf input[type=date] { min-width: 0; color-scheme: dark; }
.mtxt { color: var(--muted); font-size: 12px; }
.mlink { background: transparent; border: none; color: var(--accent2); padding: 2px 4px; font-size: 12px; }
.mlink:hover:not(:disabled) { text-decoration: underline; border: none; }
.sws { display: inline-flex; gap: 5px; }
.sw { width: 18px; height: 18px; padding: 0; border-radius: 50%; border: 2px solid transparent; }
.sw.on { border-color: var(--cream); box-shadow: 0 0 0 2px var(--bg); }
#bookHome { flex: 1; overflow: auto; padding: 18px 26px 50px; background: radial-gradient(ellipse at top, #1e2634 0, #121720 70%); }
.bh-wrap { display: flex; gap: 34px; max-width: 1000px; margin: 0 auto; align-items: flex-start; }
.bh-cover { flex: none; width: 210px; height: 296px; border-radius: 4px 10px 10px 4px; padding: 30px 22px; text-align: center; color: #e2c47a; background: linear-gradient(90deg, rgba(0,0,0,.35), transparent 7%, transparent 93%, rgba(0,0,0,.15)), var(--cover, #6e1f26);
  box-shadow: 0 14px 34px rgba(0,0,0,.6), inset 0 0 0 5px rgba(0,0,0,.12); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; }
.bh-ct { font: 700 22px/1.2 Georgia, serif; overflow-wrap: anywhere; } .bh-ca { font: 14px Georgia, serif; letter-spacing: .12em; opacity: .85; }
.bh-orn { width: 56px; height: 2px; background: currentColor; opacity: .7; } .bh-orn.small { width: 26px; }
.bh-main { flex: 1; min-width: 0; }
.bh-top { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.bh-top h2 { margin: 0; font: 600 22px Georgia, serif; color: var(--cream); } .bh-sub { color: var(--muted); font-size: 13px; }
.bh-list { list-style: none; margin: 0; padding: 0; background: var(--bg2); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.bh-list li { display: flex; align-items: center; gap: 12px; padding: 11px 14px; border-bottom: 1px solid var(--line); cursor: pointer; }
.bh-list li:last-child { border-bottom: none; } .bh-list li:hover { background: var(--panel); }
.bh-list .num { width: 26px; color: var(--accent2); font: 600 18px Georgia, serif; text-align: right; }
.bh-list .nm { flex: 1; font: 600 16px Georgia, serif; color: var(--cream); } .bh-list .nm.empty { color: var(--muted); font-weight: 400; font-style: italic; }
.bh-list .wc { color: var(--muted); font-size: 12px; } .bh-list .acts { display: flex; gap: 2px; }
.bh-list .acts button { padding: 1px 8px; background: transparent; border-color: transparent; color: var(--muted); } .bh-list .acts button:hover:not(:disabled) { color: var(--accent2); border-color: var(--line); }
.bh-list li.none { cursor: default; justify-content: center; }
.bh-hint { color: var(--muted); font-size: 13px; margin-top: 14px; }

#wPane.noworld #wHead { display: none; }
#wTree .none { padding: 14px 12px; line-height: 1.5; }

/* ---------- Read tab ---------- */
#reading { flex: 1; min-width: 0; display: flex; }
#rdSide { width: 270px; flex: none; background: var(--bg2); border-right: 1px solid var(--line); display: flex; flex-direction: column; padding: 12px 8px 0; gap: 8px; }
#rdFilter { display: flex; gap: 4px; padding: 0 4px; }
#rdFilter button { flex: 1; padding: 5px 0; background: transparent; border-color: transparent; color: var(--tc, var(--muted)); font-size: 12px; display: inline-flex; align-items: center; justify-content: center; }
#rdFilter button svg { width: 17px; height: 17px; }
#rdFilter button.on { background: var(--panel2); border-color: var(--line); color: var(--tc, var(--cream)); }
#rdQ { margin: 0 4px; }
#rdItems { flex: 1; overflow: auto; padding-bottom: 12px; }
.ri { display: flex; gap: 10px; align-items: center; padding: 9px 10px; border-radius: var(--radius); cursor: pointer; border: 1px solid transparent; margin-bottom: 2px; }
.ri:hover { background: var(--panel); } .ri.on { background: var(--panel2); border-color: var(--line); box-shadow: inset 3px 0 0 var(--tc, var(--accent)); }
.ri .ti { width: 22px; height: 22px; }
.ri .rt { min-width: 0; } .ri .rn { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } .ri .rm { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#rdStage { flex: 1; min-width: 0; position: relative; display: flex; flex-direction: column; background: radial-gradient(ellipse at 50% 30%, #2a2f3d 0, #141821 75%); overflow: hidden; }
#rdStage.t-document { background: radial-gradient(ellipse at 50% 30%, #3a2f27 0, #1a1410 80%); }
#rdStage.t-book, #rdStage.t-journal { background: radial-gradient(ellipse at 50% 35%, #33291f 0, #14100c 80%); }
#rdView { flex: 1; position: relative; min-height: 0; }
.rd-empty { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: var(--muted); }
.rd-fit { position: absolute; left: 50%; top: 50%; transform-origin: center; }
#rdHud { position: absolute; left: 0; right: 0; bottom: 14px; display: flex; justify-content: center; align-items: center; gap: 10px; pointer-events: none; }
#rdHud > * { pointer-events: auto; }
#rdHud button { background: rgba(20, 24, 33, .8); border-radius: 99px; padding: 4px 14px; font-size: 18px; line-height: 1.2; }
#rdHud button.ed { font-size: 12px; padding: 5px 14px; }
#rdHud .hl { background: rgba(20, 24, 33, .8); border: 1px solid var(--line); border-radius: 99px; padding: 5px 16px; font-size: 13px; color: var(--cream); max-width: 60%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#rdHud .hint { color: var(--muted); font-size: 12px; margin-left: 10px; }
#rdMeasure { position: absolute; left: -30000px; top: 0; visibility: hidden; pointer-events: none; }

.rpage { position: relative; overflow: hidden; background: var(--sheet); color: var(--ink); flex: none; }
.rpage > .doc-body { position: absolute; left: 0; top: 0; user-select: none; }
.rpage .pnum { position: absolute; }
.doc-body .chn { text-align: center; text-transform: uppercase; letter-spacing: .22em; font-size: .85em; font-weight: 600; padding-top: 3.5em; opacity: .6; }
.doc-body .cht { text-align: center; font-size: 1.7em; padding: .15em 0 1.3em; }
.doc-body .jd { font-size: 1.3em; padding: .2em 0 .1em; border-bottom: 1px solid color-mix(in srgb, var(--ink) 25%, transparent); margin-bottom: .6em; }
.doc-body .jt { font-style: italic; font-weight: 400; padding: 0 0 .5em; }
#editor [data-hd] { user-select: none; cursor: default; }
.rpage .rp-in { font: var(--ffs) var(--ffont); color: var(--ink); position: absolute; inset: 0; box-sizing: border-box; display: flex; flex-direction: column; }
.front-title .rp-in { align-items: center; justify-content: center; text-align: center; gap: 1.2em; }
.ft-t { font-size: 2.3em; font-weight: 700; line-height: 1.15; } .ft-o { font-size: 1.6em; opacity: .55; } .ft-a { font-size: 1.15em; letter-spacing: .14em; text-transform: uppercase; opacity: .8; }
.front-copy .rp-in, .front-empty .rp-in { justify-content: flex-end; align-items: center; text-align: center; } .fc { font-size: .8em; opacity: .65; line-height: 1.6; }
.front-empty .rp-in { justify-content: center; }
.toc-h { font-size: 1.6em; font-weight: 700; margin-bottom: 1.4em; text-align: center; }
.front-toc ol { list-style: none; margin: 0; padding: 0; }
.front-toc li { display: flex; align-items: baseline; gap: .5em; height: calc(var(--ffs) * 1.7 * 1.5); cursor: pointer; }
.front-toc li:hover .tt { text-decoration: underline; } .front-toc .tn { width: 1.6em; text-align: right; opacity: .55; } .front-toc .tt { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 70%; }
.front-toc .tl { flex: 1; border-bottom: 1px dotted color-mix(in srgb, var(--ink) 45%, transparent); transform: translateY(-.25em); min-width: 1em; } .front-toc .tp { min-width: 1.6em; text-align: right; }
.toc-none { opacity: .6; font-style: italic; cursor: default !important; }

.rboard { position: relative; overflow: hidden; flex: none; }
.rboard.cover { background: radial-gradient(ellipse at 30% 20%, rgba(255,255,255,.1), transparent 60%), linear-gradient(90deg, rgba(0,0,0,.45), rgba(0,0,0,.05) 6%, transparent 94%, rgba(0,0,0,.2)), var(--cover);
  border-radius: 3px 9px 9px 3px; color: #e2c47a; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1.1em; text-align: center; padding: 14%; box-sizing: border-box; box-shadow: inset 0 0 0 6px rgba(0,0,0,.14), inset 0 0 0 7px rgba(226,196,122,.35), inset 0 0 0 13px rgba(0,0,0,.08); }
.rboard.backc { border-radius: 9px 3px 3px 9px; background: radial-gradient(ellipse at 70% 20%, rgba(255,255,255,.1), transparent 60%), linear-gradient(270deg, rgba(0,0,0,.45), rgba(0,0,0,.05) 6%, transparent 94%, rgba(0,0,0,.2)), var(--cover); }
.rboard .ct { font: 700 var(--fs)/1.15 Georgia, serif; text-shadow: 0 1px 0 rgba(0,0,0,.45); overflow-wrap: anywhere; } .rboard .ca { font: calc(var(--fs) * .38) Georgia, serif; letter-spacing: .2em; text-transform: uppercase; opacity: .85; }
.rboard .orn { width: 38%; height: 2px; background: currentColor; opacity: .7; } .rboard .orn.small { width: 16%; }
.rboard.endpaper { background: repeating-linear-gradient(45deg, rgba(255,255,255,.04) 0 6px, transparent 6px 12px), radial-gradient(circle at 50% 50%, rgba(255,255,255,.1), transparent 70%), color-mix(in srgb, var(--cover) 55%, #d8c9a3); box-shadow: inset 0 0 40px rgba(0,0,0,.25); }

.rd-book { position: relative; width: 100%; height: 100%; perspective: 3200px; }
.rb-inner { position: absolute; inset: 0; transition: transform .9s cubic-bezier(.4, .1, .2, 1); }
.rb-leaf { position: absolute; left: 50%; top: 0; transform-origin: left center; transform-style: preserve-3d; transition: transform .9s cubic-bezier(.45, .05, .25, 1); }
.rb-leaf.turned { transform: rotateY(-180deg); }
.rb-leaf.snap { transition: none !important; }
.rb-face { position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; background: #e9e0c8; box-shadow: 0 2px 12px rgba(0,0,0,.45); }
.rb-face.back { transform: rotateY(180deg); }
.rb-face.pr::after, .rb-face.pl::after { content: ""; position: absolute; inset: 0; pointer-events: none; }
.rb-face.pr::after { background: linear-gradient(90deg, rgba(0,0,0,.28), rgba(0,0,0,.06) 7%, transparent 14%); }
.rb-face.pl::after { background: linear-gradient(270deg, rgba(0,0,0,.28), rgba(0,0,0,.06) 7%, transparent 14%); }
.rb-face .rpage, .rb-face .rboard { position: absolute; inset: 0; }
/* bookmark on the open book: a long strip with the title, or a folded corner */
.bm { position: absolute; z-index: 2500; pointer-events: none; }
.bm.away { opacity: 0; transition: opacity .28s; }
.bm-strip { filter: drop-shadow(3px 6px 6px rgba(0, 0, 0, .42)); }
.bm-card { position: absolute; inset: 0; box-sizing: border-box; display: flex; flex-direction: column; align-items: center; justify-content: space-between; padding: 7% 0 11%;
  background: linear-gradient(90deg, #f4ecd3, #e9dfbd 55%, #f0e6c8); clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 96.5%, 0 100%); }
.bm-card::before { content: ""; position: absolute; inset: 3px; border: 1px solid color-mix(in srgb, var(--cover) 55%, transparent); border-bottom: none; clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 95%, 0 100%); }
.bm-o { width: 46%; height: 2px; background: var(--cover); opacity: .6; flex: none; }
.bm-t { writing-mode: vertical-rl; transform: rotate(180deg); font: 700 1em Georgia, serif; letter-spacing: .2em; text-transform: uppercase; color: var(--cover); max-height: 64%; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.bm-d { color: var(--cover); opacity: .6; font-size: 1.1em; flex: none; margin-bottom: 6%; }
.bm-strip.enter { animation: bmIn 1s cubic-bezier(.2, .8, .25, 1) both; }
.bm-strip.leave { animation: bmOut .6s cubic-bezier(.5, 0, .9, .4) both; }
@keyframes bmIn { 0% { transform: translateY(-130%) rotate(-5deg); opacity: 0; } 12% { opacity: 1; } 68% { transform: translateY(2.2%) rotate(.9deg); } 84% { transform: translateY(-.8%) rotate(-.3deg); } 100% { transform: none; opacity: 1; } }
@keyframes bmOut { to { transform: translateY(-135%) rotate(4deg); opacity: 0; } }
.bm-corner { perspective: 900px; }
.bm-corner.l { transform: scaleX(-1); }
.bc-under, .bc-front, .bc-back, .bc-sh { position: absolute; inset: 0; }
.bc-under { clip-path: polygon(100% 0, 100% 100%, 0 100%); background: linear-gradient(135deg, #b8ac8a, #8f8466); }
.bc-sh { clip-path: polygon(0 0, 100% 0, 0 100%); background: linear-gradient(to bottom right, transparent 52%, rgba(0, 0, 0, .3)); transform: translate(-4%, -4%); opacity: 0; transition: opacity .5s ease .35s; }
.bm-corner.on .bc-sh { opacity: 1; }
.bc-flap { position: absolute; inset: 0; transform-style: preserve-3d; transition: transform .95s cubic-bezier(.45, .05, .2, 1); }
.bm-corner.on .bc-flap { transform: rotate3d(1, -1, 0, 180deg); }
.bm-corner.still .bc-flap, .bm-corner.still .bc-sh { transition: none; }
.bc-front { clip-path: polygon(100% 0, 100% 100%, 0 100%); background: var(--sheet); backface-visibility: hidden; -webkit-backface-visibility: hidden; }
.bc-back { clip-path: polygon(0 0, 100% 0, 0 100%); background: linear-gradient(to bottom right, #fbf4de 50%, #d7cdae); backface-visibility: hidden; -webkit-backface-visibility: hidden; transform: rotate3d(1, -1, 0, 180deg); }
.bm-corner.leave .bc-flap { transition-duration: .7s; }
.rd-book.has-mark .rb-ribbon { opacity: 0; }
#rdHud button.bmb { padding: 4px 10px; display: inline-flex; align-items: center; } #rdHud button.bmb svg { width: 18px; height: 18px; }
#rdHud button.bmb.on { background: var(--accent); border-color: var(--accent); color: #1b1208; }
#rdHud button.sm { font-size: 12px; padding: 5px 12px; }
.rb-ribbon { position: absolute; left: calc(50% - 6px); bottom: -34px; width: 12px; height: 70px; background: linear-gradient(90deg, #7d1717, #b52a2a, #7d1717); clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 86%, 0 100%); z-index: 0; transition: opacity .4s; }
.rd-book.closed .rb-ribbon { opacity: 0; }

.rd-board { position: relative; background: linear-gradient(135deg, #8a5a33, #6b4223 55%, #7a4d2b); border-radius: 12px; box-shadow: 0 18px 50px rgba(0,0,0,.65), inset 0 0 0 3px rgba(0,0,0,.2), inset 0 0 40px rgba(0,0,0,.25); }
.bd-pile { position: absolute; perspective: 2600px; perspective-origin: 50% 20%; }
.bd-pile::before { content: ""; position: absolute; left: 3px; right: -3px; top: 4px; bottom: -5px; background: #dcd3bd; box-shadow: 0 1px 0 #bfb59b, 0 3px 0 #d6cdb5, 0 5px 0 #b9af95; }
.bd-sheet { position: absolute; inset: 0; transform-origin: 50% 0; transform-style: preserve-3d; transition: transform .9s cubic-bezier(.45, .05, .25, 1) var(--d, 0ms), opacity .2s linear var(--d, 0ms); }
.bd-sheet.up { transform: rotateX(180deg); opacity: 0; transition: transform .9s cubic-bezier(.45, .05, .25, 1) var(--d, 0ms), opacity .3s linear calc(var(--d, 0ms) + 560ms); }
.bd-sheet.snap { transition: none !important; }
.bd-face { position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; background: #f2ecdb; box-shadow: 0 1px 6px rgba(0,0,0,.35); }
.bd-face.back { transform: rotateX(180deg); }
.bd-face .rpage { position: absolute; inset: 0; }
.bd-label { position: absolute; top: 20px; left: 24px; max-width: calc(50% - 100px); padding: 5px 14px; background: #efe5c8; color: #4a3820; font: 600 14px Georgia, serif; border-radius: 3px; box-shadow: 0 1px 3px rgba(0,0,0,.4); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; z-index: 3000; }
.bd-clip { position: absolute; top: 30px; left: 50%; width: 120px; height: 62px; transform: translateX(-50%); z-index: 3001; pointer-events: none; }
.bd-clip::before { content: ""; position: absolute; inset: 0; border-radius: 8px 8px 4px 4px; background: linear-gradient(180deg, #e6e9ee, #9aa2ae 55%, #c9ced6); box-shadow: 0 4px 8px rgba(0,0,0,.5); }
.bd-clip i { position: absolute; left: 50%; top: 10px; width: 54px; height: 16px; transform: translateX(-50%); border-radius: 99px; background: #4b525d; box-shadow: inset 0 2px 4px rgba(0,0,0,.6); }
.bd-stamp { position: absolute; right: 22px; bottom: 16px; padding: 3px 14px; border: 3px double; border-radius: 6px; font: 800 17px "Courier New", monospace; letter-spacing: .1em; transform: rotate(-6deg); opacity: .85; z-index: 3000; }
.bd-stamp.s-draft { color: #d98a2b; } .bd-stamp.s-inreview { color: #9cc3f0; } .bd-stamp.s-final { color: #8fd27c; }

.rd-story .st-page { position: absolute; left: 0; top: 0; box-shadow: 0 10px 34px rgba(0,0,0,.6); border-radius: 2px; transition: transform .4s ease, opacity .4s ease; }
.rd-story .st-page .doc-body { user-select: text; }
.rd-story .in-r, .rd-story .out-r { transform: translateX(70px); opacity: 0; } .rd-story .in-l, .rd-story .out-l { transform: translateX(-70px); opacity: 0; }
.rd-story .out-l, .rd-story .out-r { pointer-events: none; }

.rd-scroll { position: absolute; inset: 0; overflow: auto; padding: 36px 24px 90px; display: flex; justify-content: center; }
.mail { width: 100%; max-width: 780px; height: fit-content; background: #f6f7f9; color: #26303c; border-radius: 12px; box-shadow: 0 16px 50px rgba(0,0,0,.55); overflow: hidden; animation: mailIn .55s cubic-bezier(.2, .8, .2, 1); }
@keyframes mailIn { from { transform: translateY(50px) scale(.97); opacity: 0; } to { transform: none; opacity: 1; } }
.mail-bar { display: flex; align-items: center; gap: 7px; padding: 10px 14px; background: #e3e7ee; color: #5d6a7c; font-size: 12px; font-weight: 600; }
.mail-bar i { width: 11px; height: 11px; border-radius: 50%; background: #c2c9d6; } .mail-bar i:first-child { background: #ee7b6e; } .mail-bar i:nth-child(2) { background: #f1c25b; } .mail-bar i:nth-child(3) { background: #79c479; } .mail-bar span { margin-left: 12px; }
.mail-card { padding: 26px 34px 34px; }
.m-subj { margin: 0 0 18px; font: 600 24px "Segoe UI", system-ui, sans-serif; }
.m-head { display: flex; align-items: center; gap: 12px; }
.avatar { flex: none; width: 42px; height: 42px; border-radius: 50%; background: #3f7f6c; color: #fff; display: flex; align-items: center; justify-content: center; font: 600 18px "Segoe UI", sans-serif; }
.m-who { flex: 1; min-width: 0; } .m-who b { font-size: 15px; } .m-to { color: #6b7686; font-size: 13px; } .m-date { color: #6b7686; font-size: 12.5px; white-space: nowrap; }
.m-rule { height: 1px; background: #dfe3ea; margin: 18px 0 20px; }
.m-body { padding: 0; }
.cork { align-items: flex-start; padding-top: 60px; background: radial-gradient(circle at 20% 30%, rgba(255,255,255,.05) 0 2px, transparent 3px) 0 0 / 22px 22px, radial-gradient(circle at 70% 60%, rgba(0,0,0,.12) 0 2px, transparent 3px) 0 0 / 17px 17px, linear-gradient(135deg, #9b7447, #84603a); }
.sticky { position: relative; width: 460px; max-width: 100%; min-height: 340px; padding: 40px 34px 38px; background: linear-gradient(170deg, rgba(255,255,255,.35), transparent 40%), var(--note); color: #3a3320; border-radius: 2px 2px 14px 2px; box-shadow: 0 2px 2px rgba(0,0,0,.25), 12px 18px 30px rgba(0,0,0,.4); transform: rotate(-1.6deg); animation: stick .6s cubic-bezier(.2, .9, .25, 1.15); height: fit-content; }
@keyframes stick { from { transform: translateY(-150px) rotate(-12deg) scale(1.3); opacity: 0; } 60% { opacity: 1; } to { transform: rotate(-1.6deg); } }
.sticky h3 { margin: 0 0 12px; font: 700 20px "Segoe Print", "Bradley Hand", "Trebuchet MS", sans-serif; }
.pin { position: absolute; top: 10px; left: 50%; width: 18px; height: 18px; margin-left: -9px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #ff9a8a, #c0392b 60%, #7d1f15); box-shadow: 0 5px 6px rgba(0,0,0,.4); }
.n-body { padding: 0; }
@media (prefers-reduced-motion: reduce) { .rb-leaf, .rb-inner, .bd-sheet, .st-page { transition-duration: .01s !important; transition-delay: 0s !important; } .mail, .sticky { animation: none; } }

/* ---------- printing ---------- */
#print { display: none; }
@media print {
  html, body { background: #fff !important; height: auto; }
  #app, #toast, dialog { display: none !important; }
  #print { display: block; }
  #print .doc-body { --ink: #1c1c1c; color: #1c1c1c; }
  #print figure.fig { break-inside: avoid; }
  .doc-body.indent p { text-indent: 1.27cm; }
}
