:root {
  color-scheme: dark;
  font: 16px/1.45 system-ui, sans-serif;
  background: #171c1a;
  color: #f3f4ef;
  --panel: #232b27;
  --line: #425048;
  --accent: #d8f5ae;
  --soft: #bdc9bd;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0; height: 100vh; height: 100dvh; overflow: hidden;
  display: grid; grid-template-rows: auto minmax(0, 1fr);
}
button, select, input { font: inherit; }
button, select {
  min-height: 42px; padding: .45rem .7rem; color: inherit; background: var(--panel);
  border: 1px solid var(--line); border-radius: .55rem;
}
button { cursor: pointer; }
button:not(.tile):hover, button[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); }
button:disabled { opacity: .55; cursor: default; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.top {
  min-width: 0; display: flex; align-items: center; gap: .8rem;
  padding: .65rem max(clamp(.5rem, 3vw, 2rem), env(safe-area-inset-right)) .65rem
    max(clamp(.5rem, 3vw, 2rem), env(safe-area-inset-left));
  padding-top: max(.65rem, env(safe-area-inset-top));
  border-bottom: 1px solid var(--line); white-space: nowrap;
}
.toolbar, .viewerBar { display: flex; align-items: center; gap: .55rem; }
.header-text { display: flex; align-items: baseline; gap: .55rem; min-width: 0; flex: 1 1 0; }
.brand-logo { margin-inline-end: -.25rem; flex: none; width: 36px; height: 36px; object-fit: contain; }
h1, #folderTitle { margin: 0; overflow: hidden; text-overflow: ellipsis; }
h1 { font-size: 1.15rem; }
.header-meta { flex: none; color: #a7aaa8; font-size: .75rem; font-weight: normal; font-variant-numeric: tabular-nums; }
#activeSource { flex: none; color: var(--accent); }
#activeSource:empty { display: none; }
#folderTitle { flex: 0 1 auto; min-width: 0; font-size: 1rem; }
.toolbar { flex: none; }
.toolbar button, .viewerBar button { display: inline-flex; align-items: center; justify-content: center; }
.toolbar .icon-button { min-width: 42px; }
.toolbar svg, .viewerBar svg { display: block; flex: none; width: 1.15rem; height: 1.15rem; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
#scroll:not([aria-pressed="true"]) .scroll-pause,
#scroll[aria-pressed="true"] .scroll-start,
#playSlides:not([aria-pressed="true"]) .play-pause,
#playSlides[aria-pressed="true"] .play-start,
#viewerSound:not([aria-pressed="true"]) .sound-on,
#viewerSound[aria-pressed="true"] .sound-off,
#viewerFullscreen:not([aria-pressed="true"]) .exit-full,
#viewerFullscreen[aria-pressed="true"] .enter-full { display: none; }
#panelToggle[aria-expanded="true"] { border-color: var(--accent); color: var(--accent); }
#favorite[aria-pressed="true"] svg { fill: currentColor; }
.viewerBar {
  flex-wrap: wrap; justify-content: flex-end; max-inline-size: 100%; position: relative; z-index: 2;
  margin-inline: max(0px, calc(env(safe-area-inset-left) - var(--viewer-inset)))
    max(0px, calc(env(safe-area-inset-right) - var(--viewer-inset)));
}
#repeatSlides[aria-pressed="false"] { color: #a4ada6; }
.viewerBar button { gap: .25rem; min-width: 42px; }
#slideSettings { white-space: nowrap; font-variant-numeric: tabular-nums; }
#slideOptions {
  position: absolute; z-index: 3; inset-block-start: 100%;
  inset-inline-end: 0; width: max-content; max-width: 100%;
  display: flex; flex-wrap: wrap; gap: .5rem; padding: .5rem;
  background: #101411; border: 1px solid var(--line); border-radius: .4rem;
}
.mobile-device .viewerBar { gap: .15rem; }
.mobile-device #viewer:not(.viewer-fullscreen) .viewerBar {
  inset-block-start: max(28px, calc(env(safe-area-inset-top) - var(--viewer-inset)));
}
.mobile-device .viewerBar button { min-width: 44px; min-height: 44px; padding-inline: .35rem; }
main {
  --side-padding: clamp(1rem, 4vw, 3rem);
  position: relative; min-height: 0; display: grid;
  grid-template: minmax(0, 1fr) / minmax(12rem, 16.5rem) minmax(0, 1fr);
  gap: clamp(1rem, 3vw, 2.5rem); padding: 0 var(--side-padding);
}
.panel-hidden main { grid-template-columns: minmax(0, 1fr); }
aside {
  align-self: start; min-width: 0; margin-top: 1.4rem;
  max-height: calc(100% - 1.4rem - env(safe-area-inset-bottom) - .5rem);
  background: var(--panel); border: 1px solid var(--line); border-radius: .8rem;
  overflow: auto; overscroll-behavior: contain;
}
#galleryScroll {
  min-height: 0; min-width: 0; overflow: auto; overscroll-behavior: contain;
  scrollbar-gutter: stable; overflow-anchor: none;
  padding-bottom: max(3rem, env(safe-area-inset-bottom));
}
#galleryScroll:focus-visible { outline-offset: -2px; }
aside section, details { padding: 1rem; display: grid; gap: .5rem; }
aside section + section, details { border-top: 1px solid var(--line); }
aside h2 { font-size: 1rem; margin: 0; }
aside label, summary { color: var(--soft); }
details label { display: block; margin: .6rem 0 .2rem; }
aside select, input[type="range"] { width: 100%; }
input { accent-color: var(--accent); }
#status, #caption { color: var(--soft); }
#status:empty { display: none; }
.gallery { --gallery-gap: 8px; display: grid; grid-template-columns: repeat(var(--columns, 3), minmax(0, 1fr)); gap: var(--gallery-gap); align-items: start; }
.column { display: flex; flex-direction: column; gap: var(--gallery-gap); min-width: 0; }
.tile { position: relative; display: block; padding: 0; border: 0; overflow: hidden; flex: none; width: 100%; height: var(--tile-height); min-height: 0; border-radius: min(.45rem, var(--gallery-gap)); background: #303b34; }
.tile img, .placeholder { position: absolute; inset: 0; width: 100%; height: 100%; }
.tile img { display: block; object-fit: contain; }
.placeholder { display: grid; place-items: center; overflow-wrap: anywhere; padding: .25rem; }
.tile .badge { position: absolute; bottom: .25rem; right: .25rem; background: #181c19e8; padding: .15rem .35rem; border-radius: .25rem; font-size: .75rem; }
#more { margin-top: 1rem; }
#viewer {
  --viewer-inset: .7rem;
  color: inherit; background: #101411; border: 1px solid var(--line); border-radius: .8rem;
  width: 96vw; max-width: 96vw; height: 96vh; height: 96dvh;
  max-height: 96vh; max-height: 96dvh; padding: .7rem; overflow: hidden;
}
#viewer[open] {
  display: grid;
  grid-template: auto minmax(0, 1fr) auto / minmax(0, 1fr);
}
#viewer::backdrop { background: #000d; }
#stage {
  position: relative; display: grid; place-items: center;
  min-width: 0; min-height: 0; overflow: hidden; background: #000;
}
#stage > img, #stage > video {
  position: absolute; inset: 0; display: block; width: 100%; height: 100%;
  object-fit: contain; object-position: center; background: #000;
}
#caption { margin: .5rem 0 0; max-height: 2.9em; overflow: auto; overflow-wrap: anywhere; }
@media (max-width: 760px) {
  main { grid-template-columns: minmax(0, 1fr); }
  aside {
    position: absolute; z-index: 1; inset: 1.4rem auto auto var(--side-padding);
    width: min(17rem, calc(100% - 2 * var(--side-padding))); margin-top: 0;
    max-height: calc(100% - 1.4rem - env(safe-area-inset-bottom) - .5rem);
  }
}
@media (max-width: 970px) {
  #scroll .scroll-pause, #scroll[aria-pressed="true"] .scroll-start { display: none; }
  #scroll[aria-pressed="true"] .scroll-pause { display: block; }
  .toolbar button { width: 42px; padding: 0; }
}
@media (max-width: 540px) {
  .top { gap: .25rem; font-size: .73rem; }
  .header-text, .toolbar { gap: .2rem; }
  .brand-logo { margin-inline-end: 0; width: 27px; height: 27px; }
  .header-meta { font-size: .625rem; }
  h1, #folderTitle { font-size: .73rem; }
  #folderTitle { min-width: 1.2em; }
  .count-label { display: none; }
  .toolbar button, .toolbar .icon-button { width: clamp(26px, 8vw, 42px); min-width: 0; }
  .toolbar svg { width: .95rem; height: .95rem; }
}

