/* Shared alignment rhythm without changing independent scrolling/layout. */
body :is(.story-column-title,.story-selected-title,.scene-detail-heading,.library-detail-heading,.md-section-head,.story-dialog-heading){align-items:center}
body :is(.story-column-title,.scene-detail-heading,.library-detail-heading,.md-section-head,.story-dialog-heading) :is(h2,h3,h4){margin-top:0;margin-bottom:0;line-height:1.4}
body :is(.story-column-title,.library-detail-heading,.scene-detail-heading) button{min-height:32px;display:inline-flex;align-items:center;justify-content:center}
body :is(.scene-detail-actions,.enemy-card-actions,.library-tabs,.library-media-tabs,.story-step-navigation,.story-inline-actions){display:flex;align-items:center;gap:6px;flex-wrap:wrap}
body :is(.scene-detail-actions,.library-detail-heading,.enemy-card-actions) svg{vertical-align:middle;flex-shrink:0}
body :is(.story-tag,.library-badges>span,.md-skill-badge,.md-info-badge,.condition-badge){display:inline-flex;align-items:center;gap:4px;vertical-align:middle;line-height:1.4;min-height:24px;box-sizing:border-box}
body .library-badges{align-items:center;gap:5px}
body .library-controls{align-items:center;gap:8px}
body .library-sort-control{display:flex;align-items:center;gap:6px;margin:0;white-space:nowrap}
body .library-sort-control select{margin:0;min-height:36px}
body #libraryMusicPane .session-row{align-items:flex-end;gap:10px}
body #libraryMusicPane .session-row>label{display:flex;flex-direction:column;gap:5px;margin:0}
body #libraryMusicPane .session-row :is(input[type=search],select){min-height:36px}
body #libraryMusicPane .session-row>.session-upload{min-height:36px;justify-content:center}
body .music-track-tags{align-items:flex-end}
body .music-track-tags label{margin:0;line-height:1.4}
body #storySceneDetails>section>h4,body #storySceneDetails>section>.scene-detail-heading{display:flex;align-items:center;min-height:32px;margin:0 0 8px}
body #storySceneDetails>section>h4{line-height:1.4}
body #storySceneDetails .scene-detail-heading h4{margin:0}
body .story-context-row>.story-summary-field{display:flex;flex-direction:column}
body .story-context-row>.story-summary-field>strong{line-height:1.4;min-height:19px;margin:0 0 8px}
body .story-context-row>.story-summary-field>textarea{flex:1;margin:0!important}
body .session-card>.session-row{align-items:center;gap:6px;flex-wrap:wrap}
body .enemy-card-actions .save-combat-character{min-height:32px;margin-right:0}
body .story-dialog-heading button,body .popup-close{display:grid;place-items:center;line-height:1;padding:0!important}
body dialog footer{display:flex;align-items:center;gap:8px;flex-wrap:wrap}

