/* AnnotatePics Editor v2.0 — Annotely-inspired redesign */
/* Major redesign: horizontal toolbar, compact properties strip, maximized canvas */

:root {
  --editor-font: Inter, system-ui, sans-serif;
  --editor-paper: #ffffff;
  --editor-ink: #1a1a1a;
  --editor-muted: #6b7280;
  --editor-line: #e5e7eb;
  --editor-hover: #f3f4f6;
  --editor-action: #2563eb;
  --editor-action-hover: #1d4ed8;
  --editor-action-tint: #dbeafe;
  --editor-action-ink: #fff;
  --editor-accent: #eff6ff;
  --editor-focus: #2563eb;
  --editor-danger: #dc2626;
  
  /* Canvas background - checkered pattern like Annotely */
  --editor-canvas-bg: #f0f0f0;
  --editor-canvas-check1: #e8e8e8;
  --editor-canvas-check2: #f8f8f8;
  
  --editor-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  --editor-menu-shadow: 0 10px 30px rgba(0, 0, 0, 0.12);
  --editor-disabled-ink: #d1d5db;
  --editor-zoom: #27292c;
  --editor-zoom-hover: #3b3e43;
}

html, body {
  overflow-x: clip;
}

body.editor-mode {
  background: var(--editor-paper);
  color: var(--editor-ink);
  overflow: hidden;
  font-family: var(--editor-font);
}

body.editor-mode .site-header,
body.editor-mode .hero > h1,
body.editor-mode .hero > p,
body.editor-mode .hero > .eyebrow,
body.editor-mode .trust-row,
body.editor-mode main > section:not(.hero),
body.editor-mode footer {
  display: none;
}

body.editor-mode main,
body.editor-mode .hero {
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 0;
}

/* Main editor grid: top bar / tools + properties / canvas / status.
   Export options and toasts float, so they never resize the canvas. */
body.editor-mode .editor.editor-mode {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  width: 100%;
  max-width: none;
  height: 100vh;
  height: 100dvh;
  min-height: 0;
  margin: 0;
  border: 0;
  border-radius: 0;
  background: var(--editor-paper);
  box-shadow: none;
  overflow: hidden;
}

/* ==========================================================================
   TOP BAR - Keep existing design
   ========================================================================== */
body.editor-mode .editor-top {
  display: flex;
  align-items: center;
  gap: 16px;
  min-width: 0;
  min-height: 56px;
  padding: 6px 16px;
  border-bottom: 1px solid var(--editor-line);
  background: var(--editor-paper);
  grid-row: 1;
  grid-column: 1 / -1;
}

body.editor-mode .editor-brand {
  text-decoration: none;
  min-height: 44px;
  min-width: 44px;
  display: flex;
  align-items: center;
  flex: 0 0 auto;
  gap: 8px;
  color: var(--editor-ink);
  font-size: 16px;
  font-weight: 700;
  line-height: 1;
}

body.editor-mode .editor-brand-mark {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 7px;
  background: var(--editor-action);
  color: var(--editor-action-ink);
}

body.editor-mode .editor-brand-mark svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
}

body.editor-mode .file-title {
  display: flex;
  align-items: center;
  flex: 1 1 auto;
  min-width: 0;
  max-width: 32ch;
  padding-left: 16px;
  border-left: 1px solid var(--editor-line);
  text-align: left;
}

body.editor-mode .file-title .file-icon {
  display: none;
}

