*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:       linear-gradient(135deg, #27272a 0%, #09090b 100%);
  --panel:    rgba(255,255,255,0.03);
  --border:   rgba(255,255,255,0.08);
  --accent:   #10b981;
  --accent2:  #d946ef;
  --text:     #f8fafc;
  --muted:    #94a3b8;
  --success:  #10b981;
  --error:    #ef4444;
  --radius:   10px;
}

html, body { height: 100%; overflow: hidden; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 14px;
  display: flex;
  flex-direction: column;
}

/* ── Top bar (Ribbon style) ── */
.editor-bar {
  flex-shrink: 0;
  min-height: 106px;
  background: linear-gradient(90deg, #1e3a8a 0%, #172554 100%);
  border-bottom: 1px solid rgba(96,165,250,0.3);
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.5rem .875rem;
  flex-wrap: wrap;
  z-index: 100;
}
.editor-logo {
  color: #93c5fd;
  font-weight: 800;
  font-size: .95rem;
  text-decoration: none;
  white-space: nowrap;
  flex-shrink: 0;
  background: transparent;
  -webkit-text-fill-color: #93c5fd;
}

/* Fourmeld logo container */
.custom-logo-placeholder {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  padding-right: 0.5rem;
  border-right: 1px solid rgba(96,165,250,0.25);
  margin-right: 0.25rem;
}
.custom-logo-placeholder img {
  height: 65px;
  width: auto;
  display: block;
  object-fit: contain;
}

/* ── Logo + Nav inside editor-bar ── */
.editor-nav {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.editor-logo-link {
  display: flex;
  align-items: center;
  gap: 7px;
  text-decoration: none;
  color: #93c5fd;
}
.editor-logo-img {
  height: 96px;
  width: 96px;
  object-fit: contain;
}
.editor-back-btn {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 700;
  color: #fff;
  padding: 7px 18px;
  border-radius: 8px;
  background: linear-gradient(135deg, #f59e0b 0%, #ef4444 100%);
  border: none;
  white-space: nowrap;
  transition: opacity 0.15s, transform 0.1s;
  margin-right: 6px;
  box-shadow: 0 2px 8px rgba(239,68,68,0.35);
}
.editor-back-btn:hover {
  opacity: 0.88;
  transform: translateY(-1px);
}
.editor-nav-sep {
  width: 1px;
  height: 36px;
  background: rgba(96,165,250,0.25);
  flex-shrink: 0;
  margin: 0 4px;
}
/* Hide nav on mobile (mob-bar handles navigation separately) */
@media (max-width: 767px) {
  .editor-nav, .editor-nav-sep { display: none; }
}

.editor-tools {
  display: flex;
  align-items: stretch;
  flex: 1;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.mobile-quick-tools {
  display: none;
}

.mobile-tools-toggle {
  display: none;
}

.toolbar-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  padding: 0 0.75rem;
}

.toolbar-group-items {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  flex: 1;
}

.toolbar-group-label {
  font-size: 0.65rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 0.4rem;
  font-weight: 600;
}

.tool-btn {
  background: transparent;
  border: 1.5px solid transparent;
  border-radius: 6px;
  color: var(--muted);
  cursor: pointer;
  font-size: .85rem;
  font-weight: 700;
  padding: .35rem .5rem;
  min-width: 32px;
  transition: all .15s;
  white-space: nowrap;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.tool-btn:hover  { color: var(--text); border-color: var(--border); background: rgba(255,255,255,.05); }
.tool-btn.active { color: var(--text); border-color: var(--accent); background: rgba(108,99,255,.18); }

.toolbar-sep {
  width: 1px;
  height: 44px;
  background: var(--border);
  flex-shrink: 0;
  align-self: center;
}

/* Color swatches */
.color-palette {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
}
.color-swatch {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,.2);
  cursor: pointer;
  transition: transform .15s, border-color .15s;
  flex-shrink: 0;
}
.color-swatch:hover  { transform: scale(1.2); }
.color-swatch.active { border-color: var(--accent); transform: scale(1.15); box-shadow: 0 0 0 2px rgba(108,99,255,.5); }

/* Size slider */
.size-wrap {
  display: flex;
  align-items: center;
  gap: .4rem;
  flex-shrink: 0;
}
.size-label { font-size: .72rem; color: var(--muted); white-space: nowrap; }
.size-slider {
  width: 70px;
  accent-color: var(--accent);
  cursor: pointer;
}
#size-val { font-size: .78rem; font-weight: 700; min-width: 18px; color: var(--text); }

/* Font size stepper */
.fontsize-wrap {
  display: flex;
  align-items: center;
  gap: .2rem;
  flex-shrink: 0;
}
.font-size-input {
  width: 40px;
  background: rgba(0,0,0,.35);
  border: 1.5px solid var(--border);
  border-radius: 5px;
  color: var(--text);
  font-size: .8rem;
  font-weight: 700;
  padding: .25rem .3rem;
  text-align: center;
  outline: none;
  -moz-appearance: textfield;
}
.font-size-input::-webkit-outer-spin-button,
.font-size-input::-webkit-inner-spin-button { -webkit-appearance: none; }
.font-size-input:focus { border-color: var(--accent); }
.font-step-btn { padding: .3rem .4rem !important; font-size: .78rem !important; }

/* Font family */
.font-family-sel {
  background: rgba(0,0,0,.35);
  border: 1.5px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: .78rem;
  padding: .28rem .45rem;
  outline: none;
  cursor: pointer;
  flex-shrink: 0;
  max-width: 130px;
  appearance: none;
  -webkit-appearance: none;
}
.font-family-sel:focus { border-color: var(--accent); }
.font-family-sel option { background: #1a1d2e; color: var(--text); }

/* Bold / Italic */
.fmt-btn { font-size: .95rem !important; padding: .3rem .55rem !important; }
.fmt-italic { font-style: italic; }
#btn-bold { font-weight: 900; }

/* Sign button */
.sig-btn { color: #f39c12 !important; }

/* Save area */
.editor-actions {
  display: flex;
  align-items: center;
  margin-left: auto;
  position: relative;
}
#save-status {
  font-size: .78rem;
  color: var(--muted);
  white-space: nowrap;
  position: absolute;
  right: calc(100% + 0.8rem);
  pointer-events: none;
}
.btn-save {
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  border: none;
  border-radius: 8px;
  color: #fff;
  cursor: pointer;
  font-size: .88rem;
  font-weight: 700;
  padding: .5rem 1.1rem;
  white-space: nowrap;
  transition: opacity .15s, transform .15s;
  box-shadow: 0 4px 14px rgba(59,130,246,.4);
}
.btn-save:hover    { transform: translateY(-1px); }
.btn-save:disabled { opacity: .45; cursor: not-allowed; transform: none; }

/* ── Main area ── */
.editor-main {
  flex: 1;
  display: flex;
  overflow: hidden;
}

/* ── Sidebar ── */
.editor-sidebar {
  width: 110px;
  flex-shrink: 0;
  background: var(--panel);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}
.sidebar-title {
  font-size: .7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--muted);
  padding: .625rem .75rem .35rem;
  flex-shrink: 0;
}
.thumb-item {
  margin: 4px 8px;
  border-radius: 6px;
  border: 2px solid transparent;
  cursor: pointer;
  overflow: hidden;
  transition: border-color .15s, opacity .15s;
  position: relative;
}
.thumb-item:hover    { border-color: rgba(108,99,255,.5); }
.thumb-item.active   { border-color: var(--accent); }
.thumb-item img      { width: 100%; display: block; border-radius: 4px; }
.thumb-item .thumb-num {
  position: absolute;
  bottom: 3px;
  right: 5px;
  font-size: .65rem;
  font-weight: 700;
  background: rgba(0,0,0,.6);
  color: #fff;
  border-radius: 3px;
  padding: 1px 4px;
}
.thumb-loading {
  height: 130px;
  background: rgba(255,255,255,.04);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .7rem;
  color: var(--muted);
}

/* ── Canvas area ── */
.editor-canvas-wrap {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: transparent;
}
.canvas-scroll-area {
  flex: 1;
  overflow: auto;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 1.5rem;
  background: repeating-linear-gradient(
    45deg,
    rgba(255,255,255,.015),
    rgba(255,255,255,.015) 10px,
    transparent 10px,
    transparent 20px
  );
}
.canvas-stage {
  box-shadow: 0 8px 40px rgba(0,0,0,0.1);
  border-radius: 3px;
  overflow: visible;
  cursor: crosshair;
  position: relative;
}
.canvas-stage canvas { display: block; position: relative; z-index: 1; }

/* On desktop the zoom-wrap is invisible to layout */
#canvas-zoom-wrap { display: contents; }

/* Mobile bottom bar — hidden on desktop */
.mob-bottom-bar { display: none; }

/* Page nav bar */
.page-nav-bar {
  flex-shrink: 0;
  height: 44px;
  background: var(--panel);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
}
.page-nav-btn {
  background: rgba(255,255,255,.06);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  cursor: pointer;
  font-size: .82rem;
  font-weight: 700;
  padding: .3rem .9rem;
  transition: all .15s;
}
.page-nav-btn:hover    { background: rgba(255,255,255,.12); }
.page-nav-btn:disabled { opacity: .3; cursor: not-allowed; }
#page-indicator { font-size: .82rem; color: var(--muted); font-weight: 600; }

/* ── Loading overlay ── */
.editor-loading {
  position: fixed;
  inset: 0;
  background: rgba(13,15,26,.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
  backdrop-filter: blur(4px);
}
.editor-loading.hidden { display: none; }
.editor-loading-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.25rem;
}
.editor-spinner {
  width: 42px; height: 42px;
  border: 3px solid rgba(255,255,255,.1);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
#loading-text { color: var(--muted); font-size: .9rem; }

/* ── Zoom controls ── */
.zoom-controls {
  position: absolute;
  bottom: 56px;
  right: 16px;
  display: flex;
  flex-direction: column;
  gap: .3rem;
  z-index: 10;
}
.zoom-btn {
  width: 32px; height: 32px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  cursor: pointer;
  font-size: 1rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all .15s;
}
.zoom-btn:hover { background: rgba(255,255,255,.1); }
#zoom-label {
  font-size: .68rem;
  color: var(--muted);
  text-align: center;
  font-weight: 600;
}

/* ── Text overlay ── */
.text-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;   /* overlay itself never blocks — only .tspan children do */
  z-index: 50;
}

.tspan {
  position: absolute;
  white-space: pre;
  line-height: 1;
  cursor: text;
  border: 1px solid transparent;
  border-radius: 2px;
  padding: 0;
  box-sizing: content-box;
  transition: border-color .1s, background-color .1s, box-shadow .1s;
  user-select: text;
  -webkit-user-select: text;
  overflow: visible;
  pointer-events: none;   /* off by default; text mode turns them on */
}
.tspan:not(.tspan-active):not(.tspan-edited) {
  color: rgba(0,0,0,0) !important;
  -webkit-text-fill-color: rgba(0,0,0,0) !important;
  text-shadow: none !important;
  caret-color: transparent !important;
}
.tspan:not(.tspan-active):not(.tspan-edited)::selection {
  background: transparent !important;
  color: rgba(0,0,0,0) !important;
  -webkit-text-fill-color: rgba(0,0,0,0) !important;
}
.text-overlay:not(.hidden) .tspan {
  pointer-events: auto;   /* only active when T Text tool is selected */
  border: 1px dashed rgba(108,99,255,0.3); /* Visible dashed border like Acrobat */
  background: rgba(108,99,255,0.02); /* Slight background to make them visible */
}
.tspan:not(.tspan-active):not(.tspan-edited):hover {
  border: 1px solid rgba(108,99,255,0.8) !important;
  background: rgba(108,99,255,0.1) !important;
  box-shadow: 0 0 5px rgba(108,99,255,0.3);
}
.tspan.tspan-edited {
  background: #ffffff !important;
}
.tspan.tspan-edited:hover {
  border: 1px solid rgba(108,99,255,0.8) !important;
  box-shadow: 0 0 5px rgba(108,99,255,0.3);
}
.tspan.tspan-active {
  border-color: rgba(108,99,255,.8) !important;
  background: #ffffff !important; /* Force opaque white background while editing */
  outline: none;
  z-index: 20;
  min-width: 20px;
}
/* show cursor inside active span */
.tspan[contenteditable="true"] { caret-color: #000; }

/* Cursor overrides per tool */
.canvas-stage.tool-text    { cursor: text; }
.canvas-stage.tool-draw    { cursor: crosshair; }
.canvas-stage.tool-rect    { cursor: crosshair; }
.canvas-stage.tool-circle  { cursor: crosshair; }
.canvas-stage.tool-line    { cursor: crosshair; }
.canvas-stage.tool-highlight { cursor: crosshair; }
.canvas-stage.tool-erase   { cursor: cell; }
.canvas-stage.tool-select  { cursor: default; }

/* ── Signature Modal ── */
.sig-modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.75);
  backdrop-filter: blur(8px);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
}
.sig-modal.hidden { display: none; }

.sig-box {
  background: #fff;
  border-radius: 14px;
  padding: 1.5rem;
  width: 580px;
  max-width: 95vw;
  box-shadow: 0 24px 80px rgba(0,0,0,0.2);
}

.sig-header { margin-bottom: 1rem; }
.sig-title  { font-size: 1rem; font-weight: 800; color: #1a1a2e; }
.sig-hint   { font-size: .78rem; color: #7b82a8; margin-top: .2rem; }

.sig-canvas-wrap {
  position: relative;
  border: 2px solid #e0e3ef;
  border-radius: 8px;
  overflow: hidden;
  background: #fafbff;
  margin-bottom: 1rem;
}
#sig-canvas {
  display: block;
  width: 100%;
  cursor: crosshair;
  touch-action: none;
}
.sig-baseline {
  position: absolute;
  bottom: 40px;
  left: 5%;
  right: 5%;
  height: 1px;
  background: rgba(108,99,255,.25);
  pointer-events: none;
}

.sig-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
}
.sig-actions-right { display: flex; gap: .75rem; }

.sig-btn-clear {
  background: transparent;
  border: 1.5px solid #e0e3ef;
  border-radius: 8px;
  color: #7b82a8;
  cursor: pointer;
  font-size: .85rem;
  font-weight: 700;
  padding: .55rem 1rem;
  transition: all .15s;
}
.sig-btn-clear:hover { border-color: #c0c4d8; color: #1a1a2e; }

.sig-btn-cancel {
  background: transparent;
  border: 1.5px solid #e0e3ef;
  border-radius: 8px;
  color: #7b82a8;
  cursor: pointer;
  font-size: .85rem;
  font-weight: 700;
  padding: .55rem 1.1rem;
  transition: all .15s;
}
.sig-btn-cancel:hover { border-color: #c0c4d8; color: #1a1a2e; }

.sig-btn-insert {
  background: linear-gradient(135deg, #6c63ff, #f72585);
  border: none;
  border-radius: 8px;
  color: #fff;
  cursor: pointer;
  font-size: .9rem;
  font-weight: 800;
  padding: .6rem 1.4rem;
  box-shadow: 0 4px 18px rgba(108,99,255,.4);
  transition: transform .15s, box-shadow .15s;
}
.sig-btn-insert:hover { transform: translateY(-1px); box-shadow: 0 6px 24px rgba(108,99,255,.55); }
/* ── Share Buttons ── */
.share-buttons {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: .35rem;
}
.share-btn {
  border: none;
  border-radius: 6px;
  color: #fff;
  font-size: .75rem;
  font-weight: 700;
  padding: .35rem .6rem;
  cursor: pointer;
  transition: transform .15s, opacity .15s;
  display: flex;
  align-items: center;
}
.share-btn:hover { transform: translateY(-2px); opacity: .9; }
.share-wa { background: #25D366; }
.share-fb { background: #1877F2; }
.share-gm { background: #EA4335; }

/* ── Mobile Toolbar (mob-bar) — hidden on PC ── */
.mob-bar { display: none; }

/* ── Responsive Mobile & Tablet ── */
@media (max-width: 860px) {

  /* Hide PC toolbar, show mobile bar */
  .editor-tools { display: none !important; }
  .editor-actions { display: none !important; }
  .custom-logo-placeholder { display: none; }

  /* Editor bar becomes slim container for mob-bar */
  .editor-bar {
    position: relative;
    flex-wrap: nowrap;
    height: auto;
    padding: 0;
    align-items: stretch;
    gap: 0;
    z-index: 200;
  }

  /* Mobile bar: 2-row column */
  .mob-bar {
    display: flex;
    flex-direction: column;
    width: 100%;
    padding: 0.3rem 0.4rem;
    gap: 0.25rem;
    overflow: visible;
    position: relative;
    z-index: 500;
  }
  /* Both rows scroll horizontally, dropdowns escape via fixed */
  .mob-row-1, .mob-row-2 {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    overflow-x: auto;
    overflow-y: visible;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .mob-row-1::-webkit-scrollbar,
  .mob-row-2::-webkit-scrollbar { display: none; }

  /* Base button in mob-bar */
  .mob-btn {
    background: rgba(255,255,255,0.1);
    color: #fff;
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 6px;
    padding: 0.35rem 0.6rem;
    font-size: 0.78rem;
    font-weight: 600;
    white-space: nowrap;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.15s;
  }
  .mob-btn.active,
  .mob-btn:active {
    background: rgba(96,165,250,0.35);
    border-color: #60a5fa;
  }

  /* Dropdown wrapper */
  .mob-drop-wrap {
    position: relative;
    flex-shrink: 0;
  }

  /* Dropdown panel — FIXED so it escapes scrollable toolbar overflow */
  .mob-dropdown {
    display: none;
    position: fixed;
    top: 50px;   /* just below the mob-bar */
    left: 0.5rem;
    min-width: 200px;
    max-width: 88vw;
    background: #1a2d5a;
    border: 1px solid rgba(96,165,250,0.4);
    border-radius: 10px;
    box-shadow: 0 8px 30px rgba(0,0,0,0.8);
    z-index: 9999;
    max-height: 60vh;
    overflow-y: auto;
  }
  /* Right-edge dropdowns flip left so they don’t go off screen */
  .mob-drop-wrap:last-of-type .mob-dropdown,
  .mob-drop-wrap:nth-last-of-type(2) .mob-dropdown {
    left: auto;
    right: 0.5rem;
  }
  .mob-dropdown.open { display: block; }

  .mob-drop-section {
    padding: 0.75rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
  }
  .mob-drop-section label {
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #93c5fd;
    font-weight: 700;
    margin-top: 0.25rem;
  }

  /* Full-width buttons inside dropdown */
  .mob-full-btn {
    background: rgba(255,255,255,0.07);
    color: #fff;
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 6px;
    padding: 0.5rem 0.75rem;
    font-size: 0.82rem;
    font-weight: 600;
    text-align: left;
    cursor: pointer;
    transition: background 0.15s;
    width: 100%;
  }
  .mob-full-btn:active,
  .mob-full-btn.active {
    background: rgba(96,165,250,0.25);
    border-color: #60a5fa;
  }

  /* Share icon buttons with logo + label */
  .mob-share-section { gap: 0.4rem; }
  .mob-share-icon-btn {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    background: rgba(255,255,255,0.06);
    color: #fff;
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 8px;
    padding: 0.6rem 0.8rem;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    width: 100%;
    transition: background 0.15s;
  }
  .mob-share-icon-btn:active { background: rgba(255,255,255,0.15); }
  .mob-share-icon-btn svg { flex-shrink: 0; }

  /* Row layout inside font panel */
  .mob-row,
  .mob-row-inner {
    display: flex;
    gap: 0.4rem;
    align-items: center;
  }
  .mob-sm-btn {
    background: rgba(255,255,255,0.1);
    color: #fff;
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 5px;
    padding: 0.3rem 0.6rem;
    font-size: 0.8rem;
    font-weight: 700;
    cursor: pointer;
  }
  #mob-font-size {
    width: 50px;
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 5px;
    color: #fff;
    text-align: center;
    padding: 0.3rem;
    font-size: 0.85rem;
  }
  #mob-font-family {
    width: 100%;
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 5px;
    color: #fff;
    padding: 0.4rem;
    font-size: 0.82rem;
  }
  #mob-font-family option { background: #1e2d5a; }

  /* Color swatches — all in one horizontal line */
  .mob-colors {
    flex-wrap: nowrap !important;
    gap: 0.4rem;
    overflow-x: auto;
    scrollbar-width: none;
  }
  .mob-colors::-webkit-scrollbar { display: none; }
  .mob-swatch {
    width: 22px;
    height: 22px;
    min-width: 22px;
    border-radius: 50%;
    border: 2px solid rgba(255,255,255,0.3);
    cursor: pointer;
    flex-shrink: 0;
  }
  .mob-swatch.active { border-color: #fff; transform: scale(1.2); }

  /* Save button in mob-bar */
  .mob-save {
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    color: #fff;
    border: none;
    border-radius: 6px;
    padding: 0.35rem 0.7rem;
    font-size: 0.78rem;
    font-weight: 700;
    white-space: nowrap;
    cursor: pointer;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(59,130,246,0.5);
  }

  .zoom-controls { display: none !important; }
  .page-nav-bar  { display: none !important; }

  /* ── Mobile bottom bar: page nav + zoom ── */
  .mob-bottom-bar {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 52px;
    background: var(--panel);
    border-top: 1px solid var(--border);
    padding: 0 8px;
    gap: 6px;
  }
  .mob-bottom-nav {
    display: flex;
    align-items: center;
    gap: 0;
    background: rgba(255,255,255,0.07);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 10px;
    overflow: hidden;
    flex: 1;
  }
  .mob-nav-btn {
    width: 44px;
    height: 42px;
    background: none;
    border: none;
    color: #fff;
    font-size: 22px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    touch-action: manipulation;
    flex-shrink: 0;
  }
  .mob-nav-btn:active { background: rgba(96,165,250,0.25); }
  .mob-page-label {
    flex: 1;
    text-align: center;
    font-size: 13px;
    font-weight: 600;
    color: rgba(255,255,255,0.85);
    pointer-events: none;
  }
  .mob-bottom-zoom {
    display: flex;
    align-items: center;
    gap: 0;
    background: rgba(59,130,246,0.18);
    border: 1px solid rgba(96,165,250,0.35);
    border-radius: 10px;
    overflow: hidden;
    flex-shrink: 0;
  }
  .mob-zb {
    width: 42px;
    height: 42px;
    background: none;
    border: none;
    color: #fff;
    font-size: 22px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    touch-action: manipulation;
  }
  .mob-zb:active { background: rgba(96,165,250,0.35); }
  .mob-zoom-label {
    font-size: 13px;
    font-weight: 700;
    color: #93c5fd;
    min-width: 44px;
    text-align: center;
    pointer-events: none;
  }

  /* Main area */
  .editor-main {
    flex: 1;
    flex-direction: column;
    overflow: hidden;
    display: flex;
  }

  /* Canvas wrap — flex:1 to fill available space */
  .editor-canvas-wrap {
    flex: 1;
    order: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    width: 100%;
    background: #111827;  /* match dark theme, no checkerboard */
  }

  /* Scroll area: block so the zoom-wrap drives scrollbar size */
  .canvas-scroll-area {
    display: block !important;
    overflow: auto !important;
    -webkit-overflow-scrolling: touch;
    background: #111827 !important;
    padding: 8px !important;
    flex: 1;
  }
  #canvas-zoom-wrap {
    display: inline-block;
    position: relative;
  }
  #canvas-stage {
    transform-origin: top left !important;
    display: block;
  }

  /* Thumbnail sidebar at bottom */
  .editor-sidebar {
    width: 100%;
    height: 80px;
    flex-direction: row;
    border-right: none;
    border-top: 1px solid var(--border);
    overflow-x: auto;
    overflow-y: hidden;
    align-items: center;
    order: 2;
  }
  .sidebar-title { display: none; }
  #thumb-list {
    display: flex;
    flex-direction: row;
    align-items: center;
  }
  .thumb-item {
    margin: 4px 6px;
    height: 65px;
    width: auto;
  }
  .thumb-item img {
    height: 100%;
    width: auto;
  }
}
