/* Classic page layout: full-width grid, wide flat sidebars, and the stage with floating cards. */

/* ---------- Grid: use the whole width, give the sidebars room ---------- */
body.field-host main#studio { max-width: none; margin: 0; gap: 24px; padding: 0 24px 22px; grid-template-columns: 340px minmax(0, 1fr) 340px; }
body.field-host .studio-intro { max-width: none; padding: 20px 30px; }
@media (max-width: 1500px) { body.field-host main#studio { grid-template-columns: 300px minmax(0, 1fr) 300px; gap: 18px; } }
@media (max-width: 1100px) { body.field-host main#studio { grid-template-columns: 260px minmax(0, 1fr) 260px; gap: 12px; padding: 0 14px 14px; } }

/* ---------- Sidebars: one glass slab, flat sections separated by hairlines ---------- */
.field-host .left-panel.float-panel, .field-host .right-panel.float-panel { padding: 6px 22px 26px; overflow-y: auto; overscroll-behavior: contain; }
.field-host .float-panel .panel {
  border: 0; border-top: 1px solid var(--sf-hairline); border-radius: 0; background: transparent; box-shadow: none;
  padding: 22px 0 24px; margin: 0;
}
.field-host .float-panel > .panel:first-child, .field-host .float-panel > .library-tabs + .panel { border-top: 0; }
.field-host .float-panel h2 { margin: 0 0 14px; font-size: 11px; font-weight: 700; letter-spacing: 0.08em; color: var(--sf-fg); }
.field-host .float-panel h2 > .icon { width: 15px; height: 15px; color: var(--sf-muted); }
.field-host .float-panel h2 small, .field-host .float-panel h2 > span { color: var(--sf-muted); font-weight: 500; letter-spacing: 0; }
.field-host .float-panel .small-note, .field-host .float-panel .library-note, .field-host .float-panel .privacy-note { font-size: 12px; line-height: 1.55; color: var(--sf-muted); }
.field-host .library-tabs { position: sticky; top: 0; z-index: 2; margin: 14px 0 8px; outline: 8px solid var(--sf-float); outline-offset: 0; }
.field-host .device-grid, .field-host .template-grid { gap: 10px; }
.field-host .device-grid button { height: 92px; }
.field-host .device-grid .device-thumb { height: 52px; }
.field-host .divider { margin: 18px 0; }
.field-host .left-panel::-webkit-scrollbar, .field-host .right-panel::-webkit-scrollbar { width: 8px; }

/* ---------- Stage ---------- */
.field-host .workspace.classic-stage {
  position: relative; display: block; height: calc(100dvh - 162px); min-height: 560px; overflow: hidden; border-radius: 20px; isolation: isolate;
}
.classic-stage .workspace-top { position: absolute; z-index: 3; top: 12px; left: 16px; width: auto; padding: 0; gap: 10px; }
.classic-stage .workspace-top .preview-badge { background: var(--sf-btn); }
.classic-stage .privacy-note { position: absolute; z-index: 3; left: 16px; bottom: 12px; margin: 0; max-width: 40%; }
.classic-stage .artboard-card { position: absolute; z-index: 2; user-select: none; touch-action: none; }
.classic-stage .preview-wrap { margin: 0; width: auto; }
.classic-stage .preview-wrap.is-active { box-shadow: 0 0 0 2px var(--sf-fg), var(--sf-shadow-lift); border-radius: 22px; }
.classic-stage .preview-wrap .upload-hint { bottom: -58px; }
.classic-stage .artboard-card.output { border-radius: 14px; background: var(--sf-face); box-shadow: 0 0 0 1px var(--sf-hairline), var(--sf-shadow-e2); }
.classic-stage .artboard-card.output::before { display: none; }
.classic-stage .artboard-card.output canvas { display: block; width: 100%; height: 100%; border-radius: 13px; pointer-events: none; }
.classic-stage .artboard-card.output:hover { box-shadow: 0 0 0 1px color-mix(in oklab, var(--sf-fg) 40%, transparent), var(--sf-shadow-lift); }
.classic-stage .artboard-card.is-dragging { box-shadow: 0 0 0 2px var(--sf-fg), var(--sf-shadow-e3); transition: none; }
.classic-stage .artboard-tag { position: absolute; left: 0; top: -24px; font-size: 11px; font-weight: 500; color: var(--sf-muted); white-space: nowrap; pointer-events: none; }
.classic-stage .artboard-card:is(.is-active, :hover, :focus-within) .artboard-tag { color: var(--sf-fg); }
.field-host .card-remove {
  position: absolute; z-index: 4; top: -30px; right: 0; width: 24px; height: 24px; min-height: 0; padding: 0; border-radius: 8px;
  font-size: 16px; line-height: 1; color: var(--sf-muted); background: transparent; border-color: transparent; box-shadow: none; opacity: 0;
  transition: opacity 120ms ease, color 120ms ease, background 120ms ease;
}
.field-host .artboard-card:is(:hover, :focus-within) .card-remove, .field-host .card-remove:focus-visible { opacity: 1; }
.field-host .card-remove:disabled { display: none; }
.field-host .card-remove:hover { color: var(--sf-fg); background: var(--sf-btn-hover); }

/* Bottom dock with the media tools, timeline and export bar. */
/* One compact row: tools | timeline (while a video plays) | export, with the summary underneath.
   The #studio prefix out-ranks the old `.workspace:has(#uploadHint) .media-tools` spacing rule. */
#studio .classic-stage .stage-dock {
  position: absolute; z-index: 5; left: 50%; bottom: 16px; transform: translateX(-50%);
  display: grid; grid-template-columns: auto minmax(0, auto) auto; grid-template-areas: "tools timeline export" "summary summary summary";
  align-items: center; gap: 4px 18px; width: min(calc(100% - 32px), 960px); padding: 10px 14px 10px 16px; border-radius: 18px;
}
#studio .classic-stage .stage-dock .export-bar { justify-self: end; }
#studio .classic-stage .stage-dock .export-bar .resolution-picker { flex: 0 0 auto; min-width: 160px; }
#studio .classic-stage .stage-dock .export-label .icon { display: none; }
#studio .classic-stage .stage-dock .export-bar > button, #studio .classic-stage .stage-dock .export-bar .export-label { flex: 0 0 auto; }
#studio .classic-stage .stage-dock .export-bar button, #studio .classic-stage .stage-dock .export-bar #resolutionTrigger { min-height: 40px; padding: 8px 16px; }
#studio .classic-stage .stage-dock .export-bar #exportAll { gap: 6px; }
#studio .classic-stage .stage-dock .export-bar #exportAll .count { display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px; background: var(--sf-fg); color: var(--sf-bg); font-size: 10.5px; font-weight: 600; }
#studio .classic-stage .stage-dock .export-bar #exportAll:disabled { opacity: .6; }
#studio .classic-stage .stage-dock .media-tools { gap: 2px; justify-content: flex-start; }
#studio .classic-stage .stage-dock .media-tools button { padding: 6px 9px; min-height: 32px; }
#studio .classic-stage .stage-dock { padding: 8px 10px 8px 10px; gap: 4px 12px; }
#studio .classic-stage .stage-dock .media-tools { grid-area: tools; display: flex; margin: 0; min-height: 0; gap: 2px; flex-wrap: nowrap; }
#studio .classic-stage .stage-dock .media-tools:not(:has(button:not([hidden]))) { display: none; }
#studio .classic-stage .stage-dock .media-tools button { color: var(--sf-fg); font-size: 12.75px; white-space: nowrap; }
/* Reset lives in the dock as an icon button, like the reference's preset reset. */
#studio .classic-stage .stage-dock .media-tools .dock-reset { width: 32px; min-width: 32px; height: 32px; padding: 0; margin-right: 6px; border: 1px solid var(--sf-hairline); border-radius: 10px; background: var(--sf-btn); color: var(--sf-fg); box-shadow: var(--sf-shadow-e1), var(--sf-hl-top); }
#studio .classic-stage .stage-dock .media-tools .dock-reset svg { width: 15px; height: 15px; }
#studio .classic-stage .stage-dock .media-tools .dock-reset:hover { background: var(--sf-btn-hover); border-color: color-mix(in oklab, var(--sf-fg) 22%, transparent); }
#studio .classic-stage .stage-dock .timeline { grid-area: timeline; display: flex; margin: 0; width: 220px; }
#studio .classic-stage .stage-dock .timeline[hidden] { display: none; }
#studio .classic-stage .stage-dock .export-bar {
  grid-area: export; display: flex; flex-wrap: nowrap; align-items: center; gap: 8px;
  width: auto; margin: 0; padding: 0; background: transparent; border: 0; box-shadow: none;
}
#studio .classic-stage .stage-dock .export-bar .export-label { margin: 0 4px 0 2px; }
/* The export summary is a caption under the dock, not inside it. */
#studio .classic-stage .export-summary { position: absolute; z-index: 3; left: 50%; bottom: 14px; transform: translateX(-50%); margin: 0; white-space: nowrap; font-size: 11px; line-height: 1.4; color: var(--sf-muted); text-align: center; }
#studio .classic-stage .stage-dock { bottom: 44px; grid-template-areas: "tools timeline export"; }
/* The page fits the viewport: header + intro + main padding, no scroll to reach the dock caption. */
body.field-host .workspace.classic-stage, body.field-host .left-panel.float-panel, body.field-host .right-panel.float-panel { height: calc(100dvh - 216px); }
/* The add button and its menu sit above every card, whatever z-index raising has given the cards. */
.classic-stage .stage-add { position: absolute; z-index: 1000; right: 16px; top: 12px; }
.classic-stage .stage-add-menu { position: absolute; z-index: 1001; right: 16px; top: 56px; display: grid; gap: 3px; width: 224px; padding: 6px; border-radius: 16px; }
.classic-stage .stage-add-menu button { display: flex; align-items: center; justify-content: space-between; gap: 10px; width: 100%; min-height: 40px; padding: 6px 12px; border-radius: 10px; background: transparent; border-color: transparent; box-shadow: none; text-align: left; }
.classic-stage .stage-add-menu button:hover, .classic-stage .stage-add-menu button:focus-visible { background: var(--sf-btn-hover); }
.classic-stage .stage-add-menu strong { font-weight: 600; font-variant-numeric: tabular-nums; }
.classic-stage .stage-add-menu small { color: var(--sf-muted); font-size: 11px; }