body.editor-mode .file-title strong {
  display: block;
  max-width: 100%;
  overflow: hidden;
  color: var(--editor-ink);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

body.editor-mode .file-title span:not(.file-icon) {
  display: block;
  max-width: 100%;
  overflow: hidden;
  color: var(--editor-muted);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

body.editor-mode .editor-actions {
  display: flex;
  align-items: center;
  flex: 0 0 auto;
  gap: 8px;
  min-width: 0;
  margin-left: auto;
}

body.editor-mode .editor-actions .divider {
  width: 1px;
  height: 24px;
  margin: 0 4px;
  background: var(--editor-line);
}

body.editor-mode .icon-btn,
body.editor-mode .secondary-action,
body.editor-mode .scale-label select {
  color: var(--editor-ink);
  background: var(--editor-paper);
  border: 1px solid var(--editor-line);
  border-radius: 8px;
}

body.editor-mode .icon-btn {
  width: 40px;
  height: 40px;
}

body.editor-mode .secondary-action {
  min-height: 40px;
  padding: 8px 12px;
  font-size: 12px;
}

body.editor-mode #copy-image {
  min-width: 104px;
}

body.editor-mode .scale-label select {
  height: 40px;
  min-width: 58px;
  padding: 4px 8px;
  font-size: 12px;
}

body.editor-mode .primary.export {
  min-height: 40px;
  padding: 8px 16px;
  border-radius: 8px;
  background: var(--editor-action);
  color: var(--editor-action-ink);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  box-shadow: none;
}

body.editor-mode .primary.export:hover:not(:disabled) {
  background: var(--editor-action-hover);
}

body.editor-mode .icon-btn:hover:not(:disabled),
body.editor-mode .secondary-action:hover:not(:disabled) {
  background: var(--editor-hover);
}

body.editor-mode .editor-close {
  order: 3;
  flex-shrink: 0;
}

/* ==========================================================================
   EDITOR BODY - New horizontal layout
   ========================================================================== */
body.editor-mode .editor-body {
  display: contents;
}

/* ==========================================================================
   HORIZONTAL TOOLBAR - Annotely style
   ========================================================================== */
body.editor-mode .toolbar {
  grid-row: 2;
  grid-column: 1;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 2px;
  width: 100%;
  min-width: 0;
  min-height: 60px;
  padding: 4px 12px;
  overflow-x: auto;
  overflow-y: hidden;
  border-bottom: 1px solid var(--editor-line);
  background: var(--editor-paper);
  scrollbar-width: thin;
  scrollbar-color: var(--editor-line) var(--editor-paper);
  overscroll-behavior-inline: contain;
}

body.editor-mode .toolbar > .toolbar-heading {
  display: none;
}

body.editor-mode .tool-grid {
  display: flex;
  align-items: center;
  flex: 0 0 auto;
  gap: 4px;
  margin: 0;
  padding: 0;
}

body.editor-mode .tool-btn,
body.editor-mode .select-tool {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  width: 50px;
  min-width: 50px;
  height: 50px;
  padding: 6px 4px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #3f3f46;
  font: 500 10.5px/1.15 var(--editor-font);
  text-align: center;
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

body.editor-mode .tool-btn svg,
body.editor-mode .select-tool svg {
  display: block;
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

body.editor-mode .tool-btn span,
body.editor-mode .select-tool span {
  display: block;
}

body.editor-mode .tool-btn:hover:not(.active):not(:disabled),
body.editor-mode .select-tool:hover:not(.active):not(:disabled) {
  background: var(--editor-hover);
  color: var(--editor-ink);
}

body.editor-mode .tool-btn.active,
body.editor-mode .select-tool.active,
body.editor-mode #pan-tool.active {
  background: var(--editor-ink);
  color: var(--editor-paper);
}

body.editor-mode .toolbar-divider {
  flex: 0 0 auto;
  width: 1px;
  height: 36px;
  margin: 0 6px;
  background: var(--editor-line);
}

body.editor-mode .select-tool {
  width: 50px;
  min-width: 50px;
}

body.editor-mode .select-tool kbd {
  display: none;
}

body.editor-mode .tool-help {
  display: none;
}

body.editor-mode .delete-tool {
  display: flex;
  color: var(--editor-danger);
}

body.editor-mode .select-tool:disabled {
  background: transparent;
  color: var(--editor-disabled-ink);
  cursor: not-allowed;
}

body.editor-mode .restore-tool {
  display: flex;
  color: var(--editor-muted);
}

/* ==========================================================================
   PROPERTIES STRIP - Compact horizontal design below toolbar
   ========================================================================== */
/* Sits at the right end of the tool row: Color / Size / Style / Objects.
   Each opens a small panel; nothing is laid out flat any more. */
body.editor-mode .inspector {
  grid-row: 2;
  grid-column: 2;
  position: relative;
  z-index: 20;
  display: flex;
  align-items: center;
  min-width: 0;
  min-height: 60px;
  max-height: none;
  padding: 4px 12px 4px 8px;
  overflow: visible;
  border-bottom: 1px solid var(--editor-line);
  background: var(--editor-paper);
}

body.editor-mode .inspector > .toolbar-heading {
  display: none;
}

body.editor-mode .quick-props {
  display: flex;
  align-items: center;
  gap: 2px;
  padding-left: 8px;
  border-left: 1px solid var(--editor-line);
}

body.editor-mode .prop-pop {
  position: relative;
}

body.editor-mode .prop-pop[hidden] {
  display: none;
}

body.editor-mode .prop-btn,
body.editor-mode .object-details > summary {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  width: 52px;
  min-width: 52px;
  height: 50px;
  min-height: 50px;
  padding: 6px 4px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #3f3f46;
  font: 500 10.5px/1.15 var(--editor-font);
  white-space: nowrap;
  cursor: pointer;
  list-style: none;
}

body.editor-mode .object-details > summary::-webkit-details-marker {
  display: none;
}

body.editor-mode .prop-btn svg,
body.editor-mode .object-details > summary svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

body.editor-mode .prop-btn:hover,
body.editor-mode .prop-btn.open,
body.editor-mode .object-details > summary:hover,
body.editor-mode .object-details[open] > summary {
  background: var(--editor-hover);
  color: var(--editor-ink);
}

body.editor-mode .color-dot {
  display: block;
  width: 20px;
  height: 20px;
  border-radius: 5px;
  background: var(--current-color, #e5484d);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.18);
}

body.editor-mode .prop-panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 40;
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: max-content;
  min-width: 220px;
  max-width: min(320px, calc(100vw - 24px));
  max-height: calc(100dvh - 150px);
  padding: 14px;
  overflow-y: auto;
  border: 1px solid var(--editor-line);
  border-radius: 12px;
  background: var(--editor-paper);
  box-shadow: var(--editor-menu-shadow);
}

body.editor-mode .prop-panel[hidden] {
  display: none;
}

body.editor-mode .settings-strip {
  width: 300px;
}

body.editor-mode .inspector .setting {
  display: flex;
  flex: 0 0 auto;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
  min-width: 0;
  margin: 0;
  padding: 0 0 14px;
  border-bottom: 1px solid var(--editor-line);
}

body.editor-mode .prop-panel > .setting:last-child,
body.editor-mode .prop-panel > .setting:has(~ .setting[hidden]):not(:has(~ .setting:not([hidden]))) {
  padding-bottom: 0;
  border-bottom: 0;
}

body.editor-mode .setting[hidden] {
  display: none;
}

body.editor-mode .setting label {
  margin: 0;
  color: var(--editor-muted);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0;
}

body.editor-mode .setting label > span {
  color: var(--editor-muted);
  font-size: 11px;
}

body.editor-mode .setting small {
  display: block;
  color: var(--editor-muted);
  font-size: 11px;
  line-height: 1.45;
  white-space: normal;
}

body.editor-mode .setting select,
body.editor-mode .setting input[type="number"] {
  width: 100%;
  min-height: 32px;
  max-height: 32px;
  padding: 4px 8px;
  color: var(--editor-ink);
  background: var(--editor-paper);
  border: 1px solid var(--editor-line);
  border-radius: 6px;
  font-size: 11px;
}

body.editor-mode .setting input[type="range"] {
  width: 100%;
  margin: 0;
}

body.editor-mode .setting .text-button {
  align-self: flex-start;
  min-height: 32px;
  padding: 0;
  font-size: 12px;
}

body.editor-mode .setting .check-row {
  display: flex;
  flex-direction: row;
  justify-content: flex-start;
  align-items: center;
  gap: 6px;
  color: var(--editor-ink);
}

body.editor-mode .setting .check-row input {
  margin: 0;
}

/* Color swatches */
body.editor-mode .inspector .setting:has(#swatches) {
  min-width: auto;
}

body.editor-mode #color-label {
  display: none;
}

body.editor-mode .swatches {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

body.editor-mode .swatch {
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
}

body.editor-mode .custom-color {
  flex: 0 0 auto;
}

/* Text formatting buttons */
body.editor-mode .text-format-buttons {
  display: flex;
  align-items: center;
  gap: 4px;
}

body.editor-mode .text-format-buttons button {
  min-width: 32px;
  min-height: 32px;
  border: 1px solid var(--editor-line);
  border-radius: 6px;
  background: var(--editor-paper);
  color: var(--editor-ink);
}

body.editor-mode .text-format-buttons button[aria-pressed="true"] {
  border-color: var(--editor-action);
  background: var(--editor-action-tint);
  color: var(--editor-focus);
}

body.editor-mode .text-format-buttons button:hover {
  background: var(--editor-hover);
}

/* Font presets */
body.editor-mode .font-presets {
  display: flex;
  gap: 4px;
}

body.editor-mode .font-presets button {
  min-height: 32px;
  padding: 4px 10px;
  border: 1px solid var(--editor-line);
  border-radius: 6px;
  background: var(--editor-paper);
  color: var(--editor-ink);
  font-size: 11px;
}

body.editor-mode .font-presets button.active,
body.editor-mode .font-presets button[aria-pressed="true"] {
  background: var(--editor-action-tint);
  border-color: var(--editor-action);
  color: var(--editor-focus);
}

/* Stroke options */
body.editor-mode .stroke-options {
  display: flex;
  gap: 4px;
}

body.editor-mode .stroke-options button {
  min-width: 56px;
  min-height: 36px;
  border: 1px solid var(--editor-line);
  border-radius: 6px;
  background: var(--editor-paper);
}

body.editor-mode .stroke-options button.active {
  background: var(--editor-action-tint);
  border-color: var(--editor-action);
}

/* Object details menu */
body.editor-mode .object-details {
  position: relative;
  display: block;
  flex: 0 0 auto;
  margin: 0;
  padding: 0;
  font-size: 11px;
}

body.editor-mode .object-details[hidden] {
  display: none;
}

/* Summary reads "Objects N"; the count becomes a small badge on the icon. */
body.editor-mode .object-details > summary {
  position: relative;
}

body.editor-mode #object-count {
  position: absolute;
  top: 3px;
  right: 8px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 8px;
  background: var(--editor-ink);
  color: var(--editor-paper);
  font-size: 9.5px;
  font-weight: 600;
  line-height: 16px;
  text-align: center;
}

body.editor-mode .object-details:not([open]) .object-menu {
  display: none;
}

body.editor-mode .object-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 40;
  display: block;
  width: 248px;
  max-height: min(360px, 55dvh);
  padding: 12px;
  overflow-y: auto;
  border: 1px solid var(--editor-line);
  border-radius: 10px;
  background: var(--editor-paper);
  box-shadow: var(--editor-menu-shadow);
}

