/* ════════════════════════════════════════════
   石英石加工圖  ·  Global Styles
   Design: Dark / Precision / Tier-1
════════════════════════════════════════════ */

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

@font-face {
  font-family: 'NSimSunLocal';
  src: url('/static/fonts/SIMSUN.TTC') format('truetype-collection');
  font-display: swap;
}

:root {
  /* ── Deep navy / graphite / paper-white technical palette ── */
  --bg:        #0a0e16;          /* near-black navy */
  --surface:   #10141d;          /* panel base */
  --surface2:  #161b26;          /* raised surface */
  --border:    #1f2633;          /* quiet divider */
  --border2:   #2b3242;          /* stronger divider */
  --accent:    #c7d2ea;          /* cool paper white (primary actions) */
  --accent-dk: #97a4c2;          /* pressed / darker */
  --accent-lt: #eaf0ff;          /* hover glow */
  --ink:       #0a0e16;          /* for text-on-accent */
  --text:      #eef1f6;          /* primary text — warm paper-white */
  --text-2:    #8b93a6;          /* secondary */
  --text-3:    #525a6d;          /* tertiary */
  --yellow:    #e8c870;          /* muted amber (dims / blueprint accent) */
  --green:     #7db791;          /* quiet sage (confirm) */
  --green-dk:  #4f8a68;
  --danger:    #c78a8a;          /* muted terracotta */
  --blueprint: #6f8bb8;          /* blueprint line color */
  --muted:     #8b93a6;
  --fg:        #eef1f6;
  --shadow:    0 18px 36px rgba(0, 0, 0, 0.42);
  --radius-sm: 6px;
  --radius:    10px;
  --radius-lg: 14px;
  --header-h:  64px;
  --bar-h:     60px;
  --dim-font:  'NSimSunLocal', 'SimSun', 'NSimSun', 'Songti SC', serif;
  --mono:      'SF Mono', 'JetBrains Mono', 'Fira Code', ui-monospace, monospace;
}

html { height: 100%; -webkit-tap-highlight-color: transparent; }
body {
  height: 100%; min-height: 100vh;
  font-family: "Inter", "SF Pro Text", "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", sans-serif;
  background:
    radial-gradient(1200px 600px at 50% -10%, rgba(111, 139, 184, 0.06), transparent 60%),
    linear-gradient(180deg, #0a0e16 0%, #070a11 100%);
  color: var(--text);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  letter-spacing: 0.01em;
}

/* ── Header ── */
.app-header {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  height: var(--header-h);
  display: flex; align-items: center; gap: 14px;
  padding: 0 20px;
  background: rgba(12, 16, 24, 0.88);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  border-bottom: 1px solid rgba(255,255,255,.04);
  box-shadow: 0 1px 0 rgba(255,255,255,.02) inset, 0 20px 40px rgba(0,0,0,.28);
}
.header-divider {
  width: 1px; height: 26px;
  background: linear-gradient(180deg, transparent, rgba(199, 210, 234, 0.35), transparent);
  flex-shrink: 0;
  margin: 0 4px;
}
.header-main {
  font-family: "Cormorant Garamond", "Playfair Display", "Noto Serif TC", "Songti TC", "STSong", serif;
  font-size: 22px;
  font-weight: 500;
  letter-spacing: 0.28em;
  padding-left: 0.28em; /* compensate trailing letterspacing so block looks centered */
  color: var(--text);
  white-space: nowrap;
  line-height: 1;
}
.header-sub  { color: var(--text-3); letter-spacing: 0.02em; }
.btn-menu {
  font-size: 18px;
  width: 38px;
  height: 38px;
  border: 1px solid rgba(255,255,255,.08);
  background: rgba(255,255,255,.03);
}
.header-logo {
  height: 44px; width: auto; object-fit: contain;
  flex-shrink: 0;
}
.header-home {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding: 0;
  border: none;
  background: transparent;
  color: inherit;
  cursor: pointer;
}
.header-home:hover {
  opacity: 0.94;
}
.header-home:focus-visible {
  outline: 2px solid rgba(141, 162, 200, 0.85);
  outline-offset: 6px;
  border-radius: 10px;
}
.drawing-rules {
  margin-top: 20px; width: 100%;
  background: var(--surface2); border-radius: 12px;
  padding: 14px 16px; display: flex; flex-direction: column; gap: 8px;
}
.drawing-rules-title {
  font-size: 12px; font-weight: 600; color: var(--muted);
  margin-bottom: 4px; letter-spacing: 0.5px;
}
.drawing-rules-row {
  display: flex; align-items: center; gap: 10px;
  font-size: 13px; color: var(--fg);
}
.rule-dot {
  width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0;
}
.header-logo-text {
  font-size: 13px; font-weight: 700; letter-spacing: 2px;
  color: var(--muted); border: 1px solid var(--border2);
  padding: 3px 8px; border-radius: 4px; flex-shrink: 0;
}
.header-divider {
  width: 1px; height: 20px; background: var(--border2); flex-shrink: 0;
}
.btn-back {
  display: flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; flex-shrink: 0;
  background: none; border: none; border-radius: 8px;
  color: var(--fg); font-size: 26px; line-height: 1;
  cursor: pointer; padding: 0; margin-right: 2px;
  transition: background 0.15s;
}
.btn-back:active { background: var(--border); }
.header-title { display: flex; flex-direction: column; min-width: 0; }
.header-main {
  font-family: "Cormorant Garamond", "Playfair Display", "Noto Serif TC", "Songti TC", "STSong", serif;
  font-size: 22px;
  font-weight: 500;
  letter-spacing: 0.28em;
  padding-left: 0.28em;
  color: var(--text);
  white-space: nowrap;
  line-height: 1;
}
.header-sub  { font-size: 11px; color: var(--text-2); margin-top: 1px; white-space: nowrap; }
.app-menu {
  position: absolute;
  top: calc(100% + 10px);
  left: 16px;
  width: min(280px, calc(100vw - 32px));
  padding: 10px;
  border-radius: 18px;
  border: 1px solid rgba(255,255,255,.08);
  background: linear-gradient(180deg, rgba(27,29,40,.98), rgba(16,18,28,.98));
  box-shadow: 0 20px 44px rgba(0,0,0,.34);
  display: flex;
  flex-direction: column;
  gap: 6px;
  z-index: 160;
}
.app-menu button {
  width: 100%;
  text-align: left;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid transparent;
  background: rgba(255,255,255,.02);
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
  transition: background .18s ease, border-color .18s ease, transform .18s ease;
}
.app-menu button:hover {
  background: rgba(111, 139, 184,.1);
  border-color: rgba(128, 149, 189,.26);
  transform: translateX(2px);
}

/* ── Main ── */
.app-main {
  position: fixed;
  top: var(--header-h); left: 0; right: 0; bottom: 0;
  display: flex; align-items: stretch;
}

/* ── Steps ── */
.step { display: none; width: 100%; height: 100%; }
.step.active { display: flex; flex-direction: column; align-items: center; justify-content: center; }
#step-shape.active { overflow-y: auto; }
#step-editor { height: 100%; }
#step-editor.active { align-items: stretch; justify-content: flex-start; }

/* ════════════════════════════════════════════
   STEP 1 · Upload
════════════════════════════════════════════ */
/* Start options layout */
.start-options {
  display: flex;
  flex-direction: row;
  align-items: stretch;
  gap: 0;
  width: 100%;
  max-width: 760px;
}
.start-sep {
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; color: var(--text-3);
  padding: 0 16px;
  flex-shrink: 0;
}
.manual-zone {
  display: flex; flex-direction: column; align-items: center;
  flex: 1;
  padding: 40px 24px;
  border: 1.5px dashed var(--border2);
  border-radius: var(--radius-lg);
  background: var(--surface);
  cursor: pointer;
  transition: border-color .2s, background .2s, transform .15s;
  gap: 14px;
  user-select: none;
}
.manual-zone:hover {
  border-color: var(--accent);
  background: #161b26;
  transform: translateY(-2px);
}
@media (max-width: 600px) {
  .start-options { flex-direction: column; }
  .start-sep { padding: 12px 0; }
}

.upload-zone {
  display: flex; flex-direction: column; align-items: center;
  flex: 1;
  padding: 40px 24px;
  border: 1.5px dashed var(--border2);
  border-radius: var(--radius-lg);
  background: var(--surface);
  cursor: pointer;
  transition: border-color .2s, background .2s, transform .15s;
  gap: 14px;
  user-select: none;
}
.upload-zone:hover, .upload-zone.drag-over {
  border-color: var(--accent);
  background: #161b26;
  transform: translateY(-2px);
}
.upload-zone:active { transform: translateY(0); }

.upload-icon-wrap {
  width: 72px; height: 72px;
  background: var(--surface2);
  border-radius: 20px;
  display: flex; align-items: center; justify-content: center;
  font-size: 36px;
  border: 1px solid var(--border);
}
.upload-title { font-size: 17px; font-weight: 600; text-align: center; line-height: 1.4; }
.upload-hint  { font-size: 13px; color: var(--text-2); text-align: center; }
.upload-sep   { font-size: 12px; color: var(--text-3); }

/* ════════════════════════════════════════════
   STEP 2 · Loading
════════════════════════════════════════════ */
.loading-wrap {
  display: flex; flex-direction: column; align-items: center; gap: 24px;
}
.spinner-ring {
  width: 56px; height: 56px; position: relative;
}
.spinner-ring::after {
  content: '';
  position: absolute; inset: 0;
  border-radius: 50%;
  border: 3.5px solid var(--border2);
  border-top-color: var(--accent);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-label { font-size: 15px; color: var(--text-2); font-weight: 500; }
.loading-sub   { font-size: 12px; color: var(--text-3); }

/* ════════════════════════════════════════════
   STEP 3 · Editor
════════════════════════════════════════════ */
.editor-root {
  display: flex; flex: 1;
  flex-direction: row;
  overflow: hidden;
  min-height: 0;  /* allow flex child to shrink below content size */
  height: 100%;
}

/* ── Canvas panel ── */
.canvas-panel {
  flex: 1; display: flex; flex-direction: column;
  padding: 18px; gap: 14px;
  min-width: 0;
  background:
    radial-gradient(circle at 20% 0%, rgba(111, 139, 184, 0.08), transparent 28%),
    linear-gradient(180deg, rgba(18, 19, 28, 0.98), rgba(10, 11, 17, 0.98));
}

.toolbar {
  display: flex; align-items: center; justify-content: space-between;
  flex-shrink: 0;
  gap: 8px;
  flex-wrap: wrap;
}
.toolbar-left  { display: flex; align-items: center; gap: 10px; }
.toolbar-right { display: flex; align-items: center; gap: 8px;  }
.btn-toolbar {
  min-height: 44px;
  padding: 0 18px;
  border-radius: 14px;
  font-size: 13px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.btn-toolbar-primary {
  min-width: 112px;
}
.editor-close-btn{
  width: 44px;
  height: 44px;
  padding: 0;
  display:flex;
  align-items:center;
  justify-content:center;
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,.12);
  background: rgba(255,255,255,.03);
  color: rgba(255,255,255,.84);
  cursor: pointer;
  transition: transform .18s ease, background .18s ease, color .18s ease, border-color .18s ease;
  flex-shrink: 0;
}
.editor-close-btn:hover{
  background: rgba(255,255,255,.08);
  color: #ffffff;
  border-color: rgba(173, 196, 255, .34);
  transform: translateY(-1px);
}

.shape-badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px;
  background: rgba(255,255,255,.04);
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 999px;
  font-size: 13px; font-weight: 700; color: var(--text);
  white-space: nowrap;
}
.shape-badge-button {
  border: 1px solid rgba(255,255,255,.08);
  cursor: pointer;
  transition: border-color .18s ease, background .18s ease, transform .18s ease;
}
.shape-badge-button:hover {
  border-color: rgba(143,173,255,.28);
  background: rgba(111, 139, 184,.08);
  transform: translateY(-1px);
}
.shape-badge-button:focus-visible {
  outline: 2px solid rgba(143,173,255,.42);
  outline-offset: 2px;
}
.shape-badge .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }

