:root {
  color-scheme: only light;
  --bg: #f5f6f8;
  --panel: rgba(255,255,255,0.86);
  --panel-strong: rgba(255,255,255,0.96);
  --border: rgba(15,23,42,0.08);
  --hair: rgba(15,23,42,0.06);
  --text: #0f172a;
  --muted: #667085;
  --shadow: 0 16px 40px rgba(15, 23, 42, 0.08), 0 4px 16px rgba(15,23,42,0.04);
  --radius-xl: 24px;
  --radius-lg: 18px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --accent: #111827;
  --accent-soft: #eef2ff;
  --danger: #b91c1c;
  --grid-light: rgba(15,23,42,0.06);
  --grid-strong: rgba(15,23,42,0.1);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; background: radial-gradient(circle at top, #fbfbfd 0%, #f4f6f9 62%, #eef2f6 100%); color: var(--text); }
body { overscroll-behavior: none; touch-action: manipulation; }

body,
.app-shell,
.library-screen,
.editor-screen,
.canvas-wrap,
.board-svg,
.board-svg *,
.focus-chrome,
.zoom-hud,
.minimap,
.left-panel,
.right-panel,
.utility-dock,
.present-overlay,
.object-context-menu,
.focus-text-bar {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

textarea,
input,
select,
option,
[contenteditable="true"] {
  -webkit-user-select: text;
  user-select: text;
  -webkit-touch-callout: default;
}
button, input, textarea { font: inherit; }
button { cursor: pointer; border: 1px solid var(--border); background: rgba(255,255,255,0.84); color: var(--text); border-radius: 12px; padding: 10px 14px; transition: transform .14s ease, background .14s ease, border-color .14s ease, box-shadow .14s ease; }
button:hover { transform: translateY(-1px); box-shadow: 0 8px 20px rgba(15,23,42,0.06); }
button:active { transform: translateY(0); }
button.compact { padding: 8px 10px; border-radius: 10px; }
button.full { width: 100%; justify-content: center; }
button.danger { color: var(--danger); }
input[type="search"], input[type="text"], input[type="number"] { width: 100%; border: 1px solid var(--border); background: rgba(255,255,255,0.94); border-radius: 12px; padding: 12px 14px; color: var(--text); }
input[type="range"] { width: 100%; }
.hidden { display: none !important; }
.glass { backdrop-filter: blur(22px); -webkit-backdrop-filter: blur(22px); background: var(--panel); border: 1px solid var(--border); box-shadow: var(--shadow); }
.primary-btn { background: linear-gradient(180deg, #111827 0%, #1f2937 100%); color: #fff; border-color: rgba(17,24,39,0.28); }
.secondary-btn { background: rgba(255,255,255,0.9); }
.icon-btn { width: 42px; height: 42px; padding: 0; display: inline-flex; align-items: center; justify-content: center; font-size: 18px; }
.subtle { color: var(--muted); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.eyebrow { margin: 0 0 6px; font-size: 12px; text-transform: uppercase; letter-spacing: 0.16em; color: #6b7280; }
.app-shell, .library-screen, .editor-screen { width: 100%; height: 100%; }
.library-screen { padding: 24px; display: flex; flex-direction: column; gap: 18px; overflow: auto; }
.library-header, .library-toolbar { border-radius: 28px; padding: 24px; display: flex; gap: 24px; align-items: center; justify-content: space-between; }
.library-header h1 { margin: 0 0 8px; font-size: clamp(34px, 4vw, 58px); line-height: 1; letter-spacing: -0.05em; }
.library-header .subtle { max-width: 720px; font-size: 16px; }
.library-actions { display: flex; gap: 12px; flex-wrap: wrap; }
.search-wrap { flex: 1; }
.toolbar-meta { display: flex; gap: 12px; align-items: center; }
.board-grid { display: grid; gap: 18px; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); padding-bottom: 40px; }
.board-card { border-radius: 24px; padding: 14px; display: flex; flex-direction: column; gap: 12px; }
.open-board-card { all: unset; cursor: pointer; display: block; }
.board-thumb-wrap { aspect-ratio: 1.55 / 1; background: linear-gradient(180deg, rgba(255,255,255,0.9), rgba(243,244,246,0.95)); border-radius: 18px; overflow: hidden; border: 1px solid var(--hair); }
.board-thumb { width: 100%; height: 100%; object-fit: cover; display: block; }
.board-card-body { padding: 10px 4px 0; }
.board-title { margin: 0; font-size: 18px; letter-spacing: -0.02em; }
.board-meta { margin: 6px 0 0; color: var(--muted); font-size: 13px; }
.board-card-actions { display: flex; gap: 10px; }
.editor-screen { display: flex; flex-direction: column; }
.topbar { margin: 14px 14px 0; border-radius: 22px; display: grid; grid-template-columns: minmax(220px, 1fr) minmax(0, 1.25fr) minmax(220px, 1fr); align-items: center; gap: 12px; padding: 10px 14px; z-index: 30; }
.topbar-left, .topbar-right, .topbar-center { display: flex; align-items: center; gap: 12px; }
.topbar-center { justify-content: center; min-width: 0; overflow: hidden; }
.topbar-right { justify-content: flex-end; min-width: 0; flex-wrap: nowrap; overflow-x: auto; overflow-y: hidden; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
.topbar-right::-webkit-scrollbar { display: none; }
.board-title-wrap { display: flex; align-items: center; gap: 12px; min-width: 0; }
.board-title-input { width: min(360px, 42vw); border: none; background: transparent; font-size: 20px; letter-spacing: -0.03em; padding: 8px 4px; }
.board-title-input:focus { outline: none; }
.save-state { font-size: 12px; color: var(--muted); }
.tool-pills { display: flex; flex-wrap: nowrap; overflow: auto hidden; gap: 8px; padding: 4px; }
.tool-pills::-webkit-scrollbar { display: none; }
.tool-btn.active { background: #111827; color: #fff; border-color: rgba(17,24,39,0.25); }
.workspace { min-height: 0; flex: 1; display: grid; grid-template-columns: 276px minmax(0, 1fr) 318px; gap: 14px; padding: 14px; }
.left-panel, .right-panel { border-radius: 24px; padding: 18px; overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain; display: flex; flex-direction: column; gap: 18px; min-width: 0; }
.panel-section { display: flex; flex-direction: column; gap: 14px; }
.panel-header { display: flex; justify-content: space-between; gap: 12px; align-items: center; }
.panel-header h2 { margin: 0; font-size: 14px; letter-spacing: 0.03em; text-transform: uppercase; color: #475467; }
.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field-grid.single { grid-template-columns: 1fr; }
.field-row { display: flex; flex-direction: column; gap: 8px; font-size: 13px; color: #475467; }
.toggle-row { flex-direction: row; align-items: center; justify-content: space-between; padding: 12px 14px; border: 1px solid var(--hair); border-radius: 14px; background: rgba(255,255,255,0.66); }
.layers-list { display: flex; flex-direction: column; gap: 8px; max-height: 360px; overflow: auto; }
.layer-item { width: 100%; display: flex; justify-content: space-between; align-items: center; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--hair); background: rgba(255,255,255,0.7); }
.layer-item.active { outline: 2px solid rgba(17,24,39,0.12); background: rgba(17,24,39,0.06); }
.canvas-shell { position: relative; min-width: 0; min-height: 0; }
.canvas-wrap { position: relative; width: 100%; height: 100%; border-radius: 28px; overflow: hidden; background: #fcfcfd; box-shadow: inset 0 0 0 1px rgba(15,23,42,0.06), var(--shadow); }
.canvas-wrap::before, .canvas-wrap::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
}
.canvas-wrap.grid-on::before {
  background-image:
    linear-gradient(to right, var(--grid-light) 1px, transparent 1px),
    linear-gradient(to bottom, var(--grid-light) 1px, transparent 1px),
    linear-gradient(to right, transparent 63px, var(--grid-strong) 64px),
    linear-gradient(to bottom, transparent 63px, var(--grid-strong) 64px);
  background-size: var(--grid-size-small, 16px) var(--grid-size-small, 16px), var(--grid-size-small, 16px) var(--grid-size-small, 16px), var(--grid-size-big, 64px) var(--grid-size-big, 64px), var(--grid-size-big, 64px) var(--grid-size-big, 64px);
  background-position: var(--grid-offset-x, 0px) var(--grid-offset-y, 0px), var(--grid-offset-x, 0px) var(--grid-offset-y, 0px), var(--grid-offset-x, 0px) var(--grid-offset-y, 0px), var(--grid-offset-x, 0px) var(--grid-offset-y, 0px);
}
.board-svg { width: 100%; height: 100%; display: block; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.floating-editor { position: absolute; min-width: 160px; min-height: 60px; border-radius: 14px; border: 1px solid rgba(17,24,39,0.14); box-shadow: 0 18px 42px rgba(15,23,42,0.16); padding: 14px; resize: both; background: rgba(255,255,255,0.98); color: var(--text); z-index: 25; }
.minimap { position: absolute; right: 18px; bottom: 18px; width: 220px; height: 140px; border-radius: 18px; overflow: hidden; }
.minimap svg { width: 100%; height: 100%; display: block; }
.zoom-hud { position: absolute; left: 18px; bottom: 18px; display: flex; align-items: center; gap: 8px; border-radius: 16px; padding: 10px; }
.selection-summary { padding: 14px; border-radius: 14px; background: rgba(255,255,255,0.66); border: 1px solid var(--hair); }
.inspector-actions, .action-stack, .layer-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.shortcut-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.present-overlay { position: fixed; inset: 0; background: radial-gradient(circle at top, rgba(255,255,255,0.14) 0%, rgba(244,246,249,0.18) 46%, rgba(233,238,244,0.22) 100%); opacity: 0; pointer-events: none; transition: opacity 180ms ease; z-index: 95; }
.present-overlay.active { opacity: 1; pointer-events: none; }
.present-top { position: fixed; top: max(18px, env(safe-area-inset-top, 0px) + 12px); right: max(18px, env(safe-area-inset-right, 0px) + 12px); display: flex; gap: 10px; z-index: 2; pointer-events: auto; }
.present-top * { pointer-events: auto; }
body.present-mode { background: #eef2f6; }
body.present-mode .library-screen { display: none !important; }
body.present-mode .editor-screen { position: fixed; inset: 0; z-index: 90; background: radial-gradient(circle at top, #fbfbfd 0%, #f4f6f9 58%, #eef2f6 100%); }
body.present-mode .topbar,
body.present-mode .left-panel,
body.present-mode .right-panel,
body.present-mode .focus-chrome,
body.present-mode .zoom-hud,
body.present-mode .minimap { display: none !important; }
body.present-mode .workspace { grid-template-columns: 1fr; padding: 0; gap: 0; }
body.present-mode .canvas-shell,
body.present-mode .canvas-wrap { width: 100%; height: 100%; min-height: 100vh; }
body.present-mode .canvas-wrap { border-radius: 0; box-shadow: none; overscroll-behavior: contain; }
body.present-mode .canvas-wrap::after { opacity: 0; }
#presentBtn.is-active,
#focusPresentBtn.is-active { background: linear-gradient(180deg, #0f172a 0%, #111827 100%); color: #fff; border-color: rgba(15,23,42,0.18); }
.selected-outline { fill: none; stroke: #2563eb; stroke-width: 1.4; vector-effect: non-scaling-stroke; stroke-dasharray: 7 5; pointer-events: none; }
.handle { pointer-events: all; }
.handle-hit { fill: rgba(37,99,235,0.001); stroke: transparent; vector-effect: non-scaling-stroke; }
.handle-core { fill: #fff; stroke: #2563eb; stroke-width: 1.4; vector-effect: non-scaling-stroke; }
.handle.cursor-line { cursor: grab; }
.handle.cursor-ns { cursor: ns-resize; }
.handle.cursor-ew { cursor: ew-resize; }
.handle.cursor-nesw { cursor: nesw-resize; }
.handle.cursor-nwse { cursor: nwse-resize; }
.object-path { fill: none; stroke-linecap: round; stroke-linejoin: round; }
.object-highlighter { mix-blend-mode: multiply; }
.object-sticky-shadow { filter: drop-shadow(0 12px 18px rgba(15,23,42,0.08)); }
.object-selected > * { filter: drop-shadow(0 0 0 rgba(0,0,0,0)); }
.empty-state { padding: 24px; color: var(--muted); }
@media (max-width: 1200px) {
  .workspace { grid-template-columns: 240px minmax(0, 1fr) 240px; }
}
@media (max-width: 980px) {
  .topbar { grid-template-columns: 1fr; }
  .topbar-center { justify-content: flex-start; }
  .workspace { grid-template-columns: 1fr; }
  .left-panel, .right-panel { max-height: 220px; }
}

@media (max-width: 1280px) {
  .topbar {
    grid-template-columns: minmax(220px, 1fr) minmax(0, 1fr) minmax(220px, auto);
  }

  .topbar-center {
    justify-content: flex-start;
  }

  .tool-pills-shell {
    width: 100%;
    max-width: 100%;
  }

  .tool-pills {
    flex-wrap: nowrap;
    overflow-x: auto;
  }

  .topbar-right {
    justify-content: flex-start;
    overflow-x: auto;
    overscroll-behavior-x: contain;
  }

  .topbar-right > * {
    flex: 0 0 auto;
  }
}

@media (max-width: 720px) {
  .library-screen { padding: 14px; }
  .library-header, .library-toolbar { padding: 18px; border-radius: 22px; flex-direction: column; align-items: flex-start; }
  .topbar { margin: 10px 10px 0; padding: 10px; border-radius: 18px; }
  .board-title-input { width: 100%; }
  .workspace { padding: 10px; gap: 10px; }
  .canvas-wrap { min-height: 46vh; border-radius: 22px; }
  .minimap { width: 160px; height: 110px; }
  .zoom-hud { left: 10px; bottom: 10px; }
  .left-panel, .right-panel { border-radius: 20px; }
}

.swatch-block { display:flex; flex-direction:column; gap:10px; padding: 12px 14px; border:1px solid var(--hair); border-radius:16px; background: rgba(255,255,255,0.64); }
.swatch-label-row { display:flex; align-items:center; justify-content:space-between; gap:8px; font-size:12px; color:#475467; }
.swatch-row { display:flex; flex-wrap:wrap; gap:10px; }
.swatch-chip { width:24px; height:24px; min-width:24px; padding:0; border-radius:999px; border:1.5px solid rgba(15,23,42,0.08); background: var(--swatch); box-shadow: inset 0 0 0 1px rgba(255,255,255,0.38); }
.swatch-chip.swatch-light { border-color: rgba(15,23,42,0.12); }
.swatch-chip.active { outline: 2px solid rgba(37,99,235,0.24); outline-offset: 3px; }
.action-grid { display:grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap:10px; }
.board-svg .object-diamond, .board-svg .object-connector { fill: none; }
.layer-item span:first-child { min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }


.icon-tool {
  width: 42px;
  min-width: 42px;
  height: 42px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 13px;
}
.icon-tool svg {
  width: 18px;
  height: 18px;
  display: block;
}
.icon-tool svg * {
  vector-effect: non-scaling-stroke;
}
.tool-btn.icon-tool {
  font-size: 0;
  line-height: 0;
}

/* ===== Inevitable polish pass ===== */
:root {
  --bg: #eef2f6;
  --panel: rgba(255,255,255,0.78);
  --panel-strong: rgba(255,255,255,0.92);
  --border: rgba(15,23,42,0.07);
  --hair: rgba(15,23,42,0.055);
  --text: #0b1220;
  --muted: #667085;
  --shadow: 0 26px 60px rgba(15,23,42,0.09), 0 8px 24px rgba(15,23,42,0.05);
  --shadow-soft: 0 18px 40px rgba(15,23,42,0.06), 0 2px 8px rgba(15,23,42,0.03);
  --accent: #0f172a;
  --accent-soft: rgba(15,23,42,0.06);
}

body.theme-inevitable {
  background:
    radial-gradient(1200px 520px at -5% -10%, rgba(255,255,255,0.98) 0%, rgba(255,255,255,0.7) 38%, transparent 72%),
    radial-gradient(980px 460px at 104% -6%, rgba(221,232,246,0.68) 0%, rgba(233,239,246,0.42) 44%, transparent 72%),
    linear-gradient(180deg, #f8fafc 0%, #f1f4f8 44%, #eef2f6 100%);
}

body.theme-inevitable::before,
body.theme-inevitable::after {
  content: "";
  position: fixed;
  inset: auto;
  pointer-events: none;
  z-index: 0;
  filter: blur(40px);
}

body.theme-inevitable::before {
  width: 340px;
  height: 340px;
  left: -80px;
  bottom: 8vh;
  background: radial-gradient(circle, rgba(191,219,254,0.32) 0%, rgba(191,219,254,0.08) 48%, transparent 72%);
}

body.theme-inevitable::after {
  width: 420px;
  height: 420px;
  right: -120px;
  top: 10vh;
  background: radial-gradient(circle, rgba(221,214,254,0.22) 0%, rgba(221,214,254,0.06) 42%, transparent 70%);
}

#app { position: relative; z-index: 1; }

.glass {
  background:
    linear-gradient(180deg, rgba(255,255,255,0.86), rgba(255,255,255,0.72));
  border: 1px solid rgba(255,255,255,0.58);
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255,255,255,0.72);
}

button,
input[type="search"],
input[type="text"],
input[type="number"],
.floating-editor {
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

button {
  border-color: rgba(15,23,42,0.07);
  background: linear-gradient(180deg, rgba(255,255,255,0.96), rgba(245,247,250,0.88));
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.78), 0 1px 2px rgba(15,23,42,0.04);
  font-weight: 500;
}

button:hover {
  transform: translateY(-1px);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.84), 0 12px 26px rgba(15,23,42,0.08);
}

button:active {
  transform: translateY(0);
  box-shadow: inset 0 1px 1px rgba(15,23,42,0.05), 0 2px 6px rgba(15,23,42,0.05);
}

.primary-btn {
  background: linear-gradient(180deg, #111827 0%, #0b1220 100%);
  border-color: rgba(2,6,23,0.18);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.12), 0 16px 30px rgba(15,23,42,0.18);
}

.secondary-btn {
  background: linear-gradient(180deg, rgba(255,255,255,0.92), rgba(247,248,250,0.88));
}

.chrome-icon-btn {
  color: #475467;
}

.chrome-icon-btn svg,
.action-btn svg {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
}

.action-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding-inline: 12px 14px;
}

.action-btn-soft {
  color: #334155;
}

.library-screen {
  padding: 26px;
  gap: 20px;
}

.hero-card {
  position: relative;
  overflow: hidden;
}

.hero-card::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(420px 220px at 12% 0%, rgba(255,255,255,0.88) 0%, rgba(255,255,255,0.34) 48%, transparent 76%),
    radial-gradient(360px 180px at 92% 20%, rgba(219,234,254,0.34) 0%, rgba(219,234,254,0.12) 42%, transparent 72%);
}

.control-ribbon {
  padding-block: 16px;
}

.library-header,
.library-toolbar,
.topbar,
.left-panel,
.right-panel,
.board-card,
.minimap,
.zoom-hud {
  border-color: rgba(255,255,255,0.62);
}

.library-header h1 {
  letter-spacing: -0.065em;
}

.library-header .subtle {
  color: #526071;
  line-height: 1.6;
}

.search-wrap input {
  height: 48px;
  padding-inline: 16px;
  background: linear-gradient(180deg, rgba(255,255,255,0.98), rgba(248,250,252,0.92));
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.82), 0 1px 2px rgba(15,23,42,0.03);
}

.board-card {
  position: relative;
  padding: 15px;
  transition: transform .22s ease, box-shadow .22s ease, border-color .22s ease;
}

.board-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 28px 50px rgba(15,23,42,0.11), 0 8px 20px rgba(15,23,42,0.05);
}

.board-card::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(255,255,255,0.28), transparent 28%);
}

.board-thumb-wrap {
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.9), inset 0 0 0 1px rgba(15,23,42,0.04);
}

.topbar-inevitable {
  padding: 12px 14px;
  gap: 14px;
  box-shadow: 0 18px 36px rgba(15,23,42,0.08), 0 2px 10px rgba(15,23,42,0.04), inset 0 1px 0 rgba(255,255,255,0.74);
}

.topbar-left,
.topbar-right {
  min-width: 0;
}

.topbar-left .icon-btn,
.topbar-right .icon-btn {
  flex: 0 0 auto;
}

#backToLibraryBtn {
  font-size: 19px;
  font-weight: 600;
}

.board-title-wrap {
  gap: 14px;
  min-width: 0;
}

.board-title-input {
  font-size: 22px;
  font-weight: 630;
  color: #0b1220;
  letter-spacing: -0.045em;
}

.board-title-input::placeholder {
  color: #98a2b3;
}

.save-state {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 10px;
  border-radius: 999px;
  background: rgba(255,255,255,0.72);
  border: 1px solid rgba(15,23,42,0.06);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.8);
}

.tool-pills-shell {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow: hidden;
  padding: 4px;
  border-radius: 20px;
  background: linear-gradient(180deg, rgba(255,255,255,0.8), rgba(246,248,251,0.74));
  border: 1px solid rgba(15,23,42,0.05);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.88), 0 8px 18px rgba(15,23,42,0.04);
}

.tool-pills {
  gap: 6px;
  padding: 2px 4px;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
  scroll-snap-type: x proximity;
}
.tool-pills::-webkit-scrollbar { display: none; }
.tool-pills > * { scroll-snap-align: start; }

.icon-tool {
  width: 40px;
  min-width: 40px;
  height: 40px;
  border-radius: 14px;
  color: #344054;
  background: transparent;
  border-color: transparent;
  box-shadow: none;
}

.icon-tool:hover {
  background: rgba(15,23,42,0.06);
  color: #0f172a;
  box-shadow: none;
}

.tool-btn.active.icon-tool {
  background: linear-gradient(180deg, #0f172a 0%, #111827 100%);
  color: #ffffff;
  border-color: rgba(15,23,42,0.14);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.12), 0 10px 18px rgba(15,23,42,0.18);
}

.tool-btn.active.icon-tool:hover,
.tool-btn.active.icon-tool:focus-visible {
  background: linear-gradient(180deg, #0f172a 0%, #111827 100%);
  color: #ffffff;
  border-color: rgba(15,23,42,0.18);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.12), 0 10px 18px rgba(15,23,42,0.18);
}

.workspace {
  gap: 16px;
  padding: 16px;
}

.side-panel {
  padding: 16px;
  gap: 16px;
  background: linear-gradient(180deg, rgba(255,255,255,0.72), rgba(255,255,255,0.62));
}
.side-panel > *,
.side-panel .surface-card,
.side-panel .panel-section,
.side-panel .field-grid,
.side-panel .field-row,
.side-panel .action-grid,
.side-panel .action-stack,
.side-panel .inspector-actions,
.side-panel .text-align-row,
.side-panel .type-preview,
.side-panel .size-presets,
.side-panel .font-gallery {
  min-width: 0;
}

.surface-card {
  padding: 14px;
  border-radius: 18px;
  border: 1px solid rgba(15,23,42,0.045);
  background: linear-gradient(180deg, rgba(255,255,255,0.76), rgba(248,250,252,0.62));
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.74), 0 8px 20px rgba(15,23,42,0.03);
}

.panel-section {
  gap: 12px;
}

.panel-header h2 {
  letter-spacing: 0.08em;
  color: #5b6472;
}

.field-row,
.swatch-label-row,
.shortcut-list {
  color: #526071;
}

input[type="search"],
input[type="text"],
input[type="number"],
.floating-editor {
  background: linear-gradient(180deg, rgba(255,255,255,0.98), rgba(248,250,252,0.92));
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.82), 0 1px 2px rgba(15,23,42,0.03);
}

input[type="search"]:focus,
input[type="text"]:focus,
input[type="number"]:focus,
.floating-editor:focus {
  outline: none;
  border-color: rgba(37,99,235,0.24);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.9), 0 0 0 4px rgba(37,99,235,0.08);
}

input[type="color"] {
  width: 100%;
  min-height: 40px;
  border-radius: 12px;
  border: 1px solid rgba(15,23,42,0.07);
  background: linear-gradient(180deg, rgba(255,255,255,0.96), rgba(248,250,252,0.9));
  padding: 6px;
}

input[type="range"] {
  accent-color: #111827;
}

.toggle-row,
.selection-summary,
.layer-item,
.swatch-block {
  background: linear-gradient(180deg, rgba(255,255,255,0.78), rgba(249,250,251,0.66));
  border-color: rgba(15,23,42,0.045);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.72);
}

.layer-item {
  min-height: 46px;
}

.layer-item.active {
  background: linear-gradient(180deg, rgba(17,24,39,0.08), rgba(17,24,39,0.06));
  outline: 1px solid rgba(17,24,39,0.1);
}

.swatch-chip {
  width: 26px;
  height: 26px;
  min-width: 26px;
  border: 1.5px solid rgba(15,23,42,0.08);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.54), 0 2px 6px rgba(15,23,42,0.05);
}