body.editor-mode .object-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px;
  margin: 0 0 8px;
}

body.editor-mode .object-actions button {
  min-height: 34px;
  padding: 6px 8px;
  color: var(--editor-ink);
  background: var(--editor-paper);
  border: 1px solid var(--editor-line);
  border-radius: 6px;
  font-size: 11px;
}

body.editor-mode #object-list {
  max-height: 188px;
  margin: 0;
  padding: 0;
  overflow: auto;
}

body.editor-mode #object-list button {
  width: 100%;
  min-height: 34px;
  padding: 8px;
  text-align: left;
  color: var(--editor-ink);
  background: var(--editor-paper);
  border: 1px solid var(--editor-line);
  border-radius: 6px;
  font-size: 11px;
}

body.editor-mode #object-list button[aria-pressed="true"] {
  background: var(--editor-action-tint);
  border-color: var(--editor-action);
  color: var(--editor-focus);
}

body.editor-mode .privacy-card {
  display: none;
}

/* ==========================================================================
   WORKSPACE - Maximized canvas with checkered background
   ========================================================================== */
body.editor-mode .workspace {
  grid-row: 3;
  grid-column: 1 / -1;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  min-height: 0;
  height: 100%;
  padding: 24px;
  overflow: hidden;
  background: var(--editor-canvas-bg);
  background-image: 
    linear-gradient(45deg, var(--editor-canvas-check1) 25%, transparent 25%),
    linear-gradient(-45deg, var(--editor-canvas-check1) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, var(--editor-canvas-check1) 75%),
    linear-gradient(-45deg, transparent 75%, var(--editor-canvas-check1) 75%);
  background-size: 20px 20px;
  background-position: 0 0, 0 10px, 10px -10px, -10px 0;
}

