/* Van builder core styles. Light and dark through [data-theme]; the phone layout starts at 860px.
   Feature modules: use the tokens and the shared classes below (.vb-btn, .vb-card, .vb-field ...) so every
   panel looks the same. Put module-only rules in your own css file, prefixed with your module name. */

:root {
  --vb-accent: #e8792b;
  --vb-on-accent: #ffffff;
  --vb-bg: #f3f5f8;
  --vb-surface: #ffffff;
  --vb-surface-2: #f0f2f5;
  --vb-border: #dce1e7;
  --vb-text: #1b2027;
  --vb-muted: #5d6875;
  --vb-select: #2f7bf0;
  --vb-danger: #d6362c;
  --vb-warn-bg: #fff4dc;
  --vb-warn-text: #7a4a00;
  --vb-ok: #1f8a4c;
  --vb-shadow: 0 6px 24px rgba(18, 24, 32, 0.14);
  --vb-radius: 10px;
  --vb-bp-bg: #f4f6f8;
  --vb-bp-body: #dfe4ea;
  --vb-bp-floor: #ffffff;
  --vb-bp-line: #27313d;
  --vb-bp-grid: #8a97a6;
  --vb-rail: 68px;
  --vb-panel-w: 324px;
  --vb-insp-w: 300px;
  --vb-font: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, Roboto, "Helvetica Neue", Arial, sans-serif;
}

