:root {
  --bg: #1a1714; --panel: #24201c; --panel-2: #2c2722; --ink: #ece4d8; --muted: #a39788; --line: #3a332c;
  /* the red of the Dungeons & Dragons logo; --accent-text is the same red lifted for text on dark backgrounds */
  --accent: #c41e1a; --accent-text: #e2453b; --accent-ink: #fff; --link: #d9ae5f; --bar: #121010;
  --gold: #7d6a45; --tan: #3a2f24; --row-odd: #2b2a28; --row-even: #232120;
  --spell: #b9a2f0; --feat: #5fc4a8; --item: #e0b062; --rule: #e2c07e; --skill: #7fd49a;
  --class: #8db0e6; --cond: #ee8f86; --creature: #ff8a7a;
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; color: var(--ink); background: var(--bg); font: 16px/1.6 Roboto, Helvetica, Arial, sans-serif; }
a { color: var(--link); }
h1, h2, h3 { font-family: Roboto, Helvetica, sans-serif; font-weight: 500; line-height: 1.2; margin: .2em 0 .5em; }
h1 { font-size: 1.7rem; } h2 { font-size: 1.2rem; } h3 { font-size: 1rem; }
main { max-width: 1200px; margin: 0 auto; padding: 20px 16px 60px; }
.muted { color: var(--muted); } .small { font-size: .85em; }

/* The shell holds the top bar; each tab's page is a frame filling the window below it (tabs.js). */
body.shell { overflow: hidden; height: 100vh; }
.frames { position: fixed; left: 0; right: 0; bottom: 0; top: var(--shell-top, 63px); }
.tab-frame { display: block; width: 100%; height: 100%; border: 0; background: var(--bg); }
.tab-frame[hidden] { display: none; }

/* top bar = tab bar: logo, Menu, page tabs, then search + account on the right */
.topbar { display: flex; align-items: center; gap: 12px; padding: 0 16px; min-height: 60px; background: var(--bar); border-bottom: 3px solid var(--accent);
  position: sticky; top: 0; z-index: 20; }
.brand { display: flex; align-items: center; line-height: 0; flex-shrink: 0; }
.brand img { height: 48px; width: auto; }
.bar-btn { display: flex; align-items: center; gap: 7px; padding: 6px 11px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel-2);
  color: #e6e6e6; cursor: pointer; font: 500 .8rem "Roboto Condensed", Roboto, sans-serif; text-transform: uppercase; letter-spacing: .04em; }