body.editor-mode #canvas-shell {
  flex: 0 0 auto;
  max-width: 100%;
  max-height: 100%;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: var(--editor-shadow);
}

body.editor-mode #canvas-container {
  max-width: 100%;
  max-height: 100%;
  line-height: 0;
}

/* Zoom: compact group inside the bottom bar */
body.editor-mode .view-controls {
  position: static;
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 2px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  transform: none;
}

body.editor-mode .view-controls[hidden] {
  display: none;
}

body.editor-mode .view-controls button {
  min-width: 28px;
  min-height: 28px;
  padding: 0 6px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--editor-ink);
  font-size: 15px;
  line-height: 1;
}

body.editor-mode .view-controls #view-reset {
  min-width: 48px;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

body.editor-mode .view-controls button:hover:not(:disabled) {
  background: var(--editor-hover);
}

body.editor-mode .view-controls button:disabled {
  color: var(--editor-disabled-ink);
  cursor: not-allowed;
}

/* Change image: a plain header action */
body.editor-mode .replace-image {
  position: static;
  transform: none;
  box-shadow: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 40px;
  padding: 8px 12px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--editor-ink);
  font-size: 12px;
  white-space: nowrap;
}

body.editor-mode .replace-image[hidden] {
  display: none;
}

body.editor-mode .replace-image svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