.canvas-shell::before {
  content: "";
  position: absolute;
  inset: -10px;
  pointer-events: none;
  border-radius: 36px;
  background: radial-gradient(240px 120px at 18% 0%, rgba(255,255,255,0.9) 0%, transparent 72%);
  z-index: 0;
}

.canvas-shell > * {
  position: relative;
  z-index: 1;
}

.canvas-wrap {
  background:
    radial-gradient(1200px 500px at 20% -10%, rgba(255,255,255,0.92) 0%, rgba(255,255,255,0.46) 34%, transparent 72%),
    linear-gradient(180deg, #fdfdfe 0%, #fbfcfe 100%);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.85),
    inset 0 0 0 1px rgba(15,23,42,0.055),
    0 28px 55px rgba(15,23,42,0.08),
    0 8px 20px rgba(15,23,42,0.04);
}

.canvas-wrap::after {
  background: linear-gradient(180deg, rgba(255,255,255,0.16), transparent 24%);
}

.minimap {
  border-radius: 20px;
  background: linear-gradient(180deg, rgba(255,255,255,0.86), rgba(247,249,252,0.76));
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.82), 0 20px 34px rgba(15,23,42,0.12), 0 6px 14px rgba(15,23,42,0.05);
}

.zoom-hud {
  gap: 6px;
  padding: 8px;
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(255,255,255,0.86), rgba(247,249,252,0.76));
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.82), 0 18px 34px rgba(15,23,42,0.1), 0 4px 12px rgba(15,23,42,0.04);
}

.zoom-hud button {
  min-width: 36px;
}

#zoomLabel {
  min-width: 56px;
  text-align: center;
  color: #475467;
}

.floating-editor {
  border-radius: 18px;
}

.shortcut-list {
  gap: 10px;
}

.shortcut-list li {
  padding: 8px 0;
  border-bottom: 1px dashed rgba(15,23,42,0.06);
}

.shortcut-list li:last-child {
  border-bottom: 0;
}

.left-panel::-webkit-scrollbar,
.right-panel::-webkit-scrollbar,
.library-screen::-webkit-scrollbar,
.layers-list::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

