/**
 * theme.css - SimulacrumVTT visual identity ("lantern & brass").
 *
 * Loaded after spine.html's inline structural stylesheet, so it only restyles:
 * typography, surfaces, chrome and component skins. Layout geometry (positions,
 * sizes the canvas math depends on) stays in spine.html. Every rule here is
 * scoped to the default dark theme or to theme-neutral tokens, so the light and
 * high-contrast themes in spine.html keep winning where they set a token.
 *
 * Fonts are vendored (static/vendor/fonts, SIL OFL 1.1) so an offline client
 * renders the same face it renders online.
 */

@font-face {
  font-family: "Cinzel"; font-style: normal; font-display: swap; font-weight: 400 900;
  src: url("/static/vendor/fonts/cinzel-5.3.0-latin-wght.woff2") format("woff2");
}
@font-face {
  font-family: "Inter"; font-style: normal; font-display: swap; font-weight: 100 900;
  src: url("/static/vendor/fonts/inter-5.3.0-latin-wght.woff2") format("woff2");
}

:root {
  --font-display: "Cinzel", "Trajan Pro", Georgia, serif;
  --font-body: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --brass: #d9a85b;
  --brass-hi: #f3d08c;
  --brass-lo: #8a6430;
  --ember: #f08833;
  --ink-deep: #07080b;
  /* Fine film grain, inlined so it costs no request and works offline. */
  --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 .9 0 0 0 0 .75 0 0 0 .05 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
html:not([data-theme]), html[data-theme="dark"] {
  --bg: #0a0b0f;
  --panel: rgba(17, 16, 20, 0.88);
  --panel-solid: #15141a;
  --card: rgba(30, 27, 31, 0.78);
  --ink: #f2ece0;
  --mute: #a39b8d;
  --line: rgba(217, 168, 91, 0.16);
  --line-strong: rgba(217, 168, 91, 0.38);
  --gold: #e6bd72;
  --accent: #f08833;
  --accent-soft: rgba(240, 136, 51, 0.16);
  --accent-glow: rgba(240, 136, 51, 0.30);
  --shadow: 0 14px 40px rgba(0, 0, 0, 0.66), 0 1px 0 rgba(255, 236, 200, 0.04) inset;
}

body { font-family: var(--font-body); font-feature-settings: "cv11", "ss01"; }
h1, h2, .brand-title, .vtt-win-title, .setup-hero h1 { font-family: var(--font-display); }
h1 { letter-spacing: .04em; font-weight: 700; }
h2 {
  font-size: .74rem; letter-spacing: .14em; font-weight: 700; color: var(--gold);
  display: flex; align-items: center; gap: .5rem;
}
/* A hairline flourish after section titles, so panels read as bound pages, not forms. */
aside h2::after, .landing-col h2::after, .vtt-modal-card h2::after {
  content: ""; flex: 1; height: 1px; min-width: 1rem;
  background: linear-gradient(90deg, var(--line-strong), transparent);
}

/* ---------- surfaces ---------- */
html:not([data-theme]) body.in-world, html[data-theme="dark"] body.in-world {
  background:
    radial-gradient(ellipse 70% 60% at 45% 45%, rgba(240, 136, 51, 0.07), transparent 70%),
    radial-gradient(ellipse at 50% 42%, #1a1720 0%, #0a0a0e 72%, #050507 100%);
}
/* No full-screen grain overlay in-world: a blended fixed layer over the canvas costs
   a composite every frame. The grain lives on the scene floor instead (board-ui.mjs). */
:where(html:not([data-theme="light"]):not([data-theme="high-contrast"])) .hud-pill,
:where(html:not([data-theme="light"]):not([data-theme="high-contrast"])) #scene-nav,
:where(html:not([data-theme="light"]):not([data-theme="high-contrast"])) .icon-btn,
:where(html:not([data-theme="light"]):not([data-theme="high-contrast"])) nav.palette .palette-col,
:where(html:not([data-theme="light"]):not([data-theme="high-contrast"])) #sub-palette,
:where(html:not([data-theme="light"]):not([data-theme="high-contrast"])) aside,
:where(html:not([data-theme="light"]):not([data-theme="high-contrast"])) #players-box,
:where(html:not([data-theme="light"]):not([data-theme="high-contrast"])) #bottom-bar > *,
:where(html:not([data-theme="light"]):not([data-theme="high-contrast"])) .board-bar,
:where(html:not([data-theme="light"]):not([data-theme="high-contrast"])) #token-hud,
:where(html:not([data-theme="light"]):not([data-theme="high-contrast"])) .placeable-hud {
  background-image: linear-gradient(180deg, rgba(255, 240, 214, 0.045), rgba(255, 240, 214, 0) 40%);
}
:where(html:not([data-theme="light"]):not([data-theme="high-contrast"])) aside { border-color: var(--line-strong) !important; }
:where(html:not([data-theme="light"]):not([data-theme="high-contrast"])) aside section > section,
:where(html:not([data-theme="light"]):not([data-theme="high-contrast"])) .aside-card {
  background: linear-gradient(180deg, rgba(36, 31, 34, 0.80), rgba(22, 20, 25, 0.80));
  border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 1px 0 rgba(255, 236, 200, 0.05) inset, 0 6px 18px rgba(0, 0, 0, 0.35);
}
:where(html:not([data-theme="light"]):not([data-theme="high-contrast"])) #board { box-shadow: 0 30px 90px rgba(0, 0, 0, 0.85), 0 0 0 1px rgba(217, 168, 91, 0.22), 0 0 0 6px rgba(10, 9, 12, 0.85), 0 0 0 7px rgba(217, 168, 91, 0.14); }

/* ---------- controls ---------- */
:where(html:not([data-theme="light"]):not([data-theme="high-contrast"])) button {
  background: linear-gradient(180deg, rgba(58, 50, 52, 0.92), rgba(34, 30, 34, 0.92));
  border-color: rgba(217, 168, 91, 0.22);
  box-shadow: 0 1px 0 rgba(255, 236, 200, 0.07) inset, 0 1px 2px rgba(0, 0, 0, 0.4);
  font-weight: 550; letter-spacing: .01em;
}
:where(html:not([data-theme="light"]):not([data-theme="high-contrast"])) button:hover:not(:disabled) {
  background: linear-gradient(180deg, rgba(78, 64, 58, 0.95), rgba(46, 38, 38, 0.95));
  border-color: var(--brass);
  color: #fff6e6;
}
:where(html:not([data-theme="light"]):not([data-theme="high-contrast"])) button:active:not(:disabled) { transform: translateY(1px); box-shadow: 0 0 0 rgba(0,0,0,0) inset; }
/* Primary actions: the one thing a panel exists to do. */
button.primary,
#world-new,
#join-go,
#combat-start,
#chat-form > button,
.world-launch,
#profile-form > button,
#name-prompt button:first-of-type {
  background: linear-gradient(180deg, #f39a4c, #c9631c);
  color: #1b0f05; border-color: #ffb877; font-weight: 700;
  text-shadow: 0 1px 0 rgba(255, 220, 180, 0.35);
  box-shadow: 0 1px 0 rgba(255, 230, 200, 0.45) inset, 0 4px 14px rgba(240, 136, 51, 0.25);
}
button.primary:hover:not(:disabled),
#world-new:hover:not(:disabled),
#join-go:hover:not(:disabled),
#combat-start:hover:not(:disabled),
#chat-form > button:hover:not(:disabled),
.world-launch:hover:not(:disabled),
#profile-form > button:hover:not(:disabled) {
  background: linear-gradient(180deg, #ffad62, #d86f24); color: #1b0f05; border-color: #ffd2a3;
}
:where(html:not([data-theme="light"]):not([data-theme="high-contrast"])) input,
:where(html:not([data-theme="light"]):not([data-theme="high-contrast"])) select,
:where(html:not([data-theme="light"]):not([data-theme="high-contrast"])) textarea {
  background: rgba(8, 8, 11, 0.78);
  border-color: rgba(217, 168, 91, 0.18);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.45) inset;
}
:where(html:not([data-theme="light"]):not([data-theme="high-contrast"])) input::placeholder,
:where(html:not([data-theme="light"]):not([data-theme="high-contrast"])) textarea::placeholder { color: rgba(163, 155, 141, 0.7); }
:where(html:not([data-theme="light"]):not([data-theme="high-contrast"])) input[type=range] { accent-color: var(--accent); box-shadow: none; background: transparent; border: none; }
:where(html:not([data-theme="light"]):not([data-theme="high-contrast"])) input[type=file] { padding: .2rem; font-size: .78rem; }
:where(html:not([data-theme="light"]):not([data-theme="high-contrast"])) input[type=file]::file-selector-button {
  font: inherit; color: var(--ink); cursor: pointer; margin-right: .5rem;
  background: linear-gradient(180deg, rgba(58, 50, 52, 0.92), rgba(34, 30, 34, 0.92));
  border: 1px solid rgba(217, 168, 91, 0.25); border-radius: 6px; padding: .2rem .55rem;
}
:where(html:not([data-theme="light"]):not([data-theme="high-contrast"])) ::-webkit-scrollbar { width: 9px; height: 9px; }
:where(html:not([data-theme="light"]):not([data-theme="high-contrast"])) ::-webkit-scrollbar-thumb { background: rgba(217, 168, 91, 0.22); border-radius: 9px; border: 2px solid transparent; background-clip: padding-box; }
:where(html:not([data-theme="light"]):not([data-theme="high-contrast"])) ::-webkit-scrollbar-thumb:hover { background-color: rgba(217, 168, 91, 0.4); }
:where(html:not([data-theme="light"]):not([data-theme="high-contrast"])) ::-webkit-scrollbar-track { background: transparent; }
:where(html:not([data-theme="light"]):not([data-theme="high-contrast"])) * { scrollbar-color: rgba(217, 168, 91, 0.25) transparent; }

/* ---------- top HUD & palette ---------- */
:where(html:not([data-theme="light"]):not([data-theme="high-contrast"])) .hud-pill h1 { font-family: var(--font-display); color: var(--brass-hi); font-size: .95rem; }
.hud-pill h1 { font-family: var(--font-display); font-size: .95rem; }
:where(html:not([data-theme="light"]):not([data-theme="high-contrast"])) .nav-pill { font-family: var(--font-display); letter-spacing: .05em; font-weight: 700; }
:where(html:not([data-theme="light"]):not([data-theme="high-contrast"])) .nav-pill.active {
  color: #1b0f05; background: linear-gradient(180deg, #f3c27a, #c98d3f); border-color: #ffdca0;
  box-shadow: 0 0 14px rgba(217, 168, 91, 0.35);
}
:where(html:not([data-theme="light"]):not([data-theme="high-contrast"])) .icon-btn:hover,
:where(html:not([data-theme="light"]):not([data-theme="high-contrast"])) nav.palette button:hover { color: var(--brass-hi); border-color: var(--brass); }
:where(html:not([data-theme="light"]):not([data-theme="high-contrast"])) nav.palette button[aria-pressed=true],
:where(html:not([data-theme="light"]):not([data-theme="high-contrast"])) #tabs [role=tab][aria-selected=true] {
  color: #fff3dc;
  background: radial-gradient(circle at 50% 30%, rgba(240, 136, 51, 0.55), rgba(140, 66, 18, 0.35) 70%);
  border-color: #f3b06a;
  box-shadow: 0 0 0 1px rgba(255, 190, 120, 0.25) inset, 0 0 14px rgba(240, 136, 51, 0.35);
}