body.editor-mode .replace-image:hover {
  background: var(--editor-hover);
}

/* Export PNG + options chevron, joined as a split button */
body.editor-mode .export-group {
  display: flex;
  align-items: stretch;
}

body.editor-mode .export-group .primary.export {
  border-radius: 8px 0 0 8px;
}

body.editor-mode .export-group .export-more {
  display: grid;
  place-items: center;
  width: 32px;
  min-height: 40px;
  padding: 0;
  border: 0;
  border-left: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 0 8px 8px 0;
  background: var(--editor-action);
  color: var(--editor-action-ink);
  box-shadow: none;
}

body.editor-mode .export-group .export-more:hover:not(:disabled),
body.editor-mode .export-group .export-more[aria-expanded="true"] {
  background: var(--editor-action-hover);
}

body.editor-mode .export-group .export-more:disabled {
  opacity: 0.5;
}

body.editor-mode .export-group .export-more svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Export options: popover under the header, right-aligned */
body.editor-mode .export-settings {
  position: absolute;
  top: 60px;
  right: 12px;
  z-index: 50;
  width: min(440px, calc(100vw - 24px));
  max-height: calc(100dvh - 120px);
  margin: 0;
  padding: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  border: 1px solid var(--editor-line);
  border-radius: 12px;
  background: var(--editor-paper);
  box-shadow: var(--editor-menu-shadow);
  color: var(--editor-muted);
  font-size: 12px;
  text-align: left;
}