.left-panel::-webkit-scrollbar-thumb,
.right-panel::-webkit-scrollbar-thumb,
.library-screen::-webkit-scrollbar-thumb,
.layers-list::-webkit-scrollbar-thumb {
  background: rgba(148,163,184,0.38);
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: content-box;
}

.left-panel::-webkit-scrollbar-track,
.right-panel::-webkit-scrollbar-track,
.library-screen::-webkit-scrollbar-track,
.layers-list::-webkit-scrollbar-track {
  background: transparent;
}

@media (max-width: 980px) {
  .topbar {
    grid-template-columns: minmax(180px, 1fr) minmax(0, 1fr) minmax(180px, auto);
  }

  .tool-pills-shell {
    width: 100%;
  }

  .topbar-inevitable {
    gap: 12px;
  }

  .topbar-right {
    justify-content: flex-start;
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 2px;
  }
}

@media (max-width: 720px) {
  .library-screen {
    padding: 14px;
  }

  .workspace {
    padding: 10px;
    gap: 10px;
  }

  .topbar-inevitable {
    padding: 10px;
  }

  .tool-pills-shell {
    border-radius: 18px;
  }

  .action-btn span {
    display: none;
  }

  .action-btn {
    padding-inline: 10px;
  }

  .surface-card {
    padding: 12px;
    border-radius: 16px;
  }
}

select {
  width: 100%;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.94);
  border-radius: 12px;
  padding: 12px 14px;
  color: var(--text);
}

.context-badge {
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(15,23,42,0.06);
  color: #475467;
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.typography-grid .field-row input[type="range"] {
  margin-top: 2px;
}

.size-presets {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.size-preset {
  padding-inline: 0;
}

.text-align-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.align-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 0;
  border-radius: 12px;
  background: rgba(255,255,255,0.82);
}

.align-chip svg {
  width: 18px;
  height: 18px;
}

.align-chip.active {
  background: #111827;
  color: #fff;
  border-color: rgba(17,24,39,0.18);
}

.type-preview {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px 16px;
  border-radius: 18px;
  border: 1px solid var(--hair);
  background: linear-gradient(180deg, rgba(255,255,255,0.94), rgba(246,248,251,0.9));
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.78);
}

.type-preview-text {
  color: var(--text);
  font-size: 24px;
  line-height: 1.34;
  letter-spacing: 0;
}

.right-panel .panel-section.hidden {
  display: none !important;
}



.utility-dock {
  margin-top: auto;
}

.utility-dock-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.utility-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-height: 44px;
  padding-inline: 12px;
}

.utility-btn svg {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
}

.right-panel {
  padding-right: 14px;
}

.right-panel .surface-card {
  width: 100%;
}

.right-panel select,
.right-panel input,
.right-panel button,
.left-panel button {
  max-width: 100%;
}

#typeFamilySelect {
  min-width: 0;
}

.font-gallery {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.font-chip {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 14px;
  text-align: left;
  background: linear-gradient(180deg, rgba(255,255,255,0.98), rgba(248,250,252,0.9));
  border: 1px solid rgba(15,23,42,0.06);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.84), 0 1px 2px rgba(15,23,42,0.03);
}

.font-chip-name,
.font-chip-meta {
  display: block;
  min-width: 0;
}

.font-chip-name {
  font-family: var(--font-preview);
  font-size: 15px;
  color: var(--text);
  letter-spacing: -0.01em;
}

.font-chip-meta {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}

.font-chip.active {
  background: linear-gradient(180deg, rgba(15,23,42,0.08), rgba(15,23,42,0.06));
  border-color: rgba(15,23,42,0.12);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.7);
}

.typography-grid {
  gap: 10px;
}

.shortcut-list {
  gap: 10px;
}

.shortcut-sheet-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  border-bottom: 1px solid rgba(15,23,42,0.06);
  padding: 10px 0;
}

.shortcut-sheet-list li:last-child {
  border-bottom: none;
}

.shortcut-keys {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 6px;
}

kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 26px;
  padding: 0 8px;
  border-radius: 8px;
  border: 1px solid rgba(15,23,42,0.08);
  background: linear-gradient(180deg, rgba(255,255,255,0.96), rgba(243,244,246,0.92));
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.8);
  color: #334155;
  font-size: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.utility-overlay {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(11,18,32,0.18);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.utility-sheet {
  width: min(560px, calc(100vw - 48px));
  max-height: min(82vh, 820px);
  overflow: auto;
  border-radius: 28px;
  padding: 20px;
  background: linear-gradient(180deg, rgba(255,255,255,0.97), rgba(247,249,252,0.94));
  border: 1px solid rgba(255,255,255,0.68);
  box-shadow: 0 30px 80px rgba(15,23,42,0.22), inset 0 1px 0 rgba(255,255,255,0.8);
}

#settingsSheet.utility-sheet {
  width: min(920px, calc(100vw - 48px));
}

.utility-sheet-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.utility-sheet-header h2 {
  margin: 3px 0 0;
  font-size: 24px;
  letter-spacing: -0.04em;
  color: var(--text);
}

.utility-sheet-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.utility-overlay.hidden,
.utility-sheet.hidden {
  display: none !important;
}

@media (max-width: 1200px) {
  .workspace { grid-template-columns: 250px minmax(0, 1fr) 292px; }
}

@media (max-width: 980px) {
  .utility-overlay {
    align-items: flex-end;
    justify-content: center;
    padding: 14px;
  }

  .utility-sheet,
  #settingsSheet.utility-sheet {
    width: min(100%, 560px);
    max-height: 72vh;
  }
}

/* Focus mode — canvas-first, reduced chrome, optional fullscreen companion */
.focus-chrome {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 90;
  pointer-events: none;
  display: flex;
  justify-content: center;
  padding-top: max(16px, var(--sat) + 10px);
  padding-inline: max(12px, env(safe-area-inset-left, 0px) + 12px) max(12px, env(safe-area-inset-right, 0px) + 12px);
}
.focus-chrome-pill {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 999px;
  background: rgba(255,255,255,0.82);
  border: 1px solid rgba(15,23,42,0.08);
  box-shadow: 0 16px 44px rgba(15,23,42,0.12), 0 4px 16px rgba(15,23,42,0.06);
  pointer-events: auto;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}