.confidence-badge {
  font-size: 11px; padding: 6px 10px; border-radius: 999px; font-weight: 700;
}
.confidence-badge.ocr        { background: #1e3a2b; color: #cfe4d4; }
.confidence-badge.ocr_partial { background: #3a2a15; color: #eedfa6; }
.confidence-badge.shape_only  { background: #3a1e22; color: #e8c3c3; }
.confidence-badge.default     { background: #1a2238; color: #c7d2ea; }

/* Quick-dim bar */
.dim-bar {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 14px;
  background: rgba(255,255,255,.03);
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 18px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.03);
  flex-shrink: 0;
  flex-wrap: wrap;
}
/* Canvas wrap */
.canvas-wrap {
  flex: 1; display: flex; align-items: stretch; justify-content: stretch;
  background:
    radial-gradient(circle at top, rgba(49,54,82,.16), transparent 48%),
    linear-gradient(180deg, rgba(18, 20, 30, 0.99), rgba(12, 13, 20, 0.99));
  border-radius: 22px;
  border: 1px solid rgba(255,255,255,.08);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.04), 0 18px 34px rgba(0,0,0,.18);
  overflow: hidden;
  min-height: 0; min-width: 0;  /* crucial for flex shrink on mobile */
  position: relative;
  padding: 18px;
}
.canvas-wrap::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 22px;
  pointer-events: none;
}
canvas {
  cursor: pointer;
  display: block;
  width: 100%;
  height: 100%;
}
.canvas-hint {
  position: absolute; top: 18px; left: 18px;
  font-size: 11px; color: #cbd4ff;
  background: rgba(8,10,18,.72); padding: 8px 12px; border-radius: 999px;
  border: 1px solid rgba(128, 149, 189,.14);
  letter-spacing: .04em;
  pointer-events: none; white-space: nowrap;
}
.canvas-hint.is-pick-mode {
  color: #d1fae5;
  background: rgba(10, 28, 25, 0.82);
  border-color: rgba(110, 231, 183, 0.28);
}
.canvas-fullscreen-exit {
  position: absolute;
  top: 18px;
  right: 18px;
  z-index: 3;
  min-height: 40px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid rgba(173,196,255,.28);
  background: linear-gradient(135deg, rgba(87,103,149,.92), rgba(40,51,80,.94));
  color: #edf4ff;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 12px 28px rgba(10,15,25,.32);
}
.canvas-fullscreen-exit:hover {
  filter: brightness(1.06);
  transform: translateY(-1px);
}
.canvas-right-angle-delete {
  position: absolute;
  top: 18px;
  right: 18px;
  z-index: 3;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid rgba(248, 113, 113, 0.28);
  background: linear-gradient(180deg, #3a2026, #25151b);
  color: #ffe9ec;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  box-shadow: 0 12px 28px rgba(35, 10, 14, 0.34);
}
.canvas-right-angle-delete:hover {
  filter: brightness(1.06);
  transform: translateY(-1px);
}
.editor-root.preview-fullscreen {
  position: fixed;
  inset: var(--header-h) 0 0 0;
  z-index: 210;
  background: rgba(9,11,18,.98);
}
.editor-root.preview-fullscreen .canvas-panel {
  padding: 12px;
  gap: 10px;
}
.editor-root.preview-fullscreen .toolbar,
.editor-root.preview-fullscreen .slab-list-bar,
.editor-root.preview-fullscreen .download-bar {
  display: none;
}
.editor-root.preview-fullscreen .canvas-wrap {
  border-radius: 24px;
  padding: 10px;
  min-height: 0;
}
.editor-root.preview-fullscreen .canvas-hint {
  top: 14px;
  left: 14px;
}
.editor-root.preview-fullscreen .canvas-fullscreen-exit {
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
}
.editor-root.preview-fullscreen .canvas-right-angle-delete {
  top: 14px;
  right: 14px;
}

/* Download bar */
.btn-success {
  padding: 10px 16px;
  color: #edf4ff;
  border: 1px solid rgba(143, 173, 255, .22);
  border-radius: 12px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  background: linear-gradient(180deg, #232b3a, #181e2a);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.08), 0 10px 24px rgba(26, 39, 71, .28);
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease, filter .18s ease;
}
.btn-success:hover {
  transform: translateY(-1px);
  filter: brightness(1.05);
  border-color: rgba(173, 196, 255, .34);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.12), 0 14px 28px rgba(33, 48, 87, .34);
}
.btn-success.btn-toolbar {
  padding: 0 18px;
  border-radius: 14px;
}
.btn-toolbar.is-active {
  color: #defcf1;
  border-color: rgba(110, 231, 183, 0.52);
  background: linear-gradient(180deg, #254a3e, #17332b);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.08), 0 0 0 1px rgba(110, 231, 183, .16), 0 10px 24px rgba(12, 36, 30, .34);
}

.slab-list-bar {
  display: flex; flex-direction: column; align-items: stretch; gap: 8px;
  padding: 10px 14px; background: rgba(255,255,255,.03);
  border: 1px solid rgba(255,255,255,.08); border-radius: 18px;
  flex-shrink: 0;
}
.slab-list-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  padding: 6px 2px;
  border: none;
  background: transparent;
  color: var(--text);
  cursor: pointer;
}
.slab-list-toggle-icon {
  color: var(--text-2);
  font-size: 13px;
  transition: transform .18s ease;
}
.slab-list-bar.collapsed .slab-list-toggle-icon {
  transform: rotate(-90deg);
}
.slab-list-bar.collapsed .slab-chips {
  display: none;
}
.slab-chips { display: flex; flex-direction: column; gap: 8px; width: 100%; }
.slab-accordion {
  border: 1px solid rgba(255,255,255,.08);
  background: rgba(255,255,255,.03);
  border-radius: 14px;
  overflow: hidden;
}
.slab-accordion.active {
  border-color: rgba(111, 139, 184,.55);
  box-shadow: 0 0 0 1px rgba(111, 139, 184,.18);
}
.slab-accordion-head {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 14px;
  background: transparent;
  border: none;
  color: var(--text);
  cursor: pointer;
  text-align: left;
}
.slab-accordion-arrow {
  color: var(--text-2);
  font-size: 12px;
  width: 12px;
  flex-shrink: 0;
}
.slab-accordion-label {
  font-size: 12px;
  line-height: 1.35;
}
.slab-accordion-body {
  display: flex;
  gap: 8px;
  padding: 0 14px 12px 36px;
}
.slab-action-btn {
  padding: 8px 12px;
  background: rgba(255,255,255,.04);
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 10px;
  color: var(--text);
  font-size: 12px;
  cursor: pointer;
}
.slab-action-btn.danger {
  color: #fda4af;
  border-color: rgba(244,63,94,.22);
}

.download-bar {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px;
  background: rgba(255,255,255,.03);
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 18px;
  flex-shrink: 0;
}
.download-bar .field-input { flex: 1; min-width: 0; margin: 0; }

/* ── Drawer ── */
.drawer {
  width: 0;
  min-width: 0;
  background: linear-gradient(180deg, rgba(27, 28, 36, 0.98), rgba(18, 19, 26, 0.98));
  border-left: none;
  display: flex; flex-direction: column;
  transition: width .28s cubic-bezier(.4,0,.2,1), min-width .28s cubic-bezier(.4,0,.2,1), border-color .18s ease;
  transform: none;
  overflow: hidden;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
}
.drawer.open {
  width: 380px;
  min-width: 380px;
  border-left: 1px solid rgba(255,255,255,.06);
  opacity: 1;
  pointer-events: auto;
}

.drawer-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid rgba(255,255,255,.06);
  flex-shrink: 0;
}
.drawer-header h3  { font-size: 16px; font-weight: 700; letter-spacing: .02em; }
.drawer-empty {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 12px; padding: 32px;
  color: var(--text-3); font-size: 13px; text-align: center;
}
.drawer-empty-icon {
  position: relative;
  width: 58px;
  height: 58px;
  border-radius: 18px;
  border: 1px solid rgba(124, 150, 210, .18);
  background:
    linear-gradient(180deg, rgba(78, 96, 138, .16), rgba(23, 29, 47, .08)),
    radial-gradient(circle at 50% 50%, rgba(158, 178, 214, .12), transparent 70%);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.02);
  opacity: .9;
}
.drawer-empty-icon::before,
.drawer-empty-icon::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  background: linear-gradient(180deg, rgba(201, 215, 240, .96), rgba(141, 167, 216, .72));
  transform: translate(-50%, -50%);
}
.drawer-empty-icon::before {
  width: 24px;
  height: 2px;
  border-radius: 999px;
  box-shadow: 0 0 14px rgba(154, 184, 228, .22);
}
.drawer-empty-icon::after {
  width: 2px;
  height: 24px;
  border-radius: 999px;
  box-shadow: 0 0 14px rgba(154, 184, 228, .22);
}