body.editor-mode .export-settings[hidden] {
  display: none;
}

body.editor-mode .export-settings summary {
  display: none;
}

body.editor-mode .export-options-body {
  padding: 16px;
}

/* Export fields grid */
.export-settings .export-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px 16px;
  align-items: end;
  max-width: 760px;
}

.export-settings .export-fields label:has(#export-name) {
  grid-column: 1 / -1;
}

.export-settings .export-fields label:has(#beautiful) {
  grid-column: 1/-1;
  padding-top: 12px;
  border-top: 1px solid var(--editor-line);
}

.export-settings .export-fields label:has(#export-shadow) {
  grid-column: 1/-1;
}

.export-settings .export-fields input:not([type="checkbox"]),
.export-settings .export-fields select {
  width: 100%;
  max-width: none;
}

.export-settings .export-fields input[type="color"] {
  padding: 4px;
}

.export-settings .export-fields label.check-row {
  flex-direction: row !important;
  justify-content: flex-start;
  align-items: center;
  gap: 8px;
  text-align: left;
}

/* Bottom status bar */
body.editor-mode .editor-bottom {
  grid-row: 4;
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 36px;
  height: auto;
  padding: 4px 12px 4px 16px;
  padding-bottom: max(6px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--editor-line);
  background: var(--editor-paper);
  color: var(--editor-muted);
  font-size: 11px;
  text-align: left;
}

body.editor-mode #save-draft {
  flex: 0 0 auto;
  min-height: 28px;
  padding: 4px 10px;
  border: 1px solid var(--editor-line);
  border-radius: 6px;
  background: var(--editor-paper);
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

body.editor-mode #save-draft:hover {
  background: var(--editor-hover);
}

body.editor-mode .local-status {
  flex: 1;
  min-width: 0;
  max-width: 80%;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

body.editor-mode #status {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

body.editor-mode #tool-status {
  display: block;
  flex: 0 0 auto;
  color: var(--editor-ink);
  font-weight: 500;
}

body.editor-mode .bottom-tip {
  display: none;
}

/* Toast: floats above the bottom bar, never takes layout space */
body.editor-mode #toast {
  position: absolute;
  bottom: 52px;
  left: 50%;
  z-index: 60;
  display: block;
  width: max-content;
  min-width: 0;
  max-width: min(560px, calc(100% - 32px));
  margin: 0;
  padding: 10px 16px;
  border-radius: 10px;
  background: var(--editor-zoom);
  color: var(--editor-paper);
  box-shadow: var(--editor-menu-shadow);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 6px);
  text-align: center;
  font-size: 12px;
  line-height: 1.5;
  overflow-wrap: anywhere;
  transition: opacity 0.18s ease, transform 0.18s ease;
}

body.editor-mode #toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* Text editor */
body.editor-mode .text-button {
  color: var(--editor-focus);
  font-weight: 500;
}

body.editor-mode #inline-text-editor {
  max-width: none;
  min-width: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  transform-origin: 0 0;
}

body.editor-mode #inline-text-editor textarea {
  display: block;
  box-sizing: border-box;
  min-width: 0;
  min-height: 0;
  margin: 0;
  border: 0;
  border-radius: 0;
  overflow: hidden;
  resize: none;
  background: transparent;
  box-shadow: none;
  color: var(--editor-ink);
  outline: 2px dashed var(--editor-action);
  outline-offset: 2px;
  caret-color: var(--editor-action);
  white-space: pre-wrap;
  overflow-wrap: break-word;
}

body.editor-mode #inline-text-editor textarea:focus-visible {
  outline: 2px solid var(--editor-action);
  outline-offset: 2px;
}

body.editor-mode #inline-text-editor textarea::placeholder {
  color: var(--editor-ink);
  opacity: 0.7;
}

/* Crop controls */
body.editor-mode .crop-controls {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 24px;
  background: var(--editor-zoom);
  color: var(--editor-paper);
  box-shadow: var(--editor-shadow);
}

