:root {
  color-scheme: light;
  --ink: #1f1f23;
  --muted: #6f7078;
  --faint: #9a9ba3;
  --line: #e0e1e5;
  --surface: #ffffff;
  --workspace: #e8e9ec;
  --accent: #5749dc;
  --accent-dark: #4537c4;
  --accent-soft: #eeecfb;
  --shadow: 0 10px 28px rgba(29, 29, 38, .1), 0 1px 4px rgba(29, 29, 38, .06);
}

* { box-sizing: border-box; }

html, body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--workspace);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font: inherit; }
button, select { color: inherit; }
button { -webkit-tap-highlight-color: transparent; }
svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.app {
  width: 100%;
  height: 100%;
  height: 100dvh;
  display: grid;
  grid-template-rows: 60px 52px minmax(0, 1fr);
  overflow: hidden;
}

.topbar {
  z-index: 30;
  display: grid;
  grid-template-columns: minmax(190px, 1fr) auto minmax(190px, 1fr);
  align-items: center;
  padding: 0 14px 0 17px;
  background: #fbfbfc;
  border-bottom: 1px solid var(--line);
}

.brand { display: flex; align-items: center; gap: 9px; width: fit-content; color: inherit; text-decoration: none; }
.brand strong { font-size: 18px; font-weight: 720; letter-spacing: -.045em; }
.brand-mark {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
}
.brand-mark svg { width: 19px; height: 19px; stroke-width: 2; }
.top-left { position: relative; display: flex; align-items: center; gap: 18px; min-width: 0; }
.top-nav { display: flex; align-items: center; gap: 2px; }
.top-nav button {
  height: 32px;
  padding: 0 9px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: #55565d;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
}
.top-nav button:hover { background: #f0f0f2; color: var(--ink); }
.file-menu {
  position: absolute;
  z-index: 80;
  top: 43px;
  left: 94px;
  width: 190px;
  padding: 6px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 12px 28px rgba(24,24,30,.16), 0 2px 6px rgba(24,24,30,.06);
}
.file-menu[hidden] { display: none; }
.file-menu button { width: 100%; height: 36px; display: flex; align-items: center; gap: 10px; padding: 0 10px; border: 0; border-radius: 7px; background: transparent; color: var(--ink); font-size: 11px; font-weight: 600; cursor: pointer; text-align: left; }
.file-menu button:hover { background: #f2f2f4; }
.file-menu svg { width: 17px; height: 17px; color: var(--muted); }
.resize-menu { left: 139px; width: 220px; }
.resize-menu .menu-label { display: block; padding: 7px 10px 5px; color: var(--muted); font-size: 9px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.resize-menu button { display: grid; grid-template-columns: minmax(0, 1fr) auto; }
.resize-menu button small { color: #94959c; font-size: 9px; font-weight: 500; }

.document-name { display: grid; justify-items: center; gap: 2px; min-width: 180px; }
.document-name input {
  width: min(270px, 28vw);
  height: 29px;
  padding: 0 8px;
  border: 1px solid transparent;
  outline: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
  text-align: center;
  transition: border-color 130ms ease, background 130ms ease;
}
.document-name input:hover { background: #f7f7f9; }
.document-name input:focus { border-color: #b5a7f3; background: #fff; box-shadow: 0 0 0 3px var(--accent-soft); }
.document-name span { min-height: 12px; color: var(--faint); font-size: 9.5px; font-weight: 550; }

.top-actions { display: flex; justify-content: flex-end; align-items: center; gap: 3px; }
.top-divider { width: 1px; height: 24px; margin: 0 7px; background: var(--line); }
.icon-button, .format-button, .primary-button, .rail-button, .zoom-bar button, .panel-action, .text-preset, .element-card, .template-card, .background-card, .layer-action {
  border: 0;
  outline: 0;
  cursor: pointer;
}
.icon-button {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  padding: 0;
  background: transparent;
  border-radius: 9px;
  transition: background 130ms ease, transform 130ms ease;
}
.icon-button svg { width: 19px; height: 19px; }
.icon-button:hover:not(:disabled), .icon-button:focus-visible { background: #f1f1f4; }
.icon-button:active:not(:disabled) { transform: scale(.95); }
.icon-button:disabled { cursor: default; opacity: .28; }
.primary-button {
  height: 36px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 0 15px;
  background: var(--ink);
  color: #fff;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 700;
  box-shadow: 0 1px 2px rgba(20, 20, 24, .18);
  transition: background 130ms ease, transform 130ms ease;
}
.primary-button:hover { background: #050506; }
.primary-button:active { transform: scale(.97); }
.primary-button svg { width: 17px; height: 17px; stroke-width: 2; }

.propertybar {
  z-index: 22;
  display: flex;
  align-items: center;
  padding: 0 16px;
  background: #fff;
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
  scrollbar-width: none;
}
.propertybar::-webkit-scrollbar { display: none; }
.property-empty, .property-controls { min-width: max-content; display: flex; align-items: center; gap: 8px; }
.property-controls[hidden], .property-empty[hidden] { display: none; }
.property-controls [hidden] { display: none !important; }
.property-message { margin-left: 6px; color: var(--faint); font-size: 11px; }
.select-control, .number-control, .color-control { display: flex; align-items: center; gap: 7px; }
.size-select { display: none; }
.background-control { height: 32px; display: inline-flex; align-items: center; gap: 8px; padding: 0 10px; border: 0; border-radius: 7px; background: transparent; color: #55565d; font-size: 10.5px; font-weight: 650; cursor: pointer; }
.background-control:hover { background: #f0f0f3; color: var(--ink); }
.background-control > span { width: 20px; height: 20px; display: block; border: 1px solid #d4d5da; border-radius: 5px; background: #fff; box-shadow: inset 0 0 0 2px rgba(255,255,255,.35); }
.select-control > span, .number-control > span, .color-control > span { color: var(--muted); font-size: 10.5px; font-weight: 650; }
.select-control select, .number-control input {
  height: 32px;
  border: 1px solid var(--line);
  outline: 0;
  border-radius: 7px;
  background: #fff;
  font-size: 11px;
  font-weight: 600;
}
.select-control select { min-width: 120px; padding: 0 28px 0 10px; }
.number-control input { width: 58px; padding: 0 8px; }
.select-control select:focus, .number-control input:focus { border-color: #ad9cf1; box-shadow: 0 0 0 3px var(--accent-soft); }
.color-control input {
  width: 32px;
  height: 32px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  cursor: pointer;
}
.format-button {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  padding: 0;
  background: transparent;
  border-radius: 7px;
}
.format-button svg { width: 18px; height: 18px; }
.format-button:hover { background: #f0f0f3; }
.format-button.active { background: var(--accent-soft); color: var(--accent-dark); }
.format-button.danger-control:hover { background: #ffeded; color: #d64040; }
.property-text-button { height: 32px; padding: 0 10px; border: 0; border-radius: 7px; background: transparent; color: #55565d; font-size: 10.5px; font-weight: 650; cursor: pointer; }
.property-text-button:hover { background: #f0f0f3; color: var(--ink); }
.range-control { height: 32px; display: flex; align-items: center; gap: 6px; padding: 0 8px; border-left: 1px solid var(--line); }
.range-control svg { width: 17px; height: 17px; color: var(--muted); }
.range-control input { width: 78px; accent-color: var(--accent); cursor: pointer; }
.range-control output { width: 34px; color: var(--muted); font-size: 9px; font-weight: 700; }
.property-divider { width: 1px; height: 25px; background: var(--line); margin: 0 2px; }

.editor-layout { min-height: 0; display: grid; grid-template-columns: 72px 296px minmax(0, 1fr); }
.tool-rail {
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 2px;
  padding: 10px 6px;
  background: #202124;
  border-right: 1px solid #202124;
}
.rail-button {
  position: relative;
  height: 58px;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 5px;
  padding: 0 2px;
  background: transparent;
  color: #d3d4d8;
  border-radius: 8px;
  transition: background 130ms ease, color 130ms ease;
}
.rail-button svg { width: 21px; height: 21px; }
.rail-button span { font-size: 9.5px; font-weight: 600; }
.rail-button:hover { background: #303136; color: #fff; }
.rail-button.active { background: #38393e; color: #fff; }
.rail-button.active::before { content: ""; position: absolute; left: -6px; top: 16px; width: 3px; height: 26px; border-radius: 0 3px 3px 0; background: #8d82ff; }

.library-panel {
  z-index: 18;
  min-width: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  background: var(--surface);
  border-right: 1px solid var(--line);
  transition: transform 180ms ease;
}
.panel-heading { display: flex; align-items: center; justify-content: space-between; padding: 22px 19px 13px; }
.panel-heading h2 { margin: 0; font-size: 18px; font-weight: 680; letter-spacing: -.025em; }
.close-panel { display: none; }
.panel-content { min-height: 0; overflow-y: auto; padding: 5px 17px 26px; scrollbar-width: thin; scrollbar-color: #d4d4da transparent; }
.section-label { display: block; margin: 16px 1px 9px; color: var(--muted); font-size: 9.5px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; }
.panel-copy { margin: 0 1px 16px; color: var(--muted); font-size: 11.5px; line-height: 1.5; }
.panel-search { height: 37px; display: flex; align-items: center; gap: 8px; margin-bottom: 10px; padding: 0 10px; background: #fff; border: 1px solid #d7d8dd; border-radius: 8px; }
.panel-search:focus-within { border-color: #8c84dc; box-shadow: 0 0 0 2px rgba(87,73,220,.1); }
.panel-search svg { width: 17px; height: 17px; color: #85868d; }
.panel-search input { min-width: 0; flex: 1; border: 0; outline: 0; background: transparent; color: var(--ink); font-size: 11px; }
.panel-search input::placeholder { color: #9b9ca3; }
.filter-chips { display: flex; gap: 6px; margin: 0 0 15px; overflow-x: auto; scrollbar-width: none; }
.filter-chips::-webkit-scrollbar { display: none; }
.filter-chip { height: 29px; flex: 0 0 auto; padding: 0 10px; border: 1px solid var(--line); border-radius: 999px; background: #fff; color: #66676e; font-size: 9.5px; font-weight: 650; cursor: pointer; }
.filter-chip:hover { border-color: #b7b3d8; }
.filter-chip.active { border-color: #bbb6e7; background: var(--accent-soft); color: var(--accent-dark); }
.empty-search { grid-column: 1 / -1; margin: 18px 4px; color: var(--muted); font-size: 11px; text-align: center; }

.template-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 10px; }
.template-card { padding: 0; background: transparent; text-align: left; border-radius: 7px; }
.template-thumb {
  position: relative;
  width: 100%;
  aspect-ratio: var(--ratio, 1);
  max-height: 156px;
  overflow: hidden;
  background: #eee;
  border: 1px solid #e4e4e8;
  border-radius: 7px;
  box-shadow: 0 1px 3px rgba(35, 35, 42, .06);
  transition: transform 150ms ease, box-shadow 150ms ease;
}
.template-card:hover .template-thumb { transform: translateY(-1px); border-color: #b9b6d9; box-shadow: 0 5px 12px rgba(35, 35, 42, .1); }
.template-card strong { display: block; margin: 7px 1px 0; overflow: hidden; font-size: 10.5px; font-weight: 620; text-overflow: ellipsis; white-space: nowrap; }
.preview-item { position: absolute; transform-origin: center; overflow: hidden; }
.preview-text { white-space: pre-wrap; line-height: 1; }

.text-preset {
  width: 100%;
  min-height: 54px;
  display: flex;
  align-items: center;
  margin-bottom: 8px;
  padding: 11px 13px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  text-align: left;
  transition: border-color 130ms ease, background 130ms ease;
}
.text-preset:hover { border-color: #b8b2e5; background: var(--accent-soft); }
.text-preset.heading { font-size: 21px; font-weight: 800; letter-spacing: -.035em; }
.text-preset.subheading { font-family: Georgia, serif; font-size: 17px; font-weight: 600; }
.text-preset.body { font-size: 12px; line-height: 1.45; }
.font-pairs { display: grid; gap: 8px; }
.font-pair { display: grid; gap: 2px; width: 100%; padding: 12px; border: 1px solid var(--line); border-radius: 8px; background: white; cursor: pointer; text-align: left; }
.font-pair:hover { border-color: #aaa3dd; }
.font-pair strong { font-size: 17px; }
.font-pair small { color: var(--muted); font-size: 10px; }

.element-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.element-card { aspect-ratio: 1; display: grid; place-items: center; background: #fff; border: 1px solid var(--line); border-radius: 8px; transition: background 130ms ease, border-color 130ms ease, transform 130ms ease; }
.element-card:hover { background: var(--accent-soft); border-color: #b8b2e5; transform: translateY(-1px); }
.shape-preview { width: 34px; height: 34px; display: block; background: var(--ink); }
.shape-preview.circle { border-radius: 50%; }
.shape-preview.rounded { border-radius: 9px; }
.shape-preview.triangle { clip-path: polygon(50% 4%, 98% 96%, 2% 96%); }
.shape-preview.star { clip-path: polygon(50% 0%,61% 35%,98% 35%,68% 57%,79% 94%,50% 72%,21% 94%,32% 57%,2% 35%,39% 35%); }
.shape-preview.line { width: 43px; height: 5px; border-radius: 9px; transform: rotate(-20deg); }
.shape-preview.blob { border-radius: 62% 38% 45% 55% / 52% 61% 39% 48%; transform: rotate(18deg); }

.upload-zone {
  display: grid;
  place-items: center;
  gap: 8px;
  width: 100%;
  min-height: 150px;
  padding: 20px;
  border: 1.5px dashed #c9c9d1;
  border-radius: 10px;
  background: #fff;
  color: var(--muted);
  cursor: pointer;
  text-align: center;
  transition: border-color 130ms ease, background 130ms ease;
}
.upload-zone:hover, .upload-zone.dragging { border-color: var(--accent); background: var(--accent-soft); }
.upload-zone svg { width: 30px; height: 30px; color: var(--accent); }
.upload-zone strong { color: var(--ink); font-size: 12px; }
.upload-zone span { max-width: 180px; font-size: 10px; line-height: 1.45; }
.upload-tip { display: flex; gap: 9px; margin-top: 14px; padding: 11px; background: #f3f3f5; border-radius: 8px; color: var(--muted); font-size: 10px; line-height: 1.45; }
.upload-tip svg { flex: 0 0 auto; width: 17px; height: 17px; }

.background-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.background-card { aspect-ratio: 1; border: 1px solid rgba(40,40,50,.13); border-radius: 7px; background: var(--background); box-shadow: inset 0 0 0 1px rgba(255,255,255,.25); transition: transform 130ms ease; }
.background-card:hover { transform: scale(1.04); }
.custom-background { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 14px; padding: 11px 12px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.custom-background span { font-size: 11px; font-weight: 650; }
.custom-background input { width: 40px; height: 32px; padding: 3px; border: 0; background: transparent; cursor: pointer; }

.layers-list { display: grid; gap: 4px; }
.layer-row { display: grid; grid-template-columns: 32px minmax(0, 1fr) auto; align-items: center; gap: 8px; min-height: 46px; padding: 6px; border: 1px solid transparent; border-radius: 7px; cursor: pointer; }
.layer-row:hover { background: #f1f1f3; }
.layer-row.active { border-color: #c5c1e5; background: var(--accent-soft); }
.layer-thumb { width: 32px; height: 32px; display: grid; place-items: center; overflow: hidden; border: 1px solid var(--line); border-radius: 7px; background: white; color: var(--muted); font-size: 13px; font-weight: 800; }
.layer-thumb img { width: 100%; height: 100%; object-fit: cover; }
.layer-name { overflow: hidden; font-size: 10.5px; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.layer-actions { display: flex; }
.layer-action { width: 26px; height: 26px; display: grid; place-items: center; padding: 0; border-radius: 6px; background: transparent; color: var(--muted); }
.layer-action:hover { background: white; color: var(--ink); }
.layer-action svg { width: 14px; height: 14px; }
.layer-order { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; margin-top: 13px; }
.panel-action { height: 34px; background: #ededf0; border-radius: 7px; font-size: 10px; font-weight: 650; }
.panel-action:hover { background: var(--accent-soft); color: var(--accent-dark); }

.workspace {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: auto;
  background-color: var(--workspace);
  background-image: radial-gradient(rgba(95, 96, 104, .13) .65px, transparent .65px);
  background-size: 16px 16px;
}
.stage {
  min-width: 100%;
  min-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 58px 68px 240px;
}
.artboard-frame { position: relative; flex: 0 0 auto; filter: drop-shadow(0 14px 28px rgba(28,28,36,.13)); }
.artboard {
  position: absolute;
  top: 0;
  left: 0;
  overflow: hidden;
  background: #fff;
  transform-origin: top left;
  outline: 0;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}
.design-item { position: absolute; transform-origin: center; cursor: move; }
.design-item.hidden-item { opacity: .18 !important; }
.design-item .text-content { width: 100%; height: 100%; display: block; overflow: hidden; white-space: pre-wrap; outline: 0; cursor: move; }
.design-item .text-content[contenteditable="true"] { cursor: text; user-select: text; -webkit-user-select: text; box-shadow: inset 0 0 0 1px rgba(87,73,220,.38); }
.design-item .shape-content { width: 100%; height: 100%; display: block; }
.design-item .shape-content.circle { border-radius: 50%; }
.design-item .shape-content.rounded { border-radius: 18%; }
.design-item .shape-content.triangle { clip-path: polygon(50% 2%, 99% 98%, 1% 98%); }
.design-item .shape-content.star { clip-path: polygon(50% 0%,61% 35%,98% 35%,68% 57%,79% 94%,50% 72%,21% 94%,32% 57%,2% 35%,39% 35%); }
.design-item .shape-content.blob { border-radius: 62% 38% 45% 55% / 52% 61% 39% 48%; }
.design-item img { display: block; width: 100%; height: 100%; object-fit: cover; pointer-events: none; }

.empty-canvas-hint { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 7px; color: rgba(45,45,52,.36); pointer-events: none; text-align: center; }
.empty-canvas-hint span { width: 48px; height: 48px; display: grid; place-items: center; margin-bottom: 5px; border: 1.5px solid currentColor; border-radius: 50%; font-size: 24px; font-weight: 300; }
.empty-canvas-hint strong { font-size: 15px; font-weight: 650; }
.empty-canvas-hint small { font-size: 10px; }
.empty-canvas-hint.hidden { display: none; }

.selection-overlay {
  position: absolute;
  z-index: 9999;
  border: 2px solid var(--accent);
  pointer-events: none;
  transform-origin: center;
}
.resize-handle {
  position: absolute;
  width: 14px;
  height: 14px;
  padding: 0;
  border: 2px solid var(--accent);
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 4px rgba(30,30,40,.2);
  pointer-events: auto;
  touch-action: none;
}
.resize-handle.nw { top: -8px; left: -8px; cursor: nwse-resize; }
.resize-handle.ne { top: -8px; right: -8px; cursor: nesw-resize; }
.resize-handle.sw { bottom: -8px; left: -8px; cursor: nesw-resize; }
.resize-handle.se { bottom: -8px; right: -8px; cursor: nwse-resize; }
.rotation-stem { position: absolute; left: 50%; top: -32px; width: 2px; height: 30px; transform: translateX(-50%); background: var(--accent); }
.rotate-handle { position: absolute; left: 50%; top: -51px; width: 26px; height: 26px; display: grid; place-items: center; padding: 0; transform: translateX(-50%); border: 2px solid var(--accent); border-radius: 50%; background: #fff; color: var(--accent); pointer-events: auto; cursor: grab; touch-action: none; }
.rotate-handle svg { width: 14px; height: 14px; stroke-width: 2; }

.zoom-bar {
  position: fixed;
  z-index: 16;
  right: 18px;
  bottom: 18px;
  height: 38px;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 6px;
  background: rgba(255,255,255,.95);
  border: 1px solid rgba(216,216,222,.9);
  border-radius: 9px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}
.zoom-bar button { height: 30px; min-width: 29px; display: grid; place-items: center; padding: 0; background: transparent; border-radius: 7px; color: var(--muted); }
.zoom-bar button:hover { background: #f0f0f3; color: var(--ink); }
.zoom-bar input { width: 88px; accent-color: var(--accent); cursor: pointer; }
.zoom-bar .zoom-value { min-width: 46px; font-size: 9px; font-weight: 700; }
.page-status { position: fixed; z-index: 16; left: 386px; bottom: 18px; height: 38px; display: flex; align-items: center; gap: 7px; padding: 0 11px; border: 1px solid rgba(216,216,222,.9); border-radius: 9px; background: rgba(255,255,255,.95); color: var(--muted); box-shadow: var(--shadow); font-size: 9.5px; font-weight: 650; backdrop-filter: blur(12px); }
.page-status svg { width: 16px; height: 16px; }

.toast {
  position: fixed;
  z-index: 100;
  left: 50%;
  bottom: 24px;
  transform: translate(-50%, 12px);
  padding: 10px 15px;
  background: rgba(37,37,42,.94);
  color: #fff;
  border-radius: 8px;
  box-shadow: var(--shadow);
  font-size: 11px;
  font-weight: 650;
  opacity: 0;
  pointer-events: none;
  transition: opacity 170ms ease, transform 170ms ease;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 860px) {
  .app { grid-template-rows: 56px 50px minmax(0, 1fr); }
  .topbar { grid-template-columns: auto minmax(100px, 1fr) auto; padding: 0 10px; }
  .top-left { gap: 0; }
  .top-nav, .file-menu { display: none !important; }
  .brand { gap: 0; }
  .brand strong { display: none; }
  .brand-mark { transform: scale(.86); }
  .document-name { justify-items: start; padding-left: 7px; min-width: 0; }
  .document-name input { width: min(40vw, 190px); padding-left: 3px; text-align: left; }
  .document-name span { padding-left: 3px; }
  .top-divider { display: none; }
  .top-actions { gap: 0; }
  .primary-button { width: 37px; height: 37px; justify-content: center; padding: 0; }
  .primary-button span { display: none; }

  .propertybar { padding: 0 10px; }
  .size-select { display: flex; }
  .background-control { display: none; }
  .property-message { display: none; }
  .editor-layout { display: block; position: relative; min-height: 0; }
  .workspace { position: absolute; inset: 0 0 64px; }
  .stage { align-items: flex-start; padding: 44px 38px 220px; }

  .tool-rail {
    position: fixed;
    z-index: 40;
    left: 0;
    right: 0;
    bottom: 0;
    height: calc(64px + env(safe-area-inset-bottom));
    display: flex;
    flex-direction: row;
    gap: 0;
    padding: 4px 4px env(safe-area-inset-bottom);
    background: #fff;
    border-top: 1px solid var(--line);
    border-right: 0;
    overflow-x: auto;
    scrollbar-width: none;
  }
  .tool-rail::-webkit-scrollbar { display: none; }
  .rail-button { flex: 1 0 60px; height: 55px; }
  .rail-button { color: #62636b; }
  .rail-button svg { width: 20px; height: 20px; }
  .rail-button span { font-size: 8.5px; }
  .rail-button:hover { background: #f2f2f4; color: var(--ink); }
  .rail-button.active { background: var(--accent-soft); color: var(--accent-dark); }
  .rail-button.active::before { left: 50%; top: -4px; width: 24px; height: 3px; transform: translateX(-50%); border-radius: 0 0 3px 3px; }

  .library-panel {
    position: fixed;
    z-index: 35;
    left: 0;
    right: 0;
    bottom: calc(64px + env(safe-area-inset-bottom));
    height: min(340px, 46vh);
    display: grid;
    border-top: 1px solid var(--line);
    border-right: 0;
    border-radius: 14px 14px 0 0;
    box-shadow: 0 -14px 36px rgba(35,35,50,.13);
    transform: translateY(0);
  }
  .library-panel.closed { transform: translateY(calc(100% + 18px)); }
  .panel-heading { padding: 16px 17px 9px; }
  .panel-heading h2 { font-size: 16px; }
  .close-panel { display: grid; }
  .panel-content { padding: 2px 14px 18px; }
  .template-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .template-thumb { max-height: 115px; }
  .text-presets-mobile { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; }
  .text-preset { height: 58px; min-height: 0; margin: 0; overflow: hidden; }
  .text-preset.heading { font-size: 15px; }
  .text-preset.subheading { font-size: 13px; }
  .text-preset.body { font-size: 10px; }
  .element-grid { grid-template-columns: repeat(6, 1fr); }
  .background-grid { grid-template-columns: repeat(6, 1fr); }
  .zoom-bar { right: 10px; bottom: calc(76px + env(safe-area-inset-bottom)); }
  .page-status { display: none; }
  .zoom-bar input { display: none; }
  .toast { bottom: calc(78px + env(safe-area-inset-bottom)); }
}

@media (max-width: 440px) {
  .document-name input { width: 34vw; }
  .document-name span { display: none; }
  .icon-button { width: 32px; }
  .property-controls { gap: 5px; }
  .select-control > span, .number-control > span, .color-control > span { display: none; }
  .select-control select { min-width: 105px; }
  .range-control input { width: 62px; }
  .range-control output { display: none; }
  .property-divider { margin: 0; }
  .template-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .element-grid, .background-grid { grid-template-columns: repeat(4, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: .01ms !important; }
}
