:root {
  color-scheme: dark;
  --ink: #eee7d8;
  --muted: #aaa29c;
  --panel: #171518;
  --line: #4c4034;
  --gold: #d9be8b;
  --accent: #c292ed;
  --purple: #6c398d;
  --success: #a5c47f;
  --danger: #ed9c94;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
}
* { box-sizing: border-box; letter-spacing: 0; }
html, body { margin: 0; width: 100%; min-height: 100%; background: #100e11; color: var(--ink); }
button, input, select, textarea { font: inherit; }
button { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 34px; padding: 7px 11px; border: 1px solid #66513b; border-radius: 5px; color: var(--ink); background: linear-gradient(#302923, #19171a); box-shadow: inset 0 1px #e9c99519, inset 0 -2px #0004, 0 2px 3px #0003; cursor: pointer; transition: background .15s, border-color .15s, box-shadow .15s; }
button:hover { background: linear-gradient(#43362e, #28212d); border-color: #b69462; box-shadow: inset 0 1px #f4d7aa33, 0 2px 6px #0006; }
button:active { background: #241d29; box-shadow: inset 0 2px 5px #0009; }
button:disabled { opacity: .45; cursor: not-allowed; }
button, input, select, textarea { min-width: 0; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
input:not([type="checkbox"]):not([type="range"]), select, textarea { width: 100%; border: 1px solid #64513c; border-radius: 4px; background: #100f12; color: var(--ink); padding: 8px 10px; min-height: 36px; box-shadow: inset 0 2px 5px #0008, 0 1px #eacb9a12; }
input::placeholder, textarea::placeholder { color: #827a80; }
input[type="checkbox"], input[type="range"] { accent-color: var(--accent); }
input[type="range"] { min-width: 0; width: 100%; margin: 0; height: 30px; cursor: pointer; }
textarea { resize: vertical; }
svg { width: 18px; height: 18px; flex-shrink: 0; }
[hidden] { display: none !important; }
.icon-button { width: 34px; height: 34px; padding: 7px; flex: 0 0 34px; }
.danger { color: var(--danger); }
.app-shell { height: 100dvh; min-height: 640px; display: grid; grid-template-columns: 228px minmax(0, 1fr) 290px; grid-template-rows: 58px minmax(0, 1fr) 25px; gap: 12px; padding: 0 12px; background: #100e11; }
.brand-panel { grid-column: 1 / -1; display: flex; align-items: center; gap: 24px; padding: 0 8px; border-bottom: 1px solid var(--line); }
.brand-panel { background: linear-gradient(#171218eb, #100e11f5), url("assets/materials/leather-height-v1.webp") center / 420px; border-bottom-color: #806341; }
.brand-home { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.brand-mark { width: 42px; height: 44px; background: url("icons/vault-dice-icon.svg") center / contain no-repeat; color: transparent; font-size: 0; filter: drop-shadow(0 2px 4px #0008); }
h1 { margin: 0; font: 700 29px / 1.1 Georgia, serif; color: #f0d6a4; text-shadow: 0 2px 1px #000, 0 -1px #fff1; }
.top-tabs { display: flex; align-self: stretch; gap: 7px; margin: 0 auto; }
.top-tabs button { background: transparent; border: 0; border-bottom: 2px solid transparent; border-radius: 0; padding: 0 15px; color: var(--muted); box-shadow: none; }
.top-tabs button.is-active { color: var(--ink); border-bottom-color: var(--accent); background: linear-gradient(0deg, #9b5bd81a, transparent); }
.brand-actions { display: flex; align-items: center; gap: 8px; }
.header-table-state { display: grid; text-align: right; margin-right: 8px; font-size: 11px; }
.header-table-state small { color: var(--success); }
.invite-button, .rail-primary-button { border-color: #9e7bae; background: linear-gradient(#563365, #281c32); box-shadow: inset 0 1px #e7bdff40, inset 0 -2px #0005, 0 2px 4px #0005; }
.table-rail, .encounter-rail { display: flex; flex-direction: column; gap: 12px; min-height: 0; overflow: auto; scrollbar-width: thin; }
.rail-card { border: 1px solid #765b3c; border-radius: 6px; background: linear-gradient(125deg, #1b1919ed, #101115f5), url("assets/materials/leather-height-v1.webp") center / 460px; padding: 12px; min-width: 0; box-shadow: inset 0 0 0 2px #131012, inset 0 3px 0 #b4904c24, 0 3px 10px #0003; }
.rail-card-header { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; min-height: 20px; }
.rail-card-header > span { font: 600 12px / 1.3 Georgia, serif; text-transform: uppercase; color: var(--gold); }
.rail-card-header small { font-size: 10px; color: var(--muted); margin-left: auto; overflow-wrap: anywhere; }
.rail-card-header .icon-button { margin-left: auto; width: 27px; height: 27px; min-height: 27px; flex-basis: 27px; padding: 5px; }
.table-members { display: flex; flex-wrap: wrap; gap: 7px; }
.rail-members { display: grid; }
.table-member-pill { padding: 9px; border: 1px solid var(--line); border-radius: 4px; font-size: 12px; overflow-wrap: anywhere; }
.table-member-pill[data-role="gm"] { border-color: #785491; }
.rail-primary-button { width: 100%; margin-top: 12px; }
.activity-card { flex: 1; display: flex; flex-direction: column; min-height: 190px; }
.table-activity { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.rail-activity { flex: 1; overflow: auto; min-height: 0; }
.table-activity li { padding: 10px; border-bottom: 1px solid var(--line); font-size: 12px; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.table-activity li strong { color: var(--gold); }
.table-activity li span { color: var(--muted); }
.table-activity-detail { flex-basis: 100%; font-size: 11px; }
.table-visibility-badge { border: 1px solid #74548b; border-radius: 3px; padding: 2px 5px; font-size: 10px; color: var(--accent); }
.table-empty { color: var(--muted); font-size: 12px; line-height: 1.6; padding: 12px 0; }
.rail-note-row, .table-note-row { display: flex; gap: 7px; margin-top: 12px; }
.rail-note-row input { font-size: 12px; }
.rail-note-row button { padding: 7px; }
.roll-workspace { display: flex; flex-direction: column; min-width: 0; min-height: 0; gap: 12px; }
.table-stage { position: relative; flex: 1; min-height: 200px; overflow: hidden; background: #141015; }
.stage-heading { position: absolute; top: 10px; left: 12px; right: 12px; display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; font-size: 10px; color: #cab99c; z-index: 1; pointer-events: none; text-shadow: 0 1px 6px #000; }
#stageTableCode { min-width: 0; overflow-wrap: anywhere; padding: 5px 20px 6px 10px; border-left: 1px solid #b59461b3; background: linear-gradient(90deg, #1a1219e8 calc(100% - 20px), #1a121900); color: #f0d6a4; font: 600 14px / 1.35 Georgia, serif; text-shadow: 0 1px 2px #000, 0 0 5px #0008; }
#poolSummary { flex-shrink: 0; white-space: nowrap; padding-top: 7px; }
#scene { display: block; width: 100%; height: 100%; position: absolute; inset: 0; touch-action: none; cursor: grab; }
#scene.is-dragging { cursor: grabbing; }
.table-stage.has-3d-environment { background: #161015; }
.table-stage[aria-busy="true"] #scene, .table-stage[aria-busy="true"] .stage-tools { visibility: hidden; }
.table-stage[data-scene-state="unavailable"] .stage-tools { display: none; }
.scene-loading { position: absolute; inset: 0; z-index: 2; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px; background: linear-gradient(145deg, #1e1723, #100e12 70%); text-align: center; }
.scene-loading-emblem { width: 72px; height: 72px; margin-bottom: 18px; filter: drop-shadow(0 4px 10px #0006); }
.scene-loading-title { margin: 0; color: #eed7ac; font: 400 21px / 1.3 Georgia, serif; }
.scene-loading-detail { margin: 8px 0 20px; color: var(--muted); font-size: 12px; line-height: 1.5; }
.scene-loading-track { width: 124px; height: 3px; overflow: hidden; background: #382b3e; border-radius: 2px; }
.scene-loading-track span { display: block; width: 36px; height: 100%; background: linear-gradient(90deg, #94714e, #c392e7, #e7c58c); animation: table-loading 1.7s ease-in-out infinite; }
@keyframes table-loading { from { transform: translateX(-36px); } to { transform: translateX(124px); } }
.reduce-motion .scene-loading-track span { width: 100%; animation: none; opacity: .7; }
@media (prefers-reduced-motion: reduce) { .scene-loading-track span { width: 100%; animation: none; opacity: .7; } }
.roll-panel[inert] { opacity: .55; }
.stage-tools { position: absolute; right: 12px; bottom: 12px; z-index: 2; }
.stage-tools button { background: #171318bb; backdrop-filter: blur(6px); border-color: #ad88665c; }
.stage-tools button[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); }
.scene-unavailable { position: absolute; left: 15%; right: 15%; top: 40%; text-align: center; background: #171518ed; border: 1px solid var(--line); padding: 16px; border-radius: 5px; line-height: 1.5; }
.scene-unavailable p { margin: 0 0 12px; }
.command-dock { display: grid; grid-template-columns: 114px minmax(0, 1fr); gap: 14px; padding: 14px; border: 1px solid #695139; border-radius: 6px; background: linear-gradient(125deg, #221b1c, #151316 65%); }
.command-dock { background: linear-gradient(110deg, #211a1dee, #141216f2), url("assets/materials/leather-height-v1.webp") center / 420px; border-color: #967244; box-shadow: inset 0 0 0 2px #151114, inset 0 3px #dbbd7526, 0 4px 14px #0004; }
.roll-panel { --action-height: 48px; grid-column: 2; grid-row: 1; display: grid; grid-template-columns: minmax(0, 1fr) 92px 108px; gap: 12px; align-content: start; align-items: center; min-width: 0; }
.advanced-roll-row { grid-column: 1 / -1; grid-row: 1; display: grid; grid-template-columns: 1.25fr 1fr 1.1fr 1fr; gap: 8px; }
.advanced-roll-row label, .modifier-field { display: grid; gap: 5px; }
.advanced-roll-row label > span:not(.select-control), .modifier-field > span { color: var(--gold); text-transform: uppercase; font-size: 10px; }
.advanced-roll-row input, .advanced-roll-row select { padding: 8px; font-size: 12px; }
.select-control { position: relative; display: block; min-width: 0; }
.advanced-roll-row .select-control select { appearance: none; -webkit-appearance: none; padding: 8px 32px 8px 10px; text-overflow: ellipsis; }
.select-control > svg { position: absolute; right: 10px; top: 50%; width: 14px; height: 14px; transform: translateY(-50%); color: var(--gold); pointer-events: none; }
.dice-select { grid-column: 1 / -1; grid-row: 2; display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.die-option { position: relative; width: 100%; padding: 7px 4px; gap: 5px; font-size: 12px; height: 42px; background: linear-gradient(#252122, #151316); }
.die-option .die-glyph { width: 21px; height: 24px; color: var(--die-color); filter: drop-shadow(0 1px 2px #000); }
.die-option.is-active { border-color: var(--die-color); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--die-color) 25%, transparent), 0 0 9px color-mix(in srgb, var(--die-color) 10%, transparent); }
.has-count .die-option { background: linear-gradient(color-mix(in srgb, var(--die-color) 19%, #1b1820), #17141b); color: #fff0d7; }
.die-count { font-size: 9px; color: var(--muted); min-width: 14px; height: 16px; display: grid; place-items: center; border: 1px solid #77624a55; border-radius: 3px; font-variant-numeric: tabular-nums; }
.has-count .die-count { color: var(--die-color); background: #0004; }
.die-count-popover { display: none; }
.pool-count-editor { grid-column: 1 / -1; grid-row: 3; display: flex; align-items: center; gap: 10px; min-width: 0; min-height: 32px; }
.pool-count-editor label { min-width: 70px; }
.pool-count-editor label span { display: flex; gap: 7px; align-items: baseline; }
.pool-count-editor b { font-size: 12px; color: var(--gold); }
.pool-count-editor small { font-size: 10px; color: var(--muted); }
.pool-count-editor .icon-button { width: 28px; height: 28px; min-height: 28px; flex-basis: 28px; padding: 6px; }
.pool-count-editor output { width: 24px; text-align: center; font-variant-numeric: tabular-nums; color: var(--selected-die, var(--accent)); }
.pool-count-editor b { color: var(--selected-die, var(--gold)); }
#activeDieCountInput { appearance: none; -webkit-appearance: none; height: 24px; background: transparent; }
#activeDieCountInput::-webkit-slider-runnable-track { height: 6px; border: 1px solid #725e48; border-radius: 3px; background: linear-gradient(to right, var(--selected-die) var(--range-fill, 8.33%), #161419 var(--range-fill, 8.33%)); box-shadow: inset 0 1px 2px #0009; }
#activeDieCountInput::-webkit-slider-thumb { appearance: none; width: 17px; height: 17px; margin-top: -6px; border-radius: 50%; border: 2px solid #d5b47a; background: radial-gradient(circle at 35% 25%, #fff1c1, #ab7f45 58%, #523823); box-shadow: 0 2px 4px #0008; }
#activeDieCountInput::-moz-range-track { height: 5px; border: 1px solid #725e48; background: #161419; }
#activeDieCountInput::-moz-range-progress { height: 5px; background: var(--selected-die); }
#activeDieCountInput::-moz-range-thumb { width: 14px; height: 14px; border: 2px solid #d5b47a; background: #ae8249; border-radius: 50%; }
.roll-button { grid-row: 4; grid-column: 1; width: 100%; height: var(--action-height); min-height: var(--action-height); font: 700 24px / 1 Georgia, serif; background: linear-gradient(#72438f, #442452 54%, #2b1c35); border: 1px solid #bc96d0; box-shadow: inset 0 0 0 2px #3d254a, inset 0 3px 0 #efd1fa70, 0 0 0 1px #8c6b42, 0 3px 12px #0006; text-shadow: 0 2px #26132e; }
.roll-button:hover { background: linear-gradient(#774394, #43294f); border-color: #d2a3ef; }
input[aria-invalid="true"] { border-color: var(--danger) !important; }
.modifier-field { grid-row: 4; grid-column: 2; height: var(--action-height); grid-template-rows: 12px minmax(0, 1fr); gap: 0; padding: 5px 8px 4px; text-align: center; border: 1px solid #64513c; border-radius: 4px; background: #100f12; box-shadow: inset 0 2px 5px #0008, 0 1px #eacb9a12; }
.modifier-field > span { font-size: 9px; line-height: 12px; }
#modifierInput { height: 24px; min-height: 24px; padding: 0; border: 0; border-radius: 2px; background: transparent; box-shadow: none; text-align: center; font-size: 16px; font-variant-numeric: tabular-nums; appearance: textfield; }
#modifierInput::-webkit-inner-spin-button, #modifierInput::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.reset-button { grid-row: 4; grid-column: 3; font-size: 11px; height: var(--action-height); white-space: nowrap; padding: 7px; }
.preset-bar { display: flex; grid-row: 5; grid-column: 1 / -1; gap: 6px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: thin; }
.preset-bar button { min-height: 27px; padding: 5px 8px; white-space: nowrap; font-size: 10px; background: transparent; color: #bfb3c6; }
#savePresetButton { margin-left: auto; border-style: dashed; }
.result-stack { grid-row: 1; grid-column: 1; min-width: 0; border-right: 1px solid var(--line); padding-right: 14px; }
.result-panel { height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 9px; text-align: center; min-width: 0; }
.result-label { color: var(--gold); font-size: 10px; text-transform: uppercase; }
.result-value { position: relative; width: 94px; height: 100px; display: grid; place-items: center; color: #f7e8cf; border: 0; background: radial-gradient(ellipse, #42254eaa, transparent 70%); font: 700 38px / 1 Georgia, serif; }
.result-value::before { content: ""; position: absolute; inset: -3px; background: url("icons/result-sigil.svg") center / contain no-repeat; filter: drop-shadow(0 0 5px #ba7bea50); }
.result-value-text { position: relative; z-index: 1; display: inline-block; white-space: nowrap; font-variant-numeric: normal; text-shadow: 0 2px 5px #130b18; }
.result-baseline { display: inline-block; width: 0; height: 0; vertical-align: baseline; }
.result-panel[data-digits="3"] .result-value { font-size: 32px; }
.result-panel[data-digits="4"] .result-value { font-size: 25px; }
.result-title { font-size: 12px; overflow-wrap: anywhere; width: 100%; color: var(--gold); line-height: 1.4; }
.total-value { font-size: 11px; color: var(--muted); line-height: 1.5; overflow-wrap: anywhere; max-height: 65px; overflow: auto; width: 100%; }
.result-history-button { margin-top: auto; font-size: 11px; min-height: 28px; padding: 5px; border: 0; background: transparent; color: var(--muted); box-shadow: none; }
.result-history-button svg { width: 14px; height: 14px; }
.is-critical .result-value { color: #fff0a9; border-color: #f2cc76; box-shadow: 0 0 20px #e0b23855; }
.is-fumble .result-value { color: #ffc1bd; border-color: var(--danger); }
.sheet-toggle { display: none; }
.main-combat-header, .main-combat-row { display: grid; grid-template-columns: 28px minmax(0, 1fr) 40px 25px 45px; gap: 5px; align-items: center; }
.main-combat-header { font-size: 10px; color: var(--muted); padding-bottom: 9px; }
.main-combat-row { padding: 10px 3px; border-top: 1px solid var(--line); font-size: 11px; }
.main-combat-row > * { overflow-wrap: anywhere; font-weight: 400; }
.main-combat-row em { font-style: normal; font-size: 9px; color: var(--success); }
.main-combat-row.is-active { background: #6c398d33; box-shadow: inset 2px 0 var(--accent); }
.rail-button-row { display: flex; gap: 7px; margin-top: 12px; }
.rail-button-row button { flex: 1; font-size: 11px; }
.character-summary-head { display: flex; align-items: center; gap: 10px; }
.character-summary-head > div:nth-child(2) { flex: 1; min-width: 0; }
.character-portrait { background: url("assets/ui/portraits/aelar-v1.webp") center / cover; width: 48px; height: 56px; flex-shrink: 0; border-radius: 5px; border: 1px solid #7c684c; color: transparent; }
.character-summary-head h2 { font: 700 21px / 1.2 Georgia, serif; margin: 0 0 5px; overflow-wrap: anywhere; }
.character-summary-head p { font-size: 11px; color: var(--muted); margin: 0; }
.character-stat-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); margin: 14px 0; }
.character-stat-row div { display: grid; text-align: center; gap: 6px; border-right: 1px solid var(--line); }
.character-stat-row div:last-child { border: 0; }
.character-stat-row span { font-size: 9px; color: var(--gold); text-transform: uppercase; }
.character-stat-row strong { font-size: 16px; font-weight: 500; overflow-wrap: anywhere; }
.character-tabs { display: flex; border-bottom: 1px solid var(--line); }
.character-tabs button { flex: 1; font-size: 10px; padding: 6px 3px; border: 0; border-bottom: 2px solid transparent; border-radius: 0; min-height: 30px; background: transparent; box-shadow: none; }
.character-tabs button.is-active { border-bottom-color: var(--accent); color: var(--accent); }
.character-feature-list { list-style: none; padding: 0; margin: 12px 0 0; max-height: 180px; overflow: auto; }
.character-feature-list li { padding: 6px 0; font-size: 12px; line-height: 1.5; color: var(--muted); overflow-wrap: anywhere; white-space: pre-line; }
.character-feature-list button { width: 100%; text-align: left; justify-content: space-between; font-size: 11px; }
.main-resource-row { display: flex; gap: 8px; align-items: center; justify-content: space-between; font-size: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.main-resource-row strong { color: var(--accent); font-weight: 500; }
.main-resource-row > span { flex: 1; }
.resource-actions { display: flex; gap: 4px; }
.resource-actions .icon-button { width: 24px; height: 24px; min-height: 24px; flex-basis: 24px; padding: 4px; }
.resource-actions svg { width: 14px; height: 14px; }
.app-status { grid-column: 1 / -1; display: flex; gap: 16px; align-items: center; color: var(--muted); font-size: 10px; border-top: 1px solid var(--line); }
.app-status > :first-child { color: var(--success); }
.app-status > :last-child { margin-left: auto; }
.mobile-nav { display: none; }
.file-mode-warning { position: fixed; z-index: 80; top: 65px; left: 20px; right: 20px; padding: 12px; background: #392b1c; border: 1px solid var(--gold); border-radius: 5px; }
.sheet-panel { display: none; position: fixed; z-index: 10; top: 70px; bottom: 37px; left: 252px; right: 12px; border: 1px solid #67533c; border-radius: 6px; background: #19161a; box-shadow: 0 10px 50px #000a; overflow: hidden; }
.sheet-panel.is-open { display: flex; flex-direction: column; }
.sheet-header, .sheet-footer { padding: 16px 20px; display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-shrink: 0; }
.sheet-header { border-bottom: 1px solid var(--line); background: #211a20; }
.sheet-header h2 { font: 700 25px / 1.2 Georgia, serif; margin: 0; overflow-wrap: anywhere; }
.sheet-kicker { font-size: 10px; color: var(--gold); text-transform: uppercase; margin: 0 0 5px; }
.sheet-body { overflow-y: auto; min-height: 0; flex: 1; padding: 4px 20px 20px; scrollbar-width: thin; }
.sheet-section { display: grid; gap: 12px; padding: 20px 0; border-bottom: 1px solid var(--line); }
.sheet-section:last-child { border-bottom: 0; }
.sheet-section[aria-label="Character details"], .sheet-field-grid.two-column { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.sheet-section-title { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; color: var(--gold); font-size: 13px; }
.sheet-section-title small { color: var(--muted); font-size: 10px; }
.sheet-field { display: grid; gap: 6px; min-width: 0; }
.sheet-field > span, .ability-row label span { color: var(--muted); font-size: 11px; }
.sheet-field.wide { grid-column: 1 / -1; }
.stat-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.sheet-textarea { min-height: 120px; }
.sheet-textarea.compact { min-height: 80px; }
.sheet-button-row, .hp-action-row, .combat-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.sheet-roll-button { font-size: 12px; }
.hp-action-row > input { width: 70px !important; }
.combat-state-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.sheet-check-field { display: flex; align-items: center; gap: 8px; }
.death-save-group { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; grid-column: 1 / -1; font-size: 12px; }
.sheet-list { display: grid; gap: 7px; }
.sheet-roll-row { display: grid; grid-template-columns: minmax(0, 1fr) auto 64px; align-items: center; gap: 8px; padding: 7px 0; border-bottom: 1px solid #302a30; }
.sheet-roll-name { font-size: 12px; }
.sheet-roll-meta { font-size: 10px; color: var(--muted); }
.sheet-prof { display: flex; align-items: center; gap: 5px; font-size: 10px; color: var(--muted); }
.custom-roll-row { grid-template-columns: minmax(0, 1fr) 100px 70px; }
.attack-roll-row { grid-template-columns: minmax(0, 1fr) 85px 100px 50px 50px; }
.ability-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 10px; }
.ability-row { display: grid; gap: 8px; }
.ability-row label { display: grid; gap: 6px; }
.ability-row .sheet-roll-button { color: var(--accent); }
.spell-slot-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.spell-slot-row { display: grid; align-items: center; grid-template-columns: 22px minmax(0, 1fr) minmax(0, 1fr); gap: 5px; font-size: 11px; color: var(--muted); }
.spell-slot-row input { padding: 7px; }
.combat-round-label { margin-left: auto; color: var(--accent); }
.combat-tracker-list { display: grid; gap: 9px; }
.combat-row { display: grid; grid-template-columns: minmax(100px, 1.8fr) 60px 70px 50px minmax(70px, 1.2fr) auto; gap: 8px; align-items: end; padding: 12px; border-bottom: 1px solid var(--line); }
.combat-row.is-active { background: #33233d; box-shadow: inset 3px 0 var(--accent); }
.combat-cell { display: grid; gap: 6px; }
.combat-cell span { font-size: 10px; color: var(--gold); }
.combat-row input { padding: 8px; }
.combat-remove-button { font-size: 10px; color: var(--danger); }
.communal-table-box { display: grid; gap: 12px; }
.table-share-link { overflow-wrap: anywhere; color: var(--accent); font-size: 12px; user-select: all; }
.table-status, .ddb-import-status { color: var(--success); font-size: 12px; }
.ddb-import-row { display: flex; gap: 8px; }
.ddb-preview { border-left: 2px solid var(--accent); padding-left: 12px; }
.ddb-preview-summary { line-height: 1.6; padding-bottom: 12px; }
.sheet-footer { border-top: 1px solid var(--line); }
.sheet-save { background: #4b2d5e; border-color: #855ba0; }
.sheet-saved-state { font-size: 11px; color: var(--muted); }
.sheet-saved-state[data-save-error="true"] { color: var(--danger); }
#tableSavedState { min-height: 16px; }
.utility-dialog { color: var(--ink); background: #1c181e; border: 1px solid #756044; border-radius: 8px; padding: 20px; width: min(620px, calc(100% - 24px)); max-height: calc(100dvh - 48px); box-shadow: 0 24px 80px #0009; }
.utility-dialog::backdrop { background: #0b080bbf; backdrop-filter: blur(5px); }
.utility-dialog > header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; gap: 12px; }
.utility-dialog h2 { margin: 0; font: 700 25px / 1.2 Georgia, serif; }
.history-list { padding: 0; margin: 0; list-style: none; max-height: 55dvh; overflow: auto; }
.history-list li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 5px 16px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.history-list strong { grid-column: 2; grid-row: 1 / 3; font: 700 28px Georgia, serif; color: var(--accent); }
.history-list span { font-size: 13px; overflow-wrap: anywhere; }
.history-list .history-roll { line-height: 1.5; }
.history-list .history-player { font: inherit; font-weight: 600; text-transform: none; }
.history-list b { font-size: 10px; color: var(--gold); font-weight: 400; text-transform: uppercase; }
.history-list time, .history-list small { font-size: 11px; color: var(--muted); }
.history-list small { grid-column: 1 / -1; line-height: 1.5; overflow-wrap: anywhere; }
.history-actions { display: flex; gap: 8px; margin-top: 20px; }
.history-actions .danger { margin-left: auto; }
.settings-dialog { max-width: 420px; }
.settings-strip { display: grid; gap: 0; }
.settings-strip label { display: flex; align-items: center; justify-content: space-between; padding: 16px 0; border-bottom: 1px solid var(--line); }
.settings-strip input { width: 18px; height: 18px; }
.high-contrast { --muted: #d9d2dd; --line: #8b7c8d; --gold: #f2d4a3; }
.reduce-motion *, .reduce-motion *::before, .reduce-motion *::after { animation: none !important; transition: none !important; }
@media (min-width: 1550px) {
  .app-shell { grid-template-columns: 264px minmax(0, 1fr) 350px; }
  .command-dock { grid-template-columns: 150px minmax(0, 1fr); padding: 18px; gap: 20px; }
  .result-value { width: 100px; height: 100px; font-size: 46px; }
  .sheet-panel { left: 288px; }
}
@media (max-width: 1190px) {
  .app-shell { grid-template-columns: minmax(0, 1fr) 280px; }
  .table-rail { display: none; }
  .header-table-state { display: none; }
  .sheet-panel { left: 12px; }
}
@media (max-width: 960px) {
  .app-shell { grid-template-columns: minmax(0, 1fr); }
  .encounter-rail { display: none; }
  .brand-panel { gap: 14px; }
  .top-tabs button { padding: 0 10px; }
}
@media (max-width: 640px) {
  html { scroll-padding-top: 64px; scroll-padding-bottom: calc(72px + env(safe-area-inset-bottom)); }
  .app-shell { height: auto; min-height: 100dvh; grid-template-rows: 56px minmax(0, 1fr) 22px; gap: 8px; padding: 0 10px calc(64px + env(safe-area-inset-bottom)); }
  .brand-panel { padding: 0; gap: 8px; position: sticky; top: 0; z-index: 25; background: #100e11; }
  h1 { font-size: 23px; }
  .brand-mark { width: 30px; height: 34px; }
  .brand-home { gap: 8px; }
  .top-tabs { display: none; }
  .brand-actions { margin-left: auto; gap: 6px; }
  #openHistoryButton { display: none; }
  .invite-button { font-size: 12px; padding: 7px 10px; }
  .roll-workspace { gap: 8px; }
  .table-stage { flex: none; height: max(220px, calc(100dvh - 570px)); min-height: 220px; margin: 0 -10px; }
  .stage-heading { font-size: 9px; }
  .command-dock { display: flex; flex-direction: column; padding: 12px; gap: 12px; }
  .result-stack { order: -1; border-right: 0; border-bottom: 1px solid var(--line); padding: 0 0 10px; }
  .result-panel { display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; grid-template-rows: auto auto; align-items: center; gap: 3px 10px; text-align: left; }
  .result-label { display: none; }
  .result-value { grid-column: 1; grid-row: 1 / 3; width: 42px; height: 42px; font-size: 24px; }
  .result-panel[data-digits="3"] .result-value { font-size: 20px; }
  .result-panel[data-digits="4"] .result-value { font-size: 16px; }
  .result-title { grid-column: 2; grid-row: 1; font-size: 12px; }
  .total-value { grid-column: 2; grid-row: 2; max-height: 35px; font-size: 10px; }
  .result-history-button { grid-column: 3; grid-row: 1 / 3; margin: 0; }
  .roll-panel { grid-template-columns: minmax(0, 1fr) 68px 88px; gap: 10px; }
  .advanced-roll-row { grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
  .formula-field { grid-column: 1 / -1; }
  .formula-field input { height: 36px; }
  .advanced-roll-row input, .advanced-roll-row select { font-size: 12px; }
  .dice-select { gap: 4px; }
  .die-option { flex-direction: column; gap: 2px; height: 50px; font-size: 11px; padding: 3px 2px; }
  .die-option .die-glyph { width: 19px; height: 21px; }
  .die-count { position: absolute; right: 2px; top: 2px; min-width: 11px; height: 12px; font-size: 8px; border: 0; background: #171217b3; }
  .pool-count-editor { gap: 7px; }
  .roll-button { font-size: 23px; }
  .reset-button { font-size: 10px; gap: 4px; padding: 6px; }
  .reset-button svg { width: 14px; height: 14px; }
  .preset-bar button { min-height: 30px; }
  .mobile-nav { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); position: fixed; z-index: 20; bottom: 0; left: 0; right: 0; padding: 6px 8px max(8px, env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: #171318f5; backdrop-filter: blur(12px); }
  .mobile-nav button { flex-direction: column; gap: 3px; background: transparent; border: 0; font-size: 10px; min-height: 40px; padding: 4px 3px; box-shadow: none; }
  .mobile-nav button svg { width: 17px; height: 17px; }
  .mobile-nav button.is-active { color: var(--accent); background: #aa69d21a; }
  .sheet-panel { top: 64px; bottom: calc(58px + env(safe-area-inset-bottom)); left: 10px; right: 10px; }
  .sheet-header, .sheet-footer { padding: 12px; }
  .sheet-body { padding: 0 12px 16px; }
  .sheet-header h2 { font-size: 22px; }
  .sheet-section-title small { display: none; }
  .stat-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .ability-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .spell-slot-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .attack-roll-row { grid-template-columns: minmax(0, 1fr) 62px 68px; }
  .attack-roll-row input:first-child { grid-column: 1 / -1; }
  .custom-roll-row { grid-template-columns: minmax(0, 1fr) 75px 60px; }
  .combat-row { grid-template-columns: minmax(0, 1fr) 55px 62px 50px; padding: 10px; gap: 8px; }
  .combat-name-cell { grid-column: 1 / -1; }
  .combat-conditions-cell { grid-column: 1 / 4; }
  .combat-remove-button { grid-column: 4; grid-row: 3; font-size: 0; padding: 8px; }
  .combat-remove-button::after { content: "Remove"; font-size: 9px; }
  .ddb-import-row { flex-wrap: wrap; }
}
@media (max-width: 360px) {
  .roll-panel { grid-template-columns: minmax(0, 1fr) 88px; }
  .roll-button { grid-column: 1 / -1; }
  .modifier-field { grid-column: 1; grid-row: 5; }
  .reset-button { grid-column: 2; grid-row: 5; }
  .preset-bar { grid-row: 6; }
}
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; transition: none !important; } }