body.editor-mode .crop-controls span {
  color: var(--editor-paper);
  font-size: 12px;
}

body.editor-mode .crop-controls button {
  min-height: 32px;
  padding: 6px 12px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 16px;
  background: transparent;
  color: var(--editor-paper);
  font-size: 11px;
}

body.editor-mode .crop-controls button:hover {
  background: var(--editor-zoom-hover);
}

body.editor-mode .crop-controls button.primary {
  background: var(--editor-paper);
  color: var(--editor-ink);
  border-color: var(--editor-paper);
}

body.editor-mode .crop-controls button.primary:hover {
  background: var(--editor-hover);
}

/* Focus styles */
body.editor-mode button:focus-visible,
body.editor-mode select:focus-visible,
body.editor-mode input:focus-visible,
body.editor-mode textarea:focus-visible,
body.editor-mode summary:focus-visible {
  outline: 2px solid var(--editor-focus);
  outline-offset: 2px;
  box-shadow: 0 0 0 4px var(--editor-accent);
}

body.editor-mode .view-controls button:focus-visible {
  outline-color: var(--editor-paper);
  outline-offset: -4px;
}

body.editor-mode .editor-brand:focus-visible {
  outline: 2px solid var(--editor-ink);
  outline-offset: 3px;
  border-radius: 4px;
}

/* Active states */
body.editor-mode .tool-btn:active,
body.editor-mode .select-tool:active,
body.editor-mode .primary.export:active {
  transform: translateY(1px);
}

/* Unsaved indicator */
.editor.has-unsaved .local-status > span:first-child {
  background: #f59f00 !important;
}

.editor.has-unsaved #save-draft {
  border-color: #f59f00;
  box-shadow: 0 0 0 2px rgba(245, 159, 0, 0.25);
}

/* ==========================================================================
   RESPONSIVE DESIGN
   ========================================================================== */
@media (max-width: 860px) {
  body.editor-mode .editor-top {
    flex-wrap: wrap;
    gap: 8px;
    min-height: 104px;
    padding: 8px 12px;
  }

  body.editor-mode .editor-brand {
    font-size: 14px;
  }

  body.editor-mode .file-title {
    flex: 1 1 110px;
    max-width: none;
    padding-left: 8px;
  }

  body.editor-mode .file-title strong {
    font-size: 11px;
  }

  body.editor-mode .file-title span:not(.file-icon) {
    font-size: 10px;
  }

  body.editor-mode .editor-actions {
    justify-content: space-between;
    width: 100%;
    margin-left: 0;
    gap: 4px;
  }

  body.editor-mode .editor-actions .divider {
    display: none;
  }

  body.editor-mode .editor-actions .icon-btn {
    width: 36px;
    height: 38px;
  }

  body.editor-mode .editor-actions #copy-image {
    min-width: 92px;
    min-height: 38px;
    padding: 8px;
  }

  body.editor-mode .editor-actions .scale-label select {
    height: 38px;
    min-width: 50px;
    padding: 4px;
  }

  body.editor-mode .primary.export {
    min-height: 38px;
    margin-left: auto;
    padding: 8px 12px;
  }

  body.editor-mode .editor-close {
    order: 0;
    margin-left: auto;
  }

  body.editor-mode .editor-actions {
    order: 1;
  }

  body.editor-mode .toolbar {
    padding: 4px 8px;
  }

  body.editor-mode .tool-btn,
  body.editor-mode .select-tool {
    width: 48px;
    min-width: 48px;
  }

  body.editor-mode .prop-btn,
  body.editor-mode .object-details > summary {
    width: 48px;
    min-width: 48px;
  }

  body.editor-mode .inspector {
    padding: 4px 8px 4px 4px;
  }

  body.editor-mode .workspace {
    padding: 12px;
  }

  body.editor-mode .view-controls button {
    min-height: 32px;
  }

  body.editor-mode .export-options-body {
    padding: 12px;
  }

  body.editor-mode .editor-bottom {
    gap: 8px;
    padding: 6px 12px;
  }

  body.editor-mode #tool-status {
    display: none;
  }

  .export-settings .export-fields {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .export-settings .export-fields label:has(#export-name) {
    grid-column: 1/-1;
  }
}

