/* The compact mobile navigation can also expose every destination at once. */
.mobile-nav-toggle, .brand .language-trigger, .brand .language-name { display: none; }
@media(max-width:900px) {
  .sidebar .brand {
    flex-wrap: wrap;
    column-gap: clamp(4px, 1.3vw, 10px);
    row-gap: 4px;
  }
  .brand-copy { display: contents; }
  .brand-copy > p { display: none; }
  .brand .brand-name { margin-inline-end: auto; font-size: 1.375rem; white-space: nowrap; }
  .brand .brand-mark { width: 34px; height: 34px; flex-basis: 34px; }
  .brand .mobile-nav-toggle, .brand .mobile-settings-toggle, .brand .language-trigger:not([hidden]) {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: none;
    min-height: 44px;
    min-width: 44px;
    margin: 0;
    white-space: nowrap;
    overflow-wrap: normal;
  }
  .brand .mobile-nav-toggle {
    gap: 7px;
    padding: 0 10px;
    font: 600 .875rem/1.2 system-ui, sans-serif;
  }
  .mobile-nav-toggle::before {
    content: "";
    width: 13px;
    height: 10px;
    border-block: 1.5px solid currentColor;
    background: linear-gradient(currentColor, currentColor) center / 100% 1.5px no-repeat;
  }
  .brand .mobile-settings-toggle { padding: 0; font: 20px/1 system-ui, sans-serif; }
  .brand-language { position: relative; flex: none; }
  .brand .language-trigger:not([hidden]) {
    gap: 6px;
    padding: 0 6px;
    border: 0;
    background: transparent;
    color: var(--muted);
    font: 650 .8125rem/1 system-ui, sans-serif;
  }
  .language-trigger::after {
    content: "";
    width: 6px;
    height: 6px;
    border: solid currentColor;
    border-width: 0 1.5px 1.5px 0;
    transform: translateY(-2px) rotate(45deg);
  }
  .language-trigger[aria-expanded="true"]::after { transform: translateY(2px) rotate(225deg); }
  .language-trigger:not([hidden]) + #workspace-languages { display: none; }
  .language-trigger[aria-expanded="true"] + #workspace-languages {
    display: block;
    position: absolute;
    z-index: 2;
    inset-inline-end: 0;
    top: calc(100% + 4px);
  }
  .language-trigger[aria-expanded="true"] + div .locale-picker {
    display: grid;
    gap: 2px;
    width: max-content;
    min-width: 9rem;
    padding: 4px;
    margin: 0;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: linear-gradient(var(--panel-strong), var(--panel-strong)), #100f10;
    box-shadow: 0 8px 22px var(--shadow);
  }
  .brand-language .locale-picker > :is(span, a) {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 44px;
    padding: 0 12px;
    border-radius: 6px;
    color: var(--ink);
    font: 500 .875rem/1.25 system-ui, sans-serif;
    letter-spacing: normal;
  }
  .brand-language .locale-picker > [aria-current] { background: var(--soft); color: var(--action-highlight); }
  .brand-language .locale-picker > [aria-current]::after {
    content: "";
    width: 6px;
    height: 11px;
    border: solid currentColor;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
  }
  .brand .language-code { display: none; }
  .brand .language-name { display: inline; }
  .brand button:focus-visible, .brand .language-link:focus-visible {
    outline: 2px solid var(--action-highlight);
    outline-offset: 2px;
  }
  .mobile-nav-toggle[aria-expanded=true] { color: var(--ink); border-color: var(--accent); background: var(--soft); }
  .mobile-nav-open .tool-nav { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 7px; max-height: 60dvh; overflow-y: auto; padding-block: 8px; scroll-snap-type: none; }
  .mobile-nav-open .tool-nav .nav-button { min-width: 0; width: 100%; white-space: normal; min-height: 44px; font-size: 14px; }
}
@media (max-width: 359px) {
  .brand .brand-name { font-size: 1.25rem; }
  .mobile-nav-toggle::before { display: none; }
}