.drawer-body {
  padding: 22px; display: flex; flex-direction: column; gap: 18px;
  overflow-y: auto; flex: 1;
}

/* Fields */
.field-label {
  font-size: 11px; color: var(--text-2); font-weight: 700;
  letter-spacing: .12em;
  display: block; margin-bottom: 6px;
}
.field-subtitle {
  font-size: 12px;
  line-height: 1.45;
  color: var(--text-2);
  margin-top: 2px;
}
.field-input {
  width: 100%; padding: 12px 14px;
  background: rgba(255,255,255,.04); border: 1px solid rgba(255,255,255,.08);
  border-radius: 12px; color: var(--text); font-size: 14px;
  outline: none; transition: border-color .2s;
}
.field-input:focus { border-color: var(--accent); }
.field-input::placeholder { color: var(--text-3); }

.color-row { display: flex; align-items: center; gap: 10px; }
.field-color {
  width: 42px; height: 42px; flex-shrink: 0;
  background: var(--surface2); border: 1px solid var(--border2);
  border-radius: var(--radius-sm); cursor: pointer; padding: 3px;
}
.color-hex {
  flex: 1; padding: 10px 13px;
  background: var(--surface2); border: 1px solid var(--border2);
  border-radius: var(--radius-sm); color: var(--text); font-size: 13px;
  font-family: 'SF Mono', 'Fira Code', monospace;
  outline: none; transition: border-color .2s;
}
.color-hex:focus { border-color: var(--accent); }

