/* The dock always reserves one row outside the drawing viewport. Selection
   visibility and the horizontal color editor never resize the measured canvas. */
body {
  --selection-tool-fallback: #242a35;
  --selection-tool-glass: #242a35d1;
  --selection-tool-border: #a0b2ce4d;
  --selection-tool-text: #d9e0eb;
  --selection-tool-hover: #93b1db24;
  --selection-tool-danger: #ffb4aa;
  --selection-tool-shadow: 0 3px 12px #0003;
}
body.studio-light {
  --selection-tool-fallback: #fff;
  --selection-tool-glass: #ffffffe0;
  --selection-tool-border: #52698b4d;
  --selection-tool-text: #35465b;
  --selection-tool-hover: #e1e9f6;
  --selection-tool-danger: #b42318;
  --selection-tool-shadow: 0 3px 12px #2435521a;
}
body:not(.mobile-split-open) .studio .canvas-panel:has(> #selection-tools-dock) { display: flex; flex-direction: column; }
body .studio #selection-tools-dock {
  position: relative;
  display: flex;
  flex: 0 0 49px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0;
  height: 49px;
  min-height: 49px;
  max-height: 49px;
  margin: 0;
  padding: 2px 10px;
  border-top: 1px solid var(--ui-line,#ffffff1c);
  background: var(--ui-bg,#111216);
  isolation: isolate;
}
body .studio #selection-tools-dock[hidden] { display: none !important; }
body .studio #selection-tools-dock #selection-toolbar {
  position: static !important;
  inset: auto !important;
  transform: none !important;
  display: flex;
  order: 1;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  flex-wrap: nowrap !important;
  gap: 2px;
  width: max-content;
  max-width: 100%;
  min-height: 40px;
  max-height: 44px;
  margin: 0 !important;
  padding: 1px 3px;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  border: 1px solid var(--selection-tool-border);
  border-radius: 13px;
  color: var(--selection-tool-text);
  background: var(--selection-tool-fallback);
  box-shadow: var(--selection-tool-shadow);
}
body .studio #selection-tools-dock #selection-toolbar::-webkit-scrollbar { display: none; }
body .studio #selection-tools-dock #selection-toolbar[hidden],
body .studio #selection-tools-dock #selection-colors-panel[hidden] { display: none !important; }
body .studio #selection-tools-dock:has(#selection-colors-panel:not([hidden])) #selection-toolbar { visibility: hidden; pointer-events: none; }
body .studio #selection-tools-dock #selection-toolbar > :is(#selection-toolbar-name,#selection-angle,#selection-angle + span) { display: none !important; }
body .studio #selection-tools-dock #selection-toolbar > .selection-icon-action {
  position: relative;
  display: grid;
  place-items: center;
  flex: 0 0 40px;
  width: 40px;
  min-width: 40px;
  max-width: 40px;
  height: 40px;
  min-height: 40px;
  max-height: 40px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 9px;
  color: var(--selection-tool-text);
  background: transparent;
  touch-action: manipulation;
}
body .studio #selection-tools-dock #selection-toolbar > .selection-icon-action:hover,
body .studio #selection-tools-dock #selection-toolbar > .selection-icon-action[aria-expanded="true"] { color: var(--ui-text,#edf0f7); background: var(--selection-tool-hover); }
body .studio #selection-tools-dock #selection-toolbar > .selection-icon-action:focus-visible { outline: 2px solid var(--ui-focus,#55d2e0); outline-offset: -2px; }
body .studio #selection-tools-dock #selection-toolbar #selection-delete { color: var(--selection-tool-danger); }
body .studio #selection-tools-dock #selection-toolbar #selection-rotate-left:not([hidden]) { display: grid !important; }
body .studio #selection-tools-dock #selection-toolbar .selection-icon-action svg { display: block; width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.65; stroke-linecap: round; stroke-linejoin: round; pointer-events: none; }
body .studio #selection-tools-dock #selection-toolbar #selection-color-dot { position: absolute; right: 6px; bottom: 6px; width: 8px; height: 8px; border: 1px solid var(--selection-tool-text); border-radius: 50%; pointer-events: none; }
body .studio #selection-tools-dock #selection-colors-panel {
  position: absolute;
  inset: 0;
  transform: none;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  width: 100%;
  max-width: 100%;
  height: 100%;
  min-height: 0;
  max-height: 100%;
  margin: 0;
  padding: 2px 6px;
  overflow-x: auto;
  overflow-y: hidden;
  overscroll-behavior-x: contain;
  scrollbar-width: thin;
  border: 0;
  border-radius: 0;
  color: var(--ui-text,#edf0f7);
  background: var(--ui-card,#22252e);
  box-shadow: none;
  z-index: 1;
}
body .studio #selection-tools-dock #selection-colors-panel::-webkit-scrollbar { height: 3px; }
body .studio #selection-tools-dock #selection-colors-panel::-webkit-scrollbar-thumb { border-radius: 3px; background: var(--ui-muted,#91939d); }
body .studio #selection-tools-dock #selection-colors-panel > .label-row { position: sticky; left: -6px; z-index: 2; flex: 0 0 40px; align-self: stretch; justify-content: center; min-width: 40px; margin: 0; padding: 0; background: var(--ui-card,#22252e); }
body .studio #selection-tools-dock #selection-colors-panel > .label-row > strong { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; }
body .studio #selection-tools-dock #selection-colors-panel #close-selection-colors { width: 40px; min-width: 40px; height: 40px; min-height: 40px; padding: 0; color: var(--ui-muted,#91939d); background: transparent; }
body .studio #selection-tools-dock #selection-colors-panel .swatches { flex: 0 0 auto; display: flex; flex-wrap: nowrap; align-items: center; gap: 2px; min-width: 0; margin: 0; padding: 0; }
body .studio #selection-tools-dock #selection-colors-panel .swatches:empty { display: none; }
body .studio #selection-tools-dock #selection-colors-panel .swatches::before { display: block; flex: 0 0 auto; padding: 0 4px; color: var(--ui-muted,#91939d); font: 400 11px/1.25 var(--ui-font,Arial,sans-serif); }
body .studio #selection-tools-dock #selection-source-colors::before { content: 'Original'; }
body .studio #selection-tools-dock #selection-thread-colors::before { content: 'Thread'; }
body .studio #selection-tools-dock #selection-colors-panel .swatch { position: relative; flex: 0 0 40px; width: 40px; min-width: 40px; height: 40px; min-height: 40px; margin: 0; padding: 0; border: 0; background: transparent; outline: none; transform: none; }
body .studio #selection-tools-dock #selection-colors-panel .swatch::before { content: ''; position: absolute; top: 50%; left: 50%; width: 24px; height: 24px; transform: translate(-50%,-50%); border: 1px solid var(--selection-tool-border); border-radius: 50%; background: var(--swatch); pointer-events: none; }
body .studio #selection-tools-dock #selection-colors-panel .swatch.active::before,
body .studio #selection-tools-dock #selection-colors-panel .swatch[aria-pressed="true"]::before { outline: 2px solid var(--ui-accent,#1769e8); outline-offset: 2px; }
body .studio #selection-tools-dock #selection-colors-panel .swatch:focus-visible { outline: 2px solid var(--ui-focus,#55d2e0); outline-offset: -2px; }
body .studio #selection-tools-dock #selection-print-color-label { display: flex; flex: 0 0 auto; align-items: center; gap: 6px; margin: 0; padding: 0 4px; font-size: 11px; font-weight: 400; white-space: nowrap; }
body .studio #selection-tools-dock #selection-print-color { width: 40px; height: 36px; margin: 0; }
body .studio #selection-tools-dock #selection-reprocess { flex: 0 0 auto; height: 40px; min-height: 40px; padding: 4px 8px; font-size: 11px; white-space: nowrap; }
body .studio #selection-tools-dock #selection-color-message { flex: 0 0 auto; max-width: 190px; margin: 0; padding: 0 4px; font-size: 11px; line-height: 1.3; }
body .studio #selection-tools-dock #selection-color-message:empty { display: none; }
body:not(.mobile-split-open) .studio .canvas-panel:has(> #selection-tools-dock) > .editor-footer { position: relative !important; inset: auto !important; flex: 0 0 auto; }
@supports (backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px)) {
  body .studio #selection-tools-dock #selection-toolbar { background: var(--selection-tool-glass); backdrop-filter: blur(12px) saturate(1.15); -webkit-backdrop-filter: blur(12px) saturate(1.15); }
}
@media (max-width:700px), (max-height:500px) and (pointer:coarse) {
  body .studio #selection-tools-dock { flex-basis: 53px; height: 53px; min-height: 53px; max-height: 53px; padding: 2px 8px; }
  body .studio #selection-tools-dock #selection-toolbar { max-height: 48px; }
  body .studio #selection-tools-dock #selection-toolbar > .selection-icon-action { flex-basis: 44px; width: 44px; min-width: 44px; max-width: 44px; height: 44px; min-height: 44px; max-height: 44px; }
  body .studio #selection-tools-dock #selection-colors-panel > .label-row { flex-basis: 44px; min-width: 44px; }
  body .studio #selection-tools-dock #selection-colors-panel #close-selection-colors,
  body .studio #selection-tools-dock #selection-colors-panel .swatch { flex-basis: 44px; width: 44px; min-width: 44px; height: 44px; min-height: 44px; }
  body .studio #selection-tools-dock #selection-colors-panel .swatch::before { width: 28px; height: 28px; }
  body .studio #selection-tools-dock #selection-reprocess { height: 44px; min-height: 44px; }
  body.mobile-split-open .studio #selection-tools-dock { display: none !important; }
}