#sidebar {
  --folder-gold: #e8ba60;
  --indent: .8rem;
  margin-top: .55rem;
  max-height: calc(100% - .55rem - env(safe-area-inset-bottom) - .35rem);
  font-size: .875rem;
}
#sidebar section { padding: .65rem .65rem .55rem; gap: .35rem; }
#sidebar h2 { font-size: .875rem; }
#sidebar p { margin: 0; }
.section-line { display: flex; align-items: center; justify-content: space-between; }
#sidebar .sidebar-icon {
  display: grid; place-items: center; padding: 0; width: 30px; min-height: 28px;
  background: transparent;
}
.sidebar-icon svg { width: 1rem; height: 1rem; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; }
.segments { display: flex; gap: .2rem; }
#sidebar .segments button { flex: 1; min-width: 0; min-height: 30px; padding: .2rem .1rem; border-radius: .35rem; }
#sidebar .segments button[aria-pressed="true"] { background: var(--accent); color: #172018; }
.sidebar-status { color: var(--soft); min-height: 1.3em; }
#lanLogout button { width: 100%; }
#sidebar .connection-button { min-height: 30px; padding: .2rem .35rem; text-align: left; }
#sidebar #folders {
  --tree-viewport-share: 45;
  max-height: min(300px, calc(var(--tree-viewport-share) * 1vh));
  max-height: min(300px, calc(var(--tree-viewport-share) * 1dvh));
  overflow: auto;
}
#sidebar #folders:focus-visible { outline-offset: -2px; }
@media (pointer: coarse) {
  #sidebar #folders { --tree-viewport-share: 34; }
}
@media (max-width: 760px) {
  #sidebar #folders { --tree-viewport-share: 30; }
}
#sidebar ul { list-style: none; padding: 0; margin: 0; }
.tree-row {
  display: grid; grid-template-columns: 1.55rem minmax(0, 1fr); align-items: stretch;
  margin-inline-start: min(38%, calc(var(--tree-depth) * var(--indent)));
}
#sidebar .branch-toggle, #sidebar .folder-name {
  background: transparent; padding: .12rem .18rem; min-height: 28px;
  border: 1px solid transparent; border-radius: .3rem;
}
#sidebar .branch-toggle { display: grid; place-items: center; }
.branch-toggle::before {
  content: ""; width: .38rem; height: .38rem; border: solid var(--soft);
  border-width: 0 1.5px 1.5px 0; transform: rotate(-45deg);
}
.branch-toggle[aria-expanded="true"]::before { transform: rotate(45deg); }
.branch-toggle:disabled::before { visibility: hidden; }
#sidebar .folder-name {
  width: 100%; display: flex; align-items: center; gap: .38rem; text-align: left; color: inherit;
}
#sidebar .folder-name span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#sidebar .folder-name:hover, #sidebar .branch-toggle:hover { background: #303b34; }
#sidebar .folder-name[aria-current="location"] {
  color: var(--accent); border-color: #698455; background: #344432;
}
.folder-icon {
  position: relative; flex: none; display: inline-block; width: .9rem; height: .6rem;
  margin-top: .15rem; background: var(--folder-gold); border-radius: .12rem;
}
.folder-icon::before {
  content: ""; position: absolute; top: -.17rem; left: 0; width: .44rem; height: .25rem;
  background: inherit; border-radius: .12rem .12rem 0 0;
}
.tree-message { color: var(--soft); padding: .2rem .35rem; font-size: .8rem; }
#sidebar .sidebar-group { padding: .35rem .65rem; }
.sidebar-group summary { cursor: pointer; }
.summary-icon { color: var(--accent); display: inline-block; width: 1rem; text-align: center; }
.clock-icon { position: relative; width: .8rem; height: .8rem; border: 1px solid currentColor; border-radius: 50%; vertical-align: -.1rem; margin-inline: .1rem; }
.clock-icon::after { content: ""; position: absolute; top: .12rem; left: .3rem; width: .17rem; height: .23rem; border: solid currentColor; border-width: 0 0 1px 1px; }
#sidebar .settings > p { color: var(--soft); margin: .45rem 0 .2rem; }
#sidebar .check { display: flex; align-items: center; gap: .3rem; }
@media (max-width: 760px) {
  #sidebar { inset-block-start: .55rem; margin-top: 0; width: min(17rem, calc(100% - 2 * var(--side-padding))); }
}
@media (pointer: coarse) {
  #sidebar .segments button, #sidebar .folder-name, #sidebar .branch-toggle,
  #sidebar .sidebar-icon, #sidebar .connection-button, #sidebar .check { min-height: 42px; }
  .tree-row { grid-template-columns: 2rem minmax(0, 1fr); }
  .sidebar-group summary { min-height: 42px; line-height: 42px; }
}

