:root{font-family:system-ui,-apple-system,"Segoe UI",sans-serif;font-size:14px;color:#202530;background:#fff;--canvas-bg:#f5f6fa;--grid-line:#969da8;--surface:#fff;--border:#e5e7ef;--text:#202530;--muted:#475569;--header-h:56px;--bottom-h:72px}
*{box-sizing:border-box}body{margin:0;height:100dvh;display:grid;grid-template-rows:var(--header-h) minmax(0,1fr) var(--bottom-h);overflow:hidden;color:var(--text);background:var(--surface)}button,input,select{font:inherit}button{cursor:pointer;color:inherit;background:var(--surface);border:1px solid var(--border);border-radius:9px;min-height:38px;padding:7px 12px}button:hover{background:#f3f5ff}button:disabled{cursor:default;opacity:.65}button:focus-visible,input:focus-visible,select:focus-visible,#stage:focus-visible{outline:3px solid #6154ff;outline-offset:2px}button svg{display:block;width:24px;height:24px;flex-shrink:0}input,select{color:var(--text);background:var(--surface);border:1px solid var(--border);border-radius:6px;padding:6px;min-height:34px}input[type=checkbox]{min-height:auto}input[type=color]{width:42px;height:40px;padding:2px}input[type=range]{min-height:0}
[hidden],label[hidden]{display:none!important}.sr-only{position:absolute!important;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}
.topbar{display:flex;align-items:center;justify-content:space-between;gap:12px;padding:5px 12px;border-bottom:1px solid var(--border);background:var(--surface);z-index:3}.topbar h1{font-size:18px;line-height:1;margin:0;font-weight:800;letter-spacing:.2px;white-space:nowrap}.top-actions{display:flex;align-items:center;gap:8px}.header-icon{height:36px;min-height:36px;padding:5px 9px;display:flex;align-items:center;gap:7px;font-weight:650;white-space:nowrap;border-radius:12px}.header-icon svg{width:23px;height:23px}.account-button{background:#d7efff;border-color:#5364ff;color:#143247}
main{display:flex;min-height:0;min-width:0;overflow:hidden}#tools{display:grid;grid-template-columns:minmax(0,1fr);grid-auto-rows:var(--tool-size,40px);align-content:center;justify-items:center;gap:var(--tool-gap,8px);padding:var(--tool-padding,12px) 12px;width:73px;flex-shrink:0;min-height:0;height:100%;overflow:visible;border-right:1px solid var(--border);background:var(--surface)}#tools button{height:var(--tool-size,40px);width:var(--tool-size,40px);min-width:0;min-height:0;display:flex;align-items:center;justify-content:center;padding:0;border-radius:min(10px,calc(var(--tool-size)*.2));border:1px solid var(--border);flex-shrink:0;overflow:hidden}#tools button>svg{width:var(--tool-icon-size,26px);height:var(--tool-icon-size,26px)}#tools button span{display:none}#tools button[aria-pressed=true],#tools button[aria-expanded=true]{border:clamp(.5px,calc(var(--tool-size)*.07),3px) solid #6154ff;box-shadow:0 1px 7px #6154ff55;background:#f7f8ff}#tools [data-tool=select] svg{color:#0891b2}#tools [data-tool=rect] svg{color:#dc2626}#tools [data-tool=circle] svg{color:#0284c7}#tools [data-tool=polygon] svg{color:#7c3aed}#tools [data-tool=pencil] svg{color:#ea580c}#tools [data-tool=fill] svg{color:#be185d}#tools [data-tool=text] svg{color:#1d4ed8}#tools [data-tool=history] svg{color:#475569}#tools [data-tool=eyedropper] svg{color:#111827}#tools [data-tool=zoom] svg{color:#059669}#tools [data-tool=grid] svg{color:#4f46e5}
.editor,.workspace,#viewport{flex:1;min-height:0;min-width:0;position:relative;overflow:hidden;display:flex}.workspace,#viewport{background:var(--canvas-bg)}#stage{position:absolute;inset:0;width:100%;height:100%;touch-action:none;user-select:none;background:transparent;shape-rendering:geometricPrecision;text-rendering:geometricPrecision}
.editor-controls{min-width:0;display:grid;grid-template-columns:minmax(0,1fr) auto;align-items:center;gap:10px;padding:7px 10px;border-top:1px solid var(--border);background:var(--surface);z-index:3}.context-area{min-width:0;overflow-x:auto;overflow-y:hidden;padding:2px;scrollbar-width:none}.context-area::-webkit-scrollbar{display:none}.tool-context{display:flex;flex-wrap:nowrap;align-items:center;gap:9px;width:max-content;max-width:none;min-height:52px;padding:8px 12px;border:1px solid var(--border);border-radius:8px;background:var(--surface);box-shadow:0 1px 6px #20334c13}.tool-context:empty{border:0;box-shadow:none}.context-title,.context-group>.context-label{display:none}.context-group{display:flex;flex-wrap:nowrap;align-items:center;gap:8px;flex-shrink:0}.tool-context:not([data-tool=select]) .context-group>.context-label{display:block;font-size:12px;margin-right:3px}.context-icon{width:36px;height:36px;min-width:36px;min-height:36px;border:1px solid transparent;border-radius:6px;display:inline-flex;justify-content:center;align-items:center;gap:4px;padding:5px;background:transparent;font-size:17px;flex-shrink:0;color:#374151}.context-icon svg{width:21px;height:21px;fill:currentColor}.context-icon[aria-pressed=true]{background:#eef0ff;border-color:#6154ff}.context-icon[data-selection-command="2"]{color:#dc2626}.context-separator{height:23px;width:1px;background:var(--border);margin:0 4px;flex-shrink:0}.context-extra{display:flex;gap:5px;align-items:center}.context-extra[hidden]{display:none}.tool-context label{font-size:12px;display:flex;align-items:center;gap:6px;white-space:nowrap}.tool-context input[type=number]{width:58px}.tool-context input[type=range]{width:94px;padding:0}.tool-context #text{width:140px}.mode-label{font-size:11px}.context-icon:has(.mode-label){width:auto;padding:4px 7px}.file-actions{display:flex;align-items:center;gap:7px;flex-shrink:0}.file-actions button{height:50px;width:50px;min-height:50px;display:flex;justify-content:center;align-items:center;padding:8px;border-radius:12px;background:#f0f1f3;border-color:transparent}.file-actions button:hover{background:#e9ecf8}.file-actions svg{width:28px;height:28px}
dialog:not(.sc-dialog):not(.modal-panel):not(.unified-modal):not(.qs-device-modal):not(.cloud-modal){width:min(520px,94vw);max-height:90dvh;overflow:auto;padding:24px;border:1px solid var(--border);border-radius:14px;background:var(--surface);color:var(--text);line-height:1.55}dialog::backdrop{background:#18263e66}dialog h1{font-size:22px;margin:0 0 18px}dialog label{display:flex;align-items:center;gap:9px;margin:12px 0}dialog p{margin:12px 0}.dialog-actions,.cloud-actions{display:flex;flex-wrap:wrap;gap:9px;margin:18px 0}#tool-panel-content{display:flex;align-items:center;flex-wrap:wrap;gap:12px;margin-bottom:20px}#tool-panel-content p,#tool-panel-content output{width:100%;margin:0}#tool-panel-content .context-icon{width:42px;height:42px;border-color:var(--border)}#tool-panel-content .context-icon svg{width:27px;height:27px}#cloud-dialog:not(.sc-dialog):not(.modal-panel):not(.unified-modal):not(.qs-device-modal):not(.cloud-modal){width:min(650px,94vw)}#cloud-message{padding:10px;background:#eaf1fc;border-radius:8px}#cloud-files{list-style:none;padding:0;max-height:32dvh;overflow:auto}#cloud-files button{display:block;width:100%;text-align:left;overflow-wrap:anywhere;margin-bottom:7px}#error{position:fixed;bottom:76px;right:15px;max-width:440px;background:#fff1df;color:#5b2e00;border:2px solid #8d4400;padding:14px;border-radius:10px;z-index:20}
body.high-contrast{--text:#000;--border:#525252;--grid-line:#636363;--canvas-bg:#fff}body.large-text{font-size:17px}body.dark{--text:#edf1fa;--muted:#c7d0df;--border:#4a5568;--surface:#202938;--canvas-bg:#141c29;--grid-line:#566174}body.dark .context-icon{color:#edf1fa}body.dark .file-actions button{background:#303d50}body.dark .header-icon{color:#edf1fa}body.dark #cloud-message{background:#303d50}
@media(max-width:600px){:root{--header-h:44px;--bottom-h:58px}.topbar{padding:4px 8px;gap:6px}.topbar h1{font-size:16px}.top-actions{gap:4px}.header-icon{padding:4px 6px;gap:4px;min-height:32px;height:32px;font-size:12px}.header-icon svg{width:20px;height:20px}.editor-controls{gap:5px;padding:5px}.file-actions{gap:3px}.file-actions button{width:32px;height:38px;min-height:38px;padding:5px;border-radius:8px}.file-actions svg{width:23px;height:23px}.tool-context{padding:4px 7px;min-height:42px}.context-icon{width:30px;min-width:30px;height:30px;min-height:30px;padding:4px}.context-separator{margin:0 3px}#tools{padding-left:8px;padding-right:8px}.context-icon svg{width:20px;height:20px}}
@media print{body{display:block;height:auto;background:white}body>*{display:none!important}#print-art{display:block!important}#print-art{width:277mm;height:190mm}#print-art svg{display:block;width:100%;height:100%;max-height:none}@page{size:A4 landscape;margin:10mm}}

/* Keep the shared picker independent of generic editor button sizing. */
.sc-dialog{--panel:var(--surface);--line:var(--border);--sc-swatch:28.16px}
.sc-dialog button{min-height:0}
.sc-dialog .sc-close{padding:0}

/* App-sized swatches: two successive 20% reductions from 44px. */
.sc-dialog .sc-swatch{min-width:var(--sc-swatch);min-height:var(--sc-swatch)}

.sc-dialog .sc-grid{grid-template-columns:repeat(auto-fit,var(--sc-swatch))}

.resize-handle{r:calc(6px / var(--view-scale,1) / var(--object-scale,1));pointer-events:all;cursor:nwse-resize}
.resize-handle[data-resize="1"],.resize-handle[data-resize="5"]{cursor:ns-resize}
.resize-handle[data-resize="3"],.resize-handle[data-resize="7"]{cursor:ew-resize}
.resize-handle[data-resize="2"],.resize-handle[data-resize="6"]{cursor:nesw-resize}

.rotate-handle{r:calc(7px / var(--view-scale,1) / var(--object-scale,1));pointer-events:all;cursor:grab}
.rotate-handle:active{cursor:grabbing}

/* Circle/Ellipse flyout, matching the original SchoolDraw menu. */
.tool-submenu {
  position: fixed !important;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 4px;
  background: var(--surface);
  border: 1px solid #e6e8ee;
  border-radius: 12px;
  box-shadow:
    0 4px 16px rgb(0 0 0 / 0.12),
    0 2px 8px rgb(0 0 0 / 0.08);
  opacity: 0;
  transform: translateX(-8px) scale(0.95);
  pointer-events: none;
  transition:
    opacity 0.2s ease,
    transform 0.2s ease;
  z-index: 1000;
}
.tool-submenu.show {
  opacity: 1;
  transform: translateX(0) scale(1);
  pointer-events: all;
}
.tool-submenu-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: var(--surface);
  cursor: pointer;
  transition: all 0.15s ease;
  position: relative;
}
.tool-submenu-btn:hover {
  background: #f0f2f5;
  border-color: #e6e8ee;
}
.tool-submenu-btn.active {
  background: #f0f9ff;
  border-color: #0ea5e9;
}
.tool-submenu-btn.active::before {
  content: "";
  position: absolute;
  inset: -1px;
  border-radius: 8px;
  padding: 1px;
  background: linear-gradient(135deg, #0ea5e9, #06b6d4);
  -webkit-mask:
    linear-gradient(#fff 0 0) content-box,
    linear-gradient(#fff 0 0);
  mask:
    linear-gradient(#fff 0 0) content-box,
    linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  opacity: 0.3;
}
.tool-submenu-btn svg {
  width: 20px;
  height: 20px;
  color: #5b657a;
  transition: color 0.15s ease;
}
.tool-submenu-btn:hover svg {
  color: var(--ink, #1f2937);
}
.tool-submenu-btn.active svg {
  color: #0ea5e9;
}

.tool-submenu-btn{padding:0;flex-shrink:0}

.fill-colour-swatch{display:block;width:20px;height:20px;border:1px solid var(--border);border-radius:4px;flex-shrink:0}
.fill-hint{font-size:12px;white-space:nowrap;color:var(--muted)}

/* SVG normally ignores the interior of fill="none" artwork. Fill tools
   must receive clicks throughout the actual closed geometry, including
   rotated/flipped shapes, rather than only along their painted outline. */
#stage[data-fill-hit="true"] #art g[data-id] :is(rect,ellipse,polygon){pointer-events:all;cursor:crosshair}

/* Original SchoolDraw gradient dialog layout and controls. */
.sd-grad-panel {
  width: min(92vw, 480px);
  max-height: 90vh;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 24px 80px rgb(0 0 0 / 0.25);
  overflow: hidden;
  display: grid;
  grid-template-rows: auto 1fr auto;
  margin: auto;
  position: relative;
  transform: scale(0.95);
  opacity: 0;
  transition:
    transform 0.3s ease-out,
    opacity 0.3s ease-out;
}
#sdGradientOverlay.active .sd-grad-panel {
  transform: scale(1);
  opacity: 1;
}
.sd-grad-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid #e5e7eb;
  background: #fafafa;
  -webkit-user-select: none;
  user-select: none;
}
.sd-grad-title {
  margin: 0;
  font-weight: 600;
  font-size: 16px;
  line-height: 1.2;
  color: inherit;
}
.sd-grad-header button {
  appearance: none;
  border: 0;
  background: #fff0;
  width: 44px;
  height: 44px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: all 0.2s ease;
}
.sd-grad-header button:hover {
  background: #e5e7eb;
}
.sd-grad-header button:focus-visible {
  outline: 2px solid #3b82f6;
  outline-offset: -2px;
}
.sd-grad-body {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.sd-grad-body::-webkit-scrollbar {
  width: 8px;
}
.sd-grad-body::-webkit-scrollbar-track {
  background: #f3f4f6;
  border-radius: 4px;
}
.sd-grad-body::-webkit-scrollbar-thumb {
  background: #d1d5db;
  border-radius: 4px;
}
.sd-grad-body::-webkit-scrollbar-thumb:hover {
  background: #9ca3af;
}
.sd-grad-preview {
  width: 100%;
  height: 60px;
  border-radius: 12px;
  box-shadow: inset 0 0 0 1px rgb(0 0 0 / 0.1);
  background: linear-gradient(to right, #3b82f6, #ef4444);
  transition: background 0.3s ease;
  position: relative;
  overflow: hidden;
}
.sd-grad-preview::after {
  content: "";
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent,
    rgb(255 255 255 / 0.2),
    transparent
  );
  animation: shimmer 3s infinite;
}
.sd-grad-colors {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.sd-grad-color-box {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.sd-grad-color-label {
  font-size: 13px;
  font-weight: 600;
  color: #374151;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  -webkit-user-select: none;
  user-select: none;
}
.sd-grad-color-select {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  background: #fff;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
}
.sd-grad-color-select:hover {
  border-color: #3b82f6;
  box-shadow: 0 2px 4px rgb(0 0 0 / 0.06);
  transform: translateY(-1px);
}
.sd-grad-color-select:active {
  transform: translateY(0);
}
.sd-grad-color-select:focus-visible {
  outline: 2px solid #3b82f6;
  outline-offset: 2px;
}
.sd-grad-color-chip {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  box-shadow: inset 0 0 0 1px rgb(0 0 0 / 0.1);
  flex-shrink: 0;
  transition: transform 0.2s ease;
  background-image:
    linear-gradient(45deg, #ccc 25%, transparent 25%),
    linear-gradient(-45deg, #ccc 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #ccc 75%),
    linear-gradient(-45deg, transparent 75%, #ccc 75%);
  background-size: 8px 8px;
  background-position:
    0 0,
    0 4px,
    4px -4px,
    -4px 0;
}
.sd-grad-color-select:hover .sd-grad-color-chip {
  transform: scale(1.05);
}
.sd-grad-color-hex {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 14px;
  color: #111827;
  flex: 1;
  -webkit-user-select: all;
  user-select: all;
  text-transform: uppercase;
}
.sd-grad-steps {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.sd-grad-steps-label {
  font-size: 13px;
  font-weight: 600;
  color: #374151;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  -webkit-user-select: none;
  user-select: none;
}
.sd-grad-steps-control {
  display: flex;
  align-items: center;
  gap: 12px;
}
.sd-grad-slider {
  flex: 1;
  height: 6px;
  border-radius: 3px;
  background: #e5e7eb;
  appearance: none;
  outline: 0;
  cursor: pointer;
}
.sd-grad-slider:hover {
  background: #d1d5db;
}
.sd-grad-slider:focus-visible {
  outline: 2px solid #3b82f6;
  outline-offset: 4px;
}
.sd-grad-slider::-webkit-slider-thumb {
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #3b82f6;
  cursor: pointer;
  box-shadow: 0 2px 4px rgb(0 0 0 / 0.2);
  transition: all 0.2s ease;
}
.sd-grad-slider::-webkit-slider-thumb:hover {
  transform: scale(1.2);
  background: #2563eb;
}
.sd-grad-slider::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #3b82f6;
  cursor: pointer;
  box-shadow: 0 2px 4px rgb(0 0 0 / 0.2);
  border: none;
  transition: all 0.2s ease;
}
.sd-grad-slider::-moz-range-thumb:hover {
  transform: scale(1.2);
  background: #2563eb;
}
.sd-grad-steps-value {
  min-width: 32px;
  text-align: center;
  font-weight: 600;
  color: #111827;
  font-size: 15px;
  -webkit-user-select: none;
  user-select: none;
}
.sd-grad-direction {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.sd-grad-direction-label {
  font-size: 13px;
  font-weight: 600;
  color: #374151;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  -webkit-user-select: none;
  user-select: none;
}
.sd-grad-direction-toggle {
  display: flex;
  gap: 8px;
  padding: 6px;
  background: #f3f4f6;
  border-radius: 10px;
}
.sd-grad-dir-btn {
  padding: 8px;
  border: none;
  background: #fff0;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
  -webkit-user-select: none;
  user-select: none;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 48px;
  min-height: 48px;
  position: relative;
}
.sd-grad-dir-btn:hover {
  background: rgb(255 255 255 / 0.7);
  transform: scale(1.05);
}
.sd-grad-dir-btn:focus-visible {
  outline: 2px solid #3b82f6;
  outline-offset: -2px;
}
.sd-grad-dir-btn.active {
  background: #fff;
  box-shadow: 0 2px 6px rgb(0 0 0 / 0.12);
  transform: scale(1);
}
.sd-grad-dir-btn.active svg {
  filter: drop-shadow(0 1px 2px rgb(0 0 0 / 0.1));
}
.sd-grad-dir-icon {
  width: 48px;
  height: 32px;
  display: block;
}
.sd-grad-dir-btn::after {
  content: attr(aria-label);
  position: absolute;
  bottom: -28px;
  left: 50%;
  transform: translateX(-50%);
  background: #374151;
  color: #fff;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 11px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
  z-index: 10;
}
.sd-grad-dir-btn:hover::after {
  opacity: 1;
}
.sd-grad-footer {
  padding: 12px 16px;
  border-top: 1px solid #e5e7eb;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  background: #fafafa;
}
.sd-grad-footer .sd-btn {
  min-width: 80px;
}

#sdGradientOverlay{padding:0;border:0;width:min(92vw,480px);max-height:90dvh;overflow:hidden;background:transparent}
#sdGradientOverlay .sd-grad-panel{width:100%;max-height:90dvh;min-height:0;margin:0;transform:none;opacity:1}
#sdGradientOverlay .sd-grad-body{min-height:0;overflow-y:auto}
#sdGradientOverlay .spacer{flex:1}
#sdGradientOverlay .primary{background:#2563eb;color:white;border-color:#2563eb}
#sdGradientOverlay .sd-grad-dir-icon{width:48px;height:32px}
@media(max-width:400px){#sdGradientOverlay .sd-grad-colors{gap:10px}#sdGradientOverlay .sd-grad-color-select{padding:8px}#sdGradientOverlay .sd-grad-body{padding:14px}}

#tools button.gradient-ready{background:#eef0ff;border:2px solid #6154ff}

.canvas-text-overlay{overflow:visible}
.canvas-text-editor{white-space:pre;display:block;width:100%;height:1.35em;min-height:0;margin:0;padding:.15em 0 0;border:0;border-radius:0;outline:none!important;background:transparent;box-shadow:none;line-height:1;caret-color:currentColor;cursor:text}
#stage:has(.canvas-text-overlay){cursor:text}

.alignment-menu{width:190px}
.alignment-menu .tool-submenu-btn{width:100%;height:40px;justify-content:flex-start;gap:10px;padding:8px 12px;font-size:14px;color:var(--text)}
.alignment-menu .tool-submenu-btn svg{flex-shrink:0}

.grid-scale-action{width:auto;min-width:34px;border-color:var(--border);padding:5px 8px}
#grid-scale-readout{font-size:12px;white-space:nowrap}

/* Shared selection frames use the same visible, interactive handles as single objects. */

#print-preview-layer,#print-preview-layer *{pointer-events:none}
#preview[aria-pressed="true"]{border-color:#6154ff;background:#eef0ff}

/* Keep the original tooltip card inside small viewports and the top layer. */
#tool-tip-card{min-width:min(215px,calc(100vw - 16px));max-width:min(275px,calc(100vw - 16px));max-height:calc(100dvh - 16px);overflow:auto;inset:auto;margin:0;border:0}
#tool-tip-card::backdrop{background:transparent;pointer-events:none}
@media(prefers-reduced-motion:reduce){#tool-tip-card{transition:none}}

:root{--panel:var(--surface);--ink:var(--text);--line:var(--border);--line-strong:#8996aa;--accent:#1d4ed8;--radius:12px;--radius-sm:6px;}
dialog.stgd-modal:not([open]),dialog.stod-modal:not([open]){display:none;}
dialog.stgd-modal[open],dialog.stod-modal[open]{display:flex;}
dialog.stgd-modal .unified-container,dialog.stod-modal .unified-container{max-height:calc(100dvh - 24px);overflow:auto;}

dialog.qs-device-modal{padding:0;border:0;margin:0;width:100vw;max-width:100vw;height:100dvh;max-height:100dvh;}dialog.qs-device-modal:not([open]){display:none;}

dialog.cloud-modal {padding:0;border:0;margin:0;max-width:100vw;max-height:100dvh;background:transparent;color:#1f2937;}dialog.cloud-modal:not([open]){display:none;}dialog.cloud-modal .cloud-container{max-height:calc(100dvh - 24px);overflow:auto;}

.history-submenu{min-width:160px;padding:8px;gap:6px;z-index:10000}
.history-submenu .history-submenu-btn{width:100%;height:auto;min-height:44px;display:flex;justify-content:flex-start;gap:10px;padding:10px 12px;border-radius:10px;white-space:nowrap;font-size:14px;color:var(--text)}
.history-submenu-btn svg{width:20px;height:20px;flex-shrink:0}
.history-submenu-btn .label{flex:1;text-align:left;font-weight:500}
.history-submenu-btn .shortcut{margin-left:auto;font-size:11px;color:var(--muted)}
.history-submenu-btn:disabled{opacity:.4;cursor:default}
.history-submenu-btn.has-content:not(:disabled){color:#5145cd}
.history-submenu-btn:focus-visible{outline:2px solid #6154ff;outline-offset:1px}

.toolctx-zoom{display:flex;align-items:center;gap:8px;padding:0 4px;min-height:44px;flex-wrap:wrap}
.toolctx-zoom .zoom-btn{width:32px;height:32px;min-height:32px;padding:0;display:grid;place-items:center;border:1px solid transparent;border-radius:6px;background:var(--surface);color:var(--text)}
.toolctx-zoom .zoom-btn svg{width:20px;height:20px}
.toolctx-zoom .zoom-btn:hover:not(:disabled){background:#007bff1a;border-color:var(--border)}
.toolctx-zoom .zoom-btn:disabled{opacity:.45;cursor:default}
.toolctx-zoom .sep{height:28px;width:1px;background:var(--border);margin:0 4px}
.toolctx-zoom .zoom-slider{display:flex;flex-direction:column;gap:4px;min-width:140px}
.toolctx-zoom .slider-label{font-size:11px;color:var(--muted);white-space:nowrap}
.toolctx-zoom #zoomSlider{width:160px;margin:0;padding:0;accent-color:#3b82f6;cursor:pointer}
.toolctx-zoom .zoom-input{width:66px;min-height:30px;padding:4px 6px;text-align:center;font-size:13px;font-weight:600;font-variant-numeric:tabular-nums}
.toolctx-zoom .zoom-error{font-size:12px;color:#a13012;max-width:170px}
.toolctx-zoom .zoom-error:empty{display:none}
@media(max-width:480px){.toolctx-zoom{gap:5px}.toolctx-zoom .zoom-slider{min-width:120px}.toolctx-zoom #zoomSlider{width:120px}.toolctx-zoom .sep{margin:0}.toolctx-zoom .zoom-btn{width:30px}}

.eyedropper-controls{display:flex;align-items:center;gap:10px;flex-wrap:wrap}
.eyedropper-controls .screen-colour-pick{width:auto;white-space:nowrap;font-size:13px;padding:5px 9px;border-color:var(--border)}
#screen-colour-swatch{height:25px;width:25px;border:1px solid var(--border);border-radius:5px;flex-shrink:0}
#screen-colour-value{font-size:12px;font-variant-numeric:tabular-nums}
#screen-colour-status{font-size:12px;max-width:360px;white-space:normal;color:var(--muted)}

.display-menu {
  position: fixed;
  overflow-y: auto;
  font-size:16px;
  z-index: 10010;
  min-width: 232px;
  padding: 6px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid #93a3b5;
  border-radius: 12px;
  box-shadow: 0 10px 30px rgb(15 23 42 / 0.18);
}

.display-menu-title {
  display: block;
  padding: 6px 10px 8px;
  font-size: 0.8125rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  opacity: 0.75;
}

.display-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  min-height: 44px;             /* SC 2.5.8 Target Size */
  background: none;
  border: 0;
  border-radius: 8px;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.display-menu-item:hover {
  background: color-mix(in srgb, currentColor 8%, transparent);
}

.display-menu-item:focus-visible {
  outline: 3px solid var(--accent, #3730a3);
  outline-offset: -3px;
}

/* The tick. `aria-checked` is the single source of truth for both the state
   a screen reader is told and the mark a sighted child sees, so the two
   cannot disagree — which is the usual way a menu ends up announcing the
   opposite of what it shows. */
.display-menu-tick {
  flex: none;
  width: 18px;
  height: 18px;
  display: grid;
  place-items: center;
  font-weight: 900;
  line-height: 1;
  opacity: 0;
}

.display-menu-item[aria-checked="true"] .display-menu-tick { opacity: 1; }

/* State is never carried by the tick alone (SC 1.4.1): a chosen item is
   also bolder and sits on a tinted ground. */
.display-menu-item[aria-checked="true"] {
  font-weight: 700;
  background: color-mix(in srgb, var(--accent, #3730a3) 10%, transparent);
}

.display-menu-divider {
  height: 1px;
  margin: 6px 4px;
  background: var(--line, var(--border, #d5dce5));
}

/* Narrow screens: the menu is anchored to the right edge of a toolbar that
   may itself be near the edge of the screen, so it is allowed to shrink
   rather than push the page sideways. */
@media (max-width: 420px) {
  .display-menu { min-width: 0; width: max(180px, 60vw); }
}

@media (prefers-reduced-motion: reduce) {
  .display-menu, .display-menu-item { transition: none; }
}

/* Windows High Contrast hands every colour back to the OS and ignores custom
   properties, so the boundaries are re-established with system keywords. */
@media (forced-colors: active) {
  .display-menu { border: 1px solid CanvasText; }
  .display-menu-item[aria-checked="true"] { background: Highlight; color: HighlightText; }
}

#display[aria-expanded=true]{border-color:#6154ff;box-shadow:0 1px 7px #6154ff33}
body.large-text .display-menu{font-size:18px}
body.high-contrast .display-menu{border-color:currentColor}
body.dark.high-contrast{--text:#fff;--canvas-bg:#000;--grid-line:#aaa}
.object-properties{width:min(620px,94vw)!important}
.object-properties fieldset{display:grid;grid-template-columns:1fr 1fr;gap:10px;border:1px solid var(--border);border-radius:8px;padding:12px}
.object-properties fieldset label{display:flex;flex-direction:column;align-items:stretch;margin:0}
.object-properties fieldset input{width:100%;min-width:0}
.object-properties select{max-width:100%}
@media(max-width:480px){.object-properties fieldset{grid-template-columns:1fr}}

.display-menu-title{font-size:13px}
body.large-text .display-menu-title{font-size:14px}