/* ---------- sidebar tabs ---------- */
:where(html:not([data-theme="light"]):not([data-theme="high-contrast"])) #tabs { border-bottom: 1px solid var(--line-strong) !important; background: linear-gradient(180deg, rgba(0,0,0,.25), transparent); }
:where(html:not([data-theme="light"]):not([data-theme="high-contrast"])) #tabs [role=tab] { color: #b6ab98; }
:where(html:not([data-theme="light"]):not([data-theme="high-contrast"])) #tabs [role=tab]:hover { color: var(--brass-hi); }

/* ---------- directories (Actors / Items / Journal / Compendium) ---------- */
.dir-header-actions { display: grid; grid-template-columns: 1fr 1fr; gap: .35rem; margin-bottom: .45rem; }
.dir-header-actions button { display: flex; align-items: center; justify-content: center; gap: .35rem; }
.dir-row { padding: .3rem .4rem; gap: .55rem; border-radius: 8px; }
.dir-row:hover { background: linear-gradient(90deg, rgba(217, 168, 91, 0.12), rgba(217, 168, 91, 0.02)); border-color: var(--line); }
.dir-thumb {
  width: 34px; height: 34px; flex: none; border-radius: 6px; overflow: hidden; position: relative;
  display: grid; place-items: center; font-family: var(--font-display); font-weight: 700; font-size: .95rem;
  color: #fff3dc; text-shadow: 0 1px 2px rgba(0,0,0,.7);
  background: linear-gradient(135deg, hsl(var(--h, 30) 45% 32%), hsl(var(--h, 30) 50% 16%));
  border: 1px solid rgba(217, 168, 91, 0.35); box-shadow: 0 2px 6px rgba(0, 0, 0, 0.45);
}
.dir-thumb img { position: absolute; inset: 0; width: 100% !important; height: 100% !important; border-radius: 0 !important; object-fit: cover; }
.dir-open {
  flex: 1; min-width: 0; text-align: left; background: none !important; border: none !important; box-shadow: none !important;
  padding: .15rem 0; font-weight: 600; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.dir-open:hover { color: var(--brass-hi) !important; }
.dir-more,
.doc-del { opacity: .35; background: none !important; border-color: transparent !important; box-shadow: none !important; padding: .15rem .35rem; }
.dir-row:hover .dir-more,
.dir-row:hover .doc-del,
.dir-more:focus-visible,
.doc-del:focus-visible { opacity: 1; }
:where(html:not([data-theme="light"]):not([data-theme="high-contrast"])) .dir-folder { border-radius: 8px; background: rgba(0, 0, 0, 0.18); margin: .2rem 0; padding: .1rem .1rem .1rem .25rem; }
.dir-folder-btn {
  text-align: left; background: none !important; border: none !important; box-shadow: none !important;
  font-family: var(--font-display); font-weight: 700; letter-spacing: .04em; color: var(--brass-hi);
}
.dir-empty {
  list-style: none; text-align: center; padding: 1.1rem .5rem; color: var(--mute); font-size: .8rem;
  border: 1px dashed var(--line-strong); border-radius: 10px; background: rgba(0, 0, 0, 0.15);
}
.dir-empty b { display: block; font-family: var(--font-display); color: var(--gold); font-size: .9rem; margin-bottom: .15rem; }

/* ---------- chat ---------- */
:where(html:not([data-theme="light"]):not([data-theme="high-contrast"])) #chat li {
  background: linear-gradient(180deg, rgba(34, 30, 33, 0.9), rgba(20, 18, 22, 0.9));
  border: 1px solid rgba(217, 168, 91, 0.14); border-radius: 9px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
}
#chat .roll-card {
  background: linear-gradient(180deg, rgba(56, 36, 22, 0.85), rgba(30, 21, 16, 0.85));
  border-color: rgba(240, 136, 51, 0.4);
}
:where(html:not([data-theme="light"]):not([data-theme="high-contrast"])) #chat .chat-whisper { border-style: dashed; }