body .ui-sort-control{display:inline-flex;align-items:center;gap:6px;margin:0;white-space:nowrap;font-size:13px;color:var(--ui-muted)}
body .ui-sort-control select{min-height:36px;min-width:110px;width:auto;margin:0;font-size:13px}
body .ui-search-control{min-height:36px;line-height:1.4;padding-left:32px!important;background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%23b2c1d4' stroke-width='1.7' viewBox='0 0 24 24'%3E%3Ccircle cx='10' cy='10' r='6'/%3E%3Cpath d='m15 15 6 6'/%3E%3C/svg%3E");background-repeat:no-repeat;background-position:10px center}

/* Consistent geometry for cards, headings, badges and familiar actions. */
body :is(.ui-icon-action,.enemy-card-actions button,.md-entry-tools button,.initiative-reset){display:inline-flex;align-items:center;justify-content:center;line-height:1;flex-shrink:0}
body :is(.ui-icon-action,.enemy-card-actions button,.md-entry-tools button) svg{width:17px;height:17px;flex-shrink:0;margin:0}
body :is(.defense-badges,.md-skills,.md-buttons,.library-badges,.scene-detail-actions){align-items:center;gap:5px}
body :is(.defense-badge,.md-info-badge,.md-skill-badge,.condition-badge,.story-tag,.roll-die-badge){display:inline-flex;align-items:center;justify-content:center;gap:4px;vertical-align:middle;line-height:1.35;border-radius:5px;box-sizing:border-box}
body .enemy-five-cards{align-items:stretch;gap:8px}
body .enemy-five-cards>.enemy-info-card{box-sizing:border-box;display:flex;flex-direction:column;padding:10px;min-width:0;min-height:0;overflow:hidden}
body .enemy-five-cards .md-section-head{position:static;box-sizing:border-box;display:flex;align-items:center;justify-content:space-between;min-height:42px;margin:0;padding:0 0 8px;flex-shrink:0;border-bottom:1px solid #40536d}
body .enemy-five-cards .enemy-card-body{padding-top:8px;flex:1;min-height:0;overflow:auto}
body .enemy-five-cards .md-section-head h4{line-height:1.4;margin:0}
body .enemy-five-cards .md-section-head>div{align-items:center;justify-content:flex-end}
body .enemy-five-cards .md-entry-head{align-items:flex-start;gap:8px}
body .enemy-five-cards .md-entry-tools{display:flex;align-items:center;gap:4px;flex-shrink:0}
body .initiative-row{position:relative;grid-template-columns:minmax(0,1fr) 42px!important;padding:11px 19px 9px 7px;gap:5px}
body .initiative-row .initiative-remove{position:absolute;right:2px;top:2px;width:19px;height:19px;min-width:19px;min-height:19px;padding:0;display:grid;place-items:center;border:0;border-radius:4px;background:transparent;line-height:1;font-size:13px}
body #storyFlow .story-list-item>[data-story=moment],body #storyFlow .has-status-control>[data-story=moment]{min-height:92px;padding-top:29px!important;padding-bottom:29px!important}
body #storyFlow .story-card-title{padding-top:0;gap:7px}body #storyFlow .story-card-number{font-size:22px}body #storyFlow .story-direct-status{bottom:7px}
body .combat-dice-heading{min-height:32px;padding-bottom:7px;margin:0}body .dice-history-button{width:28px!important;min-width:28px!important;height:28px!important;min-height:28px!important;padding:0!important}
.dice-history-dialog{width:min(540px,calc(100vw - 32px));max-height:80vh;overflow:hidden}.dice-history-list{max-height:60vh;overflow:auto;display:flex;flex-direction:column;gap:8px;padding-right:4px}.dice-history-hint{color:var(--ui-muted);font-size:12px;margin:8px 0 12px}.dice-history-item{border:1px solid var(--ui-line);border-radius:8px;background:var(--ui-surface);padding:10px}.dice-history-item>div:first-child{display:flex;align-items:center;justify-content:space-between;gap:10px}.dice-history-item time{color:var(--ui-muted);font-size:12px}.dice-history-item p{font-size:13px;line-height:1.5;margin:7px 0}.dice-history-item .roll-dice-badges{display:flex;flex-wrap:wrap;gap:5px}.dice-history-item .roll-die-badge{padding:4px 6px;background:#1e293b;border:1px solid #40536d;font-size:12px}.dice-history-item .is-one{color:#ffe1e1;background:#672b31}.dice-history-item .is-max{color:#bbf7d0;background:#153e2b}

body .library-tabs button{display:inline-flex;align-items:center;justify-content:center;gap:6px;min-height:32px;line-height:1.4}body .library-tabs button svg{flex-shrink:0}body .initiative-remove:hover{background:#321c24;color:#fda4af}body .library-controls .ui-search-control{flex:1;min-width:150px}body .story-left-column #combatDiceCard .dice-card-stepper{flex-shrink:0}body #combatDiceCard .dice-card-grid .dice-card-label{font-size:11px}

.md-entry-identity{display:flex;align-items:center;flex-wrap:wrap;gap:5px;min-width:0;flex:1}.md-entry-identity strong{overflow-wrap:anywhere}body .md-action-type{font-size:11px;min-height:22px;padding:2px 5px;font-weight:500;white-space:nowrap;background:#1b2b42;color:#c6d9ef;border:1px solid #52647d}body .md-action-type[data-action-type=reaction]{border-color:#477b87;color:#b6edf4}body .md-action-type[data-action-type=bonus_action]{border-color:#657f55;color:#d3e8b8}

body .md-spell-role-filter{width:auto;min-width:92px;max-width:120px;min-height:28px;margin:0;padding:3px 5px;font-size:12px}body .md-spell-role-badges{display:flex;align-items:center;flex-wrap:wrap;gap:4px;margin:5px 0}body .md-spell-role-badges .story-tag{font-size:11px;min-height:22px;padding:2px 5px}.md-spell-role-editor{display:flex;flex-wrap:wrap;gap:10px;border:1px solid #40536d;border-radius:7px;padding:10px}.md-spell-role-editor label{display:inline-flex;align-items:center;gap:5px;font-size:13px}.md-spell-role-editor input{width:auto;min-height:0}
/* Adult Black Dragon compact spell-card trial. */
body .md-compact-spell{position:relative;margin:8px 0;padding:10px;border:1px solid var(--border-color,#405773);border-radius:8px;background:var(--surface-color,#162335)}
body .md-compact-spell-top{display:flex;align-items:center;justify-content:space-between;gap:8px;margin-bottom:6px}
body .md-compact-spell-top strong{font-size:13px;line-height:1.4}
body .md-compact-spell-top button{height:28px;min-height:28px;padding:3px 10px}
body .md-compact-spell-tags{display:flex;align-items:center;gap:4px;flex-wrap:wrap;padding-right:66px;min-height:24px}
body .md-compact-spell-details>summary{position:absolute;right:10px;top:46px;cursor:pointer;font-size:12px;line-height:24px;color:var(--text-color,#dceafb)}
body .md-compact-spell-details[open]{margin-top:8px;border-top:1px solid #405773;padding-top:8px}
body .md-compact-spell-details>.md-entry{margin:0;padding:0;border:0}
body .md-compact-spell-details .md-entry-identity,body .md-compact-spell-details .md-spell-role-badges{display:none}
body .md-compact-spell-details .md-entry-head{justify-content:flex-end}
body .md-compact-spell-details .spell-usage-row>[data-md^="cast:"]{display:none}
body .md-compact-spell-details>summary:focus-visible{outline:2px solid #80dfff;outline-offset:2px;border-radius:3px}
body .md-entry.md-compact-spell{padding:10px;margin:8px 0;border:1px solid #405773}
body .md-compact-rolls{display:flex;gap:4px;flex-shrink:0}
body .md-compact-spell-top strong{min-width:0;overflow-wrap:anywhere}
body .md-compact-ability .md-compact-spell-details .md-entry-head>strong,body .md-compact-ability .md-compact-spell-details .md-entry-head>.story-tag,body .md-compact-ability .md-compact-spell-details .md-entry-head>.md-resource-count{display:none}
body .md-compact-ability .md-compact-spell-details .md-buttons>[data-md^="use:"]{display:none}
body .md-compact-spell-details .md-description>summary{position:static}
body .md-compact-spell-top button{white-space:nowrap;flex-shrink:0}
body .md-compact-spell-details>summary{position:static;float:right;margin-top:-24px;line-height:24px}
body .md-compact-spell-details[open]{margin-top:0;padding-top:0;border-top:0}
body .md-compact-spell-details>.md-entry{clear:both;padding-top:8px;margin-top:8px;border-top:1px solid #405773}
/* Combat summary: one compact toolbar and one aligned health/defenses row. */
body #monstersList .enemy-summary-header{padding-bottom:10px;border-bottom:1px solid #405773}
body #monstersList .enemy-name-row{gap:8px;align-items:center;flex-wrap:wrap}
body #monstersList .enemy-card-actions{gap:6px;border-left:0;padding-left:0}
body #monstersList .enemy-card-actions button{width:30px;height:30px;min-height:30px;padding:6px}
body #monstersList .enemy-header-details{gap:18px;align-items:center;margin-top:12px;margin-bottom:0}
body #monstersList .md-defenses{padding:0;border:0}
body #monstersList .md-defense-grid{gap:16px}
body #monstersList .md-defense-grid>div{border-left:0;padding:0;display:flex;flex-direction:column;align-items:flex-start;gap:7px;min-height:48px}
body #monstersList .defense-column-heading{min-height:18px;margin:0}
body #monstersList .md-defense-grid b{font-size:11px;letter-spacing:.03em;font-weight:600}
body #monstersList .enemy-hp-strip{padding-right:16px;border-right:1px solid #405773}
body .monster-defense-fields{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:10px;border:1px solid #405773;border-radius:8px;padding:12px;margin:12px 0}
body .monster-defense-fields legend{font-weight:600;padding:0 5px}
body .monster-defense-fields label{display:flex;flex-direction:column;gap:6px;font-size:12px}
body .monster-defense-fields input{width:100%;min-height:36px;padding:8px;border:1px solid #506986;border-radius:7px;background:#0d1a29;color:#e2edf8}
@media(max-width:700px){body .monster-defense-fields{grid-template-columns:1fr}}
body #monstersList .md-defense-grid>div{border-left:0!important;padding-left:0!important}
body #monstersList .enemy-header-details{margin-top:8px;padding-top:8px;padding-bottom:4px}
body .monster-defense-fields[hidden]{display:none!important}
