:root {
  --bg: #121214;
  --bg-2: #18181b;
  --panel: #1d1d21;
  --panel-2: #24242a;
  --line: #2f2f37;
  --line-2: #3d3d47;
  --text: #ece8e1;
  --muted: #9a958c;
  --amber: #e8a33d;
  --amber-2: #f3c26b;
  --red: #d9534f;
  --green: #6fbf73;
  --blue: #6d9dc5;
  --radius: 8px;
  --sans: "IBM Plex Sans", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  --display: "Fraunces", Georgia, serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 14px/1.45 var(--sans); }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-family: var(--mono); }
h3 { font: 600 11px/1 var(--sans); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 18px 0 8px; }
h3:first-child { margin-top: 4px; }

/* inputs */
input:not([type=checkbox]):not([type=range]):not([type=color]), select, textarea {
  background: var(--bg-2); border: 1px solid var(--line-2); border-radius: 6px; padding: 6px 8px; min-width: 0; color: var(--text);
}
input:focus, select:focus, textarea:focus, button:focus-visible { outline: 2px solid var(--amber); outline-offset: 1px; }
input[type=color] { width: 40px; height: 30px; padding: 0; border: 1px solid var(--line-2); border-radius: 6px; background: none; }
input[type=number] { width: 100%; }
.btn {
  background: var(--panel-2); border: 1px solid var(--line-2); border-radius: 6px; padding: 6px 12px; cursor: pointer; white-space: nowrap;
}
.btn:hover { border-color: var(--amber); }
.btn.primary { background: var(--amber); border-color: var(--amber); color: #1a1205; font-weight: 600; }
.btn.primary:hover { background: var(--amber-2); }
.btn.ghost { background: transparent; }
.btn.danger:hover { border-color: var(--red); color: var(--red); }
.btn.file { display: inline-flex; align-items: center; }
.check { display: flex; gap: 6px; align-items: center; cursor: pointer; }
.row { display: flex; gap: 6px; align-items: center; margin: 6px 0; }
.row > input { flex: 1; }

/* join */
.join { position: fixed; inset: 0; display: grid; place-items: center; padding: 16px;
  background: radial-gradient(ellipse at 50% 30%, #2a2116 0%, var(--bg) 60%); }
.join-card { width: min(360px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 28px; display: grid; gap: 12px; box-shadow: 0 30px 80px #0008; }
.join-card label { display: grid; gap: 4px; font-size: 13px; }
.join-card p { margin: 0; }
.my-games-link { margin-left: auto; font: 500 12px var(--sans); color: var(--muted); text-decoration: none; padding: 2px 8px; border: 1px solid var(--line-2); border-radius: 99px; }
.my-games-link:hover { color: var(--text); border-color: var(--amber); }
.error { color: var(--red); min-height: 1.2em; }
.brand { font: 600 28px/1 var(--display); display: flex; align-items: center; gap: 10px; }
.brand.small { font-size: 18px; }
.flame { width: 12px; height: 12px; border-radius: 50%; background: var(--amber); box-shadow: 0 0 14px 4px #e8a33d66; flex: none; }
.brand.small .flame { width: 9px; height: 9px; }

/* layout */
.app { display: grid; grid-template-columns: 1fr 370px; height: 100vh; }
.stage { position: relative; overflow: hidden; background: #0c0c0e; }
#map { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; display: block; }
.sidebar { background: var(--panel); border-left: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.side-head { padding: 12px 14px 8px; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.presence { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
.presence span { font-size: 11px; padding: 2px 7px; border-radius: 99px; background: var(--panel-2); border: 1px solid var(--line-2); }
.presence span.gm { border-color: var(--amber); }
.tabs { display: flex; border-bottom: 1px solid var(--line); padding: 0 8px; }
.tabs button { background: none; border: 0; padding: 9px 10px; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; }
.tabs button.active { color: var(--text); border-bottom-color: var(--amber); }
.badge { font-size: 10px; background: var(--green); color: #07130a; border-radius: 99px; padding: 0 5px; margin-left: 2px; }
.panel { display: none; padding: 12px 14px; overflow: auto; flex: 1; min-height: 0; }
.panel.active { display: block; }
.panel[data-panel=chat].active { display: flex; flex-direction: column; padding: 0; }
body:not(.is-gm) .gm-only { display: none !important; }

/* toolbar */
.toolstack { position: absolute; top: 12px; left: 12px; display: flex; flex-direction: column; align-items: flex-start; gap: 6px; max-width: calc(100% - 24px); z-index: 5; pointer-events: none; }
.toolstack > * { pointer-events: auto; }
.toolbar { display: flex; gap: 4px; background: #18181bdd; border: 1px solid var(--line); border-radius: 10px; padding: 4px; backdrop-filter: blur(6px); flex-wrap: wrap; align-items: center; }
.tool { background: none; border: 1px solid transparent; border-radius: 6px; padding: 5px 10px; cursor: pointer; color: var(--muted); }
.tool:hover { color: var(--text); }
.tool.active { background: var(--panel-2); border-color: var(--line-2); color: var(--amber-2); }
.sep { width: 1px; background: var(--line-2); margin: 4px 2px; }
.zoom-ctl { position: absolute; bottom: 12px; left: 12px; display: flex; background: #18181bdd; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.zoom-ctl button { background: none; border: 0; padding: 6px 12px; cursor: pointer; }
.zoom-ctl button:hover { background: var(--panel-2); }

/* chat */
.chat-log { list-style: none; margin: 0; padding: 12px 14px; overflow-y: auto; flex: 1; display: flex; flex-direction: column; gap: 10px; }
.msg { display: grid; gap: 2px; }
.msg .who { font-size: 12px; font-weight: 600; display: flex; gap: 6px; align-items: baseline; }
.msg .who time { font-weight: 400; color: var(--muted); font-size: 11px; }
.msg .body { white-space: pre-wrap; word-wrap: break-word; }
.msg.whisper .body { font-style: italic; color: #cfc6ff; }
.tag { font-size: 10px; padding: 1px 6px; border-radius: 99px; border: 1px solid var(--line-2); color: var(--muted); font-weight: 500; }
.tag.gm { border-color: var(--amber); color: var(--amber-2); }
.tag.godice { border-color: var(--green); color: var(--green); }
.roll { background: var(--bg-2); border: 1px solid var(--line); border-left: 3px solid var(--amber); border-radius: 8px; padding: 8px 10px; }
.roll.crit { border-left-color: var(--green); }
.roll.fumble { border-left-color: var(--red); }
.roll .label { font-weight: 600; }
.roll .flavour { font-style: italic; color: #d8cfc0; margin: 2px 0; }
.roll .expr { font-family: var(--mono); font-size: 12px; color: var(--muted); }
.roll .dice { display: flex; flex-wrap: wrap; gap: 4px; margin: 6px 0 2px; align-items: center; font-family: var(--mono); }
.die { min-width: 26px; height: 26px; padding: 0 5px; display: inline-grid; place-items: center; border-radius: 5px; background: var(--panel-2); border: 1px solid var(--line-2); font-weight: 600; font-size: 13px; }
.die.max { border-color: var(--green); color: var(--green); }
.die.min { border-color: var(--red); color: var(--red); }
.die.dropped { opacity: .35; text-decoration: line-through; }
.die.wild { border-style: dashed; }
.chainsep { color: var(--muted); font-size: 11px; }
.op { color: var(--muted); padding: 0 2px; }
.roll .total { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.roll .total b { font: 600 26px/1.1 var(--mono); color: var(--amber-2); }
.flag { font-size: 11px; font-weight: 600; padding: 1px 7px; border-radius: 99px; background: #6fbf7322; color: var(--green); }
.flag.bad { background: #d9534f22; color: var(--red); }
.flag.neutral { background: #e8a33d22; color: var(--amber-2); }
.chat-form { border-top: 1px solid var(--line); padding: 8px 14px 12px; display: grid; gap: 6px; }
.chat-form textarea { resize: none; width: 100%; }
.chat-opts { display: flex; justify-content: space-between; align-items: center; font-size: 12px; }
.hint { font-family: var(--mono); font-size: 11px; }

/* dice panel */
.segmented { display: inline-flex; border: 1px solid var(--line-2); border-radius: 8px; overflow: hidden; }
.segmented button { background: none; border: 0; padding: 6px 14px; cursor: pointer; color: var(--muted); }
.segmented button.active { background: var(--amber); color: #1a1205; font-weight: 600; }
.quick-dice { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.quick-dice button { background: var(--panel-2); border: 1px solid var(--line-2); border-radius: 6px; padding: 8px 0; cursor: pointer; font-family: var(--mono); }
.quick-dice button:hover { border-color: var(--amber); }
.mydice { display: grid; gap: 8px; }
.mydice-preview { width: 100%; height: 130px; display: block; border-radius: var(--radius); background: radial-gradient(ellipse at 50% 60%, var(--panel-2), var(--bg-2)); border: 1px solid var(--line); }
.mydice-presets { display: flex; flex-wrap: wrap; gap: 6px; }
.mydice-presets button { width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--line-2); cursor: pointer; padding: 0; background: var(--a); background-image: linear-gradient(135deg, var(--a) 45%, var(--b) 100%); }
.mydice-presets button:hover, .mydice-presets button:focus-visible { border-color: var(--amber); }
.mydice-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 6px 10px; }
.mydice-grid > label { display: grid; gap: 3px; font-size: 12px; color: var(--muted); }
.mydice-grid input[type=color] { width: 100%; height: 28px; padding: 0 2px; background: var(--panel-2); border: 1px solid var(--line-2); border-radius: 6px; cursor: pointer; }
.mydice-grid > label:last-child { grid-column: 1 / -1; }
.godice-list { list-style: none; padding: 0; margin: 8px 0; display: grid; gap: 6px; }
.godice-list li { display: grid; grid-template-columns: 14px 1fr auto auto; align-items: center; gap: 8px; background: var(--bg-2); border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; }
.godice-list .dot { width: 12px; height: 12px; border-radius: 50%; border: 1px solid #fff4; }
.godice-list .meta { font-size: 12px; }
.godice-list .meta small { color: var(--muted); display: block; }
.godice-list li.rolling .dot { animation: wobble .4s linear infinite; }
.godice-list li.off { opacity: .5; }
.godice-list select { padding: 3px 4px; }
.godice-list .last { font: 600 16px var(--mono); min-width: 24px; text-align: right; }
@keyframes wobble { 50% { transform: rotate(90deg) scale(.8); } }

/* dice tray (pending physical roll) */
.dice-tray { position: fixed; z-index: 100; left: 50%; bottom: 16px; transform: translateX(-50%); width: min(460px, calc(100% - 24px)); background: #1d1d21f2; border: 1px solid var(--amber); border-radius: 12px; padding: 12px 14px; box-shadow: 0 20px 60px #000a; display: grid; gap: 8px; }
.dice-tray .title { display: flex; justify-content: space-between; gap: 8px; font-weight: 600; }
.dice-tray .slots { display: flex; gap: 6px; flex-wrap: wrap; }
.dice-tray .slot { min-width: 44px; height: 44px; padding: 0 6px; border-radius: 8px; border: 1px dashed var(--line-2); display: grid; place-items: center; font: 600 16px var(--mono); color: var(--muted); }
.dice-tray .slot.want { border-color: var(--amber); color: var(--amber-2); animation: pulse 1.2s ease-in-out infinite; }
.dice-tray .slot.done { border-style: solid; border-color: var(--green); color: var(--text); }
.dice-tray .slot small { display: block; font-size: 9px; font-weight: 400; color: var(--muted); line-height: 1; }
@keyframes pulse { 50% { box-shadow: 0 0 0 4px #e8a33d22; } }
.dice-tray .actions { display: flex; gap: 6px; flex-wrap: wrap; }
.dice-tray .actions input { width: 70px; }

/* sheets list */
.sheet-list { list-style: none; padding: 0; margin: 10px 0; display: grid; gap: 6px; }
.sheet-list li { display: flex; justify-content: space-between; align-items: center; gap: 8px; background: var(--bg-2); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; cursor: pointer; }
.sheet-list li:hover { border-color: var(--amber); }
.sheet-list .sys { font-size: 11px; color: var(--muted); }
.sheet-list select { flex: 1; }

/* scene form */
.grid-form { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 10px; }
.grid-form label { display: grid; gap: 3px; font-size: 12px; color: var(--muted); }
.grid-form label.check { display: flex; color: var(--text); grid-column: span 2; }

/* floating windows */
.window { position: fixed; z-index: 20; background: var(--panel); border: 1px solid var(--line-2); border-radius: 12px; box-shadow: 0 24px 70px #000b; display: flex; flex-direction: column; min-width: 300px; min-height: 160px; resize: both; overflow: hidden; }
.window.focused { z-index: 21; border-color: #5a4a30; }
.win-head { display: flex; align-items: center; gap: 8px; padding: 8px 10px 8px 14px; background: var(--panel-2); cursor: move; user-select: none; border-bottom: 1px solid var(--line); }
.win-head .title { font: 600 15px var(--display); flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.win-head button { background: none; border: 0; cursor: pointer; color: var(--muted); font-size: 16px; padding: 2px 6px; border-radius: 4px; }
.win-head button:hover { color: var(--text); background: var(--line); }
.win-body { overflow: auto; padding: 12px 14px; flex: 1; }

/* character sheets */
.sheet { display: grid; gap: 12px; }
.sheet .hdr { display: grid; grid-template-columns: 72px 1fr; gap: 12px; align-items: start; }
.portrait { width: 72px; height: 72px; border-radius: 10px; background: var(--bg-2) center/cover; border: 1px solid var(--line-2); cursor: pointer; display: grid; place-items: center; color: var(--muted); font-size: 11px; text-align: center; }
.fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 6px 8px; }
.fields label, .sheet label.f { display: grid; gap: 2px; font-size: 11px; color: var(--muted); }
.sheet input, .sheet select, .sheet textarea { width: 100%; }
.sheet textarea { min-height: 70px; resize: vertical; }
.sheet .name-input { font: 600 18px var(--display); }
.sheet fieldset { border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px 10px; margin: 0; }
.sheet legend { font: 600 11px var(--sans); text-transform: uppercase; letter-spacing: .08em; color: var(--amber-2); padding: 0 4px; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 6px; }
.stat { background: var(--bg-2); border: 1px solid var(--line); border-radius: 8px; padding: 6px; display: grid; gap: 3px; text-align: center; }
.stat .k { font: 600 11px var(--sans); letter-spacing: .06em; color: var(--muted); }
.stat input, .stat select { text-align: center; font: 600 16px var(--mono); padding: 3px; }
.stat .dm { font: 11px var(--mono); color: var(--muted); display: flex; align-items: center; justify-content: center; gap: 4px; }
.stat .dm input { width: 44px; font-size: 12px; padding: 1px 2px; }
.rollbtn { background: none; border: 1px solid var(--line-2); border-radius: 6px; cursor: pointer; padding: 3px 8px; font: 600 12px var(--mono); color: var(--amber-2); white-space: nowrap; }
.rollbtn:hover { border-color: var(--amber); background: #e8a33d18; }
.stat .rollbtn { width: 100%; }
.list { display: grid; gap: 4px; }
.list .li { display: grid; gap: 4px; align-items: center; }
.list .li input, .list .li select { padding: 4px 6px; }
.list .hd { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.del { background: none; border: 0; color: var(--muted); cursor: pointer; padding: 2px 6px; }
.del:hover { color: var(--red); }
.add { background: none; border: 1px dashed var(--line-2); border-radius: 6px; color: var(--muted); cursor: pointer; padding: 4px; margin-top: 4px; width: 100%; }
.add:hover { color: var(--text); border-color: var(--amber); }
.sheet-bar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 8px 10px; background: var(--bg-2); border: 1px solid var(--line); border-radius: 8px; font-size: 12px; }
.sheet-bar input { width: 64px; }
.sheet-bar .grow { flex: 1; }
.track { display: flex; gap: 4px; align-items: center; }
.track button { width: 24px; height: 24px; border-radius: 50%; border: 1px solid var(--line-2); background: var(--bg-2); cursor: pointer; font-size: 11px; }
.track button.on { background: var(--red); border-color: var(--red); }
.track.bennies button.on { background: var(--amber); border-color: var(--amber); }
.readonly input, .readonly select, .readonly textarea { pointer-events: none; opacity: .85; }

/* token dialog */
.dialog .grid-form { margin-bottom: 12px; }

/* toast */
.toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%) translateY(20px); background: var(--panel-2); border: 1px solid var(--line-2); padding: 8px 14px; border-radius: 8px; opacity: 0; pointer-events: none; transition: .2s; z-index: 50; max-width: 90vw; }
.toast.show { opacity: 1; transform: translateX(-50%); }
.toast.bad { border-color: var(--red); }

@media (max-width: 820px) {
  .app { grid-template-columns: 1fr; grid-template-rows: 55vh 45vh; }
  .sidebar { border-left: 0; border-top: 1px solid var(--line); }
  .window { left: 8px !important; right: 8px; width: auto !important; top: 8px !important; max-height: 85vh; }
}


/* ---------- library panel ---------- */
.panel[data-panel=library].drop { outline: 2px dashed var(--amber); outline-offset: -6px; }
.lib-q { width: 100%; font-size: 15px; padding: 8px 10px !important; }
.lib-add { display: flex; align-items: center; gap: 8px; margin: 8px 0 4px; }
.lib-sec[data-sec="import"].dragging { outline: 2px dashed var(--accent, #e0a33e); outline-offset: 4px; border-radius: 8px; }
.import-status { margin: 8px 0; min-height: 1.3em; }
.import-status b { color: var(--accent, #e0a33e); }
.import-warn { margin: 6px 0 0; padding-left: 18px; color: var(--muted, #9aa0a6); font-size: 12px; }
.import-how { line-height: 1.5; margin-top: 10px; border-top: 1px solid var(--line, #2a2a30); padding-top: 10px; }
.import-how code { background: #00000033; padding: 1px 4px; border-radius: 4px; }
.lib-list { list-style: none; padding: 0; margin: 10px 0; display: grid; gap: 6px; }
.lib-list li { display: flex; align-items: stretch; background: var(--bg-2); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.lib-list li.empty { padding: 12px; display: block; border-style: dashed; font-size: 13px; }
.lib-list .open { flex: 1; text-align: left; background: none; border: 0; padding: 8px 10px; cursor: pointer; display: grid; gap: 2px; min-width: 0; }
.lib-list .open:hover:not(:disabled) { background: #ffffff08; }
.lib-list .t { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lib-list .m, .lib-list .s { font-size: 11px; color: var(--muted); display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.lib-list .share.on { color: var(--green); }
.lib-list .warn { color: var(--amber-2); }
.lib-list .bad, .bad { color: var(--red); }
.lib-list .gear { background: none; border: 0; border-left: 1px solid var(--line); color: var(--muted); cursor: pointer; padding: 0 12px; font-size: 15px; }
.lib-list .gear:hover { color: var(--amber-2); }
.prog { display: inline-block; width: 90px; height: 5px; border-radius: 3px; background: var(--line); overflow: hidden; }
.prog span { display: block; height: 100%; background: var(--amber); transition: width .2s; }
.upload-row { display: grid; gap: 4px; font-size: 12px; margin: 6px 0; }
.upload-row .prog { width: 100%; }
.upload-row .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
.lib-results { margin-top: 10px; display: grid; gap: 6px; }
.lib-results p { margin: 0 0 2px; }
.hit { text-align: left; background: var(--bg-2); border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; cursor: pointer; display: grid; gap: 3px; width: 100%; }
.hit:hover, .hit.cur { border-color: var(--amber); }
.hit .where { font-size: 12px; color: var(--muted); }
.hit .where b { color: var(--amber-2); }
.hit .snip, .hit span { font-size: 12.5px; line-height: 1.4; white-space: pre-line; overflow-wrap: anywhere; }
mark { background: #e8a33d55; color: inherit; border-radius: 2px; padding: 0 1px; }
.pdfset { display: grid; gap: 8px; }
.pdfset h3 { margin: 10px 0 0; }
.pdfset .players { display: grid; gap: 4px; padding-left: 22px; }
.pdfset label.f { display: grid; gap: 3px; font-size: 12px; color: var(--muted); }

/* ---------- PDF viewer ---------- */
.window .win-body.pdfbody { padding: 0; display: flex; flex-direction: column; position: relative; }
.pdfbar { display: flex; align-items: center; gap: 4px; padding: 6px 8px; border-bottom: 1px solid var(--line); flex-wrap: wrap; background: var(--panel); }
.pdfbar .b { background: var(--panel-2); border: 1px solid var(--line-2); border-radius: 6px; padding: 3px 9px; cursor: pointer; min-width: 30px; }
.pdfbar .b:hover { border-color: var(--amber); }
.pdfbar .pg { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 4px; }
.pdfbar .pno { width: 54px; padding: 3px 5px !important; text-align: center; }
.pdfbar .toc { max-width: 160px; padding: 3px 5px !important; }
.pdfbar .find { width: 160px; padding: 4px 8px !important; }
.pdfbar .sep { width: 1px; align-self: stretch; background: var(--line-2); margin: 0 3px; }
.pdfbar .grow { flex: 1; }
.pdfmain { flex: 1; display: flex; min-height: 0; }
.pdfmain .hits { width: 210px; flex: none; overflow-y: auto; border-right: 1px solid var(--line); padding: 6px; display: flex; flex-direction: column; gap: 5px; background: var(--panel); }
.pdfmain .hits .hh { display: flex; justify-content: space-between; align-items: center; font-size: 12px; color: var(--muted); padding: 2px 2px 4px; }
.pdfmain .hits .x { background: none; border: 0; color: var(--muted); cursor: pointer; }
.pdfmain .hits .hit { padding: 5px 7px; }
.pdfmain .hits .hit b { font-size: 12px; color: var(--amber-2); }
.pdfmain .hits .hit span { font-size: 11.5px; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.scroller { flex: 1; overflow: auto; background: #0c0c0e; padding: 12px; }
.scroller .page { position: relative; margin: 0 auto; background: #fff; box-shadow: 0 6px 30px #000a; }
.scroller .page canvas { display: block; }
.selecting .scroller .page { cursor: crosshair; }
.selecting .textLayer { pointer-events: none; }
.scroller .sel { position: absolute; border: 2px solid var(--amber); background: #e8a33d22; box-shadow: 0 0 0 9999px #0006; z-index: 5; pointer-events: none; }
.selpop { position: absolute; left: 50%; top: 52px; transform: translateX(-50%); display: flex; gap: 6px; background: var(--panel); border: 1px solid var(--amber); padding: 8px; border-radius: 10px; box-shadow: 0 10px 40px #000b; z-index: 6; }

/* pdf.js text layer (the essentials of pdf_viewer.css) — invisible text over the page for selecting and highlighting */
.textLayer {
  position: absolute; text-align: initial; inset: 0; overflow: clip; opacity: 1; line-height: 1;
  letter-spacing: normal; word-spacing: normal; text-size-adjust: none; -webkit-text-size-adjust: none; forced-color-adjust: none;
  transform-origin: 0 0; caret-color: CanvasText; z-index: 0;
  --min-font-size: 1; --text-scale-factor: calc(var(--total-scale-factor) * var(--min-font-size)); --min-font-size-inv: calc(1 / var(--min-font-size));
}
.textLayer :is(span, br) { color: transparent; position: absolute; white-space: pre; cursor: text; transform-origin: 0% 0%; user-select: text; }
.textLayer > :not(.markedContent), .textLayer .markedContent span:not(.markedContent) {
  z-index: 1; --font-height: 0; font-size: calc(var(--text-scale-factor) * var(--font-height));
  --scale-x: 1; --rotate: 0deg; transform: rotate(var(--rotate)) scaleX(var(--scale-x)) scale(var(--min-font-size-inv));
}
.textLayer .markedContent { display: contents; }
.textLayer span[role=img] { user-select: none; cursor: default; }
.textLayer ::selection { background: rgb(0 90 255 / .25); }
.textLayer br::selection { background: transparent; }
.textLayer .endOfContent { display: block; position: absolute; inset: 100% 0 0; z-index: 0; cursor: default; user-select: none; }
.textLayer mark.hl { position: static; color: transparent; background: rgb(232 163 61 / .45); border-radius: 2px; padding: 0; outline: 2px solid rgb(232 163 61 / .5); }

/* ---------- handouts ---------- */
.handout { display: grid; gap: 4px; background: var(--bg-2); border: 1px solid var(--line); border-left: 3px solid var(--blue); border-radius: 8px; padding: 6px; cursor: zoom-in; text-align: left; width: 100%; }
.handout:hover { border-color: var(--blue); }
.handout img { width: 100%; max-height: 220px; object-fit: contain; background: #fff; border-radius: 4px; }
.handout span { font-size: 12px; color: var(--muted); }
.window .win-body.handoutbody { padding: 0; background: #0c0c0e; }
.handoutbody img { display: block; width: 100%; cursor: zoom-in; }
.handoutbody img.zoomed { width: auto; max-width: none; cursor: zoom-out; }

.die.succ { border-color: var(--green); color: var(--green); background: #6fbf7318; }
.die.nosucc { opacity: .7; }
.die.pushed { box-shadow: 0 0 0 2px #e8a33d55; }
.roll .push { margin-top: 6px; font-size: 12px; padding: 4px 10px; }

/* ---------- tabs: seven fit in the sidebar ---------- */
.tabs { padding: 0 4px; }
.tabs button { padding: 9px 6px; font-size: 13px; white-space: nowrap; flex: 0 1 auto; }

/* ---------- combat tracker ---------- */
.combat-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; margin-bottom: 8px; }
.combat-head .row { margin: 0; flex-wrap: wrap; justify-content: flex-end; }
.combat-add { flex-wrap: wrap; }
.combat-add .add-name { flex: 1; min-width: 80px; }
.combat-list { list-style: none; padding: 0; margin: 8px 0; display: grid; gap: 6px; }
.combat-list li { display: grid; grid-template-columns: 52px 1fr auto auto; gap: 8px; align-items: start; background: var(--bg-2); border: 1px solid var(--line); border-radius: 8px; padding: 7px 8px; }
.combat-list li.empty { display: block; border-style: dashed; font-size: 13px; }
.combat-list li.active { border-color: var(--amber); box-shadow: 0 0 0 1px var(--amber), 0 0 18px #e8a33d33; }
.combat-list li.pc { border-left: 3px solid var(--blue); }
.combat-list li.hidden-e { opacity: .6; }
.combat-list .init { display: grid; gap: 2px; justify-items: center; font: 600 16px var(--mono); }
.combat-list .init input { width: 50px; text-align: center; font: 600 15px var(--mono); padding: 3px !important; }
.combat-list .init .card { font-size: 11px; color: var(--amber-2); }
.combat-list .who { min-width: 0; display: grid; gap: 3px; }
.combat-list .name { background: none; border: 0; padding: 0; font-weight: 600; text-align: left; cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.combat-list .name:hover { color: var(--amber-2); }
.combat-list .tags { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.combat-list .tags input { width: 40px; padding: 1px 3px !important; font-size: 11px; }
.combat-list .conds { display: flex; gap: 4px; flex-wrap: wrap; align-items: center; }
.cond { font-size: 11px; background: #d9534f22; color: #f0a19e; border-radius: 99px; padding: 1px 4px 1px 8px; display: inline-flex; align-items: center; gap: 3px; }
.cond small { background: #0005; border-radius: 99px; padding: 0 5px; }
.cond button { background: none; border: 0; color: inherit; cursor: pointer; padding: 0 3px; }
.cond-add { display: inline-flex; gap: 2px; }
.cond-add .cond-in { width: 96px; padding: 1px 5px !important; font-size: 11px; }
.cond-add .cond-rounds { width: 44px; padding: 1px 3px !important; font-size: 11px; }
.combat-list .hpcell .hp { display: flex; gap: 3px; align-items: center; flex-wrap: wrap; justify-content: flex-end; font: 13px var(--mono); max-width: 170px; }
.combat-list .hp input { width: 44px; padding: 2px 3px !important; text-align: center; }
.combat-list .hp .dmg-in { width: 40px; }
.hpbar { flex-basis: 100%; height: 4px; background: var(--line); border-radius: 2px; overflow: hidden; }
.hpbar span { display: block; height: 100%; }
.status { font-size: 11px; padding: 1px 7px; border-radius: 99px; background: var(--panel-2); }
.status.hurt { color: var(--amber-2); } .status.bloodied, .status.critical { color: var(--red); } .status.down { color: #fff; background: var(--red); } .status.healthy { color: var(--green); }
.combat-list .acts { display: flex; flex-direction: column; gap: 2px; }
.b { background: var(--panel-2); border: 1px solid var(--line-2); border-radius: 5px; padding: 1px 6px; cursor: pointer; font-size: 12px; min-width: 24px; }
.b:hover { border-color: var(--amber); }
.lnk { background: none; border: 0; padding: 0; color: var(--amber-2); cursor: pointer; font-size: 11px; text-decoration: underline; }

/* ---------- library sections ---------- */
.lib-sections { display: grid; grid-template-columns: repeat(4, 1fr); margin: 10px 0 8px; width: 100%; }
.lib-results h3 { margin: 12px 0 4px; }
.note-list { list-style: none; padding: 0; margin: 0 0 6px; display: grid; gap: 5px; }
.note-list button { width: 100%; text-align: left; background: var(--bg-2); border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; cursor: pointer; display: grid; gap: 1px; }
.note-list button:hover { border-color: var(--amber); }
.note-list .t { font-weight: 600; }
.note-list .m { font-size: 11px; color: var(--muted); }
.note-list .m .on { color: var(--green); }
.notecard { display: grid; gap: 2px; text-align: left; width: 100%; background: var(--bg-2); border: 1px solid var(--line); border-left: 3px solid var(--green); border-radius: 8px; padding: 7px 10px; cursor: pointer; }
.note-edit { display: flex; flex-direction: column; gap: 8px; height: 100%; }
.note-edit .row { margin: 0; }
.note-edit .n-title { flex: 2; font: 600 16px var(--display); }
.note-edit .n-folder { flex: 1; }
.note-edit .n-body { flex: 1; min-height: 300px; resize: none; font: 13.5px/1.55 var(--mono); }
.note-tools { margin-top: 0; flex-wrap: wrap; }

/* rendered markdown (notes and rules) */
.md { line-height: 1.55; }
.md h2, .md h3, .md h4 { font-family: var(--display); color: var(--amber-2); margin: 16px 0 6px; letter-spacing: 0; text-transform: none; font-size: 17px; }
.md h3 { font-size: 15px; } .md h4 { font-size: 14px; color: var(--text); }
.md p { margin: 0 0 9px; }
.md blockquote { margin: 10px 0; padding: 10px 14px; background: #e8a33d12; border-left: 3px solid var(--amber); border-radius: 0 8px 8px 0; font-style: italic; }
.md table { border-collapse: collapse; margin: 8px 0 12px; font-size: 13px; }
.md th, .md td { border: 1px solid var(--line-2); padding: 4px 9px; text-align: left; vertical-align: top; }
.md th { background: var(--panel-2); }
.md ul, .md ol { margin: 0 0 9px; padding-left: 22px; }
.md code { font-family: var(--mono); background: var(--bg-2); padding: 0 4px; border-radius: 4px; }
.md hr { border: 0; border-top: 1px solid var(--line-2); margin: 12px 0; }
.md a, .xref { color: var(--amber-2); cursor: pointer; }
.xref { text-decoration: underline dotted; }

/* ---------- rules ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 4px; margin: 6px 0; }
.chips button { background: var(--bg-2); border: 1px solid var(--line-2); border-radius: 99px; padding: 3px 10px; cursor: pointer; font-size: 12px; color: var(--muted); }
.chips button.on { background: var(--amber); border-color: var(--amber); color: #1a1205; font-weight: 600; }
.rules-filter { width: 100%; margin: 4px 0; }
.rules-list { list-style: none; padding: 0; margin: 6px 0; display: grid; gap: 3px; }
.rules-list button { width: 100%; text-align: left; background: none; border: 0; border-bottom: 1px solid var(--line); padding: 6px 4px; cursor: pointer; display: flex; justify-content: space-between; gap: 8px; }
.rules-list button:hover { background: #ffffff08; }
.rules-list small { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 50%; }
.rules-credit { margin-top: 10px; }
.rulesbody .sub { font-style: italic; color: var(--muted); margin: 0 0 8px; }
.rulesbody .facts { display: grid; grid-template-columns: auto 1fr; gap: 3px 12px; margin: 0 0 10px; font-size: 13px; }
.rulesbody .facts dt { font-weight: 600; color: var(--amber-2); }
.rulesbody .facts dd { margin: 0; }
.statblock p { margin: 0 0 6px; }
.statblock hr { border: 0; border-top: 2px solid #8e2c2c; margin: 8px 0; }
.statblock h4 { font-family: var(--display); color: var(--amber-2); border-bottom: 1px solid var(--line-2); margin: 12px 0 6px; }
.statblock .abil { display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px; }
.statblock .abil .rollbtn { display: grid; gap: 1px; padding: 4px 0; color: var(--text); }
.statblock .abil span { font-weight: 400; color: var(--muted); }
.statblock .rollbtn { margin-left: 4px; }
.statblock .gm-actions { margin-top: 12px; flex-wrap: wrap; border-top: 1px solid var(--line); padding-top: 10px; }
.spellroll { margin-top: 12px; }
.rs-choices { display: grid; gap: 6px; }
.rs-choice { text-align: left; background: var(--bg-2); border: 1px solid var(--line-2); border-radius: 10px; padding: 9px 12px; cursor: pointer; display: grid; gap: 2px; }
.rs-choice:hover { border-color: var(--amber); }
.rs-choice span { font-size: 12px; color: var(--muted); }
.quick-macros { flex-wrap: wrap; }

/* ---------- new sheets ---------- */
.savep { display: flex; align-items: center; gap: 3px; justify-content: center; }
.savep .rollbtn { width: auto; flex: 1; font-size: 11px; padding: 2px 4px; }
.slots { display: grid; grid-template-columns: repeat(9, 1fr); gap: 4px; margin: 6px 0; }
.slots .f { font-size: 10px; text-align: center; }
.slots .pair { display: flex; align-items: center; gap: 1px; }
.slots .pair input { padding: 2px 1px !important; text-align: center; font-size: 12px; }
.tftl-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.tftl-grid .stat > input { width: 60px; justify-self: center; }

/* GM tracker rows: name and tags on top, hit points underneath, buttons on the right */
.combat-list li.gm { grid-template-columns: 52px 1fr auto; grid-template-areas: "init who acts" "init hp acts"; }
.combat-list li.gm .init { grid-area: init; }
.combat-list li.gm .who { grid-area: who; }
.combat-list li.gm .hpcell { grid-area: hp; }
.combat-list li.gm .acts { grid-area: acts; }
.combat-list li.gm .hpcell .hp { justify-content: flex-start; max-width: none; }
.combat-list li.gm .hpbar { flex-basis: 60px; flex-grow: 0; }
.combat-list li:not(:hover):not(:focus-within) .cond-add { display: none; }
.combat-add .add-name { flex: 1; }

/* ---------- video calls ---------- */
.side-right { display: flex; flex-direction: column; align-items: flex-end; gap: 5px; }
.avbtn { background: var(--panel-2); border: 1px solid var(--line-2); border-radius: 99px; padding: 3px 10px; cursor: pointer; font-size: 12px; }
.avbtn:hover { border-color: var(--green); }
.avbtn.on { border-color: var(--red); color: #f0a19e; }
.video-dock { position: absolute; z-index: 15; background: #18181bdd; border: 1px solid var(--line); border-radius: 12px; backdrop-filter: blur(6px); padding: 6px; display: flex; flex-direction: column; gap: 6px; max-height: calc(100% - 80px); }
.video-dock.dock-right { top: 64px; right: 12px; }
.video-dock.dock-bottom { left: 140px; bottom: 12px; max-width: calc(100% - 152px); }
.vbar { display: flex; gap: 3px; flex-wrap: wrap; }
.vbar button { background: var(--panel-2); border: 1px solid var(--line-2); border-radius: 6px; padding: 2px 7px; cursor: pointer; font-size: 13px; min-width: 30px; }
.vbar button:hover { border-color: var(--amber); }
.vbar button.off { background: #d9534f33; border-color: var(--red); }
.vbar .leave { margin-left: auto; color: #f0a19e; }
.vdev { display: grid; gap: 4px; font-size: 12px; color: var(--muted); max-width: 260px; }
.vdev select { width: 100%; }
.vtiles { display: grid; gap: 6px; overflow: auto; }
.dock-right .vtiles { grid-auto-flow: row; }
.dock-bottom .vtiles { grid-auto-flow: column; }
.video-dock.collapsed .vtiles, .video-dock.collapsed .vdev { display: none; }
.vtile { position: relative; background: #0c0c0e; border-radius: 8px; overflow: hidden; border: 2px solid transparent; cursor: zoom-in; aspect-ratio: 4 / 3; transition: border-color .12s; }
.size-s .vtile { width: 132px; } .size-m .vtile { width: 200px; } .size-l .vtile { width: 300px; }
.vtile.pinned { width: 440px !important; cursor: zoom-out; }
.vtile.speaking { border-color: var(--green); }
.vtile video { width: 100%; height: 100%; object-fit: cover; display: block; }
.vtile.me video { transform: scaleX(-1); }
.vtile .vavatar { display: none; position: absolute; inset: 0; margin: auto; width: 46%; aspect-ratio: 1; border-radius: 50%; place-items: center; font: 600 28px var(--display); color: #fff; }
.vtile.nocam video { visibility: hidden; }
.vtile.nocam .vavatar { display: grid; }
.vtile .vname { position: absolute; left: 4px; bottom: 4px; right: 4px; font-size: 11px; background: #000a; padding: 1px 6px; border-radius: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vtile .vname small { color: var(--amber-2); }

/* ---------- touch screens (tablets, the Android app) ---------- */
@media (hover: none) and (pointer: coarse) {
  .combat-list li .cond-add { display: inline-flex !important; } /* no hover to reveal it */
  .tool, .zoom-ctl button { padding: 9px 14px; }
  .tabs button { padding: 12px 7px; }
  .btn, .b, .rollbtn { min-height: 32px; }
  .win-head button { padding: 6px 10px; font-size: 18px; }
  .window { resize: none; }
}
.in-app body { overscroll-behavior: none; -webkit-user-select: none; user-select: none; }
.in-app input, .in-app textarea, .in-app .md, .in-app .chat-log { -webkit-user-select: text; user-select: text; }

/* chat sounds */
.sound-ctl { display: inline-flex; align-items: center; gap: 4px; margin-left: auto; }
.sound-ctl input[type=range] { width: 70px; accent-color: var(--amber-2); }
.iconbtn { background: none; border: 0; cursor: pointer; font-size: 15px; padding: 2px 4px; border-radius: 4px; }
.iconbtn:hover { background: var(--panel-2); }
.chat-opts { gap: 8px; flex-wrap: wrap; }
.chat-opts .hint { margin-left: auto; }
.chat-opts .hint + .sound-ctl { margin-left: 0; }

/* quick character generator */
[data-panel="sheets"] > .row { flex-wrap: wrap; }
.chargen { display: grid; gap: 10px; }
.chargen .row { margin: 0; }
.chargen .cg-sys { flex: 1; }
.chargen .cg-name { font: 600 16px var(--display); }
.chargen .cg-log { margin: 0; padding: 10px 12px 10px 26px; background: var(--panel-2); border: 1px solid var(--line-2); border-radius: 6px; font: 12.5px/1.5 var(--mono); }
.chargen .cg-log li + li { margin-top: 4px; }
.chargen .f { display: grid; gap: 4px; }
.godice-log-box { margin-top: 10px; }
.godice-log-box pre { max-height: 180px; overflow: auto; white-space: pre-wrap; background: var(--panel-2); border: 1px solid var(--line-2); border-radius: 6px; padding: 8px; margin: 6px 0 0; }
.share-box { border-bottom: 1px solid var(--line); padding-bottom: 12px; margin-bottom: 4px; }
.share-box .bad { color: var(--red, #e5484d); }
.share-box #share-link { flex: 1; min-width: 0; font-size: 12px; }

/* GM audio player */
.tabs { overflow-x: auto; scrollbar-width: none; }
.tabs button { position: relative; }
#audio-badge { position: absolute; top: 1px; right: -1px; background: none; color: var(--amber); padding: 0; margin: 0; font-size: 11px; }
.audio-now { padding: 8px 10px; background: var(--panel-2); border: 1px solid var(--line-2); border-radius: 6px; margin: 8px 0; line-height: 1.5; }
[data-panel="audio"] .row input[type=range] { flex: 1; accent-color: var(--amber); }
[data-panel="audio"].drop { outline: 2px dashed var(--amber); outline-offset: -6px; }
.a-buttons { flex-wrap: wrap; }
.a-buttons .big { font-size: 20px; }
.iconbtn.on { background: var(--panel-2); outline: 1px solid var(--amber); }
#audio-time { min-width: 86px; text-align: right; }
.a-list { list-style: none; margin: 4px 0 8px; padding: 0; display: grid; gap: 4px; }
.a-track { display: grid; grid-template-columns: auto 1fr auto auto; grid-template-areas: "act name dur del" ". vol vol kind"; align-items: center; gap: 2px 6px; padding: 4px 6px; border: 1px solid var(--line); border-radius: 6px; }
.a-track .a-act { grid-area: act; font-size: 16px; min-width: 30px; }
.a-track .a-name { grid-area: name; background: none; border: 1px solid transparent; padding: 3px 4px; min-width: 0; }
.a-track .a-name:hover, .a-track .a-name:focus { border-color: var(--line-2); background: var(--bg, #121214); }
.a-track .a-dur { grid-area: dur; }
.a-track .a-del { grid-area: del; color: var(--muted); }
.a-track .a-vol { grid-area: vol; accent-color: var(--amber); min-width: 0; }
.a-track .a-kind { grid-area: kind; font-size: 11px; padding: 1px 2px; }
.a-track.current, .a-track.on { border-color: var(--amber); background: color-mix(in srgb, var(--amber) 8%, transparent); }
.audio-unlock { position: fixed; left: 16px; bottom: 64px; z-index: 50; background: var(--amber); color: #1a1205; border: 0; border-radius: 999px; padding: 10px 16px; font-weight: 600; cursor: pointer; box-shadow: 0 6px 20px #0008; }

/* ---------- scenes ---------- */
.scene-bar { position: absolute; top: 0; left: 0; right: 0; z-index: 6; display: flex; align-items: center; gap: 8px; padding: 8px 12px; background: linear-gradient(#0c0c0ef2, #0c0c0ed0); border-bottom: 1px solid var(--line); }
.scene-bar.collapsed { right: auto; left: 50%; transform: translateX(-50%); padding: 4px 6px; border: 1px solid var(--line); border-top: 0; border-radius: 0 0 10px 10px; }
.scene-bar.collapsed .scene-list, .scene-bar.collapsed .scene-status { display: none; }
.scene-collapse { writing-mode: vertical-rl; transform: rotate(180deg); background: none; border: 1px solid var(--line-2); border-radius: 6px; color: var(--muted); cursor: pointer; padding: 8px 3px; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; }
.scene-bar.collapsed .scene-collapse { writing-mode: horizontal-tb; transform: none; padding: 3px 10px; }
.scene-collapse:hover { color: var(--text); border-color: var(--amber); }
.scene-list { list-style: none; margin: 0; padding: 0 0 2px; display: flex; gap: 8px; overflow-x: auto; flex: 1; scrollbar-width: thin; }
.scene-card { flex: 0 0 132px; border: 1px solid var(--line-2); border-radius: 8px; background: var(--panel); cursor: pointer; overflow: hidden; position: relative; }
.scene-card:hover { border-color: var(--muted); }
.scene-card.viewing { border-color: var(--amber); box-shadow: 0 0 0 1px var(--amber); }
.scene-card.dragging { opacity: .4; }
.scene-card.drop-before { box-shadow: -4px 0 0 var(--amber); }
.scene-card .thumb { height: 56px; background: #1b1b1f center / cover no-repeat; display: grid; place-items: center; color: var(--muted); font-size: 11px; }
.scene-card .meta { display: flex; align-items: center; gap: 4px; padding: 3px 6px; font-size: 12px; }
.scene-card .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.scene-card .nm input { width: 100%; font-size: 12px; padding: 1px 3px; }
.scene-card .acts { display: none; gap: 1px; }
.scene-card:hover .acts, .scene-card:focus-within .acts { display: flex; }
.scene-card .acts button { background: none; border: 0; color: var(--muted); cursor: pointer; padding: 0 2px; font-size: 12px; }
.scene-card .acts button:hover { color: var(--amber-2); }
.live-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--green); margin-right: 5px; vertical-align: 1px; box-shadow: 0 0 6px var(--green); }
.scene-card.add { display: flex; flex-direction: column; justify-content: center; gap: 4px; padding: 6px; background: none; border-style: dashed; cursor: default; flex-basis: 110px; }
.scene-card.add label { display: flex; flex-direction: column; align-items: center; cursor: pointer; color: var(--muted); }
.scene-card.add label span { font-size: 20px; line-height: 1; color: var(--amber); }
.scene-card.add label:hover { color: var(--text); }
.scene-card.add .blank { background: none; border: 0; color: var(--muted); font-size: 11px; cursor: pointer; text-decoration: underline; }
.scene-status { white-space: nowrap; }
.stage.has-scenebar .toolstack { top: 100px; }
.stage.has-scenebar-collapsed .toolstack { top: 44px; }
.scene-preview { position: absolute; z-index: 6; top: 100px; left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 8px; padding: 6px 8px 6px 14px; background: #2a1f0aee; border: 1px solid var(--amber); border-radius: 999px; font-size: 13px; white-space: nowrap; }
.stage.has-scenebar-collapsed .scene-preview { top: 44px; }
.stage.has-scenebar .scene-preview ~ .toolstack, .stage.has-scenebar:has(.scene-preview:not([hidden])) .toolstack { top: 148px; }
.stage.has-scenebar-collapsed:has(.scene-preview:not([hidden])) .toolstack { top: 92px; }
.scene-preview .btn { padding: 4px 12px; }
.scene-name { position: absolute; top: 12px; right: 12px; z-index: 4; font: 600 13px var(--display); color: var(--muted); background: #18181bcc; padding: 4px 10px; border-radius: 8px; pointer-events: none; }
.scene-name:empty, body.is-gm .scene-name { display: none; }
.stage.dropping::after { content: 'Drop maps here to make new scenes'; position: absolute; inset: 12px; z-index: 20; display: grid; place-items: center; border: 3px dashed var(--amber); border-radius: 16px; background: #0c0c0ecc; color: var(--amber-2); font: 600 20px var(--display); pointer-events: none; }

/* ---------- drawing, walls and fog tool options ---------- */
.tool-opts { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; background: #18181bdd; border: 1px solid var(--line); border-radius: 10px; padding: 5px 8px; backdrop-filter: blur(6px); max-width: 100%; }
.tool-opts .seg { display: inline-flex; border: 1px solid var(--line-2); border-radius: 7px; overflow: hidden; }
.tool-opts .seg button { background: none; border: 0; border-right: 1px solid var(--line-2); color: var(--muted); padding: 4px 9px; cursor: pointer; font-size: 14px; }
.tool-opts .seg button:last-child { border-right: 0; }
.tool-opts .seg button:hover { color: var(--text); }
.tool-opts .seg button.active { background: var(--panel-2); color: var(--amber-2); }
.swatches { display: inline-flex; align-items: center; gap: 3px; }
.swatches button { width: 18px; height: 18px; border-radius: 50%; border: 2px solid #0008; background: var(--c); cursor: pointer; padding: 0; }
.swatches button.active { outline: 2px solid var(--amber-2); outline-offset: 1px; }
.swatches input[type=color] { width: 24px; height: 22px; padding: 0; border: 0; background: none; }
.tool-opts input[type=range] { width: 80px; vertical-align: middle; accent-color: var(--amber); }
.tool-opts .small-btn { padding: 3px 9px; font-size: 12px; }
.tool-opts .hint { max-width: 330px; }
.fog-quick { display: inline-flex; align-items: center; gap: 4px; }
.fog-quick select { font-size: 12px; padding: 2px 4px; }
body:not([data-fog="manual"]) .fog-manual, body:not([data-fog="sight"]) .fog-sight { display: none !important; }
body:not([data-fog="manual"]) .fog-panel-manual, body:not([data-fog="sight"]) .fog-panel-sight { display: none; }
.draw-textbox { position: absolute; z-index: 15; transform: translateY(-2px); background: #18181bee; border: 1px solid var(--amber); border-radius: 4px; padding: 2px 6px; font-weight: 600; min-width: 160px; }

/* ---------- scenario prep ---------- */
.lib-list .prep { background: none; border: 0; border-left: 1px solid var(--line); color: var(--amber-2); cursor: pointer; padding: 0 10px; font-size: 12px; font-weight: 600; }
.lib-list .prep:hover { background: var(--panel-2); }
.linkish { background: none; border: 0; padding: 0 2px; color: var(--amber-2); text-decoration: underline; text-underline-offset: 2px; cursor: pointer; font: inherit; }
.linkish:hover { color: var(--amber); }
.prepwin .win-body { padding: 0; display: flex; flex-direction: column; overflow: hidden; }
.prep-wait { padding: 30px; text-align: center; }
.prep-wait .prog { height: 6px; background: var(--panel-2); border-radius: 3px; overflow: hidden; max-width: 360px; margin: 12px auto; }
.prep-wait .prog span { display: block; height: 100%; background: var(--amber); transition: width .3s; }
.prep { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.prep-head { padding: 10px 14px 8px; border-bottom: 1px solid var(--line); }
.prep-head p { margin: 0 0 8px; line-height: 1.45; }
.prep-body { flex: 1; min-height: 0; display: flex; flex-direction: column; overflow: auto; }
.prep-body .pad { padding: 10px 14px; margin: 0; }
.prep-opts { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; padding: 10px 14px; border-bottom: 1px solid var(--line); font-size: 13px; }
.prep-opts label { display: inline-flex; align-items: center; gap: 6px; }
.prep-opts .p-folder { width: 200px; }
.prep-opts .grow, .prep .grow { flex: 1; }
.prep-split { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(240px, 2fr) 3fr; }
.prep-secs { list-style: none; margin: 0; padding: 6px 0; overflow: auto; border-right: 1px solid var(--line); }
.prep-secs li { display: grid; grid-template-columns: 22px 1fr auto; align-items: center; gap: 4px; padding: 3px 10px; }
.prep-secs li.lv2 { padding-left: 26px; } .prep-secs li.lv3 { padding-left: 42px; } .prep-secs li.lv4 { padding-left: 58px; }
.prep-secs li.lv1 .t { font-weight: 600; }
.prep-secs li.inside { opacity: .7; }
.prep-secs li.sel { background: var(--panel-2); }
.prep-secs .t { background: none; border: 0; text-align: left; cursor: pointer; padding: 2px 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: inherit; }
.prep-secs .t:hover { color: var(--amber-2); }
.prep-secs .fold { color: var(--muted); text-align: center; }
.prep-preview { overflow: auto; padding: 10px 16px; font-size: 13.5px; }
.prep-foot { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-top: 1px solid var(--line); }
.prep-foot .muted { flex: 1; }
.prep-read { list-style: none; margin: 0; padding: 0 14px 14px; display: grid; gap: 10px; }
.prep-read blockquote { margin: 0 0 6px; padding: 8px 12px; border-left: 3px solid var(--amber); background: var(--panel-2); font-style: italic; border-radius: 0 6px 6px 0; }
.prep-pics { list-style: none; margin: 0; padding: 0 14px 14px; display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.prep-pics li { border: 1px solid var(--line-2); border-radius: 8px; padding: 8px; display: grid; gap: 6px; }
.prep-pics .thumb { height: 170px; display: grid; place-items: center; background: #0c0c0e; border-radius: 5px; overflow: hidden; }
.prep-pics .thumb img { max-width: 100%; max-height: 100%; object-fit: contain; }
.prep-pics .row { margin: 0; flex-wrap: wrap; }

/* sheets: drag onto the map, or 📍 to place */
.sheet-list li .place { background: none; border: 1px solid transparent; border-radius: 6px; cursor: pointer; font-size: 14px; padding: 2px 6px; margin-left: auto; margin-right: 4px; }
.sheet-list li .place:hover { border-color: var(--line-2); background: var(--panel-2); }
.sheet-list li[draggable="true"] { cursor: grab; }
body.dragging-sheet #map { outline: 3px dashed var(--amber); outline-offset: -6px; }

/* ---------- props ---------- */
.propcoll { border: 1px solid var(--line); border-radius: 8px; margin-bottom: 10px; background: var(--bg-2); }
.propcoll .head { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.propcoll .head .tag { font-size: 10px; border: 1px solid var(--line-2); border-radius: 4px; padding: 0 4px; color: var(--muted); }
.propcoll .head .share { flex-basis: 100%; }
.propcoll .head .acts { margin-left: auto; display: inline-flex; gap: 8px; font-size: 12px; }
.propcoll ul { list-style: none; margin: 0; padding: 4px 0; }
.propcoll li { display: flex; align-items: center; gap: 6px; padding: 2px 10px; }
.propcoll li .t { flex: 1; background: none; border: 0; text-align: left; padding: 4px 0; cursor: pointer; color: inherit; font: 600 13px var(--mono, monospace); letter-spacing: .02em; }
.propcoll li .t:hover { color: var(--amber-2); }
.linkish.danger { color: var(--red); }
.showmenu { position: fixed; z-index: 60; background: var(--panel); border: 1px solid var(--line-2); border-radius: 10px; padding: 10px; display: grid; gap: 8px; min-width: 210px; box-shadow: 0 10px 30px #000a; }
.showmenu .who { display: grid; gap: 4px; max-height: 200px; overflow: auto; }
.propwin .win-body { padding: 0; display: flex; flex-direction: column; overflow: hidden; }
.propbar { display: flex; align-items: center; gap: 6px; padding: 4px 8px; border-bottom: 1px solid var(--line); }
.propbar .grow { flex: 1; }
.propbar .b { background: none; border: 1px solid var(--line-2); border-radius: 6px; color: var(--muted); cursor: pointer; padding: 2px 8px; font-size: 12px; }
.propbar .b:hover { color: var(--text); border-color: var(--amber); }
.propframe { flex: 1; width: 100%; border: 0; background: #000; }
.propcard { display: grid; gap: 2px; width: 100%; text-align: left; background: var(--bg-2); border: 1px solid var(--line-2); border-left: 3px solid var(--amber); border-radius: 6px; padding: 8px 10px; cursor: pointer; color: inherit; }
.propcard b { font-family: var(--mono, monospace); }
.propcard .open { color: var(--amber-2); font-size: 12px; }
.propcard:hover { border-color: var(--amber); }

.propcoll li .pg { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.propcoll li .pg .t { flex: none; }
.propcoll li .who { font-size: 11px; color: var(--green); margin: -2px 0 3px; }
.propcoll li .who .linkish { font-size: 11px; color: var(--muted); }

/* 3D dice */
canvas.dice3d { position: fixed; inset: 0; width: 100vw; height: 100vh; pointer-events: none; z-index: 40; }
.dice3d-total { position: fixed; z-index: 41; transform: translate(-50%, -50%); pointer-events: none; padding: 4px 14px; border-radius: 999px;
  background: #18181bee; border: 2px solid var(--c); color: #fff; font: 700 26px "IBM Plex Sans", sans-serif; box-shadow: 0 6px 20px #000a;
  animation: dice-pop 0.35s cubic-bezier(.2,1.6,.4,1) both; }
@keyframes dice-pop { from { transform: translate(-50%, -30%) scale(0.4); opacity: 0; } }

.import-games { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }

/* battlemap generator */
.mapgen { display: grid; gap: 10px; }
.mapgen .mg-row { display: grid; grid-template-columns: 64px 1fr; gap: 8px; align-items: start; }
.mapgen .mg-row > b { padding-top: 5px; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.mapgen .chips { display: flex; flex-wrap: wrap; gap: 6px; }
.mapgen .chip { padding: 5px 10px; border-radius: 999px; border: 1px solid var(--line); background: var(--panel-2, #1c1c22); color: var(--text); cursor: pointer; font: inherit; font-size: 13px; }
.mapgen .chip small { color: var(--muted); }
.mapgen .chip.on { border-color: var(--amber); background: #3a2c12; color: #ffd48a; }
.mapgen .mg-preview { position: relative; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: #0b0b0d; }
.mapgen .mg-preview canvas { display: block; width: 100%; height: auto; }
.mapgen .mg-title { position: absolute; left: 8px; bottom: 6px; padding: 2px 8px; border-radius: 6px; background: #000b; font-size: 12px; }
.mapgen .mg-actions { grid-template-columns: auto 1fr; align-items: center; }
.mapgen .mg-name { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
.alarm-flash { position: fixed; inset: 0; z-index: 70; pointer-events: none; box-shadow: inset 0 0 120px 30px #ff1e1e; animation: alarm-pulse 0.5s ease-in-out 8 alternate; }
@keyframes alarm-pulse { from { opacity: 0.15; } to { opacity: 1; } }
/* Call of Cthulhu: pushing a roll asks first */
.push-warn { margin-top: 6px; padding: 6px 8px; border-radius: 6px; background: #d9534f1f; color: #f0b9b6; border: 1px solid #d9534f55; }
.btn.push.armed { background: #a8322e; border-color: #a8322e; color: #fff; }
.sheet input.tick { width: 16px; height: 16px; margin: 0; accent-color: var(--amber, #e8a33d); }
/* Library → Handouts */
.handout-q { width: 100%; margin: 6px 0; }
.ho-group { margin: 6px 0; border: 1px solid var(--line, #2a2f37); border-radius: 8px; }
.ho-group > summary { cursor: pointer; padding: 6px 10px; list-style: none; }
.ho-group > summary::-webkit-details-marker { display: none; }
.ho-group > summary::before { content: '▸ '; color: var(--muted, #8a8f98); }
.ho-group[open] > summary::before { content: '▾ '; }
.ho-list { list-style: none; margin: 0; padding: 0 6px 6px; }
.ho { display: grid; grid-template-columns: 44px 1fr auto auto auto; gap: 6px; align-items: center; padding: 4px; border-radius: 6px; }
.ho .btn { padding: 3px 10px; font-size: 12px; }
.ho:hover { background: #ffffff08; }
.ho img { width: 44px; height: 44px; object-fit: cover; border-radius: 4px; cursor: zoom-in; background: #0002; }
.ho-name { overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; font-size: 13px; line-height: 1.25; word-break: break-word; }
.ho-name input { width: 100%; }
.ho-shown { color: #6fbf73; }
.ho .iconbtn.armed { color: #fff; background: #a8322e; border-radius: 4px; padding: 0 6px; width: auto; }
.lib-sec[data-sec="handouts"].dragging { outline: 2px dashed var(--amber, #e8a33d); outline-offset: -4px; }
/* the campaign page */
.campaign-btn { margin-left: 8px; background: none; border: 1px solid var(--line-2, #3d3d47); color: var(--muted, #9a958c); border-radius: 999px; padding: 0 8px; font: 500 11px/1.7 system-ui, sans-serif; letter-spacing: 0; cursor: pointer; white-space: nowrap; flex: none; }
#room-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.campaign-btn:hover { color: var(--text, #ece8e1); border-color: var(--amber, #e8a33d); }
.win-body.cp-win { padding: 0; overflow: auto; }
.cp-banner { position: relative; aspect-ratio: 16 / 5.2; background: #16161a center / cover no-repeat; display: flex; align-items: flex-end; }
.cp-banner::after { content: ''; position: absolute; inset: 0; background: linear-gradient(180deg, #0000 40%, #000c); }
.cp-noban { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted, #9a958c); background: radial-gradient(ellipse at 50% 30%, #2a2116, #121214); }
.cp-title { position: relative; z-index: 1; margin: 0; padding: 0 22px 14px; font: 600 34px/1.1 Georgia, "Times New Roman", serif; color: #fff; text-shadow: 0 2px 10px #000; }
.cp-cols { display: grid; grid-template-columns: minmax(0, 1fr) 220px; gap: 22px; padding: 16px 22px 26px; }
@media (max-width: 700px) { .cp-cols { grid-template-columns: 1fr; } }
.cp-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.cp-chip { border: 1px solid var(--line-2, #3d3d47); border-radius: 999px; padding: 1px 10px; font-size: 12px; }
.cp-chip.lfp { border-color: #6fbf73; color: #6fbf73; }
.cp-next { display: flex; gap: 14px; align-items: center; margin: 16px 0; padding: 12px 0; border-top: 1px solid var(--line, #2f2f37); border-bottom: 1px solid var(--line, #2f2f37); }
.cp-cal { width: 62px; text-align: center; border: 1px solid var(--line-2, #3d3d47); border-radius: 8px; overflow: hidden; display: grid; background: #fff1; }
.cp-cal .m { background: var(--amber, #e8a33d); color: #1a1205; font-size: 11px; font-weight: 600; padding: 1px 0; }
.cp-cal b { font-size: 24px; line-height: 1.2; }
.cp-cal .d { font-size: 10px; color: var(--muted, #9a958c); padding-bottom: 3px; }
.cp-when .big { font-size: 17px; font-weight: 600; }
.cp-desc .md, .cp-entry .md { line-height: 1.55; }
.cp-log-head { display: flex; align-items: center; gap: 10px; margin: 18px 0 8px; }
.cp-log-head h2, .cp-side h2 { margin: 0; font: 600 18px Georgia, serif; }
.cp-entry { border: 1px solid var(--line, #2f2f37); border-radius: 10px; padding: 12px 14px; margin: 10px 0; background: #ffffff05; }
.cp-entry header { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.cp-entry h3 { margin: 0; font: 600 15px/1.3 Georgia, serif; text-transform: none; letter-spacing: 0; color: var(--text, #ece8e1); }
.cp-entry footer { margin-top: 6px; }
.cp-replies { margin-top: 8px; padding-left: 12px; border-left: 2px solid var(--line-2, #3d3d47); display: grid; gap: 8px; }
.cp-reply .iconbtn { float: right; }
.cp-replyform, .cp-write, .cp-edit { display: grid; gap: 8px; }
.cp-edit { margin: 14px 22px 0; padding: 14px; border: 1px solid var(--amber, #e8a33d); border-radius: 10px; }
.cp-write { margin: 10px 0; }
.cp-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.cp-row > input:first-child { flex: 1; min-width: 160px; }
.cp-write textarea, .cp-edit textarea, .cp-replyform textarea { width: 100%; resize: vertical; }
.cp-players { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 10px; }
.cp-players li { display: flex; gap: 10px; align-items: center; }
.cp-av { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; font: 600 17px Georgia, serif; color: #111; flex: none; box-shadow: inset 0 0 0 2px #0003; }
.cp-gm { font-size: 10px; border: 1px solid var(--amber, #e8a33d); color: var(--amber, #e8a33d); border-radius: 999px; padding: 0 6px; }
.cp .grow { flex: 1; }
.side-head .brand { min-width: 0; }
/* a long campaign name or lots of players: the player list drops to its own line rather than squashing the name */
.side-head { flex-wrap: wrap; row-gap: 6px; }
.side-head .brand { flex: 1 1 auto; }
.side-head .side-right { margin-left: auto; }

.pad { padding: 12px 14px; }

/* the dice designer (dicedesigner.js) */
.dd { display: grid; gap: 12px; }
.dd-preview { width: 100%; height: 200px; display: block; border-radius: var(--radius); background: radial-gradient(ellipse at 50% 60%, var(--panel-2), var(--bg-2)); border: 1px solid var(--line); }
.dd-slots { display: flex; flex-wrap: wrap; gap: 6px; }
.dd-slots button { padding: 5px 12px; border-radius: 999px; border: 1px solid var(--line-2); background: var(--panel-2); color: var(--text); cursor: pointer; font: inherit; font-size: 13px; }
.dd-slots button.own { border-color: var(--amber); }
.dd-slots button.own::after { content: ' •'; color: var(--amber); }
.dd-slots button.active { background: var(--amber); color: #141418; border-color: var(--amber); }
.dd-slots button.active.own::after { color: #141418; }
.dd-cols { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 16px; align-items: start; }
@media (max-width: 720px) { .dd-cols { grid-template-columns: 1fr; } }
.dd-own { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; font-size: 14px; }
.dd-fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px 12px; }
.dd-fields.off { opacity: 0.45; }
.dd-fields > label { display: grid; gap: 3px; font-size: 12px; color: var(--muted); }
.dd-fields > label.wide { grid-column: 1 / -1; }
.dd-fields input[type=color] { width: 100%; height: 28px; padding: 0 2px; background: var(--panel-2); border: 1px solid var(--line-2); border-radius: 6px; cursor: pointer; }
.dd-sets h4 { margin: 0 0 8px; }
.dd-save { display: flex; gap: 6px; margin-bottom: 8px; }
.dd-save input { flex: 1; min-width: 0; }
#dd-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
#dd-list li { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel-2); }
#dd-list li.on { border-color: var(--amber); }
.dd-swatch { width: 26px; height: 26px; border-radius: 6px; flex: none; background: linear-gradient(135deg, var(--a) 50%, var(--b)); box-shadow: inset 0 0 0 2px var(--c); }
.dd-name { flex: 1; min-width: 0; display: grid; font-size: 14px; }
.dd-name em { color: var(--amber); font-style: normal; font-size: 12px; }
.dd-name small { color: var(--muted); font-size: 11px; }

/* the token designer (tokendesigner.js) */
.td { display: grid; grid-template-columns: minmax(220px, 300px) minmax(0, 1fr); gap: 16px; align-items: start; }
.td-lib { grid-column: 1 / -1; }
@media (max-width: 720px) { .td { grid-template-columns: 1fr; } }
.td-stage { display: grid; gap: 6px; justify-items: center; }
.td-canvas { width: 100%; max-width: 300px; aspect-ratio: 1; cursor: grab; touch-action: none; background: repeating-conic-gradient(#2a2a30 0 25%, #222227 0 50%) 0 0 / 20px 20px; border-radius: 12px; }
.td-canvas:active { cursor: grabbing; }
.td-minis { display: flex; gap: 10px; align-items: center; padding: 8px 12px; border-radius: 8px; background: #3a4a3a; background-image: linear-gradient(#0002 1px, transparent 1px), linear-gradient(90deg, #0002 1px, transparent 1px); background-size: 28px 28px; }
.td-controls { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px 12px; align-content: start; }
.td-controls > label { display: grid; gap: 3px; font-size: 12px; color: var(--muted); }
.td-controls .wide { grid-column: 1 / -1; }
.td-controls input[type=color] { width: 100%; height: 28px; padding: 0 2px; background: var(--panel-2); border: 1px solid var(--line-2); border-radius: 6px; cursor: pointer; }
.td-row { display: flex; gap: 8px; align-items: center; grid-column: 1 / -1; }
.td-row input[type=color] { flex: 1; }
.td-save { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; }
.td-save input { flex: 1; min-width: 140px; }
.td-lib h4 { margin: 4px 0 8px; }
.td-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.td-card { display: grid; justify-items: center; gap: 4px; padding: 8px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel-2); }
.td-card.on { border-color: var(--amber); }
.td-card img { width: 84px; height: 84px; cursor: pointer; }
.td-card-name { font-size: 13px; text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.td-card-acts { display: flex; flex-wrap: wrap; gap: 4px; justify-content: center; }
.td-pick { position: absolute; inset: auto 16px 16px auto; z-index: 3; display: grid; gap: 6px; padding: 12px; border-radius: 10px; background: var(--panel); border: 1px solid var(--amber); box-shadow: 0 8px 30px #0008; }
.td-window .win-body { position: relative; }


/* ---------- themes (themes.js): the artwork's animations, and a game's theme behind the map ---------- */
.theme-backdrop { position: absolute; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; background: var(--theme-bg, transparent); }
.theme-backdrop .theme-flank { position: absolute; top: 0; bottom: 0; width: 50%; opacity: 0.6; }
.theme-backdrop .theme-flank svg { width: 100%; height: 100%; display: block; }
.theme-backdrop .theme-flank.left { left: 0; -webkit-mask-image: linear-gradient(90deg, #000 45%, transparent); mask-image: linear-gradient(90deg, #000 45%, transparent); }
.theme-backdrop .theme-flank.right { right: 0; transform: scaleX(-1); -webkit-mask-image: linear-gradient(90deg, #000 45%, transparent); mask-image: linear-gradient(90deg, #000 45%, transparent); }
.theme-flank .tw { animation: th-twinkle 3.5s ease-in-out infinite; }
.theme-flank .flame { animation: th-flame 0.9s ease-in-out infinite alternate; transform-box: fill-box; transform-origin: 50% 100%; }
.theme-flank .flicker { animation: th-flicker 2.3s ease-in-out infinite; }
.theme-flank .sway { animation: th-sway 6s ease-in-out infinite; transform-box: fill-box; transform-origin: 50% 0; }
.theme-flank .sway-slow { animation: th-sway-slow 9s ease-in-out infinite; }
.theme-flank .blink { animation: th-blink 2.6s steps(1) infinite; }
.theme-flank .pulse { animation: th-pulse 4s ease-in-out infinite; }
.theme-flank .sigil { animation: th-pulse 5s ease-in-out infinite; }
.theme-flank .neon { animation: th-neon 7s linear infinite; }
.theme-flank .rain { animation: th-rain 1.1s linear infinite; }
.theme-flank .rain2 { animation-delay: -0.55s; opacity: 0.7; }
.theme-flank .shine { animation: th-shine 9s ease-in-out infinite; }
.theme-flank .drift { animation: th-drift 40s linear infinite; }
.theme-flank .drift-slow { animation: th-float 14s ease-in-out infinite; }
.theme-flank .cruise { animation: th-cruise 26s linear infinite; }
@keyframes th-twinkle { 50% { opacity: 0.15; } }
@keyframes th-flame { from { transform: scale(1, 1) skewX(-2deg); } to { transform: scale(0.92, 1.08) skewX(3deg); } }
@keyframes th-flicker { 0%, 100% { opacity: 0.9; } 30% { opacity: 0.7; } 55% { opacity: 1; } 75% { opacity: 0.75; } }
@keyframes th-sway { 50% { transform: skewX(3deg); } }
@keyframes th-sway-slow { 0%, 100% { transform: rotate(-2deg); } 50% { transform: rotate(2.5deg); } }
@keyframes th-blink { 0%, 100% { opacity: 1; } 50% { opacity: 0.15; } }
@keyframes th-pulse { 0%, 100% { opacity: 0.55; } 50% { opacity: 1; } }
@keyframes th-neon { 0%, 46%, 49%, 100% { opacity: 1; } 47%, 48.5% { opacity: 0.25; } }
@keyframes th-rain { from { transform: translate(0, -40px); } to { transform: translate(-10px, 40px); } }
@keyframes th-shine { 0% { transform: translateX(0); } 60%, 100% { transform: translateX(800px); } }
@keyframes th-drift { from { transform: translateX(0); } to { transform: translateX(-420px); } }
@keyframes th-float { 50% { transform: translateY(-14px); } }
@keyframes th-cruise { 0% { transform: translate(120px, 40px); } 100% { transform: translate(-460px, -160px); } }
@media (prefers-reduced-motion: reduce) { .theme-flank * { animation: none !important; } }
.theme-flank .sweep { animation: th-sweep 9s ease-in-out infinite; }
.theme-flank .sweep2 { animation-duration: 12s; animation-direction: reverse; }
.theme-flank .spin { animation: th-spin 6s linear infinite; }
.theme-flank .swing { animation: th-swing 3s ease-in-out infinite; }
.theme-flank .roll { animation: th-roll 14s linear infinite; transform-box: fill-box; transform-origin: center; }
.theme-flank .wave { animation: th-wave 5s ease-in-out infinite; }
.theme-flank .wave2 { animation-duration: 7s; animation-direction: reverse; }
.theme-flank .flap { animation: th-flap 0.35s ease-in-out infinite alternate, th-batfly 18s linear infinite; transform-box: fill-box; transform-origin: center; }
.theme-flank .fog { animation: th-fog 30s linear infinite; }
.theme-flank .dust { animation: th-dust 8s linear infinite; }
.theme-flank .steam { animation: th-pulse 6s ease-in-out infinite; }
@keyframes th-sweep { 0%, 100% { transform: rotate(-16deg); } 50% { transform: rotate(16deg); } }
@keyframes th-spin { to { transform: rotate(360deg); } }
@keyframes th-swing { 0%, 100% { transform: rotate(-6deg); } 50% { transform: rotate(6deg); } }
@keyframes th-roll { 0% { transform: translateX(-40px) rotate(0); } 100% { transform: translateX(480px) rotate(720deg); } }
@keyframes th-wave { 0%, 100% { transform: translateX(0); } 50% { transform: translateX(-30px); } }
@keyframes th-flap { to { transform: scaleY(0.4); } }
@keyframes th-batfly { 0% { translate: 0 0; } 50% { translate: -60px 30px; } 100% { translate: 0 0; } }
@keyframes th-fog { from { transform: translateX(0); } to { transform: translateX(420px); } }
@keyframes th-dust { from { transform: translate(0, 0); } to { transform: translate(-80px, -30px); } }
.theme-flank.right .unmirror { transform: scaleX(-1); transform-box: fill-box; transform-origin: center; }
.window.themed > .win-head, .window.themed > .win-body { position: relative; }
.window .theme-backdrop .theme-flank { opacity: 0.22; }
.dd-themes { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; margin-bottom: 8px; }
.dd-themes button { width: 32px; height: 32px; border-radius: 8px; border: 1px solid var(--line-2); background: var(--panel-2); cursor: pointer; font-size: 16px; padding: 0; }
.dd-themes button:hover { border-color: var(--amber); }

/* the character card designer (carddesigner.js) */
.cd { display: grid; grid-template-columns: minmax(240px, 340px) minmax(0, 1fr); gap: 16px; align-items: start; }
@media (max-width: 720px) { .cd { grid-template-columns: 1fr; } }
.cd-stage { display: grid; gap: 6px; justify-items: center; }
.cd-canvas { width: 100%; max-width: 340px; aspect-ratio: 600 / 840; cursor: grab; touch-action: none; border-radius: 14px; box-shadow: 0 10px 30px #0008; }
.cd-controls { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px 12px; align-content: start; }
.cd-controls > label { display: grid; gap: 3px; font-size: 12px; color: var(--muted); }
.cd-controls .wide { grid-column: 1 / -1; }
.cd-controls input[type=color] { width: 100%; height: 28px; padding: 0 2px; background: var(--panel-2); border: 1px solid var(--line-2); border-radius: 6px; cursor: pointer; }
.cd-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.cd-row input[type=range] { flex: 1; min-width: 100px; }
.cd-controls .cd-check { display: flex; gap: 8px; align-items: center; font-size: 13px; color: var(--text); }
.cd-acts { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; }
/* picture themes: each side is its own picture (not mirrored), faded towards the middle, drifting very slowly */
.theme-flank.photo img { width: 100%; height: 100%; object-fit: cover; display: block; animation: th-drift-photo 60s ease-in-out infinite alternate; }
.theme-flank.photo.left img { object-position: left bottom; transform-origin: left center; }
.theme-flank.photo.right img { object-position: right bottom; transform-origin: right center; }
.theme-flank.right.photo { transform: none !important; -webkit-mask-image: linear-gradient(270deg, #000 70%, transparent) !important; mask-image: linear-gradient(270deg, #000 70%, transparent) !important; }
.theme-backdrop .theme-flank.right.photo { -webkit-mask-image: linear-gradient(270deg, #000 45%, transparent) !important; mask-image: linear-gradient(270deg, #000 45%, transparent) !important; }
@keyframes th-drift-photo { from { transform: scale(1); } to { transform: scale(1.06); } }
@media (prefers-reduced-motion: reduce) { .theme-flank.photo img { animation: none; } }