.focus-chrome-pill button,
.focus-chrome-pill select,
.focus-chrome-pill input,
.focus-chrome-pill textarea,
.focus-chrome-pill label {
  touch-action: manipulation;
  user-select: auto;
  -webkit-user-select: auto;
}
.focus-cluster { display: inline-flex; align-items: center; gap: 8px; }
.focus-tools-scroll {
  display: inline-flex;
  align-items: center;
  min-width: 0;
  max-width: min(54vw, 880px);
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  -ms-overflow-style: none;
  white-space: nowrap;
}
.focus-tools-scroll::-webkit-scrollbar { display: none; }
.focus-tools {
  flex-wrap: nowrap;
  min-width: max-content;
  padding-inline: 1px;
}
.focus-divider { width: 1px; height: 28px; background: rgba(15,23,42,0.08); flex: 0 0 auto; }
.focus-textbar {
  position: fixed;
  z-index: 92;
  top: 120px;
  left: 50%;
  transform: translateX(-50%);
}
.focus-textbar-pill {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 22px;
  background: rgba(255,255,255,0.92);
  border: 1px solid rgba(15,23,42,0.08);
  box-shadow: 0 16px 42px rgba(15,23,42,0.16), 0 6px 16px rgba(15,23,42,0.07);
  backdrop-filter: blur(22px);
  pointer-events: auto;
}
.focus-textbar-cluster { display: inline-flex; align-items: center; gap: 8px; }
.focus-textbar-leading { gap: 10px; }
.focus-textbar-trailing { gap: 10px; }
.focus-textbar-typemark {
  width: 34px;
  height: 34px;
  border-radius: 12px;
  background: linear-gradient(180deg, #0f172a 0%, #111827 100%);
  color: #fff;
  font-weight: 700;
  font-size: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: default;
}
.focus-text-select,
.focus-text-size-input {
  appearance: none;
  border: 1px solid rgba(15,23,42,0.08);
  background: rgba(248,250,252,0.94);
  color: #0f172a;
  border-radius: 12px;
  height: 38px;
  padding: 0 12px;
  font: inherit;
  font-size: 14px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.72);
}
.focus-text-select { min-width: 158px; }
.focus-text-weight { min-width: 110px; }
.focus-text-size-input {
  width: 72px;
  font-weight: 600;
  text-align: center;
}
.focus-text-select:focus,
.focus-text-size-input:focus {
  outline: none;
  border-color: rgba(37,99,235,0.42);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.12);
}
.focus-text-align-row-mini { gap: 6px; }
.focus-text-align-btn {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #334155;
  background: transparent;
}
.focus-text-align-btn svg { width: 18px; height: 18px; }
.focus-text-align-btn:hover { background: rgba(15,23,42,0.06); color: #111827; }
.focus-text-align-btn.active {
  background: linear-gradient(180deg, #0f172a 0%, #111827 100%);
  color: #fff;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.14), 0 10px 18px rgba(15,23,42,0.18);
}
.focus-text-color-wrap {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid rgba(15,23,42,0.08);
  background: rgba(248,250,252,0.94);
}
.focus-text-color-wrap input {
  width: 100%;
  height: 100%;
  border: 0;
  padding: 0;
  background: none;
  cursor: pointer;
}
.focus-text-menu-toggle { width: 38px; height: 38px; border-radius: 12px; }
.focus-text-menu {
  position: absolute;
  top: calc(100% + 12px);
  right: 0;
  min-width: 196px;
  padding: 10px;
  border-radius: 18px;
  background: rgba(255,255,255,0.96);
  border: 1px solid rgba(15,23,42,0.08);
  box-shadow: 0 22px 46px rgba(15,23,42,0.18), 0 8px 18px rgba(15,23,42,0.08);
  backdrop-filter: blur(18px);
}
.focus-text-menu-item {
  width: 100%;
  border-radius: 12px;
  min-height: 40px;
  padding: 0 12px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  font-size: 14px;
  font-weight: 560;
  color: #0f172a;
}
.focus-text-menu-item:hover { background: rgba(15,23,42,0.06); }
.focus-text-menu-item.danger { color: #b42318; }
.focus-text-menu-divider {
  height: 1px;
  background: rgba(15,23,42,0.08);
  margin: 8px 4px;
}

.object-context-menu {
  position: fixed;
  top: 0;
  left: 0;
  min-width: 212px;
  max-width: min(280px, calc(100vw - 24px));
  max-height: min(76vh, calc(100dvh - 24px));
  padding: 10px;
  border-radius: 18px;
  background: rgba(255,255,255,0.98);
  border: 1px solid rgba(15,23,42,0.08);
  box-shadow: 0 24px 52px rgba(15,23,42,0.22), 0 10px 20px rgba(15,23,42,0.12);
  backdrop-filter: blur(18px);
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: rgba(15,23,42,0.22) transparent;
  z-index: 90;
}
.object-context-menu::-webkit-scrollbar {
  width: 10px;
}
.object-context-menu::-webkit-scrollbar-track {
  background: transparent;
}
.object-context-menu::-webkit-scrollbar-thumb {
  background: rgba(15,23,42,0.18);
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: padding-box;
}
.object-context-menu::-webkit-scrollbar-thumb:hover {
  background: rgba(15,23,42,0.28);
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: padding-box;
}

.object-context-menu-item {
  width: 100%;
  min-height: 42px;
  padding: 0 12px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  font-size: 14px;
  font-weight: 560;
  color: #0f172a;
}

.object-context-menu-item:hover {
  background: rgba(15,23,42,0.06);
}

.object-context-menu-item:disabled {
  opacity: 0.38;
  cursor: default;
  pointer-events: none;
}

.object-context-menu-item.danger {
  color: #b42318;
}

.object-context-menu-divider {
  height: 1px;
  margin: 8px 4px;
  background: rgba(15,23,42,0.08);
}
.focus-control-btn,
.focus-tool-btn {
  position: relative;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border-color: transparent;
  color: #344054;
  box-shadow: none;
  overflow: visible;
  flex: 0 0 auto;
}
.focus-control-btn::before,
.focus-tool-btn::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 12px;
  background: transparent;
  box-shadow: none;
  transition: background 180ms ease, box-shadow 180ms ease, border-color 180ms ease;
  z-index: -1;
}
.focus-control-btn svg,
.focus-tool-btn svg { width: 20px; height: 20px; }
.focus-control-btn:hover::before,
.focus-tool-btn:hover::before {
  background: rgba(15,23,42,0.06);
}
.focus-control-btn:hover,
.focus-tool-btn:hover {
  color: #111827;
  box-shadow: none;
}
.focus-control-btn.is-active::before,
.focus-tool-btn.active::before {
  inset: -1px;
  border-radius: 13px;
  background: linear-gradient(180deg, #0f172a 0%, #111827 100%);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.14), 0 10px 18px rgba(15,23,42,0.18);
}
.focus-control-btn.is-active,
.focus-tool-btn.active {
  color: #ffffff;
  border-color: rgba(15,23,42,0.16);
  box-shadow: none;
}
#focusModeBtn.is-active {
  background: linear-gradient(180deg, #0f172a 0%, #111827 100%);
  color: #ffffff;
  border-color: rgba(15,23,42,0.18);
}
body.focus-mode {
  background: #eef2f6;
}
body.focus-mode .library-screen { display: none !important; }
body.focus-mode .editor-screen {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: radial-gradient(circle at top, #fbfbfd 0%, #f4f6f9 58%, #eef2f6 100%);
}
body.focus-mode .topbar {
  display: none;
}
body.focus-mode .workspace {
  grid-template-columns: 1fr;
  padding: 0;
  gap: 0;
}
body.focus-mode .left-panel,
body.focus-mode .right-panel {
  display: none;
}
body.focus-mode .canvas-shell,
body.focus-mode .canvas-wrap {
  width: 100%;
  height: 100%;
  min-height: 100vh;
}
body.focus-mode .canvas-wrap {
  border-radius: 0;
  box-shadow: none;
}
body.focus-mode .minimap {
  right: 22px;
  bottom: 22px;
}
body.focus-mode .zoom-hud {
  left: 22px;
  bottom: 22px;
}
body.focus-mode .focus-textbar,
body.present-mode .focus-textbar {
  display: block;
}
body.focus-mode.focus-panels-visible .left-panel,
body.focus-mode.focus-panels-visible .right-panel {
  display: flex;
  position: fixed;
  top: max(74px, env(safe-area-inset-top, 0px) + 68px);
  bottom: 18px;
  z-index: 85;
  background: linear-gradient(180deg, rgba(255,255,255,0.9), rgba(248,250,252,0.84));
  box-shadow: 0 22px 54px rgba(15,23,42,0.16), 0 6px 18px rgba(15,23,42,0.06);
}
body.focus-mode.focus-panels-visible .left-panel {
  left: 18px;
  width: min(var(--workspace-left-track, var(--workspace-left-width)), calc(100vw - 140px));
}
body.focus-mode.focus-panels-visible .right-panel {
  right: 18px;
  width: min(var(--workspace-right-track, var(--workspace-right-width)), calc(100vw - 140px));
}
body.focus-mode.focus-panels-visible.left-panel-collapsed .left-panel,
body.focus-mode.focus-panels-visible.right-panel-collapsed .right-panel {
  opacity: 0;
  pointer-events: none;
  overflow: hidden;
  padding: 0;
  border-width: 0;
  box-shadow: none;
  width: 0 !important;
  min-width: 0 !important;
}
body.focus-mode.focus-panels-visible .canvas-wrap::after {
  background: rgba(255,255,255,0.18);
}
@media (max-width: 820px) {
  .focus-chrome-pill {
    gap: 8px;
    padding: 8px 10px;
    max-width: calc(100vw - 20px);
    overflow-x: auto;
  }
  .focus-tools-scroll {
    max-width: min(62vw, calc(100vw - 180px));
  }
  .focus-textbar {
    max-width: calc(100vw - 16px);
  }
  .focus-textbar-pill {
    width: min(calc(100vw - 16px), 760px);
    gap: 8px;
    padding: 8px 10px;
    overflow-x: auto;
  }
  .focus-text-select { min-width: 132px; }
  .focus-text-weight { min-width: 102px; }
  .focus-text-size-input { width: 64px; }
  .focus-divider { height: 24px; }
  body.focus-mode.focus-panels-visible .left-panel,
  body.focus-mode.focus-panels-visible .right-panel {
    top: max(68px, env(safe-area-inset-top, 0px) + 62px);
    bottom: 12px;
  }
  body.focus-mode.focus-panels-visible .left-panel {
    left: 12px;
    width: min(var(--workspace-left-track, var(--workspace-left-width)), calc(100vw - 120px));
  }
  body.focus-mode.focus-panels-visible .right-panel {
    right: 12px;
    width: min(var(--workspace-right-track, var(--workspace-right-width)), calc(100vw - 120px));
  }
}

/* ===== Mobile-first productized workspace pass ===== */
.mobile-bottom-bar,
.mobile-tools-sheet,
.mobile-more-sheet,
.mobile-ui-backdrop {
  display: none;
}

@media (max-width: 820px) {
  .topbar {
    margin: 0;
    border-radius: 0;
    padding: calc(env(safe-area-inset-top, 0px) + 10px) 12px 10px;
    grid-template-columns: minmax(0,1fr) auto;
    gap: 10px;
    position: sticky;
    top: 0;
    z-index: 70;
    background: rgba(255,255,255,0.86);
    backdrop-filter: blur(18px);
  }

  .topbar-left {
    min-width: 0;
    gap: 10px;
  }

  .board-title-wrap {
    min-width: 0;
    gap: 8px;
  }

  .board-title-input {
    width: 100%;
    font-size: 17px;
    font-weight: 600;
    padding: 6px 0;
  }

  .save-state {
    display: none;
  }

  .topbar-right {
    gap: 6px;
  }

  .topbar-right .action-btn span,
  .topbar-right .secondary-btn.compact span,
  .topbar-right .primary-btn.compact span {
    display: none;
  }

  .topbar-right .action-btn,
  .topbar-right .secondary-btn.compact,
  .topbar-right .primary-btn.compact {
    width: 42px;
    min-width: 42px;
    height: 42px;
    padding: 0;
    border-radius: 14px;
    justify-content: center;
  }

  .topbar-center {
    display: none !important;
  }

  .mobile-tools-sheet {
    display: block;
    position: fixed;
    left: 10px;
    right: 10px;
    bottom: calc(env(safe-area-inset-bottom, 0px) + 86px);
    z-index: 82;
    padding: 16px;
    border-radius: 26px;
    background: rgba(255,255,255,0.97);
    backdrop-filter: blur(24px);
    border: 1px solid rgba(15,23,42,0.08);
    box-shadow: 0 34px 70px rgba(15,23,42,0.2), 0 10px 24px rgba(15,23,42,0.08);
  }

  .mobile-tools-scroller {
    overflow-x: auto;
    overflow-y: hidden;
    padding-bottom: 2px;
    -webkit-overflow-scrolling: touch;
  }

  .mobile-tool-pills {
    gap: 10px;
    padding: 2px;
    flex-wrap: nowrap;
  }

  .tool-pills-shell {
    width: 100%;
    border-radius: 24px;
    padding: 8px;
    background: rgba(255,255,255,0.94);
    backdrop-filter: blur(22px);
    border: 1px solid rgba(15,23,42,0.08);
    box-shadow: 0 22px 48px rgba(15,23,42,0.18), 0 8px 20px rgba(15,23,42,0.08);
  }

  .tool-pills {
    gap: 10px;
    padding: 2px;
  }

  .tool-btn,
  .icon-tool {
    width: 44px;
    min-width: 44px;
    height: 44px;
    border-radius: 14px;
  }

  .workspace {
    grid-template-columns: 1fr;
    padding: 10px 10px calc(env(safe-area-inset-bottom, 0px) + 92px);
    gap: 0;
  }

  .canvas-shell {
    min-height: calc(100dvh - 148px);
  }

  .canvas-wrap {
    min-height: calc(100dvh - 156px);
    border-radius: 24px;
  }

  .left-panel,
  .right-panel {
    position: fixed;
    left: 10px;
    right: 10px;
    bottom: calc(env(safe-area-inset-bottom, 0px) + 86px);
    max-height: min(68vh, 620px);
    border-radius: 26px;
    z-index: 81;
    transform: translateY(calc(100% + 24px));
    opacity: 0;
    pointer-events: none;
    transition: transform 200ms ease, opacity 200ms ease;
    box-shadow: 0 34px 70px rgba(15,23,42,0.2), 0 10px 24px rgba(15,23,42,0.08);
    background: rgba(255,255,255,0.96);
    backdrop-filter: blur(22px);
    overscroll-behavior: contain;
  }

  body.mobile-left-open .left-panel,
  body.mobile-right-open .right-panel {
    transform: translateY(0);
    opacity: 1;
    pointer-events: auto;
  }

  .right-panel {
    overflow-x: hidden;
  }

  .field-grid {
    grid-template-columns: 1fr 1fr;
  }

  .font-gallery {
    grid-template-columns: 1fr;
  }

  .utility-dock {
    display: none;
  }

  .minimap {
    display: none !important;
  }

  .zoom-hud {
    left: 10px;
    bottom: calc(env(safe-area-inset-bottom, 0px) + 18px + 72px);
    padding: 8px 10px;
    border-radius: 16px;
    gap: 6px;
    z-index: 74;
  }

  .zoom-hud .compact {
    min-width: 34px;
    height: 34px;
  }

  .mobile-bottom-bar {
    display: grid;
    grid-template-columns: repeat(5, minmax(0,1fr));
    gap: 6px;
    position: fixed;
    left: 10px;
    right: 10px;
    bottom: calc(env(safe-area-inset-bottom, 0px) + 10px);
    z-index: 78;
    padding: 8px;
    border-radius: 24px;
    background: rgba(255,255,255,0.96);
    backdrop-filter: blur(22px);
    border: 1px solid rgba(15,23,42,0.08);
    box-shadow: 0 26px 60px rgba(15,23,42,0.18), 0 10px 24px rgba(15,23,42,0.08);
  }

  .mobile-nav-btn {
    min-height: 58px;
    border-radius: 18px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 5px;
    color: #425166;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: -0.01em;
    background: transparent;
  }

  .mobile-nav-btn svg {
    width: 20px;
    height: 20px;
  }

  .mobile-nav-btn.is-active,
  .mobile-nav-btn[aria-pressed="true"] {
    background: #111827;
    color: #fff;
  }

  .mobile-ui-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(12,18,28,0.22);
    backdrop-filter: blur(6px);
    z-index: 75;
  }

  .mobile-tools-sheet .mobile-sheet-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
  }

  .mobile-more-sheet {
    display: block;
    position: fixed;
    left: 10px;
    right: 10px;
    bottom: calc(env(safe-area-inset-bottom, 0px) + 86px);
    z-index: 82;
    padding: 16px;
    border-radius: 26px;
    background: rgba(255,255,255,0.97);
    backdrop-filter: blur(24px);
    border: 1px solid rgba(15,23,42,0.08);
    box-shadow: 0 34px 70px rgba(15,23,42,0.2), 0 10px 24px rgba(15,23,42,0.08);
  }

  .mobile-sheet-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
  }

  .mobile-sheet-header h2 {
    margin: 2px 0 0;
    font-size: 20px;
    letter-spacing: -0.03em;
  }

  .mobile-action-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0,1fr));
    gap: 10px;
  }

  .mobile-sheet-action {
    min-height: 46px;
    border-radius: 16px;
    justify-content: center;
  }

  .focus-chrome {
    bottom: calc(env(safe-area-inset-bottom, 0px) + 94px);
  }

  body.present-mode .mobile-bottom-bar,
  body.present-mode .topbar-center,
  body.present-mode .left-panel,
  body.present-mode .right-panel,
  body.present-mode .mobile-more-sheet,
  body.present-mode .mobile-ui-backdrop,
  body.present-mode .zoom-hud {
    display: none !important;
  }

  body.focus-mode .mobile-bottom-bar {
    opacity: 0;
    pointer-events: none;
    transform: translateY(16px);
  }
}

@media (max-width: 560px) {
  .topbar-right {
    display: grid;
    grid-auto-flow: column;
    gap: 4px;
  }

  .topbar-right > *:nth-child(n+4) {
    display: none;
  }

  .board-title-input {
    font-size: 16px;
  }

  .field-grid {
    grid-template-columns: 1fr;
  }

  .mobile-action-grid {
    grid-template-columns: 1fr 1fr;
  }

  .floating-editor {
    min-width: 140px;
  }
}

@media (max-width: 820px) {
  body.focus-mode .mobile-tools-sheet,
  body.focus-mode .mobile-more-sheet { display: none !important; }
}


/* ===== Tablet/mobile library header hardening fix ===== */
.hero-card::before {
  z-index: 0;
}
.hero-card > * {
  position: relative;
  z-index: 1;
}
.library-header > div:first-child,
.library-toolbar > div:first-child {
  min-width: 0;
}
.library-header h1 {
  text-wrap: balance;
}

@media (max-width: 1180px) {
  .library-screen {
    padding: 18px;
    gap: 16px;
  }
  .library-header {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    align-items: start;
    justify-content: stretch;
    gap: 16px;
    padding: 18px 20px;
  }
  .library-header > div:first-child {
    width: 100%;
    padding-top: 2px;
  }
  .library-header h1 {
    font-size: clamp(30px, 5.2vw, 46px);
    line-height: 0.96;
    margin: 0 0 10px;
    max-width: 10.5ch;
  }
  .library-header .subtle {
    max-width: 100%;
    font-size: 15px;
    line-height: 1.45;
  }
  .library-actions {
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-start;
    gap: 10px;
  }
  .library-actions > button {
    flex: 0 0 auto;
  }
  .library-toolbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 14px;
    padding: 16px 18px;
  }
  .search-wrap {
    min-width: 0;
  }
  .toolbar-meta {
    flex: 0 0 auto;
    justify-content: flex-end;
    flex-wrap: wrap;
    row-gap: 8px;
  }
}

@media (max-width: 900px) {
  .library-header {
    gap: 14px;
    padding: 16px 18px;
  }
  .library-header h1 {
    font-size: clamp(28px, 6vw, 40px);
    max-width: 9.5ch;
  }
  .library-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
  }
  .library-actions > button {
    width: 100%;
  }
  .library-toolbar {
    grid-template-columns: 1fr;
    align-items: stretch;
    gap: 12px;
  }
  .toolbar-meta {
    width: 100%;
    justify-content: space-between;
  }
}

@media (max-width: 720px) {
  .library-screen {
    padding: 14px;
    gap: 14px;
  }
  .library-header {
    padding: 16px;
    border-radius: 22px;
  }
  .library-header h1 {
    font-size: clamp(26px, 8vw, 34px);
    line-height: 0.98;
    max-width: none;
  }
  .library-header .subtle {
    font-size: 14px;
  }
  .library-actions {
    grid-template-columns: 1fr;
  }
  .library-toolbar {
    padding: 14px 16px;
    border-radius: 22px;
  }
  .search-wrap input {
    height: 46px;
  }
}