/* Icon grid */
.icon-grid {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px;
}
.icon-item {
  display: flex; flex-direction: column; align-items: center;
  padding: 12px 8px 10px; background: linear-gradient(180deg, rgba(255,255,255,.04), rgba(255,255,255,.02));
  border: 1px solid rgba(255,255,255,.08); border-radius: 16px;
  cursor: pointer; transition: border-color .18s, background .18s;
  gap: 8px; min-height: 110px; justify-content: flex-start;
}
.icon-item:hover    { border-color: rgba(111, 139, 184,.72); background: rgba(111, 139, 184,.08); }
.icon-item.selected { border-color: rgba(111, 139, 184,.92); background: rgba(111, 139, 184,.12); box-shadow: 0 0 0 1px rgba(111, 139, 184,.9), 0 12px 26px rgba(111, 139, 184,.15); }
.icon-preview {
  width: 74px;
  height: 74px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  position: relative;
  border-radius: 18px;
  background: rgba(255,255,255,.03);
  border: 1px solid rgba(255,255,255,.04);
}
.icon-glyph { font-size: 30px; line-height: 1; color: var(--text); }
.icon-item.selected .icon-glyph { color: var(--accent-lt); }
.icon-item.none-icon .icon-glyph { font-size: 20px; color: var(--text-3); }
.icon-symbol {
  width: 50px;
  height: 50px;
  object-fit: contain;
  background: transparent;
  display: block;
}
.icon-item.variant-polish[data-id="small_polish"] .icon-symbol,
.icon-item[data-id="small_polish_back_polish"] .icon-symbol,
.icon-item[data-id="small_polish_water_barrier"] .icon-symbol {
  width: 32px;
  height: 32px;
  transform: translateX(-10px);
}
.icon-item[data-id="front_slope_back_polish"] .icon-symbol {
  width: 30px;
  height: 30px;
  transform: translateX(-8px);
}
.icon-item[data-id="back_slope_back_polish"] .icon-symbol {
  width: 30px;
  height: 30px;
  transform: translateX(-8px);
}
.icon-preview-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.icon-overlay-text {
  position: absolute;
  top: 50%;
  left: 60%;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  gap: 0;
  color: #ffffff;
  text-shadow: 0 1px 6px rgba(0,0,0,.55);
}
.icon-overlay-primary {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: -.04em;
  line-height: 1;
}
.icon-overlay-secondary {
  font-size: 9px;
  font-weight: 700;
  margin-left: 1px;
  margin-top: 0;
  line-height: 1;
}
.icon-overlay-text.inline-stop {
  align-items: baseline;
}
.icon-overlay-text.polish-number {
  left: 61%;
}
.icon-item.variant-polish[data-id="small_polish"] .icon-overlay-text,
.icon-item[data-id="small_polish_back_polish"] .icon-overlay-text {
  left: 61%;
}
.icon-item[data-id="small_polish_water_barrier"] .icon-overlay-text {
  left: 60%;
}
.icon-item[data-id="back_slope_back_polish"] .icon-overlay-text,
.icon-item[data-id="front_slope_back_polish"] .icon-overlay-text {
  left: 58%;
}
.icon-item.variant-back-polish[data-id="back_slope"] .icon-symbol,
.icon-item.variant-back-polish[data-id="front_slope"] .icon-symbol {
  width: 30px;
  height: 30px;
  transform: translateX(-8px);
}
.icon-item.variant-back-polish[data-id="back_slope"] .icon-overlay-text,
.icon-item.variant-back-polish[data-id="front_slope"] .icon-overlay-text {
  left: 58%;
}
.icon-item.variant-thickened[data-id="thickened"] .icon-symbol {
  width: 30px;
  height: 30px;
  transform: translateX(-8px);
}
.icon-item.variant-thickened[data-id="thickened"] .icon-overlay-text {
  left: 58%;
}
.icon-item[data-id="front_slope_back_polish"] .icon-overlay-text {
  left: 58%;
}
.icon-param-badge {
  position: absolute;
  right: -2px;
  bottom: -2px;
  min-width: 22px;
  height: 16px;
  padding: 0 5px;
  border-radius: 999px;
  background: rgba(13, 13, 17, 0.88);
  border: 1px solid var(--border2);
  color: var(--yellow);
  font-size: 9px;
  line-height: 14px;
  text-align: center;
}
.icon-item:has(.icon-overlay-text) .icon-param-badge {
  display: none;
}
.field-hint {
  font-size: 11px;
  color: var(--text-2);
}
.icon-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-2);
  text-align: center;
  line-height: 1.2;
  margin-top: 0;
  min-height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.icon-item.selected .icon-label { color: var(--accent-lt); }
.processing-panel,
.processing-config-panel {
  padding: 14px;
  border-radius: 18px;
  background: rgba(255,255,255,.025);
  border: 1px solid rgba(255,255,255,.06);
}
.processing-grid-expander {
  grid-column: 1 / -1;
  margin-top: -2px;
}
.processing-addon-panel {
  margin-top: 12px;
  padding-top: 14px;
  border-top: 1px solid rgba(255,255,255,.06);
}
.processing-panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: flex-start;
  gap: 12px;
  margin-bottom: 14px;
}
.processing-param-main {
  display: flex;
  align-items: flex-end;
  gap: 10px;
}
.processing-param-fields {
  flex: 1;
  min-width: 0;
}
.thickened-controls {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 12px;
}
.processing-variant-controls {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}
.processing-addon-head {
  margin-bottom: 12px;
}
.processing-addon-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.processing-addon-item {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.addon-toggle {
  justify-content: flex-start;
  padding: 0 12px;
}
.addon-input-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}
.addon-prefix {
  width: 34px;
  height: 42px;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,.04);
  border: 1px solid rgba(255,255,255,.08);
  color: var(--yellow);
  font-size: 13px;
  font-weight: 700;
}
.addon-input {
  flex: 1;
}
.addon-input:disabled {
  opacity: .45;
}
.processing-param-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 14px;
}
.special-processing-section {
  margin-top: 14px;
  display: grid;
  gap: 10px;
}
.special-processing-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  min-height: 54px;
  padding: 0 16px;
  border-radius: 14px;
  border: 1px dashed rgba(128, 149, 189,.35);
  background: rgba(128, 149, 189,.08);
  color: var(--text);
  cursor: pointer;
}
.special-processing-toggle.active {
  border-style: solid;
  background: rgba(128, 149, 189,.14);
  box-shadow: inset 0 0 0 1px rgba(128, 149, 189,.18);
}
.special-processing-toggle-title {
  font-size: 13px;
  font-weight: 700;
}
.special-processing-toggle-summary {
  font-size: 12px;
  color: var(--text-2);
}
.special-processing-panel {
  padding-top: 16px;
}
.special-processing-fields {
  display: grid;
  gap: 12px;
}
.special-attachment-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}
.special-attachment-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(255,255,255,.025);
  border: 1px solid rgba(255,255,255,.06);
}
.special-attachment-meta {
  min-width: 0;
  display: grid;
  gap: 4px;
}
.special-attachment-name {
  font-size: 12px;
  color: var(--text);
  word-break: break-all;
}
.special-attachment-type {
  font-size: 11px;
  color: var(--yellow);
}
.special-attachment-remove {
  padding: 7px 12px;
  flex-shrink: 0;
}
.toggle-chip {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 0 10px;
  border-radius: 12px;
  background: rgba(255,255,255,.03);
  border: 1px solid rgba(255,255,255,.08);
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
}
.toggle-chip input {
  accent-color: var(--accent);
}

