:root {
  color-scheme: light;
  --bg: #f7f7f8;
  --surface: rgba(255,255,255,.82);
  --surface-strong: #fff;
  --text: #171717;
  --muted: #666;
  --subtle: #8a8a8a;
  --line: rgba(0,0,0,.09);
  --accent: #171717;
  --focus: #171717;
  --danger: #d92d20;
  --shadow: 0 18px 48px rgba(0,0,0,.08), 0 0 0 1px var(--line);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #09090b;
  --surface: rgba(20,21,26,.82);
  --surface-strong: #15161b;
  --text: #f4f4f5;
  --muted: #b0b0b8;
  --subtle: #7d7f88;
  --line: rgba(255,255,255,.1);
  --shadow: 0 20px 54px rgba(0,0,0,.36), 0 0 0 1px var(--line);
}

* { box-sizing: border-box; }
html, body { height: 100%; overflow: hidden; }
body {
  margin: 0;
  background: radial-gradient(circle at 20% 0%, color-mix(in srgb, var(--accent) 12%, transparent), transparent 28rem), var(--bg);
  color: var(--text);
  font-family: Geist, Arial, "Microsoft YaHei", sans-serif;
}

* { scrollbar-width: thin; scrollbar-color: color-mix(in srgb, var(--accent) 72%, var(--muted)) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: color-mix(in srgb, var(--accent) 70%, transparent); border: 3px solid transparent; border-radius: 999px; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: var(--accent); border: 2px solid transparent; background-clip: padding-box; }
:root[data-theme="dark"],
:root[data-theme="dark"] * { scrollbar-color: transparent transparent; }
:root[data-theme="dark"] ::-webkit-scrollbar-thumb { background: transparent; border-color: transparent; }
:root[data-theme="dark"] ::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,.18); border-color: transparent; }

button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.mono, .money, .number-font, [data-setting="discount"], [data-setting="taxRate"], [data-item="quantity"], [data-item="unitPrice"], [data-subtotal], [data-total], .preview-count, .preview-wheel-hint, .range-section output {
  font-family: Bahnschrift, "Bahnschrift SemiCondensed", "Arial Narrow", Arial, sans-serif;
  font-variant-numeric: tabular-nums;
}
.money { text-align: right; }

.app-shell { height: 100vh; overflow: hidden; }
.designer-shell {
  height: 100vh;
  width: 100vw;
  max-width: none;
  margin: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 8px minmax(280px, 24vw);
  gap: 0;
  padding: 0;
}
.topbar {
  z-index: 10;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 14px clamp(16px, 4vw, 40px);
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(18px);
}
.brand { display: inline-flex; align-items: center; gap: 12px; color: inherit; text-decoration: none; }
.brand-mark { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 10px; background: var(--accent); color: #fff; font-weight: 700; }
.brand strong, .brand small { display: block; }
.brand small { color: var(--subtle); font-size: 12px; margin-top: 2px; }
.top-actions, .preview-tools, .header-preview-tools, .accent-picker { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.btn, .icon-btn {
  border: 0;
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 9px;
  padding: 9px 13px;
  color: var(--muted);
  background: transparent;
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--line) 72%, transparent);
  transition: transform .16s ease, background .16s ease, color .16s ease, box-shadow .16s ease;
}
.btn:hover,
.icon-btn:hover,
.btn:focus-visible,
.icon-btn:focus-visible {
  transform: translateY(-1px);
  color: var(--text);
  background: color-mix(in srgb, var(--surface-strong) 42%, transparent);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 22%, var(--line)), 0 10px 24px rgba(0,0,0,.1);
}
.btn:active,
.icon-btn:active {
  transform: translateY(0);
  background: color-mix(in srgb, var(--surface-strong) 54%, transparent);
}
.btn.primary { background: transparent; color: var(--muted); box-shadow: 0 0 0 1px color-mix(in srgb, var(--line) 72%, transparent); }
.btn.primary:hover,
.btn.primary:focus-visible {
  color: var(--text);
  background: color-mix(in srgb, var(--surface-strong) 42%, transparent);
}
.btn.ghost, .icon-btn { background: transparent; }
.icon-btn { min-width: 38px; width: 38px; padding: 0; }
.danger { color: var(--danger); }
.btn svg, .icon-btn svg { width: 16px; height: 16px; stroke-width: 1.8; }
.accent-picker { padding: 4px; border-radius: 12px; background: color-mix(in srgb, var(--surface-strong) 72%, transparent); box-shadow: inset 0 0 0 1px var(--line); }
.accent-dot { width: 22px; height: 22px; border: 0; border-radius: 50%; background: var(--dot); box-shadow: 0 0 0 1px var(--line); }
.accent-dot.active { box-shadow: 0 0 0 2px var(--surface-strong), 0 0 0 4px var(--accent); }
.accent-input { width: 28px; height: 24px; padding: 0; border: 0; background: transparent; box-shadow: none; }
.header-preview-tools { margin-left: auto; }
.menu-wrap { position: relative; }
.more-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 30;
  width: 220px;
  display: none;
  padding: 8px;
  border-radius: 14px;
  background: var(--surface-strong);
  box-shadow: var(--shadow);
}
.more-menu.open { display: grid; gap: 4px; }
.more-menu button {
  width: 100%;
  border: 0;
  min-height: 36px;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 9px;
  border-radius: 9px;
  background: transparent;
  text-align: left;
}
.more-menu button:hover { background: color-mix(in srgb, var(--accent) 10%, transparent); }
.more-menu button svg { width: 16px; height: 16px; }
.menu-section {
  display: grid;
  gap: 8px;
  margin-top: 6px;
  padding: 10px 8px 4px;
  border-top: 1px solid var(--line);
  color: var(--subtle);
  font-size: 12px;
}