/* ===== Library create-CTA hardening ===== */
.library-toolbar {
  position: relative;
}

.toolbar-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.toolbar-meta .primary-btn.compact,
.toolbar-meta .secondary-btn.compact {
  white-space: nowrap;
  flex: 0 0 auto;
}

.library-create-fab {
  position: fixed;
  right: max(20px, env(safe-area-inset-right));
  bottom: max(20px, calc(env(safe-area-inset-bottom) + 20px));
  z-index: 35;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  border: 1px solid rgba(255,255,255,0.72);
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(17,24,39,0.98), rgba(15,23,42,0.96));
  color: #fff;
  box-shadow: 0 20px 40px rgba(15,23,42,0.22), 0 8px 16px rgba(15,23,42,0.14);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.library-create-fab svg {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
}

.library-create-fab span {
  font-weight: 700;
  letter-spacing: -0.02em;
}

#editorScreen + .library-create-fab,
.editor-screen:not(.hidden) ~ .library-create-fab {
  display: none;
}

@media (min-width: 1181px) {
  .library-create-fab {
    display: none;
  }
}

@media (max-width: 1180px) {
  .library-actions {
    display: none !important;
  }

  .library-header {
    min-height: auto;
    overflow: visible;
  }

  .library-header h1,
  .library-header .subtle {
    display: none;
  }

  .library-toolbar {
    grid-template-columns: minmax(0, 1fr) auto;
  }
}

@media (max-width: 900px) {
  .toolbar-meta {
    justify-content: flex-start;
  }

  .toolbar-meta .primary-btn.compact,
  .toolbar-meta .secondary-btn.compact {
    min-height: 42px;
  }
}

@media (max-width: 720px) {
  .toolbar-meta {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }

  .toolbar-meta #refreshLibraryBtn,
  .toolbar-meta #libraryStats {
    grid-column: span 1;
  }

  .toolbar-meta #quickCreateBoardBtn,
  .toolbar-meta #importBoardBtnToolbar {
    grid-column: span 1;
  }

  .toolbar-meta #libraryStats {
    align-self: center;
    justify-self: end;
  }

  .library-create-fab {
    padding: 14px 16px;
  }

  .library-create-fab span {
    display: none;
  }
}


/* ===== Parity fix: library hero/tablet regression ===== */
@media (max-width: 1180px) and (min-width: 821px) {
  .library-header {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 18px;
    padding: 18px 20px;
    border-radius: 24px;
    overflow: visible;
  }

  .library-header > :first-child {
    min-width: 0;
  }

  .library-header .eyebrow,
  .library-header h1,
  .library-header .subtle {
    display: block !important;
  }

  .library-header h1 {
    font-size: clamp(28px, 4.2vw, 40px);
    line-height: 0.96;
    max-width: 12ch;
    margin-bottom: 6px;
  }

  .library-header .subtle {
    font-size: 14px;
    line-height: 1.4;
    max-width: 46ch;
  }

  .library-actions {
    display: flex !important;
    flex-wrap: nowrap;
    gap: 10px;
    justify-content: flex-end;
    align-items: center;
    overflow-x: auto;
    max-width: 100%;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }

  .library-actions::-webkit-scrollbar {
    display: none;
  }

  .library-actions > button {
    flex: 0 0 auto;
    min-height: 44px;
    white-space: nowrap;
  }

  .library-toolbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 14px;
    padding: 16px 18px;
    border-radius: 24px;
  }

  .toolbar-meta {
    flex-wrap: nowrap;
    justify-content: flex-end;
    overflow-x: auto;
    max-width: 100%;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }

  .toolbar-meta::-webkit-scrollbar {
    display: none;
  }

  .toolbar-meta > * {
    flex: 0 0 auto;
    white-space: nowrap;
  }

  .library-create-fab {
    display: none !important;
  }
}

@media (max-width: 820px) {
  .library-header .eyebrow,
  .library-header h1,
  .library-header .subtle {
    display: block !important;
  }
}

/* ===== Final cross-device polish pass ===== */

@media (hover: hover) and (pointer: fine) {
  .board-card,
  .surface-card,
  .library-header,
  .library-toolbar,
  .canvas-wrap,
  .tool-pills-shell,
  .topbar {
    transition: box-shadow 180ms ease, border-color 180ms ease, transform 180ms ease, background 180ms ease;
  }

  .board-card:hover,
  .surface-card:hover {
    box-shadow: 0 20px 44px rgba(15,23,42,0.10), 0 8px 18px rgba(15,23,42,0.05);
    border-color: rgba(15,23,42,0.09);
  }
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid rgba(37,99,235,0.18);
  outline-offset: 2px;
}

.tool-pills,
.topbar-right,
.library-actions,
.toolbar-meta,
.mobile-tools-scroller {
  scrollbar-width: none;
}

.tool-pills::-webkit-scrollbar,
.topbar-right::-webkit-scrollbar,
.library-actions::-webkit-scrollbar,
.toolbar-meta::-webkit-scrollbar,
.mobile-tools-scroller::-webkit-scrollbar {
  display: none;
}

/* Desktop polish */
@media (min-width: 1281px) {
  .library-screen {
    padding: 28px;
    gap: 20px;
  }

  .library-header,
  .library-toolbar {
    padding: 24px 26px;
    border-radius: 30px;
  }

  .library-header h1 {
    font-size: clamp(36px, 4.1vw, 58px);
    line-height: 0.94;
    max-width: 12ch;
  }

  .library-header .subtle {
    font-size: 16px;
    line-height: 1.5;
    max-width: 62ch;
  }

  .board-grid {
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 20px;
  }

  .board-card {
    padding: 16px;
    border-radius: 26px;
  }

  .topbar {
    margin: 16px 16px 0;
    padding: 12px 16px;
    gap: 14px;
    border-radius: 24px;
  }

  .tool-pills-shell {
    padding: 6px;
    border-radius: 18px;
    background: rgba(255,255,255,0.72);
  }

  .tool-pills {
    gap: 10px;
    padding: 2px;
  }

  .workspace {
    grid-template-columns: 288px minmax(0, 1fr) 330px;
    gap: 16px;
    padding: 16px;
  }

  .left-panel,
  .right-panel {
    padding: 20px;
    border-radius: 26px;
  }

  .canvas-wrap {
    border-radius: 30px;
  }

  .zoom-hud {
    left: 20px;
    bottom: 20px;
    padding: 10px 12px;
    border-radius: 18px;
  }

  .minimap {
    right: 20px;
    bottom: 20px;
  }
}

/* iPad / tablet polish */
@media (min-width: 821px) and (max-width: 1280px) {
  .library-screen {
    padding: 18px;
    gap: 16px;
  }

  .library-header,
  .library-toolbar {
    padding: 18px 20px;
    border-radius: 26px;
  }

  .library-header h1 {
    font-size: clamp(30px, 4vw, 42px);
    line-height: 0.95;
    letter-spacing: -0.045em;
  }

  .library-header .subtle {
    font-size: 14px;
    line-height: 1.45;
  }

  .board-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
  }

  @media (min-width: 1081px) and (max-width: 1280px) {
    .board-grid {
      grid-template-columns: repeat(3, minmax(0, 1fr));
    }
  }

  .board-card {
    padding: 14px;
    border-radius: 24px;
  }

  .topbar {
    margin: 12px 12px 0;
    padding: 10px 12px;
    gap: 10px;
    grid-template-columns: minmax(220px, 1fr) minmax(0, 1fr) auto;
  }

  .board-title-input {
    width: min(300px, 34vw);
    font-size: 18px;
  }

  .tool-pills-shell {
    width: 100%;
    padding: 5px;
    border-radius: 18px;
    background: linear-gradient(180deg, rgba(255,255,255,0.74), rgba(255,255,255,0.62));
  }

  .tool-pills {
    gap: 8px;
    padding: 2px;
  }

  .topbar-right {
    gap: 8px;
    padding-bottom: 2px;
  }

  .topbar-right > * {
    flex: 0 0 auto;
  }

  .workspace {
    grid-template-columns: 246px minmax(0, 1fr) 286px;
    gap: 12px;
    padding: 12px;
  }

  .left-panel,
  .right-panel {
    padding: 16px;
    border-radius: 24px;
  }

  .canvas-wrap {
    border-radius: 28px;
  }

  .zoom-hud {
    bottom: 16px;
    left: 16px;
  }

  .minimap {
    width: 200px;
    height: 128px;
    right: 16px;
    bottom: 16px;
  }
}

/* Mobile polish */
@media (max-width: 820px) {
  html, body {
    background: linear-gradient(180deg, #f8fafc 0%, #eef2f6 100%);
  }

  .library-screen {
    padding: 12px 12px calc(env(safe-area-inset-bottom, 0px) + 92px);
    gap: 12px;
  }

  .library-header,
  .library-toolbar {
    padding: 16px;
    border-radius: 24px;
  }

  .library-header {
    gap: 14px;
  }

  .library-header h1 {
    font-size: clamp(26px, 9vw, 34px);
    line-height: 0.96;
    max-width: 11ch;
    margin-bottom: 6px;
  }

  .library-header .subtle {
    font-size: 14px;
    line-height: 1.45;
    max-width: none;
  }

  .library-actions,
  .toolbar-meta {
    width: 100%;
  }

  .library-actions {
    display: grid !important;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }

  .library-actions > *,
  .toolbar-meta > *,
  .board-card-actions > * {
    min-height: 46px;
  }

  .search-wrap input {
    min-height: 52px;
    border-radius: 16px;
    font-size: 18px;
    padding-inline: 16px;
  }

  .board-grid {
    grid-template-columns: 1fr;
    gap: 14px;
    padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 112px);
  }

  .board-card {
    padding: 12px;
    border-radius: 22px;
    gap: 10px;
  }

  .board-thumb-wrap {
    border-radius: 16px;
  }

  .board-title {
    font-size: 17px;
    line-height: 1.08;
  }

  .board-meta {
    font-size: 12.5px;
    line-height: 1.45;
  }

  .board-card-actions {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
  }

  .board-card-actions button {
    width: 100%;
    padding-inline: 8px;
    justify-content: center;
  }

  .topbar {
    box-shadow: 0 10px 26px rgba(15,23,42,0.08);
  }

  .topbar-right {
    gap: 8px;
    padding-bottom: 2px;
  }

  .topbar-right .action-btn,
  .topbar-right .secondary-btn.compact,
  .topbar-right .primary-btn.compact,
  .topbar-right .icon-btn {
    width: 44px;
    min-width: 44px;
    height: 44px;
    border-radius: 15px;
  }

  .canvas-wrap {
    border-radius: 24px;
  }

  .left-panel,
  .right-panel,
  .mobile-tools-sheet,
  .mobile-more-sheet {
    border-radius: 28px;
  }

  .mobile-bottom-bar {
    left: 10px;
    right: 10px;
    bottom: calc(env(safe-area-inset-bottom, 0px) + 10px);
    padding: 8px;
    border-radius: 26px;
  }

  .mobile-nav-btn {
    min-height: 60px;
    border-radius: 18px;
    font-size: 11px;
  }

  .mobile-nav-btn svg {
    width: 20px;
    height: 20px;
  }

  .zoom-hud {
    left: 10px;
    bottom: calc(env(safe-area-inset-bottom, 0px) + 88px);
  }

  .floating-editor {
    border-radius: 16px;
    padding: 14px;
  }
}

/* Reduce motion polish */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}

/* ===== v9 mobile focus safe-area integrity fix ===== */
@media (max-width: 820px) {
  body.focus-mode .editor-screen,
  body.present-mode .editor-screen {
    min-height: 100dvh;
    height: 100dvh;
    overflow: clip;
  }

  body.focus-mode .canvas-shell,
  body.focus-mode .canvas-wrap,
  body.present-mode .canvas-shell,
  body.present-mode .canvas-wrap {
    min-height: 100dvh;
    height: 100dvh;
    border-radius: 0;
  }

  body.focus-mode .focus-chrome,
  body.present-mode .focus-chrome {
    top: 0;
    left: 0;
    right: 0;
    transform: none;
    width: auto;
    justify-content: center;
    z-index: 86;
    pointer-events: none;
    padding-top: calc(env(safe-area-inset-top, 0px) + 12px);
    padding-inline: 12px;
  }

  body.focus-mode .focus-chrome-pill,
  body.present-mode .focus-chrome-pill {
    max-width: min(calc(100vw - 24px), 720px);
    pointer-events: auto;
  }

  body.focus-mode .zoom-hud,
  body.present-mode .zoom-hud {
    left: 50%;
    right: auto;
    transform: translateX(-50%);
    bottom: calc(env(safe-area-inset-bottom, 0px) + 14px);
    max-width: calc(100vw - 24px);
    padding: 8px 10px;
    border-radius: 18px;
    z-index: 84;
  }

  body.focus-mode .zoom-hud #zoomLabel,
  body.present-mode .zoom-hud #zoomLabel {
    min-width: 54px;
    text-align: center;
  }

  body.focus-mode .mobile-bottom-bar,
  body.focus-mode .mobile-tools-sheet,
  body.focus-mode .mobile-more-sheet,
  body.focus-mode .mobile-ui-backdrop,
  body.present-mode .mobile-bottom-bar,
  body.present-mode .mobile-tools-sheet,
  body.present-mode .mobile-more-sheet,
  body.present-mode .mobile-ui-backdrop {
    display: none !important;
    box-shadow: none !important;
  }

  body.focus-mode .utility-overlay:not(.hidden),
  body.present-mode .utility-overlay:not(.hidden) {
    display: flex !important;
    z-index: 110;
    align-items: flex-end;
    justify-content: center;
    padding: 14px;
  }

  body.focus-mode .utility-sheet:not(.hidden),
  body.present-mode .utility-sheet:not(.hidden) {
    display: block !important;
    width: min(100%, 560px);
    max-height: 72vh;
    z-index: 111;
    box-shadow: 0 30px 80px rgba(15,23,42,0.22), inset 0 1px 0 rgba(255,255,255,0.8) !important;
  }

  body.focus-mode .left-panel,
  body.focus-mode .right-panel,
  body.present-mode .left-panel,
  body.present-mode .right-panel {
    display: none !important;
    box-shadow: none !important;
  }

  body.focus-mode.focus-panels-visible .left-panel,
  body.focus-mode.focus-panels-visible .right-panel {
    display: flex !important;
    transform: translateY(0) !important;
    opacity: 1 !important;
    pointer-events: auto !important;
  }
}