/* Buttons */
.btn-primary {
  padding: 11px 22px; background: var(--accent);
  color: #fff; border: none; border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 600; cursor: pointer;
  transition: background .2s, transform .1s;
  -webkit-tap-highlight-color: transparent;
}
.btn-primary:hover  { background: var(--accent-dk); }
.btn-primary:active { transform: scale(.97); }

.btn-outline {
  padding: 9px 16px; background: transparent;
  color: var(--text-2); border: 1px solid var(--border2);
  border-radius: var(--radius-sm); font-size: 13px; cursor: pointer;
  transition: border-color .2s, color .2s;
  white-space: nowrap;
}
.btn-outline.btn-toolbar {
  padding: 0 18px;
  border-radius: 14px;
}
.btn-outline:hover { border-color: var(--accent); color: var(--accent-lt); }

.btn-icon {
  background: none; border: none; color: var(--text-2);
  font-size: 15px; cursor: pointer; padding: 6px 8px;
  border-radius: 6px; transition: background .2s, color .2s;
  line-height: 1;
}
.btn-icon:hover { background: var(--surface2); color: var(--text); }

.btn-apply {
  width: 100%; margin-top: 4px; padding: 12px 22px; font-size: 14px;
}
.btn-inline-apply {
  width: auto;
  flex-shrink: 0;
  min-width: 88px;
  margin-top: 0;
}

.btn-accent {
  padding: 10px 16px;
  color: #edf4ff;
  border: 1px solid rgba(143, 173, 255, .22);
  border-radius: 12px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  background: linear-gradient(180deg, #262e3d, #1a2030);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.08), 0 10px 24px rgba(24, 34, 63, .3);
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease, filter .18s ease;
}
.btn-accent:hover {
  transform: translateY(-1px);
  filter: brightness(1.06);
  border-color: rgba(173, 196, 255, .34);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.12), 0 14px 28px rgba(31, 45, 81, .36);
}
.btn-accent.btn-toolbar {
  padding: 0 18px;
  border-radius: 14px;
}

.cutout-dropdown {
  position: absolute; top: calc(100% + 6px); right: 0;
  background: var(--surface); border: 1px solid var(--border2);
  border-radius: var(--radius-sm); z-index: 300;
  min-width: 200px; overflow: hidden;
  box-shadow: 0 8px 24px rgba(0,0,0,.4);
}
.cutout-dropdown button {
  display: block; width: 100%; padding: 11px 16px;
  background: none; border: none; color: var(--text);
  font-size: 13px; text-align: left; cursor: pointer;
}
.cutout-dropdown button:hover { background: var(--surface2); }

.btn-download {
  padding: 10px 24px;
  color: #0a0e16;
  border: 1px solid rgba(199, 210, 234, .6);
  border-radius: 12px;
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.04em;
  cursor: pointer;
  white-space: nowrap;
  background: linear-gradient(180deg, #eaf0ff, #c7d2ea);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.5), 0 10px 24px rgba(10, 14, 22, .4);
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease, filter .18s ease;
  flex-shrink: 0;
}
.btn-download:hover  {
  transform: translateY(-1px);
  filter: brightness(1.04);
  border-color: #ffffff;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.7), 0 14px 30px rgba(10, 14, 22, .5);
}
.btn-download:active { transform: translateY(0) scale(.985); }

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 420;
  background: rgba(6,8,14,.66);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.cutout-modal {
  width: min(760px, 100%);
  max-height: min(88vh, 920px);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  border-radius: 24px;
  background: linear-gradient(180deg, rgba(26,28,38,.98), rgba(16,18,27,.98));
  border: 1px solid rgba(255,255,255,.08);
  box-shadow: 0 32px 80px rgba(0,0,0,.38);
}
.app-modal {
  width: min(680px, 100%);
}
.app-form-grid {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.app-form-span-full {
  width: 100%;
}
.app-form-grid textarea.field-input {
  min-height: 140px;
  resize: vertical;
}
.app-form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 8px;
}
.accessory-picker {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 14px;
  background: rgba(255,255,255,.025);
}
.accessory-picker-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.accessory-toggle {
  min-width: 108px;
}
.accessory-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.accessory-item {
  display: grid;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,.06);
  background: rgba(10,12,20,.55);
}
.accessory-check {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  color: var(--text);
}
.accessory-check input {
  width: 16px;
  height: 16px;
}
.accessory-qty-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.accessory-qty-input {
  width: 96px;
  margin: 0;
}
.saved-project-modal-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.projects-drawer {
  position: fixed;
  top: var(--header-h);
  right: 0;
  bottom: 0;
  width: min(420px, 92vw);
  background: linear-gradient(180deg, rgba(26,28,38,.99), rgba(16,18,27,.99));
  border-left: 1px solid rgba(255,255,255,.08);
  box-shadow: -18px 0 40px rgba(0,0,0,.3);
  z-index: 170;
  transform: translateX(100%);
  transition: transform .24s ease;
  display: flex;
  flex-direction: column;
}
.projects-drawer.open {
  transform: translateX(0);
}
.projects-drawer .drawer-body {
  padding-top: 12px;
}
.cutout-modal.minimized {
  width: min(420px, calc(100vw - 24px));
  margin-top: auto;
  align-self: flex-end;
}
.cutout-modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 22px 24px 16px;
  border-bottom: 1px solid rgba(255,255,255,.06);
}
.cutout-modal-header h3 {
  font-size: 18px;
  font-weight: 700;
}
.cutout-modal-header p {
  margin-top: 6px;
  color: var(--text-2);
  font-size: 13px;
}
.cutout-modal-body {
  padding: 22px 24px 24px;
  overflow: auto;
  display: grid;
  gap: 18px;
}
.cutout-editor-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
.cutout-editor-grid.single {
  grid-template-columns: minmax(0, 1.15fr) minmax(280px, .85fr);
}
.cutout-card {
  padding: 16px;
  border-radius: 18px;
  background: rgba(255,255,255,.025);
  border: 1px solid rgba(255,255,255,.06);
}
.cutout-size-card {
  position: relative;
  padding-bottom: 42px;
}
.cutout-model-toggle {
  position: absolute;
  right: 0;
  bottom: 0;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 12px;
  background: rgba(255,255,255,.03);
  border: 1px solid rgba(255,255,255,.06);
  color: var(--text-2);
  font-size: 11px;
  cursor: pointer;
}
.cutout-model-toggle input {
  width: 14px;
  height: 14px;
}
.cutout-model-toggle span:not(.cutout-model-toggle-help) {
  display: inline;
  color: var(--text-2);
  font-size: 11px;
  font-weight: 600;
  line-height: 1;
}
.cutout-model-toggle-help {
  position: absolute;
  right: 0;
  bottom: calc(100% + 8px);
  width: min(260px, calc(100vw - 64px));
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(18,20,29,.96);
  border: 1px solid rgba(255,255,255,.08);
  color: var(--text);
  font-size: 11px;
  line-height: 1.5;
  box-shadow: 0 14px 26px rgba(0,0,0,.35);
  opacity: 0;
  pointer-events: none;
  transform: translateY(4px);
  transition: opacity .18s ease, transform .18s ease;
}
.cutout-model-toggle:hover .cutout-model-toggle-help,
.cutout-model-toggle:focus-within .cutout-model-toggle-help {
  opacity: 1;
  transform: translateY(0);
}
.cutout-card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.cutout-card-head h4 {
  font-size: 14px;
  font-weight: 700;
}
.cutout-card-head span {
  font-size: 12px;
  color: var(--text-2);
}
.cutout-choice-row,
.cutout-reference-row,
.cutout-faucet-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.choice-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 0 12px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,.08);
  background: rgba(255,255,255,.03);
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.choice-chip.active {
  border-color: rgba(128, 149, 189,.74);
  background: rgba(128, 149, 189,.16);
  color: #eef1ff;
}
.cutout-mini-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.cutout-summary {
  padding: 14px 16px;
  border-radius: 16px;
  background: rgba(11,13,20,.7);
  border: 1px solid rgba(255,255,255,.06);
  color: var(--text-2);
  font-size: 12px;
  line-height: 1.6;
}
.cutout-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}
.cutout-status {
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px dashed rgba(128, 149, 189,.36);
  background: rgba(128, 149, 189,.08);
  color: #dfe6ff;
  font-size: 12px;
  line-height: 1.55;
}
.cutout-preview-panel {
  display: grid;
  gap: 12px;
}
.cutout-preview-stage {
  position: sticky;
  top: 0;
  min-height: 320px;
  border-radius: 20px;
  background:
    radial-gradient(circle at top, rgba(56, 64, 104, .18), transparent 44%),
    linear-gradient(180deg, rgba(16,18,27,.98), rgba(10,12,19,.98));
  border: 1px solid rgba(255,255,255,.06);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
}
.cutout-preview-canvas {
  width: 100%;
  height: 280px;
  display: block;
}
.cutout-preview-note {
  font-size: 12px;
  color: var(--text-2);
  line-height: 1.6;
}
.cutout-stepper {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.cutout-step {
  min-width: 32px;
  height: 32px;
  padding: 0 10px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,.04);
  border: 1px solid rgba(255,255,255,.06);
  color: var(--text-2);
  font-size: 12px;
  font-weight: 700;
}
.cutout-step.active {
  background: rgba(128, 149, 189,.16);
  border-color: rgba(128, 149, 189,.6);
  color: #eef1ff;
}
.sink-style-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 10px;
}
.sink-style-card {
  display: grid;
  gap: 8px;
  padding: 10px;
  border-radius: 16px;
  border: 1px solid rgba(255,255,255,.08);
  background: rgba(255,255,255,.03);
  cursor: pointer;
  transition: border-color .18s ease, transform .18s ease, background .18s ease;
}
.sink-style-card:hover {
  transform: translateY(-1px);
  border-color: rgba(255,255,255,.16);
}
.sink-style-card.active {
  border-color: rgba(128, 149, 189,.68);
  background: rgba(128, 149, 189,.12);
  box-shadow: 0 0 0 1px rgba(128, 149, 189,.18) inset;
}
.sink-style-card-preview {
  width: 100%;
  height: 148px;
  border-radius: 12px;
  background: #ffffff;
  border: 1px solid rgba(17,17,17,.14);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}