.canvas-pane {
  position: relative;
  min-width: 0;
  min-height: 0;
  height: 100%;
  overflow: hidden;
  padding: 12px 0 0;
  background: #eceef2;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.06);
  display: grid;
  grid-template-rows: minmax(0, 1fr) 40px;
  gap: 10px;
}
:root[data-theme="dark"] .canvas-pane {
  background: #0b0c10;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.06);
}
.right-rail {
  --surface: rgba(255,255,255,.72);
  --surface-strong: #f4f4f5;
  --muted: #50535a;
  --subtle: #858993;
  --line: rgba(0,0,0,.11);
  --shadow: 0 18px 44px rgba(0,0,0,.08), 0 0 0 1px var(--line);
  min-width: 0;
  width: 100%;
  max-width: none;
  justify-self: stretch;
  height: 100%;
  overflow: hidden;
  display: grid;
  grid-template-rows: clamp(250px, 34vh, 310px) minmax(0, 1fr) minmax(68px, auto);
  align-content: stretch;
  gap: 12px;
  padding-left: 14px;
  background: #f7f7f8;
  color: #171717;
}
:root[data-theme="dark"] .right-rail {
  --surface: rgba(27,29,36,.72);
  --surface-strong: #17191f;
  --muted: #c5c7cf;
  --subtle: #8d929f;
  --line: rgba(255,255,255,.11);
  --shadow: 0 18px 44px rgba(0,0,0,.26), 0 0 0 1px var(--line);
  background: #101116;
  color: #f4f4f5;
}
.rail-brand-row {
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 8px;
  padding-top: 0;
  text-align: center;
}
.rail-brand-row .brand {
  display: grid;
  justify-items: center;
  gap: 10px;
}
.rail-brand-row .brand-mark {
  width: 88px;
  height: 88px;
  border-radius: 22px;
  font-size: 26px;
}
.mobile-toolbar-controls {
  display: none;
}
.rail-main {
  min-height: 0;
  display: grid;
  align-content: start;
  gap: clamp(10px, 1.8vh, 14px);
  overflow: hidden;
}
.rail-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  align-self: stretch;
  min-height: 68px;
  padding: 12px 0;
}
.rail-footer .icon-btn {
  width: auto;
  min-width: 42px;
  height: 38px;
  padding: 0 10px;
}
.rail-footer .icon-btn span {
  font-size: 12px;
  font-weight: 700;
}
.rail-section {
  display: grid;
  gap: 10px;
  padding: 14px;
  border-radius: 18px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.preview-tabs-section {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  padding: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}
.preview-tabs-section .segmented {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.preview-tabs-section .segment {
  min-width: 0;
  min-height: 30px;
  padding: 5px 10px;
}
.rail-actions {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  background: transparent;
  box-shadow: none;
  padding: 0;
}
.rail-actions #clearBtn {
  grid-column: 2;
}
.mobile-menu-controls {
  display: none;
}
.mobile-menu-controls[hidden] {
  display: none !important;
}
.rail-actions .btn {
  width: 100%;
  min-width: 0;
  min-height: 88px;
  flex-direction: column;
  gap: 9px;
  justify-content: center;
  padding: 12px 8px;
  font-size: 13px;
  line-height: 1.2;
  text-align: center;
  border-radius: 14px;
}
.rail-actions .btn svg {
  width: 26px;
  height: 26px;
}
.range-section {
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  background: transparent;
  box-shadow: none;
  padding: 0;
}
.range-section label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 96px;
  color: var(--muted);
  font-size: 12px;
}
.range-section output {
  color: var(--text);
  font-family: "Geist Mono", ui-monospace, monospace;
}
.range-section input[type="range"] {
  width: 100%;
  min-width: 0;
  accent-color: var(--accent);
}
.rail-hint {
  display: block;
  max-width: 230px;
  margin: 0 auto;
  color: rgba(244,244,245,.42);
  font-size: 11px;
  line-height: 1.45;
  text-align: center;
  white-space: normal;
}
.splitter {
  height: 100%;
  display: grid;
  place-items: center;
  background: transparent;
  cursor: col-resize;
  touch-action: none;
}
.splitter span {
  width: 1px;
  height: 76px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--line) 64%, transparent);
  opacity: .38;
  transition: width .16s ease, height .16s ease, background .16s ease, opacity .16s ease;
}
.splitter:hover span,
.splitter.dragging span,
.splitter:focus-visible span {
  width: 3px;
  height: 108px;
  background: var(--accent);
  opacity: .82;
}
.preview-workspace { min-height: 0; height: 100%; width: min(1320px, calc(100% - 28px)); margin: 0 auto; padding: 16px 0; display: grid; grid-template-rows: auto minmax(0, 1fr); gap: 12px; }
.preview-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 14px 16px;
  border-radius: 18px;
  background: var(--surface);
  box-shadow: var(--shadow);
  backdrop-filter: blur(20px);
}
.eyebrow { margin: 0; color: var(--subtle); font-size: 12px; }
.preview-bar h1 { margin: 4px 0 0; font-size: 18px; }
.segmented {
  position: relative;
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  border-radius: 11px;
  background: rgba(255,255,255,.28);
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.04);
}
:root[data-theme="dark"] .segmented {
  background: rgba(255,255,255,.06);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.04);
}
.segmented::before {
  content: "";
  position: absolute;
  top: 4px;
  bottom: 4px;
  left: 4px;
  width: calc((100% - 12px) / 2);
  border-radius: 8px;
  background: #171717;
  box-shadow: 0 6px 16px rgba(0,0,0,.16), inset 0 0 0 1px rgba(0,0,0,.08);
  transform: translateX(0);
  transition: transform .22s ease, background .18s ease, box-shadow .18s ease;
  pointer-events: none;
}
.segmented:has(.segment:nth-child(2).active)::before {
  transform: translateX(calc(100% + 4px));
}
.segment {
  position: relative;
  z-index: 1;
  border: 0;
  min-width: 52px;
  min-height: 32px;
  padding: 6px 10px;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  box-shadow: inset 0 0 0 1px transparent;
  transition: color .18s ease;
}
.segment + .segment {
  box-shadow: inset 1px 0 0 color-mix(in srgb, var(--line) 84%, transparent);
}
.segment.active {
  background: transparent;
  color: #fff;
  box-shadow: inset 0 0 0 1px transparent;
}
:root[data-theme="dark"] .segmented::before {
  background: #fff;
  box-shadow: 0 6px 16px rgba(0,0,0,.22), inset 0 0 0 1px rgba(0,0,0,.08);
}
:root[data-theme="dark"] .segment.active {
  color: #111;
}
.segment.active + .segment,
.segment:has(+ .segment.active) {
  box-shadow: inset 0 0 0 1px transparent;
}
.live-preview { --canvas-start-offset: 0px; --canvas-pan-y-buffer: 0px; height: 100%; min-height: 0; overflow: auto; margin: 0 14px 0 12px; padding: 0; border-radius: 0; background: transparent; box-shadow: none; cursor: grab; }
.live-preview {
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.live-preview::-webkit-scrollbar {
  width: 0;
  height: 0;
}
.live-preview:has(.print-page:hover) { cursor: auto; }
.live-preview.canvas-panning { cursor: grabbing; user-select: none; }
.canvas-add-btn {
  position: absolute;
  right: 24px;
  bottom: 58px;
  z-index: 30;
  width: 48px;
  height: 48px;
  display: inline-grid;
  place-items: center;
  border: 0;
  border-radius: 999px;
  background: #171717;
  color: #fff;
  box-shadow: 0 14px 28px rgba(0,0,0,.18), 0 0 0 1px rgba(0,0,0,.08);
  transition: transform .16s ease, background .16s ease, box-shadow .16s ease;
}
.canvas-add-btn svg {
  width: 22px;
  height: 22px;
  stroke-width: 2.4;
}
.canvas-add-btn:hover,
.canvas-add-btn:focus-visible {
  transform: translateY(-2px) scale(1.1);
  background: #000;
  box-shadow: 0 18px 34px rgba(0,0,0,.22), 0 0 0 1px rgba(0,0,0,.1);
}
.canvas-add-btn:active {
  transform: translateY(0) scale(1.03);
}
.canvas-add-tooltip {
  position: absolute;
  right: 0;
  bottom: calc(100% + 10px);
  width: max-content;
  max-width: min(280px, calc(100vw - 32px));
  padding: 9px 11px;
  border-radius: 10px;
  background: rgba(23,23,23,.9);
  color: #fff;
  font-size: 12px;
  line-height: 1.45;
  text-align: center;
  box-shadow: 0 12px 26px rgba(0,0,0,.2);
  opacity: 0;
  pointer-events: none;
  transform: translateY(6px);
  transition: opacity .16s ease .55s, transform .16s ease .55s;
}
.canvas-add-btn:hover .canvas-add-tooltip,
.canvas-add-btn:focus-visible .canvas-add-tooltip {
  opacity: 1;
  transform: translateY(0);
}
.canvas-add-btn:not(:hover):not(:focus-visible) .canvas-add-tooltip {
  transition-delay: 0s;
}
:root[data-theme="dark"] .canvas-add-btn {
  background: #f4f4f5;
  color: #111;
  box-shadow: 0 14px 28px rgba(0,0,0,.32), 0 0 0 1px rgba(255,255,255,.1);
}
:root[data-theme="dark"] .canvas-add-btn:hover,
:root[data-theme="dark"] .canvas-add-btn:focus-visible {
  background: #fff;
}
:root[data-theme="dark"] .canvas-add-tooltip {
  background: rgba(244,244,245,.92);
  color: #111;
}
.canvas-statusbar {
  min-height: 40px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 10px;
  border-radius: 0;
  background: rgba(247,247,248,.92);
  color: #171717;
  box-shadow: inset 0 1px 0 rgba(0,0,0,.1);
}
:root[data-theme="dark"] .canvas-statusbar {
  background: rgba(18,20,26,.92);
  color: #f4f4f5;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.1);
}
.canvas-status-info,
.canvas-row-height-control,
.canvas-zoom-control,
.canvas-status-actions {
  display: flex;
  align-items: center;
  min-width: 0;
}
.canvas-status-info {
  gap: 8px;
  color: rgba(23,23,23,.68);
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
}
.canvas-status-info span {
  overflow: hidden;
  text-overflow: ellipsis;
}
.canvas-status-info svg {
  width: 15px;
  height: 15px;
  flex: 0 0 auto;
}
.canvas-zoom-control {
  flex: 0 0 auto;
  gap: 8px;
}
.canvas-status-actions {
  display: none;
}
.status-icon-btn {
  width: 30px;
  height: 30px;
  flex: 0 0 auto;
}
.status-icon-btn svg {
  width: 16px;
  height: 16px;
}
.canvas-row-height-control {
  flex: 1 1 260px;
  max-width: 240px;
  gap: 10px;
  color: rgba(23,23,23,.68);
  font-size: 12px;
}
.canvas-row-height-control label {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}
.canvas-row-height-control label svg {
  width: 15px;
  height: 15px;
  flex: 0 0 auto;
}
.canvas-row-height-control output {
  width: 34px;
  color: rgba(23,23,23,.68);
  font-family: "Geist Mono", monospace;
  font-size: 11px;
  text-align: right;
}
.canvas-row-height-control input[type="range"] {
  flex: 1 1 auto;
  min-width: 90px;
  max-width: 140px;
  accent-color: #171717;
}
.canvas-tool-btn {
  width: 30px;
  height: 30px;
  display: inline-grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 7px;
  background: rgba(255,255,255,.07);
  color: #171717;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.08);
}
.canvas-tool-btn:hover,
.canvas-tool-btn:focus-visible {
  background: rgba(255,255,255,.13);
}
.canvas-tool-btn svg {
  width: 16px;
  height: 16px;
}
.canvas-zoom-control input[type="range"] {
  width: min(120px, 18vw);
  max-width: 120px;
  accent-color: #171717;
}
.canvas-zoom-control output {
  width: 42px;
  color: rgba(23,23,23,.68);
  font-family: "Geist Mono", monospace;
  font-size: 11px;
  text-align: right;
}
:root[data-theme="dark"] .canvas-status-info,
:root[data-theme="dark"] .canvas-row-height-control,
:root[data-theme="dark"] .canvas-row-height-control output,
:root[data-theme="dark"] .canvas-zoom-control output {
  color: rgba(244,244,245,.72);
}
:root[data-theme="dark"] .canvas-row-height-control input[type="range"],
:root[data-theme="dark"] .canvas-zoom-control input[type="range"] {
  accent-color: #f4f4f5;
}
:root[data-theme="dark"] .canvas-tool-btn {
  color: #f4f4f5;
}
.live-preview.preview-a4 { background: transparent; }
.live-preview.preview-web .print-page { zoom: var(--canvas-zoom, 1); }
.live-preview.preview-a4 .quote-document { display: grid; gap: 18px; justify-items: center; width: max-content; min-width: 100%; padding-top: calc(var(--canvas-start-offset) + var(--canvas-pan-y-buffer)); padding-bottom: calc(var(--canvas-start-offset) + var(--canvas-pan-y-buffer)); box-sizing: border-box; }
.live-preview.preview-a4.page-gap-collapsed .quote-document { gap: 0; }
.live-preview.preview-a4 .print-page {
  width: 794px;
  min-width: 794px;
  max-width: none;
  height: 1123px;
  margin: 0 auto var(--canvas-page-gap-correction, 0px);
  border-radius: 0;
  overflow: visible;
  box-shadow: 0 18px 46px rgba(0,0,0,.12), 0 0 0 1px rgba(0,0,0,.08);
  transform: scale(var(--canvas-zoom, 1));
  transform-origin: top center;
  will-change: transform;
}
.live-preview.preview-web .print-page { width: min(1120px, 100%); min-height: calc(100vh - 52px); margin: var(--canvas-start-offset) auto var(--canvas-start-offset); }
.live-preview.preview-web .page-number { display: none; }

.print-page { position: relative; margin: 0; padding: 42px; border-radius: 0; background: #fff; color: #171717; font-family: Arial, "Microsoft YaHei", sans-serif; }
.quote-document { display: block; }
.page-gap-toggle {
  width: 38px;
  height: 22px;
  display: inline-grid;
  place-items: center;
  margin: -8px 0;
  border: 0;
  border-radius: 999px;
  background: color-mix(in srgb, var(--surface-strong) 88%, transparent);
  color: var(--muted);
  box-shadow: 0 0 0 1px var(--line), 0 8px 18px rgba(0,0,0,.12);
  cursor: pointer;
  z-index: 5;
}
.page-gap-toggle:hover,
.page-gap-toggle:focus-visible {
  color: var(--accent);
  background: var(--surface-strong);
}
.page-gap-toggle svg {
  width: 16px;
  height: 16px;
  stroke-width: 2.2;
}
.live-preview.page-gap-collapsed .page-gap-toggle {
  height: 0;
  margin: 0;
  transform: translateY(-50%);
}
.page-number {
  position: absolute;
  left: 42px;
  right: 42px;
  bottom: 18px;
  text-align: center;
  color: #777;
  font-size: 11px;
  line-height: 1;
  pointer-events: none;
}
.page-continuation { padding-bottom: 10px; border-bottom: 1px solid rgba(0,0,0,.1); color: #666; font-size: 12px; font-weight: 700; }
.print-header { display: flex; justify-content: space-between; gap: 32px; padding-bottom: 18px; border-bottom: 1px solid rgba(0,0,0,.1); }
.quote-title-input { margin: 0 0 12px; font-size: 34px; line-height: 1.1; font-weight: 700; color: #171717; }
.quote-meta { display: grid; gap: 8px; margin-top: 14px; color: #555; font-size: 13px; }
.right-meta {
  width: max-content;
  max-width: 100%;
  margin-left: auto;
  justify-items: start;
}
.right-meta label {
  display: grid;
  grid-template-columns: 56px max-content;
  align-items: baseline;
  column-gap: 10px;
  width: max-content;
}
.meta-label-title {
  display: inline-block;
  width: 100%;
  text-align: justify;
  text-align-last: justify;
}
.right-meta .editable-text {
  text-align: left;
}
.editable-text {
  display: inline-block;
  min-width: 1.2em;
  border-radius: 3px;
  color: inherit;
  white-space: pre-wrap;
  cursor: text;
}
.editable-page [contenteditable="true"] { cursor: text; }
.editable-text:hover,
.editable-text:focus {
  background: color-mix(in srgb, var(--accent) 9%, transparent);
  outline: none;
}
.editable-page [data-item="quantity"].wheel-delay-pending,
.editable-page [data-item="unitPrice"].wheel-delay-pending,
.editable-page [data-subtotal].wheel-delay-pending,
.editable-page [data-setting="discount"].wheel-delay-pending,
.editable-page [data-setting="taxRate"].wheel-delay-pending {
  box-shadow: inset 0 -2px 0 color-mix(in srgb, var(--accent) 32%, transparent);
}
.editable-page [data-item="quantity"].wheel-ready,
.editable-page [data-item="unitPrice"].wheel-ready,
.editable-page [data-subtotal].wheel-ready,
.editable-page [data-setting="discount"].wheel-ready,
.editable-page [data-setting="taxRate"].wheel-ready {
  background: color-mix(in srgb, var(--accent) 13%, transparent);
  box-shadow: inset 0 -2px 0 var(--accent);
}
.editable-text.strong { font-weight: 700; }
.item-title-text {
  font-size: 15px;
  line-height: 1.28;
  font-weight: 700;
}
.item-date-line {
  margin-top: 4px;
  color: #666;
  font-size: 11px;
  line-height: 1.35;
}
.item-extra-line {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-top: 2px;
}
.item-extra-line > span:first-child {
  flex: 0 1 auto;
}
.item-remark {
  flex: 1 1 auto;
  min-width: 42px;
  color: #555;
}
.item-remark:empty::before {
  content: "备注";
  color: #aaa;
}
.editable-text.tiny { min-width: 54px; text-align: right; }
.editable-text[data-item="category"] { text-align: center; }
.quote-note { min-height: 92px; line-height: 1.6; color: #555; }
.print-table { width: 100%; margin-top: 0; border-collapse: separate; border-spacing: 0; table-layout: fixed; }
.print-table th, .print-table td { padding: 8px 8px; border-bottom: 0; text-align: left; vertical-align: middle; font-size: 12px; }
.print-table th { position: relative; height: 40px; background: #f7f7f7; color: #666; border-bottom: 1px solid rgba(0,0,0,.16); }
.print-table th:nth-child(3),
.print-table td:nth-child(3),
.print-table th:nth-child(4),
.print-table td:nth-child(4),
.print-table th:nth-child(5),
.print-table td:nth-child(5) {
  text-align: center;
}
.print-table th:nth-child(6),
.print-table td:nth-child(6),
.print-table th:nth-child(7),
.print-table td:nth-child(7) {
  text-align: right;
}
.print-table tbody tr td { border-bottom: 1px solid rgba(0,0,0,.1); }
.print-table tbody tr:has(+ .quote-group-row) td { border-bottom-color: transparent; }
.column-resizer {
  position: absolute;
  top: 0;
  right: -4px;
  z-index: 5;
  width: 8px;
  height: 100%;
  cursor: col-resize;
  touch-action: none;
}
.column-resizer::after {
  content: "";
  position: absolute;
  top: 9px;
  bottom: 9px;
  left: 3px;
  width: 1px;
  background: transparent;
}
.column-resizer:hover::after,
.column-resizer:focus-visible::after {
  background: var(--accent);
}
.quote-item-row:not(.quote-group-row) { height: var(--item-row-height, 72px); }
.quote-item-row:not(.quote-group-row) td { height: var(--item-row-height, 72px); padding-top: 6px; padding-bottom: 6px; }
.quote-group-row td {
  height: auto;
  padding-top: 14px;
  padding-bottom: 2px;
  background: transparent;
  border-bottom: 0 !important;
}
.project-group-cell {
  position: relative;
}
.project-group-rule {
  min-height: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding-right: 0;
}
.group-toggle {
  position: absolute;
  top: 50%;
  left: -22px;
  width: 18px;
  height: 18px;
  display: inline-grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: #555;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-50%);
  transition: opacity .14s ease, background .14s ease;
}
.quote-group-row:hover .group-toggle,
.quote-group-row:focus-within .group-toggle {
  opacity: 1;
  pointer-events: auto;
}
.group-toggle:hover,
.group-toggle:focus-visible {
  opacity: 1;
  pointer-events: auto;
  background: rgba(0,0,0,.07);
}
.group-toggle svg {
  width: 14px;
  height: 14px;
  stroke-width: 2.4;
}
.project-group-title {
  flex: 0 1 auto;
  max-width: 64%;
  font-size: 15px;
  line-height: 1.28;
  font-weight: 800;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.project-group-total {
  margin-left: auto;
  min-width: 128px;
  display: inline-flex;
  justify-content: flex-end;
  gap: 4px;
  color: #555;
  font-size: inherit;
  font-weight: 800;
  white-space: nowrap;
  text-align: right;
}
.project-group-total strong {
  color: #171717;
  font-size: inherit;
  font-weight: 800;
}
.project-group-cell .row-delete-btn {
  position: absolute;
  right: -36px;
  top: 50%;
  transform: translateY(-50%) scale(.96);
}
.quote-group-row:hover .row-delete-btn,
.quote-group-row:focus-within .row-delete-btn {
  transform: translateY(-50%) scale(1);
}
.quote-group-row + .quote-subproject-row td {
  padding-top: 2px;
}
.editable-page .quote-item-row { cursor: grab; transition: background .14s ease, opacity .14s ease; }
.editable-page .quote-item-row button,
.editable-page .preview-gallery {
  cursor: default;
}
.editable-page .quote-item-row button { cursor: pointer; }
.editable-page .quote-item-row:hover,
.editable-page .quote-item-row:focus-within { background: color-mix(in srgb, var(--accent) 5%, transparent); }
.editable-page .quote-item-row.dragging-row { cursor: grabbing; opacity: .42; }
.editable-page .quote-item-row.drop-before td { border-top: 2px solid var(--accent); }
.editable-page .quote-item-row.drop-after td { border-bottom: 2px solid var(--accent); }
.row-total-cell { position: relative; padding-right: 8px !important; }
.row-total-cell::after,
.project-group-cell::after {
  content: "";
  position: absolute;
  top: 0;
  right: -46px;
  width: 46px;
  height: 100%;
  z-index: 0;
}
.row-total-cell [data-subtotal] {
  font-size: 13px;
  line-height: 1;
  font-weight: 800;
}
.subtotal-edit { min-width: 48px; text-align: right; }
.editable-page .editable-text.money,
.editable-page [data-subtotal],
.editable-page [data-total] {
  position: relative;
  display: inline-block;
  transform-origin: center;
  transition: transform .12s ease, background .12s ease, box-shadow .12s ease;
}
.editable-page .editable-text.money:hover,
.editable-page [data-subtotal]:hover,
.editable-page [data-total]:hover,
.editable-page .editable-text.money:focus,
.editable-page [data-subtotal]:focus {
  z-index: 8;
  transform: scale(1.18);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(255,255,255,.88), 0 8px 20px rgba(0,0,0,.12);
}
.row-delete-btn {
  position: absolute;
  top: 50%;
  right: -36px;
  z-index: 3;
  width: 28px;
  height: 28px;
  display: inline-grid;
  place-items: center;
  border: 0;
  border-radius: 7px;
  background: color-mix(in srgb, var(--danger) 9%, #fff);
  color: var(--danger);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--danger) 24%, transparent);
  opacity: 0;
  pointer-events: none;
  cursor: pointer;
  transform: translateY(-50%) scale(.96);
  transition: opacity .14s ease, transform .14s ease, background .14s ease;
}
.row-delete-btn::before {
  content: "";
  position: absolute;
  top: -8px;
  bottom: -8px;
  left: -18px;
  right: -8px;
  z-index: -1;
}
.row-delete-btn svg { width: 15px; height: 15px; stroke-width: 2; }
.quote-item-row:hover .row-delete-btn,
.quote-item-row:focus-within .row-delete-btn,
.row-delete-btn:hover,
.row-delete-btn:focus-visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(-50%) scale(1);
}
.row-delete-btn:hover { background: color-mix(in srgb, var(--danger) 15%, #fff); }
.preview-cell {
  position: relative;
  overflow: visible;
}
.item-sequence {
  position: absolute;
  left: -16px;
  top: 50%;
  transform: translateY(-50%);
  width: 12px;
  color: #777;
  font-family: "Geist Mono", ui-monospace, monospace;
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
  text-align: right;
}
.preview-wrap {
  position: relative;
  width: min(calc(var(--item-row-height, 72px) - 12px), 100%);
  height: calc(var(--item-row-height, 72px) - 12px);
  display: grid;
  place-items: center;
  overflow: visible;
}
.preview-gallery {
  position: relative;
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: transparent;
  box-shadow: none;
}
.preview-gallery.replace-target {
  box-shadow: 0 0 0 2px var(--accent), 0 0 0 6px color-mix(in srgb, var(--accent) 14%, transparent);
}
.preview-gallery.replace-target::after {
  content: "替换";
  position: absolute;
  inset: auto 4px 4px;
  display: grid;
  place-items: center;
  min-height: 18px;
  background: rgba(0,0,0,.72);
  color: #fff;
  font-size: 10px;
  pointer-events: none;
}
.empty-preview {
  min-width: 100%;
  min-height: 100%;
  cursor: default;
}
.paste-thumb-hint {
  width: 26px;
  height: 26px;
  display: none;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 7px;
  background: rgba(0,0,0,.72);
  color: #fff;
  cursor: pointer;
  position: relative;
  z-index: 2;
}
.paste-thumb-hint svg {
  width: 15px;
  height: 15px;
}
.clipboard-has-image .empty-preview:hover .paste-thumb-hint,
.empty-preview:focus-within .paste-thumb-hint {
  display: grid;
}
.print-thumb {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 0;
  background: transparent;
  filter: drop-shadow(0 4px 8px rgba(0,0,0,.16));
}
.preview-count,
.preview-wheel-hint {
  position: absolute;
  left: 4px;
  border-radius: 4px;
  background: rgba(0,0,0,.64);
  color: #fff;
  font-family: "Geist Mono", ui-monospace, monospace;
  line-height: 1;
  pointer-events: none;
}
.preview-count { bottom: 4px; padding: 3px 4px; font-size: 10px; }
.preview-wheel-hint {
  top: 4px;
  max-width: calc(100% - 8px);
  padding: 3px 4px;
  opacity: 0;
  font-size: 9px;
  white-space: nowrap;
  transition: opacity .14s ease;
}
.live-preview.preview-web .preview-wrap:hover .preview-wheel-hint { opacity: 1; }
.live-preview.preview-a4 .preview-wheel-hint { display: none; }
.preview-popover {
  position: absolute;
  left: calc(100% + 12px);
  top: 50%;
  z-index: 40;
  width: min(360px, 42vw);
  height: min(280px, 38vh);
  display: none;
  place-items: center;
  padding: 10px;
  background: transparent;
  box-shadow: 0 18px 48px rgba(0,0,0,.22), 0 0 0 1px rgba(0,0,0,.1);
  transform: translateY(-50%);
  pointer-events: none;
}
.preview-popover img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}
.live-preview .preview-wrap:hover .preview-popover { display: grid; }
.print-meta, .print-note { color: #555; font-size: 12px; line-height: 1.6; }
.pixel-meta {
  font-size: 10px;
  color: #777;
  font-family: Bahnschrift, "Bahnschrift SemiCondensed", "Arial Narrow", Arial, sans-serif;
  font-variant-numeric: tabular-nums;
}
.empty-row { height: 120px; text-align: center !important; color: #999; }
.quote-bottom { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 28px; margin-top: 24px; align-items: start; }
.note-label { display: block; margin-bottom: 8px; color: #666; font-size: 13px; }
.print-total { display: grid; gap: 8px; }
.print-total label { display: flex; align-items: center; justify-content: space-between; gap: 12px; color: #666; font-size: 12px; }
.sum-row { display: flex; justify-content: space-between; gap: 14px; color: #555; font-size: 14px; }
.sum-row.total { padding-top: 12px; border-top: 1px solid rgba(0,0,0,.12); font-size: 18px; color: #171717; }
.sum-row.total [data-total="total"] {
  font-size: 22px;
  line-height: 1;
  font-weight: 800;
}

.drag-overlay { position: fixed; inset: 0; z-index: 100; display: none; place-items: center; padding: 24px; background: rgba(0,0,0,.46); color: #fff; pointer-events: none; }
.drag-overlay.show { display: grid; }
.drag-overlay strong { font-size: 22px; font-weight: 800; letter-spacing: 0; }
.item-context-menu {
  position: fixed;
  z-index: 130;
  min-width: 148px;
  padding: 6px;
  border-radius: 8px;
  background: var(--surface-strong);
  color: var(--text);
  box-shadow: 0 16px 42px rgba(0,0,0,.18), 0 0 0 1px var(--line);
}
.item-context-menu[hidden] { display: none; }
.item-context-menu button {
  width: 100%;
  min-height: 32px;
  display: flex;
  align-items: center;
  padding: 7px 9px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: inherit;
  font: inherit;
  font-size: 13px;
  text-align: left;
  cursor: pointer;
}
.item-context-menu button:hover,
.item-context-menu button:focus-visible {
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  outline: none;
}
.item-context-menu button:disabled {
  color: var(--subtle);
  cursor: default;
}
.item-context-menu button:disabled:hover {
  background: transparent;
}
.item-context-menu button.danger { color: var(--danger); }
.context-submenu-wrap {
  position: relative;
}
.context-submenu-trigger {
  justify-content: space-between;
}
.context-submenu {
  position: absolute;
  top: -6px;
  left: calc(100% + 6px);
  min-width: 168px;
  max-width: 260px;
  max-height: 320px;
  display: none;
  overflow: auto;
  padding: 6px;
  border-radius: 8px;
  background: var(--surface-strong);
  box-shadow: 0 16px 42px rgba(0,0,0,.18), 0 0 0 1px var(--line);
}
.context-submenu-wrap:hover .context-submenu,
.context-submenu-wrap:focus-within .context-submenu {
  display: block;
}
.context-submenu button {
  justify-content: flex-start;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.toast-wrap { position: fixed; right: 18px; bottom: 18px; z-index: 20; display: grid; gap: 8px; width: min(360px, calc(100vw - 36px)); }
.toast { padding: 12px 14px; border-radius: 12px; background: var(--accent); color: #fff; box-shadow: var(--shadow); font-size: 13px; }
.file-input, .print-view { display: none; }
.export-pdf-root {
  position: absolute;
  left: 0;
  top: 0;
  width: 210mm;
  background: #fff;
  color: #171717;
  pointer-events: none;
  z-index: 1;
}
.export-pdf-root .quote-document {
  display: block;
}
.export-pdf-root .print-page {
  width: 210mm;
  height: 297mm;
  min-height: 297mm;
  padding: 14mm;
  box-sizing: border-box;
  box-shadow: none;
  overflow: hidden;
  break-after: page;
  page-break-after: always;
}
.export-pdf-root .print-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14mm;
}
.export-pdf-root .quote-header-main {
  flex: 1 1 auto;
  min-width: 0;
}
.export-pdf-root .right-meta {
  flex: 0 0 46mm;
  width: 46mm;
  max-width: 46mm;
  margin-left: 0;
  justify-items: stretch;
}
.export-pdf-root .right-meta label {
  width: 100%;
  grid-template-columns: 17mm minmax(0, 1fr);
  column-gap: 4mm;
  white-space: nowrap;
}
.export-pdf-root .right-meta .editable-text {
  min-width: 0;
  white-space: nowrap;
}
.export-pdf-root .meta-label-title {
  text-align: left;
  text-align-last: auto;
}
.export-pdf-root .preview-wrap,
.export-pdf-root .preview-gallery {
  width: calc(var(--item-row-height, 72px) - 12px);
  height: calc(var(--item-row-height, 72px) - 12px);
}
.export-pdf-root .print-thumb {
  left: 50%;
  top: 50%;
  right: auto;
  bottom: auto;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  transform: translate(-50%, -50%);
  object-fit: contain;
}
.export-pdf-root .print-page:last-child {
  break-after: auto;
  page-break-after: auto;
}

@media screen and (max-width: 760px) {
  html,
  body,
  .designer-shell,
  .right-rail,
  .rail-brand-row,
  .rail-main,
  .canvas-statusbar,
  .canvas-statusbar button,
  .mobile-icon-btn {
    touch-action: manipulation;
  }
  html, body { height: auto; overflow: auto; overscroll-behavior: none; }
  html.mobile-menu-open,
  html.mobile-menu-open body {
    overflow: hidden;
  }
  .app-shell { height: auto; min-height: 100vh; display: block; overflow: visible; }
  .designer-shell { height: auto; min-height: 100vh; grid-template-columns: 1fr; padding: 0; gap: 12px; }
  .splitter { display: none; }
  .canvas-pane, .right-rail { height: auto; }
  .canvas-pane {
    margin-top: 62px;
    margin-bottom: 48px;
    height: calc(100svh - 110px);
    min-height: calc(100vh - 110px);
    overflow: hidden;
    padding: 0;
  }
  .right-rail { padding: 0 10px; }
  .right-rail {
    order: -1;
    overflow: visible;
    width: 100%;
    max-width: none;
    display: block;
    background: transparent;
  }
  .rail-brand-row {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 95;
    min-height: 54px;
    display: grid;
    grid-template-columns: 44px minmax(0, 1fr) 88px;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    background: rgba(247,247,248,.86);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    box-shadow: 0 1px 0 rgba(0,0,0,.08);
  }
  :root[data-theme="dark"] .rail-brand-row {
    background: rgba(16,17,22,.82);
    box-shadow: 0 1px 0 rgba(255,255,255,.08);
  }
  .rail-brand-row .brand {
    display: grid;
    justify-items: start;
    gap: 0;
  }
  .rail-brand-row .brand > span:last-child {
    display: none;
  }
  .rail-brand-row .brand-mark {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    font-size: 15px;
  }
  .mobile-toolbar-controls {
    grid-column: 2 / 4;
    justify-self: stretch;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 40px;
    align-items: center;
    gap: 8px;
  }
  .mobile-segmented {
    position: relative;
    justify-self: center;
    width: min(136px, 100%);
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    min-width: 0;
    gap: 4px;
    padding: 4px;
    border-radius: 11px;
    background: rgba(255,255,255,.28);
    box-shadow: inset 0 0 0 1px rgba(0,0,0,.04);
  }
  :root[data-theme="dark"] .mobile-segmented {
    background: rgba(255,255,255,.06);
    box-shadow: inset 0 0 0 1px rgba(255,255,255,.04);
  }
  .mobile-segmented::before {
    content: "";
    position: absolute;
    top: 4px;
    bottom: 4px;
    left: 4px;
    width: calc((100% - 12px) / 2);
    border-radius: 8px;
    background: #171717;
    box-shadow: 0 6px 16px rgba(0,0,0,.16), inset 0 0 0 1px rgba(0,0,0,.08);
    transform: translateX(0);
    transition: transform .22s ease, background .18s ease, box-shadow .18s ease;
    pointer-events: none;
  }
  :root[data-theme="dark"] .mobile-segmented::before {
    background: #fff;
    box-shadow: 0 6px 16px rgba(0,0,0,.22), inset 0 0 0 1px rgba(0,0,0,.08);
  }
  .mobile-segmented:has(.segment:nth-child(2).active)::before {
    transform: translateX(calc(100% + 4px));
  }
  .mobile-segmented .segment {
    min-width: 0;
    min-height: 34px;
    padding: 6px 8px;
  }
  .mobile-icon-btn {
    width: 40px;
    height: 40px;
    display: inline-grid;
    place-items: center;
    padding: 0;
    border: 0;
    border-radius: 10px;
    background: color-mix(in srgb, var(--surface-strong) 86%, transparent);
    color: #171717;
    box-shadow: 0 0 0 1px var(--line);
  }
  :root[data-theme="dark"] .mobile-icon-btn {
    color: #f4f4f5;
  }
  .mobile-icon-btn svg {
    width: 18px;
    height: 18px;
  }
  .rail-main {
    position: fixed;
    left: 0;
    right: 0;
    top: 62px;
    bottom: 0;
    z-index: 80;
    display: none;
    align-content: center;
    justify-items: center;
    gap: 18px;
    overflow: auto;
    padding: 22px 16px 112px;
    background: rgba(247,247,248,.72);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    box-shadow: inset 0 1px 0 rgba(0,0,0,.08);
  }
  :root[data-theme="dark"] .rail-main {
    background: rgba(0,0,0,.66);
    box-shadow: inset 0 1px 0 rgba(255,255,255,.08);
  }
  :root:not([data-theme="dark"]) .rail-main {
    background: rgba(247,247,248,.72);
    color: #171717;
    box-shadow: inset 0 1px 0 rgba(0,0,0,.08);
  }
  :root:not([data-theme="dark"]) .rail-main .btn {
    color: #50535a;
    box-shadow: 0 0 0 1px rgba(0,0,0,.1);
  }
  :root:not([data-theme="dark"]) .rail-main .btn:hover,
  :root:not([data-theme="dark"]) .rail-main .btn:focus-visible {
    color: #171717;
    background: rgba(255,255,255,.56);
    box-shadow: 0 0 0 1px rgba(0,0,0,.13), 0 10px 24px rgba(0,0,0,.08);
  }
  .right-rail.mobile-menu-open .rail-main { display: grid; }
  .preview-tabs-section {
    display: none;
  }
  .range-section {
    width: min(330px, 100%);
    grid-template-columns: 1fr;
    gap: 10px;
  }
  .rail-actions {
    width: min(330px, 100%);
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
  }
  .mobile-menu-controls {
    width: min(330px, 100%);
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
  }
  .rail-actions .btn,
  .mobile-menu-controls .btn {
    min-height: 118px;
    aspect-ratio: 1 / .82;
    flex-direction: column;
    gap: 10px;
    padding: 14px 10px;
    font-size: 13px;
    border-radius: 14px;
  }
  .rail-actions .btn svg,
  .mobile-menu-controls .btn svg {
    width: 28px;
    height: 28px;
  }
  .rail-hint { font-size: 11px; line-height: 1.45; }
  .rail-footer {
    position: fixed;
    left: 14px;
    right: 14px;
    bottom: 16px;
    z-index: 90;
    display: none;
    justify-content: center;
    min-height: auto;
    padding: 0;
    padding-bottom: 0;
  }
  .right-rail.mobile-menu-open .rail-footer {
    display: flex;
  }
  .topbar, .preview-bar { align-items: flex-start; flex-direction: column; }
  .top-actions, .preview-tools, .header-preview-tools { width: 100%; }
  .top-actions .btn, .preview-tools .btn { flex: 1 1 auto; }
  .header-preview-tools .segmented { flex: 1 1 auto; }
  .header-preview-tools .segment { flex: 1; }
  .menu-wrap { width: calc(100% - 46px); }
  .menu-wrap > .btn { width: 100%; }
  .more-menu { left: 0; right: auto; width: min(280px, 100%); }
  .preview-workspace { height: auto; width: 100%; padding: 0; }
  .canvas-pane { min-width: 0; }
  .live-preview {
    --canvas-pan-y-buffer: 24vh;
    width: 100%;
    max-height: none;
    height: 100%;
    min-height: 0;
    overflow: auto;
    margin: 0;
    padding: 0;
    -webkit-overflow-scrolling: touch;
    touch-action: none;
  }
  .canvas-statusbar {
    --mobile-status-control-width: 54px;
    --mobile-slider-popover-width: 24px;
    --mobile-slider-popover-height: 220px;
    --mobile-slider-track-length: 152px;
    --mobile-slider-input-bottom: 112px;
    --mobile-slider-track-color: rgba(0,0,0,.28);
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 94;
    height: 48px;
    min-height: 48px;
    flex-wrap: nowrap;
    gap: 8px;
    padding: 6px 8px;
    border-radius: 0;
    background: rgba(247,247,248,.92);
    color: #171717;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    box-shadow: inset 0 1px 0 rgba(0,0,0,.1);
    overflow: visible;
  }
  .canvas-add-btn {
    position: fixed;
    right: 14px;
    bottom: 76px;
    width: 44px;
    height: 44px;
    z-index: 93;
  }
  .canvas-add-tooltip {
    right: 0;
    max-width: min(250px, calc(100vw - 28px));
    font-size: 11px;
    display: none;
  }
  :root[data-theme="dark"] .canvas-statusbar {
    --mobile-slider-track-color: rgba(255,255,255,.34);
    background: rgba(18,20,26,.92);
    color: #f4f4f5;
    box-shadow: inset 0 1px 0 rgba(255,255,255,.1);
  }
  .canvas-tool-btn {
    background: transparent;
    box-shadow: none;
    border-radius: 0;
  }
  .canvas-tool-btn:hover,
  .canvas-tool-btn:focus-visible {
    background: transparent;
    color: #000;
  }
  :root[data-theme="dark"] .canvas-tool-btn:hover,
  :root[data-theme="dark"] .canvas-tool-btn:focus-visible {
    color: #fff;
  }
  .canvas-status-info {
    flex: 1 1 72px;
  }
  .canvas-status-actions {
    flex: 0 0 auto;
    display: flex;
    gap: 4px;
  }
  .status-icon-btn {
    width: 30px;
    height: 30px;
  }
  .status-icon-btn svg {
    width: 16px;
    height: 16px;
  }
  .canvas-row-height-control {
    position: relative;
    flex: 0 0 var(--mobile-status-control-width);
    height: 40px;
    justify-content: center;
    gap: 0;
    touch-action: none;
  }
  .canvas-row-height-control::before,
  .canvas-zoom-control::before {
    content: "";
    position: absolute;
    left: 50%;
    bottom: 0;
    width: var(--mobile-slider-popover-width);
    max-width: var(--mobile-slider-popover-width);
    height: var(--mobile-slider-popover-height);
    border-radius: 12px;
    background: rgba(246,247,249,.96);
    box-shadow: inset 0 0 0 1px rgba(0,0,0,.1), 0 18px 42px rgba(0,0,0,.18);
    opacity: 0;
    pointer-events: none;
    transform: translate(-50%, 8px);
    transition: opacity .16s ease, transform .16s ease;
  }
  :root[data-theme="dark"] .canvas-row-height-control::before,
  :root[data-theme="dark"] .canvas-zoom-control::before {
    background: rgba(32,34,42,.96);
    box-shadow: inset 0 0 0 1px rgba(255,255,255,.12), 0 18px 42px rgba(0,0,0,.36);
  }
  .canvas-row-height-control.mobile-slider-active::before,
  .canvas-row-height-control:hover::before,
  .canvas-row-height-control:focus-within::before,
  .canvas-zoom-control.mobile-slider-active::before,
  .canvas-zoom-control:hover::before,
  .canvas-zoom-control:focus-within::before {
    opacity: 1;
    transform: translate(-50%, 0);
  }
  .canvas-row-height-control label {
    position: relative;
    z-index: 1;
    width: var(--mobile-status-control-width);
    justify-content: center;
    gap: 3px;
    touch-action: none;
  }
  .canvas-row-height-control::before {
    left: 9px;
  }
  .canvas-row-height-control label svg {
    width: 16px;
    height: 16px;
  }
  .canvas-row-height-control label span {
    display: none;
  }
  .canvas-row-height-control output {
    width: 29px;
    text-align: center;
  }
  .canvas-row-height-control input[type="range"] {
    position: absolute;
    left: 7px;
    bottom: var(--mobile-slider-input-bottom);
    width: var(--mobile-slider-track-length);
    max-width: var(--mobile-slider-track-length);
    height: 24px;
    min-width: 0;
    opacity: 0;
    pointer-events: none;
    transform: translate(-50%, 8px) rotate(-90deg);
    transform-origin: center;
    writing-mode: horizontal-tb;
    direction: rtl;
    -webkit-appearance: none;
    appearance: none;
    background: transparent;
    accent-color: #171717;
    transition: opacity .16s ease, transform .16s ease;
  }
  .canvas-row-height-control:hover input[type="range"],
  .canvas-row-height-control:focus-within input[type="range"],
  .canvas-row-height-control:active input[type="range"],
  .canvas-row-height-control.mobile-slider-active input[type="range"] {
    opacity: 1;
    pointer-events: auto;
    transform: translate(-50%, 0) rotate(-90deg);
  }
  .canvas-zoom-control {
    position: relative;
    flex: 0 0 76px;
    justify-content: center;
    gap: 4px;
    height: 40px;
    touch-action: none;
  }
  .canvas-zoom-control .canvas-tool-btn {
    position: relative;
    left: auto;
    top: auto;
    width: 24px;
    height: 22px;
    transform: none;
  }
  .canvas-zoom-control .canvas-tool-btn,
  .canvas-zoom-control output {
    z-index: 1;
  }
  .canvas-zoom-control::before {
    left: 17px;
  }
  .canvas-zoom-control input[type="range"] {
    position: absolute;
    left: 15px;
    bottom: var(--mobile-slider-input-bottom);
    width: var(--mobile-slider-track-length);
    max-width: var(--mobile-slider-track-length);
    height: 24px;
    opacity: 0;
    pointer-events: none;
    transform: translate(-50%, 8px) rotate(-90deg);
    transform-origin: center;
    writing-mode: horizontal-tb;
    direction: rtl;
    -webkit-appearance: none;
    appearance: none;
    background: transparent;
    accent-color: #171717;
    transition: opacity .16s ease, transform .16s ease;
  }
  :root[data-theme="dark"] .canvas-row-height-control input[type="range"],
  :root[data-theme="dark"] .canvas-zoom-control input[type="range"] {
    background: transparent;
    accent-color: #f4f4f5;
  }
  .canvas-row-height-control input[type="range"]::-webkit-slider-runnable-track,
  .canvas-zoom-control input[type="range"]::-webkit-slider-runnable-track {
    width: 100%;
    height: 1px;
    background: var(--mobile-slider-track-color);
    border: 0;
  }
  .canvas-row-height-control input[type="range"]::-webkit-slider-thumb,
  .canvas-zoom-control input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    margin-top: -6.5px;
    border: 0;
    border-radius: 50%;
    background: #171717;
    box-shadow: 0 4px 12px rgba(0,0,0,.24);
  }
  :root[data-theme="dark"] .canvas-row-height-control input[type="range"]::-webkit-slider-thumb,
  :root[data-theme="dark"] .canvas-zoom-control input[type="range"]::-webkit-slider-thumb {
    background: #f4f4f5;
  }
  .canvas-row-height-control input[type="range"]::-moz-range-track,
  .canvas-zoom-control input[type="range"]::-moz-range-track {
    width: 100%;
    height: 1px;
    background: var(--mobile-slider-track-color);
    border: 0;
  }
  .canvas-row-height-control input[type="range"]::-moz-range-thumb,
  .canvas-zoom-control input[type="range"]::-moz-range-thumb {
    width: 14px;
    height: 14px;
    border: 0;
    border-radius: 50%;
    background: #171717;
  }
  .canvas-zoom-control:hover input[type="range"],
  .canvas-zoom-control:focus-within input[type="range"],
  .canvas-zoom-control:active input[type="range"],
  .canvas-zoom-control.mobile-slider-active input[type="range"] {
    opacity: 1;
    pointer-events: auto;
    transform: translate(-50%, 0) rotate(-90deg);
  }
  .canvas-zoom-control output {
    position: relative;
    left: auto;
    bottom: auto;
    width: 34px;
    transform: none;
    text-align: center;
    font-size: 10px;
    line-height: 1;
  }
  .live-preview.preview-a4 .print-page {
    width: 794px;
    min-width: 794px;
    max-width: none;
    height: 1123px;
    min-height: 1123px;
    padding: 42px;
    transform-origin: top left;
  }
  .live-preview.preview-a4 .quote-document {
    justify-items: start;
    padding-left: 50vw;
    padding-right: 50vw;
  }
  .live-preview.preview-a4 .print-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 32px;
  }
  .live-preview.preview-a4 .quote-header-main,
  .live-preview.preview-a4 .print-header > div:first-child {
    flex: 1 1 auto;
    min-width: 0;
  }
  .live-preview.preview-a4 .quote-title-input,
  .live-preview.preview-a4 .print-header h1 {
    font-size: 34px;
    line-height: 1.1;
  }
  .live-preview.preview-a4 .right-meta {
    width: max-content;
    max-width: 100%;
    margin-left: auto;
    justify-items: start;
  }
  .live-preview.preview-a4 .right-meta label {
    display: grid;
    grid-template-columns: 56px max-content;
    width: max-content;
    column-gap: 10px;
    white-space: nowrap;
  }
  .live-preview.preview-a4 .quote-bottom {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 320px;
    gap: 28px;
    align-items: start;
  }
  .live-preview.preview-a4 .print-total {
    width: 320px;
  }
  .live-preview.preview-web .print-page {
    width: calc(100vw - 20px);
    max-width: none;
    min-height: 62vh;
    padding: 24px;
  }
  .live-preview.preview-web .quote-document,
  .live-preview.preview-a4 .quote-document {
    width: max-content;
    min-width: 100%;
  }
  .live-preview.preview-web .print-header,
  .live-preview.preview-web .quote-bottom {
    grid-template-columns: 1fr;
    display: grid;
  }
  .live-preview.preview-web .right-meta {
    width: auto;
    margin-left: 0;
  }
  .live-preview.preview-web .right-meta label {
    grid-template-columns: 64px minmax(0, 1fr);
    width: 100%;
  }
  .item-context-menu {
    max-width: calc(100vw - 16px);
  }
  .toast-wrap {
    right: 10px;
    bottom: 10px;
    width: calc(100vw - 20px);
  }
}

@media screen and (max-width: 420px) {
  .designer-shell { padding: 0; }
  .rail-actions,
  .mobile-menu-controls { gap: 8px; }
  .rail-actions .btn,
  .mobile-menu-controls .btn {
    min-height: 112px;
    gap: 8px;
    font-size: 12px;
  }
  .btn svg, .icon-btn svg { width: 15px; height: 15px; }
  .rail-actions .btn svg,
  .mobile-menu-controls .btn svg { width: 28px; height: 28px; }
  .live-preview.preview-web .print-page {
    padding: 28px;
  }
}

@page { size: A4; margin: 0; }
@media print {
  html, body { height: auto !important; overflow: visible !important; }
  .no-print, .app-shell { display: none !important; }
  body { background: #fff !important; }
  .print-view { display: block !important; }
  .quote-document { display: block !important; }
  .print-header {
    display: flex !important;
    justify-content: space-between !important;
    align-items: flex-start !important;
    gap: 32px !important;
  }
  .right-meta {
    width: max-content !important;
    margin-left: auto !important;
  }
  .quote-bottom {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) 320px !important;
  }
  .print-page {
    width: 210mm !important;
    height: 297mm !important;
    padding: 14mm !important;
    box-shadow: none !important;
    margin: 0 !important;
    break-after: page;
    page-break-after: always;
    overflow: hidden !important;
  }
  .page-number {
    left: 14mm !important;
    right: 14mm !important;
    bottom: 7mm !important;
  }
  .print-page:last-child { break-after: auto; page-break-after: auto; }
  tr { break-inside: avoid; page-break-inside: avoid; }
  thead { display: table-header-group; }
}