/* Deferred to v2 (hidden, the features stay in the app): Company signature and custom mockup import. */
.field-host .right-panel .panel:has(#appName), .field-host #customMockupPanel { display: none; }
.field-host .float-panel > .library-tabs + .panel + .panel { border-top: 0; }

/* Toasts sit above the dock instead of on it. */
body.field-host:has(.classic-stage) #toast { bottom: 120px; }

@media (max-width: 850px) {
  .field-host .workspace.classic-stage { height: 70dvh; min-height: 480px; }
  .classic-stage .stage-dock { width: calc(100% - 24px); }
}

/* Narrower stages: drop the "EXPORT" caption and tighten the picker so the dock still fits on one row. */
@media (max-width: 1500px) {
  #studio .classic-stage .stage-dock { gap: 4px 10px; }
  #studio .classic-stage .stage-dock .export-bar .export-label { display: none; }
  #studio .classic-stage .stage-dock .export-bar .resolution-picker { min-width: 0; }
  #studio .classic-stage .stage-dock .export-bar #resolutionTrigger { padding: 8px 12px; }
}
/* The dock keeps reset and playback only: screens are dropped onto the mockup or browsed from its hint. */
#studio .classic-stage .stage-dock .media-tools :is(#sample, #replace) { display: none; }
#studio .classic-stage .stage-dock { width: max-content; max-width: min(calc(100% - 32px), 960px); }

/* Export scale (1x-4x) and format (PNG/JPG/PDF) apply to image exports; video stays 1x WebM. */
#studio .classic-stage .stage-dock .export-bar :is(.export-scale, .export-format) { flex: 0 0 auto; padding: 3px; }
#studio .classic-stage .stage-dock .export-bar :is(.export-scale, .export-format) button { flex: 0 0 auto; min-width: 36px; min-height: 32px; padding: 4px 8px; font-variant-numeric: tabular-nums; }
#studio .classic-stage .stage-dock .export-bar .export-format button { font-size: 11px; letter-spacing: 0.02em; }
/* The format buttons are the image export actions, so the separate Image button is gone. */
#studio .classic-stage .stage-dock .export-bar #exportImage { display: none; }

/* Below 1500px the export bar wraps onto two rows instead of overflowing the stage. */
@media (max-width: 1500px) {
  #studio .classic-stage .stage-dock { max-width: calc(100% - 32px); }
  #studio .classic-stage .stage-dock .export-bar { flex-wrap: wrap; justify-content: center; row-gap: 8px; }
}

/* One typeface throughout: the editorial serif accents in headlines use the UI font instead. */
.field-host .studio-intro h1 em, .field-host #liveShareTitle em { font-family: inherit; font-style: normal; font-weight: inherit; }
.field-host dialog h1 { font-family: inherit; }
/* Panel notes breathe before the control that follows them. */
.field-host .float-panel .small-note + :is(button, label, .segments, .safe-margin-grid, .screen-fit-actions) { margin-top: 14px; }
/* The stage keeps to the work: the privacy line lives in the help dialog instead. */
.classic-stage .privacy-note { display: none; }

/* Dock stack: the summary caption above the glass bar, the bar flush with the sidebar bottoms. */
#studio .classic-stage .dock-stack { position: absolute; z-index: 5; left: 50%; bottom: 0; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 8px; width: max-content; max-width: min(calc(100% - 32px), 960px); }
#studio .classic-stage .dock-stack .stage-dock { position: static; left: auto; bottom: auto; transform: none; max-width: 100%; }
#studio .classic-stage .dock-stack .export-summary { position: static; left: auto; bottom: auto; transform: none; margin: 0; }
/* The dock stack and the badge row float above the cards, whatever raising the cards have had (the add menu stays on top of all). */
#studio .classic-stage .dock-stack, .classic-stage .workspace-top { z-index: 900; }
/* Screen Fit always shows its full controls; the empty-state hint is retired. */
.field-host #screenFit .screen-fit-empty { display: none; }

/* Custom size row at the foot of the artboard menu: W x H in pixels. */
.classic-stage .stage-add-custom { display: flex; align-items: center; gap: 6px; margin-top: 4px; padding: 10px 6px 4px; border-top: 1px solid var(--sf-hairline); }
.classic-stage .stage-add-custom input { width: 0; flex: 1 1 0; min-height: 34px; padding: 6px 8px; text-align: center; font-size: 12.5px; font-variant-numeric: tabular-nums; }
.classic-stage .stage-add-custom input::-webkit-outer-spin-button, .classic-stage .stage-add-custom input::-webkit-inner-spin-button { appearance: none; margin: 0; }
.classic-stage .stage-add-custom .times { color: var(--sf-muted); font-size: 12px; }
.classic-stage .stage-add-menu .stage-add-custom button { width: auto; min-height: 34px; padding: 6px 12px; justify-content: center; color: var(--sf-fg); font-weight: 600; background: var(--sf-btn); border: 1px solid var(--sf-hairline); border-radius: 10px; box-shadow: var(--sf-shadow-e1), var(--sf-hl-top); }
.classic-stage .stage-add-menu .stage-add-custom button:hover { background: var(--sf-btn-hover); }
.classic-stage .stage-add-custom.is-invalid input { border-color: oklch(0.72 0.17 25); animation: custom-shake 240ms ease; }
@keyframes custom-shake { 25% { transform: translateX(-3px); } 75% { transform: translateX(3px); } }
/* Playback timeline: the slider shares the row with the timecode instead of overflowing into the export controls. */
#studio .classic-stage .stage-dock .timeline { width: 190px; min-width: 190px; gap: 8px; }
#studio .classic-stage .stage-dock .timeline .house-slider { flex: 1 1 auto; width: auto; min-width: 70px; height: 16px; }
#studio .classic-stage .stage-dock .timeline .house-slider-fill { width: calc(8px + var(--slider-progress) * (100% - 16px) + 6px); }
#studio .classic-stage .stage-dock .timeline .house-slider input[type=range]::-webkit-slider-thumb { width: 14px; height: 14px; margin-top: 1px; border-width: 2.5px; }
#studio .classic-stage .stage-dock .timeline .house-slider input[type=range]::-moz-range-thumb { width: 14px; height: 14px; border-width: 2.5px; }
#studio .classic-stage .stage-dock .timeline output { font-size: 11px; }
#studio .classic-stage .stage-dock .timeline output { flex: none; white-space: nowrap; }
/* Playback is an icon button in the dock: the label text drives the glyph via data-state. */
#studio .classic-stage .stage-dock .media-tools #play { width: 32px; min-width: 32px; height: 32px; padding: 0; font-size: 0; border-radius: 10px; border: 1px solid var(--sf-hairline); background: var(--sf-btn); color: var(--sf-fg); box-shadow: var(--sf-shadow-e1), var(--sf-hl-top); }
#studio .classic-stage .stage-dock .media-tools #play:hover { background: var(--sf-btn-hover); }
#studio .classic-stage .stage-dock .media-tools #play::before { content: ''; width: 13px; height: 13px; background: currentColor; -webkit-mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path d='M7 4.5v15l12-7.5z'/></svg>") center / contain no-repeat; mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path d='M7 4.5v15l12-7.5z'/></svg>") center / contain no-repeat; }
#studio .classic-stage .stage-dock .media-tools #play[data-state=playing]::before { -webkit-mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path d='M6 4h4v16H6zM14 4h4v16h-4z'/></svg>"); mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path d='M6 4h4v16H6zM14 4h4v16h-4z'/></svg>"); }
/* With a video on the screen the export is the WebM: image format and scale controls step aside. */
#studio .classic-stage .stage-dock .export-bar:has(#exportImage[data-video="1"]) :is(.export-format, .export-scale) { display: none; }

/* Narrower screens: tighter sidebars and a dock whose buttons keep their natural size. */
@media (max-width: 1500px) {
  .field-host .left-panel.float-panel, .field-host .right-panel.float-panel { padding: 4px 16px 20px; }
  .field-host .float-panel .panel { padding: 18px 0 20px; }
  .field-host .float-panel h2 { margin-bottom: 12px; }
  .field-host .library-tabs { margin: 10px 0 6px; outline-width: 6px; }
}
@media (max-width: 1100px) {
  body.field-host main#studio { padding: 0 10px 10px; gap: 10px; }
  .field-host .left-panel.float-panel, .field-host .right-panel.float-panel { padding: 2px 12px 16px; }
  .field-host .float-panel .panel { padding: 16px 0 18px; }
  .field-host .device-grid, .field-host .template-grid { gap: 8px; }
  #studio .classic-stage .stage-dock .export-bar > *, #studio .classic-stage .stage-dock .export-bar button, #studio .classic-stage .stage-dock .export-bar #resolutionTrigger { width: auto; flex: 0 0 auto; }
  #studio .classic-stage .stage-dock .export-bar :is(.export-scale, .export-format) > button { width: auto; flex: 0 0 auto; }
}
@media (max-width: 850px) {
  .field-host .left-panel.float-panel, .field-host .right-panel.float-panel { padding: 2px 12px 14px; }
  #studio .classic-stage .dock-stack { max-width: calc(100% - 16px); }
}

/* ---------- Compact layout (tablet and phone): both decks side by side, sections collapse behind their headings ---------- */
@media (max-width: 850px) {
  body.field-host main#studio { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; padding: 0 10px 16px; }
  body.field-host .studio-intro { padding: 16px 12px 8px; }
  body.field-host .workspace.classic-stage { grid-column: 1 / -1; grid-row: 1; height: 68dvh; min-height: 460px; }
  body.field-host .left-panel.float-panel, body.field-host .right-panel.float-panel { grid-row: 2; height: auto; max-height: none; overflow: visible; padding: 2px 12px 12px; align-self: start; }
  .field-host .float-panel .panel { padding: 12px 0 14px; }
  .field-host .float-panel .panel > h2.is-toggle { cursor: pointer; margin: 0; padding: 4px 0; user-select: none; -webkit-tap-highlight-color: transparent; }
  .field-host .float-panel .panel > h2.is-toggle:focus-visible { outline: 2px solid var(--sf-fg); outline-offset: 4px; border-radius: 4px; }
  .field-host .float-panel .panel > h2.is-toggle::after { content: ''; flex: none; margin-left: auto; width: 14px; height: 14px; background: var(--sf-muted); transition: transform 160ms ease;
    -webkit-mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'><path d='m6 9 6 6 6-6'/></svg>") center / contain no-repeat; mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'><path d='m6 9 6 6 6-6'/></svg>") center / contain no-repeat; }
  .field-host .float-panel .panel > h2.is-toggle:has(> small)::after { margin-left: 6px; }
  .field-host .float-panel .panel > h2.is-toggle[aria-expanded=true]::after { transform: rotate(180deg); }
  .field-host .float-panel .panel:not(.is-collapsed) > h2.is-toggle { margin-bottom: 12px; }
  /* #studio out-ranks the id-based layout rules on grids such as #shadows and #zooms. */
  #studio .float-panel .panel.is-collapsed > :not(.section-toggle) { display: none !important; }
  .field-host .library-tabs { top: 0; margin: 8px 0 4px; }
  .field-host .device-grid, .field-host .template-grid { grid-template-columns: repeat(3, 1fr); gap: 6px; }
  .field-host .device-grid button { height: 78px; font-size: 10px; }
  .field-host .device-grid .device-thumb { height: 42px; }
  .field-host .swatches { justify-content: flex-start; gap: 8px; }
  .field-host .swatches button, .field-host .swatches .color-picker { width: 26px; height: 26px; min-height: 26px; }
  /* Dock: natural-size controls wrapped into centred rows; the summary stays short. */
  #studio .classic-stage .dock-stack { max-width: calc(100% - 12px); gap: 6px; }
  #studio .classic-stage .stage-dock { padding: 8px; gap: 6px 8px; grid-template-columns: auto minmax(0, 1fr); grid-template-areas: "tools export" "timeline timeline"; }
  #studio .classic-stage .stage-dock .media-tools { grid-area: tools; }
  #studio .classic-stage .stage-dock .timeline { grid-area: timeline; width: 100%; min-width: 0; }
  #studio .classic-stage .stage-dock .timeline[hidden] { display: none; }
  #studio .classic-stage .stage-dock .export-bar { grid-area: export; justify-self: stretch; justify-content: flex-end; gap: 6px; row-gap: 6px; }
  #studio .classic-stage .stage-dock .export-bar button, #studio .classic-stage .stage-dock .export-bar #resolutionTrigger { min-height: 36px; padding: 6px 12px; }
  #studio .classic-stage .stage-dock .export-bar :is(.export-scale, .export-format) > button { min-height: 30px; min-width: 34px; padding: 4px 7px; }
  #studio .classic-stage .export-summary { font-size: 10.5px; white-space: normal; text-align: center; }
  .classic-stage .stage-add { right: 10px; top: 10px; }
  .classic-stage .workspace-top { left: 10px; top: 10px; }
  .classic-stage .stage-add-menu { right: 10px; width: min(224px, calc(100vw - 40px)); }
  .field-host .color-popover { width: min(236px, calc(100vw - 16px)); }
}
/* Tighter still on compact screens: less side padding, shorter sections, closer headings and notes. */
@media (max-width: 1100px) {
  .field-host .left-panel.float-panel, .field-host .right-panel.float-panel { padding: 2px 10px 12px; }
  .field-host .float-panel .panel { padding: 12px 0 14px; }
  .field-host .float-panel h2 { margin-bottom: 10px; }
  .field-host .float-panel .small-note, .field-host .float-panel .library-note { font-size: 11.5px; line-height: 1.45; }
  .field-host .float-panel .small-note + :is(button, label, .segments, .safe-margin-grid, .screen-fit-actions) { margin-top: 10px; }
  .field-host .divider { margin: 12px 0; }
}
@media (max-width: 850px) {
  .field-host .left-panel.float-panel, .field-host .right-panel.float-panel { padding: 0 10px 10px; border-radius: 16px; }
  .field-host .float-panel .panel { padding: 10px 0 12px; }
  .field-host .float-panel .panel > h2.is-toggle { padding: 6px 0; }
  .field-host .float-panel .panel:not(.is-collapsed) > h2.is-toggle { margin-bottom: 8px; }
  .field-host :is(#presetTrigger, #safePresetTrigger) { padding: 8px 10px; }
  .field-host .background-modes button, .field-host .segments button { min-height: 30px; font-size: 11.5px; }
  .field-host .emojis button { width: 24px; height: 24px; min-height: 24px; font-size: 13px; }
}
/* Collapsed headings: counts shrink before the chevron does, and a collapsed Screen Fit hides its hint too. */
@media (max-width: 850px) {
  .field-host .float-panel .panel > h2.is-toggle { min-width: 0; gap: 6px; }
  .field-host .float-panel .panel > h2.is-toggle small { flex: 0 1 auto; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
}
/* Compact screens: a shorter stage and a one-line intro bring the control decks up into the first screen. */
@media (max-width: 850px) {
  body.field-host .workspace.classic-stage { height: 62dvh; min-height: 460px; }
  body.field-host .left-panel.float-panel, body.field-host .right-panel.float-panel { margin-top: 14px; }
  body.field-host .studio-intro { padding: 10px 12px 4px; }
  body.field-host .studio-intro h1 { font-size: 22px; margin-bottom: 4px; }
  body.field-host .studio-intro .intro-copy > p, body.field-host .intro-steps, body.field-host .intro-details { display: none; }
}
/* The export summary caption is retired: the dock itself states format, size and scale. */
#studio .classic-stage .export-summary { display: none; }
/* Compact screens: the dock is pinned to the bottom of the screen; the page ends with room for it. */
@media (max-width: 850px) {
  #studio .classic-stage .dock-stack { position: fixed; left: 50%; bottom: max(10px, env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 950; width: max-content; max-width: calc(100vw - 16px); }
  body.field-host main#studio { padding-bottom: 100px; }
  body.field-host:has(.classic-stage) #toast { bottom: 110px; }
}

/* Screen Fit actions: the two buttons share a row and a style. */
.field-host .screen-fit-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.field-host .screen-fit-actions > button { flex: 1 1 auto; padding: 9px 12px; font-size: 12.25px; letter-spacing: -0.01em; white-space: nowrap; }
/* The closing tip line in the right panel is retired. */
.field-host .right-panel .tip { display: none; }
/* Touch screens: bigger handles, and the intro block gives its space to the stage on compact layouts. */
@media (pointer: coarse) {
  .field-host .artboard-card .move-handle { width: 68px; height: 34px; top: -18px; }
  .field-host .artboard-card .resize-handle { width: 40px; height: 40px; }
  .field-host .artboard-card .card-remove { opacity: 1; width: 30px; height: 30px; }
}
@media (max-width: 850px) {
  body.field-host .studio-intro { display: none; }
}

/* Media-info labels follow the theme's muted token (the theme sheet's fixed grey fell to 4.5:1 in light mode). */
.field-host dt { color: var(--sf-muted); }
/* Picker captions use the theme's muted token in every state (the fixed grey dipped under 4.5:1 while open). */
.field-host :is(#presetTrigger, #safePresetTrigger) small { color: var(--sf-muted); }

/* ---------- Tablet tool strip and bottom sheets (850px and below) ---------- */
.field-host .tool-strip, .field-host .sheet-head, .field-host .sheet-backdrop { display: none; }
@media (max-width: 850px) {
  body.tools-mode main#studio { grid-template-columns: minmax(0, 1fr); padding-bottom: 0; }
  body.tools-mode .workspace.classic-stage { grid-column: 1; height: calc(100dvh - 76px - 110px); min-height: 400px; }
  body.tools-mode .left-panel.float-panel, body.tools-mode .right-panel.float-panel { display: none; margin: 0; }
  body.tools-mode .left-panel.float-panel.is-sheet, body.tools-mode .right-panel.float-panel.is-sheet {
    display: block; position: fixed; left: 8px; right: 8px; bottom: 96px; max-height: min(64dvh, 600px); overflow: auto; z-index: 960;
    padding: 0 14px 14px; border-radius: 18px; overscroll-behavior: contain;
  }
  body[data-open-tool="background"] .right-panel > .panel:not([data-tool="background"]),
  body[data-open-tool="style"] .right-panel > .panel:not([data-tool="style"]),
  body[data-open-tool="screen"] .right-panel > .panel:not([data-tool="screen"]) { display: none; }
  body.tools-mode .is-sheet .library-tabs { top: 48px; }
  .field-host .sheet-head { position: sticky; top: 0; z-index: 3; display: flex; align-items: center; justify-content: space-between; padding: 12px 0 8px; margin: 0 0 6px; background: var(--sf-float); border-bottom: 1px solid var(--sf-hairline); }
  .field-host .sheet-head strong { font-size: 14px; font-weight: 600; }
  .field-host .sheet-head .sheet-done { min-height: 32px; padding: 6px 14px; font-weight: 600; }
  .field-host .sheet-backdrop { display: block; position: fixed; inset: 0; z-index: 955; background: rgb(0 0 0 / .32); }
  .field-host .sheet-backdrop[hidden] { display: none; }
  /* The dock is the tool strip: reset and play on the left, tools on the right, export as a sheet. */
  /* No transform on the pinned stack: a transformed ancestor would become the containing block of the fixed export sheet. */
  body.tools-mode #studio .classic-stage .dock-stack { left: 8px; right: 8px; transform: none; width: auto; max-width: none; align-items: center; }
  body.tools-mode #studio .classic-stage .stage-dock { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; padding: 6px; }
  body.tools-mode #studio .classic-stage .stage-dock .media-tools { margin-right: 2px; }
  body.tools-mode #studio .classic-stage .stage-dock .timeline { flex: 1 1 100%; order: 3; width: auto; min-width: 0; }
  body.tools-mode #studio .classic-stage .stage-dock .export-bar { display: none; }
  body.tools-mode #studio .classic-stage .stage-dock .export-bar.is-sheet {
    display: flex; position: fixed; left: 8px; right: auto; bottom: 96px; z-index: 960; flex-wrap: wrap; align-items: center; justify-content: flex-start; gap: 10px;
    width: calc(100vw - 16px); max-width: none; padding: 0 14px 14px; border-radius: 18px; background: var(--sf-float); border: 1px solid var(--sf-hairline); box-shadow: var(--sf-shadow-e3); -webkit-backdrop-filter: var(--sf-blur); backdrop-filter: var(--sf-blur);
  }
  body.tools-mode #studio .classic-stage .stage-dock .export-bar.is-sheet .sheet-head { flex: 1 1 100%; }
  body.tools-mode #studio .classic-stage .stage-dock .export-bar.is-sheet :is(#exportVideo, #exportAll) { flex: 1 1 40%; min-height: 44px; }
  body.tools-mode #studio .classic-stage .stage-dock .export-bar.is-sheet .resolution-picker { flex: 1 1 100%; }
  body.tools-mode #studio .classic-stage .stage-dock .export-bar.is-sheet #resolutionTrigger { width: 100%; justify-content: space-between; }
  .field-host .tool-strip { display: flex; gap: 2px; }
  #studio .tool-strip .tool { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; min-width: 60px; min-height: 48px; padding: 5px 8px; border: 0; border-radius: 12px; background: transparent; box-shadow: none; color: var(--sf-muted); font-size: 10.5px; font-weight: 500; letter-spacing: 0; }
  #studio .tool-strip .tool .icon { width: 18px; height: 18px; }
  #studio .tool-strip .tool:hover { background: color-mix(in oklab, var(--sf-fg) 7%, transparent); transform: none; }
  #studio .tool-strip .tool[aria-pressed="true"] { color: var(--sf-fg); background: var(--sf-btn-hover); }
  #studio .tool-strip .tool.is-primary { color: var(--sf-primary-fg); background: var(--sf-primary); margin-left: 4px; }
  #studio .tool-strip .tool.is-primary:hover, #studio .tool-strip .tool.is-primary[aria-pressed="true"] { background: var(--sf-primary); filter: brightness(1.08); }
}

/* One control height across the dock (40px): icon buttons, size trigger, segment groups, Video and All. */
#studio .classic-stage .stage-dock .media-tools :is(.dock-reset, #play) { width: 40px; min-width: 40px; height: 40px; border-radius: 12px; margin-right: 4px; }
#studio .classic-stage .stage-dock .export-bar :is(#resolutionTrigger, #exportVideo, #exportAll) { height: 40px; min-height: 40px; padding-top: 0; padding-bottom: 0; }
#studio .classic-stage .stage-dock .export-bar :is(.export-scale, .export-format) { box-sizing: border-box; height: 40px; padding: 3px; }
#studio .classic-stage .stage-dock .export-bar :is(.export-scale, .export-format) > button { height: 100%; min-height: 0; }