/* ---------- windows & modals ---------- */
:where(html:not([data-theme="light"]):not([data-theme="high-contrast"])) .vtt-win,
:where(html:not([data-theme="light"]):not([data-theme="high-contrast"])) .vtt-modal-card,
:where(html:not([data-theme="light"]):not([data-theme="high-contrast"])) #popout-win {
  border: 1px solid var(--line-strong) !important;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.75), 0 0 0 1px rgba(0, 0, 0, 0.6), 0 1px 0 rgba(255, 236, 200, 0.06) inset !important;
}
:where(html:not([data-theme="light"]):not([data-theme="high-contrast"])) .vtt-win-hdr,
:where(html:not([data-theme="light"]):not([data-theme="high-contrast"])) #popout-hdr {
  background: linear-gradient(180deg, rgba(74, 52, 34, 0.75), rgba(34, 26, 22, 0.75)) !important;
  border-bottom: 1px solid var(--line-strong) !important;
}
:where(html:not([data-theme="light"]):not([data-theme="high-contrast"])) .vtt-win-title { color: var(--brass-hi); letter-spacing: .05em; font-weight: 700; }
:where(html:not([data-theme="light"]):not([data-theme="high-contrast"])) #vtt-modal { backdrop-filter: blur(3px) saturate(.8); }
:where(html:not([data-theme="light"]):not([data-theme="high-contrast"])) .toast { border-color: var(--line-strong) !important; font-weight: 600; }