.slide-option {
  display: inline-flex; align-items: center; flex-wrap: wrap; gap: .35rem;
  color: var(--soft); font-size: .875rem;
}
.slide-option input[type="range"] { width: clamp(5rem, 14vw, 9rem); }
.slide-option output { min-width: 2rem; font-variant-numeric: tabular-nums; }
#stage > .slide-outgoing { pointer-events: none; }
.slide-fade { animation: slide-fade .32s ease-out both; }
@keyframes slide-fade { from { opacity: 0; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
  .slide-fade { animation: none; }
}
html:has(body.immersive), body.immersive { overscroll-behavior-y: none; }
.immersive { grid-template-rows: minmax(0, 1fr); }
.immersive .top { display: none; }
.immersive main { --side-padding: 0px; }
.immersive #galleryScroll { padding-bottom: 0; overscroll-behavior-y: none; }
#leaveImmersive {
  --exit-hit-size: 28px;
  position: fixed; z-index: 2; display: grid; place-items: center;
  inset-inline-end: max(.65rem, calc(env(safe-area-inset-right) + 4px));
  inset-block-end: max(.65rem, calc(env(safe-area-inset-bottom) + 4px));
  width: var(--exit-hit-size); height: var(--exit-hit-size); min-height: 0;
  padding: 0; border: 0; background: transparent; color: #f3f4ef;
}
#leaveImmersive::before {
  content: ""; position: absolute; inset: calc((var(--exit-hit-size) - 28px) / 2);
  border-radius: .35rem; background: #101411b8; pointer-events: none;
}
#leaveImmersive svg {
  position: relative; width: 16px; height: 16px;
  fill: none; stroke: currentColor; stroke-width: 1.7;
  stroke-linecap: round; stroke-linejoin: round;
}
.mobile-device #leaveImmersive { --exit-hit-size: 44px; }
#viewer.viewer-fullscreen[open] {
  display: block; position: fixed; inset: 0; background: #000;
  width: 100%; height: 100%; max-width: none; max-height: none; margin: 0;
  border: 0; border-radius: 0; overscroll-behavior-y: none;
}