.sink-style-card-preview svg {
  width: 100%;
  height: 100%;
  display: block;
}
.sink-style-card-loading,
.sink-style-card-fallback {
  font-size: 11px;
  color: var(--text-2);
  text-align: center;
  line-height: 1.5;
  padding: 8px;
}
.sink-style-card-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
  text-align: center;
}
.editor-root.cutout-pick-mode > :not(.canvas-panel) {
  opacity: .16;
  pointer-events: none;
}
.editor-root.cutout-pick-mode .canvas-panel {
  position: relative;
  z-index: 12;
  box-shadow: 0 0 0 9999px rgba(6,8,14,.6);
}


/* ════════════════════════════════════════════
   MOBILE  (≤ 700px)
════════════════════════════════════════════ */
@media (max-width: 700px) {
  :root {
    --header-h: 52px;
    --bar-h: 60px;
  }

  body { overflow: hidden; }

  /* Header */
  .header-sub { display: none; }
  .header-divider { display: none; }
  .app-header { padding: 0 16px; gap: 10px; }
  .projects-drawer {
    top: auto;
    left: 0;
    width: 100%;
    max-height: 84vh;
    border-left: none;
    border-top: 1px solid rgba(255,255,255,.08);
    border-radius: 20px 20px 0 0;
    transform: translateY(100%);
  }
  .projects-drawer.open {
    transform: translateY(0);
  }

  /* Editor root stacks vertically */
  .editor-root { flex-direction: column; height: 100%; }

  /* Canvas panel fills most of screen */
  .canvas-panel {
    padding: 10px 12px; gap: 8px;
    flex: 1;
    min-height: 0;   /* allow shrink */
    height: 100%;
  }

  .toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }
  .toolbar-left,
  .toolbar-right {
    width: 100%;
    min-width: 0;
  }
  .toolbar-left {
    justify-content: space-between;
    gap: 8px;
    flex-wrap: wrap;
  }
  .toolbar-right {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }
  .toolbar-right > * {
    min-width: 0;
  }
  .toolbar-right .btn-accent,
  .toolbar-right .btn-success,
  .toolbar-right .btn-outline {
    width: 100%;
    min-height: 42px;
    padding: 10px 12px;
    font-size: 12px;
    line-height: 1.15;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    white-space: nowrap;
  }
  .toolbar-right .cutout-menu {
    width: 100%;
  }
  .toolbar-right .cutout-menu > .btn-accent {
    width: 100%;
  }
  .shape-badge {
    width: 100%;
    justify-content: center;
    font-size: 12px;
    padding: 10px 12px;
  }
  .confidence-badge {
    margin-left: auto;
  }
  .accessory-grid {
    grid-template-columns: 1fr;
  }

  /* dim-bar compact */
  .dim-bar {
    padding: 8px 12px; gap: 6px;
    font-size: 12px;
  }
  .dim-input { width: 70px; font-size: 12px; }

  /* Drawer becomes a bottom sheet */
  .drawer {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    top: auto;
    width: 100%; min-width: unset;
    max-height: 88vh;
    border-left: none;
    border-top: 1px solid var(--border);
    border-radius: 20px 20px 0 0;
    z-index: 200;
    transform: translateY(100%);
    box-shadow: 0 -8px 40px rgba(0,0,0,.5);
  }
  .drawer.open { transform: translateY(0); }

  /* Drag handle on sheet */
  .drawer-handle {
    display: flex; justify-content: center; padding: 10px 0 4px;
    flex-shrink: 0;
  }
  .drawer-handle::after {
    content: ''; display: block;
    width: 36px; height: 4px;
    background: var(--border2); border-radius: 2px;
  }

  /* Sheet header */
  .drawer-header { padding: 8px 16px 12px; }

  /* Sheet body scrollable */
  .drawer-body { padding: 10px 16px 40px; }
  .icon-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  .icon-item { min-height: 92px; padding: 10px 4px; }
  .icon-glyph { font-size: 28px; }
  .icon-preview { width: 64px; height: 64px; }
  .icon-symbol { width: 42px; height: 42px; }
  .thickened-controls { grid-template-columns: 1fr; }
  .processing-addon-grid { grid-template-columns: 1fr; }
  .processing-grid-expander { margin-top: 2px; }
  .processing-param-main { flex-direction: column; align-items: stretch; }
  .btn-inline-apply { width: 100%; }
  .modal-overlay { padding: 12px; }
  .cutout-modal { max-height: 92vh; border-radius: 20px; }
  .cutout-modal-header, .cutout-modal-body { padding-left: 16px; padding-right: 16px; }
  .cutout-editor-grid, .cutout-editor-grid.single, .cutout-mini-grid { grid-template-columns: 1fr; }
  .cutout-preview-stage { min-height: 240px; }
  .cutout-preview-canvas { height: 220px; }
  .sink-style-grid { grid-template-columns: 1fr; }
  .cutout-size-card {
    padding-bottom: 48px;
  }
  .cutout-model-toggle {
    left: auto;
    right: 0;
    bottom: 0;
  }
  .cutout-model-toggle-help {
    right: 0;
    left: auto;
    width: min(220px, calc(100vw - 48px));
  }

  /* Download bar compact */
  .download-bar {
    flex-wrap: wrap; padding: 8px 12px; gap: 8px;
    border-radius: var(--radius);
  }
  .btn-download { width: 100%; text-align: center; justify-content: center; }

  /* Canvas hint */
  .canvas-hint { font-size: 11px; }

  /* Overlay when drawer is open */
  .drawer-overlay {
    display: none;
    position: fixed; inset: 0; z-index: 199;
    background: rgba(0,0,0,.4);
  }
  .drawer-overlay.active { display: block; }

  .editor-root.preview-fullscreen {
    flex-direction: row;
  }
  .editor-root.preview-fullscreen .canvas-panel {
    padding: 10px;
  }
  .editor-root.preview-fullscreen .drawer {
    position: fixed;
    top: calc(var(--header-h) + 10px);
    right: 10px;
    bottom: 10px;
    left: auto;
    width: min(430px, 48vw);
    max-height: none;
    min-width: 300px;
    border-radius: 22px;
    border-top: 1px solid var(--border);
    border-left: 1px solid var(--border);
    transform: translateX(110%);
    box-shadow: 0 16px 44px rgba(0,0,0,.46);
  }
  .editor-root.preview-fullscreen .drawer.open {
    transform: translateX(0);
  }
  .editor-root.preview-fullscreen .drawer-handle {
    display: none;
  }
}