/* ---------- settings sidebar: Foundry-style stacked full-width actions ---------- */
.game-details { display: grid; grid-template-columns: auto 1fr; gap: .2rem .7rem; font-size: .8rem; margin: 0; }
.game-details dt { color: var(--mute); }
.game-details dd { margin: 0; color: var(--ink); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.settings-stack { display: grid !important; gap: .32rem !important; }
.settings-stack > button {
  width: 100%; display: flex; align-items: center; gap: .6rem; justify-content: flex-start;
  padding: .45rem .7rem; text-align: left;
}
.settings-stack > button svg.ico { color: var(--gold); width: 16px; height: 16px; }

/* ---------- setup screen ---------- */
:where(html:not([data-theme="light"]):not([data-theme="high-contrast"])) body:not(.in-world) {
  background:
    radial-gradient(ellipse 80% 50% at 50% -10%, rgba(240, 136, 51, 0.18), transparent 70%),
    radial-gradient(ellipse at 50% 120%, rgba(90, 60, 120, 0.16), transparent 60%),
    #0a0a0e;
  background-attachment: fixed;
}
:where(html:not([data-theme="light"]):not([data-theme="high-contrast"])) body:not(.in-world)::before {
  content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background-image: var(--grain); mix-blend-mode: overlay;
}
:where(html:not([data-theme="light"]):not([data-theme="high-contrast"])) .setup-hdr {
  position: sticky; top: 0; z-index: 5;
  background: linear-gradient(180deg, rgba(14, 12, 16, 0.96), rgba(14, 12, 16, 0.86)) !important;
  backdrop-filter: blur(10px); border-bottom: 1px solid var(--line-strong) !important;
}
:where(html:not([data-theme="light"]):not([data-theme="high-contrast"])) .setup-hdr h1 { font-size: 1.15rem; color: var(--brass-hi); letter-spacing: .08em; }
:where(html:not([data-theme="light"]):not([data-theme="high-contrast"])) .setup-tabs [role=tab] { font-family: var(--font-display); font-weight: 700; letter-spacing: .05em; }
:where(html:not([data-theme="light"]):not([data-theme="high-contrast"])) .setup-tabs [role=tab][aria-selected=true] {
  color: #1b0f05 !important; background: linear-gradient(180deg, #f3c27a, #c98d3f) !important; border-color: #ffdca0 !important;
}
.setup-hero { position: relative; z-index: 1; text-align: center; padding: 2.4rem 1rem 1.2rem; }
.setup-hero h1 {
  font-size: clamp(1.8rem, 4.5vw, 3rem); letter-spacing: .12em; white-space: normal;
  background: linear-gradient(180deg, #fff1d2, #d9a85b 70%, #9b6c2c); -webkit-background-clip: text; background-clip: text;
  color: transparent; filter: drop-shadow(0 4px 18px rgba(240, 136, 51, 0.25));
}
.setup-hero p { color: var(--mute); margin: .3rem auto 0; max-width: 38rem; }
.setup-hero .sigil { width: 54px; height: 54px; margin: 0 auto .5rem; color: var(--brass); filter: drop-shadow(0 0 12px rgba(240, 136, 51, 0.4)); }
:where(html:not([data-theme="light"]):not([data-theme="high-contrast"])) .landing-main { position: relative; z-index: 1; }
:where(html:not([data-theme="light"]):not([data-theme="high-contrast"])) .landing-col { max-width: 72rem !important; }
:where(html:not([data-theme="light"]):not([data-theme="high-contrast"])) .landing-col > section > section {
  background: linear-gradient(180deg, rgba(30, 26, 30, 0.88), rgba(18, 16, 20, 0.88)) !important;
  border-color: var(--line-strong) !important; border-radius: 14px !important;
}
.world-list.world-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(15.5rem, 1fr)); gap: .9rem; }
.world-grid > li.world-card {
  display: flex; flex-direction: column; align-items: stretch; gap: 0; padding: 0; overflow: hidden;
  border-radius: 12px; border: 1px solid var(--line-strong); background: #121116;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.5); transition: transform .18s ease, box-shadow .18s ease, border-color .18s;
}
.world-grid > li.world-card:hover { transform: translateY(-3px); border-color: var(--brass); box-shadow: 0 16px 36px rgba(0, 0, 0, 0.6), 0 0 22px rgba(240, 136, 51, 0.18); }
.world-art {
  position: relative; height: 8.5rem; display: flex; align-items: flex-end; padding: .7rem .8rem;
  background:
    radial-gradient(circle at 75% 25%, hsla(var(--h, 30), 80%, 60%, .35), transparent 55%),
    linear-gradient(160deg, hsl(var(--h, 30) 40% 26%), hsl(calc(var(--h, 30) + 40) 45% 10%));
  background-size: cover; background-position: center;
}
.world-art::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, transparent 35%, rgba(8, 7, 10, 0.92)); }
.world-art .world-initial {
  position: absolute; right: .7rem; top: .3rem; font-family: var(--font-display); font-size: 3.6rem; font-weight: 900;
  color: rgba(255, 240, 214, 0.14); line-height: 1;
}
.world-art a {
  position: relative; z-index: 1; font-family: var(--font-display); font-size: 1.12rem; font-weight: 700;
  color: #fff3dc !important; letter-spacing: .04em; text-shadow: 0 2px 8px rgba(0, 0, 0, 0.8); text-decoration: none !important;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.world-body { padding: .55rem .8rem .2rem; display: grid; gap: .3rem; min-height: 3.6rem; }
.world-body .world-tags { display: flex; gap: .35rem; flex-wrap: wrap; align-items: center; }
.world-body .world-desc { color: var(--mute); font-size: .78rem; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.world-foot { display: flex; align-items: center; gap: .25rem; padding: .5rem .6rem .65rem; border-top: 1px solid var(--line); margin-top: auto; }
.world-foot .world-launch { flex: 1; white-space: nowrap; min-width: 0; }
:where(html:not([data-theme="light"]):not([data-theme="high-contrast"])) .world-foot button:not(.world-launch) { padding: .3rem .45rem; min-width: 2rem; background: transparent; box-shadow: none; border-color: transparent; color: var(--mute); }
:where(html:not([data-theme="light"]):not([data-theme="high-contrast"])) .world-foot button:not(.world-launch):hover { color: var(--brass-hi); border-color: var(--line-strong); }
:where(html:not([data-theme="light"]):not([data-theme="high-contrast"])) .badge.role-gm { color: var(--brass-hi); border-color: var(--brass); }
:where(html:not([data-theme="light"]):not([data-theme="high-contrast"])) .badge.role-player { color: #9fd7b5; border-color: #3f8f62; }

/* ---------- chat message cards (header + body; roll totals) ---------- */
:where(html:not([data-theme="light"]):not([data-theme="high-contrast"])) #chat li { position: relative; padding: .45rem .6rem .5rem; }
#chat .chat-del { position: absolute; top: .35rem; right: .35rem; float: none; opacity: .35; box-shadow: none; }
#chat li:hover .chat-del { opacity: 1; }
.msg-hdr {
  display: flex; align-items: center; gap: .45rem; padding-bottom: .3rem; margin-bottom: .3rem; padding-right: 1.1rem;
  border-bottom: 1px solid rgba(217, 168, 91, 0.14);
}
.msg-hdr .who { font-family: var(--font-display); font-weight: 700; color: var(--brass-hi); letter-spacing: .03em; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg-av {
  width: 22px; height: 22px; border-radius: 50%; flex: none; display: grid; place-items: center;
  font: 700 .7rem/1 var(--font-display); color: #fff3dc; background: var(--c); box-shadow: 0 0 0 1.5px rgba(255, 236, 200, 0.25), 0 1px 4px rgba(0,0,0,.6);
}
.msg-time { margin-left: auto; font-size: .68rem; color: var(--mute); font-variant-numeric: tabular-nums; white-space: nowrap; }
.msg-hdr .badge { font-size: .6rem; padding: .05em .4em; }
.msg-body { overflow-wrap: anywhere; }
.roll-flavor { font-style: italic; color: var(--gold); font-size: .8rem; margin-bottom: .25rem; }
.roll-formula {
  text-align: center; font-size: .8rem; color: #d9cfbd; padding: .22rem .4rem; border-radius: 6px;
  background: rgba(0, 0, 0, 0.35); border: 1px solid rgba(217, 168, 91, 0.18);
}
.roll-total {
  text-align: center; font: 800 1.55rem/1.15 var(--font-display); color: #fff3dc; margin: .3rem 0 .2rem;
  padding: .2rem; border-radius: 7px; background: linear-gradient(180deg, rgba(240, 136, 51, 0.16), rgba(240, 136, 51, 0.04));
  border: 1px solid rgba(240, 136, 51, 0.35); text-shadow: 0 2px 10px rgba(240, 136, 51, 0.35);
}
.roll-total.crit { color: #9dffbf; border-color: rgba(56, 199, 123, 0.6); background: linear-gradient(180deg, rgba(56, 199, 123, 0.2), rgba(56, 199, 123, 0.04)); text-shadow: 0 0 12px rgba(56, 199, 123, 0.6); }
.roll-total.fumble { color: #ffb0b0; border-color: rgba(232, 93, 93, 0.6); background: linear-gradient(180deg, rgba(232, 93, 93, 0.2), rgba(232, 93, 93, 0.04)); }
.roll-card .roll-details summary { text-align: center; font-size: .72rem; }
.roll-card .roll-hdr { justify-content: center; margin-top: .25rem; }
.roll-card .roll-apply { margin-left: 0; }


/* ---------- scene directory: banner cards (Scenes tab) ---------- */
#scene-thumbs { grid-template-columns: 1fr !important; max-height: none !important; margin-top: 0 !important; gap: .45rem !important; }
.scene-thumb-card {
  height: 64px !important; border-radius: 9px !important; border-color: var(--line-strong) !important;
  background: linear-gradient(135deg, hsl(var(--h, 30) 35% 24%), hsl(calc(var(--h, 30) + 40) 40% 9%)) !important;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.45) !important; display: flex !important; align-items: flex-end;
}
.scene-thumb-card img { opacity: .85 !important; }
.scene-thumb-card::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, transparent 30%, rgba(8, 7, 10, 0.85)); }
.scene-thumb-card span {
  z-index: 2 !important; background: none !important; font-family: var(--font-display); font-size: .86rem !important;
  letter-spacing: .04em; padding: 0 .6rem .45rem !important; color: #fff3dc !important;
}
.scene-thumb-card:hover { border-color: var(--brass) !important; }
.scene-thumb-card.active { border-color: var(--accent) !important; box-shadow: 0 0 0 1px var(--accent), 0 0 16px var(--accent-glow) !important; }
.sc-flags { position: absolute; z-index: 2; top: .35rem; right: .4rem; display: flex; gap: .25rem; font-style: normal; }
.sc-flag {
  font-style: normal; font-size: .6rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em;
  padding: .08rem .4rem; border-radius: 999px; background: rgba(0, 0, 0, 0.6); color: var(--mute); border: 1px solid var(--line-strong);
}
.sc-flag.on { color: #1b0f05; background: linear-gradient(180deg, #f3c27a, #c98d3f); border-color: #ffdca0; }
#scene-thumbs:empty::before {
  content: "No scenes yet. Use + below to create one."; display: block; text-align: center; padding: .9rem .5rem;
  color: var(--mute); font-size: .8rem; border: 1px dashed var(--line-strong); border-radius: 10px;
}

/* Light theme: the sidebar tab strip in spine.html keeps a dark fill; lift it to match. */
html[data-theme="light"] #tabs { background: rgba(226, 231, 240, 0.92); }
html[data-theme="light"] .nav-pill.active { color: #2a1606; }

/* ---------- tokens without art: medallions (colour from --tok-c, set by board-ui.mjs) ---------- */
.token {
  background:
    radial-gradient(circle at 34% 26%, rgba(255, 255, 255, 0.38), transparent 42%),
    radial-gradient(circle at 50% 50%, color-mix(in srgb, var(--tok-c, #4b5d82) 88%, #fff 12%) 0%,
      var(--tok-c, #4b5d82) 52%, color-mix(in srgb, var(--tok-c, #4b5d82) 40%, #000) 100%);
  box-shadow: 0 5px 14px rgba(0, 0, 0, 0.75), inset 0 0 0 2px rgba(0, 0, 0, 0.35), inset 0 -6px 10px rgba(0, 0, 0, 0.35);
}
.token .tok-label { font-family: var(--font-display); font-weight: 800; letter-spacing: .04em; text-shadow: 0 1px 3px rgba(0, 0, 0, 0.85); }
.token .tok-name {
  font-family: var(--font-body); background: linear-gradient(180deg, rgba(30, 24, 22, 0.95), rgba(14, 12, 14, 0.95)) !important;
  border: 1px solid var(--line-strong) !important; color: #fff3dc !important;
}

/* ---------- directory header: create row on top, then search (Foundry order) ---------- */
.dir-create { margin-bottom: .45rem; }
.dir-create button {
  background: linear-gradient(180deg, #f39a4c, #c9631c); color: #1b0f05; border-color: #ffb877; font-weight: 700;
}
.dir-search { display: flex; gap: .3rem; margin-bottom: .55rem; }
.dir-search input { flex: 1; }
.dir-search button { padding: .3rem .5rem; }
.scene-thumb-card video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: .85; pointer-events: none; }


/* System condition icons (CONFIG.statusEffects) in the token HUD and on tokens. */
.hud-cond img { width: 20px; height: 20px; display: block; }
.token .tok-conds img { width: 12px; height: 12px; vertical-align: middle; filter: drop-shadow(0 1px 1px #000); }

/* Wide two-column modal forms (Configure Settings). */
.vtt-modal-card.wide { width: min(94vw, 46rem) !important; }
.set-list { display: grid; gap: .35rem; max-height: 62vh; overflow: auto; padding-right: .3rem; }
.set-group { margin: .6rem 0 .1rem; font-family: var(--font-display); font-size: .8rem; letter-spacing: .08em; color: var(--gold); }
.set-group:first-child { margin-top: 0; }
.set-row { display: grid; grid-template-columns: minmax(0, 1fr) 15rem; gap: .9rem; align-items: center; padding: .5rem .65rem; border: 1px solid var(--line); border-radius: 8px; background: rgba(0, 0, 0, 0.18); }
.set-text { display: grid; gap: .15rem; min-width: 0; }
.set-text .meta { font-size: .76rem; line-height: 1.35; }
.set-ctrl { display: flex; justify-content: flex-end; }
.set-ctrl select, .set-ctrl input:not([type=checkbox]) { width: 100%; max-width: none !important; }
@media (max-width: 640px) { .set-row { grid-template-columns: 1fr; } .set-ctrl { justify-content: flex-start; } }
#token-hud { max-height: calc(100dvh - 16px); overflow-y: auto; }
#token-hud .hud-conds {
  display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: .2rem;
  max-height: 8.6rem; overflow-y: auto; padding: .15rem; border-radius: 8px; background: rgba(0, 0, 0, 0.2);
}
#token-hud .hud-cond { display: grid; place-items: center; padding: .2rem; min-height: 1.9rem; }
#token-hud .hud-cond.active { border-color: var(--accent); background: radial-gradient(circle, rgba(240, 136, 51, 0.45), rgba(240, 136, 51, 0.1)); }
.item-desc { max-height: 14rem; overflow: auto; padding: .5rem .65rem; border: 1px solid var(--line); border-radius: 8px; background: rgba(0, 0, 0, 0.2); font-size: .85rem; line-height: 1.45; }
.item-desc p { margin: 0 0 .45rem; }

/* Sidebar rows: names shrink with an ellipsis, action buttons never clip. */
#panel-placeables .dir-row { flex-wrap: nowrap; }
#panel-placeables .dir-row > .cbt-btn, #panel-placeables .dir-row > button { flex: none; padding: .2rem .4rem; }
.cbt-btn { min-width: 1.8rem; }
/* Compendium pack headers: one-line title, compact icon controls. */
#dir-compendium summary .pack-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 650; }
#dir-compendium summary .pack-title .meta { font-weight: 400; margin-left: .2rem; }
#dir-compendium summary .cbt-btn { flex: none; padding: .15rem .35rem; }

/* Phone: shell windows (fallback sheets, journals, popouts) fill the width under the HUD
   instead of keeping desktop coordinates that run off-screen. */
@media (max-width: 640px) {
  .vtt-win:not(.minimized) {
    left: 4px !important; right: 4px !important; top: 52px !important;
    width: auto !important; max-width: none !important;
    max-height: calc(100dvh - 52px - 72px) !important;
  }
  .vtt-win .vtt-win-body { overflow: auto; }
}

/* Dropped dice on roll cards (advantage, drop-lowest): struck and dimmed; the strike and the
   "dropped" label carry the meaning, the dimming only reinforces it. */
.roll-card .die-dropped { opacity: .55; text-decoration-thickness: 2px; }
.roll-card.roll-hidden .roll-total { letter-spacing: .2em; opacity: .8; }

/* Touch ergonomics (GOAL.md UXP-2; owner requirement 2026-11-25: phones are first-class, unlike
   Foundry). On a coarse pointer every shell control is at least 40px tall, icon buttons 40x40,
   checkboxes get a 40px label hit area. The board's own placeables (tokens, handles, pins) keep
   their map-scaled sizes and are excluded. */
@media (pointer: coarse) {
  :is(button, select, summary, [role="button"],
      input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]):not([type="hidden"])):not(#board *) {
    min-height: 40px;
  }
  :is(.icon-btn, .nav-pill, #aside-close, .vtt-win-close, #vtt-modal-close):not(#board *) { min-width: 40px; min-height: 40px; }
  input[type="checkbox"], input[type="radio"] { width: 22px; height: 22px; }
  label:has(> input[type="checkbox"], > input[type="radio"]) { min-height: 40px; display: inline-flex; align-items: center; gap: .45rem; }
  input[type="color"] { min-width: 40px; min-height: 40px; }
}