#lanLogout svg, #login svg { display: none; }

.mobile-device { height: var(--mobile-viewport-height, 100dvh); }
.mobile-device main { padding-bottom: env(safe-area-inset-bottom); }
.mobile-device.immersive main { padding-bottom: 0; }
.mobile-device #viewer.viewer-fullscreen[open] {
  padding: max(.45rem, env(safe-area-inset-top)) max(.45rem, env(safe-area-inset-right))
    max(.45rem, env(safe-area-inset-bottom)) max(.45rem, env(safe-area-inset-left));
}
.mobile-device.immersive #galleryScroll { touch-action: pan-y pinch-zoom; }
/* Keep touch targets larger than their visible button surface. */
.mobile-device .top { gap: .35rem; padding-block: max(.1rem, env(safe-area-inset-top)) .1rem; }
.mobile-device .toolbar { gap: 0; }
/* Keep the iPadOS window controls clear on top of the left safe inset. */
.ipad-device .top { padding-inline-start: calc(80px + env(safe-area-inset-left)); }
@media (max-width: 400px) {
  .ipad-device #folderTitle { min-width: 0; }
  .ipad-device .header-text { gap: .15rem; }
}
.mobile-device .toolbar button {
  position: relative; isolation: isolate; min-height: 44px;
  width: 44px; min-width: 0; padding: 0; border-color: transparent; background: transparent;
}
.mobile-device .toolbar svg { width: 1rem; height: 1rem; }
.mobile-device .toolbar button::before {
  content: ""; position: absolute; z-index: -1; inset: 6px 2px;
  border: 1px solid var(--line); border-radius: .4rem; background: var(--panel);
  pointer-events: none;
}
.mobile-device .toolbar button[aria-pressed="true"]::before,
.mobile-device #panelToggle[aria-expanded="true"]::before { border-color: var(--accent); }
.mobile-device #panelToggle[aria-expanded="true"] { border-color: transparent; }
.mobile-device:not(.immersive) main {
  --side-padding: .55rem;
  grid-template-columns: minmax(11.5rem, 14.5rem) minmax(0, 1fr);
  gap: .55rem;
}
.mobile-device.panel-hidden:not(.immersive) main { grid-template-columns: minmax(0, 1fr); }
.mobile-device #sidebar {
  display: flex; flex-direction: column; min-height: 0;
  margin-top: .2rem; height: calc(100% - .4rem - env(safe-area-inset-bottom));
  max-height: none; overflow-y: auto; border: 0; border-radius: 0;
}
.mobile-device #sidebar > * { flex: none; }
.mobile-device #sidebar section,
.mobile-device #sidebar .sidebar-group { padding: 0 .45rem; gap: 0; }
.mobile-device #sidebar .source-section {
  grid-template-columns: minmax(0, 1fr) repeat(2, 44px); align-items: center;
}
.mobile-device .source-section .section-line {
  grid-area: 1 / 3; justify-content: center;
}
.mobile-device .source-section .section-line h2 {
  position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%);
}
.mobile-device .source-section .segments { grid-area: 1 / 1 / 2 / 3; }
.mobile-device #sourceConnection { grid-area: 2 / 1; overflow-wrap: anywhere; }
.mobile-device #login { grid-area: 2 / 2; }
.mobile-device #lanLogout { grid-area: 2 / 3; }
.mobile-device #sidebar .source-section button,
.mobile-device #sidebar .settings .segments button {
  min-height: 44px; padding: 0 .1rem;
  background: transparent; border: 1px solid transparent;
}
.mobile-device #sidebar .segments { gap: 0; }
.mobile-device #sidebar .segments button[aria-pressed="true"] {
  color: var(--accent); font-weight: 700; text-decoration: underline; text-underline-offset: .25em;
}
.mobile-device #sidebar .source-section :is(#retry, #login, #lanLogout button) {
  display: grid; place-items: center; width: 44px;
}
.mobile-device #loginLabel, .mobile-device #lanLogout span { display: none; }
.mobile-device #login svg, .mobile-device #lanLogout svg {
  display: block; width: 1.15rem; height: 1.15rem; fill: none; stroke: currentColor;
  stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round;
}
.mobile-device #sidebar .folder-section {
  display: flex; flex-direction: column; flex: 1 0 0;
  min-height: calc(76px + 38px + 1.45em + .2rem + 1px);
}
.mobile-device .folder-section h2 { padding-block-start: .2rem; }
.mobile-device #sidebar #folders {
  flex: 1 1 0; min-height: 76px; max-height: none;
  overscroll-behavior-y: auto;
}
.mobile-device #sidebar .sidebar-group summary {
  display: list-item; min-height: 38px; line-height: 38px;
}
.mobile-device #sidebar .folder-name,
.mobile-device #sidebar .branch-toggle { min-height: 38px; }
.mobile-device .tree-row { grid-template-columns: 2.4rem minmax(0, 1fr); }
.mobile-device #sidebar .settings {
  grid-template-columns: max-content minmax(0, 1fr); align-items: center; column-gap: .35rem;
}
.mobile-device .settings > :is(summary, .segments, .check) { grid-column: 1 / -1; }
.mobile-device #sidebar .settings > p { grid-column: 1 / -1; margin: 0; }
.mobile-device #sidebar .settings > label { margin: 0; }
.mobile-device #sidebar .settings output { display: block; }
.mobile-device #sidebar .settings > input[type="range"] { min-height: 38px; min-width: 0; margin: 0; }
.mobile-device #sidebar .check { min-height: 38px; }
@media (max-width: 760px) {
  .mobile-device:not(.immersive) main { grid-template-columns: minmax(0, 1fr); }
  .mobile-device #sidebar {
    inset-block-start: .2rem; margin-top: 0;
    width: min(14.5rem, calc(100% - 2 * var(--side-padding)));
  }
  .mobile-device .toolbar button { width: clamp(29px, 8.5vw, 44px); }
  .mobile-device .toolbar button::before { inset-inline: 1px; }
  .mobile-device .top { gap: .2rem; }
}

