/* The same workbench, with comfortable controls and a steady rhythm on small screens. */
:root {--app-safe-left:env(safe-area-inset-left,0px);--app-safe-right:env(safe-area-inset-right,0px)}
#arcade-tooltip:not(.preview-tooltip) {pointer-events:none}
/* Notices belong above the current screen, with the same hard-edged chrome. */
.community-toast {z-index:1000;color:var(--on-accent);bottom:max(20px,env(safe-area-inset-bottom));max-height:40dvh;overflow:auto;pointer-events:auto;cursor:pointer}
.community-toast.error {background:var(--coral)}
.community-toast-region {position:fixed;left:50%;bottom:max(20px,env(safe-area-inset-bottom));translate:-50% 0;width:max-content;max-width:min(640px,90vw);z-index:1000;background:transparent;pointer-events:none}
.community-toast-region>.community-toast {position:relative;left:auto;bottom:auto;transform:none;max-width:100%}
.toast {border:2px solid var(--border);border-radius:var(--radius-inset);box-shadow:4px 4px 0 #000}
.toast-status {background:var(--mint);color:var(--on-accent)}
.toast-alert {background:var(--yellow);color:var(--on-accent)}
.toast-warning {background:var(--coral);color:var(--on-accent)}
/* Hide before the mutation observer clears active notices, avoiding even one
   painted frame during the fullscreen player's entrance. Keep colors elsewhere. */
body:has(.preview-station.station-playing[aria-modal=true]) :is(.toast-region,.community-toast-region) {display:none!important}
.preview-station[aria-modal=true]>:is(.toast-region,.community-toast-region) {position:absolute}
@media (max-width:760px) {
 html:has(body>.site-header):has(dialog[open]) {overflow:hidden}
 body:has(>.site-header) {
  -webkit-text-size-adjust:100%;
  text-size-adjust:100%;
 }
 body>.app-main,body>.app-main:has(>.arcade-workspace:not(.station-tools-route)) {
  width:calc(100% - max(24px,env(safe-area-inset-left)) - max(24px,env(safe-area-inset-right)));
  padding-bottom:max(24px,env(safe-area-inset-bottom));
 }
 .site-header {
  padding-top:max(14px,env(safe-area-inset-top));
  padding-left:max(12px,env(safe-area-inset-left));
  padding-right:max(12px,env(safe-area-inset-right));
 }
 .site-footer {padding-bottom:max(24px,env(safe-area-inset-bottom))}
 body:has(>.site-header) :is(button,.button,summary,.site-header nav a):not(.station-system-controls button) {
  -webkit-user-select:none;
  user-select:none;
  -webkit-tap-highlight-color:transparent;
  touch-action:manipulation;
 }
 /* Keep all four primary actions on one balanced row, including narrow phones. */
 #builder-panel .builder-toolbar {display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:8px}
 #builder-panel .builder-toolbar .labeled-action {width:auto;min-width:0;gap:7px}
 #builder-panel .builder-toolbar .action-caption {font-size:11px;line-height:1.3}
 #builder-panel .builder-editor>.panel {padding:16px}
 #builder-panel .contents-panel .panel-heading {margin-bottom:16px}
 #builder-panel .contents-tools {gap:8px;margin-bottom:12px}
 #builder-panel #details .advanced>summary {min-height:36px;padding:7px 0}
 #builder-panel #details .form-grid {gap:14px}
 #builder-panel #details .art-actions>:is(button,.button),
 #builder-panel #cart-details,
 #builder-panel .folder-line button,
 #builder-panel .explorer-tools button,
 #builder-panel .explorer-address>.explorer-button,
 #builder-panel .explorer-breadcrumbs button,
 #builder-panel .explorer-view-buttons button,
 #builder-panel .explorer-options>.explorer-button {min-height:44px}
 #builder-panel .explorer-address>.explorer-button {min-width:36px}
 #builder-panel .explorer-tools {gap:8px;padding:12px}
 #builder-panel .explorer-address {gap:4px;padding:12px 12px 8px}
 #builder-panel .explorer-breadcrumbs {min-width:calc(100% - 120px)}
 #builder-panel .builder-explorer input.explorer-search {height:44px;margin-top:4px}
 #builder-panel .explorer-options {padding:0 12px 12px;gap:8px}
 #builder-panel .explorer-options select {height:44px;min-height:44px;width:auto;min-width:94px}
 #builder-panel .explorer-view-buttons {display:grid;grid-template-columns:repeat(5,minmax(0,1fr));gap:3px}
 #builder-panel .explorer-view-buttons button {min-width:0;padding:6px 2px;font-size:11px;line-height:1.25;white-space:normal}
 #builder-panel .settings-height-resize {margin-left:-16px;margin-right:-16px;min-height:20px}
 #builder-panel .explorer-height-resize {min-height:20px}
 #builder-panel .explorer-files {scroll-padding:12px;overscroll-behavior:contain}
 .arcade-workspace .browse-grouping .community-check {min-height:44px;align-items:center}
 .arcade-workspace .browse-search input {text-overflow:ellipsis}
 .page-guide {padding-top:24px}
 .guide-steps {gap:24px}
 #device-panel .device-browser-help {padding:20px 18px}
 #device-panel .device-browser-actions {margin:20px 0;gap:16px}
 #device-panel .device-browser-actions .button {width:100%;min-height:48px}
 /* Dialogs stay within the visible viewport, including a raised software keyboard. */
 body:has(>.site-header) dialog {
  width:calc(100% - 32px);
  max-width:calc(100% - 32px);
  max-height:calc(100dvh - 32px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  margin:auto;
  padding:20px;
  overflow-y:auto;
  overscroll-behavior:contain;
  scroll-padding-block:20px;
 }
 body:has(>.site-header) dialog>h2 {padding-right:42px;margin-bottom:20px}
 body:has(>.site-header) dialog .dialog-close {width:44px;height:44px;min-height:44px;right:10px;top:10px}
 body:has(>.site-header) dialog .actions {gap:12px}
 body:has(>.site-header) dialog .actions>button {min-height:44px}
 .toast-region {right:16px;bottom:max(16px,env(safe-area-inset-bottom));width:calc(100% - 32px)}
 .toast {padding:12px 14px}
 .toast button {min-width:36px;min-height:36px}
}
@media (min-width:360px) and (max-width:560px) {
 .site-header {--header-icon-size:44px}
}
@media (max-width:359px) {
 .site-header {--header-icon-size:40px;padding-inline:8px;gap:4px}
 .site-header nav,.site-header>.header-device-controls {gap:4px}
 .site-header .brand-badge {width:32px;height:32px}
 .site-header :is(nav a,#community-account,#connection-menu>summary,#theme-toggle) {transition:background-color .1s,color .1s}
}
@media (max-width:550px) {
 /* Preserve the artwork as an anchor while bringing the editable fields closer. */
 #builder-panel #details .cart-overview .detail-art-column .artwork-card {display:grid;grid-template-columns:128px minmax(0,1fr);align-items:center;gap:16px;width:100%}
 #builder-panel #details .cart-overview .detail-art-column .art-picker,
 #builder-panel #details .cart-overview .detail-art-column .artwork-card>.asset-image,
 #builder-panel #details .cart-overview .detail-art-column .cover-placeholder {width:128px;height:128px;min-width:0}
 #builder-panel #details .cart-overview .detail-art-column .asset-image>img {width:100%;height:100%;max-width:100%}
 #builder-panel #details .cart-overview {gap:20px}
 #builder-panel #details .cart-overview .detail-art-column {display:block}
 #builder-panel #details .cart-overview .art-actions {flex-direction:column;gap:12px}
 #builder-panel #details .cart-overview .art-actions>:is(button,.button) {width:100%;font-size:12px;padding:8px 6px}
}
@media (pointer:coarse) and (max-width:850px) {
 /* Safari zooms focused form fields below 16px; retain page scale while typing. */
 body:has(>.site-header) :is(input,textarea,select):not([type=checkbox]):not([type=radio]):not([type=range]):not([type=file]):not([type=color]) {
  font-size:16px!important;
  line-height:1.35;
 }
 body:has(>.site-header) :is(input,select):not([type=checkbox]):not([type=radio]):not([type=range]):not([type=file]):not([type=color]) {min-height:44px}
 body:has(>.site-header) textarea {scroll-margin-block:24px}
}

/* The cart tray opens the same file guide as a page on compact screens. */
#drop-help .cart-help-heading,#drop-help .cart-help-content {display:contents}
#drop-help .cart-help-heading h2 {padding-right:42px}
#drop-help .cart-help-builder {display:none}
@media (max-width:850px), (max-width:1100px) and (max-height:500px) {
 #drop-bubble :is(#drop-add,#drop-info,.cart-stats-slot) {display:none}
 #drop-bubble .drop-open,#drop-bubble.has-document .drop-open {padding-inline:34px}
 html:has(#drop-help[open]) {overflow:hidden}
 body:has(>.site-header) #drop-help {
  position:fixed;inset:0;margin:0;width:100%;max-width:none;height:100dvh;max-height:none;
  padding:0;border:0;border-radius:0;box-shadow:none;overflow:hidden;
  background:var(--bg);color:var(--ink);overscroll-behavior:none;
 }
 #drop-help[open] {display:grid;grid-template-rows:auto minmax(0,1fr) auto}
 #drop-help .cart-help-heading {
  display:flex;align-items:center;justify-content:space-between;gap:16px;
  padding:max(12px,env(safe-area-inset-top)) max(20px,env(safe-area-inset-right)) 12px max(20px,env(safe-area-inset-left));
  border-bottom:2px solid var(--border);background:var(--panel);
 }
 #drop-help .cart-help-heading h2 {margin:0;padding:0;font-size:22px;line-height:1.2;outline:none}
 body:has(>.site-header) #drop-help .dialog-close {
  position:static;flex:none;min-width:44px;width:44px;height:44px;min-height:44px;border-radius:50%;
 }
 #drop-help .cart-help-content {
  display:block;min-height:0;overflow-y:auto;overscroll-behavior:contain;
  padding:22px max(20px,env(safe-area-inset-right)) 24px max(20px,env(safe-area-inset-left));
  scrollbar-gutter:stable;scroll-padding-block:20px;
 }
 #drop-help .cart-help-content>:first-child {margin-top:0}
 #drop-help .cart-help-content>:last-child {margin-bottom:0}
 #drop-help .cart-help-content h3 {margin-top:28px}
 #drop-help .file-formats {margin-block:24px}
 #drop-help .file-formats>div {grid-template-columns:90px minmax(0,1fr);gap:14px}
 #drop-help .file-formats dd {font-size:14px;overflow-wrap:anywhere}
 #drop-help .cart-help-content details {margin-top:22px}
 #drop-help .cart-help-content summary {min-height:44px}
 #drop-help .actions {
  display:grid;grid-template-columns:1fr 1fr;align-items:stretch;gap:12px;margin:0;
  padding:14px max(20px,env(safe-area-inset-right)) max(18px,env(safe-area-inset-bottom)) max(20px,env(safe-area-inset-left));
  border-top:2px solid var(--border);background:var(--panel);
 }
 #drop-help .actions>button {min-width:0;min-height:46px;margin:0;font-size:13px;padding:10px 8px;border-radius:999px}
 #drop-help .cart-help-builder {display:flex;gap:8px;align-items:center;justify-content:center}
 #drop-help .cart-help-builder .ui-icon {width:19px;height:19px;flex:none}
 #drop-help #drop-help-close {display:none}
}