:root[data-theme="dark"] {
  --vb-bg: #111418;
  --vb-surface: #1a1e24;
  --vb-surface-2: #232830;
  --vb-border: #303742;
  --vb-text: #e9edf2;
  --vb-muted: #9aa5b2;
  --vb-select: #5b9bff;
  --vb-danger: #ff6a5f;
  --vb-warn-bg: #3a2e12;
  --vb-warn-text: #ffd58a;
  --vb-ok: #4cc27f;
  --vb-shadow: 0 6px 24px rgba(0, 0, 0, 0.5);
  --vb-bp-bg: #14181d;
  --vb-bp-body: #2a3038;
  --vb-bp-floor: #1d2228;
  --vb-bp-line: #c9d2dc;
  --vb-bp-grid: #6f7c8b;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font: 14px/1.4 var(--vb-font);
  color: var(--vb-text);
  background: var(--vb-bg);
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-text-size-adjust: 100%;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
h2, h3, p, ul, dl, dd { margin: 0; }
ul { padding: 0; list-style: none; }
.vb-icon { flex: none; display: block; }
:focus-visible { outline: 2px solid var(--vb-select); outline-offset: 1px; }

/* ---- frame ---- */
.vb-app { height: 100vh; height: 100dvh; display: grid; grid-template-rows: auto auto minmax(0, 1fr) auto; }
.vb-header { display: flex; align-items: center; gap: 12px; padding: 6px 12px; background: var(--vb-surface); border-bottom: 1px solid var(--vb-border); min-height: 46px; }
.vb-brand { display: flex; align-items: center; gap: 9px; min-width: 0; flex: 1 1 0; }
.vb-brand-mark { width: 22px; height: 22px; border-radius: 6px; background: var(--vb-accent); flex: none; }
.vb-brand-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.15; }
.vb-brand-text strong { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vb-brand-text span { font-size: 11.5px; color: var(--vb-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vb-brand-text span:empty { display: none; }
.vb-header-right { display: flex; justify-content: flex-end; gap: 6px; flex: 1 1 0; }

.vb-modes { display: flex; background: var(--vb-surface-2); border-radius: 9px; padding: 3px; gap: 2px; flex: none; }
.vb-mode { display: flex; align-items: center; gap: 6px; border: 0; background: transparent; padding: 6px 12px; border-radius: 7px; font-weight: 600; color: var(--vb-muted); }
.vb-mode[aria-selected="true"] { background: var(--vb-surface); color: var(--vb-text); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.16); }

.vb-toolbar { display: flex; align-items: center; gap: 4px; padding: 5px 10px; background: var(--vb-surface); border-bottom: 1px solid var(--vb-border); overflow-x: auto; scrollbar-width: none; }
.vb-toolbar::-webkit-scrollbar { display: none; }
.vb-tool-group { display: flex; align-items: center; gap: 2px; padding-right: 6px; margin-right: 2px; border-right: 1px solid var(--vb-border); flex: none; }
.vb-tool-group:last-of-type { border-right: 0; }
.vb-tool { display: inline-flex; align-items: center; gap: 6px; min-width: 34px; height: 34px; padding: 0 8px; justify-content: center; border: 0; border-radius: 8px; background: transparent; white-space: nowrap; }
.vb-tool:hover:not(:disabled), .vb-icon-btn:hover { background: var(--vb-surface-2); }
.vb-tool:disabled { opacity: 0.35; cursor: default; }
.vb-tool.is-active { background: var(--vb-accent); color: var(--vb-on-accent); }
.vb-tool-field { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: var(--vb-muted); padding: 0 4px; white-space: nowrap; }
.vb-tool-select { height: 30px; padding: 0 22px 0 8px; width: auto; }
.vb-saved { margin-left: auto; font-size: 12px; color: var(--vb-muted); white-space: nowrap; padding-left: 8px; }
.vb-saved.is-warn { color: var(--vb-danger); }
.vb-icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; border: 0; border-radius: 8px; background: transparent; flex: none; }

.vb-body { display: flex; min-height: 0; }
.vb-sidebar { display: flex; flex: none; background: var(--vb-surface); border-right: 1px solid var(--vb-border); min-height: 0; }
.vb-tabs { width: var(--vb-rail); display: flex; flex-direction: column; gap: 2px; padding: 6px 4px; overflow-y: auto; scrollbar-width: none; border-right: 1px solid var(--vb-border); }
.vb-tabs::-webkit-scrollbar { display: none; }
.vb-tab { position: relative; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 8px 2px 6px; border: 0; border-radius: 9px; background: transparent; color: var(--vb-muted); font-size: 11px; font-weight: 600; flex: none; }
.vb-tab:hover { background: var(--vb-surface-2); }
.vb-tab[aria-selected="true"] { color: var(--vb-accent); background: color-mix(in srgb, var(--vb-accent) 12%, transparent); }
.vb-tab-label { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vb-tab-badge { position: absolute; top: 3px; right: 6px; min-width: 16px; padding: 0 4px; border-radius: 8px; background: var(--vb-accent); color: var(--vb-on-accent); font-size: 10px; line-height: 16px; text-align: center; }
.vb-panels { width: var(--vb-panel-w); min-height: 0; display: none; }
.vb-sidebar.is-open .vb-panels { display: block; }
.vb-panel { height: 100%; overflow-y: auto; padding: 12px; overscroll-behavior: contain; }

.vb-stage { position: relative; flex: 1 1 0; min-width: 0; min-height: 0; overflow: hidden; background: var(--vb-bg); }
.vb-view3d, .vb-labels { position: absolute; inset: 0; }
.vb-canvas3d { display: block; width: 100%; height: 100%; touch-action: none; outline: none; }
.vb-view3d.is-dragging { cursor: grabbing; }
.vb-view3d.is-measuring { cursor: crosshair; }
.vb-labels { pointer-events: none; overflow: hidden; }
.vb-blueprint { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
.vb-app[data-mode="blueprint"] .vb-view3d, .vb-app[data-mode="blueprint"] .vb-labels { visibility: hidden; }

.vb-label { position: absolute; left: 0; top: 0; padding: 2px 6px; border-radius: 5px; font-size: 11.5px; font-weight: 600; line-height: 1.25; white-space: pre; text-align: center; background: rgba(20, 24, 30, 0.86); color: #fff; will-change: transform; }
.vb-label-dist { background: var(--vb-select); }
.vb-label-measure { background: #ff8a1f; color: #1b1205; font-size: 12.5px; }

.vb-hint { position: absolute; top: 10px; left: 50%; transform: translateX(-50%); max-width: min(92%, 640px); padding: 6px 12px; border-radius: 8px; background: rgba(20, 24, 30, 0.88); color: #fff; font-size: 12.5px; text-align: center; pointer-events: none; }
.vb-selbar { position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); display: flex; gap: 2px; padding: 4px; border-radius: 12px; background: var(--vb-surface); border: 1px solid var(--vb-border); box-shadow: var(--vb-shadow); }
.vb-selbtn { display: flex; align-items: center; gap: 6px; border: 0; background: transparent; padding: 7px 10px; border-radius: 9px; font-weight: 600; font-size: 12.5px; white-space: nowrap; }
.vb-selbtn:hover { background: var(--vb-surface-2); }
.vb-selbtn.is-danger { color: var(--vb-danger); }
.vb-toasts { position: absolute; top: 10px; right: 10px; display: flex; flex-direction: column; gap: 6px; align-items: flex-end; z-index: 5; max-width: min(360px, 90%); }
.vb-toast { padding: 9px 13px; border-radius: 9px; background: #1f252d; color: #fff; font-size: 13px; box-shadow: var(--vb-shadow); cursor: pointer; }
.vb-toast-success { background: #1f7a45; }
.vb-toast-warn { background: #8a5a00; }
.vb-toast-error { background: #b3261e; }
.vb-loading { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; padding: 24px; text-align: center; background: var(--vb-bg); color: var(--vb-muted); font-size: 15px; z-index: 6; }
.vb-loading.is-error { color: var(--vb-danger); }

.vb-inspector { width: var(--vb-insp-w); flex: none; overflow-y: auto; padding: 12px; background: var(--vb-surface); border-left: 1px solid var(--vb-border); overscroll-behavior: contain; }
.vb-insp-head { display: flex; align-items: center; gap: 6px; margin-bottom: 8px; }
.vb-insp-head h2 { font-size: 15px; flex: 1; }
.vb-insp-name { font-weight: 600; flex: 1; min-width: 0; }
.vb-insp-buy { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.vb-insp-size { margin-top: 5px; font-size: 11.5px; }
.vb-insp-actions { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0; }

.vb-stats { display: flex; align-items: stretch; gap: 0; background: var(--vb-surface); border-top: 1px solid var(--vb-border); overflow-x: auto; scrollbar-width: thin; min-height: 42px; padding-bottom: env(safe-area-inset-bottom); }
.vb-widget { display: flex; flex-direction: column; justify-content: center; padding: 5px 14px; border-right: 1px solid var(--vb-border); white-space: nowrap; flex: none; font-size: 13px; }
.vb-widget-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--vb-muted); }
.vb-widget.is-warn strong { color: var(--vb-danger); }

/* ---- shared building blocks for every panel ---- */
.vb-btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 13px; border-radius: 8px; border: 1px solid var(--vb-border); background: var(--vb-surface); font-weight: 600; text-decoration: none; color: var(--vb-text); line-height: 1.2; }
.vb-btn:hover { background: var(--vb-surface-2); }
.vb-btn:disabled { opacity: 0.45; cursor: default; }
.vb-btn-primary { background: var(--vb-accent); border-color: var(--vb-accent); color: var(--vb-on-accent); }
.vb-btn-primary:hover { background: var(--vb-accent); filter: brightness(1.06); }
.vb-btn-danger { color: var(--vb-danger); }
.vb-btn-small { padding: 6px 9px; font-size: 12.5px; }
.vb-btn-block { width: 100%; }
.vb-link { border: 0; background: none; padding: 0; color: var(--vb-select); text-decoration: underline; text-align: left; }
.vb-buy { display: inline-flex; align-items: center; gap: 6px; padding: 7px 11px; border-radius: 8px; border: 1px solid var(--vb-border); background: var(--vb-surface); color: var(--vb-text); font-weight: 600; font-size: 12.5px; text-decoration: none; white-space: nowrap; flex: none; }
.vb-buy:hover { border-color: var(--vb-accent); color: var(--vb-accent); }
.vb-buy-compact { padding: 5px 8px; font-size: 12px; }
.vb-disclosure { margin-top: 12px; font-size: 11px; color: var(--vb-muted); line-height: 1.35; }
.vb-price { font-weight: 600; }
.vb-price small { font-weight: 400; color: var(--vb-muted); }
.vb-input, .vb-select { width: 100%; min-width: 0; height: 34px; padding: 0 9px; border-radius: 8px; border: 1px solid var(--vb-border); background: var(--vb-surface); color: var(--vb-text); }
textarea.vb-input { height: auto; padding: 8px 9px; resize: vertical; }
.vb-input:disabled, .vb-select:disabled { background: var(--vb-surface-2); color: var(--vb-muted); }
.vb-color { width: 44px; height: 30px; padding: 0; border: 1px solid var(--vb-border); border-radius: 6px; background: none; }
.vb-field { display: flex; flex-direction: column; gap: 3px; font-size: 11.5px; color: var(--vb-muted); min-width: 0; }
.vb-field-row { flex-direction: row; align-items: center; justify-content: space-between; gap: 10px; margin-top: 8px; }
.vb-field-row .vb-select { width: 110px; }
.vb-grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.vb-grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.vb-row { display: flex; align-items: center; gap: 8px; }
.vb-row-between { justify-content: space-between; }
.vb-section { margin-top: 14px; }
.vb-section-title { font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--vb-muted); margin-bottom: 6px; }
.vb-panel-title { font-size: 16px; margin-bottom: 4px; }
.vb-muted { color: var(--vb-muted); font-size: 12.5px; }
.vb-note { padding: 8px 10px; border-radius: 8px; background: var(--vb-surface-2); font-size: 12.5px; margin: 8px 0; }
.vb-note-warn { background: var(--vb-warn-bg); color: var(--vb-warn-text); }
.vb-card { border: 1px solid var(--vb-border); border-radius: var(--vb-radius); padding: 10px; background: var(--vb-surface); }
.vb-card + .vb-card { margin-top: 8px; }
.vb-chip { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 999px; background: var(--vb-surface-2); font-size: 11.5px; color: var(--vb-muted); }
.vb-list li { padding: 4px 0; font-size: 13px; }
.vb-kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; font-size: 13px; }
.vb-kv dt { color: var(--vb-muted); }
.vb-kv dd { text-align: right; font-variant-numeric: tabular-nums; }
.vb-kv dd.is-bad { color: var(--vb-danger); font-weight: 600; }
.vb-notes { min-height: 64px; }
.vb-empty { padding: 18px 8px; text-align: center; color: var(--vb-muted); }
.vb-swatch { width: 18px; height: 18px; border-radius: 5px; border: 1px solid var(--vb-border); flex: none; }
.vb-phone-only { display: none; }

.vb-popover { position: fixed; z-index: 40; min-width: 220px; max-width: min(340px, calc(100vw - 16px)); max-height: calc(100dvh - 80px); overflow-y: auto; padding: 5px; border-radius: 11px; background: var(--vb-surface); border: 1px solid var(--vb-border); box-shadow: var(--vb-shadow); }
.vb-menu-title { padding: 7px 9px 3px; font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--vb-muted); }
.vb-menu-item { display: flex; align-items: center; gap: 8px; width: 100%; padding: 8px 9px; border: 0; border-radius: 7px; background: transparent; text-align: left; }
.vb-menu-item:hover { background: var(--vb-surface-2); }
.vb-menu-mark { width: 16px; flex: none; color: var(--vb-accent); font-weight: 700; display: inline-flex; justify-content: center; }
.vb-menu-item kbd { margin-left: auto; font: inherit; font-size: 11px; color: var(--vb-muted); }

.vb-overlay { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; padding: 16px; background: rgba(10, 13, 18, 0.5); }
.vb-modal { width: min(460px, 100%); max-height: calc(100dvh - 32px); display: flex; flex-direction: column; border-radius: 14px; background: var(--vb-surface); box-shadow: var(--vb-shadow); }
.vb-modal-wide { width: min(820px, 100%); }
.vb-modal-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 12px 4px 16px; }
.vb-modal-head h2 { font-size: 16px; }
.vb-modal-body { padding: 8px 16px; overflow-y: auto; }
.vb-modal-body p + * { margin-top: 10px; }
.vb-modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 16px 16px; }

/* ---- embed (?embed=1): compact chrome for use inside an iframe ---- */
.vb-embed .vb-brand { display: none; }
.vb-embed .vb-header { min-height: 40px; padding: 4px 8px; justify-content: space-between; }
.vb-embed .vb-header-right { flex: none; }
.vb-embed .vb-saved { display: none; }
.vb-embed .vb-toolbar { padding: 3px 8px; }

/* ---- phone: the sidebar and the inspector become bottom sheets ---- */
@media (max-width: 860px), (max-width: 960px) and (max-height: 500px) {
  .vb-app { display: flex; flex-direction: column; }
  .vb-body { display: contents; }
  .vb-header { order: 0; padding: 5px 8px; gap: 6px; min-height: 42px; }
  .vb-brand-text span, .vb-brand-mark { display: none; }
  .vb-mode { padding: 6px 9px; }
  .vb-toolbar { order: 1; padding: 4px 6px; }
  .vb-tool.has-label span, .vb-tool-field > span, .vb-saved { display: none; }
  .vb-stage { order: 2; }
  .vb-stats { order: 3; min-height: 36px; padding-bottom: 0; }
  .vb-sidebar { order: 4; display: block; border-right: 0; border-top: 1px solid var(--vb-border); padding-bottom: env(safe-area-inset-bottom); }
  .vb-tabs { width: auto; flex-direction: row; overflow-x: auto; overflow-y: hidden; padding: 4px 6px; border-right: 0; }
  .vb-tab { min-width: 64px; padding: 6px 6px 4px; }
  .vb-panels, .vb-inspector { position: fixed; left: 0; right: 0; bottom: calc(57px + env(safe-area-inset-bottom)); width: auto; max-height: 58dvh; height: 58dvh; z-index: 20; border: 0; border-top: 1px solid var(--vb-border); border-radius: 16px 16px 0 0; background: var(--vb-surface); box-shadow: 0 -8px 28px rgba(0, 0, 0, 0.22); }
  .vb-inspector { display: none; height: auto; }
  .vb-inspector.is-open { display: block; }
  .vb-phone-only { display: inline-flex; }
  .vb-selbar { bottom: 8px; max-width: calc(100% - 12px); overflow-x: auto; }
  .vb-selbtn span { display: none; }
  .vb-selbtn { padding: 9px 11px; }
  .vb-hint { font-size: 12px; }
  .vb-input, .vb-select { height: 38px; font-size: 16px; }
  .vb-tool-select { height: 32px; font-size: 13px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