.viewer-fullscreen #stage, .pre-viewer #stage { position: absolute; inset: 0; }
.pre-viewer #stage { touch-action: pan-y; }
.pre-viewer #stage > img { user-select: none; -webkit-user-drag: none; }
.viewer-fullscreen .viewerBar, .viewer-fullscreen #caption,
.pre-viewer .viewerBar, .pre-viewer #caption {
  position: absolute; z-index: 2; background: #101411e6;
}
:is(.viewer-fullscreen, .pre-viewer) .viewerBar {
  inset-block-start: max(var(--viewer-inset), env(safe-area-inset-top));
  inset-inline: max(var(--viewer-inset), env(safe-area-inset-left)) max(var(--viewer-inset), env(safe-area-inset-right));
  width: fit-content; margin-inline: auto 0; border-radius: .4rem;
}
.mobile-device :is(.viewer-fullscreen, .pre-viewer) .viewerBar {
  /* Leave room for iPadOS window controls even when the safe inset is zero. */
  inset-block-start: max(40px, env(safe-area-inset-top));
}
:is(.viewer-fullscreen, .pre-viewer) #caption {
  inset-inline: max(var(--viewer-inset), env(safe-area-inset-left)) max(var(--viewer-inset), env(safe-area-inset-right));
  inset-block-end: max(var(--viewer-inset), env(safe-area-inset-bottom)); width: fit-content;
}
.viewer-fullscreen.controls-hidden .viewerBar,
.viewer-fullscreen.controls-hidden #caption { opacity: 0; pointer-events: none; }
.pre-controls-hidden .viewerBar, .pre-controls-hidden #caption { visibility: hidden; }

