/* Keep the existing desktop/mobile layout and original speed slider. */
/* Reserve gestures on the artwork for the viewer; libraries and panels scroll normally. */
.stage > canvas, .stage > svg { touch-action: none; }
.rail.hide, .top-pill.hide, .tool-strip.hide, .playbar.hide, .status.hide { visibility: hidden !important; }
#floatPanel .rp-page { min-height: 0; overscroll-behavior: contain; }
@media (max-width: 720px) {
  html[data-gav-ui="clean"] body .playbar:not(.collapsed) { padding: 6px !important; gap: 6px !important; align-items: center !important; }
  html[data-gav-ui="clean"] body .playbar-toggle { flex: 0 0 40px !important; width: 40px !important; height: 40px !important; }
  html[data-gav-ui="clean"] body .playbar .playbar-controls {
    grid-template-columns: 40px minmax(24px, 1fr) 64px !important;
    grid-template-rows: 40px 40px !important;
    gap: 6px 8px !important;
    align-items: center;
  }
  html[data-gav-ui="clean"] body .playbar .playbar-controls > .ctl { width: 40px !important; height: 40px !important; }
  html[data-gav-ui="clean"] body .playbar input[type="range"] { height: 40px; }
  html[data-gav-ui="clean"] body .playbar :is(.pb-time, .pb-speed-val) { font-variant-numeric: tabular-nums; text-align: center; }
  html[data-gav-ui="clean"] body .playbar .pb-time { font-size: 11px !important; }
  html[data-gav-ui="clean"] body .playbar.playbar-speed-only .playbar-controls { grid-template-columns: 40px minmax(24px, 1fr) 40px !important; grid-template-rows: 40px !important; }
  .playbar.playbar-speed-only #pbSpeed { grid-row: 1; }
  .playbar.playbar-speed-only #pbSpeedVal { grid-row: 1; }
  .playbar.playbar-speed-only .playbar-controls > span:empty { display: none; }
  /* The same panel is already available in the right-hand tools. */
  .playbar.playbar-speed-only #btnPanel { display: none !important; }
}

/* Shared control cells keep native viewer styles from shifting icon centers. */
html[data-gav-ui="clean"] body :is(.rail,.tool-strip) { align-items: center !important; }
html[data-gav-ui="clean"] body :is(.rail,.tool-strip) button { box-sizing: border-box; }
html[data-gav-ui="clean"] body :is(.rail,.tool-strip) button > .arthub-icon { display: block; flex: none; width: 18px; height: 18px; }
@media (min-width: 721px) {
  html[data-gav-ui="clean"] body :is(.rail,.tool-strip) {
    height: 48px !important; min-height: 48px !important; box-sizing: border-box;
    padding: 5px !important; gap: 4px !important;
  }
  html[data-gav-ui="clean"] body :is(.rail,.tool-strip) button { height: 36px !important; min-height: 36px !important; }
  html[data-gav-ui="clean"] body .status { top: 72px !important; }
  html[data-gav-ui="clean"] body .tool-strip :is(.zoom-bar,.tool-zoom) {
    height: 36px !important; padding: 0 !important; align-items: center !important;
  }
}
@media (max-width: 720px) {
  html[data-gav-ui="clean"] body :is(.rail,.tool-strip) { gap: 4px !important; }
  html[data-gav-ui="clean"] body .tool-strip :is(.zoom-bar,.tool-zoom) { align-items: center !important; gap: 0 !important; }
  html[data-gav-ui="clean"] body .tool-strip .tool-zoom :is(button,.zoom-pct) {
    flex: 0 0 48px !important; height: 48px !important; min-height: 48px !important;
    display: inline-flex !important; align-items: center !important; justify-content: center !important;
  }
}