/* ===== Surgical create-entry cleanup ===== */
/* Keep only one create-board entry on desktop/iPad: the hero/header button. */
#quickCreateBoardBtn {
  display: none !important;
}

/* On mobile, keep only the bottom plus FAB as the create entry. */
@media (max-width: 820px) {
  #createBoardBtn {
    display: none !important;
  }

  .library-create-fab {
    padding-inline: 0;
    width: 56px;
    min-width: 56px;
    height: 56px;
    justify-content: center;
    gap: 0;
    border-radius: 999px;
  }

  .library-create-fab span {
    display: none !important;
  }
}


/* Surgical brand + create-entry cleanup */
.library-header {
  padding: 18px 20px;
  gap: 18px;
  border-radius: 24px;
  align-items: center;
}
.library-header > div:first-child {
  min-width: 0;
}
.library-header .eyebrow {
  display: none !important;
}
.library-header h1 {
  margin: 0;
  font-size: clamp(24px, 3.2vw, 34px);
  line-height: 1.02;
  letter-spacing: -0.045em;
  text-transform: lowercase;
}
.library-header .subtle {
  margin-top: 6px;
  font-size: 13px;
  line-height: 1.35;
  max-width: none;
}
.library-actions {
  gap: 10px;
  align-items: center;
}
#createBoardBtn.create-plus-btn,
#libraryCreateFab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  padding: 0;
  border-radius: 999px;
}
#createBoardBtn.create-plus-btn svg,
#libraryCreateFab svg {
  width: 18px;
  height: 18px;
}
#libraryCreateFab {
  font-size: 0;
}
#libraryCreateFab span {
  display: none !important;
}
#quickCreateBoardBtn {
  display: none !important;
}
@media (max-width: 900px) {
  .library-header {
    padding: 16px 16px;
    gap: 14px;
  }
  .library-header h1 {
    font-size: clamp(22px, 7vw, 28px);
  }
  .library-header .subtle {
    font-size: 12px;
  }
}
@media (max-width: 700px) {
  #createBoardBtn {
    display: none !important;
  }
}


/* ===== idea board alignment cleanup ===== */
#libraryScreen #importBoardBtn {
  display: none !important;
}

.library-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
}

.library-header > :first-child {
  min-width: 0;
}

.library-actions {
  justify-content: flex-end;
  align-items: center;
}

.toolbar-meta {
  align-items: center;
}

.toolbar-meta .primary-btn.compact,
.toolbar-meta .secondary-btn.compact {
  min-height: 46px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

#libraryStats {
  min-height: 46px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 2px;
  line-height: 1;
}

@media (max-width: 1180px) {
  .library-header {
    padding: 16px 18px;
    gap: 14px;
  }

  .library-header h1 {
    max-width: none;
  }

  .library-toolbar {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
  }

  .toolbar-meta {
    flex-wrap: nowrap;
    justify-content: flex-end;
  }
}

@media (max-width: 820px) {
  .library-header {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: start;
  }

  .library-header h1 {
    font-size: clamp(26px, 6.6vw, 34px);
    margin-bottom: 4px;
  }

  .library-header .subtle {
    font-size: 13px;
  }

  .library-toolbar {
    gap: 12px;
  }

  .toolbar-meta {
    gap: 8px;
  }
}

@media (max-width: 720px) {
  .library-header {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
  }

  .library-actions {
    display: flex !important;
  }

  .toolbar-meta {
    width: auto;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: nowrap;
    overflow-x: auto;
  }

  #libraryStats {
    justify-self: auto;
    align-self: center;
  }
}


/* Focus chrome stays centered; no draggable behavior */
.focus-chrome,
.focus-chrome-pill {
  cursor: default !important;
}



/* ===== Real portrait/mobile focus chrome fix ===== */
@media (max-width: 820px) {
  body.focus-mode .focus-chrome,
  body.present-mode .focus-chrome {
    top: calc(env(safe-area-inset-top, 0px) + 12px) !important;
    bottom: auto !important;
    left: 0;
    right: 0;
    width: auto;
    height: auto;
    min-height: 0;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding-inline: 12px;
    pointer-events: none;
  }

  body.focus-mode .focus-chrome-pill,
  body.present-mode .focus-chrome-pill {
    display: inline-flex;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
    align-self: flex-start;
    justify-content: center;
    width: max-content;
    min-width: 0;
    max-width: min(calc(100vw - 24px), 720px);
    height: auto;
    max-height: none;
    overflow-x: auto;
    overflow-y: hidden;
    white-space: nowrap;
    pointer-events: auto;
  }

  body.focus-mode .focus-chrome-pill > *,
  body.present-mode .focus-chrome-pill > * {
    flex: 0 0 auto;
  }

  body.focus-mode .focus-cluster,
  body.present-mode .focus-cluster {
    flex-wrap: nowrap;
    white-space: nowrap;
    min-width: 0;
  }

  body.focus-mode .focus-tools-scroll,
  body.present-mode .focus-tools-scroll {
    max-width: min(100%, calc(100vw - 188px));
  }
}




