/* ==========================================================================
   Mobile app shell for the public tool workbenches.
   Loaded after tool-mobile.css on purpose: this file replaces the old
   "whole page scrolls, artwork sticks" model with a stable, phone-shaped
   layout that a person can actually use with one thumb.

     ┌───────────────┐
     │ header        │  keeps its natural height
     ├───────────────┤
     │ artwork pane  │  fixed band, never scrolls away
     ├───────────────┤
     │ control sheet │  takes every remaining pixel and scrolls inside
     └───────────────┘

   The shell only turns on for pages that really have a preview + controls
   pair: tool-viewport.js adds `.tool-app-shell` to <body> after it finds
   them. Pages without a workbench (external/vendored tools) keep scrolling
   normally.
   ========================================================================== */

/* Shared dense workspace language, including desktop control panels. */
body.tool-dense-ui {
  --tool-control-size: 30px;
  --tool-control-radius: 8px;
  --tool-page-gutter: 12px;
  --tool-section-gap: 12px;
  --tool-group-gap: 8px;
}
body.tool-dense-ui .tool-has-disclosure { padding: 0 !important; }
body.tool-dense-ui .tool-disclosure > summary {
  display: flex;
  min-height: 34px;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  color: var(--aiw-ink, var(--ts-ink, #211b16));
  font-size: 12px;
  font-weight: 600;
  list-style: none;
  cursor: pointer;
}
body.tool-dense-ui .tool-disclosure > summary::-webkit-details-marker { display: none; }
body.tool-dense-ui .tool-disclosure > summary::after {
  content: '';
  width: 5px;
  height: 5px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(45deg);
  transition: transform .18s ease;
  opacity: .6;
}
body.tool-dense-ui .tool-disclosure[open] > summary::after { transform: rotate(225deg); }
body.tool-dense-ui .tool-disclosure__body { padding: 0 10px 10px; }
body.tool-dense-ui .tool-disclosure[open] > .tool-disclosure__body { animation: tool-panel-reveal .18s ease both; }
body.tool-dense-ui .tool-disclosure__body > :is(.ms-step__head, .pt-card__head, .sll-card__head, .image-upscale__control-head) :is(h2,h3) { display: none; }
body.tool-dense-ui [data-tool-controls] .tool-workbench__canvas-toolbar {
  display: flex !important;
  align-items: center;
  gap: 5px;
  padding: 0 !important;
  margin: 0 0 8px !important;
  overflow-x: auto;
  scrollbar-width: none;
  border: 0;
  background: none;
}
body.tool-dense-ui [data-tool-controls] :is(.tool-workbench__mode-group,.tool-workbench__canvas-actions) { display: flex; flex: 0 0 auto; gap: 2px; width: auto; }
body.tool-dense-ui [data-tool-controls] .tool-workbench__mode-group button {
  display: inline-flex;
  min-height: 30px;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 4px 5px;
  font-size: 12px;
  border-radius: 7px;
}
body.tool-dense-ui [data-tool-controls] .tool-workbench__mode-group svg { width: 12px; height: 12px; }
body.tool-dense-ui .perspective-mode-indicator { display: none !important; }
body.tool-dense-ui .tool-detail[data-tool-slug="perspective-grid"] .tool-workbench__mode-group button[aria-pressed="true"] { background: var(--ts-accent); color: var(--ts-on-accent); }
body.tool-dense-ui [data-tool-controls] .tool-workbench__canvas-actions button { min-width: 28px; min-height: 30px; padding: 3px 5px; font-size: 12px; white-space: nowrap; }
body.tool-dense-ui [data-tool-controls] :is(.ms-dock,.sll-stagebar,.ms-stagebar,.aiw-toolbar,.aiw-filmstrip) { margin: 0 0 8px; }
body.tool-dense-ui [data-tool-controls] .ms-dock { display: flex; flex-wrap: nowrap; overflow-x: auto; gap: 3px; padding: 3px; }
body.tool-dense-ui [data-tool-controls] .ms-dock button { display: inline-flex; align-items: center; gap: 3px; min-width: 34px; min-height: 30px; height: auto; padding: 5px; font-size: 12px; }
body.tool-dense-ui [data-tool-controls] .ms-dock .ms-i { width: 14px; height: 14px; }
body.tool-dense-ui [data-tool-controls] .ic-preview__head { margin: 0 0 6px; min-height: 24px; }
body.tool-dense-ui [data-tool-controls] .ic-preview__title h2 { max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
body.tool-dense-ui [data-tool-controls] .ic-detail { margin: 4px 0; font-size: 12px; }
body.tool-dense-ui .stage-zoom-bar button { transition: background .16s, transform .16s; }
body.tool-dense-ui .stage-zoom-bar button:active { transform: scale(.88); }
/* The empty watermark surface fills the same preview as its uploaded canvas. */
body.tool-dense-ui.tool-app-shell .tool-detail[data-tool-slug="watermark-remover"] .watermark-workbench .dropzone {
  flex: 1 1 0;
  height: auto !important;
  min-height: 0 !important;
  max-height: none !important;
}
@keyframes tool-panel-reveal { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) {
  body.tool-dense-ui *, body.tool-dense-ui *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
@media (min-width: 1024px) {
  body.tool-dense-ui.tool-app-shell .page-main { padding-top: var(--tool-section-gap); }
  body.tool-dense-ui.tool-app-shell [data-tool-viewport="local"] { gap: var(--tool-section-gap) !important; }
    body.tool-dense-ui.tool-app-shell [data-tool-preview] {
    display: flex !important;
    position: relative !important;
    flex-direction: column;
    height: clamp(320px, 62dvh, 620px) !important;
    min-height: 0 !important;
    max-height: none !important;
    padding: 0 !important;
    border: 0 !important;
    box-sizing: border-box;
    overflow: hidden;
  }
  body.tool-dense-ui [data-tool-preview] :is(.ms-board,.sll-board,.ic-preview,.watermark-workbench .editor,.tool-workbench__canvas-section) { display: flex; flex: 1 1 0; flex-direction: column; height: auto; min-height: 0; padding: 0; margin: 0; gap: 0; }
  body.tool-dense-ui [data-tool-preview] :is(.sll-viewport,.ms-viewport,.ic-preview__stage,.image-upscale__stage,.palette-tool__stage,.tool-workbench__canvas-wrap,.aiw-stage,.watermark-workbench .stage) { flex: 1 1 0; min-height: 0 !important; height: auto !important; max-height: none !important; }
}

@media (max-width: 1023px) {
  /* 1 · Lock the page, hand the height to the two panes ------------------ */
  html.tool-app-shell,
  html.tool-app-shell body.tool-app-shell {
    height: 100dvh;
    max-height: 100dvh;
    overflow: hidden;
    overscroll-behavior: none;
  }

  body.tool-app-shell .page-shell {
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
    width: min(calc(100% - var(--tool-page-gutter) * 2), 1168px);
    height: 100dvh;
    max-width: none;
    margin: 0 auto;
    padding: 0 !important;
  }

  body.tool-app-shell .page-main {
    display: flex !important;
    flex: 1 1 auto;
    flex-direction: column;
    min-height: 0;
    padding: 0 !important;
    margin: 0 !important;
  }

  body.tool-app-shell .tool-detail {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    min-height: 0;
    margin: 0;
    padding: 0 !important;
  }

  /* The studio chrome between the shell and the viewport is pure wrapper. */
  body.tool-app-shell .tstudio-workspace,
  body.tool-app-shell .tstudio-console {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    min-height: 0;
    margin: 0;
    padding: 0;
    border: 0;
    background: none;
    box-shadow: none;
  }

  /* The tool's own root section sits between the console and the layout; it
     must forward the height instead of sizing to its content. */
  body.tool-app-shell .tstudio-console > * {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    min-height: 0;
  }

  body.tool-app-shell [data-tool-viewport],
  body.tool-app-shell .tool-detail[data-tool-slug] [data-tool-viewport] {
    position: fixed !important;
    top: var(--tool-workspace-top, 102px) !important;
    right: var(--tool-page-gutter);
    bottom: auto;
    left: var(--tool-page-gutter);
    display: flex !important;
    flex: 1 1 auto;
    flex-direction: column;
    min-height: 0;
    width: auto !important;
    height: max(0px, calc(var(--tool-viewport-height, 100dvh) - var(--tool-workspace-top, 102px))) !important;
    max-height: none !important;
    box-sizing: border-box;
    background: var(--aiw-surface-2, var(--ts-surface-2, #faf4ea));
    gap: 0 !important;
    margin: 0;
    padding: 4px 0 0;
  }

  /* Hidden tool panes must stay hidden: the layout rules below force flex. */
  body.tool-app-shell [data-tool-viewport][hidden],
  body.tool-app-shell [data-tool-preview][hidden],
  body.tool-app-shell [data-tool-controls][hidden],
  body.tool-app-shell [data-tool-viewport] > [hidden] {
    display: none !important;
  }

  /* Artwork always above the sheet, whatever the template order is. */
  body.tool-app-shell [data-tool-preview] {
    order: 1;
    flex: 0 0 auto !important;
    margin: 0 !important;
  }

  body.tool-app-shell [data-tool-controls] {
    order: 2;
    flex: 0 0 auto !important;
  }

  /* 2 · Artwork pane ----------------------------------------------------- */
  /* --tool-stage-h is the whole preview band, fixed while the sheet scrolls. */
  body.tool-app-shell [data-tool-preview] {
    position: relative !important;
    inset: auto !important;
    top: auto !important;
    z-index: 1;
    display: flex !important;
    flex: 0 0 auto;
    flex-direction: column;
    height: var(--tool-stage-h, clamp(196px, 30dvh, 292px)) !important;
    gap: var(--tool-group-gap);
    max-height: none;
    min-height: 0;
    box-sizing: border-box;
    padding: 0 6px !important;
    overflow: hidden;
    border: 0 !important;
    border-radius: 0;
    background: none;
    box-shadow: none !important;
  }

  /* One radius for every artwork surface, so the card never meets the sheet
     with a squared edge. */
  body.tool-app-shell [data-tool-preview] :is(.sll-viewport, .ms-viewport, .palette-tool__stage, .image-upscale__stage, .ic-preview__stage, .tool-workbench__canvas-wrap, .aiw-stage, .watermark-workbench .stage) {
    border-radius: 18px;
  }

  /* Every tool wraps its canvas in one more column box; keep those flexible so
     the artwork can use the whole band. */
  body.tool-app-shell [data-tool-preview] :is(.tool-workbench__stage, .tool-workbench__canvas-section, .ic-main, .ic-preview, .pt-main, .sll-stage, .ms-stage, .aiw-stage-col) {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    min-height: 0;
    height: 100%;
    padding: 0;
  }

  body.tool-app-shell [data-tool-preview] :is(.sll-viewport, .ms-viewport, .palette-tool__stage, .image-upscale__stage, .ic-preview__stage, .tool-workbench__canvas-wrap, .aiw-stage, .watermark-workbench .stage) {
    flex: 1 1 auto;
    width: 100%;
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
    aspect-ratio: auto;
    margin: 0;
  }

  body.tool-app-shell [data-tool-preview] .tool-workbench__canvas {
    width: 100%;
    height: 100%;
    max-height: 100%;
    object-fit: contain;
  }

  /* 3 · Control sheet ---------------------------------------------------- */
  /* Keep the identity bar out of the way: the sticky header already names the
     tool, and every pixel here belongs to the artwork or the controls. */
  body.tool-app-shell .tstudio-console__bar {
    display: none !important;
  }

  body.tool-app-shell [data-tool-controls] {
    position: relative !important;
    z-index: 2;
    display: block;
    flex: 1 1 0 !important;
    width: 100% !important;
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
    margin: 6px 0 0 !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    padding: var(--tool-section-gap) var(--tool-page-gutter) calc(var(--tool-bottom-reserve, 56px) + 12px) !important;
    border: 0;
    border-radius: 16px 16px 0 0;
    background: var(--aiw-surface, var(--ts-surface, #fffdf8));
    box-shadow: 0 -8px 22px -5px rgb(24 20 17 / 24%), 0 -1px 4px rgb(24 20 17 / 9%) !important;
    scrollbar-width: none !important;
    scroll-padding-bottom: calc(var(--tool-bottom-reserve, 56px) + 20px);
  }

  body.tool-app-shell [data-tool-controls]::-webkit-scrollbar {
    display: none !important;
    width: 0 !important;
    height: 0 !important;
  }

  /* The sticky sheet lip stays visible while controls scroll underneath it.
     It marks the clipped edge; it is decorative, not a draggable control. */
  body.tool-app-shell [data-tool-controls]::before {
    content: "";
    display: block !important;
    position: sticky;
    top: calc(-1 * var(--tool-section-gap));
    z-index: 9;
    height: 18px;
    min-height: 18px;
    flex: 0 0 18px;
    margin: calc(-1 * var(--tool-section-gap)) calc(-1 * var(--tool-page-gutter)) 2px;
    border-radius: 16px 16px 0 0;
    background:
      url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='38' height='4' viewBox='0 0 38 4'%3E%3Crect width='38' height='4' rx='2' fill='%237e756b'/%3E%3C/svg%3E") center 6px / 38px 4px no-repeat,
      linear-gradient(to bottom, var(--aiw-surface, var(--ts-surface, #fffdf8)) 68%, transparent);
    pointer-events: none;
  }

  body.tool-app-shell [data-tool-controls]::after {
    display: none !important;
  }

  body.tool-app-shell [data-tool-controls] {
    background-image: none;
  }

  /* Nested lists inside the sheet may scroll, but their scrollbars must not
     paint a second strip over the sheet's rounded surface. */
  body.tool-app-shell [data-tool-controls] *::-webkit-scrollbar {
    width: 0;
    height: 0;
  }

  body.tool-app-shell [data-tool-controls] * {
    scrollbar-width: none;
  }

  /* Lists inside the sheet must not create their own scroll traps. */
  body.tool-app-shell [data-tool-controls] :is(ol, ul) {
    min-width: 0;
  }

  /* 4 · Per-tool tuning -------------------------------------------------- */
  /* Palettes + converters show a narrow image, so they get a slightly
     shorter band and more room for the colour list. */
  body.tool-app-shell[data-tool-stage="palette-extractor"],
  body.tool-app-shell[data-tool-stage="image-converter"] {
    --tool-stage-h: clamp(190px, 28dvh, 260px);
  }

  /* 4.1 AI workbench: toolbar stays, stage flexes, dock follows the sheet. */

  /* The submit dock belongs to the top of the sheet, not to the artwork. */

  /* 4.2 Perspective: one compact scrollable action row so the canvas keeps the
     band. The legacy sheet put the mode and canvas actions on two 40px rows. */
  body.tool-app-shell [data-tool-preview] .tool-workbench__canvas-toolbar {
    display: flex !important;
    flex: 0 0 auto;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    align-items: center;
    gap: 5px;
    margin: 0 !important;
    padding: 2px 2px 4px !important;
    border: 0 !important;
    background: none !important;
    overflow-x: auto;
    scrollbar-width: none;
  }

  /* The sliding pill was positioned before this row became scrollable, so on
     phones the pressed state uses the button's own background instead. */
  body.tool-app-shell .perspective-mode-indicator {
    display: none !important;
  }

  body.tool-app-shell .tool-detail[data-tool-slug="perspective-grid"] .tool-workbench__mode-group button[aria-pressed="true"] {
    background: var(--ts-accent);
    color: var(--ts-on-accent);
  }

  body.tool-app-shell [data-tool-preview] .tool-workbench__mode-group,
  body.tool-app-shell [data-tool-preview] .tool-workbench__canvas-actions {
    display: flex;
    flex: 0 0 auto !important;
    flex-direction: row;
    flex-wrap: nowrap;
    width: auto !important;
    gap: 3px;
  }

  body.tool-app-shell [data-tool-preview] :is(.tool-workbench__mode-group, .tool-workbench__canvas-actions) button {
    min-height: 40px !important;
    padding: 2px 7px !important;
    border-radius: 9px;
    font-size: 12px !important;
    line-height: 1.1;
    white-space: nowrap;
  }

  body.tool-app-shell [data-tool-preview] .tool-workbench__mode-group button svg {
    width: 13px;
    height: 13px;
  }

  /* 4.3 Image upscale: the tool's own column must not resize the band. */
  body.tool-app-shell .image-upscale__main {
    position: relative !important;
    display: flex !important;
    flex-direction: column;
    padding: 0 6px !important;
    background: none !important;
  }

  body.tool-app-shell .tool-detail[data-tool-slug="image-upscale"] .image-upscale.image-upscale--studio .image-upscale__main[data-tool-preview] {
    position: relative !important;
    display: flex !important;
    height: var(--tool-stage-h) !important;
    padding: 0 6px !important;
  }

  body.tool-app-shell .image-upscale__stage-actions {
    flex: 0 0 auto;
    padding-top: 6px !important;
  }

  /* 4.3 Image converter: preview head above the stage, sheet below. */
  body.tool-app-shell .ic-preview {
    display: flex;
    flex-direction: column;
    min-height: 0;
    height: 100%;
    gap: 0;
    margin: 0 !important;
  }

  body.tool-app-shell .ic-preview__head {
    flex: 0 0 auto;
    margin: 0;
  }

  /* 4.4 Palette: the stage keeps its own radius, the marker strip is gone. */
  body.tool-app-shell .palette-tool__stage {
    border-radius: 16px;
  }

  /* 4.5 Material segment: the stage bar, canvas and tool dock share the band;
     the canvas must keep the biggest slice. */
  body.tool-app-shell .ms-stage {
    display: flex;
    flex-direction: column;
    min-height: 0;
    gap: 6px;
    padding: 0 6px !important;
  }

  body.tool-app-shell :is(.ms-stagebar, .sll-stagebar) {
    flex: 0 0 auto;
    min-height: 0;
    gap: 6px;
  }

  body.tool-app-shell .ms-viewport {
    flex: 1 1 auto;
    min-height: 0;
  }

  /* The canvas sits inside a wrapper between the bar and the dock; the wrapper
     must forward the height or the artwork collapses to 2px. */
  body.tool-app-shell :is(.ms-board, .sll-board) {
    display: flex !important;
    flex: 1 1 auto;
    flex-direction: column;
    min-height: 0;
    height: auto;
  }

  body.tool-app-shell .ms-board > .ms-viewport,
  body.tool-app-shell .sll-board > .sll-viewport {
    flex: 1 1 auto;
    min-height: 0;
    height: auto;
  }

  body.tool-app-shell .ms-dock {
    flex: 0 0 auto;
    margin: 0;
    padding: 3px;
    gap: 3px;
  }

  body.tool-app-shell .ms-dock button {
    height: 44px;
    min-width: 44px;
    font-size: 12px;
  }

  /* 4.6 Watermark: model strip on top of the sheet, stage under it. */
  body.tool-app-shell .watermark-workbench .editor {
    flex: 1 1 0 !important;
    height: auto !important;
    min-height: 0 !important;
  }

  /* 4.6 Space light lab: the panel repeats the upload call to action that the
     artwork already offers; keep it, but as a small secondary row. */
  body.tool-app-shell [data-tool-controls] .sll-import {
    margin: 0 0 10px;
    padding: 0;
    border: 0;
    background: none;
    border-radius: 0;
  }

  body.tool-app-shell [data-tool-controls] .sll-file-button {
    min-height: 34px !important;
    padding: 0 12px !important;
    font-size: 12px !important;
    border-radius: 12px;
    background: color-mix(in srgb, var(--ts-accent, #b0632a) 12%, transparent) !important;
    color: var(--ts-ink, #2a241d) !important;
  }

  /* 4.7 Watermark: the model strip belongs to the sheet, not the artwork. */
  body.tool-app-shell .model-loader {
    margin: 0 0 8px;
    border-radius: 12px;
  }

  /* 5 · Glass controls overlay the image; they never consume a layout row. */
  body.tool-app-shell .stage-zoom-bar {
    position: absolute;
    top: auto;
    bottom: 8px;
    right: 8px;
    margin: 0;
    padding: 0 2px;
    border-radius: 10px;
    background: color-mix(in srgb, var(--ts-surface, #fffdf8) 68%, transparent);
    box-shadow: 0 3px 14px color-mix(in srgb, var(--ts-ink, #211b16) 12%, transparent);
    opacity: 1;
  }

  body.tool-app-shell .stage-zoom-bar:focus-within,
  body.tool-app-shell .stage-zoom-bar:active {
    opacity: 1;
  }

  body.tool-app-shell .stage-zoom-bar button {
    width: 28px;
    height: 28px;
    min-width: 28px;
    font-size: 14px;
  }

  body.tool-app-shell .stage-zoom-bar output {
    min-width: 34px;
    font-size: 12px;
  }

  body.tool-app-shell .sll-stagebar { margin-bottom: 12px; }
  body.tool-app-shell .sll-stagebar:not(:has([data-sll-replace-image]:not([hidden]))) { display: none !important; }
  body.tool-app-shell .ms-stagebar { margin-bottom: 12px; }
  body.tool-app-shell [data-tool-controls] :is(input[type="text"], input[type="number"], textarea, select) { font-size: 16px; }
                  body.tool-app-shell .tool-detail[data-tool-slug="watermark-remover"] .watermark-workbench .toolbar {
    flex: 0 0 auto;
    flex-wrap: wrap;
    overflow: visible;
    padding: 2px;
    gap: 4px;
  }
  body.tool-app-shell .tool-detail[data-tool-slug="watermark-remover"] .watermark-workbench .toolbar > * { flex-shrink: 0; }
  body.tool-app-shell .tool-detail[data-tool-slug="watermark-remover"] .watermark-workbench .tool-btn { min-height: 44px; padding: 4px 8px; }
  body.tool-app-shell .watermark-workbench .editor { gap: 6px; }
  body.tool-app-shell .watermark-workbench .model-loader { position: static; }
  body.tool-app-shell .watermark-workbench .toast-container {
    top: auto;
    right: 12px;
    bottom: calc(82px + env(safe-area-inset-bottom, 0px));
    left: 12px;
    max-width: none;
  }
  body.tool-app-shell .tool-detail[data-tool-slug="watermark-remover"] .watermark-workbench .toast {
    color: var(--ts-ink, #211b16);
    background: var(--ts-surface, #fffdf8);
    border: 1px solid var(--ts-line, rgba(55, 42, 30, .13));
    border-radius: 12px;
  }
  body.tool-app-shell .watermark-workbench .toast-msg { color: inherit; }
  body.tool-app-shell .watermark-workbench .toast-close { min-width: 44px; min-height: 44px; color: inherit; }
  body.tool-keyboard-open [data-tool-preview] { display: none !important; }
}

/* Short landscape phones: keep the same two panes, just a shorter artwork
   band. The legacy landscape rules in tool-viewport.css must not turn the
   sheet back into the page scroller. */
@media (min-width: 600px) and (max-width: 1023px) and (max-height: 560px) {
  body.tool-app-shell [data-tool-viewport],
  body.tool-app-shell .tool-detail[data-tool-slug] [data-tool-viewport] { flex-direction: row; }
  body.tool-app-shell [data-tool-preview] {
    flex: 48 1 0 !important;
    width: 0;
    height: 100% !important;
    padding-bottom: calc(var(--tool-bottom-reserve, 56px) + 10px) !important;
  }
  body.tool-app-shell [data-tool-controls] {
    flex: 52 1 0 !important;
    width: 0 !important;
    height: 100% !important;
    max-height: none !important;
  }
  body.tool-app-shell .tool-detail[data-tool-slug="image-upscale"] .image-upscale.image-upscale--studio .image-upscale__main[data-tool-preview] { height: 100% !important; }
}

/* A running AI task needs its full status, rather than a fixed canvas band.
   Scroll the workspace as a whole so short screens and larger text still fit. */

/* Compact controls: preserve the primary task, disclose secondary detail. */
@media (max-width: 1023px) {
  body.tool-app-shell :is([data-tool-controls], .tool-detail dialog, .aiw dialog) input[type="range"] { touch-action: pan-y pinch-zoom; }
}
body.tool-dense-ui.tool-app-shell .stage-zoom-bar button {
  width: 28px !important;
  height: 28px !important;
  min-width: 28px !important;
  min-height: 28px !important;
  padding: 0 !important;
  border-radius: 7px;
  font-size: 14px !important;
}
body.tool-dense-ui.tool-app-shell .stage-zoom-bar output { min-width: 34px; font-size: 12px; }

/* One artwork action system, including the original AI preview dialog. */
body :is(.stage-zoom-bar, .aiw-viewtools__zoom, .tool-stage-action-source),
body [data-tool-kind="perspective-grid"] [data-view-reset],
body [data-sll-replace-image] { display: none !important; }
body [data-stage-zoom-host] { position: relative; overflow: hidden !important; isolation: isolate; }
.tool-stage-content { position: absolute; inset: 0; display: grid; place-items: center; width: 100%; height: 100%; transform-origin: center; }
body .tool-stage-actions { position: absolute; z-index: 30; display: flex; flex-direction: column; gap: 8px; width: 34px; }
body .tool-stage-actions[hidden], body .tool-stage-actions button[hidden], .tool-stage-loading[hidden] { display: none !important; }
body.tool-dense-ui.tool-app-shell .tool-stage-actions button {
  display: grid; place-items: center; flex: 0 0 34px; box-sizing: border-box;
  width: 34px !important; height: 34px !important; min-width: 34px !important; min-height: 34px !important; margin: 0; padding: 8px !important;
  border: 1px solid rgb(255 255 255 / .25); border-radius: 50% !important;
  color: #fff; background: rgb(35 36 38 / .78); box-shadow: 0 2px 6px rgb(0 0 0 / .14);
  cursor: pointer; touch-action: manipulation;
}
body .tool-stage-actions button svg { display: block; width: 16px; height: 16px; pointer-events: none; }
body .tool-stage-actions button:hover { background: #25272a; }
body .tool-stage-actions button:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
body .tool-stage-actions button:disabled { opacity: .5; cursor: wait; }
body [data-upscale-working] { background: transparent !important; pointer-events: none; }
body [data-upscale-working] > :not([data-upscale-cancel]) { visibility: hidden; }
body [data-upscale-working] > [data-upscale-cancel] { position: absolute; bottom: 12px; left: 50%; transform: translateX(-50%); pointer-events: auto; }
body.tool-preview-open { overflow: hidden; }
body dialog.tool-stage-dialog {
  box-sizing: border-box; position: fixed; inset: 0; width: 100vw; max-width: none;
  height: 100dvh; max-height: none; margin: 0; padding: 12px; border: 0; border-radius: 0;
  background: var(--shell-bg, #202528); color: var(--shell-text, #f3f4f5); overflow: hidden;
}
body dialog.tool-stage-dialog[open] { display: flex; flex-direction: column; gap: 10px; }
body dialog.tool-stage-dialog::backdrop { background: #16191c; }
body.tool-app-shell dialog.tool-stage-dialog [data-stage-zoom-host] {
  position: relative !important; inset: auto !important; flex: 1 1 0 !important;
  box-sizing: border-box; width: 100% !important; height: 100% !important;
  min-width: 0 !important; min-height: 0 !important; max-width: none !important; max-height: none !important;
  margin: 0 !important; border-radius: 12px;
}
.tool-fullscreen-tools { display: flex; flex: 0 0 auto; flex-wrap: wrap; justify-content: center; gap: 6px; padding-bottom: env(safe-area-inset-bottom, 0px); max-height: 25dvh; overflow: auto; }
.tool-fullscreen-tools button { min-height: 36px; padding: 6px 12px; border: 1px solid var(--shell-line, #596368); border-radius: 8px; background: var(--shell-card-strong, #fff); color: var(--shell-text, #222); font: inherit; font-size: 12px; }
.tool-fullscreen-tools button[aria-pressed="true"] { background: var(--studio-accent, #176c70); color: #fff; }
.tool-fullscreen-tools label { display: flex; align-items: center; gap: 8px; padding: 6px 10px; font-size: 12px; }
.tool-fullscreen-tools input { width: 100px; accent-color: var(--studio-accent, #176c70); }
body .tool-stage-loading {
  position: absolute; z-index: 20; left: 50%; top: 50%; transform: translate(-50%, -50%);
  box-sizing: border-box; width: min(420px, calc(100% - 112px)); padding: 18px 20px;
  border-radius: 14px; background: var(--shell-card-strong, #fffdf9); color: var(--shell-text, #25272a);
  box-shadow: 0 8px 30px rgb(0 0 0 / .16); pointer-events: none;
}
.tool-stage-loading__head { display: flex; gap: 12px; align-items: flex-start; }
.tool-stage-loading__head > div { min-width: 0; }
.tool-stage-loading strong { display: block; font-size: 14px; line-height: 1.5; }
.tool-stage-loading p { margin: 4px 0 0; font-size: 12px; line-height: 1.6; overflow-wrap: anywhere; }
.tool-stage-loading__spinner { flex: 0 0 20px; width: 20px; height: 20px; margin-top: 3px; border: 2px solid color-mix(in srgb, currentColor 18%, transparent); border-top-color: var(--studio-accent, #176c70); border-radius: 50%; animation: tool-model-spin 1s linear infinite; }
.tool-stage-loading ol { display: flex; gap: 8px; list-style: none; margin: 12px 0 0; padding: 0; }
.tool-stage-loading li { flex: 1; padding-top: 6px; border-top: 2px solid var(--shell-line, #ddd); font-size: 11px; line-height: 1.4; text-align: center; }
.tool-stage-loading li:is(.is-current, .is-done) { border-color: var(--studio-accent, #176c70); }
.tool-stage-loading li.is-current { font-weight: 700; }
@keyframes tool-model-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .tool-stage-loading__spinner { animation: none; } }
@media (max-width: 600px) {
  body .tool-stage-loading { width: min(360px, calc(100% - 100px)); padding: 12px; border-radius: 12px; }
  .tool-stage-loading__head { gap: 8px; }
  .tool-stage-loading strong { font-size: 13px; }
  .tool-stage-loading p { font-size: 11px; line-height: 1.45; }
  .tool-stage-loading ol { margin-top: 8px; gap: 5px; }
  .tool-stage-loading li { font-size: 10px; }
}
body.tool-dense-ui.tool-app-shell .tool-detail[data-tool-slug="perspective-grid"] .tool-workbench__canvas-actions { margin-left: auto; justify-content: flex-end; }
body.tool-dense-ui.tool-app-shell [data-tool-controls] .tool-workbench__canvas-toolbar { justify-content: flex-end; }
body .perspective-template-dialog { box-sizing: border-box; width: min(400px, calc(100vw - 40px)); height: auto; min-height: 0; max-height: calc(100dvh - 48px); padding: 20px; overflow: auto; }
body .perspective-template-dialog__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 0 14px; margin: 0 0 14px; }
body .perspective-template-dialog__head h3 { margin: 0; }
body.tool-dense-ui.tool-app-shell .tool-detail[data-tool-slug="perspective-grid"] .perspective-template-dialog__head button { box-sizing: border-box; display: grid; place-items: center; flex: 0 0 32px; width: 32px !important; height: 32px !important; min-width: 32px !important; min-height: 32px !important; padding: 0 !important; border-radius: 50% !important; }
body .pt-export .tool-disclosure__body { padding: 0; }
body .pt-export .pt-card__head { display: none; }
body .pt-export__body { display: grid; grid-template-columns: minmax(88px, .8fr) minmax(0, 1.2fr); gap: 12px; align-items: stretch; margin-top: 12px; }
body .pt-export .palette-tool__export-preview { min-width: 0; min-height: 100px; margin: 0; border-radius: 10px; overflow: hidden; }
body .pt-export .palette-tool__actions { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
body .pt-export .palette-tool__actions button { flex: 1; width: 100%; min-height: 40px; }
body .pt-export .pt-note { margin: 12px 0 0; font-size: 12px; line-height: 1.6; }
body .pt-side > .tool-ai-trigger { display: flex; justify-content: center; width: 100%; min-height: 42px; margin: 12px 0; }
@media (max-width: 1023px) {
  body.tool-app-shell .watermark-workbench #actions-card { position: static !important; inset: auto !important; width: auto !important; margin-top: 14px; transform: none !important; }
}
body.tool-dense-ui.tool-app-shell [data-tool-controls] :is(.ms-step,.sll-card,.pt-card,.image-upscale__control,.watermark-workbench .card) {
  padding: var(--tool-section-gap);
  margin-top: var(--tool-section-gap);
  border-radius: 12px;
  box-shadow: none;
}
body.tool-dense-ui.tool-app-shell [data-tool-controls] :is(h2,h3) { font-size: 12px; line-height: 1.35; }
body.tool-dense-ui.tool-app-shell [data-tool-controls] :is(.ms-step__head,.pt-card__head,.sll-card__head,.image-upscale__control-head) { gap: var(--tool-group-gap); margin-bottom: var(--tool-group-gap); }
body.tool-dense-ui.tool-app-shell [data-tool-controls] :is(.ms-btn,.sll-button,.tool-button,.btn-primary,.btn-ghost,.btn-danger) {
  min-height: 30px;
  padding: 5px 8px;
  border-radius: 8px;
  font-size: 12px;
  line-height: 1.35;
}
body.tool-dense-ui.tool-app-shell [data-tool-controls] button:active { transform: scale(.97); }
body.tool-dense-ui.tool-app-shell [data-tool-controls] :is(button,summary) { transition: background-color .16s, border-color .16s, color .16s, transform .16s; }

/* AI: one compact setup flow; keep editable text at the safe native size. */
/* This toolbar lives in the scrolling controls; mode content must never shrink it. */

/* Perspective: type icons and compact utilities wrap when the sheet is narrow. */
body.tool-dense-ui.tool-app-shell [data-tool-controls] .tool-workbench__canvas-actions button { width: auto; min-width: 30px; padding-inline: 8px; font-size: 12px; }
body.tool-dense-ui.tool-app-shell [data-tool-controls] .tool-workbench__canvas-actions [data-view-toggle-lines] { width: auto; font-size: 12px; }
body.tool-dense-ui.tool-app-shell [data-tool-controls] .tool-workbench__canvas-toolbar { flex-direction: row !important; flex-wrap: wrap !important; justify-content: flex-start; row-gap: 6px; }
body.tool-dense-ui.tool-app-shell [data-tool-controls] :is(.tool-workbench__mode-group,.tool-workbench__canvas-actions) { width: auto !important; flex: 0 0 auto !important; }
body.tool-dense-ui.tool-app-shell .tool-detail[data-tool-slug="perspective-grid"] .tool-workbench__canvas-actions { margin-left: auto; justify-content: flex-end; }
@media (max-width: 1023px) {
  /* Reclaim the sheet's extra toolbar gap; keep both template actions equal. */
  body.tool-dense-ui.tool-app-shell .tool-detail[data-tool-slug="perspective-grid"] [data-tool-controls] .tool-workbench__canvas-toolbar { min-height: 0; margin: -8px 0 0 !important; }
  body.tool-dense-ui.tool-app-shell .tool-detail[data-tool-slug="perspective-grid"] [data-tool-controls] .tool-workbench__canvas-actions { flex: 1 1 100% !important; width: 100% !important; margin-left: 0; gap: 8px; }
  body.tool-dense-ui.tool-app-shell .tool-detail[data-tool-slug="perspective-grid"] [data-tool-controls] :is([data-perspective-template-save], [data-perspective-template-load]) { flex: 1 1 0; min-width: 0; height: 32px; min-height: 32px !important; padding: 0 8px; line-height: 1.2; }
  body.tool-dense-ui.tool-app-shell .tool-detail[data-tool-slug="perspective-grid"] [data-tool-controls] .tool-workbench__upload-empty { min-height: 56px; }
}
body.tool-dense-ui.tool-app-shell .tool-detail[data-tool-slug="perspective-grid"] .tool-workbench__vision-panel { display: flex; flex-wrap: wrap; align-items: stretch; gap: 8px; padding: 8px; }
body.tool-dense-ui.tool-app-shell .tool-detail[data-tool-slug="perspective-grid"] .tool-workbench__upload-area { flex: 1; min-width: 0; margin: 0; padding: 0; }
@media (max-width: 480px) {
  body.tool-dense-ui.tool-app-shell .tool-detail[data-tool-slug="perspective-grid"] .tool-workbench__upload-area { flex: 1 0 100%; }
}
body.tool-dense-ui.tool-app-shell .tool-detail[data-tool-slug="perspective-grid"] .tool-workbench__upload-preview { height: 128px; min-height: 128px; isolation: isolate; }
body.tool-dense-ui.tool-app-shell .tool-detail[data-tool-slug="perspective-grid"] .tool-workbench__upload-preview > .huihua-image-shell { position: absolute; inset: 0; display: block; width: 100%; height: 100%; }
body.tool-dense-ui.tool-app-shell .tool-detail[data-tool-slug="perspective-grid"] [data-background-preview-image] { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
body.tool-dense-ui.tool-app-shell .tool-detail[data-tool-slug="perspective-grid"] .perspective-detection-notice { position: absolute; inset: 0; z-index: 1; display: flex; align-items: safe center; margin: 0; padding: 34px 10px 10px; overflow-y: auto; background: rgb(20 24 28 / 82%); color: #fff; font-size: 12px; line-height: 1.6; cursor: default; }
body.tool-dense-ui.tool-app-shell .tool-detail[data-tool-slug="perspective-grid"] .tool-workbench__upload-remove { z-index: 2; width: 32px; height: 32px; }
@media (max-width: 1023px) {
  body.tool-dense-ui.tool-app-shell .tool-detail[data-tool-slug="perspective-grid"] .tool-workbench__upload-remove { width: 44px; height: 44px; }
  body.tool-dense-ui.tool-app-shell .tool-detail[data-tool-slug="perspective-grid"] .perspective-detection-notice { padding-top: 52px; }
}
body.tool-dense-ui.tool-app-shell .tool-detail[data-tool-slug="perspective-grid"] dialog.perspective-template-dialog { box-sizing: border-box; position: fixed; inset: 50% 0 auto; transform: translateY(-50%); width: min(400px, calc(100vw - 40px)); height: fit-content !important; min-width: 0; min-height: 0; max-height: calc(100dvh - 48px); margin: 0 auto; padding: 20px; flex: none; overflow-y: auto; }
body .perspective-template-dialog form { padding: 0; }
body.tool-dense-ui.tool-app-shell .tool-detail[data-tool-slug="perspective-grid"] [data-reference-help] { flex: 0 0 100%; margin: 0; font-size: 12px; line-height: 1.5; }
body.tool-dense-ui.tool-app-shell .tool-detail[data-tool-slug="perspective-grid"] [data-detect-perspective] { flex: 0 0 auto; width: auto; min-height: 32px; margin: 0; padding: 5px 10px; font-size: 12px; }
body.tool-dense-ui.tool-app-shell .tool-detail[data-tool-slug="perspective-grid"] .tool-workbench__canvas-actions button { min-height: 30px; }
body.tool-dense-ui.tool-app-shell .tool-detail[data-tool-slug="perspective-grid"] .perspective-size-schemes { padding-inline: 8px; }
body.tool-dense-ui.tool-app-shell .tool-detail[data-tool-slug="perspective-grid"] .perspective-size-scheme[aria-pressed="true"] { border-color: var(--pg-accent); background: var(--pg-accent); }
body.tool-dense-ui.tool-app-shell .tool-detail[data-tool-slug="perspective-grid"] .perspective-size-scheme[aria-pressed="true"],
body.tool-dense-ui.tool-app-shell .tool-detail[data-tool-slug="perspective-grid"] .perspective-size-scheme[aria-pressed="true"] :is(strong, small) { color: #fff; }
body.tool-dense-ui.tool-app-shell .tool-detail[data-tool-slug="perspective-grid"] .perspective-size-categories { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1.5fr) minmax(0, 1fr); }
body.tool-dense-ui.tool-app-shell .tool-detail[data-tool-slug="perspective-grid"] .perspective-size-categories button { padding-inline: 3px; font-size: 12px !important; white-space: nowrap; }

/* Segment: precision tools stay compact; refinement/export disclose on demand. */
body.tool-dense-ui.tool-app-shell [data-tool-controls] .ms-stagebar { min-height: 30px; gap: 5px; }
body.tool-dense-ui.tool-app-shell [data-tool-controls] .ms-stagebar button { min-width: 28px; min-height: 30px; padding: 4px 6px; font-size: 12px; }
body.tool-dense-ui.tool-app-shell [data-tool-controls] .ms-dock button { min-width: 32px; min-height: 30px; height: 30px; padding: 4px 6px; }
body.tool-dense-ui.tool-app-shell [data-tool-controls] .ms-dock button { flex-direction: row; }
body.tool-dense-ui.tool-app-shell .tool-control-strip { display: flex; align-items: center; gap: 6px; width: 100%; min-height: 34px; margin: 0 0 7px; overflow-x: auto; scrollbar-width: none; list-style: none; }
body.tool-dense-ui.tool-app-shell .tool-control-strip > :is(.ms-dock,.ms-stagebar) { flex: 0 0 auto; margin: 0; }
body.tool-dense-ui.tool-app-shell [data-tool-controls] .ms-dock { position: static !important; inset: auto !important; transform: none !important; }
body.tool-dense-ui.tool-app-shell [data-tool-preview] .ms-board { padding: 0 !important; }
body.tool-dense-ui.tool-app-shell [data-tool-controls] .ms-stagebar .ms-icon-btn { width: 28px; height: 30px; min-height: 30px; }
body.tool-dense-ui.tool-app-shell [data-ms-step="import"] .ms-step__body { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr); gap: 5px; }
body.tool-dense-ui.tool-app-shell [data-ms-step="import"] .ms-row { gap: 4px; }
body.tool-dense-ui.tool-app-shell [data-tool-controls] .ms-seg button { min-height: 30px; padding: 5px; font-size: 12px; }
body.tool-dense-ui.tool-app-shell [data-tool-controls] .ms-filebtn { min-height: 30px; height: 32px; padding: 5px 8px; font-size: 12px; box-sizing: border-box; }
body.tool-dense-ui.tool-app-shell [data-tool-controls] .ms-step__body { gap: 7px; }
body.tool-dense-ui.tool-app-shell [data-tool-controls] .ms-choice-group button { min-height: 30px; padding: 5px; font-size: 12px; }
body.tool-dense-ui.tool-app-shell [data-tool-controls] .ms-step__head::before { width: 20px; height: 20px; font-size: 12px; }

/* Light lab: the lamp is the main object; depth and recognition are secondary. */
body.tool-dense-ui.tool-app-shell [data-tool-controls] :is(.sll-tabs,.sll-stagebar) button { min-height: 30px; padding: 5px 8px; font-size: 12px; }
body.tool-dense-ui.tool-app-shell [data-tool-controls] .sll-range { display: grid; grid-template-columns: minmax(70px,auto) minmax(60px,1fr) auto; align-items: center; gap: 5px; }
body.tool-dense-ui.tool-app-shell [data-tool-controls] .sll-range input[type="range"] { grid-column: 2; grid-row: 1; width: 100%; }
body.tool-dense-ui.tool-app-shell [data-tool-controls] .sll-range output { grid-column: 3; grid-row: 1; font-size: 12px; }
body.tool-dense-ui.tool-app-shell [data-tool-controls] .sll-range > span { font-size: 12px; }

/* Palette: prominent swatches, compact selectors and collapsible archives. */
body.tool-dense-ui.tool-app-shell [data-tool-controls] .palette-tool__mobile-actions { gap: 5px; margin-bottom: 7px; }
body.tool-dense-ui.tool-app-shell [data-tool-controls] .palette-tool__mobile-actions button { min-height: 30px; padding: 5px 8px; font-size: 12px; border-radius: 8px; }
body.tool-dense-ui.tool-app-shell [data-tool-controls] .palette-tool__strip { height: 38px; }
body.tool-dense-ui.tool-app-shell [data-tool-controls] .palette-tool__count-step { width: 28px; min-width: 28px; height: 28px; font-size: 16px; }
body.tool-dense-ui.tool-app-shell [data-tool-controls] .pt-controls { gap: 8px; padding-top: 8px; margin-top: 8px; }
body.tool-dense-ui.tool-app-shell [data-tool-controls] .palette-tool__count button { min-height: 28px; border-radius: 8px; font-size: 12px; }
body.tool-dense-ui.tool-app-shell [data-tool-controls] .pt-list { margin-top: 8px; }
body.tool-dense-ui.tool-app-shell [data-tool-controls] .palette-tool__swatch { height: 38px; }

/* Upscale: type and scale first, model resources behind one disclosure. */
body.tool-dense-ui.tool-app-shell [data-tool-controls] .image-upscale__panel-title { margin-bottom: 7px; }
body.tool-dense-ui.tool-app-shell [data-tool-controls] .image-upscale__segments { gap: 5px; }
body.tool-dense-ui.tool-app-shell [data-tool-controls] .image-upscale__segments button { min-height: 42px; padding: 6px; border-radius: 8px; }
body.tool-dense-ui.tool-app-shell [data-tool-controls] .image-upscale__segments strong { font-size: 12px; }
body.tool-dense-ui.tool-app-shell [data-tool-controls] .image-upscale__segments span { font-size: 12px; line-height: 1.3; }
body.tool-dense-ui.tool-app-shell [data-tool-controls] .image-upscale__rule { font-size: 12px; line-height: 1.45; }
body.tool-dense-ui.tool-app-shell [data-tool-controls] .image-upscale__status { margin: 0 0 6px; font-size: 12px; }

/* Converter: compact queue, single-line option labels, existing details intact. */
body.tool-dense-ui.tool-app-shell [data-tool-preview] .ic-preview { flex: 1 1 0 !important; width: 100%; min-height: 0; margin: 0 !important; padding: 0 !important; border: 0; }
body.tool-dense-ui.tool-app-shell [data-tool-controls] .ic-queue { padding: 7px; margin-bottom: 7px; border-radius: 10px; }
body.tool-dense-ui.tool-app-shell [data-tool-controls] .ic-field { gap: 5px; font-size: 12px; }
body.tool-dense-ui.tool-app-shell [data-tool-controls] .ic-target { display: grid; grid-template-columns: auto minmax(0,1fr); align-items: center; }
body.tool-dense-ui.tool-app-shell [data-tool-controls] .ic-adjust > summary { padding: 8px 0; min-height: 30px; }
body.tool-dense-ui.tool-app-shell [data-tool-controls] .ic-options { gap: 8px; }

/* Watermark: task and paint tools first; output quality and storage fold away. */
body.tool-dense-ui.tool-app-shell .tool-detail[data-tool-slug="watermark-remover"] .watermark-workbench .tool-btn { display: inline-flex; justify-content: center; min-height: 38px; padding: 6px 10px; font-size: 12px; }
body.tool-dense-ui.tool-app-shell .tool-detail[data-tool-slug="watermark-remover"] .watermark-workbench .toolbar { display: flex; flex-direction: column; align-items: stretch; flex-wrap: nowrap; overflow: visible; margin: 0 0 12px; padding: 12px; gap: 8px; border-radius: 12px; white-space: normal; }
body.tool-dense-ui.tool-app-shell .watermark-workbench .wm-toolbar-row { display: flex; align-items: center; gap: 6px; min-width: 0; }
body.tool-dense-ui.tool-app-shell .watermark-workbench .wm-toolbar-detect { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); }
body.tool-dense-ui.tool-app-shell .watermark-workbench .wm-toolbar-detect .select { width: 100%; min-width: 0; height: 38px; padding: 5px 24px 5px 8px; font-size: 12px; }
body.tool-dense-ui.tool-app-shell .watermark-workbench .wm-toolbar-tools .tool-btn { flex: 1 1 0; width: 38px; min-width: 0; padding: 6px; }
body.tool-dense-ui.tool-app-shell .watermark-workbench .toolbar .separator { flex: none; width: 1px; height: 22px; margin: 0 2px; }
body.tool-dense-ui.tool-app-shell .watermark-workbench .tool-icon .wm-i { display: block; width: 18px; height: 18px; }
body.tool-dense-ui.tool-app-shell .watermark-workbench .wm-toolbar-size { min-height: 32px; gap: 10px; }
body.tool-dense-ui.tool-app-shell .watermark-workbench .wm-toolbar-size .tool-label { flex: none; font: inherit; font-size: 12px; }
body.tool-dense-ui.tool-app-shell .watermark-workbench .toolbar input[type="range"] { flex: 1 1 0; width: 0; min-width: 0; margin: 0; }
body.tool-dense-ui.tool-app-shell .watermark-workbench #brush-size-val { min-width: 3ch; text-align: right; font-size: 12px; font-variant-numeric: tabular-nums; }
body.tool-dense-ui.tool-app-shell .watermark-workbench .wm-toolbar-view { border-top: 1px solid var(--ts-line); padding-top: 8px; }
body.tool-dense-ui.tool-app-shell .watermark-workbench .wm-toolbar-view .tool-btn { flex: 1 1 0; }
body.tool-dense-ui.tool-app-shell .watermark-workbench .toolbar .detect-status:empty,
body.tool-dense-ui.tool-app-shell .watermark-workbench .toolbar .ml-auto { display: none; }
/* 空状态只留“选择文件”；工具栏是给已载入文件的画布用的。 */
body.tool-dense-ui.tool-app-shell .watermark-workbench:not(.has-file) .toolbar { display: none !important; }
body.tool-dense-ui.tool-app-shell [data-tool-controls] .radio-group { display: flex; flex-wrap: wrap; gap: 5px; }
body.tool-dense-ui.tool-app-shell [data-tool-controls] .radio-group label { flex: 1; min-height: 30px; padding: 5px 7px; font-size: 12px; }
body.tool-dense-ui.tool-app-shell [data-tool-controls] .watermark-workbench .label { margin-top: 8px; margin-bottom: 5px; font-size: 12px; }
body.tool-dense-ui.tool-app-shell .tool-disclosure--inline { margin-top: 8px; border-top: 1px solid var(--ts-line); }
body.tool-dense-ui.tool-app-shell .tool-disclosure--inline > summary { padding-right: 0; padding-left: 0; }
body.tool-dense-ui.tool-app-shell [data-tool-controls] .hint { font-size: 12px; line-height: 1.4; }
body.tool-dense-ui.tool-app-shell .watermark-workbench [data-tool-controls] .actions { position: relative; display: grid; grid-template-columns: minmax(0,1fr) 40px; gap: 8px; margin: 12px 0; padding: 0; border: 0; background: none; box-shadow: none; }
body.tool-dense-ui.tool-app-shell .watermark-workbench [data-tool-controls] .actions > button { display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 40px !important; min-height: 40px !important; min-width: 0; padding: 8px 10px; font-size: 13px; white-space: nowrap; }
body.tool-dense-ui.tool-app-shell .watermark-workbench [data-tool-controls] #btn-remove { grid-column: 1 / -1; }
body.tool-dense-ui.tool-app-shell .watermark-workbench [data-tool-controls] #btn-start-over { width: 40px; padding: 0; }
body.tool-dense-ui.tool-app-shell .watermark-workbench [data-tool-controls] .actions .btn-icon { display: grid !important; place-items: center; width: 18px; height: 18px; margin: 0; }
body.tool-dense-ui.tool-app-shell .watermark-workbench [data-tool-controls] .actions .wm-i { display: block; }
body.tool-dense-ui.tool-app-shell .watermark-workbench [data-tool-controls] .label { margin: 6px 0; font-size: 12px; }
body.tool-dense-ui.tool-app-shell .watermark-workbench .sidebar { min-height: 0 !important; overflow-y: auto !important; overscroll-behavior-y: contain; }
@media (min-width: 1024px) {
  body.tool-dense-ui.tool-app-shell .watermark-workbench .app-grid { grid-template-rows: minmax(0, 1fr); }
  body.tool-dense-ui.tool-app-shell .watermark-workbench [data-tool-preview],
  body.tool-dense-ui.tool-app-shell .watermark-workbench [data-tool-controls] { height: 100% !important; min-height: 0 !important; max-height: 100% !important; box-sizing: border-box; }
  body.tool-dense-ui.tool-app-shell .watermark-workbench .sidebar { flex-wrap: nowrap; padding-right: 8px; }
  body.tool-dense-ui.tool-app-shell .watermark-workbench .sidebar > * { flex-shrink: 0; }
}
@media (max-width: 1023px) {
  body.tool-dense-ui.tool-app-shell .tool-detail[data-tool-slug="watermark-remover"] .watermark-workbench .tool-btn,
  body.tool-dense-ui.tool-app-shell .watermark-workbench .wm-toolbar-detect .select { min-height: 44px; }
  body.tool-dense-ui.tool-app-shell .watermark-workbench .wm-toolbar-tools .tool-btn { width: 44px; }
  body.tool-dense-ui.tool-app-shell .watermark-workbench [data-tool-controls] .actions > button { height: 44px !important; min-height: 44px !important; }
}
@media (max-width: 1023px) {
                body.tool-dense-ui.tool-app-shell [data-tool-preview] :is(.ms-board,.sll-board,.ic-preview,.watermark-workbench .editor,.tool-workbench__canvas-section) { height: auto !important; flex: 1 1 0; min-height: 0; }
}

/* One stable command row; the prompt opens above the submit dock without
   changing the scrollable controls' height or available text width. */

/* Keep auxiliary text legible; shared bottom navigation keeps its public sizing. */
body.tool-dense-ui :is(small, .desktop-secondary__back,
  .tool-feedback-trigger, .desktop-secondary__studio-toggle,
  .perspective-export-note, .pt-hint) { font-size: 12px !important; }
