/* Final shared layout rules for the Story-only interface. */
:root{--ui-control-height:32px;--ui-field-height:36px;--ui-gap:8px}
body :is(.library-controls,.session-row,.scene-detail-actions,.story-dialog footer,.enemy-entry-controls){gap:var(--ui-gap)}
body :is(.library-tabs,.story-step-navigation,.scene-detail-heading,.library-detail-heading,.story-dialog-heading){align-items:center}
body :is(.library-tabs,.scene-detail-actions,.story-step-navigation) button{line-height:1.25;white-space:nowrap}
body :is(.library-controls,.session-row) :is(input[type=search],select){min-height:var(--ui-field-height);box-sizing:border-box}
body .story-tag,body .library-badges>span{line-height:1.25;min-height:22px;padding:3px 6px;font-variant-numeric:tabular-nums}
body .story-dialog-heading{gap:12px;min-height:38px}
body .story-dialog-heading h2{min-width:0;overflow-wrap:anywhere}
body .story-dialog footer{display:flex;align-items:center;justify-content:flex-end;gap:8px;flex-shrink:0}
body .story-dialog footer button{min-height:32px}
/* Keep long titles and summary controls readable at real laptop widths. */
@media(min-width:1101px){body #storyCombatDock .combat-workspace{grid-template-columns:180px minmax(0,1fr)}body .story-columns{grid-template-columns:180px minmax(0,1fr)}}
body #storyCombatDock .initiative-toolbar{display:grid;grid-template-columns:auto 28px minmax(0,1fr);gap:6px}
body #storyCombatDock .initiative-next{min-width:0;padding:6px!important;white-space:nowrap}
body #monstersList .enemy-header-details{grid-template-columns:minmax(260px,1.4fr) repeat(3,minmax(0,1fr));gap:12px}
body #monstersList .enemy-hp-controls{flex-wrap:nowrap!important;gap:5px;align-items:center}
body #monstersList .enemy-hp-controls button{white-space:nowrap!important;min-width:0;padding:5px 7px!important;min-height:30px}
body #monstersList .enemy-hp-controls input{width:48px!important;min-width:48px}
body #monstersList .hp-adjust-label{white-space:nowrap;font-size:11px}
body #monstersList .enemy-header-details .md-defense-grid>div{border-left:0!important;padding:0!important}
body #storyCombatDock .enemy-five-cards{gap:8px}
body #monstersList .enemy-info-card{min-width:0;container-type:inline-size}
body #monstersList .md-save-grid{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:5px}
body #monstersList .md-save-grid button{min-width:0;max-width:100%;height:48px!important;min-height:48px!important;box-sizing:border-box;padding:5px!important;overflow:hidden;transform:none!important;display:grid;grid-template-columns:minmax(0,1fr) auto;align-items:center;gap:3px}
body #monstersList .md-save-identity{display:flex;width:auto;flex-direction:column;align-items:flex-start;justify-content:center;gap:2px}
body #monstersList .md-save-grid button>strong{font-size:21px;line-height:1;align-self:center;justify-self:end;font-variant-numeric:tabular-nums}
body #monstersList .md-save-name{font-size:11px}
body #monstersList .md-save-score{font-size:11px}
body .md-section-head{flex-wrap:wrap;row-gap:6px;align-items:center}
body .md-section-head>div{display:flex;align-items:center;gap:5px;flex-wrap:wrap}
body .md-compact-spell-top strong{word-break:normal;overflow-wrap:normal;line-height:1.4}
@container(max-width:225px){body .md-compact-spell-top{display:grid;grid-template-columns:1fr;gap:6px}body .md-compact-spell-top>button,body .md-compact-spell-top>.md-compact-rolls{justify-self:end}}
/* Image and video actions share one row rather than clipping the video button. */
body #storySceneDetails .scene-image-section:not(:has(.scene-image-preview)){grid-template-columns:1fr;align-content:start;gap:7px}
body #storySceneDetails .scene-image-section:not(:has(.scene-image-preview))>.scene-detail-actions{grid-column:1;padding-right:102px}
body #storySceneDetails .scene-image-section:not(:has(.scene-image-preview)) .scene-setting-video{grid-column:1;justify-self:end;margin-top:-39px;align-self:end}
body #storySceneDetails .scene-image-section .scene-detail-actions{gap:5px;margin-top:0}
body #storySceneDetails .scene-image-section .scene-detail-actions button{min-height:30px;padding:5px 8px}
/* Library tools have one search row and one aligned filter/action row. */
body .library-controls{display:flex;flex-wrap:wrap;padding:12px;gap:8px}
body .library-controls input[type=search]{flex:1 0 100%;width:100%;min-width:0}
body .library-controls .library-sort-control{order:2;margin:0;align-items:center}
body .library-controls>select{order:1}
body .library-controls>button{order:3;min-height:36px}
body .library-controls #libraryCharacterCount{order:4;margin-left:auto;white-space:nowrap}
body #libraryCharacterResults>button{padding:10px;display:flex;flex-direction:column;align-items:flex-start;gap:7px}
body #libraryCharacterResults>button>strong{line-height:1.35}
body #libraryCharacterResults .library-badges{margin:0;display:flex;gap:4px;flex-wrap:wrap}
/* Titles take the full reader width; facts remain grouped underneath. */
body #compDetailsPanel>.comp-detail-heading{grid-template-columns:minmax(0,1fr);gap:6px;min-height:0;padding:12px 16px}
body .comp-detail-heading>span{grid-column:1;grid-row:1;margin-bottom:0;min-height:24px}
body .comp-detail-heading>h2{grid-column:1;grid-row:2;max-width:100%;margin:0;font-size:20px!important}
body .comp-detail-heading>.comp-reader-facts{grid-column:1;grid-row:3;margin-top:4px}
body .comp-fact-group:first-child{border-left:0;padding-left:0}
@media(max-width:1000px){body #monstersList .enemy-header-details{grid-template-columns:repeat(2,minmax(0,1fr))}body #monstersList .enemy-hp-strip{grid-column:1/-1}}
body #storySceneDetails .scene-image-section:not(:has(.scene-image-preview))>.scene-detail-actions{grid-row:3;align-self:center}
body #storySceneDetails .scene-image-section:not(:has(.scene-image-preview)) .scene-setting-video{grid-row:3;margin-top:0;align-self:center}
@media(min-width:1101px){body #storyCombatDock .combat-workspace{grid-template-columns:200px minmax(0,1fr)}}
body #storyCombatDock .initiative-toolbar{gap:5px}
body #storyCombatDock .initiative-next{font-size:11px!important}
body #storyCombatDock .initiative-person{padding:0!important}
body .md-compact-attack .md-compact-spell-details [data-md^="hit:"],body .md-compact-attack .md-compact-spell-details [data-md^="damage:"],body .md-compact-ability .md-compact-spell-details [data-md^="damage:"]{display:none}
body .md-compact-spell-details .md-roll-formula{font-size:12px;color:var(--ui-muted);margin:6px 0}
body #libraryMusicPane>.session-row:not(.library-import-row){padding-bottom:12px;border-bottom:1px solid var(--ui-line);margin-bottom:12px;align-items:flex-end;gap:10px}
body #libraryMusicPane #musicSearch{order:-1;flex:1;max-width:480px}
body #libraryMusicPane #musicCount{order:5;margin-left:auto;align-self:center;white-space:nowrap}
body #libraryMusicPane .library-import-row{gap:10px;align-items:flex-end;margin-bottom:16px}
body #libraryMusicPane .library-import-row label{display:flex;flex-direction:column;gap:5px}
body #libraryMusicPane .library-import-row .session-upload{min-height:36px;justify-content:center}
body #libraryMusicPane .session-grid>p{grid-column:1/-1;margin:0}
body :is(#picturesPanel,#libraryMapPane,#libraryVideoPane) .session-row{display:flex;align-items:center;gap:8px;flex-wrap:wrap;margin-bottom:14px}
body :is(#picturesPanel,#libraryMapPane,#libraryVideoPane) .session-row input[type=search]{flex:1;min-width:180px;max-width:480px}
body .library-media-pane .session-grid>p,body #picturesPanel .session-grid>p{grid-column:1/-1;max-width:none}
body .library-gallery-controls .session-upload{min-height:36px;display:inline-flex;align-items:center;justify-content:center}
/* Reference-card headers share their card surface and a safe title inset. */
body #monstersList .enemy-info-card{border-radius:9px;overflow:hidden;background:var(--ui-surface)}
body #monstersList .enemy-info-card>.md-section-head{padding:6px 8px 9px!important;margin:0 0 8px!important;box-sizing:border-box;background:transparent!important;border-radius:0;gap:8px;flex-shrink:0}
body #monstersList .enemy-info-card>.md-section-head h4{padding:0!important;margin:0!important;text-indent:0;line-height:1.4;flex-shrink:0}
body #monstersList .enemy-info-card>.md-section-head>div{margin-left:auto;min-width:0;justify-content:flex-end}
body #monstersList .enemy-info-card .enemy-card-body{background:transparent;border-radius:0}
body #monstersList .enemy-info-card>.md-section-head button{height:28px;min-height:28px!important;padding:4px 8px!important;line-height:1.2;display:inline-flex;align-items:center;justify-content:center;box-sizing:border-box}
body .md-role-filters{display:flex;gap:3px;flex-wrap:nowrap;align-items:center}
body #monstersList .md-role-filters button{width:28px;min-width:28px;padding:5px!important;border:1px solid var(--ui-line);border-radius:6px;background:var(--ui-input);color:var(--ui-muted)}
body #monstersList .md-role-filters button[aria-pressed=true]{border-color:var(--ui-reference);background:var(--ui-reference-fill);color:var(--ui-reference);box-shadow:inset 0 -2px 0 var(--ui-reference)}
body .md-role-filters svg{display:block;flex-shrink:0}
body .md-role-filters button:focus-visible{outline:2px solid var(--ui-reference);outline-offset:2px}
body #monstersList .enemy-header-details .enemy-hp-strip{border-right:0!important}
body #monstersList .enemy-header-details .defense-column-heading,body #monstersList .enemy-header-details .md-defense-grid>div,body #monstersList .enemy-header-details .md-defense-grid b,body #monstersList .enemy-header-details [data-defense-actor]{border-left:0!important;border-right:0!important;border-top:0!important;border-bottom:0!important}
body #monstersList .enemy-header-details .defense-column-heading{padding:0!important;background:transparent}
/* Roll selection belongs beside the reference cards, separate from creature facts. */
body .enemy-roll-toolbar{display:flex;align-items:center;gap:10px;padding:8px 0 10px;flex-shrink:0;flex-wrap:wrap}
body .enemy-roll-label{font-size:12px;font-weight:600;color:var(--ui-text);white-space:nowrap}
body .enemy-roll-toolbar .roll-mode-segment{margin:0!important;display:inline-flex;gap:3px;padding:3px;border:1px solid var(--ui-line);border-radius:7px;background:var(--ui-input)}
body .enemy-roll-toolbar .roll-mode-segment button{height:28px;min-height:28px;padding:4px 10px;line-height:1.2}
body .enemy-roll-toolbar .roll-mode-segment button[aria-pressed=true]{border-color:var(--ui-combat);color:#ffe3a6;background:var(--ui-combat-fill)}
body #monstersList .enemy-card-actions .enemy-loot-button{width:auto;min-width:0;height:30px;padding:4px 10px!important;margin-right:6px;font-size:12px;white-space:nowrap;border:1px solid var(--ui-line)}
body #monstersList .enemy-name-row{justify-content:flex-start;gap:10px}
body #monstersList .enemy-context{display:flex;align-items:center;flex-wrap:wrap;gap:6px;min-width:0}
body #monstersList .enemy-cr-badge{margin:0}
body #monstersList .combat-condition-name button{width:20px!important;min-width:20px!important;height:20px!important;min-height:20px!important;padding:2px!important;margin:0!important;border:0!important;border-radius:4px;background:transparent!important;display:inline-flex;align-items:center;justify-content:center;line-height:1;color:inherit}
body #monstersList .combat-condition-name button svg{width:13px!important;height:13px!important}
body #monstersList .combat-condition{padding:4px 6px;align-items:center}
body #monstersList .combat-condition-name{gap:4px;align-items:center}
body #monstersList .combat-condition-name button:hover{background:#ffffff18!important}
body :is(input:not([type=checkbox]):not([type=radio]):not([type=range]),textarea,select):focus-visible{outline:2px solid var(--ui-reference)!important;outline-offset:-2px!important;box-shadow:none!important}
body #monstersList .enemy-hp-controls,body #playerTurnEnemies .enemy-hp-controls{display:flex;align-items:center;gap:6px!important;column-gap:6px!important}
body .enemy-hp-controls>*{margin:0!important}
body .enemy-hp-controls .hp-adjust-label{flex-shrink:0}
body #monstersList .enemy-info-card>.md-section-head{height:42px;min-height:42px;flex-wrap:nowrap;align-items:center;padding:4px 6px 9px!important}
body #monstersList .enemy-info-card>.md-section-head>div{flex-wrap:nowrap}
body #monstersList .enemy-info-card>.md-section-head .enemy-card-add,body #monstersList .enemy-info-card>.md-section-head .enemy-card-refresh{width:28px;min-width:28px;padding:3px!important;font-size:20px;font-weight:500}
body .enemy-spell-toolbar{display:flex;align-items:center;justify-content:space-between;gap:5px;padding:0 0 8px;flex-shrink:0}
body #monstersList .enemy-spell-toolbar .md-role-filters{gap:3px}
body #monstersList .enemy-spell-toolbar button{height:24px!important;min-height:24px!important;width:24px!important;min-width:24px!important;padding:3px!important;display:inline-flex;align-items:center;justify-content:center}
body #monstersList .enemy-spell-toolbar [data-md=spellRest]{font-size:18px}
body #monstersList .enemy-header-details{grid-template-columns:minmax(260px,300px) repeat(3,minmax(0,1fr));gap:20px;align-items:center;margin:8px 0 0;padding:8px 0}
body #monstersList .enemy-header-details .enemy-hp-strip{padding:0!important;border:0!important;gap:6px 8px}
body #monstersList .enemy-header-details .md-defense-grid>div{justify-content:center;gap:6px;min-height:48px;margin:0!important}
body #monstersList .enemy-header-details .defense-column-heading{min-height:16px;margin:0!important;line-height:1.4}
body #monstersList .enemy-header-details .defense-badges,body #monstersList .enemy-header-details .defense-empty{border:0!important;padding:0!important;margin:0!important;background:transparent!important;min-height:22px;display:flex;align-items:center;gap:4px}
body #monstersList .enemy-header-details .defense-badges::before,body #monstersList .enemy-header-details .defense-badges::after,body #monstersList .enemy-header-details .defense-empty::before,body #monstersList .enemy-header-details .defense-empty::after{display:none!important}
@media(max-width:1000px){body #monstersList .enemy-header-details{grid-template-columns:repeat(3,minmax(0,1fr));gap:10px}body #monstersList .enemy-header-details .enemy-hp-strip{grid-column:1/-1;max-width:340px}}
body .monster-defense-picker{border:0;padding:0;margin:0;min-width:0}
body .monster-defense-picker legend{font-size:12px;padding:0;margin-bottom:8px}
body .monster-defense-checks{display:flex;gap:6px;flex-wrap:wrap}
body .monster-defense-checks label{display:inline-flex;flex-direction:row;align-items:center;gap:4px}
body .monster-defense-checks input[type=checkbox]{width:14px;min-height:0;height:14px;padding:0;accent-color:var(--ui-reference)}
body .monster-defense-custom{margin-top:10px}
body #monsterDefenseFields>label[hidden]{display:none!important}
/* Spell header tools sit together above a single divider. */
body #monstersList .enemy-info-card[data-info-section=spells]>.md-section-head{border-bottom:0!important;margin-bottom:0!important}
body #monstersList .enemy-info-card>.enemy-spell-toolbar{border-bottom:1px solid var(--ui-line);padding-bottom:9px;margin-bottom:8px}
/* Initiative hover/focus stays on the row instead of expanding the name button. */
body #initiativeRail .initiative-row{position:relative;isolation:isolate;overflow:hidden}
body #initiativeRail .initiative-select{box-sizing:border-box;max-width:100%;min-width:0;overflow:hidden;transform:none!important}
body #initiativeRail .initiative-select:hover{background:transparent!important;filter:none;box-shadow:none!important}
body #initiativeRail .initiative-row:has(.initiative-select:hover):not(.is-current){background:#1a2b40;border-color:#7294b4}
body #initiativeRail .initiative-row.is-current:has(.initiative-select:hover){background:#3b3018;border-color:#e4bd73}
body #initiativeRail .initiative-row:focus-within{outline:2px solid var(--ui-reference);outline-offset:-2px}
body #initiativeRail .initiative-select:focus-visible{outline:2px solid var(--ui-reference)!important;outline-offset:-2px!important}
body #initiativeRail .initiative-score,body #initiativeRail .initiative-remove{position:relative;z-index:1}
body #initiativeRail .initiative-remove{position:absolute}
body #monsterDefenseFields{display:block}
body .defense-assignment-ui{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:10px}
body .defense-drag-hint{grid-column:1/-1;margin:0;font-size:12px;color:var(--ui-muted);line-height:1.4}
body .defense-drop-zone{border:1px solid var(--ui-line);border-radius:7px;padding:10px;min-width:0;background:var(--ui-input)}
body .defense-drop-zone[data-defense-zone=None]{grid-column:1/-1;display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:10px}
body .defense-drop-zone h4{margin:0 0 8px;font-size:12px}
body .defense-drop-zone[data-defense-zone=None]>h4,body .defense-drop-zone[data-defense-zone=None]>.defense-drop-empty{grid-column:1/-1;margin-bottom:0}
body .defense-damage-family{margin-bottom:8px}
body .defense-damage-family h5{font-size:11px;color:var(--ui-muted);margin:0 0 5px}
body .defense-drag-badges{display:flex;gap:5px;flex-wrap:wrap}
body .defense-drag-badges button{cursor:grab;min-height:26px;padding:4px 6px;font-size:11px}
body .defense-drag-badges button:active{cursor:grabbing}
body .defense-drop-zone.is-drag-over{outline:2px solid var(--ui-reference);outline-offset:-2px;background:var(--ui-reference-fill)}
body .defense-drop-empty{font-size:12px;line-height:1.4;color:var(--ui-muted);min-height:30px}
body .defense-move-choice{flex:1 0 100%;font-size:12px}
body .defense-move-choice select{width:100%;min-height:32px}
@media(max-width:650px){body .defense-assignment-ui,body .defense-drop-zone[data-defense-zone=None]{grid-template-columns:1fr}}
body #monstersList .enemy-info-card[data-info-section=spells]>.md-section-head{border-bottom:1px solid var(--ui-line)!important;margin-bottom:8px!important;gap:5px}
body #monstersList .enemy-info-card[data-info-section=spells]>.md-section-head>.md-role-filters{margin-left:0;gap:2px;flex-shrink:0}
body #monstersList .enemy-info-card[data-info-section=spells]>.md-section-head .md-role-filters button{width:22px;min-width:22px;height:28px;padding:3px!important}
body #monstersList .enemy-info-card[data-info-section=spells]>.md-section-head .md-role-filters svg{width:14px;height:14px}
body #monstersList .enemy-info-card[data-info-section=spells]>.md-section-head>h4{font-size:11px;letter-spacing:0}
@container(max-width:275px){body #monstersList .enemy-info-card[data-info-section=spells]>.md-section-head{padding-left:2px!important;padding-right:2px!important;gap:3px}body #monstersList .enemy-info-card[data-info-section=spells]>.md-section-head .md-role-filters{gap:1px}body #monstersList .enemy-info-card[data-info-section=spells]>.md-section-head .md-role-filters button{width:16px;min-width:16px;padding:1px!important}body #monstersList .enemy-info-card[data-info-section=spells]>.md-section-head .md-role-filters svg{width:12px;height:12px}body #monstersList .enemy-info-card[data-info-section=spells]>.md-section-head .enemy-card-refresh,body #monstersList .enemy-info-card[data-info-section=spells]>.md-section-head .enemy-card-add{width:23px;min-width:23px}}
/* Dedicated four-quarter summary. Dividers belong to padded section containers only. */
body #monstersList .enemy-health-summary{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,3fr);align-items:stretch;gap:0;padding:12px 0 8px;margin:0;min-width:0}
body #monstersList .enemy-health-summary>.enemy-hp-strip{display:grid;grid-template-columns:auto minmax(30px,1fr);align-items:center;gap:6px 8px;padding:0 16px 0 0;border:0;margin:0;min-width:0;box-sizing:border-box}
body #monstersList .enemy-health-summary .enemy-hp-controls{grid-column:1/-1;display:flex;gap:6px;flex-wrap:nowrap}
body #monstersList .enemy-defense-summary{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:0;margin:0;padding:0;border:0;min-width:0}
body #monstersList .enemy-defense-fact{display:grid;grid-template-rows:auto minmax(24px,auto);align-content:center;gap:6px;margin:0;padding:0 16px;border:0;border-left:1px solid var(--ui-line);min-width:0;background:transparent;box-sizing:border-box}
body #monstersList .enemy-defense-fact>dt{font-size:11px;font-weight:600;line-height:1.4;text-transform:uppercase;letter-spacing:.03em;color:var(--ui-muted);margin:0;padding:0;border:0;overflow-wrap:anywhere}
body #monstersList .enemy-defense-fact>dd{display:flex;align-items:center;flex-wrap:wrap;gap:5px;margin:0;padding:0;border:0;font-size:12px;line-height:1.4;color:var(--ui-muted);min-width:0}
body #monstersList .enemy-defense-fact::before,body #monstersList .enemy-defense-fact::after,body #monstersList .enemy-defense-fact>dt::before,body #monstersList .enemy-defense-fact>dt::after,body #monstersList .enemy-defense-fact>dd::before,body #monstersList .enemy-defense-fact>dd::after{content:none}
@media(max-width:650px){body #monstersList .enemy-health-summary{grid-template-columns:1fr;gap:12px}body #monstersList .enemy-health-summary>.enemy-hp-strip{padding-right:0}body #monstersList .enemy-defense-fact{padding:0 10px}body #monstersList .enemy-defense-fact:first-child{border-left:0;padding-left:0}}

/* Ability tools share the spell header geometry. */
body #monstersList .enemy-info-card[data-info-section=abilities]>.md-section-head{border-bottom:0!important;margin-bottom:0!important}
body #monstersList .enemy-info-card[data-info-section=abilities]>.md-section-head{border-bottom:1px solid var(--ui-line)!important;margin-bottom:8px!important;gap:5px}
body #monstersList .enemy-info-card[data-info-section=abilities]>.md-section-head>.md-role-filters{margin-left:0;gap:2px;flex-shrink:0}
body #monstersList .enemy-info-card[data-info-section=abilities]>.md-section-head .md-role-filters button{width:22px;min-width:22px;height:28px;padding:3px!important}
body #monstersList .enemy-info-card[data-info-section=abilities]>.md-section-head .md-role-filters svg{width:14px;height:14px}
body #monstersList .enemy-info-card[data-info-section=abilities]>.md-section-head>h4{font-size:11px;letter-spacing:0}
@container(max-width:275px){body #monstersList .enemy-info-card[data-info-section=abilities]>.md-section-head{padding-left:2px!important;padding-right:2px!important;gap:3px}body #monstersList .enemy-info-card[data-info-section=abilities]>.md-section-head .md-role-filters{gap:1px}body #monstersList .enemy-info-card[data-info-section=abilities]>.md-section-head .md-role-filters button{width:16px;min-width:16px;padding:1px!important}body #monstersList .enemy-info-card[data-info-section=abilities]>.md-section-head .md-role-filters svg{width:12px;height:12px}body #monstersList .enemy-info-card[data-info-section=abilities]>.md-section-head .enemy-card-refresh,body #monstersList .enemy-info-card[data-info-section=abilities]>.md-section-head .enemy-card-add{width:23px;min-width:23px}}

/* Compact reference rows preserve badges without tall stacks of headings. */
body #monstersList .enemy-info-card[data-info-section=stats] .md-info-group{display:flex;flex-wrap:wrap;align-items:center;gap:4px 6px;padding:5px 0;margin:0;border:0}
body #monstersList .enemy-info-card[data-info-section=stats] .md-info-group h5{margin:0;padding:0;line-height:1.4;font-size:11px;flex:0 0 auto}
body #monstersList .enemy-info-card[data-info-section=stats] .md-info-badges{display:contents}
body #monstersList .enemy-info-card[data-info-section=stats] .md-info-badges>span{padding:3px 5px;min-height:0;line-height:1.4}
body #monstersList .enemy-info-card[data-info-section=stats] .md-skills{margin:0 0 8px;gap:4px;border:0;padding:0}
body #monstersList .enemy-info-card[data-info-section=stats] .md-skills:empty{display:none}
body #monstersList .enemy-info-card[data-info-section=stats] .md-skills-heading{margin:0 0 6px;padding:0;border:0}
body .stats-skills-editor{border:1px solid var(--ui-line);border-radius:8px;padding:10px;margin:0}
body .stats-skills-editor legend{font-size:12px;padding:0 5px}
body .stats-skill-row{display:grid;grid-template-columns:minmax(0,1fr) 90px 28px;gap:6px;align-items:center;margin-bottom:6px}
body .stats-skill-row button{width:28px;height:28px;padding:0}
body .stats-skill-row input{min-width:0;width:100%}

body #monstersList .enemy-info-card[data-info-section=stats] .md-save-grid{grid-auto-rows:48px;grid-template-rows:none;margin:6px 0 12px;gap:6px}
body #monstersList .enemy-info-card[data-info-section=stats] .md-skills .skill-badge{min-height:24px;padding:3px 5px!important;line-height:1.4}

body #monstersList .enemy-info-card[data-info-section=stats] .md-save-grid button:hover{transform:none!important;box-shadow:inset 0 0 0 1px var(--ui-reference)}
body #monstersList .enemy-info-card[data-info-section=stats] .md-save-grid button:focus-visible{outline:2px solid var(--ui-reference)!important;outline-offset:-2px!important;box-shadow:none!important}

/* Scene music lives beside the title; media panels fill the remaining reading area. */
body header #musicPlayer{display:none}
body .story-selected-heading{flex-wrap:wrap;gap:10px}
body .scene-header-music{display:flex;align-items:center;gap:8px;flex:1;min-width:0;flex-wrap:wrap}
body #sceneMusicSettings{display:flex;align-items:center;gap:6px;flex-wrap:wrap}
body #sceneMusicSettings .story-asset-controls{display:flex;gap:4px;margin:0;flex-wrap:wrap}
body .scene-header-music #musicPlayer{border:0;background:transparent;min-width:0;flex:1}
body .scene-header-music .music-player-inner{padding:0;gap:8px;max-width:none;flex-wrap:wrap}
body .scene-header-music #nowPlaying{max-width:180px;font-size:12px}
body .scene-header-music .music-controls{gap:5px}
body .scene-header-music .music-controls button{height:28px;width:28px;padding:0}
body .scene-header-music .music-controls label{font-size:11px}
body .story-reader #storyDocument{display:flex;flex-direction:column;min-height:0}
body #storySceneDetails{flex:1;min-height:300px;height:auto;grid-template-rows:repeat(2,minmax(0,1fr));align-content:stretch}
body #storySceneDetails>.scene-characters-card{grid-row:1/3}
body #storySceneDetails>.scene-map-card{grid-row:2}
body #storySceneDetails>.scene-image-section{grid-template-columns:minmax(100px,32%) minmax(0,1fr)}
body #storySceneDetails .scene-image-preview{width:100%;align-self:stretch}
body #storySceneDetails .scene-image-preview img{width:100%;height:100%;min-height:100px;max-height:180px;object-fit:contain}
@media(max-width:650px){body #storySceneDetails{flex:none;grid-template-rows:none}body #storySceneDetails>.scene-characters-card,body #storySceneDetails>.scene-map-card{grid-row:auto}body .scene-header-music{flex-basis:100%}}
body .story-reader #storyDocument>.story-context{display:flex;flex-direction:column;flex:1;min-height:0}body .story-reader #storyDocument>.story-context-row{flex-shrink:0}

/* One bounded music panel instead of disconnected header controls. */
body .scene-header-music{flex:0 1 auto;max-width:100%;padding:5px 7px;border:1px solid #4b647a;border-radius:8px;background:#101e2c;box-shadow:inset 0 1px 0 #ffffff05;gap:7px;box-sizing:border-box}
body #sceneMusicSettings{gap:4px;flex-wrap:nowrap}
body #sceneMusicSettings>button,body #sceneMusicSettings .story-asset-controls button{height:28px;min-height:28px;padding:3px 7px;font-size:12px;white-space:nowrap}
body #sceneMusicSettings .story-asset-controls{flex-wrap:nowrap}
body .scene-header-music #musicPlayer{flex:0 1 auto}
body .scene-header-music .music-player-inner{gap:7px;justify-content:flex-start}
body .scene-header-music #nowPlaying{flex:0 1 140px;max-width:140px;min-width:90px;padding-left:7px;border-left:1px solid #40566b;line-height:24px}
body .scene-header-music .music-controls{flex-wrap:nowrap;gap:4px}
body .scene-header-music .music-controls input[type=range]{width:54px}
body .scene-header-music .music-controls label{white-space:nowrap}
body .scene-header-music:focus-within{border-color:var(--ui-reference)}
@media(max-width:1100px){body .scene-header-music .music-player-inner{flex-wrap:wrap}body .scene-header-music .music-controls{flex-wrap:wrap}}
body .scene-header-music{flex-wrap:nowrap}body .scene-header-music #musicPlayer{flex:0 0 auto}body .scene-header-music .music-player-inner{flex-wrap:nowrap}body .scene-header-music #nowPlaying{width:120px;flex:0 0 120px;max-width:120px}@media(max-width:1100px){body .scene-header-music{flex-wrap:wrap}body .scene-header-music .music-player-inner{flex-wrap:wrap}}

/* Global music control is independent of the selected scene and app section. */
body header #musicPlayer{display:block;border:1px solid #4b647a;border-radius:8px;background:#101e2c;min-width:0;margin:0;padding:0}
body header #musicPlayer .music-player-inner{padding:4px 6px;gap:5px;max-width:none;flex-wrap:nowrap}
body header #nowPlaying{max-width:120px;min-width:65px;font-size:12px;line-height:24px}
body header .music-controls{gap:4px;flex-wrap:nowrap}
body header .music-controls button,body header #browseMusic{min-height:28px;height:28px;padding:3px 6px;font-size:12px;white-space:nowrap}
body header .music-controls input[type=range]{width:50px}
body header .music-controls label{font-size:11px;white-space:nowrap}
body .scene-header-music{border:0;background:transparent;box-shadow:none;padding:0;flex:1}
body .global-music-filters{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:10px;margin-bottom:12px}
body .global-music-filters>input{grid-column:1/-1}
body .global-music-filters label{display:flex;flex-direction:column;gap:5px;font-size:12px}
body .global-music-filters select{width:100%}
body #globalMusicPicker{width:min(620px,95vw);max-height:80vh;overflow:auto}
body #globalMusicResults{display:flex;flex-direction:column;gap:6px}
body .global-music-track{display:grid;grid-template-columns:minmax(0,1fr) auto;gap:4px 10px;text-align:left;padding:10px;border:1px solid var(--ui-line);border-radius:7px;background:var(--ui-input)}
body .global-music-track>span:nth-child(2){grid-column:1;font-size:12px;color:var(--ui-muted)}
body .global-music-track>span:last-child{grid-column:2;grid-row:1/3;align-self:center}
body .global-music-track[aria-pressed=true]{border-color:var(--ui-library);background:var(--ui-library-fill)}
@media(max-width:1100px){body header #musicPlayer .music-controls label{display:none}body header #nowPlaying{max-width:90px}}

/* Music browser uses one shared title row and neutral navy surfaces. */
body #globalMusicPicker{background:var(--ui-surface);color:var(--ui-text);border:1px solid var(--ui-line);padding:18px 20px;border-radius:12px}
body #globalMusicPicker>.story-dialog-heading{display:flex;justify-content:space-between;align-items:center;background:transparent;margin:0 0 16px;padding:0 0 12px;border-bottom:1px solid var(--ui-line);min-height:32px}
body #globalMusicTitle{margin:0;font-size:18px;line-height:1.4;color:var(--ui-text)}
body #globalMusicPicker .global-music-filters input,body #globalMusicPicker .global-music-filters select{min-height:36px;box-sizing:border-box;background:var(--ui-input);color:var(--ui-text);border:1px solid var(--ui-line);border-radius:7px}
body #globalMusicPicker .global-music-filters label{color:var(--ui-muted);font-weight:600}
body #globalMusicPicker .popup-close:focus-visible{outline-color:var(--ui-reference);outline-offset:-2px}
body #globalMusicResults>p{margin:8px 0 0;padding:14px;border:1px dashed var(--ui-line);border-radius:7px;background:var(--ui-input);color:var(--ui-muted);font-size:13px;line-height:1.5}
body header #musicPlayer{width:clamp(440px,38vw,650px);box-sizing:border-box}
body header #musicPlayer .music-player-inner{width:100%;box-sizing:border-box}
body header #nowPlaying{flex:1;min-width:100px;max-width:none}
body #storyFlow .story-scene-edit-actions .ui-icon-action{width:20px!important;min-width:20px!important;height:20px!important;min-height:20px!important;padding:2px!important;box-sizing:border-box}
body #storyFlow .story-scene-edit-actions .ui-icon-action svg{width:14px!important;height:14px!important}
body #storyFlow .story-scene-edit-actions{gap:2px}
body #storyFlow .story-direct-status{height:20px;min-height:20px!important;padding:1px 5px!important;font-size:11px!important;line-height:1.3;box-sizing:border-box}
@media(max-width:1100px){body header #musicPlayer{width:350px}body header #nowPlaying{min-width:60px;max-width:none}}

/* Matching media card headers and action rows. */
body #storySceneDetails>.scene-image-section{display:flex;flex-direction:column;gap:8px;padding:10px}
body #storySceneDetails>.scene-map-card{display:flex;flex-direction:column;gap:8px;padding:10px}
body #storySceneDetails .scene-media-toolbar{display:flex;align-items:center;flex-wrap:wrap;gap:6px;margin:0;flex-shrink:0}
body #storySceneDetails .scene-media-toolbar button,body #storySceneDetails .scene-media-toolbar .scene-image-upload{height:30px;min-height:30px;box-sizing:border-box;margin:0}
body #storySceneDetails .scene-image-preview{flex:1;min-height:70px;align-self:stretch;width:100%;max-height:180px}
body #storySceneDetails .scene-image-preview img{min-height:70px;max-height:180px}
body #storySceneDetails .scene-image-name{white-space:normal}
body #storySceneDetails .scene-setting-video:empty{display:none}
body #storySceneDetails .scene-hint,body #storySceneDetails .scene-image-section>.story-empty{margin:0}
body #storySceneDetails .scene-map-card>.scene-detail-heading{min-height:20px;height:20px;margin:0}body #storySceneDetails .scene-image-section>h4,body #storySceneDetails .scene-map-card h4{min-height:20px;height:20px;line-height:20px;margin:0}

body #storySceneDetails .scene-characters-card>.scene-detail-heading{min-height:20px;height:20px;margin:0 0 8px}body #storySceneDetails .scene-characters-card h4{min-height:20px;height:20px;line-height:20px;margin:0}body #storySceneDetails .scene-characters-card .scene-media-toolbar{margin-bottom:8px}body #storySceneDetails .scene-characters-card .scene-media-toolbar label{margin:0;flex:1;max-width:340px;min-width:140px}body #storySceneDetails .scene-characters-card .scene-media-toolbar select{height:30px;min-height:30px;padding:4px 8px;margin:0}

body #storySceneDetails .scene-npc{border:1px solid var(--ui-line);border-radius:8px;background:var(--ui-input);padding:10px;margin:0 0 8px}
body #storySceneDetails .scene-npc>.scene-detail-heading{align-items:flex-start;gap:8px;margin-bottom:6px}
body .scene-npc-identity{display:flex;flex-wrap:wrap;align-items:center;gap:5px;min-width:0;flex:1}
body .scene-npc-actions{display:flex;align-items:center;gap:4px;flex-shrink:0;margin-left:auto}
body .scene-npc-actions button{height:26px;min-height:26px;padding:3px 6px}
body .scene-media-heading{display:flex;align-items:center;justify-content:space-between;gap:8px;flex-wrap:wrap;flex-shrink:0}
body #storySceneDetails .scene-media-heading .scene-media-toolbar{margin-left:auto}
body #storySceneDetails .scene-media-toolbar .scene-image-upload{display:inline-flex;align-items:center;justify-content:center;width:30px;min-width:30px;padding:0;cursor:pointer}
body #storySceneDetails .scene-map-card>.scene-detail-heading{height:auto;min-height:30px}
body #storySceneDetails .scene-image-preview,body #storySceneDetails .scene-map-preview,body #storySceneDetails .scene-setting-preview-video{flex:1;width:100%;height:auto;min-height:80px;max-height:none;background:var(--ui-input);border:0;border-radius:6px;padding:0;overflow:hidden}
body #storySceneDetails .scene-image-preview img,body #storySceneDetails .scene-map-preview img{width:100%;height:100%;max-height:none;min-height:80px;object-fit:contain}
body #sceneNpcFields [hidden]{display:none!important}
body #sceneMerchantInventory{width:min(900px,95vw);max-height:85vh;overflow:auto}

body #sceneMerchantInventory #itemVendorsPane>.item-library-heading,body #sceneMerchantInventory #vendorList,body #sceneMerchantInventory .item-vendor-head{display:none}body #sceneMerchantInventory #itemVendorsPane{border:0;padding:0;background:transparent;margin:12px 0 0}body .merchant-inventory-actions{display:flex;align-items:center;gap:8px;flex-wrap:wrap}body .merchant-inventory-actions span{margin-left:auto;font-size:12px;color:var(--ui-success)}body #sceneMerchantInventory .vendor-table td{padding:8px 4px}body #sceneMerchantInventory .vendor-table input{max-width:100px}body #itemVendorForm label[hidden]{display:none!important}

body .library-inline-editor{display:flex;flex-direction:column;min-height:100%;gap:12px}body .library-inline-editor>.story-dialog-heading{position:sticky;top:0;background:var(--ui-surface);z-index:2;padding:0 0 10px;border-bottom:1px solid var(--ui-line);margin:0}body .library-inline-editor>.story-dialog-heading [data-character-action=close]{display:none}body .library-inline-editor #libraryCharacterFields{display:flex;flex-direction:column;gap:12px}body .library-inline-editor footer{position:sticky;bottom:0;display:flex;justify-content:flex-end;gap:8px;padding:10px 0;background:var(--ui-surface);border-top:1px solid var(--ui-line);margin-top:auto}body .library-inline-editor textarea{width:100%;min-height:120px}body .library-inline-editor h2{margin:0;font-size:18px}body .library-inline-editor .library-form-grid{grid-template-columns:repeat(2,minmax(0,1fr))}

body .character-reading-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:10px;margin:12px 0}body .character-reading-field{border:1px solid var(--ui-line);border-radius:8px;background:var(--ui-input);padding:10px;margin:0 0 10px}body .character-reading-grid .character-reading-field{margin:0}body .character-reading-field>div:first-child{display:flex;align-items:center;justify-content:space-between;gap:8px;margin-bottom:6px}body .character-reading-field>div:first-child>strong{font-size:12px;color:var(--ui-muted)}body .character-reading-field button[data-character-action=field-edit],body .library-detail-heading>button[data-field=name]{width:24px;height:24px;min-height:24px;padding:0;flex-shrink:0}body .character-field-value{font-size:13px;line-height:1.6;overflow-wrap:anywhere}body .character-field-editor{display:flex;flex-direction:column;gap:8px;margin-top:8px}body .character-field-editor label{display:flex;flex-direction:column;gap:5px}body .character-field-editor input,body .character-field-editor textarea,body .character-field-editor select{width:100%}body .character-field-editor>div{display:flex;gap:6px}body .character-field-editor [role=alert]{color:var(--ui-danger)}

/* Stable reading surfaces: three section edits, no per-field card expansion. */
body .character-reference-section{padding:0 0 14px;margin:0 0 14px;border-bottom:1px solid var(--ui-line)}
body .character-reference-heading{display:flex;align-items:center;justify-content:space-between;gap:10px;min-height:30px;margin-bottom:10px}
body .character-reference-heading h3{margin:0;font-size:14px;color:var(--ui-text)}
body .character-reference-actions{display:flex;justify-content:flex-end;gap:5px;min-width:112px;height:28px}
body .character-reference-actions button{height:28px;min-height:28px;padding:3px 8px;font-size:12px}
body .character-reference-actions [hidden]{display:none!important}
body .character-reference-grid{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:10px 14px}
body .character-reference-field{display:flex;flex-direction:column;gap:4px;min-width:0}
body .character-reference-field>span{font-size:11px;color:var(--ui-muted)}
body .character-reference-field input,body .character-reference-field select{width:100%;height:34px;min-height:34px;padding:5px 7px;box-sizing:border-box;font-size:13px;border:1px solid transparent;border-radius:6px;background:transparent;color:var(--ui-text)}
body .character-reference-section:not(.is-editing) select{opacity:1;appearance:none;cursor:default}
body .character-reference-section:not(.is-editing) input{cursor:default}
body .character-reference-section textarea{width:100%;height:160px;min-height:160px;max-height:160px;resize:none;padding:10px;box-sizing:border-box;font-size:13px;line-height:1.6;border:1px solid transparent;background:var(--ui-input);border-radius:7px}
body .character-reference-section.is-editing :is(input,select,textarea){border-color:var(--ui-line);background:var(--ui-input)}
body .character-reference-section input[type=number]{appearance:textfield;-moz-appearance:textfield}
body .character-reference-section input::-webkit-inner-spin-button{display:none}
body .character-reference-scores{display:grid;grid-template-columns:repeat(6,minmax(0,1fr));gap:8px;margin-top:14px}
body .character-reference-scores>div{background:var(--ui-input);border-radius:7px;padding:8px;min-width:0}
body .character-reference-scores strong{display:block;font-size:12px;margin-bottom:6px}
body .character-reference-grid.combat-facts{grid-template-columns:repeat(4,minmax(0,1fr))}
body .character-reference-error{margin:0;height:20px;font-size:12px;color:var(--ui-danger)}
@media(max-width:1100px){body .character-reference-grid{grid-template-columns:repeat(2,minmax(0,1fr))}body .character-reference-scores{grid-template-columns:repeat(3,minmax(0,1fr))}}
/* Keep character reading geometry independent of legacy Library form rules. */
body #libraryCharacterDetails .character-reference-section{display:block;padding:0 0 12px;margin:0 0 12px;gap:0}
body #libraryCharacterDetails .character-reference-heading h3{margin:0;color:var(--ui-text)}
body #libraryCharacterDetails .character-reference-field{margin:0;gap:4px}
body #libraryCharacterDetails .character-reference-field :is(input,select){height:34px;min-height:34px;margin:0;padding:5px 7px;border:1px solid transparent;background:transparent;box-sizing:border-box}
body #libraryCharacterDetails .character-reference-section.is-editing :is(input,select,textarea){background:var(--ui-input);border-color:var(--ui-line)}
body #libraryCharacterDetails .character-reference-section textarea{margin:0;height:160px;min-height:160px;max-height:160px;resize:none}
body #libraryCharacterDetails .character-reference-error{margin:0;padding:0;height:20px;min-height:20px;line-height:20px}
body #libraryCharacterDetails .character-overview-row{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1fr);gap:20px;align-items:stretch}
body #libraryCharacterDetails .character-overview-row .character-reference-section{min-width:0}
body #libraryCharacterDetails .character-overview-row textarea{height:190px;min-height:190px;max-height:190px}
body .character-basic-layout{display:flex;gap:14px;align-items:flex-start}
body .character-basic-fields{flex:1;min-width:0}
body .character-portrait-square{width:88px;height:88px;min-width:88px;padding:0;overflow:hidden;border:1px solid var(--ui-line);border-radius:8px;display:flex;flex-direction:column;justify-content:center;align-items:center;background:var(--ui-input);color:var(--ui-text)}
body .character-portrait-square img{width:100%;height:100%;object-fit:cover}
body .character-portrait-square>span{font-size:32px}body .character-portrait-square small{font-size:11px}
body #libraryCharacterDetails .character-trait-badges{display:flex;flex-wrap:wrap;gap:8px;margin-top:10px}
body #libraryCharacterDetails .character-trait-badges label{max-width:100%;width:auto}
body #libraryCharacterDetails .character-trait-badges select{border:1px solid var(--ui-line);background:var(--ui-input);height:28px;min-height:28px;width:auto;max-width:100%;padding:3px 8px;border-radius:6px}
body #libraryCharacterDetails .character-reference-scores{grid-template-columns:repeat(3,minmax(0,1fr));max-width:620px;gap:6px}
body #libraryCharacterDetails .character-reference-scores>div{display:grid;grid-template-columns:1fr 1fr;gap:0 6px;border:1px solid var(--ui-line);background:var(--ui-surface);padding:6px 8px}
body #libraryCharacterDetails .character-reference-scores>div>strong{grid-column:1/-1;margin:0;font-size:12px}
body #libraryCharacterDetails .character-reference-scores input{height:28px;min-height:28px;padding:0 3px}
body #libraryCharacterDetails .character-reference-scores label:last-child input{color:#80dcff;font-size:22px;font-weight:700;text-align:right}
body .character-portrait-picker{width:min(600px,90vw)}body .portrait-upload{display:inline-flex;align-items:center;gap:8px;padding:8px;border:1px solid var(--ui-line);border-radius:6px}
body .portrait-library{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:8px;max-height:360px;overflow:auto}
body .portrait-library button{display:flex;flex-direction:column;gap:6px;padding:6px;min-width:0}
body .portrait-library img{width:100%;height:90px;object-fit:cover;border-radius:4px}body .portrait-library span{overflow-wrap:anywhere}
@media(max-width:1000px){body #libraryCharacterDetails .character-overview-row{grid-template-columns:1fr}}
body #libraryCharacterDetails .character-reference-heading>[data-character-action=use]{margin-left:auto;flex-shrink:0;position:static}
body #libraryCharacterDetails .character-reference-heading .character-reference-actions{order:3;min-width:112px}
body #libraryCharacterDetails .character-trait-badges>[data-character-action=vendor]{position:static;align-self:flex-end;height:28px;min-height:28px;padding:3px 8px}
body #libraryCharacterDetails .character-trait-badges select{appearance:auto;cursor:pointer;padding-right:18px}
body #libraryCharacterDetails .library-combat-reference .monster-dashboard{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px}
body #libraryCharacterDetails .library-combat-reference .monster-dashboard>section{border:1px solid var(--ui-line);border-radius:9px;padding:10px;background:var(--ui-surface);min-width:0;grid-column:auto;overflow:hidden}
body #libraryCharacterDetails .library-combat-reference .monster-dashboard>.md-defenses{grid-column:1/-1}
body #libraryCharacterDetails .library-combat-reference .md-section-head{display:flex;align-items:center;min-height:32px;margin:0 0 8px;padding:0 0 8px;border-bottom:1px solid var(--ui-line)}
body #libraryCharacterDetails .library-combat-reference .md-section-head h4{margin:0;padding:0;font-size:13px}
body #libraryCharacterDetails .character-reference-scores{max-width:none;margin:6px 0 12px;grid-template-columns:repeat(3,minmax(0,1fr));gap:6px}
body #libraryCharacterDetails .character-reference-scores .library-save-tile{height:48px;min-height:48px;box-sizing:border-box;padding:5px;display:grid;grid-template-columns:minmax(0,1fr) auto;align-items:center;background:#1c3448;border:1px solid #608aa4;border-radius:6px;gap:3px}
body #libraryCharacterDetails .library-save-tile .md-save-identity{display:flex;flex-direction:column;gap:2px;min-width:0;align-items:flex-start}
body #libraryCharacterDetails .library-save-tile .md-save-name{font-size:12px;font-weight:700}
body #libraryCharacterDetails .library-save-tile label>span{display:none}
body #libraryCharacterDetails .library-save-tile label{gap:0;min-width:0}
body #libraryCharacterDetails .library-save-tile .md-save-identity input{height:16px;min-height:16px;line-height:16px;padding:0;font-size:12px;width:40px}
body #libraryCharacterDetails .library-save-tile>label input{width:48px;height:28px;min-height:28px;padding:0;font-size:21px;line-height:1;color:#80dcff;font-weight:700;text-align:right}
body #libraryCharacterDetails .library-combat-reference .md-entry{margin-bottom:8px}
body #libraryCharacterDetails .library-combat-reference .md-skills button:disabled{opacity:1}
body header #appBrandTitle{font-size:23px!important;line-height:32px;margin:0;white-space:nowrap;letter-spacing:.035em}
body #libraryCharacterDetails .library-save-tile .md-save-identity label input{font-size:12px!important;font-weight:400!important;text-align:left!important;color:var(--ui-text)!important;width:40px;height:16px;min-height:16px;padding:0}
body #libraryCharacterDetails .library-combat-reference .md-skills button:disabled{opacity:1!important;color:var(--ui-text)!important;cursor:default}
body #libraryCharacters .library-controls{display:grid;grid-template-columns:minmax(110px,1fr) minmax(125px,1fr) minmax(110px,1fr);gap:10px;align-items:end}
body #libraryCharacters .library-controls>#libraryCharacterSearch{grid-column:1/-1;order:0;width:100%}
body #libraryCharacters .library-controls .character-filter,body #libraryCharacters .library-controls .library-sort-control{display:flex;flex-direction:column;gap:4px;font-size:12px;min-width:0;margin:0;order:1;color:var(--ui-muted)}
body #libraryCharacters .library-controls :is(.character-filter,.library-sort-control) select{width:100%;height:34px;margin:0}
body #libraryCharacters .library-controls>[data-character-action=new]{order:2;justify-self:start}
body #libraryCharacters .library-controls>#libraryCharacterCount{order:2;grid-column:2/-1;justify-self:end;align-self:center}
body #libraryCharacterDetails .library-combat-reference .md-section-head>div{margin-left:auto;display:flex;gap:5px;align-items:center}
body #libraryCharacterDetails .library-combat-reference .md-section-head>button{margin-left:auto}
body #libraryCharacters{grid-template-columns:minmax(280px,20%) minmax(0,1fr)!important}
body #libraryCharacters .library-controls{grid-template-columns:repeat(2,minmax(0,1fr))}
body #libraryCharacters .library-controls .library-sort-control{grid-column:1/-1}
body #libraryCharacters .library-controls>#libraryCharacterCount{grid-column:2}
@media(max-width:950px){body #libraryCharacters{grid-template-columns:minmax(240px,28%) minmax(0,1fr)!important}}
body #libraryCharacterDetails .library-combat-reference .monster-dashboard{grid-template-columns:repeat(4,minmax(0,1fr));gap:8px}
body #libraryCharacterDetails .library-combat-reference .monster-dashboard>section:not(.md-defenses){height:430px;display:flex;flex-direction:column;overflow:auto;min-width:0}
body #libraryCharacterDetails .library-combat-reference .md-section-head{flex-shrink:0;position:sticky;top:-10px;z-index:1;background:var(--ui-surface);padding-top:8px}
body #libraryCharacterDetails .library-combat-reference .md-save-grid{flex-shrink:0}
body #libraryCharacters .library-controls .library-sort-control{width:100%;align-items:stretch;justify-content:flex-start}
body #libraryCharacters .library-controls .library-sort-control select{max-width:none;width:100%}
body #libraryCharacterDetails .library-save-tile{grid-template-columns:minmax(28px,1fr) 32px!important}
body #libraryCharacterDetails .library-save-tile .md-save-name{white-space:nowrap}
body #libraryCharacterDetails .library-save-tile>label input{width:32px!important}
body #libraryCharacterDetails .library-save-tile .md-save-identity label input{width:28px!important}
body #libraryCharacterDetails .library-combat-reference .monster-dashboard>section:not(.md-defenses)>.md-section-head{min-height:72px;align-items:flex-start;flex-wrap:wrap}
body #libraryCharacterDetails .library-combat-reference .md-role-filters button{width:23px;min-width:23px;height:26px;min-height:26px;padding:2px}
body #libraryCharacterDetails .library-combat-reference [data-md^="add:"]{width:28px;min-width:28px;padding:0}
body #libraryCharacterDetails .character-trait-badges [name=characterLevel]{width:60px;height:28px;min-height:28px;border:1px solid var(--ui-line);border-radius:6px;padding:3px 8px;background:var(--ui-input);cursor:text}
body #libraryCharacterDetails .class-build-note{padding:8px 10px;background:var(--ui-input);border:1px solid var(--ui-line);border-radius:6px;font-size:12px;line-height:1.5;margin:8px 0 12px}
body #libraryCharacterDetails .character-reference-heading{flex-wrap:wrap}
/* Library profiles share combat cards; surrounding reference stays within the viewport. */
body #libraryCharacterDetails .library-character-content{display:flex;flex-direction:column;padding:10px 14px;gap:8px;overflow:hidden}
body #libraryCharacterDetails .character-overview-row{flex:none;gap:14px}
body #libraryCharacterDetails .character-overview-row .character-reference-section{padding:0 0 6px;margin:0}
body #libraryCharacterDetails .character-overview-row textarea{height:110px;min-height:110px;max-height:110px;padding:8px}
body #libraryCharacterDetails .character-overview-row .character-reference-error{height:0;min-height:0;overflow:hidden}
body #libraryCharacterDetails .character-overview-row .character-reference-error:not(:empty){height:20px;min-height:20px}
body #libraryCharacterDetails .character-reference-heading{min-height:28px;margin-bottom:6px}
body #libraryCharacterDetails [data-character-group=combat]{display:flex;flex-direction:column;flex:1;min-height:0;margin:0;padding:0;border:0;gap:4px}
body #libraryCharacterDetails [data-character-group=combat]>.character-reference-grid{flex:none;gap:4px 12px}
body #libraryCharacterDetails [data-character-group=combat]>.character-reference-error{flex:none;height:0;min-height:0}
body #libraryCharacterDetails [data-character-group=combat]>.character-reference-error:not(:empty){height:20px;min-height:20px}
body #libraryCharacterDetails .library-combat-reference{flex:1;min-height:0}
body #libraryCharacterDetails .library-combat-reference .monster-dashboard{height:100%;grid-template-rows:auto minmax(0,1fr);gap:8px}
body #libraryCharacterDetails .library-combat-reference .monster-dashboard>section:not(.md-defenses){height:auto;min-height:0;overflow:hidden;padding:8px}
body #libraryCharacterDetails .library-combat-reference .monster-dashboard>.md-defenses{padding:6px 8px;display:flex;align-items:center;gap:8px}
body #libraryCharacterDetails .library-combat-reference .md-defenses>.md-section-head{order:2;border:0;margin:0;padding:0;min-height:28px}
body #libraryCharacterDetails .library-combat-reference .md-defense-grid{flex:1;margin:0}
body #libraryCharacterDetails .library-combat-reference .monster-dashboard>section:not(.md-defenses)>.md-section-head{position:static;min-height:50px;height:50px;padding:0 0 6px;margin:0 0 6px;align-items:center;box-sizing:border-box}
body #libraryCharacterDetails .md-library-card-body{flex:1;min-height:0;overflow:auto;scrollbar-gutter:stable}
body #libraryCharacterDetails .class-build-note{font-size:11px;line-height:1.4;margin:0;padding:4px 8px;max-height:38px;overflow:auto;flex:none}
body .character-portrait-picker .story-dialog-heading{display:flex;align-items:center;justify-content:space-between;border-bottom:1px solid var(--ui-line);padding:0 0 12px;margin:0 0 12px;background:transparent}
body .character-portrait-picker .story-dialog-heading h2{margin:0;font-size:19px;color:var(--ui-text)}
body .character-portrait-picker .portrait-upload{position:relative;width:32px;height:32px;padding:0;justify-content:center;cursor:pointer;margin:0 0 14px;background:var(--ui-input)}
body .character-portrait-picker .portrait-upload input{position:absolute;inset:0;opacity:0;width:100%;height:100%;margin:0;padding:0;cursor:pointer}
body .character-portrait-picker .portrait-upload:focus-within{outline:2px solid var(--ui-reference);outline-offset:2px}
body .character-portrait-picker h3{margin:0 0 10px;font-size:13px;color:var(--ui-text)}
body .character-portrait-picker .portrait-library button{background:var(--ui-input);border:1px solid var(--ui-line);border-radius:7px;font-size:12px;line-height:1.4}
/* Merchant controls remain outside the only scrolling surface: the stock table. */
body #sceneMerchantInventory{overflow:hidden;max-height:85dvh}
body #sceneMerchantInventory .merchant-stock-scroll{overflow:auto;max-height:calc(85dvh - 205px);min-height:0;scrollbar-gutter:stable}
body #sceneMerchantInventory .vendor-table{width:100%;margin:0;border-collapse:separate;border-spacing:0}
body #sceneMerchantInventory .vendor-table thead th{position:sticky;top:0;z-index:2;background:var(--ui-surface);border-bottom:1px solid var(--ui-line);box-shadow:0 1px 0 var(--ui-line)}
body #sceneMerchantInventory>.story-dialog-heading,body #sceneMerchantInventory>.merchant-inventory-actions{flex-shrink:0}
/* Library profiles are reference lists, visually distinct from live combat controls. */
body #libraryCharacterDetails .library-combat-reference .monster-dashboard>section:not(.md-defenses){background:transparent;border-color:var(--ui-line);border-radius:7px}
body #libraryCharacterDetails .library-profile-stat-list{display:flex;flex-direction:column;gap:0;margin:6px 0 12px}
body #libraryCharacterDetails .library-profile-stat-list>div{display:grid;grid-template-columns:minmax(0,1fr) 55px 55px;align-items:center;gap:4px;padding:4px 0;border:0;border-bottom:1px solid var(--ui-line);background:transparent;border-radius:0;min-height:30px}
body #libraryCharacterDetails .library-profile-stat-list>div>strong{grid-column:auto;margin:0;font-size:12px}
body #libraryCharacterDetails .library-profile-stat-list label>span{display:none}
body #libraryCharacterDetails .library-profile-stat-list label{margin:0;gap:0}
body #libraryCharacterDetails .library-profile-stat-list input{height:26px;min-height:26px;width:100%;padding:1px 4px;font-size:13px!important;font-weight:400!important;color:var(--ui-text)!important;text-align:right}
body #libraryCharacterDetails .library-profile-stat-head{font-size:11px;color:var(--ui-muted)}
body #libraryCharacterDetails .library-profile-stat-head span:not(:first-child){text-align:right;padding-right:4px}
body #libraryCharacterDetails .library-profile-list-entry{border:0;border-bottom:1px solid var(--ui-line);margin:0;padding:9px 0;background:transparent;border-radius:0}
body #libraryCharacterDetails .library-profile-list-entry>summary{display:flex;flex-direction:column;gap:5px;cursor:pointer;list-style:none;padding-right:14px;position:relative;font-size:13px;line-height:1.45}
body #libraryCharacterDetails .library-profile-list-entry>summary::after{content:'▸';position:absolute;right:0;top:0;color:var(--ui-muted)}
body #libraryCharacterDetails .library-profile-list-entry[open]>summary::after{content:'▾'}
body #libraryCharacterDetails .library-profile-list-entry>summary::-webkit-details-marker{display:none}
body #libraryCharacterDetails .library-profile-tags{display:flex;flex-wrap:wrap;gap:4px;color:var(--ui-muted);font-size:11px}
body #libraryCharacterDetails .library-profile-tags>span{padding:0 5px;border-left:1px solid var(--ui-line)}
body #libraryCharacterDetails .library-profile-tags>span:first-child{padding-left:0;border-left:0}
body #libraryCharacterDetails .library-profile-entry-content{padding-top:7px;font-size:13px;line-height:1.6}
body #libraryCharacterDetails .library-profile-entry-content p{font-size:13px;line-height:1.6}
body #libraryCharacterDetails .library-profile-metadata,body #libraryCharacterDetails .library-profile-pool{font-size:12px!important;color:var(--ui-muted);line-height:1.5;padding:4px 0}
body #libraryCharacterDetails .library-profile-entry-tools{display:flex;gap:6px;justify-content:flex-end;margin-top:8px}
body #libraryCharacterDetails .library-profile-entry-tools button{font-size:12px;height:26px;min-height:26px;padding:3px 8px}
body #libraryCharacterDetails .library-profile-list-entry>summary .library-profile-metadata{padding:0;font-size:12px!important;line-height:1.5;color:var(--ui-muted)}
body #libraryCharacterDetails .library-profile-skill{display:inline-block;font-size:12px;line-height:1.5;padding:2px 5px;border:1px solid var(--ui-line);border-radius:4px;color:var(--ui-text);background:transparent}
/* Profile filters keep their icon geometry; the title and add action get a separate row. */
body #libraryCharacterDetails .library-combat-reference .monster-dashboard>section:not(.md-defenses)>.md-section-head{display:grid;grid-template-columns:minmax(0,1fr) 28px;grid-template-rows:28px 28px;gap:4px;min-height:66px;height:66px;align-items:center;padding:0 0 6px}
body #libraryCharacterDetails .library-combat-reference .md-section-head>h4{grid-column:1;grid-row:1;min-width:0}
body #libraryCharacterDetails .library-combat-reference .md-section-head>div{display:contents}
body #libraryCharacterDetails .library-combat-reference .md-section-head>div>button{grid-column:2;grid-row:1;margin:0;width:28px;min-width:28px;height:28px;min-height:28px;padding:0!important;box-sizing:border-box;display:flex;align-items:center;justify-content:center}
body #libraryCharacterDetails .library-combat-reference .md-section-head .md-role-filters{grid-column:1/-1;grid-row:2;display:flex;flex-wrap:nowrap;justify-content:flex-start;align-items:center;gap:4px;margin:0;min-width:0;max-width:100%;overflow-x:auto;overflow-y:hidden;scrollbar-width:thin}
body #libraryCharacterDetails .library-combat-reference .md-role-filters button{flex:0 0 26px;width:26px!important;min-width:26px!important;max-width:26px;height:26px!important;min-height:26px!important;padding:0!important;box-sizing:border-box;display:flex;align-items:center;justify-content:center;line-height:1;transform:none}
body #libraryCharacterDetails .library-combat-reference .md-role-filters button svg{display:block;flex:none;width:15px!important;height:15px!important;margin:0;overflow:visible}
/* Compact one-row profile headers: filters scroll instead of shrinking. */
body #libraryCharacterDetails .library-combat-reference .monster-dashboard>section:not(.md-defenses)>.md-section-head{display:grid;grid-template-columns:auto minmax(0,1fr);grid-template-rows:28px;gap:6px;min-height:36px;height:36px;padding:0 0 7px;align-items:center}
body #libraryCharacterDetails .library-combat-reference .md-section-head>h4{grid-column:1;grid-row:1;white-space:nowrap}
body #libraryCharacterDetails .library-combat-reference .md-section-head>div{grid-column:2;grid-row:1;display:flex;align-items:center;justify-content:flex-end;gap:5px;min-width:0;margin:0}
body #libraryCharacterDetails .library-combat-reference .md-section-head>div>button{flex:0 0 28px;width:28px;min-width:28px;height:28px;margin:0}
body #libraryCharacterDetails .library-combat-reference .md-section-head .md-role-filters{flex:0 1 auto;min-width:0;max-width:100%;gap:3px;height:28px;overflow-x:auto;overflow-y:hidden;scrollbar-width:none;scroll-behavior:smooth}
body #libraryCharacterDetails .library-combat-reference .md-role-filters::-webkit-scrollbar{display:none}
body #libraryCharacterDetails .library-combat-reference .md-role-filters button{flex:0 0 26px}
body #libraryCharacterDetails .library-basic-combat-row{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1fr);gap:12px;flex:none;align-items:start}
body #libraryCharacterDetails .library-basic-combat-traits{min-width:0;border:1px solid var(--ui-line);border-radius:6px;padding:7px 9px}
body #libraryCharacterDetails .library-basic-combat-heading{display:flex;align-items:center;justify-content:space-between;gap:8px;margin-bottom:4px}
body #libraryCharacterDetails .library-basic-combat-heading h4{margin:0;font-size:12px}
body #libraryCharacterDetails .library-basic-combat-heading .character-reference-actions{min-width:112px}
body #libraryCharacterDetails .library-basic-combat-traits .combat-facts{display:flex;flex-wrap:wrap;justify-content:flex-start;gap:6px 18px}
body #libraryCharacterDetails .library-basic-combat-traits .character-reference-field{flex:0 1 auto;min-width:55px;max-width:150px}
body #libraryCharacterDetails .library-basic-combat-traits .character-reference-field input{height:28px;min-height:28px;padding:2px 0;width:100%}
body #libraryCharacterDetails .library-basic-combat-row>.md-defenses{min-width:0;border:1px solid var(--ui-line);border-radius:6px;padding:7px 9px;background:transparent;display:flex;align-items:flex-start;gap:8px}
body #libraryCharacterDetails .library-basic-combat-row .md-defenses>.md-section-head{order:2;margin:0;padding:0;border:0;flex:none}
body #libraryCharacterDetails .library-basic-combat-row .md-defenses>.md-section-head h4{display:none}
body #libraryCharacterDetails .library-basic-combat-row .md-defense-grid{flex:1;display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:8px;margin:0}
body #libraryCharacterDetails .library-basic-combat-row .md-defense-grid>div{background:transparent;border:0;padding:0;gap:3px;min-width:0;display:flex;flex-direction:column}
body #libraryCharacterDetails .library-basic-combat-row .md-defense-grid b{font-size:11px;line-height:1.4;color:var(--ui-muted);font-weight:400;text-transform:none}
body #libraryCharacterDetails .library-combat-reference .monster-dashboard{grid-template-rows:minmax(0,1fr)}
body #libraryCharacterDetails .library-basic-combat-row .md-description{display:none}
body #libraryCharacterDetails .library-basic-combat-row .md-defenses>.md-section-head{display:flex!important;position:static!important;align-items:center;min-height:28px}
body #libraryCharacterDetails .library-basic-combat-traits .combat-facts{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:8px;align-items:start}
body #libraryCharacterDetails .library-basic-combat-traits .character-reference-field{min-width:0;max-width:none}
body #libraryCharacterDetails .library-basic-combat-traits .character-reference-field>span{font-size:11px;white-space:nowrap}
body #libraryCharacterDetails .library-basic-combat-row .md-defense-grid>div,body #libraryCharacterDetails .library-basic-combat-row .md-defense-grid :is(b,span){text-align:left;align-items:flex-start}
/* Give the compact Library defense summary a little more breathing room. */
body #libraryCharacterDetails .library-basic-combat-row>.md-defenses{min-height:76px;box-sizing:border-box;padding:11px 10px}
body #libraryCharacterDetails .library-basic-combat-row .md-defense-grid>div{gap:6px}
/* Defense assignment spans the full editor rather than one form-grid column. */
body #monsterEntryEditor[data-editor-group=defenses]{width:min(780px,94vw);max-height:90dvh;overflow:auto;padding:16px 20px}
body #monsterEntryEditor[data-editor-group=defenses] .sheet-fields{display:flex;flex-direction:column;gap:12px}
body #monsterEntryEditor[data-editor-group=defenses] .defense-assignment-ui{width:100%;grid-column:1/-1;box-sizing:border-box}
body #monsterEntryEditor[data-editor-group=defenses] .defense-drag-hint{grid-column:1/-1;margin:0;font-size:12px;line-height:1.5}
body #monsterEntryEditor[data-editor-group=defenses] .defense-drop-zone h4{white-space:normal;overflow-wrap:normal}
body #monsterEntryEditor[data-editor-group=defenses] .monster-defense-custom{margin-top:10px;gap:5px;font-size:11px}
body #monsterEntryEditor[data-editor-group=defenses] .monster-defense-custom input{width:100%;max-width:none;box-sizing:border-box}
body #monsterEntryEditor[data-editor-group=defenses] [name=defenses]{height:66px;min-height:66px;max-height:150px;width:100%;box-sizing:border-box}
body #monsterEntryEditor[data-editor-group=defenses] .md-editor-form>.md-buttons{position:sticky;bottom:-16px;z-index:3;padding:12px 0;margin:8px 0 0;background:var(--ui-surface);border-top:1px solid var(--ui-line);justify-content:flex-end}
body #monsterEntryEditor[data-editor-group=defenses] [hidden]{display:none!important}
body #monsterEntryEditor[data-editor-group=defenses] .sheet-fields>label.sheet-wide{width:100%;max-width:none;align-self:stretch;display:flex;flex-direction:column;align-items:stretch;gap:5px;box-sizing:border-box}
/* Both halves share the same row height, including wrapped defense badges. */
body #libraryCharacterDetails .library-basic-combat-row{align-items:stretch}
body #libraryCharacterDetails .library-basic-combat-row>.library-basic-combat-traits,body #libraryCharacterDetails .library-basic-combat-row>.md-defenses{height:auto;min-height:76px;box-sizing:border-box;align-self:stretch}
body>header>.campaign-header-row{display:grid;grid-template-columns:auto minmax(150px,1fr) auto;align-items:center;gap:12px}
body #campaignContext{display:flex;align-items:center;justify-content:center;gap:6px;min-width:0}
body .campaign-context-menu{position:relative;min-width:0;max-width:160px}
body .campaign-context-menu>summary{display:flex;align-items:center;gap:6px;cursor:pointer;list-style:none;padding:5px 7px;border:1px solid transparent;border-radius:6px;color:var(--ui-text);font-size:13px;line-height:1.4;min-height:30px;box-sizing:border-box}
body .campaign-context-menu>summary>span:first-child{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;min-width:0}
body .campaign-context-menu>summary::-webkit-details-marker{display:none}
body .campaign-context-menu>summary:hover,body .campaign-context-menu[open]>summary{background:var(--ui-input);border-color:var(--ui-line)}
body .campaign-context-menu>summary:focus-visible{outline:2px solid var(--ui-reference);outline-offset:1px}
body .session-context-menu>summary{border-color:var(--ui-line);background:var(--ui-input);font-size:12px}
body .campaign-context-popover{position:absolute;top:calc(100% + 7px);left:0;z-index:60;width:230px;max-height:65dvh;overflow:auto;background:var(--ui-surface);border:1px solid var(--ui-line);border-radius:8px;padding:7px;box-shadow:0 8px 24px #0008}
body .campaign-context-popover button{display:block;text-align:left;width:100%;padding:6px 8px;border:1px solid transparent;background:transparent;white-space:normal}
body .campaign-context-popover button[aria-pressed=true]{border-color:var(--ui-reference);background:var(--ui-reference-fill)}
body .campaign-menu-label{padding:4px 8px;font-size:11px;color:var(--ui-muted)}
body .campaign-context-popover hr{border:0;border-top:1px solid var(--ui-line);margin:6px 0}
body #storyChapterTabs[hidden]{display:none!important}
body .campaign-header-row #musicPlayer{width:clamp(400px,30vw,560px)}
@media(max-width:1450px){body #campaignContext{flex-direction:column;gap:1px}body .campaign-context-menu{max-width:160px}body .campaign-context-menu>summary{min-height:24px;padding:2px 6px}}
@media(max-width:1100px){body>header>.campaign-header-row{grid-template-columns:auto minmax(150px,1fr)}body .campaign-header-row>div:last-child{grid-column:1/-1;justify-content:flex-end}}
/* Campaign names deserve a prominent, wider place in the header. */
body>header>.campaign-header-row{grid-template-columns:auto minmax(240px,1fr) auto;gap:12px}
body #campaignContext{justify-content:flex-start;gap:10px}
body #campaignContext>.campaign-context-menu:not(.session-context-menu){flex:1;max-width:360px;min-width:0}
body #campaignContext>.campaign-context-menu:not(.session-context-menu)>summary{font-size:17px;font-weight:700;min-height:34px;padding:4px 7px}
body #campaignContext>.session-context-menu{flex:none;max-width:150px}
body .campaign-header-row #musicPlayer{width:clamp(380px,27vw,480px)}
@media(max-width:1450px){body #campaignContext{flex-direction:column;align-items:flex-start;gap:1px}body #campaignContext>.campaign-context-menu:not(.session-context-menu){width:100%;max-width:360px;flex:none}body #campaignContext>.campaign-context-menu:not(.session-context-menu)>summary{font-size:16px;min-height:25px;padding:1px 6px}body #campaignContext>.session-context-menu>summary{min-height:23px}}
@media(max-width:1100px){body>header>.campaign-header-row{grid-template-columns:auto minmax(240px,1fr)}}
/* Campaign and session remain side by side, centered in the header's middle space. */
body #campaignContext{flex-direction:row;align-items:center;justify-content:center;gap:10px}
body #campaignContext>.campaign-context-menu:not(.session-context-menu){flex:0 1 auto;width:auto;max-width:360px;min-width:0}
body #campaignContext>.campaign-context-menu:not(.session-context-menu)>summary{font-size:17px;min-height:34px;padding:4px 7px}
body #campaignContext>.session-context-menu{flex:0 0 auto}
@media(max-width:1450px){body>header>.campaign-header-row{grid-template-columns:auto minmax(280px,1fr) auto}body .campaign-header-row #musicPlayer{width:380px}body #campaignContext{flex-direction:row;align-items:center;justify-content:center;gap:6px}body #campaignContext>.campaign-context-menu:not(.session-context-menu){flex:0 1 auto;width:auto;max-width:360px}body #campaignContext>.campaign-context-menu:not(.session-context-menu)>summary{font-size:16px;min-height:32px;padding:3px 6px}body #campaignContext>.session-context-menu>summary{min-height:28px}}
@media(max-width:1100px){body>header>.campaign-header-row{grid-template-columns:auto minmax(280px,1fr)}}
/* Shared library controls for online and local music. */
.music-source-badge{display:inline-flex;margin:6px 0;padding:3px 7px;border:1px solid #526c83;border-radius:5px;color:#bfcede;font-size:11px;align-self:flex-start}
#youtubeMusicDialog{width:min(560px,90vw)}
#youtubeMusicDialog form>label{display:grid;gap:7px;margin:14px 0}
#youtubeMusicDialog input{width:100%;box-sizing:border-box}
.youtube-form-tags{display:grid;grid-template-columns:1fr 1fr;gap:14px}.youtube-form-tags label{display:grid;gap:7px}
#youtubeMusicDialog [data-error]{color:#ffb5b5;min-height:18px}
#youtubeMusicPanel{position:fixed;right:18px;top:76px;width:400px;max-width:calc(100vw - 24px);padding:10px;z-index:90;background:#122032;border:1px solid #607e99;border-radius:9px;box-shadow:0 10px 28px #0009}
#youtubeMusicPanel[hidden]{display:none}.youtube-panel-heading{display:flex;align-items:center;justify-content:space-between;gap:12px;margin-bottom:8px;cursor:move;touch-action:none}.youtube-panel-heading strong{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.youtube-panel-heading button{flex-shrink:0}#youtubeMusicPanel iframe{width:100%;height:225px;border:0}#youtubeMusicPanel p{font-size:12px;margin:8px 0;color:#bfd0e3}#youtubeMusicPanel a{font-size:12px;color:#8adfff}
/* Music is a dense list with one dedicated editing dialog. */
body #libraryMusicPane:not([hidden]){display:flex;flex-direction:column;height:calc(100dvh - 130px);min-height:380px;box-sizing:border-box;overflow:hidden}
body #libraryMusicPane>h2{margin:0 0 10px}body #libraryMusicPane>.session-row{flex-shrink:0;margin:5px 0 10px}
body #musicTracks.music-list{display:block;flex:1;min-height:0;overflow:auto;border:1px solid var(--ui-line);border-radius:8px;background:#101d2d}
.music-list-heading,body #musicTracks .music-list-row{display:grid;grid-template-columns:minmax(180px,1fr) 85px 120px 115px 90px;gap:14px;align-items:center}
.music-list-heading{position:sticky;top:0;z-index:2;background:#1c2d42;color:#b9cce0;padding:10px 14px;border-bottom:1px solid #506680;font-size:12px;font-weight:600}
body #musicTracks .music-list-row{min-height:47px;padding:6px 14px;margin:0;border:0;border-bottom:1px solid #304459;border-radius:0;box-sizing:border-box;background:transparent}
body #musicTracks .music-list-row:last-child{border-bottom:0}body #musicTracks .music-list-row:hover{background:#1a2b3f}body #musicTracks .music-current{background:#203d36;border-left:3px solid #99d5b9;padding-left:11px}
body #musicTracks .music-track-name{min-width:0}body #musicTracks strong{font-size:13px;margin:0;white-space:nowrap;text-overflow:ellipsis;overflow:hidden;display:block;font-weight:600}
.music-list-source{color:#a8bfd3;font-size:12px}.music-list-tag{width:max-content;max-width:100%;font-size:12px;padding:3px 7px;border:1px solid #49657b;border-radius:5px;color:#c8dfef;box-sizing:border-box}.music-list-tag[data-type=Combat]{border-color:#9a804d;color:#eed299}.music-list-tag[data-type=Exploration]{border-color:#477f90;color:#99d8e2}.music-list-tag[data-type=Travel]{border-color:#658599;color:#c2d3ea}
.music-list-actions{display:flex;align-items:center;justify-content:flex-end;gap:6px}.music-list-actions button{padding:4px 8px;min-height:28px}.music-list-actions .ui-icon-action{width:28px;min-width:28px!important;height:28px}.music-playing-marker{font-size:11px;color:#9bdabb}.music-list-empty{padding:16px}
#musicTrackEditor{width:min(540px,90vw)}#musicTrackEditor form>label{display:grid;gap:7px;margin:16px 0}#musicTrackEditor input{width:100%;box-sizing:border-box}.music-editor-labels{display:grid;grid-template-columns:1fr 1fr;gap:14px}.music-editor-labels label{display:grid;gap:7px}.music-editor-management{padding-top:12px;border-top:1px solid var(--ui-line)}.music-editor-footer{justify-content:flex-end}#musicTrackEditor [data-error]{color:#ffb5b5}
@media(max-width:800px){.music-list-heading,body #musicTracks .music-list-row{grid-template-columns:minmax(120px,1fr) 60px 90px 85px 82px;gap:6px}body #libraryMusicPane:not([hidden]){height:auto;min-height:0}body #musicTracks.music-list{max-height:65dvh}}
/* Track transport stays beside the name, with an HP-style filled time rail. */
.music-list-heading,body #musicTracks .music-list-row{grid-template-columns:minmax(320px,1fr) 65px 110px 110px 36px}
body #musicTracks .music-track-name{display:flex;align-items:center;gap:12px}body #musicTracks .music-track-name>strong{flex:1;min-width:90px}.music-row-play{display:inline-flex;align-items:center;justify-content:center;width:28px;height:28px;padding:3px!important;flex-shrink:0}
.music-track-progress{display:flex;align-items:center;gap:8px;flex:0 0 190px}.music-time{font-size:11px;color:#bdd0e2;font-variant-numeric:tabular-nums;white-space:nowrap;min-width:66px}.music-track-progress input[type=range]{appearance:none;-webkit-appearance:none;width:112px;height:9px;border:1px solid #3f6174;border-radius:5px;padding:0;background:linear-gradient(to right,#63cda8 0 var(--music-progress,0%),#0b1422 var(--music-progress,0%) 100%);cursor:pointer;margin:0}.music-track-progress input[type=range]::-webkit-slider-thumb{appearance:none;-webkit-appearance:none;width:7px;height:13px;border-radius:3px;background:#b1f2d7}.music-track-progress input[type=range]::-moz-range-thumb{width:7px;height:13px;border:0;border-radius:3px;background:#b1f2d7}.music-track-progress input[type=range]:disabled{cursor:default;opacity:.7}.music-track-progress input[type=range]:disabled::-webkit-slider-thumb{background:transparent}
#storyMediaDialog:has(.scene-music-browser){width:min(780px,94vw);max-height:90dvh}#storyMediaFields:has(.scene-music-browser){display:block}.scene-music-slots{display:flex;gap:8px;margin:12px 0}.scene-music-current{padding:9px 12px;border:1px solid #4c6b83;background:#0b1829;border-radius:6px;font-size:13px}.scene-music-search{display:grid;grid-template-columns:minmax(160px,1fr) 130px 130px;align-items:end;gap:10px;margin:12px 0}.scene-music-search label{display:grid;gap:5px}.scene-music-search input{width:100%;box-sizing:border-box}.scene-music-modes{display:flex;align-items:center;gap:8px;margin-bottom:10px}.scene-music-modes [data-count]{margin-left:auto;font-size:12px;color:#abc3d8}.scene-music-results{max-height:32dvh;overflow:auto;border:1px solid #405971;border-radius:7px}.scene-music-choice{width:100%;display:grid;grid-template-columns:18px minmax(130px,1fr) auto;align-items:center;text-align:left;gap:8px;padding:10px 12px;border:0;border-bottom:1px solid #30485f;border-radius:0;background:#101d2d}.scene-music-choice strong{font-size:13px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.scene-music-choice>span:last-child{font-size:11px;color:#b7ccdf}.scene-music-choice:hover{background:#20344b}.scene-music-browser button[aria-pressed=true]{background:#20483c;border-color:#8bcfaf;color:#dbf4e9}.scene-music-results>p{padding:12px}.scene-music-slots:has(button:only-child){display:none}
@media(max-width:800px){.music-list-heading,body #musicTracks .music-list-row{grid-template-columns:minmax(260px,1fr) 50px 95px 95px 30px;gap:6px}.music-track-progress{flex-basis:140px}.music-track-progress input[type=range]{width:65px}.scene-music-search{grid-template-columns:1fr 1fr}.scene-music-search>input{grid-column:1/-1}.scene-music-choice{grid-template-columns:18px minmax(100px,1fr)}.scene-music-choice>span:last-child{grid-column:2}}
.music-title-heading{display:flex;align-items:center;justify-content:space-between;gap:12px;min-width:0}.music-duration-heading{flex:0 0 190px}.music-title-heading [data-music-name-sort]{display:inline-flex;align-items:center;gap:7px;background:transparent;border:0;border-radius:4px;padding:2px 3px;min-height:24px;color:#c4daeb;font-weight:600;font-size:12px}.music-title-heading [data-music-name-sort]:hover{background:#2c435b}.music-sort-arrows{display:inline-flex;flex-direction:column;gap:2px}.music-sort-arrows svg{fill:none;stroke:#7b91a6;stroke-width:1.6;stroke-linecap:round;stroke-linejoin:round}[data-sort-state=az] [data-arrow=up],[data-sort-state=za] [data-arrow=down]{stroke:#9df0cd;stroke-width:2.3}
@media(max-width:800px){.music-duration-heading{flex-basis:140px}}
body #musicTracks .music-favorite{display:inline-flex;align-items:center;justify-content:center;width:27px;height:28px;min-width:27px;padding:3px;flex-shrink:0;border-color:transparent;background:transparent}.music-favorite svg{fill:none;stroke:#a9bfd3;stroke-width:1.6;stroke-linejoin:round}.music-favorite[aria-pressed=true] svg{fill:#efc75a;stroke:#f3d67e}.music-favorite:hover{background:#273a4d!important}.music-favorites-filter{display:inline-flex!important;flex-direction:row!important;align-items:center;gap:6px!important;white-space:nowrap;min-height:30px}.music-favorites-filter input[type=checkbox]{width:14px;height:14px;padding:0;margin:0;accent-color:#efc75a}
body #viewMusic:not(.hidden):not([hidden]):has(#libraryMedia:not([hidden]) #libraryMusicPane:not([hidden])){display:flex;flex-direction:column;height:calc(100dvh - var(--music-view-top,85px) - 10px);min-height:0;overflow:hidden;box-sizing:border-box;margin-bottom:0;padding:12px}
body #viewMusic:not(.hidden):not([hidden]):has(#libraryMedia:not([hidden]) #libraryMusicPane:not([hidden])) #libraryMedia,body #viewMusic:not(.hidden):not([hidden]):has(#libraryMedia:not([hidden]) #libraryMusicPane:not([hidden])) #libraryMediaContent{display:flex;flex-direction:column;flex:1;min-height:0;overflow:hidden}
body #viewMusic #libraryMedia:not([hidden]) #libraryMusicPane:not([hidden]){height:auto;min-height:0;flex:1;overflow:hidden}
body #libraryMusicPane>h2{margin:0 0 4px}body #libraryMusicPane>.session-row:not(.library-import-row){margin:0 0 8px;padding-bottom:8px;gap:9px}body #libraryMusicPane .library-import-row{margin:0 0 8px;gap:9px}body #libraryMusicPane>.session-row label{gap:3px}body #libraryMusicPane .library-sort-control[hidden]{display:none!important}body #musicTracks.music-list{max-height:none}
.music-source-tags{display:block;max-width:85px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:11px;color:#a8d7bd;line-height:16px}body #libraryMusicPane #musicTagFilter{min-width:115px;max-width:150px}.scene-music-search{grid-template-columns:minmax(140px,1fr) repeat(3,minmax(100px,125px))}.global-music-filters{grid-template-columns:repeat(4,minmax(0,1fr))}#musicTrackEditor label>span{font-size:12px;color:#a8bfd3}
@media(max-width:800px){.scene-music-search{grid-template-columns:1fr 1fr}}

.music-list-source{min-width:0}.music-source-tags{max-width:100%}
/* Scene music picker: bounded dialog, fixed controls, scrollable flat track list. */
body #storyMediaDialog:has(.scene-music-browser){width:min(860px,calc(100vw - 32px));height:min(720px,calc(100dvh - 40px));max-height:calc(100dvh - 40px);box-sizing:border-box;overflow:hidden;padding:20px}
body #storyMediaForm:has(.scene-music-browser){display:flex;flex-direction:column;height:100%;min-height:0;gap:12px;overflow:hidden}
body #storyMediaForm:has(.scene-music-browser)>.story-dialog-heading{flex:none;margin:0;padding-bottom:12px}
body #storyMediaForm:has(.scene-music-browser)>p{flex:none;margin:0;font-size:13px;line-height:1.5}
body #storyMediaFields:has(.scene-music-browser){display:flex;flex:1;min-height:0;min-width:0;overflow:hidden}
body #storyMediaFields>.scene-music-browser{display:flex;flex-direction:column;flex:1;min-height:0;min-width:0;gap:10px}
body .scene-music-slots{flex:none;margin:0}
body .scene-music-current{flex:none;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
body .scene-music-search{flex:none;margin:0;grid-template-columns:minmax(0,2fr) repeat(3,minmax(0,1fr));gap:10px;align-items:end}
body .scene-music-search>*{min-width:0;max-width:100%;grid-column:auto}
body .scene-music-search label{margin:0;font-size:12px}
body .scene-music-search input,body .scene-music-search select{width:100%;min-width:0;max-width:100%;box-sizing:border-box;height:36px;margin:0}
body .scene-music-modes{flex:none;flex-wrap:wrap;margin:0;gap:8px}
body .scene-music-results{flex:1;min-height:80px;max-height:none;overflow:auto;overscroll-behavior:contain}
body #storyMediaDialog .scene-music-results .scene-music-choice{display:grid;grid-template-columns:18px minmax(0,1fr) auto;width:100%;min-width:0;max-width:100%;box-sizing:border-box;margin:0;border:0;border-bottom:1px solid var(--ui-line,#30485f);border-radius:0;background:var(--ui-surface,#101d2d);padding:10px 12px;gap:8px;text-align:left}
body #storyMediaDialog .scene-music-choice:hover{background:#20344b}
body #storyMediaDialog .scene-music-browser button[aria-pressed=true]{background:#20483c;color:#dbf4e9;box-shadow:inset 3px 0 #8bcfaf}
body #storyMediaDialog .scene-music-choice>span:last-child{grid-column:auto;white-space:nowrap;font-size:12px}
body #storyMediaForm:has(.scene-music-browser)>.story-media-imports{flex:none;display:flex;align-items:center;margin:0}
body #storyMediaForm:has(.scene-music-browser)>.story-empty{display:none}
body #storyMediaForm:has(.scene-music-browser)>footer{flex:none;margin:0;padding-top:12px;border-top:1px solid var(--ui-line,#405971)}
@media(max-width:650px){body .scene-music-search{grid-template-columns:repeat(3,minmax(0,1fr))}body .scene-music-search>input{grid-column:1/-1}body #storyMediaDialog .scene-music-results .scene-music-choice{grid-template-columns:18px minmax(0,1fr)}body #storyMediaDialog .scene-music-choice>span:last-child{grid-column:2;white-space:normal}body #storyMediaDialog:has(.scene-music-browser){padding:14px}}
body #sceneMusicSettings .scene-assigned-track{font-size:13px;min-width:0;max-width:240px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;padding-left:7px;border-left:1px solid var(--ui-line,#40566b)}
body #sceneMusicSettings>button{flex:none}
body #storyMediaDialog .scene-music-result-row{display:flex;align-items:center;border-bottom:1px solid var(--ui-line,#30485f);padding-right:8px}
body #storyMediaDialog .scene-music-result-row .scene-music-choice{flex:1;min-width:0;border-bottom:0}
body #storyMediaDialog .scene-music-preview{flex:0 0 30px;width:30px;height:30px;padding:5px;margin:0 0 0 6px;display:grid;place-items:center}
body .scene-music-current{display:flex;align-items:center;gap:8px}
body .scene-music-current>span{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
body .scene-music-current>button{flex:none;width:30px;height:30px;min-height:30px;padding:4px;display:grid;place-items:center}
/* Clearer track hierarchy, with collection tags visible without extra badge clutter. */
body #storyMediaDialog .scene-music-results .scene-music-choice{padding:11px 12px;gap:10px}
body #storyMediaDialog .scene-music-choice strong{font-weight:600;font-size:13px}
body #storyMediaDialog .scene-music-choice>.scene-track-meta{display:flex;flex-direction:column;align-items:flex-end;gap:3px;max-width:240px;min-width:0;line-height:1.35;color:#b7ccdf;font-weight:400}
body #storyMediaDialog .scene-track-tags{max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:#a8d7bd;font-size:12px}
body #storyMediaDialog .scene-music-result-row{padding-right:12px}
body #storyMediaDialog .scene-music-preview{margin-left:10px;background:transparent;border-color:#405971}
body #storyMediaDialog .scene-music-browser .scene-music-choice[aria-pressed=true]{background:#20483c!important;color:#dbf4e9!important;box-shadow:inset 3px 0 #8bcfaf}
body .scene-music-modes{padding:2px 0 4px}
@media(max-width:650px){body #storyMediaDialog .scene-music-choice>.scene-track-meta{align-items:flex-start;max-width:100%;flex-direction:row;flex-wrap:wrap;gap:4px 10px}}
/* Match the library's left-hand playback controls and aligned metadata columns. */
body #storyMediaDialog .scene-music-results{--scene-type-width:90px;--scene-emotion-width:90px;--scene-tag-width:150px}
body #storyMediaDialog .scene-music-result-row{display:grid;grid-template-columns:30px minmax(0,1fr);gap:6px;padding:0 10px}
body #storyMediaDialog .scene-music-result-row .scene-music-preview{margin:0;width:30px}
body #storyMediaDialog .scene-music-results .scene-music-choice{grid-template-columns:16px minmax(0,1fr) var(--scene-type-width) var(--scene-emotion-width) var(--scene-tag-width);gap:8px;padding:11px 0}
body #storyMediaDialog .scene-music-choice>span{min-width:0;text-align:left;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;font-size:12px;font-weight:400;color:#b7ccdf;grid-column:auto}
body #storyMediaDialog .scene-music-choice>.scene-track-tags{color:#a8d7bd}
body #storyMediaDialog .scene-music-choice>.scene-music-check{color:#dbf4e9;font-size:15px}
body #storyMediaDialog .scene-music-list-heading{display:grid;grid-template-columns:30px minmax(0,1fr) var(--scene-type-width) var(--scene-emotion-width) var(--scene-tag-width);gap:8px;align-items:center;padding:10px;position:sticky;top:0;z-index:1;background:#1b2d40;border-bottom:1px solid var(--ui-line,#405971);font-size:12px;font-weight:600;color:#c5d9ec}
body #storyMediaDialog .scene-music-list-heading>span:nth-child(2){padding-left:22px}
@media(max-width:650px){body #storyMediaDialog .scene-music-results{--scene-type-width:80px;--scene-emotion-width:80px;--scene-tag-width:120px}body #storyMediaDialog .scene-music-result-row,body #storyMediaDialog .scene-music-list-heading{min-width:560px;box-sizing:border-box}}
body .scene-music-current{gap:6px}
body .scene-music-current>span{font-size:13px;padding:0 4px}
body .scene-preview-progress{flex:0 1 190px;min-width:120px;display:flex;align-items:center;gap:7px}
body .scene-preview-progress input{width:85px;min-width:40px;height:8px;padding:0;margin:0;appearance:none;background:linear-gradient(to right,#4ca889 var(--music-progress,0%),#0b1829 var(--music-progress,0%));border:1px solid #405971;border-radius:5px}
body .scene-preview-progress input::-webkit-slider-thumb{appearance:none;width:8px;height:12px;background:#b7dfd0;border-radius:3px}
body .scene-preview-progress>span{white-space:nowrap;font-size:12px;color:#c5d9ec}
@media(max-width:650px){body .scene-music-current{flex-wrap:wrap}body .scene-music-current>span{flex:1 1 180px}body .scene-preview-progress{flex:1 1 200px}}
body .scene-title-player{display:flex;align-items:center;gap:6px;min-width:0;padding:5px 7px;border:1px solid #405971;border-radius:7px;background:#0b1829}
body #sceneMusicSettings .scene-title-player>button{flex:none;height:28px;width:30px;padding:4px;display:grid;place-items:center}
body #sceneMusicSettings .scene-title-player .scene-assigned-track{border:0;padding:0 5px;flex:1 1 160px;max-width:230px;font-size:12px}
body .scene-title-player .scene-preview-progress{flex:0 1 160px;min-width:120px}
body #sceneMusicSettings{min-width:0;flex-wrap:wrap}
@media(max-width:1100px){body .scene-title-player{flex-wrap:wrap}body .scene-title-player .scene-preview-progress{flex:1 1 140px}}
body .campaign-header-row #musicPlayer{width:clamp(540px,39vw,690px)}
body header #musicPlayer .music-player-inner{display:flex;align-items:center;gap:5px;flex-wrap:nowrap}
body header #musicPlayer .music-player-inner>button{flex:none;min-height:28px;padding:4px 6px}
body header #musicPlayer #nowPlaying{min-width:70px;flex:1 1 160px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
body header #musicPlayer .global-music-progress{min-width:100px;flex:0 1 150px}
body header #musicPlayer .music-controls{flex:none;gap:6px}
body header #musicPlayer .music-controls label{display:flex;align-items:center;gap:3px}
body header #musicPlayer .music-controls input[type=range]{width:45px}
@media(max-width:1100px){body .campaign-header-row #musicPlayer{width:min(100%,590px)}body header #musicPlayer .music-player-inner{flex-wrap:wrap}body header #musicPlayer .music-controls label{display:flex}}
body header #musicPlayer .music-player-inner{flex-wrap:wrap;min-width:0}
body header #musicPlayer .music-controls{min-width:0}
body .campaign-header-row #musicPlayer{width:clamp(600px,40vw,730px);max-width:100%}
@media(max-width:1100px){body .campaign-header-row #musicPlayer{width:min(100%,600px)}}
@media(min-width:1101px){body header #musicPlayer .music-player-inner{flex-wrap:nowrap;gap:4px}body header #musicPlayer .global-music-progress{flex:0 0 120px;min-width:0}body header #musicPlayer .global-music-progress input{width:45px;min-width:30px}body header #musicPlayer .music-controls{flex:0 0 130px;gap:4px}body header #musicPlayer .music-controls input[type=range]{width:40px}body header #musicPlayer #nowPlaying{flex:1 1 80px;min-width:50px}body header #musicPlayer .music-player-inner>button:not(#browseMusic){width:26px;padding:3px}body header #musicPlayer .music-player-inner>button svg{width:16px;height:16px}}
/* Reserve the full width of Volume and Loop; never clip their labels/icons. */
body header #musicPlayer .music-controls{flex:0 0 auto;width:auto;min-width:max-content;flex-wrap:nowrap;gap:8px}
body header #musicPlayer .music-controls label{flex:none;white-space:nowrap;margin:0}
body header #musicPlayer .music-controls input{flex:none}
body header #musicPlayer .music-player-inner{flex-wrap:wrap;align-items:center}
body header #musicPlayer{padding-right:10px}
/* Songs popup has fixed browsing controls and one scrolling list. */
body #globalMusicPicker{width:min(820px,calc(100vw - 32px));height:min(680px,calc(100dvh - 40px));max-height:calc(100dvh - 40px);box-sizing:border-box;overflow:hidden;padding:20px}
body #globalMusicPicker[open]{display:flex;flex-direction:column;gap:12px}
body #globalMusicPicker>.story-dialog-heading{flex:none;margin:0;padding-bottom:12px}
body #globalMusicPicker .global-music-filters{flex:none;grid-template-columns:repeat(4,minmax(0,1fr));margin:0;gap:10px}
body #globalMusicPicker .global-music-filters>*{min-width:0;margin:0}
body #globalMusicPicker .global-music-filters input,body #globalMusicPicker .global-music-filters select{min-width:0;width:100%;margin:0}
body #globalMusicPicker .global-music-summary{display:flex;align-items:center;justify-content:space-between;flex:none;gap:12px;font-size:12px;color:#b7ccdf}
body #globalMusicPicker .music-favorites-filter{margin:0}
body #globalMusicResults{display:block;flex:1;min-height:0;overflow:auto;overscroll-behavior:contain;border:1px solid var(--ui-line);border-radius:7px;--global-type:95px;--global-emotion:90px;--global-tag:150px}
body #globalMusicResults .global-music-heading,body #globalMusicResults .global-music-track{display:grid;grid-template-columns:minmax(0,1fr) var(--global-type) var(--global-emotion) var(--global-tag);gap:10px;box-sizing:border-box;width:100%;align-items:center;padding:12px;font-size:12px}
body #globalMusicResults .global-music-heading{position:sticky;top:0;z-index:1;background:#1b2d40;color:#c5d9ec;font-weight:600;border-bottom:1px solid var(--ui-line)}
body #globalMusicResults .global-music-heading>span:first-child{padding-left:26px}
body #globalMusicResults .global-music-track{margin:0;border:0;border-bottom:1px solid var(--ui-line);border-radius:0;background:var(--ui-input);text-align:left}
body #globalMusicResults .global-music-track>span{grid-column:auto;grid-row:auto;min-width:0;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;color:#b7ccdf;font-size:12px;font-weight:400}
body #globalMusicResults .global-track-title{display:flex;align-items:center;gap:10px}
body #globalMusicResults .global-track-title svg{flex:none;color:#c5d9ec}
body #globalMusicResults .global-track-title strong{min-width:0;overflow:hidden;text-overflow:ellipsis;font-size:13px;font-weight:600;color:var(--ui-text)}
body #globalMusicResults .global-music-track>.global-track-tags{color:#a8d7bd}
body #globalMusicResults .global-music-track:hover{background:#20344b}
body #globalMusicResults .global-music-track[aria-pressed=true]{background:#20483c;box-shadow:inset 3px 0 #8bcfaf}
@media(max-width:650px){body #globalMusicPicker{padding:14px}body #globalMusicPicker .global-music-filters{grid-template-columns:repeat(2,minmax(0,1fr))}body #globalMusicResults{--global-type:80px;--global-emotion:80px;--global-tag:120px}body #globalMusicResults .global-music-heading,body #globalMusicResults .global-music-track{min-width:550px}}
body #sceneMusicSettings .scene-music-reminder{display:flex;flex-direction:column;gap:3px;min-width:0;padding-left:9px;border-left:1px solid var(--ui-line);max-width:380px}
body #sceneMusicSettings .scene-music-reminder .scene-assigned-track{border:0;padding:0;max-width:100%;font-size:13px;font-weight:600;line-height:1.3}
body .scene-assigned-info{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:12px;color:#b7ccdf;line-height:1.3}
body #sceneMusicSettings .scene-music-reminder{padding:7px 10px;border:1px solid #405971;border-radius:7px;background:#0b1829;max-width:380px}
body #sceneMusicSettings .scene-music-reminder{width:340px;max-width:100%;height:50px;flex:0 0 340px;box-sizing:border-box;justify-content:center;overflow:hidden}
body #sceneMusicSettings .scene-music-reminder>span{display:block;width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
@media(max-width:650px){body #sceneMusicSettings .scene-music-reminder{width:280px;flex-basis:280px}}
body #sceneMusicSettings .scene-music-reminder{flex-direction:row;align-items:center;gap:10px}
body .scene-reminder-text{flex:1;min-width:0;display:flex;flex-direction:column;gap:3px}
body .scene-reminder-text>span{width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
body #sceneMusicSettings [data-reminder-play]{flex:none;width:30px;height:30px;padding:5px;display:grid;place-items:center}
/* Stable scene-title region: wrapping text cannot displace the music section. */
body .story-selected-heading{display:grid;grid-template-columns:minmax(0,40%) minmax(0,1fr) auto;gap:14px;align-items:center;flex-wrap:nowrap}
body .story-selected-heading .story-selected-title{min-width:0;width:100%;box-sizing:border-box;padding-right:14px;border-right:1px solid var(--ui-line,#405971);align-self:stretch;display:flex;align-items:center}
body #storySceneHeading{white-space:normal;overflow:visible;text-overflow:clip;overflow-wrap:anywhere;word-break:normal;min-width:0;width:100%;margin:0;line-height:1.35}
body #storySelectedType{display:none!important}
body .story-selected-heading .scene-header-music{min-width:0;width:100%;max-width:100%}
body .story-selected-heading #sceneMusicSettings{width:100%;min-width:0;flex-wrap:nowrap}
body .story-selected-heading #sceneMusicSettings .scene-music-reminder{flex:1 1 340px;min-width:0;max-width:340px}
body .story-selected-heading .story-step-navigation{display:flex;gap:6px;min-width:0}
@media(max-width:1200px){body .story-selected-heading{grid-template-columns:minmax(0,40%) minmax(0,1fr)}body .story-selected-heading .story-step-navigation{grid-column:1/-1;justify-content:flex-end}}
@media(max-width:650px){body .story-selected-heading{grid-template-columns:minmax(0,40%) minmax(0,1fr);gap:8px}body .story-selected-heading #sceneMusicSettings{flex-wrap:wrap}body .story-selected-heading #sceneMusicSettings .scene-music-reminder{flex-basis:100%;width:100%}}

body #sceneMusicSettings .scene-victory-music{flex:none;white-space:nowrap}

body #storySceneDetails .scene-image-gallery{display:flex;gap:6px;overflow-x:auto;flex:none;max-width:100%;padding:3px}body #storySceneDetails .scene-image-gallery button{flex:0 0 64px;width:64px;padding:3px}body #storySceneDetails .scene-image-gallery img{width:56px;height:36px;object-fit:cover}body #storySceneDetails .scene-image-gallery span{display:block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:11px}body #storySceneDetails .scene-image-gallery button[aria-pressed="true"]{border-color:var(--ui-accent,#7dd3fc);box-shadow:0 0 0 1px #7dd3fc}

body .story-reader-empty>.story-selected-heading{display:none}
/* Shared scene Details: equal reading/media halves, independently scrolling bodies. */
body .story-reader #storyDocument:has(.story-context-row){display:grid;grid-template-columns:repeat(4,minmax(0,1fr));grid-template-rows:161px minmax(260px,1fr);gap:12px;align-content:stretch;overflow-y:auto}
body .story-reader #storyDocument>.story-context-row,body .story-reader #storyDocument>.story-context,body .story-reader #storyDocument #storySceneDetails{display:contents}
body #storyDocument .story-summary-field{display:flex;flex-direction:column;min-height:0;margin:0;padding:12px;border:1px solid var(--ui-line);border-radius:8px;background:var(--ui-surface)}
body #storyDocument .story-summary-field:has([data-scene-field="location"]){grid-column:1;grid-row:1}
body #storyDocument .story-summary-field:has([data-scene-field="objective"]){grid-column:2;grid-row:1}
body #storyDocument .story-summary-field:has([data-moment-context]){grid-column:1/3;grid-row:2}
body #storyDocument .story-summary-field>strong{flex:none;margin:0 0 8px;line-height:19px;color:var(--ui-text)}
body #storyDocument .story-summary-field textarea{flex:1;min-height:0;height:110px;resize:none;overflow:auto;margin:0;font-size:15px;line-height:1.65}
body #storyDocument .story-summary-field:has([data-moment-context]) textarea{height:100%;font-size:15px}
body #storySceneDetails>.scene-image-section{grid-column:3;grid-row:1;min-height:0;overflow:auto}
body #storySceneDetails>.scene-map-card{grid-column:4;grid-row:1;min-height:0;overflow:auto}
body #storySceneDetails>.scene-characters-card{grid-column:3/5;grid-row:2;min-height:0;max-height:none;overflow:auto}
body #storySceneDetails .scene-image-preview,body #storySceneDetails .scene-map-preview{min-height:55px}
body #storySceneDetails .scene-image-preview img,body #storySceneDetails .scene-map-preview img{min-height:55px}
body #storyDocument>.story-context>section,body #storyDocument>.story-context>aside{grid-column:1/3;min-width:0}
@media(max-width:850px){body .story-reader #storyDocument:has(.story-context-row){grid-template-columns:repeat(2,minmax(0,1fr));grid-template-rows:161px minmax(300px,1fr) 220px minmax(260px,1fr)}body #storySceneDetails>.scene-image-section{grid-column:1;grid-row:3}body #storySceneDetails>.scene-map-card{grid-column:2;grid-row:3}body #storySceneDetails>.scene-characters-card{grid-column:1/3;grid-row:4}}

/* Matching title accents for every shared scene Details card. */
body #storyDocument .story-context-row>.story-summary-field,body #storyDocument #storySceneDetails>.scene-image-section,body #storyDocument #storySceneDetails>.scene-map-card,body #storyDocument #storySceneDetails>.scene-characters-card{border-top:3px solid var(--ui-story);box-shadow:none}


body #storySceneDetails .scene-character-notes{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px;margin-top:10px}body #storySceneDetails .scene-character-notes label{display:flex;flex-direction:column;gap:6px;min-width:0;margin:0}body #storySceneDetails .scene-character-notes strong{font-size:13px;color:var(--ui-text)}body #storySceneDetails .scene-character-notes small{color:var(--ui-muted);font-size:12px;line-height:1.4}body #storySceneDetails .scene-character-notes textarea{width:100%;box-sizing:border-box;min-height:130px;height:150px;resize:vertical;font-size:14px;line-height:1.6;margin:0}@media(max-width:1000px){body #storySceneDetails .scene-character-notes{grid-template-columns:1fr}}


body #storySceneDetails .scene-character-notes{display:block;margin-top:6px}body #storySceneDetails .scene-character-notes textarea{min-height:44px;height:50px;resize:none;font-size:14px;padding:6px 8px}body #storySceneDetails .scene-npc{padding:8px;margin-bottom:6px}body #storySceneDetails .scene-npc>.scene-detail-heading{margin-bottom:0}body #storySceneDetails .scene-npc-actions [data-scene-action=open-bio]{width:auto!important;min-width:64px!important;padding:4px 8px!important;font-size:12px}


body #storyDocument #storySceneDetails>.scene-characters-card{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px;align-content:start}body #storySceneDetails>.scene-characters-card>.scene-detail-heading,body #storySceneDetails>.scene-characters-card>.scene-media-toolbar,body #storySceneDetails>.scene-characters-card>.story-empty{grid-column:1/-1;margin:0}body #storySceneDetails .scene-npc{min-width:0;margin:0}body #storySceneDetails .scene-npc-identity{min-width:0;flex-wrap:wrap}body #storySceneDetails .scene-npc-identity>strong{overflow-wrap:anywhere}@media(max-width:1000px){body #storyDocument #storySceneDetails>.scene-characters-card{grid-template-columns:1fr}}


/* Give scene artwork more vertical room while keeping the left facts compact. */
body .story-reader #storyDocument:has(.story-context-row){grid-template-rows:161px 119px minmax(260px,1fr)}body #storyDocument .story-summary-field:has([data-moment-context]){grid-row:2/4}body #storyDocument #storySceneDetails>.scene-image-section,body #storyDocument #storySceneDetails>.scene-map-card{grid-row:1/3}body #storyDocument #storySceneDetails>.scene-characters-card{grid-row:3}@media(max-width:850px){body .story-reader #storyDocument:has(.story-context-row){grid-template-rows:161px minmax(300px,1fr) 280px minmax(260px,1fr)}body #storyDocument .story-summary-field:has([data-moment-context]){grid-row:2}body #storyDocument #storySceneDetails>.scene-image-section,body #storyDocument #storySceneDetails>.scene-map-card{grid-row:3}body #storyDocument #storySceneDetails>.scene-characters-card{grid-row:4}}


/* Setting and Map share header, preview and caption placement. */
body #storySceneDetails :is(.scene-image-section,.scene-map-card)>.scene-media-heading{min-height:30px;height:auto;margin:0}body #storySceneDetails :is(.scene-image-preview,.scene-map-preview){flex:none;height:128px;min-height:128px;max-height:128px}body #storySceneDetails :is(.scene-image-preview,.scene-map-preview) img{height:100%;min-height:0;max-height:100%;object-fit:contain}body #storySceneDetails :is(.scene-image-section,.scene-map-card)>.scene-image-name{display:block;flex:none;margin:0;line-height:18px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}


/* Scene characters read as a single list, with stable identity and action columns. */
body #storyDocument #storySceneDetails>.scene-characters-card{display:flex;flex-direction:column;gap:8px;overflow-y:auto;align-content:normal}
body #storySceneDetails>.scene-characters-card>.scene-detail-heading{flex:none;min-height:22px}
body #storySceneDetails>.scene-characters-card>.scene-media-toolbar{flex:none;display:flex;flex-wrap:nowrap;gap:6px;margin:0 0 2px}
body #storySceneDetails>.scene-characters-card>.scene-media-toolbar label{flex:1;max-width:none;min-width:0}
body #storySceneDetails .scene-npc{flex:none;width:100%;box-sizing:border-box;padding:8px 10px;margin:0;border-radius:7px}
body #storySceneDetails .scene-npc>.scene-detail-heading{display:grid;grid-template-columns:minmax(0,1fr) auto;gap:10px;align-items:center}
body #storySceneDetails .scene-npc-identity{display:flex;gap:6px;align-items:center;min-width:0}
body #storySceneDetails .scene-npc-identity>strong{font-size:13px;line-height:1.4}
body #storySceneDetails .scene-npc-identity .story-tag{font-size:11px;line-height:1.4;white-space:nowrap}
body #storySceneDetails .scene-npc-actions{margin:0;align-self:start}
body #storySceneDetails .scene-character-notes{margin-top:6px}
body #storySceneDetails .scene-character-notes textarea{height:44px;min-height:44px;font-size:13px;line-height:1.5;padding:3px 7px;overflow-y:auto}

body #storySceneDetails .scene-image-carousel{display:flex;align-items:center;gap:5px;min-width:0;flex:none;width:100%}body #storySceneDetails .scene-image-carousel .scene-image-gallery{flex:1;min-width:0;overflow-x:hidden;scrollbar-width:none}body #storySceneDetails .scene-image-carousel .scene-image-gallery::-webkit-scrollbar{display:none}body #storySceneDetails .scene-gallery-arrow{flex:none;width:23px;min-width:23px;height:42px;padding:0;font-size:24px;line-height:1;border:1px solid var(--ui-line);border-radius:5px;background:var(--ui-raised);color:var(--ui-text)}body #storySceneDetails .scene-gallery-arrow:disabled{opacity:.35;cursor:default}body #storySceneDetails .scene-gallery-arrow:focus-visible{outline:2px solid var(--ui-story);outline-offset:1px}