/* Collaboration layer */
.collab-status-badge {
  display:inline-flex; align-items:center; min-height:24px; padding:0 10px; border-radius:999px;
  border:1px solid rgba(15,23,42,.08); background:rgba(255,255,255,.74); color:#64748b;
  font-size:11px; letter-spacing:.01em; white-space:nowrap;
}
.collab-status-badge[data-tone="live"] { color:#065f46; background:rgba(236,253,245,.95); border-color:rgba(16,185,129,.24); }
.collab-status-badge[data-tone="syncing"] { color:#1d4ed8; background:rgba(239,246,255,.96); border-color:rgba(59,130,246,.22); }
.collab-status-badge[data-tone="warn"] { color:#92400e; background:rgba(255,251,235,.96); border-color:rgba(245,158,11,.24); }
.collab-status-badge[data-tone="error"] { color:#991b1b; background:rgba(254,242,242,.96); border-color:rgba(239,68,68,.22); }
.collab-settings-card {
  display:flex; flex-direction:column; gap:16px; padding:20px; border-radius:22px;
  border:1px solid rgba(15,23,42,.08); background:linear-gradient(180deg, rgba(255,255,255,.98), rgba(248,250,252,.94));
  box-shadow:0 14px 34px rgba(15,23,42,.07);
}
.collab-settings-head { display:flex; align-items:flex-start; justify-content:space-between; gap:16px; }
.collab-settings-head h3 { margin:2px 0 0; font-size:24px; letter-spacing:-.03em; }
.collab-toggle-row { min-width:132px; padding:12px 14px; }
.collab-status-line { margin:0; line-height:1.5; }
.collab-simple-grid { display:grid; grid-template-columns:minmax(0,1.25fr) minmax(280px,.85fr); gap:16px; align-items:start; }
.collab-share-panel, .collab-side-card {
  display:flex; flex-direction:column; gap:14px; padding:18px; border-radius:18px;
  border:1px solid rgba(15,23,42,.08); background:rgba(255,255,255,.82);
}
.collab-share-panel h4 { margin:4px 0 0; font-size:21px; letter-spacing:-.03em; color:#0f172a; }
.collab-share-copy { margin:0; }
.collab-passcode-row { display:grid; grid-template-columns:minmax(0,1fr) auto; gap:12px; align-items:end; }
.collab-grid input[type="text"],
.collab-share-panel input[type="text"] { min-height:46px; }
.collab-actions-row { display:flex; flex-wrap:wrap; gap:10px; }
.collab-advanced { border:1px solid rgba(15,23,42,.08); border-radius:18px; background:rgba(248,250,252,.75); }
.collab-advanced summary { cursor:pointer; list-style:none; padding:16px 18px; font-weight:600; color:#0f172a; }
.collab-advanced summary::-webkit-details-marker { display:none; }
.collab-advanced > *:not(summary) { padding:0 18px 18px; }
.collab-presence-list { display:flex; flex-direction:column; gap:8px; min-height:100%; }
.collab-presence-empty { padding:12px 14px; border-radius:14px; background:rgba(255,255,255,.66); border:1px solid rgba(15,23,42,.08); color:#64748b; font-size:13px; }
.collab-presence-item {
  display:flex; align-items:center; justify-content:space-between; gap:14px; padding:12px 14px; border-radius:14px;
  border:1px solid rgba(15,23,42,.08); background:rgba(255,255,255,.72);
}
.collab-presence-id { display:flex; align-items:center; gap:10px; min-width:0; }
.collab-presence-dot { width:12px; height:12px; border-radius:999px; flex:0 0 auto; box-shadow:0 0 0 3px rgba(255,255,255,.75); }
.collab-presence-copy { display:flex; flex-direction:column; min-width:0; }
.collab-presence-copy strong { font-size:13px; color:#0f172a; }
.collab-presence-copy span { font-size:12px; color:#64748b; }
.join-overlay {
  position:fixed; inset:0; z-index:95; display:flex; align-items:center; justify-content:center;
  background:rgba(11,18,32,.34); backdrop-filter:blur(10px); -webkit-backdrop-filter:blur(10px);
  padding:20px;
}
.join-card {
  width:min(420px, calc(100vw - 32px)); display:flex; flex-direction:column; gap:14px; padding:22px;
  border-radius:24px; background:rgba(255,255,255,.98); border:1px solid rgba(255,255,255,.72);
  box-shadow:0 30px 80px rgba(15,23,42,.28);
}
.join-card h2 { margin:2px 0 0; font-size:28px; letter-spacing:-.04em; color:#0f172a; }
.join-actions { display:flex; gap:10px; flex-wrap:wrap; }
.presence-layer { position:absolute; inset:0; z-index:12; pointer-events:none; }
.presence-cursor { position:absolute; transform:translate(-4px, -4px); display:flex; flex-direction:column; align-items:flex-start; gap:4px; }
.presence-cursor-dot { width:12px; height:12px; border-radius:999px; border:2px solid rgba(255,255,255,.96); box-shadow:0 8px 18px rgba(15,23,42,.18); }
.presence-cursor-label {
  padding:5px 8px; border-radius:999px; background:rgba(15,23,42,.86); color:#fff; font-size:11px;
  line-height:1; letter-spacing:.01em; white-space:nowrap; box-shadow:0 10px 24px rgba(15,23,42,.18);
}
@media (max-width: 980px) {
  .collab-settings-head { flex-direction:column; }
  .collab-toggle-row { width:100%; }
  .collab-simple-grid { grid-template-columns:1fr; }
  .collab-passcode-row { grid-template-columns:1fr; }
  .collab-actions-row { display:grid; grid-template-columns:1fr; }
}



.more-shapes-btn.active,
#mobileMoreShapesOpenBtn.active {
  background: linear-gradient(180deg, #0f172a 0%, #111827 100%);
  color: #ffffff;
  border-color: rgba(15,23,42,0.18);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.12), 0 10px 18px rgba(15,23,42,0.18);
}

.shape-sheet-body {
  gap: 18px;
}

.shape-sheet-copy {
  margin: 0;
}

.shape-library-section {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.shape-library-head {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.shape-library-head h3 {
  margin: 0;
  font-size: 20px;
  line-height: 1.15;
  color: #0f172a;
}

.shape-library-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 12px;
}

.shape-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 12px;
  min-height: 110px;
  padding: 14px;
  border-radius: 20px;
  border: 1px solid rgba(15,23,42,0.08);
  background: linear-gradient(180deg, rgba(255,255,255,0.98), rgba(247,248,251,0.96));
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.9), 0 10px 24px rgba(15,23,42,0.05);
  color: #0f172a;
  text-align: left;
  transition: transform 160ms ease, box-shadow 160ms ease, border-color 160ms ease;
}

.shape-card:hover,
.shape-card:focus-visible {
  transform: translateY(-1px);
  border-color: rgba(15,23,42,0.14);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.95), 0 16px 30px rgba(15,23,42,0.09);
}

.shape-card.active {
  border-color: rgba(37,99,235,0.28);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.95), 0 16px 30px rgba(37,99,235,0.10);
}

.shape-card svg {
  width: 32px;
  height: 32px;
  flex: 0 0 auto;
}

.shape-card span {
  font-size: 13px;
  line-height: 1.25;
  font-weight: 600;
  color: #344054;
}

@media (max-width: 820px) {
  .shape-library-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .shape-card {
    min-height: 98px;
    padding: 12px;
    border-radius: 18px;
  }

  .shape-card svg {
    width: 28px;
    height: 28px;
  }

  .shape-card span {
    font-size: 12px;
  }
}


@media (max-width: 1120px) {
  .focus-tools-scroll {
    max-width: min(50vw, calc(100vw - 260px));
  }
}

@media (max-width: 640px) {
  .focus-tools-scroll {
    max-width: calc(100vw - 164px);
  }
}

/* ===== V72.3.6 focus chrome collapse + adaptive zoom HUD ===== */
.focus-chrome-pill {
  transition: padding 180ms ease, border-radius 180ms ease, box-shadow 180ms ease, background 180ms ease, transform 180ms ease, opacity 280ms ease, filter 280ms ease;
}

.focus-compact-toggle {
  display: none;
  width: 42px;
  height: 42px;
  border-radius: 14px;
  background: linear-gradient(180deg, #0f172a 0%, #111827 100%);
  color: #ffffff;
  border-color: rgba(15,23,42,0.14);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.14), 0 10px 18px rgba(15,23,42,0.18);
}
.focus-compact-toggle::before {
  display: none !important;
}
.focus-compact-toggle svg {
  width: 20px;
  height: 20px;
}

body.focus-mode.focus-chrome-collapsed .focus-compact-toggle,
body.present-mode.focus-chrome-collapsed .focus-compact-toggle {
  display: inline-flex;
}

body.focus-mode.focus-chrome-collapsed .focus-chrome-pill,
body.present-mode.focus-chrome-collapsed .focus-chrome-pill {
  padding: 8px;
  gap: 0;
  border-radius: 18px;
  max-width: none;
  overflow: visible;
}

body.focus-mode.focus-chrome-collapsed .focus-chrome-pill > :not(.focus-compact-toggle),
body.present-mode.focus-chrome-collapsed .focus-chrome-pill > :not(.focus-compact-toggle) {
  display: none !important;
}

body.focus-mode.focus-chrome-collapsed.focus-chrome-collapsed-dim .focus-chrome-pill,
body.present-mode.focus-chrome-collapsed.focus-chrome-collapsed-dim .focus-chrome-pill {
  opacity: 0.34;
  background: rgba(255,255,255,0.58);
  box-shadow: 0 10px 24px rgba(15,23,42,0.10), inset 0 1px 0 rgba(255,255,255,0.60);
  filter: saturate(0.92);
}

body.focus-mode.focus-chrome-collapsed.focus-chrome-collapsed-dim .focus-chrome-pill:hover,
body.present-mode.focus-chrome-collapsed.focus-chrome-collapsed-dim .focus-chrome-pill:hover,
body.focus-mode.focus-chrome-collapsed.focus-chrome-collapsed-dim .focus-chrome-pill:focus-within,
body.present-mode.focus-chrome-collapsed.focus-chrome-collapsed-dim .focus-chrome-pill:focus-within {
  opacity: 0.92;
  filter: none;
}

body.focus-mode.focus-zoom-auto-hidden .zoom-hud,
body.present-mode.focus-zoom-auto-hidden .zoom-hud {
  display: none !important;
}

@media (max-width: 820px) {
  body.focus-mode.focus-chrome-collapsed .focus-chrome-pill,
  body.present-mode.focus-chrome-collapsed .focus-chrome-pill {
    max-width: none !important;
    padding: 8px !important;
  }
}


/* ===== v72.3.7 iPad landscape focus spacing + viewport integrity ===== */
.focus-chrome {
  top: var(--focus-chrome-top, max(16px, env(safe-area-inset-top, 0px) + 10px));
  padding-top: 0;
}

body.focus-mode .focus-chrome,
body.present-mode .focus-chrome {
  top: var(--focus-chrome-top, max(16px, env(safe-area-inset-top, 0px) + 10px));
}

@media (min-width: 821px) and (max-width: 1366px) {
  .topbar {
    margin-top: 8px;
  }

  body.focus-mode .editor-screen,
  body.present-mode .editor-screen {
    min-height: 100dvh;
    height: 100dvh;
    overflow: clip;
  }

  body.focus-mode .canvas-shell,
  body.focus-mode .canvas-wrap,
  body.present-mode .canvas-shell,
  body.present-mode .canvas-wrap {
    min-height: 100dvh;
    height: 100dvh;
  }

  body.focus-mode .minimap,
  body.present-mode .minimap {
    right: max(14px, env(safe-area-inset-right, 0px) + 14px);
    bottom: max(14px, env(safe-area-inset-bottom, 0px) + 14px);
  }

  body.focus-mode .zoom-hud,
  body.present-mode .zoom-hud {
    left: max(14px, env(safe-area-inset-left, 0px) + 14px);
    bottom: max(14px, env(safe-area-inset-bottom, 0px) + 14px);
  }
}


.publish-settings-card { margin-top: 16px; }
.publish-settings-card input[type="text"] { min-height: 46px; }
#publishStatusLine[data-tone="error"] { color: #b42318; }
#publishStatusLine[data-tone="live"] { color: #166534; }
#publishStatusLine[data-tone="syncing"] { color: #1d4ed8; }
body.read-only-mode .left-panel,
body.read-only-mode .right-panel,
body.read-only-mode #openSettingsBtn,
body.read-only-mode #topbarSettingsBtn,
body.read-only-mode #topbarCollaborateBtn,
body.read-only-mode #undoBtn,
body.read-only-mode #redoBtn,
body.read-only-mode #importImageBtn,
body.read-only-mode #exportBtn,
body.read-only-mode .mobile-bottom-bar,
body.read-only-mode #objectContextMenu,
body.read-only-mode #floatingEditor,
body.read-only-mode #pluginTopbarMount,
body.read-only-mode #focusSettingsBtn,
body.read-only-mode #focusCollaborateBtn,
body.read-only-mode #focusImportImageBtn,
body.read-only-mode #focusMoreShapesBtn,
body.read-only-mode #focusPanelsBtn,
body.read-only-mode .focus-tool-btn,
body.read-only-mode #focusTextBar { display: none !important; }
body.read-only-mode .topbar-center { display:none; }
body.read-only-mode .board-title-input { pointer-events:none; color:#334155; }
body.read-only-mode .save-state { display:none !important; }
body.read-only-mode .workspace {
  grid-template-columns: minmax(0, 1fr) !important;
  gap: 0 !important;
  padding: 14px !important;
}
body.read-only-mode .canvas-shell,
body.read-only-mode .canvas-wrap {
  width: 100% !important;
  max-width: none !important;
  min-width: 0 !important;
}
body.read-only-mode .canvas-shell {
  min-height: calc(100dvh - 110px) !important;
}
body.read-only-mode .canvas-wrap {
  min-height: calc(100dvh - 118px) !important;
}
body.read-only-mode .zoom-hud {
  left: 18px !important;
  right: auto !important;
  bottom: 18px !important;
}
body.read-only-mode.focus-panels-visible {
  --unused: 0;
}
body.read-only-mode.focus-panels-visible .left-panel,
body.read-only-mode.focus-panels-visible .right-panel {
  display: none !important;
}
@media (min-width: 821px) {
  body.read-only-mode .topbar {
    grid-template-columns: minmax(220px, 1fr) auto !important;
  }
  body.read-only-mode .topbar-right {
    justify-content: flex-end;
  }
}
@media (max-width: 820px) {
  body.read-only-mode .workspace {
    padding: 10px 10px calc(env(safe-area-inset-bottom, 0px) + 10px) !important;
  }
  body.read-only-mode .canvas-shell {
    min-height: calc(100dvh - 84px) !important;
  }
  body.read-only-mode .canvas-wrap {
    min-height: calc(100dvh - 92px) !important;
    border-radius: 24px;
  }
  body.read-only-mode .zoom-hud {
    left: 10px !important;
    bottom: calc(env(safe-area-inset-bottom, 0px) + 14px) !important;
  }
}


/* Built-in shape kit library */
.shape-sheet-body {
  gap: 18px;
}

.shape-sheet-copy {
  margin: 0;
}

.shape-catalog-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-radius: 18px;
  border: 1px solid rgba(15,23,42,0.08);
  background: linear-gradient(180deg, rgba(255,255,255,0.98), rgba(247,248,251,0.96));
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.9), 0 10px 24px rgba(15,23,42,0.05);
}

.shape-search-input {
  flex: 1 1 280px;
  min-width: 220px;
  border-radius: 14px;
  border: 1px solid rgba(15,23,42,0.10);
  background: rgba(255,255,255,0.96);
  color: #0f172a;
  padding: 12px 14px;
  font: inherit;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.94);
}

.shape-search-input:focus {
  outline: none;
  border-color: rgba(37,99,235,0.28);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.10);
}

.shape-catalog-meta {
  white-space: nowrap;
  font-weight: 600;
}

.builtin-shape-kit-host {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.shape-section-count {
  font-size: 12px;
  font-weight: 700;
}

.builtin-shape-kit-section .shape-library-head {
  flex-direction: row;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
}

.shape-kit-card svg {
  width: 44px;
  height: 44px;
}

.shape-library-section {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.shape-library-head {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.shape-library-head h3 {
  margin: 0;
  font-size: 20px;
  line-height: 1.15;
  color: #0f172a;
}

.shape-library-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 12px;
}

.shape-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 12px;
  min-height: 110px;
  padding: 14px;
  border-radius: 20px;
  border: 1px solid rgba(15,23,42,0.08);
  background: linear-gradient(180deg, rgba(255,255,255,0.98), rgba(247,248,251,0.96));
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.9), 0 10px 24px rgba(15,23,42,0.05);
  color: #0f172a;
  text-align: left;
  transition: transform 160ms ease, box-shadow 160ms ease, border-color 160ms ease;
}

.shape-card:hover,
.shape-card:focus-visible {
  transform: translateY(-1px);
  border-color: rgba(15,23,42,0.14);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.95), 0 16px 30px rgba(15,23,42,0.09);
}

.shape-card.active {
  border-color: rgba(37,99,235,0.28);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.95), 0 16px 30px rgba(37,99,235,0.08);
}

.shape-card svg {
  width: 40px;
  height: 40px;
  flex: 0 0 auto;
  color: #334155;
}

.shape-card span {
  font-size: 13px;
  line-height: 1.35;
  font-weight: 600;
}


/* Attachment objects and previews */
.attachment-preview-overlay {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: flex;
  align-items: stretch;
  justify-content: stretch;
  padding: 12px;
  background: rgba(15, 23, 42, 0.38);
  backdrop-filter: blur(10px) saturate(1.04);
}
.attachment-preview-card {
  width: min(1280px, calc(100vw - 24px));
  height: calc(100dvh - 24px);
  max-height: none;
  margin: 0 auto;
  border-radius: 30px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow: hidden;
}
.attachment-preview-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}
.attachment-preview-header h2 {
  margin: 4px 0 0;
  font-size: 26px;
  line-height: 1.08;
  letter-spacing: -0.03em;
  overflow-wrap: anywhere;
  word-break: break-word;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  max-width: min(100%, 980px);
}
.attachment-preview-meta { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.attachment-preview-meta span {
  display: inline-flex; align-items: center; padding: 6px 10px; border-radius: 999px;
  background: rgba(248,250,252,0.9); border: 1px solid rgba(203,213,225,0.9); color: #475569; font-size: 12px; font-weight: 700;
}
.attachment-preview-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  border-radius: 24px;
  background: linear-gradient(180deg, rgba(255,255,255,0.92), rgba(248,250,252,0.98));
  border: 1px solid rgba(203,213,225,0.8);
  padding: 20px;
}
.attachment-preview-text {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  font: 14px/1.72 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color: #0f172a;
}
.attachment-preview-image, .attachment-preview-frame, .attachment-preview-media {
  width: 100%;
  max-width: 100%;
  border-radius: 20px;
  border: 1px solid rgba(203,213,225,0.7);
  background: #fff;
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.06);
}
.attachment-preview-image {
  max-height: calc(100dvh - 220px);
  object-fit: contain;
}
.attachment-preview-frame {
  min-height: calc(100dvh - 250px);
}
.attachment-preview-media {
  display: block;
  max-height: calc(100dvh - 250px);
}
.attachment-preview-footer {
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
}
.attachment-preview-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.attachment-preview-empty, .attachment-preview-fallback {
  display: flex; align-items: center; justify-content: center; min-height: 240px; color: #475569;
}
.attachment-preview-fallback { gap: 18px; justify-content: flex-start; align-items: flex-start; }
.attachment-preview-fallback-copy { min-width: 0; flex: 1 1 auto; }
.attachment-preview-fallback-copy h3,
.attachment-preview-archive-copy h3 {
  margin: 0;
  overflow-wrap: anywhere;
  word-break: break-word;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.attachment-preview-fallback-copy p,
.attachment-preview-archive-copy p {
  margin: 8px 0 0;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.attachment-preview-fallback-badge {
  min-width: 84px; height: 84px; border-radius: 22px; display: inline-flex; align-items: center; justify-content: center;
  background: linear-gradient(180deg, #F8FAFC 0%, #EEF2FF 100%); color: #334155; border: 1px solid #CBD5E1; font-size: 22px; font-weight: 800;
}
@media (max-width: 980px) {
  .attachment-preview-overlay { padding: 0; align-items: stretch; }
  .attachment-preview-card {
    width: 100%;
    height: 100dvh;
    border-radius: 0;
    margin: 0;
    padding: 18px 16px calc(env(safe-area-inset-bottom, 0px) + 16px);
  }
  .attachment-preview-header h2 { font-size: 22px; }
  .attachment-preview-frame,
  .attachment-preview-media,
  .attachment-preview-image { max-height: calc(100dvh - 250px); }
}


/* ===== Desktop collapsible + resizable side columns ===== */
:root {
  --workspace-left-width: 276px;
  --workspace-right-width: 318px;
  --workspace-left-handle: 18px;
  --workspace-right-handle: 18px;
}

.panel-collapse-btn,
.panel-peek-toggle,
.panel-resize-handle {
  display: none;
}

@media (min-width: 981px) {
  body:not(.present-mode):not(.focus-mode) .workspace {
    grid-template-columns:
      var(--workspace-left-track, var(--workspace-left-width))
      var(--workspace-left-handle, 12px)
      minmax(0, 1fr)
      var(--workspace-right-handle, 12px)
      var(--workspace-right-track, var(--workspace-right-width));
    align-items: stretch;
  }

  body.left-panel-collapsed:not(.present-mode):not(.focus-mode) {
    --workspace-left-track: 0px;
    --workspace-left-handle: 18px;
  }

  body.right-panel-collapsed:not(.present-mode):not(.focus-mode) {
    --workspace-right-track: 0px;
    --workspace-right-handle: 18px;
  }

  body:not(.present-mode):not(.focus-mode) .left-panel,
  body:not(.present-mode):not(.focus-mode) .right-panel {
    min-width: 0;
    width: 100%;
    max-width: none;
  }

  body.left-panel-collapsed:not(.present-mode):not(.focus-mode) .left-panel,
  body.right-panel-collapsed:not(.present-mode):not(.focus-mode) .right-panel {
    opacity: 0;
    pointer-events: none;
    overflow: hidden;
    padding: 0;
    border-width: 0;
    box-shadow: none;
  }

  .panel-collapse-btn {
    display: none;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 11px;
    border: 1px solid rgba(15,23,42,0.08);
    background: linear-gradient(180deg, rgba(255,255,255,0.95), rgba(248,250,252,0.88));
    color: #475467;
    cursor: pointer;
    flex: 0 0 auto;
    transition: background 160ms ease, border-color 160ms ease, transform 160ms ease, color 160ms ease, box-shadow 160ms ease;
    box-shadow: 0 4px 12px rgba(15,23,42,0.04);
  }

  .panel-collapse-btn:hover,
  .panel-collapse-btn:focus-visible {
    outline: none;
    color: #111827;
    border-color: rgba(15,23,42,0.12);
    background: linear-gradient(180deg, rgba(255,255,255,1), rgba(248,250,252,0.94));
    box-shadow: 0 8px 18px rgba(15,23,42,0.08);
  }

  .panel-collapse-btn svg {
    width: 16px;
    height: 16px;
    display: block;
  }

  .panel-resize-handle {
    display: flex;
    align-items: center;
    justify-content: center;
    align-self: stretch;
    gap: 5px;
    width: 18px;
    min-width: 18px;
    padding: 0;
    border: 0;
    background: transparent;
    cursor: col-resize;
    touch-action: none;
    position: relative;
    isolation: isolate;
  }

  .panel-resize-handle::before {
    content: "";
    position: absolute;
    left: 7px;
    top: 50%;
    transform: translateY(-50%);
    width: 4px;
    height: 84px;
    border-radius: 999px;
    background: linear-gradient(180deg, rgba(148,163,184,0.10), rgba(100,116,139,0.18), rgba(148,163,184,0.10));
    box-shadow: inset 0 0 0 1px rgba(255,255,255,0.52);
    transition: background 160ms ease, transform 160ms ease, opacity 160ms ease;
  }

  .panel-resize-grip {
    position: absolute;
    left: 7px;
    top: 50%;
    width: 4px;
    height: 84px;
    transform: translateY(-50%);
    border-radius: 999px;
    background: transparent;
    opacity: 0;
    pointer-events: none;
  }

  .panel-edge-toggle-icon {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 30px;
    border-radius: 999px;
    border: 1px solid rgba(15,23,42,0.08);
    background: linear-gradient(180deg, rgba(255,255,255,0.94), rgba(248,250,252,0.90));
    color: #667085;
    box-shadow: 0 8px 18px rgba(15,23,42,0.08);
    transition: color 160ms ease, border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease, background 160ms ease, opacity 160ms ease;
    z-index: 1;
    pointer-events: none;
  }

  .panel-edge-toggle-icon svg {
    width: 11px;
    height: 11px;
    display: block;
  }

  .left-panel-handle {
    justify-self: center;
  }

  .right-panel-handle {
    justify-self: center;
  }

  .left-panel-handle .panel-edge-toggle-icon {
    margin-left: 8px;
  }

  .right-panel-handle .panel-edge-toggle-icon {
    margin-right: 8px;
  }

  .panel-resize-handle:hover::before,
  .panel-resize-handle:focus-visible::before,
  body.panel-resizing .panel-resize-handle.is-active::before {
    background: linear-gradient(180deg, rgba(96,165,250,0.18), rgba(59,130,246,0.34), rgba(96,165,250,0.18));
    transform: translateY(-50%) scaleX(1.15);
  }

  .panel-resize-handle:hover .panel-edge-toggle-icon,
  .panel-resize-handle:focus-visible .panel-edge-toggle-icon,
  body.panel-resizing .panel-resize-handle.is-active .panel-edge-toggle-icon {
    color: #0f172a;
    border-color: rgba(15,23,42,0.12);
    background: linear-gradient(180deg, rgba(255,255,255,0.98), rgba(248,250,252,0.94));
    box-shadow: 0 10px 22px rgba(15,23,42,0.12);
  }

  body.left-panel-collapsed:not(.present-mode):not(.focus-mode) .left-panel-handle,
  body.right-panel-collapsed:not(.present-mode):not(.focus-mode) .right-panel-handle {
    display: flex;
  }

  body.left-panel-collapsed:not(.present-mode):not(.focus-mode) .left-panel-handle::before,
  body.right-panel-collapsed:not(.present-mode):not(.focus-mode) .right-panel-handle::before {
    opacity: 0;
  }

  body.left-panel-collapsed:not(.present-mode):not(.focus-mode) .left-panel-handle .panel-edge-toggle-icon,
  body.right-panel-collapsed:not(.present-mode):not(.focus-mode) .right-panel-handle .panel-edge-toggle-icon {
    opacity: 0.98;
  }

  body.left-panel-collapsed:not(.present-mode):not(.focus-mode) .left-panel-handle .panel-edge-toggle-icon {
    transform: translateX(1px);
  }

  body.right-panel-collapsed:not(.present-mode):not(.focus-mode) .right-panel-handle .panel-edge-toggle-icon {
    transform: translateX(-1px);
  }

  .panel-peek-toggle {
    display: none !important;
  }

  body.left-panel-collapsed:not(.present-mode):not(.focus-mode) .left-panel-handle .panel-edge-toggle-icon svg,
  body.right-panel-collapsed:not(.present-mode):not(.focus-mode) .right-panel-handle .panel-edge-toggle-icon svg {
    transform: rotate(180deg);
  }
  body.panel-resizing,
  body.panel-resizing * {
    cursor: col-resize !important;
    user-select: none !important;
  }
}

@media (max-width: 980px) {
  .panel-collapse-btn,
  .panel-peek-toggle,
  .panel-resize-handle {
    display: none !important;
  }
}

body.present-mode .panel-collapse-btn,
body.present-mode .panel-peek-toggle,
body.present-mode .panel-resize-handle,
body.read-only-mode .panel-collapse-btn,
body.read-only-mode .panel-peek-toggle,
body.read-only-mode .panel-resize-handle {
  display: none !important;
}

body.focus-mode .panel-collapse-btn,
body.focus-mode .panel-peek-toggle {
  display: none !important;
}

@media (min-width: 981px) {
  body.focus-mode.focus-panels-visible .panel-resize-handle {
    display: flex !important;
    position: fixed;
    top: max(74px, env(safe-area-inset-top, 0px) + 68px);
    bottom: 18px;
    width: 18px;
    min-width: 18px;
    z-index: 86;
    align-self: auto;
  }

  body.focus-mode.focus-panels-visible .left-panel-handle {
    left: calc(18px + min(var(--workspace-left-track, var(--workspace-left-width)), calc(100vw - 140px)) - 9px);
  }

  body.focus-mode.focus-panels-visible .right-panel-handle {
    right: calc(18px + min(var(--workspace-right-track, var(--workspace-right-width)), calc(100vw - 140px)) - 9px);
  }

  body.focus-mode.focus-panels-visible.left-panel-collapsed .left-panel-handle {
    left: 9px;
  }

  body.focus-mode.focus-panels-visible.right-panel-collapsed .right-panel-handle {
    right: 9px;
  }

  body.focus-mode.focus-panels-visible.left-panel-collapsed .left-panel-handle::before,
  body.focus-mode.focus-panels-visible.right-panel-collapsed .right-panel-handle::before {
    opacity: 0;
  }

  body.focus-mode.focus-panels-visible.left-panel-collapsed .left-panel-handle .panel-edge-toggle-icon,
  body.focus-mode.focus-panels-visible.right-panel-collapsed .right-panel-handle .panel-edge-toggle-icon {
    opacity: 0.98;
  }

  body.focus-mode.focus-panels-visible.left-panel-collapsed .left-panel-handle .panel-edge-toggle-icon {
    transform: translateX(1px);
  }

  body.focus-mode.focus-panels-visible.right-panel-collapsed .right-panel-handle .panel-edge-toggle-icon {
    transform: translateX(-1px);
  }

  body.focus-mode.focus-panels-visible.left-panel-collapsed .left-panel-handle .panel-edge-toggle-icon svg,
  body.focus-mode.focus-panels-visible.right-panel-collapsed .right-panel-handle .panel-edge-toggle-icon svg {
    transform: rotate(180deg);
  }
}


/* ===== v5 compact focus panels for mobile + iPad portrait ===== */
.focus-compact-panels-bar {
  display: none;
}

@media (max-width: 980px) {
  body.focus-mode .focus-compact-panels-bar {
    position: fixed;
    top: calc(var(--focus-chrome-top, max(16px, env(safe-area-inset-top, 0px) + 10px)) + 62px);
    left: 50%;
    transform: translateX(-50%);
    z-index: 88;
    width: min(calc(100vw - 24px), 420px);
  }

  body.focus-mode.focus-compact-panels-open .focus-compact-panels-bar {
    display: flex;
    justify-content: center;
  }

  .focus-compact-panels-pill {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 8px;
    border-radius: 20px;
    background: rgba(255,255,255,0.9);
    border: 1px solid rgba(15,23,42,0.08);
    box-shadow: 0 18px 40px rgba(15,23,42,0.14), 0 6px 18px rgba(15,23,42,0.08);
    backdrop-filter: blur(22px);
  }

  .focus-compact-segmented {
    flex: 1 1 auto;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    padding: 4px;
    border-radius: 16px;
    background: rgba(15,23,42,0.04);
  }

  .focus-compact-segment,
  .focus-compact-close {
    -webkit-appearance: none;
    appearance: none;
    border: 0;
    background: transparent;
    color: #475467;
  }

  .focus-compact-segment {
    min-height: 38px;
    border-radius: 12px;
    padding: 0 14px;
    font-size: 14px;
    font-weight: 620;
    letter-spacing: -0.01em;
    transition: background 160ms ease, color 160ms ease, box-shadow 160ms ease;
  }

  .focus-compact-segment.active {
    background: linear-gradient(180deg, #0f172a 0%, #111827 100%);
    color: #ffffff;
    box-shadow: 0 10px 18px rgba(15,23,42,0.18), inset 0 1px 0 rgba(255,255,255,0.14);
  }

  .focus-compact-close {
    flex: 0 0 auto;
    width: 38px;
    height: 38px;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(15,23,42,0.08);
    background: rgba(248,250,252,0.92);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.8);
  }

  .focus-compact-close svg {
    width: 17px;
    height: 17px;
    display: block;
  }

  .focus-compact-close:hover,
  .focus-compact-close:focus-visible,
  .focus-compact-segment:hover,
  .focus-compact-segment:focus-visible {
    outline: none;
    color: #111827;
  }

  body.focus-mode.focus-compact-panels-open .left-panel,
  body.focus-mode.focus-compact-panels-open .right-panel {
    top: calc(var(--focus-chrome-top, max(16px, env(safe-area-inset-top, 0px) + 10px)) + 122px) !important;
    left: 12px !important;
    right: 12px !important;
    bottom: 12px !important;
    width: auto !important;
    max-height: none !important;
    border-radius: 28px !important;
    box-shadow: 0 30px 72px rgba(15,23,42,0.18), 0 10px 24px rgba(15,23,42,0.08) !important;
  }

  body.focus-mode.focus-compact-panels-open.mobile-left-open .left-panel,
  body.focus-mode.focus-compact-panels-open.mobile-right-open .right-panel {
    display: flex !important;
    transform: translateY(0) !important;
    opacity: 1 !important;
    pointer-events: auto !important;
  }

  body.focus-mode.focus-compact-panels-open.mobile-left-open .right-panel,
  body.focus-mode.focus-compact-panels-open.mobile-right-open .left-panel {
    display: none !important;
  }
}


.attachment-preview-archive {
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-height: 100%;
}
.attachment-preview-archive-top {
  display: flex;
  align-items: flex-start;
  gap: 18px;
}
.attachment-preview-archive-copy {
  min-width: 0;
  flex: 1 1 auto;
}
.attachment-preview-archive-list-wrap {
  border-radius: 22px;
  border: 1px solid rgba(203, 213, 225, 0.88);
  background: rgba(255,255,255,0.92);
  overflow: hidden;
}
.attachment-preview-archive-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.attachment-preview-archive-list li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: start;
  padding: 14px 16px;
  border-top: 1px solid rgba(226,232,240,0.92);
}
.attachment-preview-archive-list li:first-child { border-top: 0; }
.attachment-archive-entry-name {
  min-width: 0;
  color: #0f172a;
  font-weight: 650;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.attachment-archive-entry-meta {
  color: #64748b;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.attachment-preview-archive-note {
  margin: 0;
}
@media (max-width: 980px) {
  .attachment-preview-archive-top,
  .attachment-preview-fallback {
    flex-direction: column;
  }
  .attachment-preview-archive-list li {
    grid-template-columns: 1fr;
  }
  .attachment-archive-entry-meta {
    white-space: normal;
  }
}