/* Every viewer exposes the same zoom controls on desktop and mobile. */
html[data-gav-ui="clean"] body .tool-strip .tool-zoom {
 display:flex !important; position:static !important; align-items:center; gap:2px; margin:0; padding:0; border:0; background:transparent; box-shadow:none;
}
html[data-gav-ui="clean"] body .tool-zoom :is(button,#zPct) { display:inline-flex; align-items:center; justify-content:center; min-width:32px; min-height:36px; padding:5px; border:0; border-radius:9px; color:var(--text-dim); background:transparent; cursor:pointer; font:inherit; }
html[data-gav-ui="clean"] body .tool-zoom .zoom-pct { min-width:46px; font-size:11px; font-variant-numeric:tabular-nums; }
html[data-gav-ui="clean"] body .tool-zoom :is(button,#zPct):hover { color:var(--accent); background:var(--accent-dim-bg); }

html[data-gav-ui="clean"] body .tool-strip .tool-zoom :is(#zOut,#zPct,#zIn) { display:inline-flex !important; align-items:center; justify-content:center; }
body.game-interaction-viewer #btnStagePan { display:inline-flex; align-items:center; justify-content:center; }
body.game-interaction-viewer #btnStagePan[aria-pressed="true"] { color:var(--accent); background:var(--accent-dim-bg); }
body.game-interaction-viewer > .stage[data-pan-mode="pan"] > canvas { cursor:grab; }
body.game-interaction-viewer > .stage[data-pan-dragging="true"] > canvas { cursor:grabbing; }

/* Words identify unfamiliar actions; +/- remain standard zoom controls. */
html[data-gav-ui="clean"] body :is(.rail,.tool-strip) button[data-action-label]:not([data-action-label=""]):not(.kit-secondary-tool) {
  width: auto !important; min-width: 36px; padding-inline: 9px !important; gap: 5px;
}
html[data-gav-ui="clean"] body .playbar.collapsed { width: max-content !important; min-width: 98px !important; height: auto !important; box-sizing: border-box; }
html[data-gav-ui="clean"] body .playbar.collapsed .playbar-toggle[data-action-label] { flex: 0 0 auto !important; width: auto !important; min-width: 86px; padding-inline: 8px; gap: 5px; }
@media (max-width: 720px) {
  html[data-gav-ui="clean"] body :is(.rail,.tool-strip) button[data-action-label]:not([data-action-label=""]):not(.kit-secondary-tool) {
    flex: 0 0 48px !important; width: 44px !important; height: 48px !important;
    flex-direction: column !important; justify-content: center !important; padding: 3px 0 !important; gap: 3px;
  }
  html[data-gav-ui="clean"] body :is(.rail,.tool-strip) button[data-action-label]::after { font-size: 10px; }
  html[data-gav-ui="clean"] body .rail button[data-action-label] { flex-basis: 44px !important; }
  html[data-gav-ui="clean"] body .playbar.collapsed .playbar-toggle { flex: 0 0 auto !important; min-width: 86px; }
  :is(.ctx-menu,.stage-popup) .arthub-popup-head .arthub-popup-close { min-height: 40px; }
  html[data-gav-ui="clean"] body #gridView.library-ui .library-top-row > #btnTheme[data-action-label] {
    width: 40px !important; padding: 2px 0 !important; gap: 2px;
    display: inline-flex; flex-direction: column; align-items: center; justify-content: center;
  }
  #gridView.library-ui #btnTheme[data-action-label] .arthub-icon { width: 14px; height: 14px; }
  #gridView.library-ui #btnTheme[data-action-label]::after { font-size: 10px; }
}

/* Shared background editor and edit-panel geometry across every runtime. */
.stage-popup.arthub-tool-popup { width: min(324px,calc(100vw - 16px)); }
.stage-popup.arthub-tool-popup > .col { width: 100%; max-width: 100%; }
.stage[data-stage-background="checker"]::before { display: none !important; }
.stage-popup .stage-background-options { display: grid; align-items: stretch; gap: 10px; width: min(300px, calc(100vw - 44px)); max-width: 100%; }
.stage-background-presets { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 6px; }
.stage-background-presets button:last-child { grid-column: 1 / -1; }
.stage-popup .stage-background-options button { min-height: 38px; white-space: nowrap; }
.stage-popup .stage-background-presets button[aria-pressed="true"] { color: var(--accent); border-color: var(--accent); background: var(--accent-dim-bg); }
.stage-background-label { color: var(--text-dim) !important; font-size: 12px; }
.stage-background-custom { display: grid; grid-template-columns: 44px minmax(0,1fr) auto; align-items: center; gap: 7px; }
.stage-background-custom input[type="color"] { width: 44px; height: 40px; padding: 3px; border: 1px solid var(--border2); border-radius: 9px; background: var(--panel2); cursor: pointer; box-sizing: border-box; }
.stage-background-custom input[type="text"] { width: 100%; min-width: 0; height: 40px; padding: 7px 9px; box-sizing: border-box; font: 12px var(--mono,Consolas,monospace); }
.stage-background-custom input[aria-invalid="true"] { border-color: #df7373; }
.stage-background-message { margin: 0; min-height: 2.8em; color: var(--text-dim); font-size: 11px; line-height: 1.5; }
.ctx-menu .menu-heading { padding: 8px 10px 4px; color: var(--text-faint); font-size: 10px; font-weight: 600; letter-spacing: .06em; }
.ctx-menu .menu-heading ~ .menu-heading { margin-top: 5px; border-top: 1px solid var(--border); }
.ctx-menu .arthub-popup-head,.stage-popup.arthub-tool-popup > .arthub-popup-head { position: sticky; top: 0; z-index: 1; background: var(--panel); }
html[data-gav-ui="clean"][data-stage-ui-ready="1"] body #floatPanel[aria-label] { z-index: 40; box-sizing: border-box; border-radius: 16px !important; }
html[data-gav-ui="clean"][data-stage-ui-ready="1"] body #floatPanel[aria-label] .rp-panel-head { flex: none; align-items: center; gap: 6px; padding: 10px 10px 0 !important; }
html[data-gav-ui="clean"][data-stage-ui-ready="1"] body #floatPanel[aria-label] .rp-panel-head .rp-tabs { min-width: 0; overflow-x: auto; flex-wrap: nowrap; scrollbar-width: none; }
html[data-gav-ui="clean"][data-stage-ui-ready="1"] body #floatPanel[aria-label] .rp-panel-head .rp-tabs::-webkit-scrollbar { display: none; }
html[data-gav-ui="clean"][data-stage-ui-ready="1"] body #floatPanel[aria-label] .rp-tabs button { flex: 1 0 50px; min-width: 50px; min-height: 36px; padding: 7px 9px !important; font-size: 12px; line-height: 1.3; }
html[data-gav-ui="clean"][data-stage-ui-ready="1"] body #floatPanel[aria-label] .rp-panel-close { display: inline-flex; align-items: center; justify-content: center; flex: 0 0 36px; width: 36px; height: 36px; padding: 0; }
html[data-gav-ui="clean"][data-stage-ui-ready="1"] body #floatPanel[aria-label] .rp-extra-tabs:empty { display: none; }
html[data-gav-ui="clean"][data-stage-ui-ready="1"] body #floatPanel[aria-label] .rp-page { min-height: 0; padding: 12px !important; overscroll-behavior: contain; }
html[data-gav-ui="clean"][data-stage-ui-ready="1"] body #floatPanel[aria-label] :is(.slot-row,.viewer-part-row) .eye { display: inline-flex; align-items: center; justify-content: center; flex: 0 0 32px; width: 32px; height: 32px; padding: 5px !important; }
html[data-gav-ui="clean"][data-stage-ui-ready="1"] body #floatPanel[aria-label] .eye > .arthub-icon { display: block; flex: none; width: 18px; height: 18px; }
@media (min-width: 721px) {
  html[data-gav-ui="clean"][data-stage-ui-ready="1"] body #floatPanel[aria-label] { left: auto !important; right: 12px !important; top: 80px !important; bottom: var(--stage-panel-bottom,72px) !important; width: 320px !important; height: auto !important; max-height: calc(100dvh - 92px) !important; transform: none !important; }
}
@media (max-width: 720px) {
  html[data-gav-ui="clean"][data-stage-ui-ready="1"] body #floatPanel[aria-label] { left: 8px !important; right: 8px !important; top: auto !important; bottom: var(--stage-panel-bottom,calc(140px + env(safe-area-inset-bottom))) !important; width: auto !important; height: min(48dvh,400px) !important; max-height: calc(100dvh - 150px) !important; transform: none !important; }
  html[data-gav-ui="clean"] body:has(#floatPanel.open) #toolStrip { display: none !important; }
  html[data-gav-ui="clean"][data-stage-ui-ready="1"] body #floatPanel[aria-label] .rp-tabs button { min-height: 40px; }
  html[data-gav-ui="clean"][data-stage-ui-ready="1"] body #floatPanel[aria-label] .rp-panel-close { flex-basis: 40px; width: 40px; height: 40px; }
  html[data-gav-ui="clean"][data-stage-ui-ready="1"] body #floatPanel[aria-label] :is(.slot-row,.viewer-part-row) .eye { flex-basis: 40px; width: 40px; height: 40px; }
  .stage-popup .stage-background-options button { min-height: 42px; }
}