/* Phones: tools get the full row; properties drop to a slim row of their own */
@media (max-width: 640px) {
  body.editor-mode .editor.editor-mode {
    grid-template-rows: auto auto auto minmax(0, 1fr) auto;
  }

  body.editor-mode .toolbar {
    grid-column: 1 / -1;
  }

  body.editor-mode .inspector {
    grid-row: 3;
    grid-column: 1 / -1;
    justify-content: flex-end;
    min-height: 44px;
    padding: 2px 8px;
  }

  body.editor-mode .quick-props {
    padding-left: 0;
    border-left: 0;
  }

  body.editor-mode .prop-btn,
  body.editor-mode .object-details > summary {
    flex-direction: row;
    gap: 6px;
    width: auto;
    min-width: 44px;
    height: 40px;
    min-height: 40px;
    padding: 0 10px;
    font-size: 11.5px;
  }

  body.editor-mode .prop-btn svg,
  body.editor-mode .object-details > summary svg,
  body.editor-mode .color-dot {
    width: 18px;
    height: 18px;
  }

  body.editor-mode #object-count {
    position: static;
  }

  body.editor-mode .workspace {
    grid-row: 4;
  }

  body.editor-mode .editor-bottom {
    grid-row: 5;
  }

  body.editor-mode .replace-image span {
    display: none;
  }

  /* Keep every header action on one line at 360–640px */
  body.editor-mode .editor-actions {
    flex-wrap: wrap;
    gap: 4px;
  }

  body.editor-mode .replace-image,
  body.editor-mode .editor-actions .icon-btn {
    width: 34px;
    min-height: 38px;
    padding: 0;
    justify-content: center;
  }

  body.editor-mode .editor-actions .scale-label select {
    min-width: 46px;
    padding: 4px;
  }

  body.editor-mode .editor-actions #copy-image {
    min-width: 0;
    padding: 6px 8px;
    font-size: 11px;
  }

  body.editor-mode .primary.export {
    margin-left: 0;
    padding: 6px 10px;
    font-size: 11px;
  }

  body.editor-mode .primary.export svg {
    display: none;
  }

  body.editor-mode .export-group {
    margin-left: auto;
  }

  body.editor-mode .export-group .export-more {
    width: 28px;
    min-height: 38px;
  }
}

@media (max-width: 380px) {
  body.editor-mode .editor-brand strong {
    display: none;
  }

  body.editor-mode .replace-image,
  body.editor-mode .editor-actions .icon-btn {
    width: 30px;
  }

  body.editor-mode .editor-actions .scale-label select {
    min-width: 0;
    width: 42px;
  }
}

@media (prefers-reduced-motion: reduce) {
  body.editor-mode *,
  body.editor-mode *::before,
  body.editor-mode *::after {
    scroll-behavior: auto;
    transition: none;
    animation: none;
  }
}

/* Phone toolbar order - priority tools first */
@media (max-width: 860px) {
  body.editor-mode .select-tool#select-tool {
    order: -7;
  }
  body.editor-mode .tool-btn[data-tool="arrow"] {
    order: -6;
  }
  body.editor-mode .tool-btn[data-tool="text"] {
    order: -5;
  }
  body.editor-mode .tool-btn[data-tool="rect"] {
    order: -4;
  }
  body.editor-mode .tool-btn[data-tool="blur"] {
    order: -3;
  }
  body.editor-mode .tool-btn[data-tool="highlight"] {
    order: -2;
  }
}

/* Empty state - awaiting image */
.empty-state p.upload-heading {
  margin: 12px 0;
  color: var(--editor-ink);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0;
  line-height: 1.3;
}