#logoSettings { grid-column: 1 / -1; min-width: 0; margin-block-start: .25rem; padding: 0; border: 0; }
#logoSettings summary { display: list-item; }
#logoCount { color: var(--soft); font-variant-numeric: tabular-nums; }
#logoChoices {
  display: flex; flex-wrap: nowrap; gap: .25rem;
  overflow-x: auto; overscroll-behavior-x: contain; padding: 3px;
}
#logoChoices button {
  flex: 0 0 54px; display: grid; justify-items: center; min-width: 0;
  padding: 2px; border-radius: .35rem;
}
#logoChoices button[aria-pressed="true"] { border-color: #698455; }
#logoChoices img { width: 48px; height: 48px; object-fit: contain; }
#logoChoices span { width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .75rem; }
#logoStatus { color: var(--soft); font-size: .75rem; }
#logoStatus:empty { display: none; }

button.pdf-open { margin-inline-start: .65rem; min-height: 0; padding: 0 .4rem; }
#pdfReader {
  color: inherit; background: #101411; padding: 0; overflow: hidden;
  border: 1px solid var(--line); border-radius: .65rem;
  width: 96vw; max-width: 100%; height: 94dvh; max-height: 100%;
}
#pdfReader[open] { display: grid; grid-template-rows: auto minmax(0, 1fr); }
#pdfReader.pdf-full {
  position: fixed; inset: 0; margin: 0; width: 100%; height: 100%; border: 0; border-radius: 0;
}
#pdfReader::backdrop { background: #000c; }
.pdf-toolbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: .3rem;
  padding: max(.45rem, env(safe-area-inset-top)) max(.45rem, env(safe-area-inset-right))
    .45rem max(.45rem, env(safe-area-inset-left));
}
.mobile-device .pdf-toolbar { padding-top: max(36px, env(safe-area-inset-top)); }
.pdf-toolbar button { min-width: 44px; min-height: 44px; padding: .15rem .4rem; }
.pdf-page input { width: 3.2em; }
#pdfStatus {
  grid-area: 2 / 1; z-index: 1; place-self: start center;
  margin: .45rem .55rem 0; padding: .3rem .55rem; border-radius: .35rem;
  background: #101411e6; overflow-wrap: anywhere; pointer-events: none;
}
#pdfReader:has(#pdfViewport > img) #pdfStatus::before {
  content: "Aperçu provisoire · ";
}
#pdfStatus:empty { display: none; }
#pdfViewport {
  grid-area: 2 / 1; display: flex; flex-direction: column; min-width: 0; min-height: 0;
  overflow: auto; overscroll-behavior: contain; background: #080a09;
  padding: .35rem max(.35rem, env(safe-area-inset-right))
    max(.35rem, env(safe-area-inset-bottom)) max(.35rem, env(safe-area-inset-left));
}
#pdfViewport > :is(canvas, img) { display: block; flex: none; margin: auto; background: white; }
#pdfViewport > img { width: 100%; height: 100%; object-fit: contain; background: transparent; }