/* Reference dialogs keep the title and actions available while reading. */
.reference-modal.tool-modal {
  display: flex; flex-direction: column; padding: 0; overflow: hidden;
  max-height: calc(100dvh - 48px); width: min(1040px, 100%);
}
.reference-modal > .modal-header {
  position: relative; top: auto; flex: none; margin: 0; padding: 20px 72px 18px 24px; border-bottom: 1px solid var(--border);
}
.reference-modal > .modal-header h2 { margin: 0; font-size: 30px; line-height: 1.15; overflow-wrap: anywhere; }
.reference-modal > .modal-header .eyebrow { margin: 0 0 7px; font-size: 11px; }
.reference-modal > .modal-close { position: absolute; top: 14px; right: 14px; bottom: auto; left: auto; width: 44px; height: 44px; min-height: 44px; z-index: 3; }
.reference-modal > .monster-detail { display: block; flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 22px 24px; scrollbar-gutter: stable; }
.reference-modal > .monster-detail > * + * { margin-top: 18px; }
.reference-modal > .modal-actions { flex: none; display: flex; flex-wrap: wrap; gap: 8px; margin: 0; padding: 14px 24px; border-top: 1px solid var(--border); background: var(--panel-strong); }
.reference-modal > .modal-actions > :is(button,a) { flex: 0 1 auto; min-height: 44px; font-size: 14px; }
.reference-modal > .modal-actions > :is([data-close-monster],[data-close-spell],[data-close-potion-detail],[data-close-tavern-detail],[data-close-shop-detail],[data-close-character-detail],[data-close-npc-detail],[data-close-curse-detail],[data-close-random-event-detail],[data-close-loot-detail]) { display: none; }
.reference-page-link { display: inline-flex; align-items: center; justify-content: center; padding: 9px 14px; border: 1px solid var(--border); border-radius: 8px; text-decoration: none; color: var(--muted); }
.reference-page-link:hover { color: var(--ink); border-color: var(--accent); }
.reference-page-link.primary-action { color: var(--action-ink); }
.reference-page-link[hidden] { display: none; }
.ability-editor { grid-template-columns: repeat(3,minmax(0,1fr)); gap: 12px; }
.ability-editor .field { align-content: end; }
.ability-editor input { font-size: 16px; }
.map-object-dialog [data-object-security] label:has(select) { grid-column: 1 / -1; }
.creature-subtitle { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.5; }
.reference-card-overview { display: grid; gap: 20px; }
.reference-card-overview:has(> .creature-illustration) { grid-template-columns: minmax(200px,.75fr) minmax(0,1.45fr); }
.reference-card-overview .creature-illustration { margin: 0; min-height: 0; padding: 14px; aspect-ratio: auto; background-size: cover; }
.reference-card-overview .creature-illustration img { width: 100%; height: 100%; max-height: 290px; object-fit: contain; }
.reference-card-stats { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.reference-card-stats .monster-meta-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
.reference-card-stats .monster-meta-grid > div { padding: 10px 12px; font-size: 14px; }
.reference-card-stats .monster-meta-grid span { font-size: 12px; }
.reference-card-stats .abilities-grid { gap: 5px; }
.reference-card-stats .ability-cell { padding: 8px 3px; border-radius: 6px; gap: 2px; }
.reference-card-stats .ability-cell strong { font-size: 21px; }
.reference-card-stats .ability-cell :is(span,small) { font-size: 12px; }
.reference-modal .monster-section { border: 0; border-top: 1px solid var(--border); padding: 20px 0 0; background: none; border-radius: 0; }
.reference-modal .monster-section h4 { font-size: 24px; margin-bottom: 14px; }
.reference-modal .monster-text-list p { line-height: 1.7; }
.reference-modal .monster-info-lines { border: 0; border-block: 1px solid var(--border); border-radius: 0; background: none; padding: 14px 0; font-size: 14px; }
.reference-modal .license-note { border: 0; border-top: 1px solid var(--border); border-radius: 0; padding: 14px 0 0; background: none; font-size: 12px; line-height: 1.6; }
.item-card-layout.has-art { display: grid; grid-template-columns: minmax(200px,.8fr) minmax(0,1.5fr); gap: 24px; align-items: start; }
.item-card-copy { min-width: 0; }
.item-card-layout .loot-item-art { width: 100%; margin: 0; }
.item-card-copy .monster-meta-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
.item-card-copy .monster-meta-grid > div { padding: 10px 12px; font-size: 14px; }
.item-card-copy .monster-meta-grid span { font-size: 12px; }
.item-card-copy .monster-section { margin-top: 20px; }

/* Map navigation has a stable location and separates creation from replacement. */
.map-intro { margin: 0 0 14px; }
.map-intro p { font-size: 14px; }
.map-toolbar-room-slot { display: none; }
.map-main > .map-rebuild { display: none; }
.map-toolbar [data-room-open] { white-space: nowrap; }
.map-editor:not(.map-phone) .map-main > .map-toolbar { flex-wrap: wrap; gap: 8px; padding: 10px 12px; }
.map-editor:not(.map-phone) .map-main > .map-toolbar .map-title-label { flex: 1 1 160px; }
.map-main > .map-session-bar > :is(.map-lighting,[data-map-editor-light]) { display: none; }
.map-stage > .map-view-tools { position: absolute; bottom: 12px; right: 12px; z-index: 5; display: flex; flex-wrap: nowrap; gap: 4px; width: auto; padding: 4px; border: 1px solid var(--border); border-radius: 10px; background: var(--panel-strong); box-shadow: 0 4px 18px #0005; }
.map-stage > .map-view-tools button { min-width: 38px; min-height: 40px; padding: 6px 9px; background: transparent; }
.map-phone .map-stage > .map-view-tools button { min-width: 44px; min-height: 44px; }
.map-editor.map-phone .map-session-bar > [data-workshop-open]:not([hidden]) { display: inline-flex; align-items: center; justify-content: center; flex: 1 1 120px; }
.map-editor.map-phone .map-session-bar > [data-battle-start] { flex: 1 1 120px; }
.map-phone .map-touch-selection:not(.has-selection) { display: none; }
.map-editor:not(.map-phone) .map-main > .map-dock { border-top: 0; border-bottom: 1px solid var(--border); padding: 7px 10px; }
.map-editor:not(.map-phone):not(.map-drawing):not(.map-in-battle):not(.map-immersive) .map-stage { height: clamp(320px, 56dvh, 680px); }
.map-sheet-body > .map-shelf { margin-bottom: 18px; }
.map-file-import { margin: 0 0 16px; }
.map-sheet[data-sheet=settings] .map-settings { margin: 0; }
.map-sheet[data-sheet=settings] .map-settings > summary { font-size: 16px; }
.map-sheet[data-sheet=file] .map-sheet-body { display: flex; flex-direction: column; gap: 22px; }
.map-sheet[data-sheet=file] .map-launch-actions { margin: 0; padding: 0; border: 0; }
.map-sheet[data-sheet=file] .map-export { padding: 0; margin: 0; }
.map-export h4 { grid-column: 1 / -1; margin: 0 0 2px; font-size: 17px; }
.map-sheet .map-export [data-map-action=save] { margin-bottom: 4px; }
.map-sheet[data-sheet=file] .map-room-notes { margin: 0; padding: 12px 0 0; }
.map-sheet .map-rebuild { display: flex; flex-wrap: wrap; gap: 10px; padding-top: 18px; border-top: 1px solid var(--border); }
.map-rebuild h4 { flex-basis: 100%; margin: 0; font-size: 17px; }
.map-rebuild p { flex-basis: 100%; margin: 0 0 3px; font-size: 13px; line-height: 1.5; color: var(--muted); }
.map-arrange { display: grid; gap: 8px; flex-basis: 100%; padding-bottom: 12px; }
.map-arrange button { justify-self: start; max-width: 100%; white-space: normal; }
.map-sheet .map-help-actions { display: flex; flex-wrap: wrap; gap: 8px; padding-top: 18px; border-top: 1px solid var(--border); }
.map-sheet[data-sheet=file] .map-help { margin: 0; padding-top: 0; border-top: 0; }
.map-sheet[data-sheet=file] .map-footnote { margin: 0; font-size: 11px; }
.map-sheet:not(.map-tour-underlay) .map-sheet-body { padding: 20px; }
.map-sheet .map-palette-filter { margin-top: 20px; }
.map-sheet .map-palette p { line-height: 1.6; }
.map-sheet .map-prop-button { padding: 10px 5px; }
.map-sheet .map-prop-button span { font-size: 12px; line-height: 1.35; }
.map-sheet .map-actor-add { width: 100%; min-height: 46px; }
.map-editor.map-drawing .map-main > .map-dock { display: none; }
.map-editor.map-drawing .map-touch-selection { display: none; }
.map-phone.map-drawing .map-materials { top: 12px; }
.map-drawing .map-toolbar :is([data-room-open],[data-map-action=fullscreen]) { display: none; }
.map-immersive .map-toolbar [data-map-action=fullscreen] { display: none; }
.map-editor.map-phone .map-toolbar { grid-template-columns: 44px minmax(0,1fr) auto; }
.map-editor.map-phone .map-toolbar .map-save-status { grid-column: 2 / -1; }
.map-editor.map-phone.map-drawing .map-toolbar .map-save-status { grid-column: 1 / -1; }
.map-drawing .map-drawing-tools { top: 58px; }
.map-drawing .map-main .map-brush-toolbar { justify-content: center; }
.map-editor.map-drawing:not(.map-phone) .map-brush-toolbar [data-brush-kind] { display: none; }
.map-editor.map-drawing .map-brush-toolbar [data-brush-kind] { max-width: 190px; }
@media(min-width:901px) {
  .map-editor:not(.map-phone) .map-toolbar .map-save-status { order: 2; }
  .map-editor:not(.map-phone) .map-toolbar .map-view-tools { margin-left: auto; }
}
@media(max-width:720px) {
  .reference-modal.tool-modal { width: 100%; height: 100dvh; max-height: 100dvh; border-radius: 0; }
  .reference-modal > .modal-header { padding: max(16px,env(safe-area-inset-top)) 66px 14px 16px; }
  .reference-modal > .modal-header h2 { font-size: 25px; }
  .reference-modal > .modal-close { top: max(10px,env(safe-area-inset-top)); right: 10px; }
  .reference-modal > .monster-detail { padding: 16px; scrollbar-gutter: auto; }
  .reference-modal > .modal-actions { display: grid !important; grid-template-columns: 1fr 1fr; gap: 8px; padding: 10px 12px max(10px,env(safe-area-inset-bottom)); }
  .reference-modal > .modal-actions > :is(button,a) { font-size: 12px; margin: 0; padding: 9px 10px; line-height: 1.35; }
  .reference-card-overview:has(> .creature-illustration), .item-card-layout.has-art { grid-template-columns: minmax(0,1fr); gap: 16px; }
  .reference-card-overview .creature-illustration { height: 170px; padding: 8px; }
  .reference-card-overview .creature-illustration img { height: 152px; max-height: none; }
  .reference-card-stats .abilities-grid { grid-template-columns: repeat(6,minmax(0,1fr)); }
  .reference-modal .monster-section h4 { font-size: 22px; }
  .item-card-layout .loot-item-art { width: min(100%,220px); margin: 0 auto; }
  .map-sheet:not(.map-tour-underlay) .map-sheet-body { padding: 16px; }
  .map-sheet .map-help-actions > button { flex: 1 1 150px; }
  .map-sheet .map-rebuild > button { flex: 1 1 150px; }
  .map-editor.map-phone .map-sheet .map-prop-button span { font-size: 11px; }
}
@media(max-width:360px) { .reference-card-stats .abilities-grid { grid-template-columns: repeat(3,minmax(0,1fr)); } }
@media(max-height:500px) and (orientation:landscape) {
  .reference-modal > .modal-header { padding-block: 10px; }
  .reference-modal > .modal-header h2 { font-size: 22px; }
  .reference-modal > .modal-actions { padding-block: 6px; }
}
