:root { color-scheme: dark; font: 17px/1.5 system-ui, sans-serif; background: #171b20; color: #f4f1e8; }
/* Shared typography scale. Keep the root rem size for existing layout dimensions. */
:root {
    --font-small: 8pt;
    --font-normal: 11pt;
    --font-heading: 14pt;
    --font-icon: 14pt;
}
body { margin: 0; font-size: var(--font-normal); }
h1, h2, h3, h4, h5, h6, legend { font-size: var(--font-heading); }
small, sub, sup { font-size: var(--font-small); }
input, select, textarea, button, input::file-selector-button { font-size: var(--font-normal); }
main { box-sizing: border-box; width: min(100%, 72rem); margin: 3rem auto; padding: 0 1.25rem; }
h1, h2 { line-height: 1.2; }
section, .panel { padding: 1.25rem; background: #232931; border: 1px solid #3c4650; border-radius: .75rem; margin-block: 1rem; }
label { display: block; margin-bottom: .45rem; font-weight: 600; }
input, button { box-sizing: border-box; font: inherit; padding: .55rem .75rem; border-radius: .35rem; }
input { min-width: 0; border: 1px solid #69747e; background: #171b20; }
button { cursor: pointer; border: 1px solid transparent; background: #edcb89; color: #211b12; font-weight: 650; }
button:disabled { opacity: .65; }
.icon-button { min-width: 2.4rem; min-height: 2.4rem; padding: .4rem .55rem; line-height: 1; vertical-align: middle; }
.button-icon {
    display: inline-block;
    width: 1.3rem;
    height: 1.3rem;
    vertical-align: middle;
    color: #edcb89;
    font-family: "Segoe UI Symbol", "Apple Symbols", "Noto Sans Symbols 2", sans-serif;
    font-variant-emoji: text;
    font-size: var(--font-icon);
    font-style: normal;
    font-weight: normal;
    line-height: 1;
    text-align: center;
}
.icon-button-up .button-icon { transform: rotate(180deg); }
.controls { display: flex; flex-wrap: wrap; gap: .6rem; }
.controls input { flex: 1 1 10rem; }
a { color: #edcb89; }
.status { color: #ffc3a7; }
ol { padding-inline-start: 1.4rem; }
li { padding-block: .35rem; overflow-wrap: anywhere; }
select { max-width: 100%; font: inherit; padding: .55rem; }
#tabletop-handouts form { margin-top: .75rem; }
#tabletop-handouts select, #tabletop-handouts input { max-width: 100%; }
#handout-library { list-style: none; margin: .4rem 0 0; padding: 0; }
#handout-library li:not(.journal-folder) { display: grid; align-items: center; gap: .2rem; padding: .15rem 0; }
#handout-library li:has([data-handout-action="edit"]) { grid-template-columns: minmax(0, 1fr) 1.85rem; }
#handout-new-image ~ #handout-library li:not(.journal-folder) { grid-template-columns: minmax(0, 1fr) repeat(5, 1.85rem); }
#handout-library [data-handout-action="access"] { grid-column: -2; }
#tabletop-handouts .status:empty { display: none; }
#handout-player-list, #handout-access-players { max-height: 45vh; overflow: auto; }
#handout-player-list label, #handout-access-players label { font-weight: normal; overflow-wrap: anywhere; }
#tabletop-handouts dialog .controls { margin-top: .65rem; }
#handout-viewer, #handout-editor {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 10;
    width: min(44rem, calc(100vw - 2rem));
    box-sizing: border-box;
    margin: 0;
    padding: .65rem;
    box-shadow: 0 .5rem 2rem #0008;
}
#handout-viewer-bar, #handout-editor-bar { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
#handout-viewer-title, #handout-editor-title { flex: 1; min-width: 0; overflow-wrap: anywhere; cursor: move; touch-action: none; }
#handout-editor { z-index: 11; max-height: calc(100dvh - 2rem); overflow: auto; }
#handout-editor textarea { width: 100%; }
#handout-format-bar { margin-block: .35rem .5rem; gap: .35rem; }
#handout-format-bar button { background: #303944; color: inherit; padding: .25rem .5rem; }
#handout-viewer-image[hidden] { display: none; }
#handout-viewer-image { display: block; width: 100%; max-height: 70vh; object-fit: contain; margin-top: .5rem; }
.room-page, .scene-editor-page { width: 100%; padding-inline: .5rem; }
.room-page:not([data-popout]) { margin-block: 0 .5rem; }
.room-page:not([data-popout]) .tabletop { margin-bottom: .5rem; }
.room-page[data-popout] { width: 100%; margin: 0; padding: .5rem; }
[data-popout="map"] #tabletop-map {
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    height: calc(100dvh - 1rem);
}
[data-popout="map"] #map-control-layer { flex: 1 1 auto; height: auto; min-height: 0; }
[data-popout="map"] .map-bar { flex-shrink: 0; }
:has(> .panel-popout) { position: relative; }
.panel-popout {
    position: absolute;
    z-index: 4;
    inset-block-start: .18rem;
    inset-inline-end: .25rem;
    display: grid;
    place-items: center;
    inline-size: 1.05rem;
    block-size: 1.05rem;
    border-radius: .2rem;
    color: inherit;
    font-size: var(--font-small);
    line-height: 1;
    text-decoration: none;
}
.panel-popout > span {
    border: 1px solid currentColor;
    border-radius: .1rem;
    inline-size: .68rem;
    block-size: .68rem;
    line-height: .58rem;
    text-align: center;
}
.panel-popout:hover, .panel-popout:focus-visible { background: #3c4650; color: #edcb89; }
#tabletop-layout:has(> .panel-popout), #tabletop-tools:has(> .panel-popout) { padding-block-start: 1.25rem; }
#tabletop-map:has(> .panel-popout) #tabletop-map-tool-bar { padding-inline-end: 1.5rem; }
#tabletop-roll-log:has(> .panel-popout),
#tabletop-roll-input:has(> .panel-popout),
#tabletop-chat-input:has(> .panel-popout),
#tabletop-token-placement:has(> .panel-popout),
#tabletop-token-list:has(> .panel-popout) { padding-inline-end: 1.3rem; }
#tabletop-map-tools:has(> .panel-popout) { padding-block-start: 1.3rem; }
#tabletop-header { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: .75rem 1.5rem; }
#tabletop-header:has(> .panel-popout) { padding-inline-end: 1.5rem; }
.tabletop-header-title { flex: 1 1 14rem; min-width: 0; overflow-wrap: anywhere; }
.tabletop-header-title h1 { margin: 0; }
.tabletop-header-title p { margin: .4rem 0 0; }
.tabletop-header-nav { display: flex; align-items: flex-start; gap: .4rem; margin-inline-start: auto; max-width: 100%; }
.tabletop-header-nav a {
    display: grid;
    justify-items: center;
    grid-template-rows: 1.7rem auto;
    align-items: center;
    gap: .2rem;
    min-width: 0;
    padding: .2rem .35rem;
    border-radius: .35rem;
    color: inherit;
    font-size: var(--font-small);
    text-align: center;
    text-decoration: none;
    overflow-wrap: anywhere;
}
.tabletop-header-nav a:hover, .tabletop-header-nav a:focus-visible { background: #303944; color: #edcb89; }
.tabletop-header-portrait {
    position: relative;
    display: grid;
    place-items: center;
    width: 1.65rem;
    height: 1.65rem;
    overflow: hidden;
    border-radius: .3rem;
    background: #303944;
    font-weight: 700;
}
.tabletop-header-portrait img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.tabletop {
    display: grid;
    grid-template-columns: minmax(17rem, 21rem) minmax(0, 1fr) clamp(15rem, 22%, 20rem);
    grid-template-areas: "sidebar map chat";
    gap: 1rem;
    align-items: start;
    margin-block: 1rem;
}
@media (width > 64rem) {
    #tabletop-layout.tabletop-adjustable {
        --tabletop-sidebar-track: calc(17rem + (max(17rem, 38%) - 17rem) * var(--sidebar-width));
        grid-template-columns: var(--tabletop-sidebar-track) 1rem minmax(0, 1fr) 1rem clamp(15rem, 22%, 20rem);
        grid-template-areas: "sidebar splitter map . chat";
        column-gap: 0;
    }
}
#tabletop-splitter:not([hidden]) {
    grid-area: splitter;
    align-self: stretch;
    display: grid;
    justify-items: center;
    cursor: col-resize;
    touch-action: none;
    user-select: none;
}
#tabletop-splitter::before {
    content: "";
    width: 2px;
    background: #3c4650;
}
#tabletop-splitter:is(:hover, :focus-visible, .tabletop-splitter-dragging)::before {
    background: #edcb89;
}
.tabletop-sidebar { grid-area: sidebar; display: grid; gap: .75rem; min-width: 0; }
#tabletop-tabs:not([hidden]) { display: flex; flex-wrap: wrap; gap: .35rem; }
#tabletop-tabs button {
    flex: 1 1 auto;
    border-color: #3c4650;
    background: #303944;
    color: inherit;
    font-size: var(--font-normal);
    padding: .35rem .45rem;
}
#tabletop-tabs button[aria-selected="true"] { background: #edcb89; color: #211b12; }
.tabletop-sidebar [role="tabpanel"][hidden],
.tabletop-sidebar > .tabletop-tools:not(:has(> :is(#tabletop-scenes, #tabletop-handouts, #tabletop-map-tools):not([hidden]))) {
    display: none;
}
.tabletop-tools { display: grid; gap: .75rem; min-width: 0; }
.tabletop-tools > *, .tabletop-map { margin: 0; min-width: 0; }
#scene-title { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
.tabletop-rolls { grid-area: chat; margin: 0; min-width: 0; padding: .85rem; }
.tabletop-rolls input { max-width: 100%; }
.tabletop-rolls [role="status"]:empty { display: none; }
.tabletop-map { grid-area: map; margin: 0; padding: 0; overflow: hidden; }
.tabletop-map .status:not(:empty) { padding: .5rem .75rem; }
.tabletop-tools .panel { margin: 0; padding: .85rem; }
.tabletop-tools input { max-width: 100%; }
.scene-sidebar { margin: 0; padding: .65rem; }
#scene-list { list-style: none; margin: .4rem 0 0; padding: 0; }
#scene-list li { display: grid; grid-template-columns: minmax(0, 1fr) repeat(4, 1.85rem); gap: .2rem; align-items: center; padding: .15rem 0; }
.scene-preview, .scene-icon { background: #303944; color: inherit; }
.scene-preview { min-width: 0; min-height: 1.85rem; padding: .2rem .4rem; text-align: left; overflow-wrap: anywhere; }
.scene-preview[aria-pressed="true"] { background: #edcb89; color: #211b12; }
.scene-preview[draggable="true"] { cursor: grab; }
.scene-preview.drop-target { outline: 2px solid #edcb89; outline-offset: 1px; }
.scene-icon { box-sizing: border-box; display: inline-grid; place-items: center; width: 1.85rem; height: 1.85rem; padding: 0; border: 1px solid #3c4650; border-radius: .35rem; text-decoration: none; line-height: 1; }
.scene-icon:hover:not(:disabled), .scene-icon:focus-visible { color: #edcb89; border-color: #edcb89; }
.scene-icon .button-icon { width: 1rem; height: 1rem; }
#scene-feedback:empty, #scene-players-status:empty { display: none; }
#scene-players-options { max-height: 50vh; overflow: auto; margin-bottom: .65rem; }
.tabletop-tools [role="status"]:empty { display: none; }
.tabletop-rolls #roll-form { margin-top: .75rem; }
#map-control-layer { position: relative; -webkit-user-select: none; user-select: none; height: clamp(18rem, 65vh, 47rem); }
#map-player-list {
    position: absolute;
    z-index: 3;
    top: .5rem;
    left: .5rem;
    max-height: calc(100% - 1rem);
    width: min(8rem, 28%);
    overflow: auto;
    scrollbar-width: none;
}
#map-player-list::-webkit-scrollbar { display: none; }
.map-player { display: flex; flex-direction: column; align-items: flex-start; margin-bottom: .4rem; }
.map-player-image {
    box-sizing: border-box;
    width: 2.6rem;
    height: 2.6rem;
    display: grid;
    place-items: center;
    overflow: hidden;
    border: 2px solid var(--player-color);
    border-radius: .35rem;
    background: #232931;
    font-weight: 700;
}
.map-player-image img { width: 100%; height: 100%; object-fit: cover; }
.map-player-name {
    max-width: 100%;
    box-sizing: border-box;
    padding: .08rem .3rem;
    border-radius: .25rem;
    background: #171b20e8;
    overflow-wrap: anywhere;
    font-size: var(--font-small);
}
#tileset-library label { display: block; margin-block: .5rem; }
#tileset-library input { max-width: 100%; }
#tileset-preview { overflow: auto; max-height: 12rem; max-width: 100%; margin-top: .75rem; }
#tileset-preview-sheet { position: relative; width: max-content; }
#tileset-preview-sheet img { display: block; max-width: none; image-rendering: pixelated; }
#tileset-preview-sheet.has-grid::after {
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none;
    background-image: linear-gradient(to right, #fff9 1px, transparent 1px),
        linear-gradient(to bottom, #fff9 1px, transparent 1px);
    background-size: var(--tile-width) var(--tile-height);
    box-shadow: inset -1px -1px #fff9;
}
#tileset-preview-sheet.has-grid img { cursor: crosshair; }
#selected-tile { pointer-events: none; position: absolute; box-sizing: border-box; border: 2px solid #edcb89; }
#tile-layer { position: absolute; inset: 0; z-index: 0; pointer-events: none; }
.map-tile { position: absolute; image-rendering: pixelated; }
.scene-editor-map-panel { padding: .5rem; }
#scene-editor-map { display: block; width: 100%; height: max(46rem, 72vh); border: 0; }
[data-edit-map] #measure-map, [data-edit-map] #map-template-shape, [data-edit-map] #place-map-template,
[data-edit-map] #ping-map, [data-edit-map] #tabletop-map-action-bar,
[data-edit-map] #map-player-list, [data-edit-map] #map-measure-notices { display: none; }
#map-viewport { container-type: size; overflow: auto; scrollbar-width: none; overflow-anchor: none; width: 100%; height: 100%; }
.map-bar {
    box-sizing: border-box;
    min-height: 2.75rem;
    padding: .35rem .75rem;
}
#tabletop-map-tool-bar { border-bottom: 1px solid #3c4650; }
#tabletop-map-action-bar { border-top: 1px solid #3c4650; }
#tabletop-map-tool-bar label { margin: 0; }
[data-edit-map] #tabletop-map-tool-bar { min-width: 0; overflow: auto; }
@media (min-width: 42rem) {
    [data-edit-map] #tabletop-map {
        display: grid;
        grid-template-columns: clamp(13rem, 28%, 20rem) minmax(0, 1fr);
        grid-template-rows: minmax(0, 1fr) auto;
        grid-template-areas: "tools map" "tools status";
    }
    [data-edit-map] #tabletop-map-tool-bar {
        grid-area: tools;
        border-bottom: 0;
        border-inline-end: 1px solid #3c4650;
    }
    [data-edit-map] #tabletop-map-tool-bar details > summary { margin-block: .5rem; }
    [data-edit-map] #map-control-layer { grid-area: map; min-width: 0; }
    [data-edit-map] #map-status { grid-area: status; }
}
@media (max-width: 41.999rem) {
    [data-edit-map] #tabletop-map-tool-bar { max-height: 42%; }
}
#board[data-drawing-mode^='tile-'] { cursor: crosshair; touch-action: none; }
#map-viewport::-webkit-scrollbar { display: none; }
#map-viewport:focus-visible { outline: 2px solid #edcb89; outline-offset: -2px; }
#board {
    position: relative;
    --image-ratio: calc(var(--columns) / var(--rows));
    width: calc(min(100cqw, 100cqh * var(--image-ratio)) * var(--zoom, 1));
    height: auto;
    aspect-ratio: var(--image-ratio);
    margin-inline: auto;
    isolation: isolate;
    overflow: hidden;
}
#board[data-image-ratio] {
    width: calc(min(100cqw, 100cqh * var(--image-ratio)) * var(--zoom, 1));
    height: auto;
    aspect-ratio: var(--image-ratio);
    margin-inline: auto;
}
#background-layer, #interactive-object-layer {
    position: absolute;
    inset: 0;
    pointer-events: none;
}
#background-layer {
    z-index: 0;
    background-color: #343c47;
}
#background-layer img { display: block; width: 100%; height: 100%; object-fit: contain; }
#background-layer img[hidden] { display: none; }
#board:not([data-grid-hidden]) #tile-layer::after {
    content: "";
    position: absolute;
    inset: 0;
    background-image:
        repeating-linear-gradient(to right, #15181270 var(--grid-x), #15181270 calc(var(--grid-x) + 1px),
            transparent calc(var(--grid-x) + 1px), transparent calc(var(--grid-x) + var(--grid-width))),
        repeating-linear-gradient(to bottom, #15181270 var(--grid-y), #15181270 calc(var(--grid-y) + 1px),
            transparent calc(var(--grid-y) + 1px), transparent calc(var(--grid-y) + var(--grid-height)));
}
#static-object-layer, #map-template-layer, #map-drawing-layer, #map-label-layer { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 1; pointer-events: none; }
#map-label-layer, #map-drawing-layer { z-index: 2; }
.map-template { fill: var(--template-color); fill-opacity: .22; stroke: var(--template-color);
    stroke-width: 2; vector-effect: non-scaling-stroke; }
#board:not([data-drawing-mode]) .map-template[data-template-id] { pointer-events: visiblePainted; cursor: grab; touch-action: none; }
#board:not([data-drawing-mode]) .map-template[data-dragging] { cursor: grabbing; }
#board[data-drawing-mode="template"] { cursor: crosshair; }
.map-template-preview { stroke-dasharray: 5 4; pointer-events: none; }
.map-template-preview[hidden] { display: none; }
.map-label {
    position: absolute;
    box-sizing: border-box;
    max-width: min(16rem, 48%);
    padding: .2rem .35rem;
    border: 1px solid var(--label-color);
    border-radius: .25rem;
    background: #171b20ed;
    color: var(--label-color);
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    font-size: var(--font-normal);
    pointer-events: auto;
    transform: translate(var(--label-shift-x, 0), var(--label-shift-y, 0));
}
#board[data-drawing-mode] .map-label { pointer-events: none; }
#board[data-drawing-mode="label"] { cursor: crosshair; }
#map-label-dialog, #token-emote-dialog, #quick-note-dialog { color: inherit; width: min(28rem, 85vw); }
#token-emote-dialog { margin: auto; }
#token-emote-dialog input { display: block; width: 100%; margin-block: .5rem; }
#quick-note-dialog { width: min(34rem, 85vw); }
#quick-note-status:empty { display: none; }
#map-label-dialog textarea, #quick-note-dialog textarea { display: block; width: 100%; margin-block: .5rem; }
.map-drawing { fill: none; stroke: var(--drawing-color); stroke-width: 3; stroke-linecap: round;
    stroke-linejoin: round; vector-effect: non-scaling-stroke; }
#board[data-drawing-mode="draw"] { cursor: crosshair; touch-action: none; }
#board:not([data-drawing-mode]) .map-drawing[data-removable] { pointer-events: stroke; }
#board[data-drawing-mode="erase"] .map-drawing[data-removable] { pointer-events: stroke; cursor: pointer; stroke-width: 6; }
#drawing-tools button[aria-pressed="true"] { outline: 2px solid #fff; outline-offset: 2px; }
#interactive-object-layer { z-index: 2; }
#interactive-object-layer .token { pointer-events: auto; }
#board[data-drawing-mode] #interactive-object-layer .token { pointer-events: none; }
#interactive-object-layer .token.dragging { pointer-events: none; }
#background-form input { max-width: 100%; }
#background-form { margin-top: .5rem; }
#grid-form { margin-top: .5rem; }
#grid-form input[type="number"], #grid-form input[name="unit"] { width: 6rem; }
.token, #placement {
    position: absolute;
    left: calc(var(--grid-x) + var(--grid-width) * var(--x));
    top: calc(var(--grid-y) + var(--grid-height) * var(--y));
    width: var(--grid-width);
    height: var(--grid-height);
    display: grid;
    place-items: center;
    box-sizing: border-box;
}
.token { border-radius: 50%; background: #272a34; border: 0; color: #fff; font-weight: 700; padding: 0; touch-action: none; user-select: none; cursor: default; }
.token[data-hidden-token="true"] { opacity: .5; }
.token.has-emote { z-index: 3; }
.token-initial { pointer-events: none; }
.token-emote {
    position: absolute;
    bottom: calc(100% + .35rem);
    left: calc(50% + var(--emote-offset, 0px));
    translate: -50% 0;
    box-sizing: border-box;
    width: max-content;
    max-inline-size: min(14rem, var(--emote-map-width, 14rem));
    padding: .35rem .65rem;
    border-radius: .65rem;
    background: #fff6e3;
    color: #211b12;
    font-size: var(--font-normal);
    font-weight: 500;
    line-height: 1.25;
    overflow-wrap: anywhere;
    box-shadow: 0 2px 8px #0008;
    pointer-events: none;
}
.emote-below .token-emote { bottom: auto; top: calc(100% + .35rem); }
.token-emote::after {
    content: "";
    position: absolute;
    top: 100%;
    left: calc(var(--emote-tail, 50%) - .3rem);
    border: .3rem solid transparent;
    border-top-color: #fff6e3;
}
.emote-below .token-emote::after {
    top: auto;
    bottom: 100%;
    border-top-color: transparent;
    border-bottom-color: #fff6e3;
}
.token-emote[data-kind="thought"] { border-radius: 1rem; background: #e4ecff; }
.token-emote[data-kind="thought"]::after {
    width: .36rem;
    height: .36rem;
    margin-top: .12rem;
    border: 0;
    border-radius: 50%;
    background: #e4ecff;
    box-shadow: -.28rem .32rem 0 -.08rem #e4ecff;
}
.emote-below .token-emote[data-kind="thought"]::after {
    margin-bottom: .12rem;
    box-shadow: -.28rem -.32rem 0 -.08rem #e4ecff;
}
#token-context { position: fixed; z-index: 9; margin: 0; padding: .25rem; }
#token-context button { display: block; width: 100%; }
#token-context button[hidden] { display: none; }
#board[data-drawing-mode="measure"] { cursor: crosshair; }
#map-measure-notices:not(:empty) { padding: .35rem .75rem; }
.map-measurement { position: absolute; inset: 0; z-index: 4; pointer-events: none; }
.map-measurement svg { display: block; width: 100%; height: 100%; }
.map-measure-line { stroke: var(--measure-color, #fff); stroke-width: 3; stroke-dasharray: 6 4; }
.map-measure-result { position: absolute; transform: translate(-50%, -50%); background: #171b20;
    color: var(--measure-color, #fff); padding: .15rem .4rem; border-radius: .25rem; white-space: nowrap; }
#fog-layer, #fog-preview-layer { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
#fog-layer { z-index: 5; image-rendering: pixelated; }
#board[data-gm="true"] #fog-layer { opacity: .55; }
#fog-preview-layer { z-index: 6; }
#fog-preview { fill: #82ddf940; stroke: #9eeaff; stroke-width: 2; stroke-dasharray: 5 4;
    vector-effect: non-scaling-stroke; }
#fog-preview[hidden] { display: none; }
#board[data-drawing-mode^="fog-"] { cursor: crosshair; touch-action: none; }
#fog-tools button[aria-pressed="true"] { outline: 2px solid #fff; outline-offset: 2px; }
#map-ping-layer { position: absolute; inset: 0; z-index: 3; pointer-events: none; }
.map-ping {
    position: absolute;
    width: 1.75rem;
    height: 1.75rem;
    box-sizing: border-box;
    border: 3px solid var(--ping-color, #edcb89);
    border-radius: 50%;
    box-shadow: 0 0 0 2px #171b20;
    transform: translate(-50%, -50%);
    animation: map-ping-pulse 1s ease-out infinite;
}
@keyframes map-ping-pulse {
    from { transform: translate(-50%, -50%) scale(.7); opacity: 1; }
    to { transform: translate(-50%, -50%) scale(1.8); opacity: .25; }
}
@media (prefers-reduced-motion: reduce) { .map-ping { animation: none; } }
.token[data-movable="true"] { cursor: grab; }
.token.dragging { z-index: 2; cursor: grabbing; pointer-events: none; }
.token:focus-visible { z-index: 1; outline: 3px solid white; outline-offset: -4px; }
#placement { border: 2px dashed white; pointer-events: none; }
#placement[hidden] { display: none; }
.map-tools { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.map-tools input[type="number"] { width: 5rem; }
#token-admin li { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; justify-content: space-between; }
@media (max-width: 64rem) {
    #tabletop-splitter:not([hidden]) { display: none; }
    .tabletop {
        grid-template-columns: minmax(0, 1fr);
        grid-template-areas: "map" "chat" "sidebar";
    }
}
.account-form, .account-form label { display: grid; gap: .5rem; justify-items: start; }
.user-entry { border-top: 1px solid #3c4650; padding-block: .75rem; display: grid; gap: .5rem; }
.user-entry h3, .user-entry p { margin: 0; }
.campaign-swatches { display: flex; flex-wrap: wrap; gap: .3rem; }
.campaign-swatches .campaign-swatch { position: relative; display: block; margin: 0; cursor: pointer; }
.campaign-swatch input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.campaign-swatch span { display: block; width: 1.65rem; height: 1.65rem; border: 2px solid transparent;
    border-radius: .3rem; background: var(--swatch-color); }
.campaign-swatch input:checked + span { border-color: #171b20; outline: 2px solid #fff; }
.campaign-swatch input:focus-visible + span { outline: 2px dashed #fff; outline-offset: 2px; }
.player-portrait { width: 4rem; height: 4rem; object-fit: cover; border-radius: .35rem; }
.room-description { white-space: pre-wrap; overflow-wrap: anywhere; }
details > summary { cursor: pointer; font-weight: 650; }
details > form { margin-top: 1rem; }
textarea { box-sizing: border-box; max-width: 100%; font: inherit; padding: .55rem; }
.account-form .checkbox-label { display: flex; align-items: center; }

#map-object-select { display: block; }
#map-object-preview { display: block; max-width: 100%; max-height: 7rem; margin-block: .5rem; }
#map-object-preview[hidden] { display: none; }
#map-asset-layer { position: absolute; inset: 0; pointer-events: none; }
.map-asset {
    position: absolute;
    background: center / contain no-repeat;
    image-rendering: pixelated;
}
[data-edit-map] #board:not([data-drawing-mode]) .map-asset,
[data-edit-map] #board[data-drawing-mode^='asset-'] .map-asset { pointer-events: auto; }
#board[data-drawing-mode^='asset-'] { cursor: crosshair; }

#chat-scroll {
    max-height: 20rem;
    overflow-y: auto;
    overflow-anchor: none;
}
#roll-log {
    overflow-wrap: anywhere;
    list-style: none;
    margin: .5rem 0;
    padding: 0;
}
#roll-log > li {
    display: grid;
    grid-template-columns: 3rem minmax(0, 1fr);
    gap: .55rem;
    align-items: start;
    padding: .42rem .15rem;
    color: var(--chat-player-color, inherit);
}
#roll-log > li + li { border-top: 1px solid #3c4650; }
.chat-avatar-column { display: flex; flex-direction: column; align-items: center; gap: .25rem; }
.chat-avatar {
    position: relative;
    display: grid;
    place-items: center;
    width: 3rem;
    height: 3rem;
    overflow: hidden;
    border-radius: .2rem;
    background: #171b20;
    font-size: var(--font-small);
    font-weight: 650;
    font-style: normal;
}
.chat-avatar img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.chat-metadata { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 .45rem; line-height: 1.25; }
.chat-author { font-size: var(--font-normal); }
.chat-time { color: #aab3be; font-size: var(--font-small); font-style: normal; white-space: nowrap; }
#roll-log .chat-message a, #roll-log .chat-mention { color: inherit; }
#roll-log .chat-mention-self { color: #211b12; }
#roll-log .chat-message { display: block; white-space: pre-wrap; line-height: 1.3; }
#roll-log .chat-roll-success { color: #69d88a; font-weight: 700; }
#roll-log .chat-roll-failure { color: #ff7777; font-weight: 700; }
#roll-log .chat-reroll { width: 3rem; padding: .1rem; border: 1px solid currentColor; border-radius: .25rem; background: transparent; color: inherit; font-size: var(--font-normal); line-height: 1.1; }
#roll-log .chat-reroll:hover { background: rgba(255, 255, 255, .16); }
#roll-log .chat-reroll:disabled { opacity: .5; }
#roll-log [data-kind="me"] { font-style: italic; }
#roll-log blockquote { margin: .25rem 0; padding-inline-start: .65rem; border-inline-start: 2px solid #8495a6; }
#roll-log code { background: #171b20; border-radius: .2rem; padding-inline: .2rem; }
.chat-mention { color: #a4d7ff; font-weight: 650; }
.chat-mention-self { color: #211b12; background: #edcb89; border-radius: .25rem; padding-inline: .15rem; }
#chat-form { margin-top: .75rem; }
.chat-send-controls, .chat-audience { display: flex; align-items: center; flex-wrap: wrap; gap: .35rem; }
.chat-audience button { background: #303944; border-color: #566575; color: #f4f1e8; }
.chat-audience button[aria-pressed="true"] { background: #edcb89; border-color: #edcb89; color: #211b12; }
#chat-message { display: block; width: 100%; margin-bottom: .45rem; resize: vertical; }
#chat-help { margin-top: .45rem; overflow-wrap: anywhere; }
#chat-help p { margin-block: .35rem; }

.chat-inline-roll {
    display: inline;
    padding: .08rem .4rem;
    border-color: currentColor;
    background: #263340;
    color: inherit;
    font: inherit;
    font-weight: 650;
    white-space: normal;
    overflow-wrap: anywhere;
}
.chat-inline-roll:hover, .chat-inline-roll:focus-visible { background: #394b5d; }

.combat-turns { width: 100%; margin-block: .5rem; border-collapse: collapse; font-size: var(--font-normal); }
.combat-turns th, .combat-turns td { padding: .35rem .25rem; text-align: center; border-bottom: 1px solid #3c4650; }
.combat-turns th:nth-child(2), .combat-turns .combat-tracker-actor { text-align: start; overflow-wrap: anywhere; }
.combat-turns button { padding: .18rem .4rem; font-variant-numeric: tabular-nums; }
.combat-actor-portrait {
    position: relative; display: inline-grid; place-items: center; overflow: hidden;
    width: 2.4rem; height: 2.4rem; vertical-align: middle;
    border-radius: .25rem; background: #171b20; font-weight: 650;
}
.combat-actor-portrait img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.combat-turns [aria-current="step"] { background: #394653; border-radius: .25rem; }
.combat-tracker-controls { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem; margin-block: .45rem; }
.combat-tracker-controls label { margin: 0; }
.combat-tracker-controls input { width: 4rem; padding-inline: .35rem; }
.combat-tracker-controls select { flex: 1; min-width: 0; }

.token-art { position: absolute; inset: 0; width: 100%; height: 100%; border-radius: 50%; pointer-events: none; }
#open-token-maker { margin-block: .25rem .55rem; }
#token-art-status:empty, #token-maker-dialog [role="status"]:empty { display: none; }
#token-maker-dialog { width: min(25rem, 85vw); margin: auto; max-height: 90dvh; overflow: auto; }
#token-maker-dialog :is(input, select) { max-width: 100%; }
#token-maker-dialog canvas {
    display: block;
    width: min(100%, 14rem);
    height: auto;
    margin: .65rem auto;
    border-radius: 50%;
    background: #171b20;
    outline: 1px dashed #687483;
    cursor: grab;
    touch-action: none;
}
#token-maker-dialog canvas:active { cursor: grabbing; }

.sheet-list { list-style: none; margin: .4rem 0 0; padding: 0; }
.sheet-list li { display: grid; grid-template-columns: 1.85rem minmax(0, 1fr); grid-auto-columns: 1.85rem; grid-auto-flow: column; align-items: center; gap: .25rem; padding: .15rem 0; overflow-wrap: anywhere; }
.sheet-list-avatar { position: relative; display: grid; place-items: center; aspect-ratio: 1; border-radius: 50%; background: #303944; }
.sheet-list-avatar img { position: absolute; inset: 0; width: 100%; height: 100%; border-radius: inherit; }
#npc-list-status:empty, #sc-list-status:empty { display: none; }

.scene-player-dots:not([hidden]) { display: flex; flex-wrap: wrap; gap: .25rem; margin-top: .2rem; }
.scene-player-dot {
    font-size: var(--font-small);
    line-height: 1;
    text-shadow: 0 0 1px #171b20;
}

#compendium-search { width: 100%; }
.compendium-actions { margin-block: .5rem; align-items: start; }
.compendium-create, .compendium-actions summary { display: block; padding: .3rem .55rem; border: 1px solid #3c4650; border-radius: .35rem; cursor: pointer; }
.compendium-actions details label { margin-top: .4rem; }
.compendium-table { border-collapse: collapse; width: 100%; font-size: var(--font-normal); }
.compendium-table th, .compendium-table td { padding: .25rem; text-align: left; border-bottom: 1px solid #3c4650; overflow-wrap: anywhere; }
#compendium-editor [hidden] { display: none; }

#handout-library .journal-folder { padding: .2rem 0; }
.journal-folder ul { list-style: none; padding-inline-start: .6rem; }
.journal-folder summary { cursor: pointer; overflow-wrap: anywhere; }
.journal-folder-actions { gap: .25rem; margin-block: .2rem; }
#journal-new-folder { font-size: var(--font-normal); padding: .2rem .35rem; }
.journal-folder-actions .journal-folder-icon { position: relative; display: inline-grid; place-items: center; width: 1.6rem; height: 1.6rem; padding: 0; border: 0; background: none; color: inherit; }
.journal-folder-actions .journal-folder-icon .button-icon { width: 1.15rem; height: 1.15rem; }
.journal-folder-actions .journal-folder-icon:hover { color: #edcb89; }
.journal-folder-actions .journal-folder-icon:focus-visible { outline: 2px solid #edcb89; outline-offset: 1px; }

#journal-folder-dialog [hidden], #journal-folder-dialog [role="status"]:empty { display: none; }

.token-details {
    position: absolute;
    inset: 0;
    z-index: 1;
    pointer-events: none;
}
.token-display-name,
.token-conditions > span {
    position: absolute;
    background: #20212a;
    color: #fff;
    border-radius: .2rem;
    padding: 0 .2rem;
    font-size: var(--font-small);
    line-height: 1.15;
    white-space: nowrap;
}
.token-display-name {
    top: calc(100% + 2px);
    left: 50%;
    transform: translateX(-50%);
}
.token-life-bar {
    position: absolute;
    inset-inline: 12%;
    bottom: 8%;
    height: clamp(3px, .35rem, 6px);
    border: 1px solid #fff;
    border-radius: .2rem;
    background: linear-gradient(90deg, #6fc97a var(--lp), #572c34 var(--lp));
}
.token-conditions {
    position: absolute;
    inset: 0;
}
.token-conditions > span {
    left: var(--condition-x);
    top: var(--condition-y);
    transform: translate(-50%, -50%);
}
#board:not([data-drawing-mode]) .token-conditions > span { pointer-events: auto; }
.combat-resource-form,
.combat-condition-form {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .35rem;
    margin: .25rem 0;
}
.combat-resource-form input { width: 5ch; }
.combat-condition-form input { width: 13ch; }
#combat-token-dialog {
    margin: auto;
    width: min(35rem, 90vw);
    max-height: 90dvh;
    overflow: auto;
}

.combat-actor-line {
    display: flex;
    flex-wrap: wrap;
    gap: .25rem;
    align-items: center;
}
.combat-tracker-conditions > span {
    padding-inline: .2rem;
    background: #20212a;
    border-radius: .2rem;
}
.combat-tracker-health meter {
    width: 4rem;
    min-width: 2rem;
}
.combat-tracker-health > span {
    font-variant-numeric: tabular-nums;
}

.combat-editor-health meter {
    flex: 1 1 5rem;
    min-width: 5rem;
}
#combat-token-dialog [data-combat-token-fields] button {
    min-width: 2rem;
    padding: .2rem .4rem;
}

@media (prefers-reduced-motion: no-preference) {
    .token.is-active-turn > :is(.token-art, .token-initial) {
        animation: token-turn-pulse 2s ease-in-out infinite;
    }
}

@keyframes token-turn-pulse {
    50% { transform: scale(1.05); }
}

@font-face {
    font-family: Polymath;
    src: url('assets/fonts/Polymath/Polymath.otf') format('opentype');
}
.chat-roll-die {
    font-family: Polymath;
    font-size: 1.65em;
    line-height: 1;
    vertical-align: middle;
}

#action-bar {
    display: grid;
    grid-template-columns: repeat(10, minmax(0, 3.5rem));
    justify-content: center;
    gap: clamp(.125rem, .5vw, .35rem);
}
.action-bar-slot {
    display: grid;
    grid-template-rows: auto 1fr auto;
    justify-items: center;
    align-items: center;
    width: 100%;
    min-width: 0;
    aspect-ratio: 1;
    padding: .12rem;
    border: 1px solid #4b5665;
    border-radius: .25rem;
    background: #26303b;
    color: #f4f6fa;
    overflow: hidden;
}
.action-bar-slot kbd { justify-self: end; font-size: var(--font-small); }
.action-bar-icon { font-size: var(--font-icon); line-height: 1; }
.action-bar-name { width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: var(--font-small); }
.action-bar-empty { background: transparent; color: #aab3be; }
.action-bar-empty .action-bar-icon { visibility: hidden; }
.action-bar-empty:hover .action-bar-icon, .action-bar-empty:focus-visible .action-bar-icon { visibility: visible; }
.action-bar-unavailable { opacity: .55; filter: grayscale(1); }
.action-bar-triggered { background: #496681; border-color: #a9d5ff; }
.action-bar-dialog { width: min(28rem, 90vw); }
.action-bar-dialog label { display: block; margin: .45rem 0; }
.action-bar-dialog select { max-width: 100%; }
.action-bar-dialog button { margin: .15rem; }
.action-bar-description { white-space: pre-wrap; }
.action-bar-feedback:empty { display: none; }
.action-bar-options {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
    gap: .45rem;
    margin-block: .75rem;
}
.action-bar-options input { width: 100%; }
.sc-page [data-action-bar-key][draggable="true"] { cursor: grab; }
.action-bar-slot.action-bar-drop-target { outline: 2px solid #edcb89; outline-offset: -2px; }

.targeted-attack-feedback { margin: 0; padding: .4rem .75rem; color: #edcb89; }
.targeted-attack-picking .token { cursor: crosshair; }
.targeted-attack-picking .token:is(:hover, :focus-visible) { outline: 2px solid #edcb89; }

.sidebar-sheet { margin-top: .65rem; border-top: 1px solid #3c4650; }
.sidebar-sheet-controls { justify-content: space-between; margin-block: .35rem; }
.sidebar-sheet-controls a { font-size: var(--font-normal); }
.sidebar-sheet iframe { display: block; width: 100%; height: clamp(16rem, 58vh, 36rem); border: 0; }
.sidebar-sheet-avatar:not([draggable="true"]) { cursor: pointer; }
.sheet-list a[aria-current="true"] { color: #edcb89; }
.room-page[data-embedded-sheet] { margin: 0; padding: .4rem 0; }

@media (width > 64rem) {
    #tabletop-layout > .tabletop-sidebar {
        align-self: start;
        height: var(--tabletop-map-height, 0px);
        box-sizing: border-box;
        contain: size;
        display: flex;
        flex-direction: column;
        min-height: 0;
    }
    .tabletop-sidebar > #tabletop-tabs { flex: none; }
    .tabletop-sidebar > :is([role="tabpanel"], .tabletop-tools):not([hidden]) {
        flex: 1 1 0;
        min-height: 0;
        margin: 0;
    }
    .tabletop-sidebar > [role="tabpanel"]:not([hidden]),
    .tabletop-sidebar .tabletop-tools > [role="tabpanel"]:not([hidden]) {
        display: flex;
        flex-direction: column;
        min-height: 0;
    }
    .tabletop-sidebar .tabletop-tools:has(> [role="tabpanel"]:not([hidden])) {
        display: flex;
        flex-direction: column;
    }
    .tabletop-sidebar .tabletop-tools > [role="tabpanel"]:not([hidden]),
    .tabletop-sidebar [role="tabpanel"] > .panel {
        flex: 1;
        min-height: 0;
    }
    #tabletop-layout > #tabletop-rolls {
        display: flex;
        flex-direction: column;
        height: var(--tabletop-map-height, auto);
        box-sizing: border-box;
        contain: size;
    }
    .tabletop-sidebar [role="tabpanel"] > .panel,
    .tabletop-sidebar #tabletop-combat,
    #tabletop-layout > #tabletop-rolls {
        overflow: auto;
    }
    #tabletop-layout #tabletop-roll-log {
        display: flex;
        flex: 1 1 auto;
        flex-direction: column;
        min-height: 5rem;
    }
    #tabletop-layout #chat-scroll { flex: 1 1 0; min-height: 0; max-height: none; }
    #tabletop-layout :is(#tabletop-roll-input, #tabletop-chat-input) { flex: none; }
    .tabletop-sidebar .scene-sidebar:has(> .sidebar-sheet:not([hidden])) {
        display: flex;
        flex-direction: column;
        align-items: stretch;
    }
    .tabletop-sidebar .scene-sidebar:has(> .sidebar-sheet:not([hidden])) > :not(.sidebar-sheet) { flex: none; }
    .tabletop-sidebar .scene-sidebar:has(> .sidebar-sheet:not([hidden])) > .scene-icon { align-self: start; }
    .tabletop-sidebar .scene-sidebar:has(> .sidebar-sheet:not([hidden])) > .sheet-list {
        max-height: 30%;
        overflow: auto;
    }
    .tabletop-sidebar .sidebar-sheet:not([hidden]) {
        display: flex;
        flex: 1;
        flex-direction: column;
        min-height: 0;
    }
    .tabletop-sidebar .sidebar-sheet iframe { flex: 1 1 0; height: 0; min-height: 0; }
}

.targeted-attack-results { padding: .45rem .75rem; border-top: 1px solid #3c4650; }
.targeted-attack-results h3, .targeted-attack-results p { margin: .25rem 0; }
.targeted-attack-results article + article { margin-top: .4rem; padding-top: .4rem; border-top: 1px solid #3c4650; }
.targeted-attack-results input[type="number"] { width: 4rem; }

/* Controls override compact component text sizes, including Unicode-only controls. */
button, input::file-selector-button, .sc-action, .compendium-create,
.compendium-actions summary { font-size: var(--font-normal); }
.icon-button, .scene-icon, .journal-folder-icon, .panel-popout,
#roll-log .chat-reroll, .sc-resource-buttons button,
#combat-token-dialog [data-combat-token-fields] button,
.journal-folder-actions .journal-folder-add::after { font-size: var(--font-icon); }

/* Explicit Unicode glyph colors on dark and light controls. */
.scene-icon .button-icon, .journal-folder-icon .button-icon { color: #edcb89; }
.icon-button .button-icon { color: #211b12; }
.chat-audience button[aria-pressed="false"] .button-icon { color: #f4f1e8; }


.dice-style-picker { position: relative; flex: 0 0 auto; }
.dice-style-popup { position: absolute; bottom: calc(100% + .4rem); right: 0; z-index: 100; min-width: 11rem; padding: .65rem; background: #232931; border: 1px solid #69747e; border-radius: .5rem; box-shadow: 0 .5rem 1.5rem #0009; }
.dice-style-popup[hidden] { display: none; }
.dice-style-popup strong { display: block; margin-bottom: .4rem; }
.dice-style-popup button { display: block; width: 100%; margin-top: .2rem; text-align: left; background: transparent; color: #f4f1e8; }
.dice-style-popup button:hover, .dice-style-popup button[aria-pressed="true"] { background: #425465; }
.dice-style-popup button[aria-pressed="true"]::before { content: '✓ '; color: #edcb89; }


/* Visual rhythm shared by the lobby, tabletop and editors. */
:root {
    --ui-canvas: #111820;
    --ui-surface: #202b35;
    --ui-surface-raised: #293743;
    --ui-border: #40505d;
    --ui-muted: #b4c0c9;
    --ui-accent: #edcb89;
    background: var(--ui-canvas);
}
body {
    background: radial-gradient(ellipse at 50% -18rem, #293b4a 0, var(--ui-canvas) 45rem);
    min-height: 100dvh;
}
main:not(.room-page):not(.scene-editor-page) { margin-block: 2.5rem; }
h1, h2, h3, legend { letter-spacing: -.025em; }
h1 { color: #fff7e8; }
h2, h3 { color: #f5e4c2; }
p { line-height: 1.55; }
section, .panel {
    background: linear-gradient(145deg, #25313c, var(--ui-surface) 72%);
    border-color: var(--ui-border);
    box-shadow: 0 .4rem 1.5rem #080d1340, inset 0 1px #ffffff0b;
}
input, select, textarea {
    color: #f4f1e8;
    background: #141d25;
    border: 1px solid #60717e;
    border-radius: .45rem;
}
textarea { min-width: 0; }
input::placeholder, textarea::placeholder { color: #aab9c4; opacity: 1; }
:is(input, select, textarea):focus-visible,
:is(button, a, summary):focus-visible {
    outline: 2px solid var(--ui-accent);
    outline-offset: 2px;
}
button, .scene-icon, .compendium-create {
    transition: background-color .15s ease, border-color .15s ease, box-shadow .15s ease, color .15s ease;
}
button:not(:disabled):hover { filter: brightness(1.11); }
button:active:not(:disabled) { transform: translateY(1px); }
button:disabled { cursor: not-allowed; }
a:hover { color: #ffe4ac; }
.tabletop { gap: .85rem; }
#tabletop-header {
    align-items: center;
    margin-block: .3rem .8rem;
    padding: .75rem 1rem;
    border: 1px solid var(--ui-border);
    border-radius: .7rem;
    background: #1c2731e8;
}
.tabletop-header-title h1 { font-size: clamp(var(--font-heading), 1.5vw, 1.45rem); }
.tabletop-header-title p { color: var(--ui-muted); }
.tabletop-header-nav a { padding: .35rem .5rem; }
.tabletop-header-nav a:hover, .tabletop-header-nav a:focus-visible { background: var(--ui-surface-raised); }
#tabletop-tabs:not([hidden]) { gap: .25rem; padding: .25rem; border-radius: .55rem; background: #141d25; }
#tabletop-tabs button {
    border-color: transparent;
    border-radius: .4rem;
    background: transparent;
    color: #c5d0d8;
}
#tabletop-tabs button:hover:not([aria-selected="true"]) { background: #33424e; color: #fff; }
#tabletop-tabs button[aria-selected="true"] {
    background: #3c4d5b;
    color: #fff3d6;
    box-shadow: inset 0 -2px var(--ui-accent), 0 2px 6px #0004;
}
.scene-preview, .sheet-list li, #handout-library li:not(.journal-folder) { border-radius: .4rem; }
.scene-preview:hover:not([aria-pressed="true"]), .sheet-list li:hover, #handout-library li:not(.journal-folder):hover { background: #34434f; }
.scene-preview[aria-pressed="true"] { box-shadow: inset 3px 0 #fff2d3; }
.scene-icon { background: #34424e; border-color: #536472; }
#tabletop-rolls { background: #1e2933; }
#roll-log > li { padding-block: .65rem; }
#roll-log > li + li { border-top-color: #43515c; }
.chat-avatar { border-radius: .5rem; border: 1px solid #536472; }
#chat-message { min-height: 4.5rem; }
#tabletop-map { border-color: #536472; box-shadow: 0 .65rem 2rem #080d1370; }
#map-viewport { background: #111820; }
.map-bar { background: #26333e; }
#tabletop-map-tool-bar, #tabletop-map-action-bar { border-color: #4b5b68; }
#action-bar { padding-block: .3rem; }
.action-bar-slot { border-radius: .5rem; background: #293844; box-shadow: inset 0 1px #ffffff12; }
.action-bar-slot:hover:not(:disabled) { border-color: var(--ui-accent); }
.action-bar-empty { background: #1c2731; border-style: dashed; }
.compendium-table tr:hover td, .combat-turns tr:hover td { background: #ffffff0a; }
dialog, #token-context {
    color: #f4f1e8;
    background: #25323e;
    border: 1px solid #657685;
    border-radius: .7rem;
    box-shadow: 0 1.2rem 3rem #0009;
}
dialog::backdrop { background: #080d13b8; backdrop-filter: blur(3px); }
@media (max-width: 64rem) {
    .tabletop { gap: .75rem; }
    #tabletop-header { align-items: flex-start; }
}
@media (max-width: 42rem) {
    main:not(.room-page):not(.scene-editor-page) { margin-block: 1rem; padding-inline: .8rem; }
    .room-page, .scene-editor-page { padding-inline: .35rem; }
    #tabletop-header { padding: .65rem; }
    .tabletop-header-nav { flex-wrap: wrap; margin-inline-start: 0; }
    #tabletop-tabs button { flex: 1 1 28%; }
}
@media (prefers-reduced-motion: reduce) {
    button, .scene-icon, .compendium-create { transition: none; }
}


/* AP-46: shared component vocabulary. Keep layout decisions in the view-specific APs. */
:root {
    --ui-text: #f4f1e8;
    --ui-text-muted: #b4c0c9;
    --ui-field: #141d25;
    --ui-field-border: #718392;
    --ui-line: #40505d;
    --ui-primary: #edcb89;
    --ui-primary-hover: #f9dcaa;
    --ui-primary-text: #211b12;
    --ui-danger: #f2a69d;
    --ui-danger-surface: #493037;
    --ui-focus: #ffdc99;
    --ui-radius: .5rem;
    --ui-space: .75rem;
}
:where(button, input, select, textarea, .scene-icon, .sc-action, .compendium-create) {
    accent-color: var(--ui-primary);
}
:where(input, select, textarea):not([type="checkbox"]):not([type="radio"]) {
    border-color: var(--ui-field-border);
    background-color: var(--ui-field);
    color: var(--ui-text);
}
:where(input, select, textarea):disabled { opacity: .58; cursor: not-allowed; }
:where(input, select, textarea)[aria-invalid="true"] {
    border-color: var(--ui-danger);
    box-shadow: inset 0 0 0 1px var(--ui-danger);
}
:where(input, select, textarea):focus-visible,
:where(button, a, summary, [tabindex]):focus-visible {
    outline: 2px solid var(--ui-focus);
    outline-offset: 2px;
}
:where(button, .sc-action, .compendium-create) {
    border-radius: var(--ui-radius);
}
:where(button, .sc-action, .compendium-create):disabled,
:where(button, .sc-action, .compendium-create)[aria-disabled="true"] {
    opacity: .55;
    cursor: not-allowed;
}
:where(.scene-icon, .compendium-create, .sc-action):hover { border-color: var(--ui-primary); }
:where(button[aria-pressed="true"], button[aria-selected="true"]) {
    border-color: var(--ui-primary);
}
:where(button[aria-pressed="true"], button[aria-selected="true"]):focus-visible {
    outline-offset: 3px;
}
/* Quiet actions use a dark surface; destructive actions have a separate tone. */
:is(#scene-players-cancel, [data-handout-cancel], [data-folder-cancel],
       #cancel-map-label, #cancel-token-emote, #grid-cancel,
       .sc-roll-dialog button[type="button"], .action-bar-dialog button[type="button"]) {
    border: 1px solid var(--ui-field-border);
    background: var(--ui-surface-raised);
    color: var(--ui-text);
}
:is(#scene-players-cancel, [data-handout-cancel], [data-folder-cancel],
       #cancel-map-label, #cancel-token-emote, #grid-cancel,
       .sc-roll-dialog button[type="button"], .action-bar-dialog button[type="button"]):hover {
    background: #405363;
    border-color: #94a8b6;
}
:is([data-confirm-delete] button, [data-compendium-delete] button,
       #delete-map-object, #remove-background, button[value="disable"]) {
    border-color: #ab6870;
    background: var(--ui-danger-surface);
    color: #ffe5e0;
}
:is([data-confirm-delete] button, [data-compendium-delete] button,
       #delete-map-object, #remove-background, button[value="disable"]):hover:not(:disabled) {
    background: #653840;
    border-color: var(--ui-danger);
}
:where(section, .panel) { border-color: var(--ui-line); }
:where(fieldset) { min-width: 0; border: 1px solid var(--ui-line); border-radius: var(--ui-radius); }
:where(legend) { padding-inline: .3rem; color: var(--ui-primary); }
:where(table) { font-variant-numeric: tabular-nums; }
:where(th) { color: #f2ddba; }
:where(.compendium-table, .combat-turns) tr:focus-within { background: #ffffff12; }
:where(dialog) {
    max-width: calc(100vw - 2rem);
    max-height: calc(100dvh - 2rem);
    box-sizing: border-box;
    overflow: auto;
}
:where(dialog) h2:first-child { margin-top: 0; }
:where(dialog) .controls:last-child { margin-top: 1rem; }
:where([role="alert"]) { color: #ffd0c9; }
@media (prefers-reduced-motion: reduce) {
    :where(button, .scene-icon, .sc-action, .compendium-create) { transition: none; }
}


/* AP-47: make the next step obvious on entry and campaign pages. */
main[data-entry-view] {
    width: min(100%, 58rem);
    padding-inline: clamp(.8rem, 3vw, 1.5rem);
}
main[data-entry-view="account"] { width: min(100%, 32rem); }
main[data-entry-view="join"] { width: min(100%, 40rem); }
main[data-entry-view] > h1 {
    margin: 0 0 .55rem;
    font-size: clamp(var(--font-heading), 2.4vw, 1.8rem);
}
main[data-entry-view] > h1 + p { color: var(--ui-text-muted); }
main[data-entry-view] > .status[role="alert"] {
    padding: .75rem 1rem;
    border: 1px solid #ab6870;
    border-radius: var(--ui-radius);
    background: #493037;
}
main[data-entry-view="account"] .account-form {
    gap: .85rem;
    padding: clamp(1rem, 3vw, 1.5rem);
}
main[data-entry-view="account"] .account-form label { width: 100%; }
main[data-entry-view="account"] .account-form label > input:not([type="checkbox"]) {
    display: block;
    width: 100%;
    margin-top: .35rem;
}
main[data-entry-view="account"] .account-form button { width: 100%; }
main[data-entry-view="home"] .campaign-home-panel {
    padding: clamp(1rem, 2.5vw, 1.5rem);
}
.campaign-home-panel > form { margin-bottom: 1.1rem; }
.campaign-list { display: grid; gap: .7rem; list-style: none; margin: 0; padding: 0; }
.campaign-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    min-width: 0;
    padding: .85rem 1rem;
    border: 1px solid var(--ui-border);
    border-radius: var(--ui-radius);
    background: #17232d;
}
.campaign-card > div { min-width: 0; }
.campaign-card h2 { margin: 0 0 .25rem; overflow-wrap: anywhere; }
.campaign-card p { margin: 0; color: var(--ui-text-muted); overflow-wrap: anywhere; }
.campaign-open, .entry-primary-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .4rem;
    padding: .55rem .8rem;
    border: 1px solid var(--ui-primary);
    border-radius: var(--ui-radius);
    background: var(--ui-primary);
    color: var(--ui-primary-text);
    font-weight: 650;
    text-decoration: none;
    white-space: nowrap;
}
.campaign-open:hover, .entry-primary-link:hover {
    background: var(--ui-primary-hover);
    color: var(--ui-primary-text);
}
.campaign-card:focus-within { border-color: var(--ui-primary); }
main[data-entry-view="join"] .room-description {
    margin-block: .7rem 1.25rem;
    color: var(--ui-text-muted);
}
main[data-entry-view="join"] .entry-join { padding: 1.25rem; }
main[data-entry-view="join"] .entry-join p { margin-top: 0; }
main[data-entry-view="join"] > p:last-child { margin-top: 1.25rem; }
@media (max-width: 34rem) {
    .campaign-card { align-items: stretch; flex-direction: column; }
    .campaign-open { align-self: flex-start; }
}


/* AP-48: account and campaign management. */
main:has(> .account-identity) { width: min(100%, 62rem); }
.account-identity {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: .75rem 1.5rem;
    margin-block: 1.1rem;
    padding: .85rem 1.1rem;
}
.account-identity > div { display: grid; gap: .1rem; min-width: 0; }
.account-identity strong { font-size: var(--font-heading); overflow-wrap: anywhere; }
.account-identity span { color: var(--ui-text-muted); overflow-wrap: anywhere; }
.account-identity form { margin: 0; }
.account-identity button { background: var(--ui-surface-raised); color: var(--ui-text); border: 1px solid var(--ui-field-border); }
.account-identity button:hover { background: #405363; }
.account-portrait-form, .account-password-form { gap: .7rem; }
.account-portrait-form h2, .account-password-form h2 { margin: 0; }
.account-portrait-form .player-portrait { width: 5.5rem; height: 5.5rem; }
.account-portrait-form p { margin: .2rem 0; color: var(--ui-text-muted); }
.account-portrait-form label, .account-password-form label { width: min(100%, 30rem); }
.account-portrait-form input[type="file"], .account-password-form input:not([type="checkbox"]) {
    display: block;
    width: 100%;
    margin-top: .35rem;
}
.account-users .user-entry {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: .5rem 1rem;
    padding: .85rem 0;
}
.account-users .user-entry > .account-form { grid-column: 1 / -1; }
.account-users .user-entry > p { color: var(--ui-text-muted); }
.account-users button[value="disable"] { background: var(--ui-danger-surface); color: #ffe5e0; }
.campaign-invite, .campaign-profiles, .campaign-settings { scroll-margin-top: 1rem; }
.campaign-invite h2, .campaign-profiles h2, .campaign-settings h2 { margin: 0 0 .85rem; }
.campaign-invite #invite { flex: 1 1 16rem; width: 100%; }
.campaign-invite #invite-status:not(:empty) { margin-top: .5rem; color: var(--ui-primary); }
.campaign-shortcuts {
    margin-block: 1rem;
    padding: .65rem .85rem;
    border: 1px solid var(--ui-border);
    border-radius: var(--ui-radius);
    background: var(--ui-surface);
}
#player-profiles { display: grid; gap: .75rem; }
.player-profile-card {
    margin: 0;
    padding: .9rem 1rem;
    border: 1px solid var(--ui-border);
    border-radius: var(--ui-radius);
    background: #17232d;
}
.player-profile-heading {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: .25rem .8rem;
    width: 100%;
}
.player-profile-heading h3 { margin: 0; overflow-wrap: anywhere; }
.player-profile-heading span {
    padding: .15rem .5rem;
    border-radius: 100rem;
    background: var(--ui-surface-raised);
    color: var(--ui-text-muted);
}
.player-profile-card .campaign-palette { width: min(100%, 34rem); }
.player-profile-card label:not(.campaign-swatch) { max-width: 100%; }
.player-profile-card label > input:not([type="checkbox"]):not([type="radio"]),
.campaign-settings label > :is(input, textarea) {
    display: block;
    max-width: 100%;
    margin-top: .3rem;
}
.player-profile-card > button, .campaign-settings .account-form > button { justify-self: start; }
.campaign-settings .account-form { gap: .8rem; }
.campaign-settings .account-form > label { width: min(100%, 35rem); }
.campaign-settings textarea { width: 100%; }
@media (max-width: 36rem) {
    .account-users .user-entry { grid-template-columns: minmax(0, 1fr); }
    .account-users .user-entry > .account-form { grid-column: 1; }
    .account-identity { align-items: flex-start; }
}


/* Design preference: controls have square corners; round tokens and portraits stay round. */
button:not(.token):not(.sc-token-avatar),
input:is([type="button"], [type="submit"], [type="reset"]),
.scene-icon, .sc-action, .compendium-create,
.campaign-open, .entry-primary-link, .sc-tabs a, .panel-popout,
.compendium-actions summary {
    border-radius: 0 !important;
}


/* Square frames across the app. Circular tokens and illustrated portraits are exempt. */
:root { --ui-radius: 0; }
:is(section, .panel, fieldset, dialog, input, select, textarea,
    .campaign-card, .player-profile-card, .account-identity, .campaign-shortcuts,
    #tabletop-header, #tabletop-tabs, .tabletop-header-nav a,
    .scene-preview, .scene-icon, .sheet-list li, #handout-library li,
    #tabletop-map, .map-bar, .action-bar-slot, .dice-style-popup,
    .chat-avatar, .chat-inline-roll, .chat-mention-self,
    .combat-turns [aria-current="step"], .combat-actor-portrait,
    .map-label, .map-measure-result, .map-player-name, .player-profile-heading span,
    .user-entry, .sc-roster a, .sc-hero, .sc-resource, .sc-skills,
    .sc-combat, .sc-combat-stats > div, .sc-weapon, .sc-defenses,
    .sc-ability-card, .sc-journal-pages > div, .sc-roll-dialog,
    .sc-tabs a, .sc-action, #token-context) {
    border-radius: 0 !important;
}


/* AP-49: keep the map central and make navigation compact across widths. */
.room-page:not([data-popout]) { padding-inline: clamp(.35rem, .8vw, .85rem); }
#tabletop-header {
    gap: .5rem 1rem;
    padding: .55rem .8rem;
    border-color: #526471;
    border-left: 3px solid var(--ui-primary);
    background: #1b2630;
}
.tabletop-header-title { flex: 1 1 16rem; }
.tabletop-header-title h1 { line-height: 1.2; }
.tabletop-header-title p { margin-top: .2rem; font-size: var(--font-small); }
.tabletop-header-nav { align-items: center; flex-wrap: wrap; gap: .2rem; }
.tabletop-header-nav a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .35rem;
    grid-template-rows: none;
    min-height: 2.2rem;
    padding: .25rem .5rem;
    border: 1px solid transparent;
    font-size: var(--font-small);
    text-align: start;
}
.tabletop-header-nav a:hover, .tabletop-header-nav a:focus-visible { border-color: #607381; }
.tabletop-header-nav .button-icon { flex: 0 0 auto; }
.tabletop { align-items: stretch; margin-block: .55rem; }
#tabletop-layout > .tabletop-sidebar { min-width: 0; }
#tabletop-tabs:not([hidden]) {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1px;
    padding: 0;
    border: 1px solid #526471;
    background: #526471;
}
#tabletop-tabs button {
    min-width: 0;
    min-height: 2.35rem;
    padding: .3rem .2rem;
    overflow-wrap: anywhere;
    line-height: 1.15;
}
#tabletop-layout > #tabletop-map {
    border: 1px solid #718392;
    background: #111820;
    box-shadow: 0 .4rem 1.4rem #0007;
}
#tabletop-layout > #tabletop-rolls { border-color: #526471; }
@media (width > 64rem) {
    #tabletop-layout:not(.tabletop-adjustable) {
        grid-template-columns: minmax(16rem, 19rem) minmax(0, 1fr) clamp(15rem, 20%, 19rem);
    }
    #tabletop-layout.tabletop-adjustable {
        grid-template-columns: var(--tabletop-sidebar-track) .8rem minmax(0, 1fr) .8rem clamp(15rem, 20%, 19rem);
    }
    #tabletop-splitter::before { width: 3px; background: #607381; }
}
@media (48rem < width <= 64rem) {
    #tabletop-layout {
        grid-template-columns: minmax(14rem, 17rem) minmax(0, 1fr);
        grid-template-areas: "sidebar map" "chat chat";
        align-items: start;
    }
    #tabletop-layout > #tabletop-rolls { width: 100%; }
    #tabletop-layout #chat-scroll { max-height: 16rem; }
}
@media (width <= 48rem) {
    #tabletop-layout {
        grid-template-columns: minmax(0, 1fr);
        grid-template-areas: "map" "sidebar" "chat";
    }
    #tabletop-header { align-items: flex-start; }
    .tabletop-header-nav { margin-inline-start: 0; }
    #tabletop-tabs:not([hidden]) { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}


/* AP-50: scan-friendly sidebar lists and embedded sheets. */
.tabletop-sidebar .scene-sidebar { padding: .7rem; }
.sidebar-panel-heading {
    margin: 0 1.9rem .5rem 0;
    padding-bottom: .35rem;
    border-bottom: 1px solid var(--ui-border);
    color: #f5e4c2;
}
#scene-list { margin-top: .5rem; }
#scene-list li {
    grid-template-columns: repeat(4, 1.85rem) minmax(0, 1fr);
    gap: .2rem;
    padding: .4rem .2rem;
    border-bottom: 1px solid #40505d;
}
#scene-list li .scene-preview {
    grid-column: 1 / -1;
    width: 100%;
    min-height: 2rem;
    font-weight: 600;
}
#scene-list li .scene-preview[aria-pressed="true"] {
    border: 1px solid var(--ui-primary);
    border-left: 3px solid var(--ui-primary);
    background: #394a56;
    color: #fff3d6;
}
#scene-list li .scene-icon { background: #26333e; }
#handout-library { margin-top: .6rem; }
#handout-library li:not(.journal-folder),
#handout-new-image ~ #handout-library li:not(.journal-folder),
#handout-library li:has([data-handout-action="edit"]) {
    grid-template-columns: repeat(5, 1.85rem) minmax(0, 1fr);
    gap: .2rem;
    padding: .4rem .2rem;
    border-bottom: 1px solid #40505d;
}
#handout-library li:not(.journal-folder) > .scene-preview {
    grid-column: 1 / -1;
    width: 100%;
    text-align: start;
    font-weight: 600;
}
#handout-library li:not(.journal-folder) .scene-icon { background: #26333e; }
#handout-library .journal-folder { padding: .4rem 0; border-bottom: 1px solid #40505d; }
#handout-library .journal-folder summary { padding: .3rem .35rem; color: #f2ddba; font-weight: 650; }
#handout-library .journal-folder summary:hover,
#handout-library .journal-folder summary:focus-visible { background: #33424e; }
#handout-library .journal-folder ul {
    margin: .3rem 0 .1rem .45rem;
    padding-inline-start: .65rem;
    border-inline-start: 1px solid #607381;
}
#handout-library .journal-folder-actions { padding-inline: .35rem; }
.sheet-list { margin-top: .5rem; }
.sheet-list li { min-height: 2.3rem; border-bottom: 1px solid #40505d; }
.sheet-list li:has(a[aria-current="true"]) { background: #344550; box-shadow: inset 3px 0 var(--ui-primary); }
.sheet-list li > a:not(.scene-icon) { min-width: 0; overflow-wrap: anywhere; }
.sidebar-sheet {
    min-width: 0;
    margin-top: .75rem;
    border: 1px solid #607381;
    background: #18232d;
}
.sidebar-sheet-controls {
    align-items: center;
    gap: .3rem .6rem;
    margin: 0;
    padding: .45rem .55rem;
    background: #26333e;
}
.sidebar-sheet-controls [data-sheet-title] {
    flex: 1 0 100%;
    min-width: 0;
    overflow-wrap: anywhere;
    color: #f5e4c2;
    font-size: var(--font-normal);
}
.sidebar-sheet-controls [data-sheet-full] { min-width: 0; }
.sidebar-sheet-controls [data-sheet-close] {
    margin-inline-start: auto;
    padding: .25rem .45rem;
    border: 1px solid #718392;
    background: #33424e;
    color: var(--ui-text);
}
.sidebar-sheet iframe { background: #111820; }


/* AP-51: tool families and clear slot states. */
#tabletop-map-tool-bar {
    display: flex;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: .4rem .65rem;
}
.map-tool-groups { display: flex; flex-wrap: wrap; align-items: stretch; gap: .35rem; min-width: 0; }
.map-tool-group {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .25rem;
    padding: .25rem .35rem;
    border: 1px solid #526471;
    background: #1b2832;
}
.map-tool-group-label {
    margin-inline-end: .2rem;
    color: #c5d0d8;
    font-size: var(--font-small);
    font-weight: 650;
}
.map-tool-group .icon-button {
    min-width: 2.1rem;
    min-height: 2.1rem;
    padding: .25rem;
    border: 1px solid #647787;
    background: #344550;
    color: var(--ui-text);
}
.map-tool-group .icon-button .button-icon { color: var(--ui-text); }
#drawing-tools button[aria-pressed="true"],
#fog-tools button[aria-pressed="true"],
#tabletop-map-tool-bar [data-tile-mode][aria-pressed="true"],
#tabletop-map-tool-bar #place-map-asset[aria-pressed="true"] {
    outline: none;
    border-color: var(--ui-primary);
    background: #665538;
    color: #fff5e2;
    box-shadow: inset 0 -3px var(--ui-primary);
}
#drawing-tools button[aria-pressed="true"] .button-icon { color: #fff5e2; }
#drawing-tools button:focus-visible,
#fog-tools button:focus-visible { outline: 2px solid var(--ui-focus); outline-offset: 2px; }
#tabletop-map-tool-bar details {
    min-width: 0;
    padding: .25rem .45rem;
    border: 1px solid #526471;
    background: #1b2832;
}
#tabletop-map-tool-bar details[open] { border-color: var(--ui-primary); }
#tabletop-map-tool-bar details summary { color: #f2ddba; }
#tabletop-map-action-bar { padding-block: .4rem; }
#action-bar { grid-template-columns: repeat(10, minmax(0, 3.5rem)); gap: clamp(.15rem, .5vw, .4rem); }
#action-bar .action-bar-slot {
    position: relative;
    border: 1px solid #78909e;
    background: #2d3e4c;
    color: var(--ui-text);
}
#action-bar .action-bar-slot[data-kind="skill"] { border-top: 3px solid #a8c9db; }
#action-bar .action-bar-slot[data-kind="attack"] { border-top: 3px solid #dfab9d; }
#action-bar .action-bar-slot[data-kind="talent"] { border-top: 3px solid #e8cc90; }
#action-bar .action-bar-slot[data-kind="spell"] { border-top: 3px solid #bfafe4; }
#action-bar .action-bar-empty {
    border: 1px dashed #6c7b87;
    background: #19252f;
    color: #c0cbd3;
}
#action-bar .action-bar-empty .action-bar-icon { visibility: visible; opacity: .6; }
#action-bar .action-bar-unavailable {
    border-style: dashed;
    background: #263038;
    color: #c7cdd0;
    opacity: .72;
    filter: none;
}
#action-bar .action-bar-triggered {
    border-color: var(--ui-primary);
    background: #665538;
    box-shadow: inset 0 0 0 2px var(--ui-primary);
}
#action-bar .action-bar-slot:hover:not(:disabled),
#action-bar .action-bar-slot:focus-visible { border-color: var(--ui-primary); }
#action-bar .action-bar-slot kbd { color: #d0dae1; font-variant-numeric: tabular-nums; }
#action-bar .action-bar-name { font-weight: 650; }
@media (max-width: 48rem) {
    #tabletop-map-tool-bar { gap: .35rem; }
    .map-tool-group-label { flex-basis: 100%; }
    #action-bar .action-bar-slot { min-height: 2.5rem; }
}

/* Embedded hero sheet has no second toolbar or frame. */
#sc-sidebar-sheet { margin-top: .45rem; border: 0; background: transparent; }
#sc-sidebar-sheet iframe { background: transparent; }


/* AP-52: readable conversation and combat status in narrow columns. */
.chat-panel-heading {
    margin: 0 0 .4rem;
    padding-bottom: .35rem;
    border-bottom: 1px solid var(--ui-border);
    font-size: var(--font-heading);
}
#tabletop-roll-log { min-height: 0; }
#roll-log { display: grid; gap: .35rem; margin: .35rem 0; }
#roll-log > li {
    min-width: 0;
    padding: .55rem .4rem;
    border: 1px solid #465a68;
    background: #17242e;
    line-height: 1.4;
}
#roll-log > li + li { border-top: 1px solid #465a68; }
#roll-log > li.chat-combat-event { background: #28303a; }
#roll-log .chat-entry { min-width: 0; overflow-wrap: anywhere; }
#roll-log .chat-metadata { justify-content: space-between; gap: .15rem .45rem; margin-bottom: .35rem; }
#roll-log .chat-author { min-width: 0; overflow-wrap: anywhere; line-height: 1.3; }
#roll-log .chat-time { color: #c1cbd2; }
#roll-log .chat-visibility {
    padding: 0 .3rem;
    border: 1px solid #89929c;
    color: #e0e5e8;
    font-size: var(--font-small);
}
#roll-log .chat-message { line-height: 1.45; }
#roll-log .chat-reroll { margin-top: .3rem; min-height: 1.65rem; }
#tabletop-roll-input, #tabletop-chat-input {
    padding-top: .6rem;
    border-top: 1px solid #526471;
}
#tabletop-roll-input label, #tabletop-chat-input label { margin-bottom: .3rem; }
#chat-form { margin-top: .25rem; }
.chat-send-controls, .chat-audience { align-items: center; }
.chat-audience button[aria-pressed="true"] {
    border-color: var(--ui-primary);
    box-shadow: inset 0 -2px #211b12;
}
#tabletop-combat > h2 {
    margin: 0 0 .4rem;
    padding-bottom: .35rem;
    border-bottom: 1px solid var(--ui-border);
}
#tabletop-combat [data-combat-status] {
    margin: .25rem 0 .7rem;
    color: #f2ddba;
    font-weight: 650;
}
.combat-turns { table-layout: fixed; }
.combat-turns th:first-child { width: 3.25rem; }
.combat-turns th:nth-child(3), .combat-turns th:nth-child(4) { width: 2.25rem; }
.combat-turns th, .combat-turns td { padding: .35rem .15rem; vertical-align: top; }
.combat-turns tbody tr[aria-current="step"] {
    background: #394c58;
    box-shadow: inset 3px 0 var(--ui-primary);
}
.combat-tracker-actor { min-width: 0; }
.combat-actor-line { min-width: 0; gap: .2rem; }
.combat-actor-line strong { overflow-wrap: anywhere; }
.combat-tracker-conditions { margin-block: .2rem; }
.combat-tracker-conditions > span { padding: 0 .12rem; background: #17242e; }
.combat-tracker-health { margin-top: .3rem; }
.combat-tracker-health meter { flex: 1 1 3rem; width: auto; min-width: 2.5rem; }
.combat-tracker-health > span { font-size: var(--font-small); white-space: nowrap; }
.combat-turns button { max-width: 100%; }
.combat-tracker-controls button[data-combat-command="next"],
.combat-tracker-controls button[data-combat-command="start"] {
    border: 1px solid var(--ui-primary);
    background: var(--ui-primary);
    color: var(--ui-primary-text);
}
.combat-tracker-controls button[data-combat-command="end"] {
    border: 1px solid #ab6870;
    background: var(--ui-danger-surface);
    color: #ffe5e0;
}

/* AP-56: compact compendium list in the sidebar. */
.scene-sidebar .compendium-list-table { display: block; min-width: 0; }
.scene-sidebar .compendium-list-table thead { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.scene-sidebar .compendium-list-table tbody { display: grid; gap: .45rem; }
.scene-sidebar .compendium-list-table tr {
    display: grid;
    grid-template-columns: minmax(0, 1fr) repeat(3, auto);
    gap: .2rem .4rem;
    align-items: center;
    padding: .45rem .55rem;
    border: 1px solid var(--ui-line, #52616a);
    background: var(--ui-surface, #202b35);
}
.scene-sidebar .compendium-list-table td { min-width: 0; padding: 0; border: 0; }
.scene-sidebar .compendium-list-table td:first-child { grid-column: 1 / -1; font-weight: 700; overflow-wrap: anywhere; }
.scene-sidebar .compendium-list-table td:first-child a { display: inline-block; max-width: 100%; overflow-wrap: anywhere; }
.scene-sidebar .compendium-list-table td:nth-child(2) { grid-column: 1; color: var(--ui-text-muted, #c4d0d8); font-size: var(--font-small); }
.scene-sidebar .compendium-list-table td:nth-child(n+3) { justify-self: end; }
.scene-sidebar .compendium-list-table td form { margin: 0; }
.scene-sidebar .compendium-list-table :is(.scene-icon, button) { min-width: 2rem; min-height: 2rem; }

/* AP-57: scene management, dialogs and token preview. */
.scene-editor-page { display: grid; gap: .65rem; align-content: start; min-width: 0; }
.scene-editor-heading { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem; padding: .55rem .75rem; border: 1px solid var(--ui-line, #657685); background: #202d38; }
.scene-editor-heading h1 { margin: 0; font-size: var(--font-heading); }
.scene-editor-heading a { display: inline-flex; align-items: center; min-height: 2rem; padding: .3rem .65rem; border: 1px solid var(--ui-line, #657685); background: #293b48; text-decoration: none; }
.scene-editor-management { display: flex; flex-wrap: wrap; align-items: end; gap: .5rem .8rem; padding: .65rem .75rem; border: 1px solid var(--ui-line, #657685); background: #202d38; }
.scene-editor-management form { display: flex; flex-wrap: wrap; align-items: end; gap: .5rem; margin: 0; }
.scene-editor-management form label { margin: 0; }
.scene-editor-management form input { display: block; min-width: min(16rem, 100%); margin-top: .2rem; }
.scene-editor-management [data-confirm-delete] { margin-inline-start: auto; padding-inline-start: .8rem; border-inline-start: 1px solid var(--ui-line, #657685); }
.scene-editor-management #scene-editor-status { flex: 1 0 100%; margin: 0; }
.scene-editor-map-panel { min-width: 0; padding: .65rem; border: 1px solid var(--ui-line, #657685); background: #202d38; }
.scene-editor-map-panel h2 { margin: 0 0 .5rem; }
:is(#scene-players-dialog, #journal-folder-dialog, #handout-upload-dialog,
    #handout-show-dialog, #handout-access-dialog, #map-image-drop,
    #quick-note-dialog, #token-emote-dialog, #map-label-dialog,
    #combat-token-dialog, #token-maker-dialog) {
    box-sizing: border-box;
    width: min(34rem, calc(100vw - 1.5rem));
    max-height: min(90dvh, 52rem);
    overflow-y: auto;
    padding: 1rem;
    border-radius: 0;
}
:is(#scene-players-dialog, #journal-folder-dialog, #handout-upload-dialog,
    #handout-show-dialog, #handout-access-dialog, #map-image-drop,
    #quick-note-dialog, #token-emote-dialog, #map-label-dialog,
    #combat-token-dialog, #token-maker-dialog) :is(h2:first-child, form > h2:first-child) {
    margin: 0 0 .75rem;
    padding-bottom: .5rem;
    border-bottom: 1px solid var(--ui-line, #657685);
    color: var(--ui-primary, #edcb89);
}
:is(#scene-players-dialog, #journal-folder-dialog, #handout-upload-dialog,
    #handout-show-dialog, #handout-access-dialog, #map-image-drop,
    #quick-note-dialog, #token-emote-dialog, #map-label-dialog,
    #combat-token-dialog, #token-maker-dialog) .controls:last-child,
:is(#scene-players-dialog, #journal-folder-dialog, #handout-upload-dialog,
    #handout-show-dialog, #handout-access-dialog, #map-image-drop,
    #quick-note-dialog, #token-emote-dialog, #map-label-dialog,
    #combat-token-dialog, #token-maker-dialog) form > .controls {
    display: flex;
    flex-wrap: wrap;
    gap: .4rem;
    padding-top: .7rem;
    border-top: 1px solid var(--ui-line, #657685);
}
:is(#scene-players-dialog, #journal-folder-dialog, #handout-upload-dialog,
    #handout-show-dialog, #handout-access-dialog, #map-image-drop,
    #quick-note-dialog, #token-emote-dialog, #map-label-dialog,
    #combat-token-dialog, #token-maker-dialog) :is(input, select, textarea, fieldset) { max-width: 100%; box-sizing: border-box; }
#token-maker-dialog .token-maker-preview { display: grid; place-items: center; padding: .6rem; margin-bottom: .7rem; border: 1px solid var(--ui-line, #657685); background: #17232d; }
#token-maker-dialog .token-maker-preview canvas { margin: 0; }
@media (max-width: 42rem) {
    .scene-editor-management [data-confirm-delete] { margin-inline-start: 0; padding-inline-start: 0; border-inline-start: 0; }
    .scene-editor-management form input { min-width: 0; width: 100%; }
}

#token-maker-dialog form > .controls:not(:last-child) { border-top: 0; padding-top: 0; }

/* Give the embedded hero sheet the sidebar width. */
.tabletop-sidebar #tabletop-sc .scene-sidebar:has(> #sc-sidebar-sheet:not([hidden])) { padding-inline: .35rem; }
#sc-sidebar-sheet { width: 100%; min-width: 0; box-sizing: border-box; }
#sc-sidebar-sheet iframe { width: 100%; box-sizing: border-box; }
.room-page[data-embedded-sheet] { width: 100%; max-width: none; padding: .2rem 0; }

/* Embedded hero sheet: remove the surrounding panel inset. */
.tabletop-sidebar #tabletop-sc .scene-sidebar:has(> #sc-sidebar-sheet:not([hidden])) { padding-inline: 0; padding-bottom: 0; }
.tabletop-sidebar #sc-sidebar-sheet { margin-top: 0; }

/* The embedded sheet is a section and must not inherit section padding. */
#sc-sidebar-sheet {
    padding: 0;
    margin-block: 0;
}

/* Classic RPG visual language across the VTT. Keep the map artwork untouched. */
:root {
    --ui-canvas: #101720;
    --ui-surface: #1d2935;
    --ui-surface-raised: #2a3949;
    --ui-border: #705f4b;
    --ui-line: #776a59;
    --ui-accent: #f1cf8d;
    --ui-primary: #f1cf8d;
    --ui-primary-hover: #ffe2a8;
    --ui-focus: #ffe2a8;
    --ui-text: #f5eddd;
    --ui-text-muted: #c8c5bd;
    --ui-field: #121d29;
    --ui-field-border: #887b69;
}
body {
    color: var(--ui-text);
    background:
        radial-gradient(ellipse at 50% -14rem, #3d3746 0, transparent 52rem),
        linear-gradient(#15212c, var(--ui-canvas));
}
:is(main[data-entry-view] > h1, .tabletop-header-title h1, .scene-editor-heading h1) {
    color: #ffe4ae;
    font-family: Georgia, serif;
    text-shadow: 1px 2px #0d141d;
}
:is(.campaign-home-panel, .campaign-card, .account-identity, #tabletop-header,
    .tabletop-sidebar .scene-sidebar, #tabletop-rolls, .scene-editor-management,
    .scene-editor-map-panel, dialog) {
    border-color: #857155;
    background:
        repeating-linear-gradient(135deg, #ffffff03 0 1px, transparent 1px 8px),
        radial-gradient(ellipse at 100% 0%, #51435544, transparent 60%),
        linear-gradient(155deg, #263340, #192532 76%);
    box-shadow: inset 0 0 0 2px #111c28, 0 .3rem 1rem #080d1359;
}
:is(.campaign-home-panel, #tabletop-header, .tabletop-sidebar .scene-sidebar,
    #tabletop-rolls, .scene-editor-management, .scene-editor-map-panel) {
    border-top: 2px solid #b19161;
}
:is(.campaign-card, .account-identity) { border-inline-start: 3px solid #b19161; }
:is(.campaign-card, .scene-preview, .sheet-list li, #handout-library li:not(.journal-folder)):hover {
    border-color: #c7a56b;
    background-color: #344054;
}
:is(#tabletop-header, .tabletop-sidebar .scene-sidebar, #tabletop-rolls) h2,
:is(.scene-editor-map-panel, .campaign-home-panel) h2 {
    color: #f5d495;
    font-family: Georgia, serif;
    letter-spacing: .01em;
}
.sidebar-panel-heading, .chat-panel-heading {
    border-bottom-color: #ad8c60;
    color: #f5d495;
    text-shadow: 1px 1px #101820;
}
#tabletop-tabs:not([hidden]) {
    border: 1px solid #806b4e;
    background: linear-gradient(#222e3b, #111d29);
}
#tabletop-tabs button {
    border: 1px solid #617080;
    border-radius: 0;
    background: #253444;
    color: #f0e5d0;
    font-weight: 700;
}
#tabletop-tabs button[aria-selected="true"] {
    border-color: #f2d095;
    background: linear-gradient(#f5d79e, #d3a969);
    color: #241c17;
    box-shadow: inset 0 1px #fff2d0;
}
:is(.tabletop-header-nav a, .scene-editor-heading a, .compendium-create, .compendium-actions summary) {
    border: 1px solid #9a805c;
    background: #283849;
    color: #f5d495;
    font-weight: 700;
    text-decoration: none;
}
:is(.scene-preview, .sheet-list li, #handout-library li:not(.journal-folder)) {
    border-inline-start: 3px solid #917a5a;
    background: linear-gradient(100deg, #263544, #1d2b38);
}
.scene-preview[aria-pressed="true"] {
    border-inline-start-color: #f6d99e;
    background: linear-gradient(100deg, #5a4a48, #3a4050);
    color: #fff1d5;
}
.scene-icon {
    border-color: #88785f;
    background: #293846;
    color: #f6dfa9;
}
.scene-icon:hover:not(:disabled), .scene-icon:focus-visible {
    border-color: #f5d495;
    background: #3d4756;
}
:is(button:not(.scene-icon):not(.icon-button):not(.action-bar-slot),
    .sc-action, .compendium-create) { border-bottom-width: 2px; }
:is(button, .scene-icon, .icon-button, .sc-action, input, select, textarea, fieldset, dialog) { border-radius: 0; }
:is(input, select, textarea) {
    border-color: var(--ui-field-border);
    background: #121d29;
    color: #f5eddd;
}
:is(input, select, textarea):focus-visible { border-color: #f3ce89; }
:is(.chat-message, .chat-roll, .combat-turns tbody tr, .compendium-table tbody tr) {
    border-color: #6b665e;
}
#tabletop-roll-log { border-bottom-color: #806b4e; }
#tabletop-rolls :is(.chat-author, .chat-roll-die) { color: #f5d495; }
.chat-audience button[aria-pressed="true"] {
    border-color: #f2d095;
    background: #e8c382;
    color: #201b18;
}
.combat-turns thead, .compendium-table thead {
    border-bottom: 2px solid #b7935f;
    background: #293745;
}
.combat-turns th, .compendium-table th { color: #f7dca9; }
.combat-turns tbody tr:nth-child(even), .compendium-table tbody tr:nth-child(even) { background: #ffffff07; }
.combat-turns [aria-current="step"] {
    border-inline-start: 3px solid #f2cd8b;
    background: #504747;
}
:is(dialog, .scene-editor-map-panel, .scene-editor-management) h2 {
    color: #f5d495;
    font-family: Georgia, serif;
}
:is(dialog, .scene-editor-management) .controls { border-top-color: #8c7556; }
#token-maker-dialog .token-maker-preview {
    border-color: #a3865b;
    background:
        repeating-linear-gradient(135deg, #ffffff05 0 1px, transparent 1px 8px),
        #15222f;
}
/* The sidebar sheet stays flush against its outer container. */
#sc-sidebar-sheet { padding: 0; margin-block: 0; background: transparent; box-shadow: none; }

/* No vertical accent strokes. Selection is conveyed by surface and outline. */
#scene-list li .scene-preview[aria-pressed="true"],
.scene-preview[aria-pressed="true"],
.sheet-list li:has(a[aria-current="true"]),
.combat-turns tbody tr[aria-current="step"] {
    border-inline-start-width: 1px;
    box-shadow: none;
}
:is(.campaign-card, .account-identity) { border-inline-start-width: 1px; }
:is(.scene-preview, .sheet-list li, #handout-library li:not(.journal-folder)) { border-inline-start: 0; }
.combat-turns [aria-current="step"] { border-inline-start: 0; }
.scene-editor-management [data-confirm-delete] { border-inline-start: 0; padding-inline-start: 0; }
#roll-log blockquote { border-inline-start: 0; }
#handout-library .journal-folder ul { border-inline-start: 1px solid #7198b6; }
[data-edit-map] #tabletop-map-tool-bar { border-inline-end: 0; }

#tabletop-header { border-left-width: 1px; border-left-color: #857155; }

/* Neutral stone beneath translucent UI color. The map canvas remains clear. */
:root { --ui-stone: url("assets/stone-texture.svg"); }
:is(.campaign-home-panel, .campaign-card, .account-identity, #tabletop-header,
    .tabletop-sidebar .scene-sidebar, #tabletop-rolls, .scene-editor-management,
    .scene-editor-map-panel, dialog) {
    background-image:
        linear-gradient(155deg, #393a3dd9, #252629e8),
        var(--ui-stone);
    background-color: #303033;
    background-repeat: no-repeat, repeat;
    background-size: auto, 192px 192px;
}
:is(.scene-preview, .sheet-list li, #handout-library li:not(.journal-folder),
    .compendium-list-table tr) {
    background-image: linear-gradient(100deg, #414347d9, #2c2e32e0), var(--ui-stone);
    background-repeat: no-repeat, repeat;
    background-size: auto, 192px 192px;
}
:is(.scene-preview[aria-pressed="true"], #tabletop-tabs button[aria-selected="true"]) {
    background-image: linear-gradient(100deg, #7d5d48d6, #554557d9), var(--ui-stone);
    color: #fff0d5;
}
:is(.scene-preview, .sheet-list li, #handout-library li:not(.journal-folder)):hover {
    background-image: linear-gradient(100deg, #55585ed9, #393c42df), var(--ui-stone);
}
#tabletop-tabs:not([hidden]) {
    background-image: linear-gradient(#383a3ee0, #222428e8), var(--ui-stone);
    background-size: auto, 192px 192px;
}
#tabletop-tabs button:not([aria-selected="true"]) {
    background-image: linear-gradient(#47494ddb, #303237e3), var(--ui-stone);
    background-size: auto, 192px 192px;
}
:is(dialog, .scene-editor-management) fieldset {
    background-image: linear-gradient(#3a3b3fdf, #292b2fe8), var(--ui-stone);
    background-size: auto, 192px 192px;
}

/* Slate-grey base beneath the stone; functional resource colors remain. */
:root {
    --ui-canvas: #18191c;
    --ui-surface: #28292d;
    --ui-surface-raised: #393b40;
    --ui-field: #202226;
}
body {
    background: radial-gradient(ellipse at 50% -14rem, #444046, transparent 52rem), #18191c;
}
:is(input, select, textarea) { background-color: #202226; }

/* Fine horizontal grain and a polished edge on gold primary controls. */
:root { --ui-brushed-metal: url("assets/brushed-metal.svg"); }
button:not(.scene-icon):not(.icon-button):not(.action-bar-slot):not([type="button"]):not([aria-pressed]):not([aria-selected]):not([value="delete"]):not([value="disable"]):not(.sc-advancement-discard):not(:is([data-confirm-delete] button, [data-compendium-delete] button)),
#tabletop-tabs button[aria-selected="true"],
.chat-audience button[aria-pressed="true"],
.scene-preview[aria-pressed="true"] {
    background-image: linear-gradient(180deg, #fff9df7a 0%, #f5d79723 42%, #78502547 100%), var(--ui-brushed-metal);
    background-size: auto, 192px 192px;
    border-top-color: #ffe4a6;
    border-bottom-color: #8a663b;
    box-shadow: inset 0 1px #fff9db94, inset 0 -1px #74512f73;
}
button:not(.scene-icon):not(.icon-button):not(.action-bar-slot):not([type="button"]):not([aria-pressed]):not([aria-selected]):not([value="delete"]):not([value="disable"]):not(.sc-advancement-discard):not(:is([data-confirm-delete] button, [data-compendium-delete] button)):hover:not(:disabled),
#tabletop-tabs button[aria-selected="true"]:hover,
.chat-audience button[aria-pressed="true"]:hover {
    background-image: linear-gradient(180deg, #fffce3a0 0%, #f9d99540 42%, #78502538 100%), var(--ui-brushed-metal);
}

/* Interactive control audit: one vocabulary for actions, navigation and toggles. */
:root {
    --control-edge: #aa8a5d;
    --control-surface: #35373c;
    --control-surface-hover: #48494e;
}
:is(button, .campaign-open, .entry-primary-link, .compendium-create,
    .tabletop-header-nav a, .scene-editor-heading a, .panel-popout,
    .scene-icon, .scene-preview, .action-bar-slot, .chat-reroll,
    .compendium-actions summary) {
    border-radius: 0;
    text-decoration-thickness: auto;
}
:is(.campaign-open, .entry-primary-link, .compendium-create,
    .scene-editor-heading a, .tabletop-header-nav a) {
    box-sizing: border-box;
    min-height: 2.3rem;
}
:is(.campaign-open, .entry-primary-link) {
    border: 1px solid #e6c487;
    border-bottom: 2px solid #836137;
    background-color: #dfbb78;
    background-image: linear-gradient(180deg, #fff9df7a, #f5d79723 42%, #78502547), var(--ui-brushed-metal);
    background-size: auto, 192px 192px;
    color: #211b12;
    box-shadow: inset 0 1px #fff9db94, inset 0 -1px #74512f73;
}
:is(.campaign-open, .entry-primary-link):hover {
    background-color: #f2d393;
    background-image: linear-gradient(180deg, #fffce3a0, #f9d99540 42%, #78502538), var(--ui-brushed-metal);
    color: #211b12;
}
:is(.compendium-create, .scene-editor-heading a, .tabletop-header-nav a,
    .compendium-actions summary, .panel-popout) {
    border: 1px solid #a18a68;
    background-color: #34373c;
    color: #f5d495;
}
:is(.compendium-create, .scene-editor-heading a, .tabletop-header-nav a,
    .compendium-actions summary, .panel-popout):hover {
    border-color: #f2d095;
    background-color: #4a4a4e;
    color: #ffebbd;
}
:is(.scene-icon, .icon-button, .chat-reroll) {
    border: 1px solid #9e8968;
    border-radius: 0;
    background-color: #34373c;
    color: #f6dba7;
}
:is(.scene-icon, .icon-button, .chat-reroll):hover:not(:disabled) {
    border-color: #f2d095;
    background-color: #505055;
    color: #ffebbd;
}
:is(.scene-icon, .icon-button) .button-icon { color: currentColor; }
:is(.scene-icon, .icon-button, .journal-folder-icon, .chat-reroll):focus-visible {
    outline: 2px solid var(--ui-focus);
    outline-offset: 2px;
}
.journal-folder-icon:hover:not(:disabled) { color: #ffe3a7; background: #ffffff16; }
:is(.controls, .sc-nav) > a:not(.scene-icon) {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 2.3rem;
    padding: .4rem .7rem;
    border: 1px solid #a18a68;
    background: #34373c;
    color: #f5d495;
    font-weight: 700;
    text-decoration: none;
}
:is(.controls, .sc-nav) > a:not(.scene-icon):hover {
    border-color: #f2d095;
    background: #4a4a4e;
}
:is(.controls, dialog) button[type="button"]:not(.scene-icon):not(.icon-button),
:is(.controls, dialog) button[data-handout-cancel],
:is(.controls, dialog) button[data-folder-cancel] {
    border: 1px solid #9a8c77;
    background-color: #34373c;
    background-image: none;
    color: #f0e3cd;
}
:is(.controls, dialog) button[type="button"]:not(.scene-icon):not(.icon-button):hover,
:is(.controls, dialog) button[data-handout-cancel]:hover,
:is(.controls, dialog) button[data-folder-cancel]:hover {
    border-color: #d0b88b;
    background-color: #505055;
}
:is([data-confirm-delete] button, [data-compendium-delete] button,
    #delete-map-object, #remove-background, button[value="disable"],
    .account-users button[value="disable"]) {
    background-image: none;
    border-color: #ab6870;
    background-color: var(--ui-danger-surface);
    color: #ffe5e0;
}
:is([data-confirm-delete] button, [data-compendium-delete] button,
    #delete-map-object, #remove-background, button[value="disable"]):hover:not(:disabled) {
    background-color: #653840;
    border-color: var(--ui-danger);
}
:is(.action-bar-slot, .scene-preview) {
    border-color: #928069;
    background-color: #373b40;
}
:is(.action-bar-slot, .scene-preview):hover:not(:disabled) { border-color: #eccb8f; }
:is(.compendium-actions summary, #tabletop-map-tool-bar details summary,
    .sc-ability-card summary) { cursor: pointer; }
:is(.compendium-actions summary, #tabletop-map-tool-bar details summary):focus-visible {
    outline: 2px solid var(--ui-focus);
    outline-offset: 2px;
}
:where(button, a, summary)[aria-disabled="true"] {
    opacity: .55;
    cursor: not-allowed;
    pointer-events: none;
}

/* Menus and toolbar controls created dynamically use the same secondary surface. */
:is(#open-token-character, [data-sheet-full]) {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 2.3rem;
    padding: .4rem .7rem;
    border: 1px solid #a18a68;
    background: #34373c;
    color: #f5d495;
    font-weight: 700;
    text-decoration: none;
}
:is(#open-token-character, [data-sheet-full]):hover {
    border-color: #f2d095;
    background: #4a4a4e;
}
:is(#token-context button:not([value="delete"]):not(#delete-map-object):not(#remove-background), #handout-format-bar button,
    .map-tool-group button:not([aria-pressed="true"]):not(#delete-map-object):not(#remove-background)) {
    border: 1px solid #97866e;
    background-color: #34373c;
    background-image: none;
    color: #f1e6d2;
}
:is(#token-context button:not([value="delete"]):not(#delete-map-object):not(#remove-background), #handout-format-bar button,
    .map-tool-group button:not([aria-pressed="true"]):not(#delete-map-object):not(#remove-background)):hover:not(:disabled) {
    border-color: #f2d095;
    background-color: #4a4a4e;
}
#tabletop-map-tool-bar details summary {
    padding: .35rem .55rem;
    border: 1px solid #a18a68;
    background: #34373c;
    color: #f5d495;
}
#tabletop-map-tool-bar details[open] summary { border-color: #f2d095; background: #514846; }

#open-token-character[hidden], [data-sheet-full][hidden] { display: none; }

/* Initiative controls in the combat tracker match sheet roll controls. */
.combat-tracker-controls :is(button[data-combat-command="roll-all"], button[type="submit"]),
.combat-turns button[data-combat-command="roll"] {
    border: 1px solid #a28c68;
    border-radius: 0;
    background-color: #343940 !important;
    background-image: linear-gradient(180deg, #ffffff38, #1b232b33 65%, #0c141c78), url("assets/brushed-metal.svg") !important;
    background-size: auto, 192px 192px;
    color: #fff0d8;
    font-weight: 700;
    text-shadow: 1px 1px #101820;
    box-shadow: inset 0 1px #ffffff45, inset 0 -1px #0e151c99;
}
.combat-tracker-controls :is(button[data-combat-command="roll-all"], button[type="submit"]):hover:not(:disabled),
.combat-turns button[data-combat-command="roll"]:hover:not(:disabled) {
    border-color: #f2d095;
    background-color: #4b5057 !important;
    background-image: linear-gradient(180deg, #ffffff55, #26344240 65%, #0c141c66), url("assets/brushed-metal.svg") !important;
    color: #fff5df;
}
.combat-turns button[data-combat-command="roll"] .button-icon { color: currentColor; }

/* Combat resources stay on one readable row in narrow sidebars. */
.combat-tracker-health {
    display: grid;
    grid-template-columns: minmax(2rem, 1fr) auto auto;
    align-items: center;
    gap: .3rem;
    width: 100%;
    min-width: 0;
    margin-top: .4rem;
}
.combat-tracker-health meter { width: 100%; min-width: 0; height: .8rem; }
.combat-tracker-health > span { white-space: nowrap; font-variant-numeric: tabular-nums; }
.combat-resource-controls { display: flex; flex-wrap: nowrap; gap: .2rem; }
.combat-resource-form {
    display: grid;
    grid-template-columns: minmax(3.4rem, auto) minmax(2rem, 1fr) minmax(3.7rem, 4.2rem) auto 2rem;
    align-items: center;
    gap: .25rem;
    width: 100%;
    min-width: 0;
    margin: .35rem 0;
}
.combat-resource-label, .combat-resource-limit { white-space: nowrap; }
.combat-resource-form meter { width: 100%; min-width: 0; height: .8rem; }
.combat-resource-form input[type="number"] {
    width: 100%;
    min-width: 0;
    padding: .25rem .15rem .25rem .35rem;
    font-variant-numeric: tabular-nums;
}
.combat-resource-form[data-resource="wp"] { --combat-resource-color: #91c5df; }
.combat-resource-form[data-resource="gp"] { --combat-resource-color: #e2c384; }
.combat-resource-form meter::-webkit-meter-optimum-value { background: var(--combat-resource-color, #88c696); }
.combat-resource-form meter::-moz-meter-bar { background: var(--combat-resource-color, #88c696); }
:is(.combat-tracker-health .combat-resource-controls button, .combat-resource-form button) {
    min-width: 2rem;
    min-height: 2rem;
    padding: 0 .2rem;
    border: 1px solid #a28c68;
    background-color: #343940 !important;
    background-image: linear-gradient(180deg, #ffffff38, #1b232b33 65%, #0c141c78), url("assets/brushed-metal.svg") !important;
    color: #fff0d8;
    font-weight: 700;
}
:is(.combat-tracker-health .combat-resource-controls button, .combat-resource-form button):hover:not(:disabled) {
    border-color: #f2d095;
    background-color: #4b5057 !important;
}
.combat-tracker-conditions button[title="Zustand hinzufügen"] {
    min-width: 2rem;
    font-family: "Segoe UI Symbol", "Noto Sans Symbols 2", sans-serif;
    font-variant-emoji: text;
    color: #f5d495;
}
@media (max-width: 27rem) {
    .combat-resource-form { grid-template-columns: minmax(2.8rem, auto) minmax(1.5rem, 1fr) minmax(3.4rem, 3.8rem) auto 1.8rem; gap: .15rem; }
    .combat-resource-controls { gap: .1rem; }
    :is(.combat-tracker-health .combat-resource-controls button, .combat-resource-form button) { min-width: 1.8rem; }
}

/* Compact combat tracker: use the entire sidebar width. */
#tabletop-combat { padding: 0; }
#tabletop-combat > :is(h2, [data-combat-status], .panel-popout, .combat-tracker-controls) { margin-inline: .55rem; }
#tabletop-combat [data-combat-content] { min-width: 0; }
#tabletop-combat .combat-turns { margin: .35rem 0; }
#tabletop-combat .combat-turns th,
#tabletop-combat .combat-turns td { padding-inline: .1rem; }

/* The condition action uses the same dark metal as the resource controls. */
#tabletop-combat .combat-tracker-conditions button[title="Zustand hinzufügen"] {
    min-width: 2rem;
    min-height: 2rem;
    padding: .1rem;
    border: 1px solid #a28c68;
    background-color: #343940 !important;
    background-image: linear-gradient(180deg, #ffffff38, #1b232b33 65%, #0c141c78), url("assets/brushed-metal.svg") !important;
    background-size: auto, 192px 192px;
    color: #fff0d8;
    font: 1.4rem/1 "Segoe UI Symbol", "Noto Sans Symbols 2", sans-serif;
    font-variant-emoji: text;
    text-shadow: none;
}

.combat-resource-form {
    grid-template-columns: minmax(3.6rem, auto) minmax(1.7rem, 1fr) auto auto;
    gap: .2rem;
}
.combat-resource-value { white-space: nowrap; font-size: var(--font-small); font-variant-numeric: tabular-nums; }
.combat-resource-form .combat-resource-controls { display: flex; flex-wrap: nowrap; }
@media (max-width: 27rem) {
    .combat-resource-form { grid-template-columns: minmax(3.3rem, auto) minmax(1rem, 1fr) auto auto; }
}

/* Halunkenbogen fills its sidebar like the Heldenbogen. */
.tabletop-sidebar #tabletop-nsc .scene-sidebar:has(> #npc-sidebar-sheet:not([hidden])) {
    padding-inline: 0;
    padding-bottom: 0;
}
.tabletop-sidebar #npc-sidebar-sheet {
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
    padding: 0;
    margin-block: 0;
    border: 0;
    background: transparent;
    box-shadow: none;
}
#npc-sidebar-sheet iframe {
    width: 100%;
    box-sizing: border-box;
    background: transparent;
}

/* A single primary sign-in form with registration available on demand. */
main[data-entry-view="account"] .account-login h2 { margin: 0; font-size: var(--font-heading); }
main[data-entry-view="account"] .account-register { padding: 0; overflow: hidden; }
main[data-entry-view="account"] .account-register summary {
    display: block;
    padding: .85rem 1.15rem;
    cursor: pointer;
    color: #f5d495;
    font-weight: 700;
    background: #27333e;
}
main[data-entry-view="account"] .account-register summary::-webkit-details-marker { display: none; }
main[data-entry-view="account"] .account-register summary::after { content: ' ▸'; }
main[data-entry-view="account"] .account-register[open] summary::after { content: ' ▾'; }
main[data-entry-view="account"] .account-register summary:hover { background: #35424e; }
main[data-entry-view="account"] .account-register summary:focus-visible { outline: 2px solid #f1cf8d; outline-offset: -3px; }
main[data-entry-view="account"] .account-register .account-form { margin: 0; border-top: 1px solid #705f4b; }

.account-password-details { padding: 0; overflow: hidden; }
.account-password-details > summary {
    display: block;
    padding: .85rem 1.15rem;
    cursor: pointer;
    color: #f5d495;
    font-weight: 700;
    background: #27333e;
}
.account-password-details > summary::-webkit-details-marker { display: none; }
.account-password-details > summary::after { content: ' ▸'; }
.account-password-details[open] > summary::after { content: ' ▾'; }
.account-password-details > summary:hover { background: #35424e; }
.account-password-details > summary:focus-visible { outline: 2px solid #f1cf8d; outline-offset: -3px; }
.account-password-details .account-password-form { margin: 0; padding: 1rem 1.15rem; border-top: 1px solid #705f4b; }

/* Place the frequent combat controls across the full tracker width. */
#tabletop-combat .combat-turns .combat-tracker-entry-row { position: relative; }
#tabletop-combat .combat-turns .combat-tracker-entry-row td {
    padding-bottom: 4rem;
}
#tabletop-combat .combat-turns .combat-tracker-entry-row td:first-child { position: static; }
#tabletop-combat .combat-turns .combat-tracker-entry-row td:first-child button[data-combat-command="roll"] {
    position: absolute;
    top: 2.55rem;
    left: .65rem;
    z-index: 1;
    min-width: 1.5rem;
    width: 1.5rem;
    min-height: 1.5rem;
    height: 1.5rem;
    padding: 0;
}
#tabletop-combat .combat-tracker-quick-actions {
    display: contents;
}
#tabletop-combat .combat-tracker-quick-actions .combat-tracker-health {
    position: absolute;
    top: 2.05rem;
    left: 5.2rem;
    right: 4.8rem;
}
#tabletop-combat .combat-tracker-quick-actions .combat-tracker-conditions {
    position: absolute;
    left: 5.2rem;
    top: 4.35rem;
    bottom: auto;
}
#tabletop-combat .combat-tracker-quick-actions .combat-attack-icon {
    position: absolute;
    top: .55rem;
    right: .45rem;
}
#tabletop-combat .combat-tracker-quick-actions .combat-tracker-health {
    flex: 1 1 auto;
    width: auto;
    min-width: 0;
    margin: 0;
}
#tabletop-combat .combat-tracker-quick-actions .combat-tracker-conditions {
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    gap: .15rem;
    margin: 0;
}
#tabletop-combat .combat-tracker-quick-actions .combat-attack-icon {
    flex: 0 0 auto;
    width: 2rem;
    height: 2rem;
    padding: 0;
    border: 1px solid #89949d;
    border-radius: 0;
    background-color: #343940 !important;
    background-image: linear-gradient(180deg, #ffffff38, #1b232b33 65%, #0c141c78), var(--ui-brushed-metal) !important;
    background-size: auto, 192px 192px;
    color: #f1e6d2;
    font: 1.35rem/1 "Segoe UI Symbol", "Noto Sans Symbols 2", sans-serif;
    font-variant-emoji: text;
    box-shadow: inset 0 1px #ffffff45, inset 0 -1px #0e151c99;
}
#tabletop-combat .combat-tracker-quick-actions .combat-attack-icon:hover:not(:disabled) {
    border-color: #d9dce0;
    background-color: #4b5057 !important;
}

#tabletop-combat .combat-tracker-conditions .combat-condition-icon {
    display: inline-grid;
    place-items: center;
    min-width: 1.85rem;
    height: 1.85rem;
    padding: .05rem .15rem;
    border: 1px solid #8b99a5;
    background: #26313a;
    color: #f4ecdc;
    font: 1.35rem/1 "Segoe UI Symbol", "Noto Sans Symbols 2", sans-serif;
    font-variant-emoji: text;
    text-shadow: 0 1px 1px #000;
}
#tabletop-combat .combat-tracker-conditions .combat-condition-icon[data-condition="sterbend"],
#tabletop-combat .combat-tracker-conditions .combat-condition-icon[data-condition="zehrend-lp"] {
    border-color: #a87872;
    color: #f1bab0;
}
#tabletop-combat .combat-tracker-conditions .combat-condition-icon[data-condition="benommen"],
#tabletop-combat .combat-tracker-conditions .combat-condition-icon[data-condition="angeschlagen"] {
    border-color: #b49a66;
    color: #f6daa0;
}