/* Le dialogue peut recevoir le focus quand le bouton actif est escamoté.
   Les commandes gardent leurs propres indicateurs :focus-visible. */
#viewer:focus-visible { outline: none; }
#viewer:is(.pre-controls-hidden, .controls-hidden) {
  background: #000;
  border-color: transparent;
  border-radius: 0;
  box-shadow: none;
}
#viewer:is(.pre-controls-hidden, .controls-hidden)::backdrop { background: #000; }
#viewer:is(.pre-controls-hidden, .controls-hidden) :is(.viewerBar, #caption) {
  visibility: hidden;
  pointer-events: none;
}

/* La barre de la mosaïque sert de référence aux deux barres de commandes. */
:is(.toolbar, #viewer .viewerBar) {
  --command-width: 42px;
  --command-height: 42px;
  --command-icon: 1.15rem;
  --command-gap: .55rem;
  --command-radius: .55rem;
  gap: var(--command-gap);
}
:is(.toolbar, #viewer .viewerBar) > button {
  position: relative;
  flex: 0 0 var(--command-width);
  width: var(--command-width);
  min-width: 0;
  min-height: var(--command-height);
  padding: 0;
  border-radius: var(--command-radius);
}
:is(.toolbar, #viewer .viewerBar) > button > svg {
  width: var(--command-icon);
  height: var(--command-icon);
}

#viewer .viewerBar {
  flex-wrap: nowrap;
  width: max-content;
  margin-inline-start: auto;
  background: transparent;
}

#slideSettings svg { transform: translateY(-4px); }
#slideSecondsValue {
  position: absolute;
  inset: auto 0 5px;
  text-align: center;
  font-size: .56rem;
  line-height: 1;
}

@media (max-width: 540px) {
  :is(.toolbar, #viewer .viewerBar) {
    --command-width: clamp(26px, 8vw, 42px);
    --command-icon: .95rem;
    --command-gap: .2rem;
  }
}
.mobile-device :is(.toolbar, #viewer .viewerBar) {
  --command-width: 44px;
  --command-height: 44px;
  --command-icon: 1rem;
  --command-gap: 0px;
  --command-radius: .4rem;
  --command-edge: 2px;
}
.mobile-device :is(.toolbar, #viewer .viewerBar) > button {
  isolation: isolate;
  border-color: transparent;
  background: transparent;
}
.mobile-device :is(.toolbar, #viewer .viewerBar) > button::before {
  content: "";
  position: absolute;
  z-index: -1;
  inset: 6px var(--command-edge);
  border: 1px solid var(--line);
  border-radius: var(--command-radius);
  background: var(--panel);
  pointer-events: none;
}
.mobile-device :is(.toolbar, #viewer .viewerBar) > button[aria-pressed="true"]::before,
.mobile-device #panelToggle[aria-expanded="true"]::before {
  border-color: var(--accent);
}
@media (max-width: 760px) {
  .mobile-device :is(.toolbar, #viewer .viewerBar) {
    --command-width: clamp(29px, 8.5vw, 44px);
    --command-edge: 1px;
  }
}