.bar-btn:hover, .bar-btn[aria-expanded="true"] { color: #fff; border-color: var(--accent); }
.mainmenu { position: relative; flex-shrink: 0; }
.bar-menu { position: absolute; top: calc(100% + 10px); min-width: 230px; z-index: 70; background: var(--panel); border: 1px solid var(--line);
  border-radius: 8px; box-shadow: 0 10px 30px rgba(0,0,0,.5); padding: 6px; font: 400 .9rem Roboto, Helvetica, sans-serif; text-transform: none; }
.mainmenu-list { left: 0; }
.bar-item { display: block; width: 100%; box-sizing: border-box; text-align: left; padding: 8px 10px; border: 0; border-radius: 5px; background: none;
  color: var(--ink); font: inherit; cursor: pointer; text-decoration: none; }
.bar-item:hover, .bar-item:focus-visible { background: var(--panel-2); outline: none; }
.bar-item.danger { color: var(--accent-text); }

/* page tabs: sit on the accent line, scroll sideways once search + account are down to 200px */
.char-tabs { flex: 0 1 auto; min-width: 0; margin-left: 14px; align-self: flex-end; display: flex; align-items: flex-end; gap: 4px; padding-top: 8px;
  overflow-x: auto; overflow-y: hidden; scrollbar-width: none; }
.char-tabs::-webkit-scrollbar { display: none; }
.char-tab { display: flex; align-items: center; flex-shrink: 0; max-width: 220px; min-width: 0; border: 1px solid var(--line); border-bottom: 0;
  border-radius: 8px 8px 0 0; background: var(--panel); margin-bottom: 3px; }
.char-tab a { flex: 1; min-width: 0; padding: 7px 4px 7px 14px; color: var(--muted); text-decoration: none; font: 500 .85rem Roboto, Helvetica, sans-serif;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.char-tab-kind { margin-right: 2px; }
.char-tab:hover a { color: var(--ink); }
.char-tab.active { background: var(--accent); border-color: var(--accent); margin-bottom: 0; padding-bottom: 3px; }
.char-tab.active a { color: #fff; }
.char-tab-x { border: 0; background: none; opacity: .55; cursor: pointer; font-size: 1.05rem; line-height: 1; padding: 4px 9px 4px 4px; color: var(--muted); }
.char-tab.active .char-tab-x { color: #fff; }
.char-tab-x:hover { opacity: 1; }
.char-tab-new { flex-shrink: 0; border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 1rem; padding: 4px 8px; margin-bottom: 7px; }
.char-tab-new:hover { color: var(--ink); }

/* right side: takes whatever the tabs leave, from 200px up to 560px */
.topbar-right { flex: 1 1 0; min-width: 200px; max-width: 560px; margin-left: auto; display: flex; align-items: center; gap: 8px; }
.search { flex: 1; min-width: 0; }
.search input { width: 100%; box-sizing: border-box; }
.topbar .search input { background: var(--panel-2); border-color: var(--line); color: var(--ink); }

input, select, textarea { font: inherit; font-family: Roboto, Helvetica, sans-serif; font-size: .95rem; padding: 7px 9px; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); color: var(--ink); }
textarea { width: 100%; resize: vertical; }
.btn { font: 600 .9rem/1.25 Roboto, Helvetica, sans-serif; padding: 7px 14px; border-radius: 6px; border: 1px solid var(--line); background: var(--panel); color: var(--ink); cursor: pointer; text-decoration: none; display: inline-block; }  /* same height for <a> and <button> */
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.danger { color: var(--accent-text); }
.btn:disabled { opacity: .5; }
.btn.small { padding: 4px 10px; font-size: .8rem; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 16px 18px; margin-bottom: 16px; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.grid { display: grid; gap: 16px; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.grid.three { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.hero { margin: 10px 0 24px; } .hero p { font-size: 1.1rem; }
.callout { background: var(--panel); border-left: 4px solid var(--accent); padding: 10px 14px; }
.row-link { display: block; padding: 8px 0; border-bottom: 1px solid var(--line); text-decoration: none; color: var(--ink); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-block; font: .85rem Roboto, Helvetica, sans-serif; padding: 3px 10px; border-radius: 999px; border: 1px solid var(--line); text-decoration: none; color: var(--ink); background: var(--bg); }
.chip.small { font-size: .72rem; padding: 1px 8px; }
.chip b { color: var(--muted); font-weight: 500; }

.results { list-style: none; padding: 0; } .results li { padding: 10px 0; border-bottom: 1px solid var(--line); }
.clamp { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; font-size: .9rem; }
.filter { width: 100%; max-width: 400px; margin-bottom: 8px; }

.crumbs { font: .85rem Roboto, Helvetica, sans-serif; color: var(--muted); margin-bottom: 8px; }
.node-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 16px; align-items: start; }
@media (max-width: 900px) { .node-layout, .char-layout { grid-template-columns: 1fr !important; } }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 2px 14px; font-size: .92rem; background: var(--bg); padding: 8px 12px; border-radius: 6px; }
.facts dt { font-weight: 700; font-family: Roboto, Helvetica, sans-serif; } .facts dd { margin: 0; }
.rules-text table { border-collapse: collapse; width: 100%; font-size: .9rem; margin: 10px 0; display: block; overflow-x: auto; }
.rules-text th, .rules-text td, table.plain th, table.plain td { border-bottom: 1px solid var(--line); padding: 4px 8px; text-align: left; vertical-align: top; }
.rules-text h1, .rules-text h2, .rules-text h3, .rules-text h4, .rules-text h5 { font-size: 1rem; }
table.plain { border-collapse: collapse; width: 100%; font-size: .9rem; }
.relations .card { padding: 10px 14px; } .relations ul { margin: 0; padding-left: 18px; max-height: 260px; overflow: auto; font-size: .92rem; }

/* Link colours by entity type, everywhere links into the graph appear (D&D Beyond conventions). */
a.kg-link { text-decoration: none; font-weight: 700; }
a.kg-link:hover { text-decoration: underline; }
.kg-spell, .t-spell { color: var(--spell) !important; }
.kg-feat, .t-feat { color: var(--feat) !important; }
.kg-weapon, .kg-armor, .kg-gear, .kg-tool, .kg-equipment, .kg-magic_item, .t-weapon, .t-armor, .t-gear, .t-tool, .t-magic_item { color: var(--item) !important; }
.kg-rule, .kg-action, .kg-condition, .kg-hazard, .kg-area_of_effect, .t-rule, .t-action, .t-condition { color: var(--rule) !important; }
.kg-skill, .kg-sense, .t-skill, .t-sense { color: var(--skill) !important; }
.kg-creature, .t-creature { color: var(--creature) !important; }
a.kg-section, a.kg-chapter, a.kg-table, a.kg-sidebar, a.kg-class, a.kg-subclass, a.kg-class_feature, a.kg-subclass_feature,
a.kg-species, a.kg-lineage, a.kg-background, a.kg-weapon_property, a.kg-weapon_mastery { color: var(--link) !important; font-weight: 500; }
.chip.t-section, .chip.t-chapter, .chip.t-class, .chip.t-subclass { color: var(--link) !important; }

.form label { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; font: .85rem Roboto, Helvetica, sans-serif; color: var(--muted); }
.form input, .form select { width: 100%; }
.inline { display: flex; gap: 8px; flex-wrap: wrap; } .inline input { flex: 1; min-width: 160px; }
.abilities { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; margin-bottom: 10px; }
@media (max-width: 600px) { .abilities { grid-template-columns: repeat(3, 1fr); } }
.abilities label { align-items: center; font-weight: 700; color: var(--ink); }
.abilities input { text-align: center; } .mod { font-size: .9rem; color: var(--muted); }
.links { list-style: none; padding: 0; } .links li { padding: 4px 0; }
.x { border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 1rem; }
.log { border-top: 1px solid var(--line); padding-top: 8px; margin-top: 8px; } .log p { white-space: pre-wrap; margin: 4px 0; }

.char-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.chat { position: sticky; top: 12px; display: flex; flex-direction: column; height: calc(100vh - 100px); min-height: 420px; }
.chat.wide { position: static; height: 70vh; }
.messages { flex: 1; overflow-y: auto; padding: 6px 0; }
.msg { padding: 10px 12px; border-radius: 8px; margin: 8px 0; max-width: 92%; }
.msg.user { background: var(--bg); margin-left: auto; font-family: Roboto, Helvetica, sans-serif; font-size: .95rem; }
.msg.assistant { border: 1px solid var(--line); } .msg.pending { color: var(--muted); font-style: italic; }
.msg.error { border: 1px solid var(--accent); color: var(--accent-text); }
.msg p:first-child { margin-top: 0; } .msg p:last-child { margin-bottom: 0; }
.ask { display: flex; gap: 8px; align-items: flex-end; border-top: 1px solid var(--line); padding-top: 10px; }

pre.code { background: var(--bg); padding: 12px; border-radius: 6px; overflow-x: auto; font-size: .8rem; }
.graph { width: 100%; height: 70vh; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; }
.graph .edge { stroke: var(--line); stroke-width: 1.2; }
.graph .edge.rel-has_feature, .graph .edge.rel-subclass_of { stroke: var(--class); stroke-opacity: .5; }
.graph .gnode { cursor: pointer; fill: var(--rule); font: 11px Roboto, Helvetica, sans-serif; }
.graph .gnode text { fill: var(--ink); }
.graph .gnode.t-spell { fill: var(--spell); } .graph .gnode.t-feat { fill: var(--feat); }
.graph .gnode.t-condition { fill: var(--cond); } .graph .gnode.t-class, .graph .gnode.t-subclass, .graph .gnode.t-class_feature { fill: var(--class); }
.graph .gnode.t-weapon, .graph .gnode.t-armor, .graph .gnode.t-gear { fill: var(--item); }
.graph .gnode.centre text { font-weight: 700; }

/* ---------------- Character sheet: a faithful copy of the official 2024 sheet ---------------- */
main:has(.sheet-wrap) { max-width: 2200px; }
.sheet-top { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.tabs { display: flex; gap: 4px; }
.tab { font: 600 .9rem "Roboto Condensed", Roboto, sans-serif; text-transform: uppercase; letter-spacing: .04em; padding: 8px 16px; border: 1px solid var(--line); border-radius: 8px 8px 0 0; background: var(--bg); color: var(--muted); cursor: pointer; }
.tab.active { background: var(--panel); color: var(--ink); border-bottom-color: var(--panel); }
.tab-add { border-style: dashed; }
.tab-add:hover { color: var(--ink); border-color: var(--accent); }
.sheet-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.badge { display: inline-block; min-width: 18px; padding: 0 5px; border-radius: 9px; background: var(--accent); color: #fff; font-size: .72rem; line-height: 18px; }
.badge:empty { display: none; }
#history-count { background: var(--line); color: var(--ink); }  /* a count, not an alert */
.sheet-wrap { display: block; }
/* Character page fills the window: the tabs, buttons and HP bar stay put and only the area under them
   scrolls (the sheet, or the Notes / Picture pane). */
@media screen {
  body.char-page { height: 100vh; overflow: hidden; }
  body.char-page main { height: 100vh; box-sizing: border-box; display: flex; flex-direction: column; padding-bottom: 12px; }
  body.char-page .sheet-top { flex: none; }
  body.char-page .sheet-wrap { flex: 1; min-height: 0; display: flex; }
  body.char-page .sheet-col { flex: 1; min-width: 0; min-height: 0; display: flex; flex-direction: column; }
  body.char-page .sheet-col > * { flex: none; }
  body.char-page .sheet-col > .cs-fit, body.char-page .sheet-col > #pnotes, body.char-page .sheet-col > #ppic { flex: 1 1 auto; min-height: 0; overflow: auto; }
  body.char-page .cs-fit:not(:has(.page:not([hidden]))) { display: none; }   /* Notes / Picture showing */
}
/* Character page: the active sheet tab and everything under it form one panel, black like the dark
   sheet (white with the light sheet); the tab bar and the other tabs keep their colours. */
.sheet-top { align-items: flex-end; margin-bottom: 0; }
.sheet-top .sheet-actions { margin-bottom: 6px; }
.sheet-top .tab.active { position: relative; z-index: 1; margin-bottom: -1px; background: #000; color: #fff; border-color: var(--line); border-bottom-color: #000; }
.sheet-wrap { background: #000; border: 1px solid var(--line); border-radius: 0 8px 8px 8px; padding: 12px; }
body.embedded:not(.sheet-dark) .sheet-top .tab.active { background: #fff; color: #231f20; border-bottom-color: #fff; }
body.embedded:not(.sheet-dark) .sheet-wrap { background: #fff; }
.sheet-wrap .paper-tools { background: #000; }                          /* the HP bar matches its panel */
body.embedded:not(.sheet-dark) .sheet-wrap .paper-tools { background: #fff; color: #231f20; }
body.embedded:not(.sheet-dark) .paper-tools .btn:not(.primary),
body.embedded:not(.sheet-dark) .paper-tools input:not([type=range]) { background: #fff; color: #111; border-color: #111; }
body.embedded:not(.sheet-dark) .paper-tools .btn:not(.primary):hover { background: #f1f1f1; }
body.embedded:not(.sheet-dark) .paper-tools input::placeholder { color: #777; }
.sheet-col { min-width: 0; }
.cs-fit { width: 100%; overflow-x: auto; overflow-y: hidden; touch-action: pan-x pan-y; }  /* pinch = sheet zoom (sheet.js) */
.cs-fit { cursor: grab; }                                    /* drag empty areas to scroll (sheet.js) */
.cs-fit.panning, .cs-fit.panning * { cursor: grabbing !important; user-select: none; }
.cs-fit input, .cs-fit textarea, .cs-fit select, .cs-fit [contenteditable] { cursor: text; }
.cs-fit button, .cs-fit a, .cs-fit label, .cs-fit .pmark, .cs-fit .padd { cursor: pointer; }

.cs {
  --ink: #231f20; --rule: #231f20; --grid: #e6e6e6;
  width: 1040px; color: var(--ink);
  font: 13px/1.3 "Gill Sans", "Gill Sans MT", Seravek, "Roboto Condensed", Roboto, sans-serif;
}
.cs-page { background: #fff; padding: 22px 24px 26px; box-shadow: 0 2px 12px rgba(0,0,0,.18); border-radius: 3px; }
.cs h4 { font: 600 12.5px/1.1 "Gill Sans", "Gill Sans MT", Seravek, "Roboto Condensed", sans-serif; text-transform: uppercase; letter-spacing: .07em; text-align: center; margin: 0 0 6px; color: var(--ink); }
.cs .lbl { font: 600 9px/1.1 "Gill Sans", "Gill Sans MT", Seravek, sans-serif; text-transform: uppercase; letter-spacing: .08em; color: var(--ink); }
.cs input, .cs select, .cs textarea { font: inherit; color: var(--ink); background: transparent; border: 0; border-radius: 0; padding: 1px 2px; width: 100%; }
.cs input:focus, .cs select:focus, .cs textarea:focus { outline: 2px solid rgba(197, 49, 49, .35); outline-offset: 1px; background: #fffdf5; }
.cs input[type=number] { -moz-appearance: textfield; } .cs input::-webkit-inner-spin-button { -webkit-appearance: none; }
.cs a.kg-link { color: var(--ink) !important; font-weight: 600; border-bottom: 1px dotted #999; }
.cs a.kg-link:hover { color: var(--accent) !important; text-decoration: none; }
.cs .x { color: #999; padding: 0 2px; }
.cs .btn.small { padding: 2px 8px; font-size: 11px; }

/* the heavy double-edged box with a clipped top-left corner */
.bx { position: relative; background: #fff; border: 2.5px solid var(--rule); border-radius: 10px; padding: 8px 12px 10px;
  box-shadow: 2px 2px 0 0 #fff, 4.5px 4.5px 0 0 var(--rule); margin: 0 5px 14px 0; }
.bx::before { content: ""; position: absolute; top: -3px; left: -3px; width: 20px; height: 20px; border-top-left-radius: 9px;
  background: linear-gradient(135deg, #fff 0 calc(50% - 1.6px), var(--rule) calc(50% - 1.6px) calc(50% + 1.2px), transparent calc(50% + 1.2px)); }
.bx > h4 { border-bottom: 1.5px solid var(--rule); padding-bottom: 5px; margin: 0 -2px 6px; }
.grid-paper { background-image: linear-gradient(var(--grid) 1px, transparent 1px), linear-gradient(90deg, var(--grid) 1px, transparent 1px); background-size: 11px 11px; background-position: -1px -1px; }
.grid-paper > h4 { background: #fff; margin: -8px -12px 6px; padding: 8px 12px 5px; border-radius: 8px 8px 0 0; }

/* four-point diamond checkbox, as printed on the sheet */
.dia { display: inline-block; width: 15px; height: 15px; vertical-align: -3px; cursor: pointer; flex: none;
  background: center / contain no-repeat url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 20'%3E%3Cpath d='M0 10h5' stroke='%23231f20' stroke-width='1.6'/%3E%3Cpath d='M14 1.5l2.6 6 6 2.5-6 2.5-2.6 6-2.6-6-6-2.5 6-2.5z' fill='white' stroke='%23231f20' stroke-width='1.7' stroke-linejoin='round'/%3E%3C/svg%3E"); }
.dia.on { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 20'%3E%3Cpath d='M0 10h5' stroke='%23231f20' stroke-width='1.6'/%3E%3Cpath d='M14 1.5l2.6 6 6 2.5-6 2.5-2.6 6-2.6-6-6-2.5 6-2.5z' fill='%23231f20' stroke='%23231f20' stroke-width='1.7' stroke-linejoin='round'/%3E%3C/svg%3E"); }
.dias .fail .dia.on, .dias.fail .dia.on { filter: invert(18%) sepia(85%) saturate(3000%) hue-rotate(350deg); }
.dia.off { opacity: .22; cursor: default; }
.dia.sm { width: 12px; height: 12px; }
.dias { display: inline-flex; gap: 1px; }
.dia-label { display: inline-flex; align-items: center; gap: 3px; margin-right: 10px; cursor: pointer; font-size: 12px; }

/* ---- page 1 header ---- */
.cs-header { display: grid; grid-template-columns: 440px 118px 1fr; gap: 0 14px; align-items: start; }
.cs-identity { padding: 10px 70px 6px 16px; margin-right: 52px; min-height: 128px; }
.fld { display: flex; flex-direction: column-reverse; margin-bottom: 7px; }
.fld > span { font: 600 9px "Gill Sans", "Gill Sans MT", Seravek, sans-serif; text-transform: uppercase; letter-spacing: .08em; padding-top: 1px; }
.fld input, .fld select { border-bottom: 1px solid #9a9a9a; font-size: 14px; padding: 2px 2px 1px; -webkit-appearance: none; appearance: none; }
.fld-name input { font-size: 17px; font-weight: 600; }
.cs-identity .two { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.cs-level { position: absolute; right: -60px; top: 4px; width: 106px; height: 124px; border: 3px solid var(--rule); border-radius: 50%; background: #fff;
  display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 6px 14px; box-shadow: 0 0 0 3px #fff, 0 0 0 4.5px var(--rule); }
.cs-level input { text-align: center; border-bottom: 1px solid #9a9a9a; font-size: 20px; font-weight: 700; width: 64px; }
.cs-level input[data-state] { font-size: 13px; font-weight: 400; }
.cs-level .lbl { margin: 1px 0 5px; }
.cs-ac { position: relative; width: 108px; height: 132px; margin-top: 0; border: 3px solid var(--rule); background: #fff;
  border-radius: 12px 12px 54px 54px / 12px 12px 78px 78px; box-shadow: 0 0 0 2px #fff, 0 0 0 3.5px var(--rule);
  display: flex; flex-direction: column; align-items: center; padding-top: 10px; cursor: help; }
.cs-ac .lbl-t { font: 600 11px/1.05 "Gill Sans", "Gill Sans MT", Seravek, sans-serif; text-transform: uppercase; letter-spacing: .07em; text-align: center; }
.cs-ac .val { font: 700 36px/1 Roboto, sans-serif; margin: 6px 0 4px; }
.cs-ac .lbl { font-size: 8px; } .cs-ac .dia { margin-top: 2px; cursor: default; }
.cs-vitals { display: grid; grid-template-columns: 1.6fr .8fr .8fr; padding: 8px 10px 8px; min-height: 128px; margin-right: 6px; }
.cs-vitals > div { padding: 0 8px; } .cs-vitals > div + div { border-left: 1.5px solid var(--rule); }
.cs-vitals h4 { margin-bottom: 4px; }
.hp-cells { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.hp-cells label { display: flex; flex-direction: column-reverse; font: 600 8.5px Gill Sans, Seravek, sans-serif; text-transform: uppercase; letter-spacing: .08em; }
.hp-cells input { border-bottom: 1px solid #9a9a9a; text-align: center; font: 600 15px Roboto, sans-serif; }
.hp-current input { font-size: 30px !important; height: 52px; border: 1.5px solid var(--rule) !important; border-radius: 6px; }
.hp-side { display: flex; flex-direction: column; gap: 4px; }
.hp-adjust { display: flex; gap: 3px; margin-top: 5px; } .hp-adjust input { width: 46px; border-bottom: 1px solid #9a9a9a; text-align: center; }
.v-hd label { display: flex; flex-direction: column-reverse; align-items: center; font: 600 8.5px Gill Sans, Seravek, sans-serif; text-transform: uppercase; letter-spacing: .08em; margin-bottom: 6px; }
.v-hd b { font: 700 18px Roboto, sans-serif; border-bottom: 1px solid #9a9a9a; min-width: 54px; text-align: center; }
.stepper { display: flex; align-items: center; gap: 4px; } .stepper b { min-width: 30px; }
.step { border: 1px solid #bbb; background: #fff; border-radius: 3px; width: 18px; height: 18px; line-height: 14px; padding: 0; cursor: pointer; font-size: 12px; }
.v-ds { text-align: center; } .ds-row { display: flex; flex-direction: column; align-items: center; margin: 4px 0 6px; }
.ds-row > span:last-child { font: 600 8.5px Gill Sans, Seravek, sans-serif; text-transform: uppercase; letter-spacing: .08em; }
.v-ds .dia { width: 18px; height: 16px; }

.cs-banner { display: flex; align-items: center; gap: 14px; margin: 4px 0 12px; }
.cs-banner::before, .cs-banner::after { content: ""; flex: 1; border-top: 3px double var(--rule); }
.cs-banner span { font: 700 21px/1 "Iowan Old Style", Georgia, "Times New Roman", serif; font-variant: small-caps; letter-spacing: .06em; }
.cs-banner em { font-style: normal; color: var(--accent); font-size: 1.15em; }

/* ---- page 1 body ---- */
.cs-body { display: grid; grid-template-columns: 404px 1fr; gap: 14px; align-items: start; }
.cs-left { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; align-items: start; }
.cs-stack > div { margin-bottom: 12px; }
.cs-training { grid-column: 1 / -1; }
.cs-pb { text-align: center; padding-bottom: 12px; }
.pillar { width: 92px; height: 60px; margin: 2px auto 0; border: 2.5px solid var(--rule); border-top: 0; border-radius: 0 0 14px 14px;
  display: flex; align-items: center; justify-content: center; position: relative; }
.pillar::before, .pillar::after { content: ""; position: absolute; top: 0; bottom: 8px; width: 6px; border: 1.5px solid var(--rule); border-top: 0; }
.pillar::before { left: 8px; border-radius: 0 0 0 6px; } .pillar::after { right: 8px; border-radius: 0 0 6px 0; }
.pillar b { font: 700 26px Roboto, sans-serif; }

.ab { position: relative; background: #fff; border: 2.5px solid var(--rule); border-radius: 22px 22px 8px 8px / 14px 14px 8px 8px; padding: 6px 8px 6px; margin-right: 4px; }
.ab::before { content: ""; position: absolute; inset: 3px 3px auto 3px; height: 26px; border: 1.2px solid var(--rule); border-bottom: 0; border-radius: 18px 18px 0 0 / 11px 11px 0 0; pointer-events: none; }
.ab h4 { margin: 2px 0 4px; }
.ab-nums { position: relative; height: 78px; margin-bottom: 4px; }
.ab-mod { position: absolute; left: 18px; top: 2px; width: 66px; height: 66px; border: 3.5px solid var(--rule); border-radius: 50%; background: #fff; z-index: 1;
  display: flex; align-items: center; justify-content: center; }
.ab-mod b { font: 700 26px Roboto, sans-serif; }
.ab-score { position: absolute; left: 70px; top: 14px; width: 92px; height: 38px; border: 2px solid var(--rule); border-left: 0; border-radius: 0 6px 6px 0;
  transform: skewY(-4deg); display: flex; align-items: center; justify-content: flex-end; padding-right: 6px; background: #fff; }
.ab-score input { width: 44px; text-align: center; font: 600 17px Roboto, sans-serif; transform: skewY(4deg); }
.ab .l-mod { position: absolute; left: 22px; bottom: 0; } .ab .l-score { position: absolute; left: 112px; top: 56px; }
.ab-row { display: flex; align-items: center; gap: 5px; padding: 2.5px 0; font-size: 12.5px; }
.ab-row u { text-decoration: none; display: inline-block; width: 28px; text-align: center; border-bottom: 1px solid #9a9a9a; font-size: 12px; font-weight: 600; }
.ab-save { border-top: 1.5px solid var(--rule); border-bottom: 1.5px solid var(--rule); margin: 0 -8px; padding: 4px 8px; }
.ab-save b { font-weight: 700; }
.ab-skills { padding-top: 3px; }
.ab-row.option span { text-decoration: underline dotted #b9b2a6; }
.cs .dot { width: 13px; height: 13px; border: 2px solid var(--rule); border-radius: 50%; background: #fff; cursor: pointer; padding: 0; flex: none; }
.cs .dot.p1 { background: var(--rule); }
.cs .dot.p2 { background: var(--rule); box-shadow: 0 0 0 2px #fff, 0 0 0 3.5px var(--rule); }

.cs-insp { text-align: center; padding-bottom: 12px; }
.insp { width: 46px; height: 46px; border: 2.5px solid var(--rule); border-radius: 50%; background: #fff; cursor: pointer; position: relative; }
.insp::after { content: ""; position: absolute; inset: 11px; border: 2px solid var(--rule); transform: rotate(45deg); }
.insp.on::after { background: var(--accent); border-color: var(--accent); }

.armor-row { display: flex; align-items: center; gap: 8px; border-bottom: 1.5px solid var(--rule); padding-bottom: 5px; margin-bottom: 4px; }
.armor-row .lbl { flex: none; }
.cs-training > .lbl { display: block; margin-top: 4px; }
.paper-lines { min-height: 38px; font-size: 12.5px; line-height: 19px; padding: 0 2px;
  background: repeating-linear-gradient(transparent 0 18px, #bdbdbd 18px 19px); }
.line-input { border-bottom: 1px solid #bdbdbd !important; font-size: 12px; margin-bottom: 4px; }

.cs-right { min-width: 0; }
.cs-tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 14px; }
.tile { position: relative; border: 2.5px solid var(--rule); border-radius: 8px; text-align: center; padding: 6px 4px 8px; min-height: 76px; background: #fff;
  box-shadow: 2px 2px 0 0 #fff, 4px 4px 0 0 var(--rule); }
.tile h4 { margin: 0 -4px 4px; padding: 0 4px 4px; border-bottom: 1.5px solid var(--rule); font-size: 11.5px; }
.tile b { font: 700 24px Roboto, sans-serif; display: block; }
.tile b#speed, .tile b#size { font-size: 18px; padding-top: 4px; }

table.ruled { width: 100%; border-collapse: collapse; font-size: 12.5px; }
table.ruled th { font: 600 9px "Gill Sans", "Gill Sans MT", Seravek, sans-serif; text-transform: uppercase; letter-spacing: .06em; text-align: left; color: #555; padding: 2px 4px; border-bottom: 1px solid #9a9a9a; }
table.ruled td { border-bottom: 1px solid #c4c4c4; padding: 3px 4px; height: 25px; vertical-align: middle; }
table.ruled td + td, table.ruled th + th { border-left: 1px solid #d6d6d6; }
table.ruled td.notes { font-size: 11px; color: #444; }
.add-row { font-size: 11px; color: #777; margin-top: 4px; } .add-row summary { cursor: pointer; }
.add-row .inline input { border-bottom: 1px solid #bbb; }

.cs-features { min-height: 300px; }
.feat-cols { columns: 2; column-gap: 30px; column-rule: 1.5px solid var(--rule); list-style: none; margin: 0; padding: 0; min-height: 240px; }
.feat-cols li, .feat-list li { break-inside: avoid; padding: 2px 0; font-size: 12.5px; }
.feat-list { list-style: none; margin: 0; padding: 0; min-height: 140px; }
.cs .src { color: #666; font-size: 10.5px; }
.paper-note { resize: vertical; font-size: 12.5px; line-height: 1.4; background: transparent !important; }
.cs-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; }
.cs .picker { margin-top: 6px; } .cs .picker input { border-bottom: 1px solid #bbb; font-size: 12px; }
.cs .picker .inline { gap: 4px; flex-wrap: nowrap; }

/* ---- page 2 ---- */
.cs-p2 { display: grid; grid-template-columns: 640px 1fr; gap: 16px; align-items: start; }
.p2-top { display: grid; grid-template-columns: 220px 1fr; gap: 12px; align-items: end; }
.cs-casting { padding: 0; overflow: hidden; }
.cs-casting::before { display: none; }
.cast-ability { padding: 10px 12px 6px; border-bottom: 1.5px solid var(--rule); display: flex; flex-direction: column-reverse; }
.cast-ability > span:first-child { border-bottom: 1px solid #9a9a9a; min-height: 20px; font-size: 14px; }
.cast-row { display: grid; grid-template-columns: 54px 1fr; align-items: center; min-height: 44px; }
.cast-row + .cast-row { border-top: 1.5px solid var(--rule); }
.cast-row b { font: 700 20px Roboto, sans-serif; text-align: center; border-right: 1.5px solid var(--rule); height: 100%; display: flex; align-items: center; justify-content: center; }
.cast-row span { font: 600 11.5px/1.1 "Gill Sans", "Gill Sans MT", Seravek, sans-serif; text-transform: uppercase; letter-spacing: .06em; padding-left: 10px; }
.cs-art { height: 52px; margin: 0 6px 8px; border-radius: 6px; display: flex; align-items: center; justify-content: center;
  border: 1.5px solid #ddd; background: repeating-linear-gradient(135deg, #faf7f2 0 8px, #f2ede4 8px 16px); }
.cs-art span { font: 700 28px Georgia, serif; color: var(--accent); text-shadow: 0 0 6px #fff, 0 0 2px #fff; }
.slot-grid { display: grid; grid-template-rows: repeat(3, auto); grid-auto-flow: column; gap: 4px 14px; }
.slot { display: grid; grid-template-columns: 50px 30px auto; align-items: center; gap: 4px; font-size: 11.5px; }
.slot-l { font-variant: small-caps; font-weight: 600; letter-spacing: .03em; }
.slot-total { border-bottom: 1px solid #9a9a9a !important; text-align: center; font-weight: 600; }
.cs-spells { padding-bottom: 12px; }
.cs-spells h4 small { font-size: 10px; color: #777; letter-spacing: .02em; text-transform: none; font-weight: 400; }
.spells-table td { height: 26px; } .spells-table td:first-child { text-align: center; width: 40px; }
.spells-table td.crm { font-size: 10.5px; color: #444; width: 130px; }
.crm-tag { display: inline-flex; align-items: center; gap: 2px; margin-right: 4px; white-space: nowrap; }
.spells-table .cell { font-size: 12px; }
.cs-equipment { min-height: 300px; }
table.equip { width: 100%; border-collapse: collapse; font-size: 12.5px; }
table.equip td { padding: 2px 2px; border-bottom: 1px solid #e0e0e0; background: rgba(255,255,255,.8); }
table.equip .qty { width: 40px; text-align: center; border-bottom: 1px solid #bbb; }
table.equip .toggles { white-space: nowrap; font-size: 11px; }
.attune-title { display: block; margin-top: 10px; }
.attune-line { display: flex; align-items: center; gap: 6px; border-bottom: 1px solid #9a9a9a; padding: 3px 0; min-height: 26px; background: rgba(255,255,255,.85); }
.attune-line .dia { cursor: default; }
.coins { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.coin { display: flex; flex-direction: column; align-items: center; border: 2px solid var(--rule); border-radius: 6px 6px 50% 50% / 6px 6px 22px 22px; padding: 3px 2px 10px; }
.coin span { font: 600 10px Gill Sans, Seravek, sans-serif; letter-spacing: .08em; color: #555; }
.coin input { text-align: center; font: 600 15px Roboto, sans-serif; }
.cs-backstory .fld { margin-top: 6px; background: rgba(255,255,255,.85); }
.notes-page .two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.notes-page .form input, .notes-page .form textarea { border: 1px solid #ccc; border-radius: 4px; padding: 6px; margin-bottom: 6px; }

.callout.warn { border-left-color: #c58a1b; margin-bottom: 10px; font: .9rem Roboto, sans-serif; }
.callout.warn ul { margin: 4px 0 0; padding-left: 18px; }

/* ---- change history ---- */
.history-drawer { position: fixed; right: 0; top: var(--topbar-h, 60px); bottom: 0; width: 400px; max-width: 92vw; z-index: 40; background: var(--panel);
  border-left: 3px solid var(--accent); box-shadow: -8px 0 24px rgba(0,0,0,.18); padding: 14px 16px; overflow-y: auto; font: 14px Roboto, sans-serif; }
/* Open history takes its own column: the page narrows to its left (and the sheet refits), never under it. */
body.embedded { transition: padding-right .2s; }
@media screen and (min-width: 701px) {
  body.history-open { padding-right: min(400px, 92vw); }
  body.history-open .history-drawer { max-width: 400px; }
}
/* the title bar and close button stay at the top while the history scrolls under them */
.history-head { position: sticky; top: -14px; z-index: 2; display: flex; justify-content: space-between; align-items: center;
  margin: -14px -16px 8px; padding: 12px 16px; background: var(--panel); border-bottom: 1px solid var(--line); }
.history-head h3 { margin: 0; }
.history-head .x { font-size: 1.4rem; line-height: 1; padding: 2px 8px; border-radius: 6px; }
.history-head .x:hover { background: var(--panel-2); }
.history-list { list-style: none; padding: 0; margin: 10px 0 0; }
.history-list > li { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; margin-bottom: 8px; cursor: pointer; }
.history-list > li:hover { background: var(--panel-2); }
.history-list > li.selected { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(196,30,26,.35); background: #3a1d1b; }
.history-list > li ul { margin: 4px 0 0; padding-left: 18px; font-size: 13px; }
.h-meta { font-size: 12px; color: var(--muted); }
.h-kind { display: inline-block; font-size: 10px; text-transform: uppercase; letter-spacing: .05em; padding: 1px 6px; border-radius: 8px; background: var(--panel-2); color: var(--muted); margin-right: 4px; }
.h-kind.k-restore { background: #22344a; color: #9cc3f0; } .h-kind.k-advisor { background: #3a2a44; color: #d3b4f0; } .h-kind.k-rest { background: #1f3a2a; color: #8fd6a8; }
.history-list > li.current .h-kind { background: var(--accent); color: #fff; }
.preview-bar { position: sticky; top: calc(var(--topbar-h, 60px) + 6px); z-index: 30; display: flex; justify-content: space-between; gap: 12px; align-items: flex-start;
  background: #3a3020; border: 2px solid #e2b13c; border-radius: 8px; padding: 10px 14px; margin-bottom: 10px; font: 14px Roboto, sans-serif; box-shadow: 0 4px 14px rgba(0,0,0,.4); }
.preview-bar ul { margin: 4px 0 0; padding-left: 18px; font-size: 13px; }
.preview-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
body.previewing .cs { filter: sepia(.25); }
body.previewing .cs input, body.previewing .cs select, body.previewing .cs textarea, body.previewing .cs button,
body.previewing .cs .dia, body.previewing .cs .dot, body.previewing .cs label { pointer-events: none; }
body.previewing .cs .picker, body.previewing .cs .add-row, body.previewing .cs .hp-adjust, body.previewing .cs .x { display: none; }

/* ---------------- Player's Handbook reader ---------------- */
body.reading main { max-width: 1240px; }
.reader { display: grid; grid-template-columns: 290px minmax(0, 850px); gap: 28px; justify-content: center; align-items: start; }
@media (max-width: 960px) { .reader { grid-template-columns: 1fr; } .reader-toc { position: static !important; } .toc-box { max-height: 40vh !important; } }
.reader-toc { position: sticky; top: calc(var(--topbar-h, 60px) + 8px); }
.toc-box { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; max-height: calc(100vh - var(--topbar-h, 60px) - 24px); overflow-y: auto;
  font: 13px/1.35 "Roboto Condensed", Roboto, sans-serif; }
.toc-filter { position: sticky; top: 0; z-index: 2; background: var(--panel); padding: 8px; border-bottom: 1px solid var(--line); }
.toc-filter input { width: 100%; font-size: 13px; }
.toc-tools { margin-top: 5px; font-size: 11px; color: var(--muted); }
.toc-tools a, .toc-tools button { color: var(--muted); background: none; border: 0; padding: 0; cursor: pointer; font: inherit; text-decoration: none; }
.toc-tools a:hover, .toc-tools button:hover { color: var(--ink); }
.tree, .tree ul { list-style: none; margin: 0; padding: 0; }
.tree ul { padding-left: 12px; display: none; }
.tree li.open > ul { display: block; }
.tn-row { display: flex; align-items: flex-start; }
.tn-row a { flex: 1; display: block; padding: 3px 8px 3px 2px; color: var(--ink); text-decoration: none; border-left: 3px solid transparent; }
.tn-row a:hover { background: var(--panel-2); }
.tw, .tw-pad { flex: none; width: 18px; height: 22px; }
.tw { background: none; border: 0; color: var(--muted); cursor: pointer; padding: 0; }
.tw::before { content: "▸"; display: inline-block; transition: transform .12s; }
li.open > .tn-row .tw::before { transform: rotate(90deg); }
.tree > li.chapter > .tn-row a { font-weight: 700; font-size: 13.5px; padding: 6px 8px 6px 2px; }
.tree > li.chapter { border-bottom: 1px solid var(--line); }
.tree > li.current-chapter > .tn-row a { color: var(--accent-text); }
.tree li.active > .tn-row a { background: var(--tan); border-left-color: var(--accent); font-weight: 700; }
.tree mark { background: rgba(240, 168, 104, .35); color: inherit; border-radius: 2px; }
.toc-text-hits { border-top: 1px solid var(--line); padding: 8px; }
.hits-title { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin-bottom: 4px; }
.toc-text-hits .hit { display: block; padding: 3px 4px; text-decoration: none; color: var(--ink); }
.toc-text-hits .hit:hover { background: var(--panel-2); } .toc-text-hits .hit span { color: var(--muted); font-size: 11px; }
.reader-main { min-width: 0; }

.phb { color: var(--ink); font: 16px/1.6 Roboto, Helvetica, Arial, sans-serif; min-width: 0; }
.phb p { margin: 0 0 14px; }
.phb h1, .phb h2, .phb h3, .phb h4, .phb h5, .phb h6 { font-family: Roboto, Helvetica, sans-serif; color: #f3ebdf; line-height: 1.25; scroll-margin-top: calc(var(--topbar-h, 60px) + 60px); }
.phb h1 { font-size: 32px; font-weight: 400; margin: 10px 0 18px; }
.phb h2 { font-size: 28px; font-weight: 400; margin: 34px 0 14px; padding-bottom: 4px; border-bottom: 1px solid var(--gold); }
.phb h3 { font-size: 22px; font-weight: 500; margin: 26px 0 10px; }
.phb h4 { font-size: 18px; font-weight: 700; margin: 20px 0 8px; }
.phb h5 { font-size: 16px; font-weight: 700; margin: 16px 0 6px; }
.phb h6 { font-size: 14px; font-weight: 700; text-transform: uppercase; margin: 14px 0 6px; }
.phb .kg-block { scroll-margin-top: calc(var(--topbar-h, 60px) + 60px); border-radius: 4px; }
.phb [id] { scroll-margin-top: calc(var(--topbar-h, 60px) + 60px); }
.phb .kg-details { margin-left: 8px; font-size: .6em; color: var(--muted); text-decoration: none; opacity: 0; transition: opacity .15s; vertical-align: middle; }
.phb h1:hover .kg-details, .phb h2:hover .kg-details, .phb h3:hover .kg-details, .phb h4:hover .kg-details, .phb h5:hover .kg-details { opacity: 1; }
.phb ul, .phb ol { padding-left: 22px; margin: 0 0 14px; }
.phb a { color: var(--link); }

/* the thing you jumped to */
@keyframes kg-flash { 0% { background-color: rgba(255, 200, 60, .75); } 100% { background-color: rgba(255, 214, 102, .28); } }
.phb .kg-hit { background-color: rgba(255, 214, 102, .28); box-shadow: 0 0 0 6px rgba(255, 214, 102, .28); animation: kg-flash 1.6s ease-out; border-radius: 3px; }
.phb table.kg-hit, .phb aside.kg-hit, .phb .stat-block.kg-hit { outline: 3px solid rgba(230, 170, 30, .8); outline-offset: 3px; }

/* tables */
.phb table { width: 100%; border-collapse: collapse; margin: 10px 0 22px; font-size: 14px; background: var(--panel); }
.phb caption { text-align: left; font-weight: 700; font-size: 16px; padding: 4px 0 8px; caption-side: top; }
.phb th { font-weight: 700; text-align: left; padding: 6px 10px; border-bottom: 1px solid var(--line); background: var(--panel); vertical-align: bottom; }
.phb td { padding: 6px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.phb tbody tr:nth-child(odd) td { background: var(--row-odd); }
.phb tbody tr:nth-child(even) td { background: var(--row-even); }
.phb .table-compendium { display: table; }
@media (max-width: 700px) { .phb table { display: block; overflow-x: auto; } }

/* sidebars */
.phb aside, .phb .text--rules-sidebar {
  display: block; margin: 28px 0; padding: 20px 28px 22px 30px; font-size: 14px; background-color: var(--tan);
  border-top: 3px solid var(--gold); border-bottom: 3px solid var(--gold); border-left: 1.5px solid var(--line); border-right: 1.5px solid var(--line);
  background-image:
    linear-gradient(135deg, var(--gold) 7px, transparent 7px), linear-gradient(225deg, var(--gold) 7px, transparent 7px),
    linear-gradient(45deg, var(--gold) 7px, transparent 7px), linear-gradient(315deg, var(--gold) 7px, transparent 7px);
  background-position: top left, top right, bottom left, bottom right; background-size: 14px 14px; background-repeat: no-repeat;
}
.phb aside > p:first-child, .phb aside > :is(h3, h4, h5, h6):first-child { text-transform: uppercase; font-weight: 700; font-size: 15px; margin: 0 0 10px; letter-spacing: .02em; }
.phb aside p:last-child { margin-bottom: 0; }

/* artwork */
.phb figure { margin: 18px auto 22px; text-align: center; max-width: 100%; }
.phb figure img { max-width: 100%; height: auto; display: block; margin: 0 auto; }
.phb .compendium-art-right { float: right; max-width: 45%; margin: 4px 0 12px 20px; }
.phb .compendium-art-left { float: left; max-width: 45%; margin: 4px 20px 12px 0; }
.phb .artist-credit { display: block; text-align: right; font-size: 10px; font-weight: 600; text-transform: uppercase; color: var(--muted); letter-spacing: .03em; margin-bottom: 2px; }
.phb .artist-credit::before { content: "Artist: "; }
.phb figcaption { font-size: 14px; font-weight: 700; font-style: italic; text-transform: uppercase; margin-top: 8px; }
.phb .kg-block::after { content: ""; display: table; clear: both; }

/* multi-column layouts used in the book */
.phb .flexible-double-column { columns: 2 300px; column-gap: 32px; }
.phb .flexible-triple-column { columns: 3 200px; column-gap: 24px; }
.phb .flexible-quad-column { columns: 4 150px; column-gap: 20px; }
.phb .flexible-double-column > *, .phb .flexible-triple-column > *, .phb .flexible-quad-column > * { break-inside: avoid; }

/* stat blocks */
.phb .stat-block { background: #2a221b; border-top: 3px solid #b0402c; border-bottom: 3px solid #b0402c; padding: 12px 16px; margin: 18px 0 24px; font-size: 14px; box-shadow: 0 1px 4px rgba(0,0,0,.15); }
.phb .stat-block > :is(h3, h4, h5, h6):first-child { font-size: 24px; font-weight: 700; color: #f08a70; font-variant: small-caps; margin: 0 0 2px; border: 0; }
.phb .stat-block > :is(h3, h4, h5, h6):first-child + p { font-style: italic; }
.phb .stat-block .monster-header { color: #f08a70; border-bottom: 1px solid #b0402c; margin: 12px 0 6px; font-size: 17px; font-weight: 400; font-variant: small-caps; }
.phb .stat-block p { margin: 0 0 6px; }
.phb .stat-block .stats { display: flex; gap: 10px; flex-wrap: wrap; margin: 8px 0; }
.phb .stat-block table { margin: 0; font-size: 13px; text-align: center; width: auto; flex: 1; }
.phb .stat-block table td, .phb .stat-block table th { background: transparent !important; padding: 2px 6px; text-align: center; }
.phb .stat-block .physical table thead th { color: #f08a70; }
.phb .stat-block .mental table thead th { color: #f08a70; }


/* contents page */
.contents-page { max-width: 1000px; margin: 0 auto; }
.book-banner { text-align: center; padding: 26px 0 10px; border-bottom: 1px solid var(--gold); margin-bottom: 20px; }
.book-banner h1 { font-size: 40px; font-weight: 300; margin: 0; letter-spacing: .02em; }
.book-banner p { color: var(--muted); margin: 4px 0 0; }
.contents-grid { columns: 3 280px; column-gap: 28px; }
.contents-grid section { break-inside: avoid; background: var(--panel); border: 1px solid var(--line); padding: 12px 16px; margin-bottom: 18px; }
.contents-grid h3 { margin: 0 0 6px; font-size: 17px; } .contents-grid h3 a { color: var(--accent-text); text-decoration: none; }
.contents-grid ul { list-style: none; padding: 0; margin: 0; font-size: 14px; } .contents-grid li a { color: var(--ink); text-decoration: none; }
.contents-grid li a:hover { color: var(--link); }

/* hover previews on rules links */
.kg-tip { position: absolute; z-index: 10000; max-width: 360px; background: var(--panel-2); border: 1px solid var(--line); border-top: 3px solid var(--accent); box-shadow: 0 6px 20px rgba(0,0,0,.5); padding: 10px 12px; font: 13px/1.45 Roboto, sans-serif; color: var(--ink); pointer-events: none; }
.kg-tip b { font-size: 15px; display: block; } .kg-tip .tip-type { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .04em; }
.kg-tip .tip-meta { font-style: italic; margin: 2px 0 4px; }
/* the handbook card is one big link: an icon, the text, and an obvious "Open" button */
.handbook-card { display: flex; align-items: center; gap: 16px; text-decoration: none; color: inherit; border-left: 4px solid var(--accent);
  transition: background .15s, transform .15s, box-shadow .15s; }
.handbook-card:hover { background: var(--panel-2); transform: translateY(-1px); box-shadow: 0 6px 18px rgba(0,0,0,.35); }
.handbook-card h2 { color: var(--accent-text); margin: 0 0 4px; }
.hb-icon { font-size: 2rem; line-height: 1; }
.hb-text { flex: 1; display: flex; flex-direction: column; }
.hb-open { flex: none; border-color: var(--accent); color: var(--accent-text); }
.handbook-card:hover .hb-open { background: var(--accent); color: #fff; }
/* first run: no characters yet */
.first-character { display: flex; align-items: center; gap: 18px; margin-bottom: 16px; padding: 22px 24px; border-radius: 10px;
  background: var(--accent); color: #fff; text-decoration: none; box-shadow: 0 8px 24px rgba(196,30,26,.35);
  transition: transform .15s, box-shadow .15s, background .15s; }
.first-character:hover { background: #d4241f; transform: translateY(-2px); box-shadow: 0 12px 30px rgba(196,30,26,.45); }
.fc-icon { font-size: 2.2rem; line-height: 1; }
.fc-text { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.fc-text strong { font: 700 1.5rem "Roboto Condensed", Roboto, sans-serif; letter-spacing: .02em; }
.fc-text span { opacity: .9; }
.fc-go { font-size: 2rem; line-height: 1; }
@media screen and (max-width: 700px) {
  .hb-open { display: none; } .handbook-card::after { content: "→"; font-size: 1.6rem; color: var(--accent-text); }
  .fc-text strong { font-size: 1.2rem; }
}

/* ---------------- live search ---------------- */
.search { position: relative; }
.search-pop { position: absolute; top: calc(100% + 6px); right: 0; width: max(100%, 420px); max-width: calc(100vw - 32px); max-height: 72vh; overflow-y: auto; z-index: 60;
  background: var(--panel); border: 1px solid var(--line); border-top: 3px solid var(--accent); border-radius: 0 0 8px 8px; box-shadow: 0 12px 32px rgba(0,0,0,.55); }
.s-card { display: block; padding: 8px 12px; border-bottom: 1px solid var(--line); text-decoration: none; color: var(--ink); }
.s-card:hover, .s-card.active { background: var(--panel-2); }
.s-top { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.s-top b { font-size: .95rem; }
.s-sum { font-size: .8rem; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.s-all, .s-empty { display: block; padding: 8px 12px; font-size: .85rem; color: var(--link); text-decoration: none; }
.s-empty { color: var(--muted); }
.cs .btn { background: #fff; color: #231f20; border-color: #9a9a9a; }
.cs .btn:hover { background: #f3efe8; }

/* ---------------- floating advisor ---------------- */
#advisor { font: 14px/1.5 Roboto, sans-serif; }  /* no stacking context: its windows stack with the dice roller */
.adv-bubble { position: fixed; width: 58px; height: 58px; border-radius: 50%; border: 2px solid #d9ae5f; cursor: grab; z-index: 82;
  background: radial-gradient(circle at 35% 30%, #d8342a, #780a08); box-shadow: 0 6px 20px rgba(0,0,0,.55), 0 0 0 4px rgba(196,30,26,.2);
  display: flex; align-items: center; justify-content: center; padding: 0; touch-action: none; }
.adv-bubble:hover { transform: scale(1.06); } .adv-bubble.dragging { cursor: grabbing; transform: scale(1.1); }
.adv-bubble svg { width: 26px; height: 26px; fill: #fff4e6; }
.adv-dot { position: absolute; top: 2px; right: 2px; width: 14px; height: 14px; border-radius: 50%; background: #ffd34d; border: 2px solid #8e2f1f; }
.adv-panel { position: fixed; width: 450px; height: 560px; min-width: 430px; min-height: 320px; max-width: 96vw; max-height: 92vh; z-index: 81;
  display: flex; flex-direction: column; background: var(--panel); border: 1px solid var(--line); border-top: 3px solid var(--accent);
  border-radius: 10px; box-shadow: 0 18px 50px rgba(0,0,0,.6); resize: both; overflow: hidden; }
/* Everything below the title bar is slightly see-through (more so while dragging); the red title bar
   is always solid. Each section carries the panel colour so the page shows through it evenly. */
.adv-panel { background: transparent !important; }
.adv-panel > :not(.adv-head) { opacity: .96; transition: opacity .12s; }
.adv-panel.dragging > :not(.adv-head) { opacity: .7; }
.adv-panel > .adv-sub, .adv-panel > .adv-msgs, .adv-panel > .adv-ask { background: var(--panel); }
.adv-panel > .adv-head { opacity: 1; }
/* a thick red title bar that is all drag handle, apart from the minimise button */
.adv-head { display: flex; align-items: center; min-height: 40px; padding: 0 6px 0 14px; background: var(--accent); color: #fff; cursor: grab; touch-action: none; user-select: none; }
.adv-head strong { font: 600 15px "Roboto Condensed", Roboto, sans-serif; letter-spacing: .05em; text-transform: uppercase; margin-right: auto; }
.adv-head .adv-icon { color: #fff; opacity: .85; font-size: 22px; width: 34px; height: 30px; border-radius: 5px; }
.adv-head .adv-icon:hover { opacity: 1; background: rgba(0,0,0,.18); }
.adv-tools { display: flex; align-items: center; gap: 6px; padding: 6px 10px; background: var(--panel-2); border-bottom: 1px solid var(--line); }
.adv-tools select { font-size: 12px; padding: 3px 4px; min-width: 0; }
.adv-tools #adv-char { flex: 1; max-width: 200px; }
.adv-tools #adv-dice { margin-left: auto; }
.adv-icon { background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 16px; padding: 0 4px; text-decoration: none; line-height: 1; }
.adv-icon:hover { color: var(--ink); }
.adv-sub { display: flex; align-items: center; gap: 6px; padding: 3px 10px 3px 12px; border-bottom: 1px solid var(--line); }
.adv-ctx { flex: 1; font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.adv-sub select { font-size: 11px; padding: 1px 3px; max-width: 150px; }
.adv-usage { padding: 8px 12px; border-bottom: 1px solid var(--line); background: var(--bg); font-size: 12px; }
.adv-usage .u-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.q-box { margin: 4px 0 10px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; }
.q-box.over { border-color: var(--accent); }
.q-row { display: grid; grid-template-columns: 90px auto 1fr; align-items: center; gap: 8px; margin: 2px 0; }
.q-bar { height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; }
.q-bar i { display: block; height: 100%; background: var(--skill); }
.q-box.over .q-bar i { background: var(--accent); }
.adv-usage table { width: 100%; border-collapse: collapse; } .adv-usage th, .adv-usage td { text-align: right; padding: 2px 4px; border-bottom: 1px solid var(--line); }
.adv-usage th:first-child, .adv-usage td:first-child { text-align: left; } .adv-usage tr.tot td { font-weight: 700; }
.adv-msgs { flex: 1; overflow-y: auto; padding: 8px 12px; }
/* admins viewing as a player: messages the player cleared */
.adv-msg.cleared { opacity: .6; border-style: dashed !important; }
.adv-cleared-mark { margin: 10px 0 6px; padding: 4px 10px; border: 1px dashed var(--accent); border-radius: 6px; color: var(--accent-text);
  font-size: 12px; font-weight: 600; text-align: center; }
.adv-cleared-mark.end { border-color: var(--line); color: var(--muted); font-weight: 400; }
.adv-empty { color: var(--muted); font-size: 13px; padding: 12px 4px; }
.adv-msg { padding: 8px 10px; border-radius: 8px; margin: 8px 0; max-width: 94%; font-size: 13.5px; }
.adv-msg.user { background: var(--panel-2); margin-left: auto; }
.adv-msg.assistant { border: 1px solid var(--line); }
.adv-msg.error { border: 1px solid var(--accent); color: var(--accent-text); }
.adv-msg p { margin: 0 0 6px; } .adv-msg p:last-child { margin-bottom: 0; } .adv-msg ul, .adv-msg ol { margin: 4px 0; padding-left: 18px; }
.adv-msg.thinking { color: var(--muted); font-style: italic; }
.dots i { display: inline-block; width: 5px; height: 5px; margin-right: 2px; border-radius: 50%; background: var(--muted); animation: dot 1.2s infinite; }
.dots i:nth-child(2) { animation-delay: .2s; } .dots i:nth-child(3) { animation-delay: .4s; }
@keyframes dot { 0%, 80%, 100% { opacity: .2; } 40% { opacity: 1; } }
.adv-acts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.adv-chip { font-size: 11.5px; padding: 2px 8px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); color: var(--link); cursor: pointer; text-decoration: none; }
.adv-proposal { width: 100%; border: 1px solid #b38df0; border-left: 4px solid #b38df0; border-radius: 6px; padding: 8px 10px; background: #2a2236; }
.adv-proposal .p-title { font-weight: 700; font-size: 13px; }
.adv-proposal ul { margin: 4px 0 6px; padding-left: 18px; font-size: 13px; }
.adv-proposal .p-actions { display: flex; gap: 6px; }
.adv-proposal.s-accepted { border-color: #5fc48a; background: #1f3328; } .adv-proposal.s-rejected { border-color: #6b6259; background: var(--bg); opacity: .75; }
.adv-proposal .p-status { font-size: 12px; font-weight: 700; }
/* the Ask button matches the textbox's height; the right padding leaves the resize grip its corner */
.adv-ask { display: flex; gap: 8px; align-items: stretch; padding: 8px 24px 8px 10px; border-top: 1px solid var(--line); }
.adv-ask .btn { padding: 0 16px; }
.adv-ask textarea { flex: 1; resize: none; font-size: 13.5px; }
@media (max-width: 600px) { .adv-panel { width: calc(100vw - 8px) !important; } }

.adv-win { position: fixed; z-index: 75; width: 440px; height: 380px; min-width: 260px; min-height: 160px; max-width: 95vw; max-height: 85vh;
  display: flex; flex-direction: column; background: var(--panel); border: 1px solid var(--line); border-top: 3px solid var(--gold);
  border-radius: 8px; box-shadow: 0 14px 40px rgba(0,0,0,.6); resize: both; overflow: hidden; }
.adv-win-head { display: flex; align-items: center; gap: 8px; padding: 7px 10px; background: var(--panel-2); cursor: grab; touch-action: none; border-bottom: 1px solid var(--line); }
.adv-win-head .grow { flex: 1; }
.adv-win-note { font-size: 12px; color: var(--muted); padding: 6px 12px 0; font-style: italic; }
.adv-win-body { flex: 1; overflow-y: auto; padding: 10px 14px; font-size: 14px !important; }
.adv-win-body table { font-size: 12.5px; }
/* entry peek: the full entry on hover over the character sheet (same look as a pinned window) */
.adv-win.kg-peek { z-index: 10002; height: auto; max-height: min(380px, 70vh); cursor: pointer; box-shadow: 0 14px 40px rgba(0,0,0,.6); }
.kg-peek .adv-win-head { cursor: pointer; }
.kg-peek-hint { color: var(--muted); font-size: 11px; white-space: nowrap; }

@keyframes adv-pulse { 0%, 100% { box-shadow: 0 0 0 3px rgba(255, 211, 77, .9), 0 0 18px 4px rgba(255, 211, 77, .45); } 50% { box-shadow: 0 0 0 6px rgba(255, 211, 77, .35), 0 0 28px 8px rgba(255, 211, 77, .2); } }
.adv-hl { animation: adv-pulse 1.2s ease-in-out 5; border-radius: 6px; position: relative; z-index: 2; }
.adv-toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 10000; background: var(--panel-2); border: 1px solid var(--line);
  border-left: 4px solid var(--accent); padding: 8px 14px; border-radius: 6px; box-shadow: 0 8px 24px rgba(0,0,0,.5); font-size: 13px; }
.adv-sel-ask { position: fixed; z-index: 10000; font: 600 12px Roboto, sans-serif; padding: 5px 10px; border-radius: 14px; border: 0; cursor: pointer;
  background: var(--accent); color: #fff; box-shadow: 0 4px 12px rgba(0,0,0,.5); }

/* ---------------- dice roller ---------------- */
.dice-win { width: 496px; height: auto; max-height: 92vh; resize: none; z-index: 78; }
.dice-label { font-size: 12px; color: var(--muted); margin-left: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 240px; }
.dice-body { padding: 10px 14px 12px; overflow-y: auto; }
.dice-inputs { display: grid; grid-template-columns: 1.3fr 1.2fr 1fr; gap: 8px; }
.dice-inputs label { display: flex; flex-direction: column; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; gap: 2px; }
.dice-inputs label:nth-child(2) { flex-direction: row; flex-wrap: wrap; align-items: center; } .dice-inputs label:nth-child(2) input { flex: 1; min-width: 60px; }
.dice-inputs input, .dice-inputs select { font-size: 14px; padding: 5px 6px; }
#dice-expr { font-family: ui-monospace, Menlo, monospace; }
.dice-quick { display: flex; flex-wrap: wrap; gap: 4px; margin: 8px 0; }
.dice-quick button { font: 600 12px Roboto, sans-serif; padding: 3px 8px; border-radius: 4px; border: 1px solid var(--line); background: var(--panel-2); color: var(--ink); cursor: pointer; }
.dice-quick button:hover { border-color: var(--accent); }
.dice-odds { min-height: 40px; }
.odds-big { font-size: 15px; } .odds-big b { font-size: 24px; color: var(--skill); margin-right: 4px; }
.odds-meta { font-size: 12px; color: var(--muted); }
.dice-err { color: var(--accent-text); font-size: 13px; }
.dice-hist { width: 100%; height: 60px; display: block; margin: 4px 0 8px; }
.dice-hist rect { fill: #5a5148; } .dice-hist rect.hit { fill: var(--skill); }
.dice-tray { width: 100%; aspect-ratio: 460 / 230; border-radius: 8px; display: block; box-shadow: inset 0 2px 10px rgba(0,0,0,.6), 0 2px 0 #3a2a1d; border: 3px solid #4a3220; }
.dice-result { display: flex; align-items: center; gap: 12px; min-height: 52px; margin-top: 8px; }
.dice-result .total { font: 700 34px Roboto, sans-serif; min-width: 56px; text-align: center; }
.dice-result .total.ok { color: var(--skill); } .dice-result .total.bad { color: var(--accent-text); }
.breakdown { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; font-size: 13px; }
.die-chip { background: var(--c); color: #fff; border-radius: 4px; padding: 1px 6px; font-weight: 700; } .die-chip small { opacity: .75; font-weight: 400; margin-left: 2px; }
.die-chip.dropped { opacity: .35; text-decoration: line-through; }
.breakdown .mod { color: var(--muted); }
.verdict { font-weight: 700; padding: 1px 8px; border-radius: 10px; } .verdict.ok { background: #1f3a2a; color: var(--skill); } .verdict.bad { background: #3a1d1b; color: var(--accent-text); }
.dice-actions { display: flex; align-items: center; gap: 10px; margin-top: 6px; }
.dice-log { display: flex; gap: 6px; font-size: 12px; color: var(--muted); overflow: hidden; }
.dice-log span { border: 1px solid var(--line); border-radius: 4px; padding: 0 6px; }
.dice-log span:first-child { color: var(--ink); border-color: var(--gold); }

/* stacking & focus for floating windows (z-index is set by bringToFront) */
.floating { transition: box-shadow .15s, border-color .15s; }
.adv-win.floating:not(.focused) { box-shadow: 0 8px 24px rgba(0,0,0,.45); }
.adv-win.floating:not(.focused) .adv-win-head { opacity: .8; }
.floating.focused { box-shadow: 0 18px 50px rgba(0,0,0,.65), 0 0 0 1px var(--gold); }
.adv-win-head [data-close] { font-size: 20px; padding: 0 6px; }

/* ---------------- handbook info on the sheet ---------------- */
.info-pip { position: absolute; z-index: 10001; width: 16px; height: 16px; border-radius: 50%; padding: 0; cursor: pointer;
  border: 1.5px solid #1b6fba; background: #fff; color: #1b6fba; font: italic 700 11px/13px Georgia, serif; text-align: center;
  box-shadow: 0 1px 4px rgba(0,0,0,.35); }
.info-pip:hover { background: #1b6fba; color: #fff; }
.cs .has-info { cursor: help; text-decoration: underline dotted rgba(27, 111, 186, .55); text-underline-offset: 2px; }
.cs .has-info:hover { color: #1b6fba; }
.book-jump { display: inline-flex; color: var(--gold) !important; }
.book-jump:hover { color: var(--link) !important; }

/* custom dropdowns on the sheet */
.csel { position: relative; }
.csel-btn { width: 100%; display: flex; justify-content: space-between; align-items: center; background: transparent; border: 0;
  border-bottom: 1px solid #9a9a9a; padding: 2px 2px 1px; font: inherit; font-size: 14px; color: var(--ink); cursor: pointer; text-align: left; }
.csel-btn:hover { background: #faf6ee; }
.csel-caret { font-size: 11px; color: #777; }
.csel-pop { position: absolute; left: 0; top: calc(100% + 2px); z-index: 20; width: max(100%, 240px); max-height: 320px; display: flex; flex-direction: column;
  background: #fff; border: 2px solid var(--ink); border-radius: 6px; box-shadow: 0 10px 28px rgba(0,0,0,.35); }
.csel-filter { border-bottom: 1px solid #ccc !important; padding: 6px 8px !important; font-size: 13px; }
.csel-list { list-style: none; margin: 0; padding: 2px 0; overflow-y: auto; }
.csel-list li { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 4px 8px; cursor: pointer; font-size: 13.5px; }
.csel-list li:hover { background: #f3eee4; }
.csel-list li.cur { font-weight: 700; background: #efe7d8; }
.csel-list .csel-empty { color: #888; cursor: default; }
.csel-info { flex: none; width: 18px; height: 18px; border-radius: 50%; border: 1.5px solid #1b6fba; background: #fff; color: #1b6fba; padding: 0;
  font: italic 700 11px/14px Georgia, serif; cursor: pointer; }
.csel-info:hover { background: #1b6fba; color: #fff; }

/* ---------------- official sheet: values drawn over the real PDF pages ---------------- */
.paper-page { position: relative; width: 1040px; height: 1345.9px; background: #fff; box-shadow: 0 2px 12px rgba(0,0,0,.35); margin-bottom: 16px; }
.paper-page > img { position: absolute; inset: 0; width: 100%; height: 100%; user-select: none; pointer-events: none; }
.pp-layer { position: absolute; inset: 0; font-family: Helvetica, Arial, sans-serif; color: #111; }
.pf { position: absolute; box-sizing: border-box; margin: 0; overflow: hidden; line-height: 1.15; }
.pf.pin, .pf.parea { border: 0; background: transparent; color: #111; font-family: inherit; padding: 0 2px; border-radius: 2px; }
.pf.pin:hover, .pf.parea:hover { background: rgba(27, 111, 186, .06); }
.pf.pin:focus, .pf.parea:focus { outline: 1.5px solid rgba(27, 111, 186, .55); background: rgba(255, 253, 240, .9); }
.pf.pin { line-height: normal; } .pf.center { text-align: center; }
.pf.pin[type=number] { -moz-appearance: textfield; } .pf.pin::-webkit-inner-spin-button { -webkit-appearance: none; }
.pf.parea { resize: none; font-size: 12px !important; line-height: 1.35; padding: 2px 4px; }
.pf.pval { display: flex; align-items: center; justify-content: center; font-weight: 400; white-space: nowrap; }
.pf.ptext { font-size: 11px; display: flex; align-items: center; white-space: nowrap; text-overflow: ellipsis; padding: 0 2px; }
.pf.ptext.multi { white-space: normal; align-items: flex-start; line-height: 1.4; padding-top: 2px; font-size: 11.5px; }
.pf.ptext.center { justify-content: center; } .pf.ptext.num { font-size: 12.5px; }
.pf.ptext.tiny { font-size: 9.5px; color: #333; }
.pf.plist { font-size: 11.5px; line-height: 1.45; padding: 3px 5px; overflow-y: auto; }
.pf.plist > div { break-inside: avoid; }
.pf .psrc { color: #666; font-size: 9.5px; } .pf .pnote { margin-top: 6px; font-style: italic; color: #333; white-space: pre-wrap; }
.pp-layer a.kg-link { color: #111 !important; font-weight: 400; text-decoration: none; border-bottom: 1px dotted #8aa7c7; }
.pp-layer a.kg-link:hover { color: #1b6fba !important; }
.pf .px { border: 0; background: none; color: #b33; cursor: pointer; padding: 0 2px; font-size: 12px; visibility: hidden; }
.pf:hover .px, .peq:hover .px { visibility: visible; }
.pf.psel .csel-btn { border-bottom: 0; font: 15px Helvetica, Arial, sans-serif; padding: 0 2px; height: 100%; }
.pf.psel .csel-caret { opacity: .35; } .pf.psel { overflow: visible; }
.pf.psel .csel-pop { top: calc(100% + 2px); }
.peq { display: flex; align-items: center; gap: 4px; }
.pqty { width: 28px !important; flex: none; border: 0; background: transparent; text-align: right; font: inherit; color: #555; padding: 0 !important; }
.ptog { font-size: 9.5px; color: #555; display: inline-flex; align-items: center; gap: 2px; }
.ptog input { margin: 0; width: 10px; height: 10px; }

/* filled marks for the printed circles and diamonds */
.pmark { position: absolute; border: 0; padding: 0; background: transparent; cursor: pointer; }
.pmark:hover { background: rgba(27, 111, 186, .12); border-radius: 50%; }
i.pmark { cursor: default; } i.pmark:hover { background: transparent; }
.pmark.on::after { content: ""; position: absolute; inset: 22%; background: #111; }
.pmark.dot-mark.on::after { border-radius: 50%; inset: 18%; }
.pmark.dot-mark.expert.on::after { box-shadow: 0 0 0 1.5px #fff, 0 0 0 3px #111; }
.pmark.dia-mark.on::after { transform: rotate(45deg); inset: 26%; }
.pmark.dia-mark.fail.on::after { background: #b3261e; }
#inspiration.on::after { inset: 20%; transform: rotate(45deg); }

/* hotspots over printed labels: invisible until hovered */
.phot { position: absolute; cursor: help; border-radius: 3px; }
.phot:hover { background: rgba(27, 111, 186, .1); }

.paper-tools { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; margin-bottom: 10px; padding: 8px 12px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px; font-size: 13px; }
.pt-zoom { margin-left: auto; gap: 4px; }
.icon-btn { min-width: 34px; padding-left: 8px; padding-right: 8px; font-size: 1rem; text-align: center; }
/* the zoom slider is drawn as an outline: a hollow track and a hollow round handle */
.pt-zoom input[type=range] { --wire: #d8d2c8; width: 120px; padding: 0; margin: 0 4px; height: 18px; background: none; border: 0;
  -webkit-appearance: none; appearance: none; cursor: pointer; }
.pt-zoom input[type=range]::-webkit-slider-runnable-track { height: 6px; border: 1.5px solid var(--wire); border-radius: 4px; background: transparent; }
.pt-zoom input[type=range]::-moz-range-track { height: 4px; border: 1.5px solid var(--wire); border-radius: 4px; background: transparent; }
.pt-zoom input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 14px; height: 14px; margin-top: -5.5px;
  border: 1.5px solid var(--wire); border-radius: 50%; background: #000; }
.pt-zoom input[type=range]::-moz-range-thumb { width: 12px; height: 12px; border: 1.5px solid var(--wire); border-radius: 50%; background: #000; }
.pt-zoom input[type=range]:focus-visible { outline: 1px dotted var(--wire); outline-offset: 2px; }
body.embedded:not(.sheet-dark) .pt-zoom input[type=range] { --wire: #111; }
body.embedded:not(.sheet-dark) .pt-zoom input[type=range]::-webkit-slider-thumb { background: #fff; }
body.embedded:not(.sheet-dark) .pt-zoom input[type=range]::-moz-range-thumb { background: #fff; }
.pt-zoom #zoom-reset { min-width: 52px; }
.pt-group { display: inline-flex; align-items: center; gap: 6px; }
.pt-group input { width: 80px; font-size: 13px; padding: 3px 6px; }
.pt-pick .picker { margin: 0; } .pt-pick .picker input { width: 170px; }
.pt-pick b { color: var(--muted); font-weight: 600; }
details.pt-group summary { cursor: pointer; color: var(--link); }
details.pt-group[open] { flex-basis: 100%; }
body.previewing .pp-layer input, body.previewing .pp-layer textarea, body.previewing .pp-layer button,
body.previewing .pp-layer .pmark, body.previewing .pp-layer label, body.previewing .paper-tools { pointer-events: none; }
body.previewing .paper-page { filter: sepia(.25); }

/* both sheet pages side by side */
.cs.both { width: 2100px; display: flex; gap: 20px; align-items: flex-start; }
.cs.both > .page { width: 1040px; flex: none; margin-bottom: 0; }
/* Floating windows stack from z-index 100 upward (bringToFront); tooltips, the info icon, the
   "Ask the advisor" selection button and notices sit above every window at 10000+. */

/* "+" buttons on the official sheet's boxes */
/* "add" buttons on the sheet: a solid red circle with a white plus drawn from two bars, so it's exactly centred */
.padd { position: absolute; border-radius: 50%; border: 0; background: #c41e1a; padding: 0; font-size: 0; color: transparent;
  cursor: pointer; transition: transform .15s, background .15s; box-shadow: 0 1px 2px rgba(0,0,0,.25); }
.padd::before, .padd::after { content: ""; position: absolute; left: 50%; top: 50%; background: #fff; border-radius: 1px; transform: translate(-50%, -50%); }
.padd::before { width: 56%; height: 14%; }
.padd::after { width: 14%; height: 56%; }
.padd:hover { background: #e0241f; transform: scale(1.15); }
body.sheet-dark #sheet .padd { filter: invert(1) hue-rotate(180deg); }   /* undo the dark sheet's inversion: stay red and white */
body.previewing .padd { display: none; }

/* Add to sheet window */
.add-win { width: 560px; height: 560px; }
.add-cats { display: flex; flex-wrap: wrap; gap: 4px; padding: 8px 10px; border-bottom: 1px solid var(--line); background: var(--panel-2); }
.add-cats button { font: 600 12px Roboto, sans-serif; padding: 3px 9px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg); color: var(--ink); cursor: pointer; }
.add-cats button.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.add-body { flex: 1; overflow-y: auto; padding: 10px 14px; font-size: 14px; }
.add-have-list { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.add-have { background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px; padding: 2px 8px; font-size: 13px; }
.add-search { width: 100%; margin: 4px 0 6px; }
.add-results { list-style: none; padding: 0; margin: 0; }
.add-results li { display: flex; align-items: center; gap: 8px; padding: 5px 2px; border-bottom: 1px solid var(--line); }
.add-results .grow { flex: 1; }
.add-free { display: flex; gap: 6px; margin: 8px 0; } .add-free input { flex: 1; }
.add-qty { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); } .add-qty input { width: 64px; }
.add-toggle { display: block; padding: 4px 0; }
.add-group { margin: 6px 0; display: flex; flex-wrap: wrap; gap: 4px; align-items: center; } .add-group b { width: 70px; color: var(--muted); font-size: 12px; }
.add-pick { font-size: 12px; padding: 2px 8px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); color: var(--ink); cursor: pointer; }
.add-pick:hover { border-color: var(--accent); }
.add-skills { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; }
.add-skill { text-align: left; padding: 5px 8px; border-radius: 6px; border: 1px solid var(--line); background: var(--bg); color: var(--ink); cursor: pointer; font-size: 13px; }
.add-skill small { display: block; color: var(--muted); } .add-skill.p1 { border-color: var(--skill); } .add-skill.p2 { border-color: var(--accent); background: #3a1d1b; }
.add-attack { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; } .add-attack button { grid-column: span 2; }

.pf.plist.clickable { cursor: pointer; } .pf.plist.clickable:hover { background: rgba(27, 111, 186, .06); }
.pf .phint { color: #1b6fba; font-size: 10.5px; font-style: italic; }
.add-lang-list { list-style: none; padding: 0; margin: 0 0 8px; }
.add-lang-list li { display: flex; align-items: center; gap: 8px; padding: 4px 2px; border-bottom: 1px solid var(--line); }
.add-lang-list select { font-size: 13px; padding: 2px 4px; }
.add-lang-list .grow { flex: 1; }
.link-btn { background: none; border: 0; color: var(--link); cursor: pointer; padding: 0; font: inherit; text-decoration: underline; }

/* ---------------- notes ---------------- */
.notes-host { min-height: 70vh; }
.notes-page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.notes-pane { margin-bottom: 16px; }
.np { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 14px; height: calc(100vh - var(--topbar-h, 60px) - 150px); min-height: 480px; }
@media (max-width: 800px) { .np { grid-template-columns: 1fr; height: auto; } }
.np-side { display: flex; flex-direction: column; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.np-tools { display: flex; gap: 6px; padding: 8px; border-bottom: 1px solid var(--line); } .np-tools input { flex: 1; min-width: 0; }
.np-list { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; }
.np-list li { padding: 8px 10px; border-bottom: 1px solid var(--line); cursor: pointer; }
.np-list li:hover { background: var(--panel-2); }
.np-list li.on { background: var(--tan); border-left: 3px solid var(--accent); }
.np-li-title { font-weight: 600; } .np-list .tiny { font-size: 11px; } .np-none { cursor: default !important; }
.np-main { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 10px 14px; display: flex; flex-direction: column; min-height: 0; }
.np-empty { margin: auto; }
.np-editor { display: flex; flex-direction: column; gap: 6px; min-height: 0; flex: 1; }
.np-bar { display: flex; gap: 6px; align-items: center; } .np-title { flex: 1; font-size: 17px; font-weight: 600; }
.np-pin.on { background: var(--tan); }
.np-body { flex: 1; resize: none; font: 14px/1.5 ui-monospace, Menlo, monospace; min-height: 300px; }
.np-preview { flex: 1; overflow-y: auto; padding: 4px 2px; font-size: 15px !important; }
.np-preview blockquote, .adv-msg blockquote { border-left: 3px solid var(--gold); margin: 6px 0; padding: 2px 10px; color: var(--muted); }
.md-table { border-collapse: collapse; margin: 6px 0; font-size: 13px; } .md-table th, .md-table td { border: 1px solid var(--line); padding: 3px 6px; text-align: left; vertical-align: top; }
.md-table th { background: var(--panel-2); }

.note-picker { position: fixed; z-index: 10002; width: 290px; background: var(--panel-2); border: 1px solid var(--line); border-top: 3px solid var(--gold);
  border-radius: 8px; box-shadow: 0 12px 32px rgba(0,0,0,.55); padding: 8px; font: 13px Roboto, sans-serif; display: flex; flex-direction: column; gap: 6px; }
.note-picker .np-head { display: flex; justify-content: space-between; align-items: baseline; }
.note-picker .np-item { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.note-picker .np-choices { list-style: none; margin: 0; padding: 0; max-height: 220px; overflow-y: auto; }
.note-picker .np-choices li { padding: 5px 6px; border-radius: 4px; cursor: pointer; display: flex; flex-direction: column; }
.note-picker .np-choices li:hover { background: var(--panel); }
.note-pip { position: absolute; z-index: 10001; border: 1px solid var(--line); background: var(--panel-2); border-radius: 6px; padding: 1px 5px;
  font-size: 14px; cursor: pointer; box-shadow: 0 2px 8px rgba(0,0,0,.4); }
.note-pip:hover { border-color: var(--gold); }
.adv-msg { position: relative; }
.adv-note-btn { position: absolute; top: 4px; right: 4px; border: 1px solid var(--line); background: var(--panel-2); border-radius: 5px; padding: 0 4px;
  font-size: 13px; cursor: pointer; opacity: 0; transition: opacity .15s; }
.adv-msg:hover .adv-note-btn { opacity: 1; }

/* window resizing: custom corner handle (see app.js) instead of CSS resize */
.adv-win, .adv-panel { resize: none !important; }
.win-resize { position: absolute; right: 0; bottom: 0; width: 18px; height: 18px; cursor: nwse-resize; z-index: 6;
  background: linear-gradient(135deg, transparent 0 52%, var(--muted) 52% 60%, transparent 60% 70%, var(--muted) 70% 78%, transparent 78%);
  border-bottom-right-radius: 8px; opacity: .7; }
.win-resize:hover { opacity: 1; }
body.resizing, body.resizing * { cursor: nwse-resize !important; user-select: none !important; }

/* sheet-only tools are hidden on the Notes and Details tabs */
body.sheet-off .paper-tools, body.sheet-off #warnings { display: none; }

/* character name generator */
.namegen { display: grid; grid-template-columns: 1fr auto; gap: 6px 10px; align-items: end; margin-bottom: 10px; }
.namegen .ng-name { margin-bottom: 0; }
.ng-controls { display: flex; gap: 6px; }
.ng-results { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 6px; }
.ng-chip { font: 14px Roboto, sans-serif; padding: 5px 12px; border-radius: 16px; border: 1px solid var(--line); background: var(--panel-2); color: var(--ink); cursor: pointer; }
.ng-chip small { margin-left: 6px; color: var(--muted); font-size: 11px; }
.ng-chip:hover { border-color: var(--gold); } .ng-chip.on { border-color: var(--accent); background: #3a1d1b; }
.ng-hint { grid-column: 1 / -1; margin: 0; }
@media (max-width: 600px) { .namegen { grid-template-columns: 1fr; } }
.ng-controls .btn, .ng-controls select { white-space: nowrap; }

/* sign-in */
.login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-card { max-width: 380px; width: calc(100% - 32px); background: var(--panel); border: 1px solid var(--line); border-top: 3px solid var(--accent);
  border-radius: 10px; padding: 28px 26px; text-align: center; }
.login-emblem { display: block; width: 100%; max-width: 300px; height: auto; margin: 0 auto 14px; border-radius: 12px; }
.login-google { display: inline-flex; align-items: center; gap: 10px; margin-top: 10px; padding: 10px 18px; font-size: 1rem; }
/* account: Log out + arrow menu, top right */
.account { position: relative; display: flex; align-items: stretch; flex-shrink: 0; font: 500 .8rem "Roboto Condensed", Roboto, sans-serif; text-transform: uppercase; }
.account-logout { display: flex; align-items: center; white-space: nowrap; color: #e6e6e6; text-decoration: none; padding: 6px 10px; border: 1px solid var(--line); border-radius: 6px 0 0 6px; background: var(--panel-2); letter-spacing: .03em; }
.account-logout:hover { color: #fff; border-color: var(--accent); }
.account-logout.disabled { color: var(--muted); cursor: default; }
.account-logout.disabled:hover { color: var(--muted); border-color: var(--line); }
.account-toggle { display: flex; align-items: center; justify-content: center; padding: 0 9px; margin-left: -1px;
  border: 1px solid var(--line); border-radius: 0 6px 6px 0; background: var(--panel-2); color: #e6e6e6; cursor: pointer; }
.account-toggle:hover, .account-toggle[aria-expanded="true"] { color: #fff; border-color: var(--accent); }
.account-menu { right: 0; top: calc(100% + 14px); }
.account-who { display: flex; align-items: center; gap: 10px; padding: 6px 10px 8px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.account-who img { width: 30px; height: 30px; border-radius: 50%; }
.account-who div { display: flex; flex-direction: column; min-width: 0; }
.account-who span { color: var(--muted); font-size: .8rem; overflow: hidden; text-overflow: ellipsis; }

/* modal dialogs */
.modal-back { position: fixed; inset: 0; z-index: 9000; background: rgba(0,0,0,.6); display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal { width: 440px; max-width: 100%; max-height: 85vh; overflow-y: auto; background: var(--panel); border: 1px solid var(--line);
  border-top: 3px solid var(--accent); border-radius: 10px; box-shadow: 0 20px 50px rgba(0,0,0,.6); }
.modal.wide { width: 560px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px 0; }
.modal-head h2 { margin: 0; }
.modal-x { background: none; border: 0; color: var(--muted); font-size: 1.5rem; line-height: 1; cursor: pointer; }
.modal-x:hover { color: var(--ink); }
.modal-body { padding: 10px 18px 18px; }
.modal-confirm { display: flex; flex-direction: column; gap: 6px; margin: 12px 0; }
.modal-confirm input { padding: 8px 10px; border-radius: 6px; border: 1px solid var(--line); background: var(--panel-2); color: var(--ink); font: inherit; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }
.btn.danger-fill { background: #b3261e; border-color: #b3261e; color: #fff; }
.btn.danger-fill:disabled { opacity: .45; cursor: not-allowed; }
.card-head-actions { display: flex; gap: 8px; align-items: center; }

/* character trash */
.trash-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.trash-actions { display: flex; gap: 6px; flex-shrink: 0; }

/* admin "viewing as" banner */
.impersonation-bar { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; justify-content: center; gap: 12px;
  flex-wrap: wrap; padding: 8px 16px; background: #7a0c0a; color: #fff; font: 500 .9rem Roboto, Helvetica, sans-serif; }
.impersonation-bar .btn { background: #fff; color: #7a0c0a; border-color: #fff; }
body.impersonating .topbar { top: 42px; }

/* "Back to…" on knowledge-base pages (embed.js) */
.kb-back { position: sticky; top: 8px; z-index: 25; display: inline-flex; align-items: center; gap: 6px; max-width: 100%;
  margin: 0 0 10px; padding: 6px 14px 6px 10px; border: 1px solid var(--line); border-radius: 999px; background: var(--panel-2);
  color: var(--ink); font: 500 .85rem Roboto, Helvetica, sans-serif; cursor: pointer; box-shadow: 0 4px 12px rgba(0,0,0,.35); }
.kb-back:hover { border-color: var(--accent); }
.kb-back span { color: var(--accent-text); font-size: 1rem; }
.kb-back strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 50vw; }

/* privacy page */
.privacy-card { max-width: 620px; text-align: left; }
.privacy-card h2 { font-size: 1.05rem; margin-top: 18px; }
.privacy-card li { margin-bottom: 6px; }

/* approval: waiting page and the admin Users page */
.pending-card h2 { margin-top: 6px; }
.attest { display: flex; flex-direction: column; gap: 12px; align-items: center; margin: 14px 0; }
.attest-box { display: flex; gap: 10px; align-items: flex-start; text-align: left; cursor: pointer; }
.attest-box input { margin-top: 4px; width: 18px; height: 18px; accent-color: var(--accent); flex: none; }
.user-table { width: 100%; border-collapse: collapse; margin-top: 10px; }
.user-table th { text-align: left; font: 600 .8rem "Roboto Condensed", Roboto, sans-serif; text-transform: uppercase; color: var(--muted); padding: 6px 8px; border-bottom: 1px solid var(--line); }
.user-table td { padding: 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.user-table tr.u-pending { background: rgba(196,30,26,.06); }
.u-who { display: flex; align-items: center; gap: 10px; }
.u-who img { width: 32px; height: 32px; border-radius: 50%; }
.u-who div { display: flex; flex-direction: column; }
.u-actions { white-space: nowrap; text-align: right; }
.chip.ok { color: var(--skill); } .chip.warn { color: var(--accent-text); }
.tok-hot { color: var(--accent-text); font-weight: 700; }
.quota-cell { white-space: nowrap; } .quota-cell .btn { margin-left: 6px; }
.quota-field { display: grid; grid-template-columns: 1fr 150px auto; align-items: center; gap: 10px; margin: 10px 0; }
.quota-field input[type=number] { padding: 6px 8px; border-radius: 6px; border: 1px solid var(--line); background: var(--panel-2); color: var(--ink); }
.quota-field label { display: flex; gap: 6px; align-items: center; white-space: nowrap; }
.activity-head { margin-top: 24px; font-size: 1rem; }
.activity { list-style: none; padding: 0; margin: 0; font-size: .88rem; } .activity li { padding: 4px 0; border-bottom: 1px solid var(--line); }
.alog { display: flex; flex-direction: column; gap: 6px; }
.alog-row { border: 1px solid var(--line); border-radius: 8px; background: var(--panel-2); }
.alog-row > summary { cursor: pointer; padding: 8px 12px; display: grid; grid-template-columns: 150px 1fr; gap: 2px 12px; list-style: none; }
.alog-row > summary::-webkit-details-marker { display: none; }
.alog-q { font-weight: 600; overflow-wrap: anywhere; } .alog-stats { grid-column: 2; color: var(--muted); }
.alog-err { border-color: var(--accent); } .alog-errtag { color: var(--accent-text); }
.alog-body { padding: 4px 14px 12px; border-top: 1px solid var(--line); }
.alog-body h4 { margin: 10px 0 4px; font-size: .8rem; text-transform: uppercase; color: var(--muted); letter-spacing: .04em; }
.alog-tools { margin: 0; padding-left: 20px; } .alog-tools li { margin-bottom: 6px; }
.alog-tools pre { margin: 2px 0; padding: 6px 8px; background: var(--bg); border-radius: 4px; font-size: 12px; white-space: pre-wrap; overflow-wrap: anywhere; }
.alog-res { white-space: pre-wrap; overflow-wrap: anywhere; max-height: 6em; overflow: hidden; }
@media screen and (max-width: 700px) { .alog-row > summary { grid-template-columns: 1fr; } .alog-stats { grid-column: 1; } }
.review-head h1 { margin: 0; } .review-head img { width: 48px; height: 48px; }
.admin-review h2 { margin-top: 26px; }
.day-chip { display: inline-block; margin: 2px 8px 2px 0; padding: 1px 8px; border: 1px solid var(--line); border-radius: 999px; }
.review-filter a { text-decoration: none; } .review-filter a.on { color: var(--ink); font-weight: 700; }
.review-chat { display: flex; flex-direction: column; gap: 8px; max-height: 70vh; overflow-y: auto; padding: 4px; }
.review-msg { border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; background: var(--panel-2); }
.review-msg.r-user { border-left: 3px solid var(--accent); }
.review-meta { display: flex; justify-content: space-between; gap: 10px; font-size: .8rem; margin-bottom: 4px; }
.review-msg.r-cleared { opacity: .7; border-style: dashed; }
.cleared-chip { color: var(--accent-text); border-color: var(--accent); font-weight: 600; margin-left: 6px; }
.review-body { white-space: pre-wrap; font-size: .9rem; overflow-wrap: anywhere; }
@media screen and (max-width: 700px) { .admin-users .user-table th:nth-child(n+4):nth-child(-n+7), .admin-users .user-table td:nth-child(n+4):nth-child(-n+7) { display: none; } }

/* admin Users page: one card per person */
.admin-users { max-width: 1200px; }
.au-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 8px; }
.au-head h1 { margin: 0 0 2px; }
.au-head p { margin: 0; }
.au-counts { display: flex; gap: 14px; color: var(--muted); } .au-counts b { color: var(--ink); font-size: 1.2rem; }
.au-link { background: none; border: 0; padding: 0; color: var(--link); cursor: pointer; font: inherit; }
.au-link:hover { text-decoration: underline; }
.au-help ul { margin: 0; padding-left: 18px; } .au-help li { margin: 4px 0; }
.au-section { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 20px 0 8px; }
.au-list { display: flex; flex-direction: column; gap: 8px; }
.au-row { display: grid; grid-template-columns: minmax(200px, 1.6fr) minmax(150px, 1fr) minmax(140px, .9fr) minmax(220px, 1.4fr) 285px;
  gap: 14px 18px; align-items: center; padding: 12px 14px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; }
.au-row.au-waiting { border-left: 3px solid var(--accent); }
.au-who { display: flex; align-items: center; gap: 10px; min-width: 0; }
.au-who img, .au-initial { width: 38px; height: 38px; border-radius: 50%; flex: none; }
.au-initial { display: flex; align-items: center; justify-content: center; background: var(--panel-2); color: var(--muted); font-weight: 700; }
.au-who div { display: flex; flex-direction: column; min-width: 0; }
.au-who strong, .au-who span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.au-state { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; }
.au-note { font-size: .78rem; }
.au-stats { display: flex; flex-direction: column; gap: 2px; font-size: .85rem; }
.au-stats b { font-size: .95rem; }
.au-quota { display: flex; flex-direction: column; gap: 4px; font-size: .8rem; }
.au-meter { display: grid; grid-template-columns: 26px 1fr auto; align-items: center; gap: 8px; }
.au-meter-label { color: var(--muted); }
.au-meter-bar { height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; }
.au-meter-bar i { display: block; height: 100%; background: var(--skill); }
.au-meter.over .au-meter-bar i { background: var(--accent); } .au-meter.over .au-meter-val { color: var(--accent-text); font-weight: 700; }
.au-meter-val { white-space: nowrap; font-variant-numeric: tabular-nums; }
.au-quota .au-link { align-self: flex-start; font-size: .8rem; }
.au-actions { display: flex; gap: 6px; align-items: center; justify-content: flex-end; }
.au-actions .btn { white-space: nowrap; }
.au-more { position: relative; }
.au-more-menu { position: absolute; right: 0; top: calc(100% + 6px); z-index: 20; min-width: 240px; padding: 6px; background: var(--panel);
  border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 10px 30px rgba(0,0,0,.5); }
.au-more-menu button { display: block; width: 100%; text-align: left; padding: 8px 10px; border: 0; border-radius: 5px; background: none;
  color: var(--ink); font: inherit; font-size: .9rem; cursor: pointer; }
.au-more-menu button:hover:not(:disabled) { background: var(--panel-2); }
.au-more-menu button:disabled { color: var(--muted); cursor: default; }
.au-more-menu button.danger { color: var(--accent-text); }
.au-activity { margin-top: 20px; } .au-activity summary { cursor: pointer; font-weight: 600; }
.au-activity .activity { margin-top: 10px; } .au-activity time { color: var(--muted); font-size: .85rem; }
.au-row { grid-template-areas: "who state stats quota actions"; }
.au-who { grid-area: who; } .au-state { grid-area: state; } .au-stats { grid-area: stats; } .au-quota { grid-area: quota; } .au-actions { grid-area: actions; }
@media screen and (max-width: 1100px) {   /* name + actions on top; status, numbers and usage underneath */
  .au-row { grid-template-columns: minmax(150px, 1fr) minmax(130px, .9fr) minmax(220px, 1.4fr);
    grid-template-areas: "who who actions" "state stats quota"; }
}
@media screen and (max-width: 700px) {
  .au-row { grid-template-columns: 1fr; grid-template-areas: "who" "state" "stats" "quota" "actions"; }
  .au-actions { justify-content: flex-start; flex-wrap: wrap; }
  .au-stats { flex-direction: row; flex-wrap: wrap; gap: 4px 12px; }
}

/* character picture tab and list thumbnails */
.picture-pane { padding: 0; }
.pic-bar { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.pic-frame { display: flex; justify-content: center; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 16px; }
.pic-frame img { max-width: 100%; max-height: calc(100vh - var(--topbar-h, 60px) - 200px); border-radius: 4px; box-shadow: 0 6px 24px rgba(0,0,0,.5); }
.picture-pane.dropping .pic-frame { border: 2px dashed var(--accent); }
.char-row { display: flex; align-items: center; gap: 12px; }
.char-thumb { width: 44px; height: 44px; flex: none; border-radius: 8px; object-fit: cover; border: 1px solid var(--line); background: var(--panel-2); }
.char-thumb-empty { display: flex; align-items: center; justify-content: center; color: var(--muted); font: 600 18px "Roboto Condensed", Roboto, sans-serif; }

/* Dark sheet (the default): the printed sheet with its colours inverted, so the paper is black and
   the lines and writing white. hue-rotate turns reds and blues back to their own hues. */
body.sheet-dark #sheet .page:not(.notes-pane) { filter: invert(1) hue-rotate(180deg); box-shadow: 0 0 0 1px #3a3a3a; }
body.sheet-dark #sheet .page img:not(.paper-page > img) { filter: invert(1) hue-rotate(180deg); }  /* photos stay photos */

/* Printing a character: just its two sheet pages, one per letter-size sheet of paper. */
@media print {
  @page { size: letter; margin: .4in; }
  :root { color-scheme: light; }
  html, body { background: #fff !important; }
  .sheet-wrap { background: none !important; border: 0 !important; padding: 0 !important; }
  body.char-page, body.char-page main { height: auto !important; overflow: visible !important; display: block !important; }
  body.sheet-dark #sheet .page, body.sheet-dark #sheet .page img { filter: none !important; }  /* paper is always light */
  body > :not(main), .sheet-top, .paper-tools, #warnings, .preview-bar, #pnotes, .sheet-wrap > :not(.sheet-col),
  #paper-selects, .kg-peek, .kg-tip, .info-pip { display: none !important; }
  main { max-width: none !important; margin: 0 !important; padding: 0 !important; }
  .sheet-wrap, .sheet-col, .cs-fit { display: block !important; overflow: visible !important; }
  /* Like printing the official PDF "scaled to fit": each 1040x1346px page shrinks to about
     7.4 x 9.5 inches, which fits inside the margins (and Safari's headers and footers) of a
     letter sheet, so the two pages print as exactly two pages. */
  #sheet { zoom: .68 !important; width: 1040px !important; display: block !important; margin: 0 auto !important; }
  #sheet > #p1, #sheet > #p2, #sheet > #p1[hidden], #sheet > #p2[hidden] { display: block !important; }
  #sheet > #p3 { display: none !important; }
  #sheet > .page { width: 1040px !important; margin: 0 !important; box-shadow: none !important; break-after: page; break-inside: avoid;
    -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  #sheet > #p2 { break-after: auto; }
  /* on-screen controls don't belong on paper */
  .pp-layer .padd, .pp-layer .phint, .pp-layer .ptog, .phot { display: none !important; }
  .pp-layer a.kg-link { border-bottom: 0 !important; }
}

/* ---------------- phones ---------------- */
.phone-only { display: none !important; }
/* screen only: Safari treats a printed page as ~700px wide, and these must never apply to paper */
@media screen and (max-width: 700px) {
  .phone-only { display: block !important; }
  .account-logout { display: none !important; }       /* Log out moves into the account menu */
  .account-toggle { border-radius: 6px; margin-left: 0; padding: 8px 10px; }
  main { padding: 12px 10px 80px; }
  /* top bar: logo, Menu, search and account on one row; the tabs get a scrolling row of their own */
  .topbar { flex-wrap: wrap; gap: 8px; padding: 6px 10px 0; min-height: 0; }
  .brand img { height: 32px; }
  .bar-btn { padding: 6px 9px; }
  .topbar-right { flex: 1 1 0; min-width: 0; max-width: none; gap: 6px; }
  .topbar .search input { padding: 6px 8px; font-size: 16px; }   /* 16px stops iOS zooming into the field */
  .account-logout { padding: 6px 8px; }
  .char-tabs { order: 3; flex: 1 0 100%; margin-left: 0; padding-top: 2px; }
  .char-tab { max-width: 160px; }
  .search-pop { width: calc(100vw - 20px); right: -60px; }
  /* character page: tabs and buttons in single rows you scroll sideways */
  .sheet-top { flex-wrap: nowrap; flex-direction: column; align-items: stretch; gap: 8px; }
  .sheet-top .sheet-actions { order: -1; }   /* tabs last, so the active one sits on the panel */
  .sheet-wrap { padding: 8px; border-radius: 0 0 8px 8px; }
  .tabs, .sheet-actions, .paper-tools { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .tabs::-webkit-scrollbar, .sheet-actions::-webkit-scrollbar, .paper-tools::-webkit-scrollbar { display: none; }
  .tabs > *, .sheet-actions > *, .paper-tools > * { flex-shrink: 0; }
  .tab { padding: 7px 11px; font-size: .8rem; white-space: nowrap; }
  .sheet-actions .btn { padding: 6px 10px; font-size: .82rem; white-space: nowrap; }
  .paper-tools { padding: 6px 8px; gap: 8px; }
  .pt-zoom { margin-left: 0; }
  .pt-zoom input[type=range] { width: 90px; }
  .adv-panel { min-width: 0 !important; }
  h1 { font-size: 1.4rem; }
}