/* ════════════════════════════════════════════
   Shape Picker (Step 3)
════════════════════════════════════════════ */
.shape-picker-wrap {
  display: flex; flex-direction: column; align-items: stretch;
  width: 100%; max-width: 600px; padding: 24px 20px;
  gap: 16px; overflow-y: auto; max-height: 100%;
}
.shape-picker-wrap.dim-entry-wrap {
  max-width: min(920px, calc(100vw - 40px));
  padding: 18px 20px;
  gap: 12px;
}
.picker-title { font-size: 20px; font-weight: 700; text-align: center; }
.picker-sub   { font-size: 13px; color: var(--text-2); text-align: center; }

.shape-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px;
}
.saved-projects-panel {
  margin-top: 6px;
  padding: 16px;
  border-radius: 18px;
  border: 1px solid rgba(255,255,255,.08);
  background: linear-gradient(180deg, rgba(255,255,255,.04), rgba(255,255,255,.02));
  box-shadow: inset 0 1px 0 rgba(255,255,255,.03);
}
.saved-projects-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.saved-projects-head h3 {
  font-size: 15px;
  font-weight: 700;
}
.saved-projects-head span {
  font-size: 12px;
  color: var(--text-2);
}
.saved-projects-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.saved-project-card {
  display: flex;
  align-items: center;
  gap: 10px;
}
.saved-project-open {
  flex: 1;
  min-width: 0;
  border: 1px solid rgba(255,255,255,.08);
  background: rgba(255,255,255,.03);
  color: var(--text);
  border-radius: 14px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  cursor: pointer;
  text-align: left;
  transition: border-color .18s ease, background .18s ease, transform .18s ease;
}
.saved-project-open:hover {
  border-color: rgba(128, 149, 189,.38);
  background: rgba(111, 139, 184,.08);
  transform: translateY(-1px);
}
.saved-project-name {
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}
.saved-project-meta {
  font-size: 12px;
  color: var(--text-2);
}
.saved-project-clone {
  width: 42px;
  height: 42px;
  flex-shrink: 0;
  border-radius: 12px;
  border: 1px solid rgba(128, 149, 189,.22);
  background: rgba(111, 139, 184,.08);
  color: #c4b5fd;
  cursor: pointer;
  transition: transform .18s ease, background .18s ease, border-color .18s ease;
}
.saved-project-clone:hover {
  transform: translateY(-1px);
  background: rgba(111, 139, 184,.14);
  border-color: rgba(129,140,248,.36);
}
.saved-project-delete {
  width: 42px;
  height: 42px;
  flex-shrink: 0;
  border-radius: 12px;
  border: 1px solid rgba(244,63,94,.18);
  background: rgba(244,63,94,.08);
  color: #fda4af;
  cursor: pointer;
  transition: transform .18s ease, background .18s ease, border-color .18s ease;
}
.saved-project-delete:hover {
  transform: translateY(-1px);
  background: rgba(244,63,94,.14);
  border-color: rgba(244,63,94,.3);
}
.shape-card {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 16px 8px; gap: 8px;
  background: var(--surface); border: 1.5px solid var(--border);
  border-radius: var(--radius); cursor: pointer;
  transition: border-color .18s, background .18s, transform .12s;
  position: relative; min-height: 90px;
}
.shape-card:hover { border-color: var(--accent); background: #161b26; transform: translateY(-2px); }
.shape-card.suggested { border-color: var(--accent); }
.shape-card-icon  { font-size: 28px; line-height: 1; }
.shape-card-label { font-size: 11px; color: var(--text-2); text-align: center; line-height: 1.3; }
.shape-card-badge {
  position: absolute; top: -8px; right: -6px;
  font-size: 9px; font-weight: 700; padding: 2px 6px;
  background: var(--accent); color: #fff; border-radius: 8px;
  white-space: nowrap;
}
.ai-dims-box {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  padding: 10px 14px;
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.ai-dims-label { font-size: 11px; color: var(--text-2); white-space: nowrap; }
.ai-dims-vals  { font-size: 13px; font-weight: 600; color: var(--yellow); }

/* Dim form */
/* SVG diagram */
.shape-svg-wrap {
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 8px;
  display: flex; justify-content: center;
}
.shape-svg { width: 100%; max-width: 280px; height: auto; display: block; }
.shape-svg text { font-family: var(--dim-font); }

.dim-form { display: flex; flex-direction: column; gap: 10px; }
.dim-form-row {
  display: grid;
  grid-template-columns: minmax(82px, 108px) minmax(118px, 1fr) 34px;
  align-items: center;
  gap: 8px;
}
.dim-form-label-wrap { display: flex; flex-direction: column; width: 110px; flex-shrink: 0; }
.dim-form-label {
  font-size: 13px; color: var(--text); font-weight: 600;
}
.dim-form-hint { font-size: 10px; color: var(--text-3); }
.dim-form-input {
  width: 100%;
  min-height: 38px;
  padding: 7px 10px;
  background: var(--surface2); border: 1px solid var(--border2);
  border-radius: var(--radius-sm); color: var(--text); font-size: 15px;
  font-weight: 600; text-align: center;
  outline: none; transition: border-color .2s;
}
.dim-form-input:focus { border-color: var(--accent); }
.dim-form-unit { font-size: 12px; color: var(--text-3); width: 34px; }
.dim-form-input.ai-filled { border-color: #4ade80; }

.ai-note {
  font-size: 12px; color: var(--text-2);
  padding: 8px 12px; background: var(--surface2);
  border-radius: var(--radius-sm); border-left: 3px solid var(--accent);
}

/* AI detected numbers */
.ai-nums-row {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
  padding: 8px 12px;
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.ai-nums-title { font-size: 11px; color: var(--text-2); white-space: nowrap; }
.ai-num-tag {
  padding: 2px 8px; background: #1e3a1e; border: 1px solid #4ade80;
  color: #4ade80; border-radius: 12px; font-size: 12px; font-weight: 700;
}

/* Mirror buttons */
.mirror-row, .flip-row {
  display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 4px; align-items: center;
}
/* Number chips */
.chip-box {
  background: var(--surface2); border: 1px solid var(--border2);
  border-radius: var(--radius); padding: 10px 12px; margin-bottom: 10px;
}
.chip-title { font-size: 11px; color: var(--text-2); margin-bottom: 8px; }
.chip-list { display: flex; flex-wrap: wrap; gap: 8px; }
.num-chip {
  padding: 6px 14px; background: var(--accent); color: #fff;
  border: none; border-radius: 20px; font-size: 14px; font-weight: 600;
  cursor: pointer; transition: opacity .15s, transform .1s;
}
.num-chip:hover { opacity: .85; transform: scale(1.05); }
.num-chip.chip-used { background: var(--surface2); color: var(--text-3); border: 1px solid var(--border2); }
.dim-form-input.edge-focused {
  border-color: var(--accent) !important;
  box-shadow: 0 0 0 2px rgba(111, 139, 184,.4);
}
.sketch-label-row {
  display: flex; align-items: center; justify-content: space-between;
  margin: 8px 0 4px;
}
.rotate-controls {
  display: flex; align-items: center; gap: 6px;
}
.btn-rotate {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--surface2); border: 1px solid var(--border2);
  color: var(--text); font-size: 16px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: border-color .18s, background .18s;
}
.btn-rotate:hover { border-color: var(--accent); background: #161b26; }
.rot-badge {
  font-size: 11px; color: var(--accent-lt); min-width: 28px; text-align: center;
}
.btn-mirror {
  padding: 7px 14px; background: var(--surface2);
  color: var(--text-2); border: 1px solid var(--border2);
  border-radius: var(--radius-sm); font-size: 12px; cursor: pointer;
  transition: border-color .18s, color .18s;
}
.btn-mirror:hover { border-color: var(--accent); color: var(--accent-lt); }

/* Live preview canvas */
.preview-canvas {
  width: 100%; border-radius: var(--radius-sm);
  background: var(--surface2); border: 1px solid var(--border);
  display: block;
}

/* Two-column layout for dim form */
.dim-form-layout {
  display: grid;
  grid-template-columns: minmax(300px, 1fr) minmax(260px, 320px);
  gap: 18px;
  align-items: flex-start;
}
.dim-form-left  { min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.dim-form-right { min-width: 0; display: flex; flex-direction: column; }

/* Sketch preview */
.sketch-preview-wrap {
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
  height: 200px; display: flex; align-items: center; justify-content: center;
}
.sketch-preview {
  max-width: 100%; max-height: 180px; object-fit: contain; display: block;
  transform-origin: center center;
}

@media (max-width: 700px) {
  .dim-form-layout { grid-template-columns: 1fr; }
  .dim-form-left   { width: 100%; }
  .shape-svg-wrap  { max-width: 100%; }
  .sketch-preview-wrap { max-height: 150px; }
}

@media (max-width: 700px) {
  .shape-grid { grid-template-columns: repeat(2, 1fr); }
  .shape-picker-wrap { padding: 16px; }
}

/* ════════════════════════════════════════════
   Scrollbar styling
════════════════════════════════════════════ */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #4a4a5a; }

/* ════════════════════════════════════════════
   Unified icon glyph system
════════════════════════════════════════════ */
.ic {
  width: 16px; height: 16px;
  display: inline-block;
  vertical-align: -3px;
  color: currentColor;
  flex-shrink: 0;
}
.ic-lg { width: 28px; height: 28px; vertical-align: middle; }
.ic-xl { width: 40px; height: 40px; }

/* Large "mode picker" rows on upload step */
.mode-option {
  display: flex;
  align-items: center;
  gap: 16px;
  width: 100%;
  padding: 20px 22px;
  border: 1px solid rgba(255,255,255,.08);
  border-radius: var(--radius-lg);
  background: linear-gradient(180deg, rgba(255,255,255,.03), rgba(255,255,255,.01));
  color: var(--text);
  cursor: pointer;
  text-align: left;
  transition: border-color .18s ease, background .18s ease, transform .18s ease;
}
.mode-option:hover {
  border-color: rgba(199, 210, 234, .24);
  background: linear-gradient(180deg, rgba(255,255,255,.05), rgba(255,255,255,.015));
  transform: translateY(-1px);
}
.mode-ic {
  width: 44px; height: 44px;
  flex-shrink: 0;
  border-radius: 10px;
  background: rgba(255,255,255,.03);
  border: 1px solid rgba(255,255,255,.06);
  display: flex; align-items: center; justify-content: center;
  color: var(--accent);
}
.mode-title { font-size: 15px; font-weight: 600; letter-spacing: 0.02em; }
.mode-sub   { font-size: 12px; color: var(--text-3); margin-top: 3px; letter-spacing: 0.02em; }

/* Shape picker cards — quiet line icons on flat surface */
.shape-card-icon {
  width: 56px; height: 56px;
  display: flex; align-items: center; justify-content: center;
  color: var(--accent);
  margin-bottom: 2px;
}
.shape-card-icon svg,
.shape-card-icon .ic { width: 40px; height: 40px; }
.shape-card {
  background: rgba(255,255,255,.02);
  border: 1px solid rgba(255,255,255,.06);
  transition: border-color .2s ease, background .2s ease, transform .15s ease;
}
.shape-card:hover {
  border-color: rgba(199, 210, 234, .32);
  background: rgba(255,255,255,.04);
  color: var(--accent-lt);
}
.shape-card.suggested {
  border-color: rgba(199, 210, 234, .42);
  background: rgba(199, 210, 234, .05);
}
.shape-card-label { font-weight: 600; letter-spacing: 0.02em; }

/* Drawing-rules block — blueprint legend */
.drawing-rules {
  background: rgba(255,255,255,.025);
  border: 1px solid rgba(255,255,255,.06);
  border-radius: var(--radius);
}
.drawing-rules-title {
  display: flex; align-items: center; gap: 8px;
  color: var(--text-2); font-weight: 600;
  letter-spacing: 0.14em; text-transform: uppercase;
  font-size: 11px;
}

/* Make all plain cutout-dropdown items show icon + label in line */
.cutout-dropdown button {
  display: flex; align-items: center; gap: 10px;
}
.cutout-dropdown button svg.ic { color: var(--accent); }

/* ════════════════════════════════════════════
   Rotation confirm page
════════════════════════════════════════════ */
.rotate-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 20px 16px;
  max-width: 520px;
  margin: 0 auto;
  width: 100%;
}
.rotate-preview-box {
  /* Square container — works for any rotation angle without clipping */
  width: min(calc(100vw - 32px), 380px);
  height: min(calc(100vw - 32px), 380px);
  background: #111;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
  flex-shrink: 0;
}
.rotate-preview-img {
  /* Fill at most 70% of the box so 90°/270° rotations still fit */
  max-width: 70%;
  max-height: 70%;
  object-fit: contain;
  transition: transform 0.3s ease;
  transform-origin: center center;
  border-radius: 4px;
}
.rotate-controls {
  display: flex;
  gap: 12px;
  margin-bottom: 4px;
}

/* ════════════════════════════════════════════
   Variant sub-picker
════════════════════════════════════════════ */
.variant-grid {
  grid-template-columns: repeat(2, 1fr) !important;
  gap: 12px !important;
}
.variant-card {
  padding: 16px 10px !important;
}
.variant-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 8px;
}
.variant-icon svg {
  filter: drop-shadow(0 0 4px rgba(111, 139, 184,0.4));
}
