/* Maverick Floor Visualizer — matches maverickperformancesolutions.com tokens */
:root {
  --mav-blue: #0E5FD8; --mav-blue-deep: #0A3D8F; --mav-blue-electric: #3D8BFF;
  --mav-charcoal: #1C2026; --mav-charcoal-2: #262B33; --mav-steel: #5A6472; --mav-line: #DDE3EA;
  --mav-bg: #F5F7FA; --mav-ink: #14171C; --mav-safety: #FF8A00; --white: #fff;
  --font-display: "Barlow Condensed", "Arial Narrow", sans-serif; --font-body: "Inter", system-ui, sans-serif;
  --radius: 10px; --shadow: 0 8px 28px rgba(20,23,28,.14); --panel-w: 400px; --header-h: 64px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 14px/1.45 var(--font-body); color: var(--mav-ink); background: var(--mav-bg); overflow: hidden; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; }
a { color: var(--mav-blue); }
h1, h2, h3 { font-family: var(--font-display); text-transform: uppercase; letter-spacing: .02em; margin: 0; }

/* Header */
.app-header { height: var(--header-h); display: flex; align-items: center; gap: 18px; padding: 0 20px; background: var(--white); border-bottom: 1px solid var(--mav-line); }
.logo-link { display: flex; align-items: center; gap: 8px; }
.logo-mark { height: 34px; width: auto; }
.logo { display: block; height: 32px; width: auto; }
.header-text h1 { font-size: 26px; line-height: 1; color: var(--mav-charcoal); }
.tagline { margin: 2px 0 0; color: var(--mav-steel); font-size: 12.5px; }
.header-actions { margin-left: auto; display: flex; gap: 8px; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 10px 16px; border-radius: 8px; border: 1px solid transparent; font-weight: 600; text-decoration: none; cursor: pointer; white-space: nowrap; transition: background .15s, border-color .15s, transform .05s; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--mav-blue); color: #fff; }
.btn-primary:hover { background: var(--mav-blue-deep); }
.btn-secondary { background: #fff; color: var(--mav-blue); border-color: var(--mav-blue); }
.btn-secondary:hover { background: #EDF3FD; }
.btn-ghost { background: transparent; color: var(--mav-charcoal); border-color: var(--mav-line); }
.btn-ghost:hover { background: #fff; border-color: var(--mav-steel); }
.btn-sm { padding: 7px 11px; font-size: 13px; font-weight: 500; }
.btn-block { width: 100%; }
.btn-icon { width: 44px; padding: 0; font-size: 20px; }

/* Layout */
.app-main { display: grid; grid-template-columns: 1fr var(--panel-w); grid-template-rows: 100%; height: calc(100% - var(--header-h)); min-height: 0; }
.stage-wrap { position: relative; display: flex; flex-direction: column; background: #0f1216; min-width: 0; min-height: 0; overflow: hidden; }
.stage { position: relative; flex: 1 1 0; min-height: 0; display: flex; align-items: center; justify-content: center; overflow: hidden; touch-action: none; }
.stage canvas { max-width: 100%; max-height: 100%; width: auto; height: auto; object-fit: contain; display: block; }
.stage canvas[hidden] { display: none; }
.stage-badge { position: absolute; left: 14px; top: 12px; background: rgba(20,23,28,.72); color: #fff; padding: 6px 10px; border-radius: 6px; font-size: 12.5px; font-weight: 600; backdrop-filter: blur(4px); pointer-events: none; }
.stage-note { position: absolute; right: 12px; bottom: 10px; color: #fff; background: rgba(20,23,28,.6); padding: 4px 8px; border-radius: 6px; font-size: 11px; pointer-events: none; }
.render-status { position: absolute; left: 50%; top: 14px; transform: translateX(-50%); background: rgba(14,95,216,.92); color: #fff; padding: 6px 12px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.divider { position: absolute; top: 0; bottom: 0; width: 0; border-left: 2px solid #fff; box-shadow: 0 0 0 1px rgba(0,0,0,.3); cursor: ew-resize; touch-action: none; }
.divider-handle { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 40px; height: 40px; border-radius: 50%; background: #fff; color: var(--mav-charcoal); display: flex; align-items: center; justify-content: center; font-size: 18px; box-shadow: var(--shadow); }
.stage-tools { flex: 0 0 auto; display: flex; align-items: center; gap: 6px; padding: 8px 12px; background: var(--mav-charcoal); border-top: 1px solid #2f3540; }
.tool { background: transparent; color: #cfd6df; border: 1px solid #3a4150; border-radius: 6px; padding: 6px 10px; cursor: pointer; font-size: 13px; font-weight: 500; }
.tool:hover { background: #262B33; color: #fff; }
.tool[aria-pressed="true"] { background: var(--mav-blue); border-color: var(--mav-blue); color: #fff; }
.tool-sep { flex: 1; }

/* Panel */
.panel { min-height: 0; overflow-y: auto; background: #fff; border-left: 1px solid var(--mav-line); padding: 0 18px 0; }
.sheet-header { display: none; }
.step { padding: 16px 0 6px; border-bottom: 1px solid var(--mav-line); }
.step h2 { font-size: 19px; color: var(--mav-charcoal); margin-bottom: 10px; display: flex; align-items: center; gap: 8px; }
.num { display: inline-flex; width: 22px; height: 22px; border-radius: 50%; background: var(--mav-blue); color: #fff; font: 700 13px/22px var(--font-body); justify-content: center; }
.scene-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 10px; }
.scene-card { position: relative; border: 2px solid transparent; border-radius: 8px; overflow: hidden; cursor: pointer; padding: 0; background: #eee; aspect-ratio: 16/10; }
.scene-card img { width: 100%; height: 100%; object-fit: cover; display: block; }
.scene-card span { position: absolute; left: 0; right: 0; bottom: 0; padding: 4px 6px; font-size: 11px; font-weight: 600; color: #fff; background: linear-gradient(transparent, rgba(0,0,0,.75)); text-align: left; line-height: 1.15; }
.scene-card.on { border-color: var(--mav-blue); }
.segmented { display: flex; border: 1px solid var(--mav-line); border-radius: 8px; overflow: hidden; }
.segmented button { flex: 1; padding: 9px 4px; border: 0; background: #fff; cursor: pointer; font-weight: 600; color: var(--mav-steel); }
.segmented button + button { border-left: 1px solid var(--mav-line); }
.segmented button.on, .segmented button[aria-selected="true"] { background: var(--mav-blue); color: #fff; }
.segmented.small button { padding: 6px 8px; font-size: 13px; }
.segmented button.off { color: #9aa3ad; font-weight: 500; }
.segmented button.off::after { content: ' ·'; color: var(--mav-safety); }
:is(.swatch, .scene-card, .tool, .btn, .chip, .segmented button):focus-visible { outline: 3px solid var(--mav-blue-electric); outline-offset: 2px; }
.family-note { color: var(--mav-steel); font-size: 12.5px; margin: 8px 0 4px; }
.color-tools { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.color-tools input[type="search"] { width: 100%; padding: 8px 10px; border: 1px solid var(--mav-line); border-radius: 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid var(--mav-line); background: #fff; border-radius: 999px; padding: 4px 10px; font-size: 12px; cursor: pointer; color: var(--mav-charcoal); }
.chip.on { background: var(--mav-charcoal); color: #fff; border-color: var(--mav-charcoal); }
.color-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; max-height: clamp(220px, 40vh, 440px); overflow-y: auto; padding: 2px; }
.swatch { border: 2px solid transparent; border-radius: 8px; padding: 0; background: #fff; cursor: pointer; text-align: left; overflow: hidden; }
.swatch img, .swatch .solid { display: block; width: 100%; aspect-ratio: 1; object-fit: cover; }
.swatch .lbl { display: block; padding: 4px 5px 5px; font-size: 11px; line-height: 1.2; color: var(--mav-charcoal); }
.swatch .lbl small { display: block; color: var(--mav-steel); font-size: 11px; }
.swatch.on { border-color: var(--mav-blue); box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--mav-blue-electric); }
.swatch.b { border-color: var(--mav-safety); }
.field { margin: 8px 0; }
.field label { display: flex; justify-content: space-between; font-weight: 600; font-size: 12.5px; color: var(--mav-charcoal); margin-bottom: 4px; }
.field .val { color: var(--mav-steel); font-weight: 500; }
.field select, .field input[type="number"] { width: 100%; padding: 8px 10px; border: 1px solid var(--mav-line); border-radius: 8px; background: #fff; }
.field input[type="range"] { width: 100%; accent-color: var(--mav-blue); }
.blend { border: 1px solid var(--mav-line); border-radius: 8px; padding: 8px 10px; margin: 10px 0; }
.blend summary { font-weight: 600; cursor: pointer; color: var(--mav-blue); }
.blend-rows { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.blend-row { display: grid; grid-template-columns: 26px 1fr 42px 24px; align-items: center; gap: 8px; }
.blend-row .sw { width: 26px; height: 26px; border-radius: 6px; border: 1px solid rgba(0,0,0,.15); padding: 0; cursor: pointer; }
.blend-row input[type="range"] { width: 100%; accent-color: var(--mav-blue); }
.blend-row .pct { font-size: 12px; text-align: right; color: var(--mav-steel); }
.blend-row .rm { border: 0; background: transparent; color: var(--mav-steel); cursor: pointer; font-size: 16px; }
.blend-actions { display: flex; gap: 8px; margin-top: 8px; }
.hint { color: var(--mav-steel); font-size: 11.5px; margin: 8px 0 0; }
.mix-slots { display: flex; gap: 8px; }
.mix-slot { flex: 1; aspect-ratio: 1.6; border: 1px dashed var(--mav-line); border-radius: 8px; background: #fff; cursor: pointer; font-size: 11px; color: var(--mav-steel); position: relative; overflow: hidden; }
.mix-slot img { width: 100%; height: 100%; object-fit: cover; display: block; }
.mix-slot .x { position: absolute; top: 2px; right: 4px; color: #fff; text-shadow: 0 0 3px #000; font-size: 14px; }

/* Summary — sticky so the primary CTA is always in reach */
.summary { position: sticky; bottom: 0; background: #fff; padding: 12px 18px 24px; margin: 0 -18px; border-top: 1px solid var(--mav-line); box-shadow: 0 -8px 20px rgba(20,23,28,.06); }
.summary-head { display: flex; gap: 12px; align-items: center; margin-bottom: 10px; }
.summary-head img { width: 56px; height: 56px; border-radius: 8px; object-fit: cover; border: 1px solid var(--mav-line); }
.sum-name { font-family: var(--font-display); font-size: 22px; text-transform: uppercase; line-height: 1; color: var(--mav-charcoal); }
.sum-code { color: var(--mav-steel); font-size: 12.5px; }
.sum-systems { margin-bottom: 12px; }
.sum-systems .lbl { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--mav-steel); margin-bottom: 4px; }
.sys { display: inline-block; background: #EDF3FD; color: var(--mav-blue-deep); border-radius: 6px; padding: 3px 8px; font-size: 12px; font-weight: 600; margin: 0 4px 4px 0; }
.cta-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 8px; }
.cta-row.small { display: flex; flex-wrap: wrap; }
.my-designs { display: flex; gap: 6px; flex-wrap: wrap; margin: 8px 0; }
.my-designs button { border: 1px solid var(--mav-line); border-radius: 6px; background: #fff; padding: 2px; cursor: pointer; width: 46px; height: 46px; overflow: hidden; }
.my-designs img { width: 100%; height: 100%; object-fit: cover; border-radius: 4px; }
.footnote { color: var(--mav-steel); font-size: 11.5px; margin: 8px 0 0; }

/* Modals */
.modal { position: fixed; inset: 0; background: rgba(20,23,28,.55); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 16px; }
.modal[hidden] { display: none; }
.modal-card { position: relative; background: #fff; border-radius: 12px; padding: 22px; width: min(460px, 100%); box-shadow: var(--shadow); max-height: 92vh; overflow: auto; }
.modal-card.wide { width: min(980px, 100%); }
.modal-close { position: absolute; right: 10px; top: 8px; border: 0; background: transparent; font-size: 26px; cursor: pointer; color: var(--mav-steel); }
.modal h2 { font-size: 24px; color: var(--mav-charcoal); }
.modal-sub { color: var(--mav-steel); margin: 4px 0 14px; }
.modal form label { display: block; font-size: 12.5px; font-weight: 600; margin-bottom: 8px; }
.modal form input, .modal form textarea { display: block; width: 100%; padding: 9px 10px; border: 1px solid var(--mav-line); border-radius: 8px; margin-top: 4px; font-weight: 400; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.hp { position: absolute; left: -9999px; }
.form-status { min-height: 18px; font-size: 13px; color: var(--mav-steel); margin: 8px 0 0; }
.upload-stage { position: relative; background: #111; border-radius: 8px; overflow: hidden; aspect-ratio: 16/10; touch-action: none; }
.upload-stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.upload-tools { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 10px; font-size: 13px; }
.upload-tools input[type="number"] { width: 70px; padding: 6px; border: 1px solid var(--mav-line); border-radius: 6px; margin-left: 4px; }

/* Present mode (?present=1): stage + tools only, for reps showing a client */
body.present .app-header, body.present .panel, body.present .mobile-bar { display: none !important; }
body.present .app-main { grid-template-columns: 1fr; height: 100%; }

/* Headless review renders (?shot=1): stage only, edge to edge */
body.shot .app-header, body.shot .panel, body.shot .stage-tools, body.shot .mobile-bar, body.shot .stage-badge, body.shot .stage-note, body.shot .render-status { display: none !important; }
body.shot .app-main { grid-template-columns: 1fr; height: 100%; }
body.shot .stage { background: #000; }

/* Mobile */
.sheet-backdrop, .mobile-bar { display: none; }
@media (max-height: 820px) and (min-width: 881px) { .summary { position: static; box-shadow: none; } }
@media (max-width: 880px), (max-width: 1100px) and (orientation: portrait) {
  :root { --header-h: 56px; }
  .app-header { gap: 10px; padding: 0 12px; }
  .logo { height: 26px; } .logo-mark { height: 28px; }
  .header-text h1 { font-size: 18px; }
  .tool { white-space: nowrap; padding: 6px 8px; font-size: 12px; }
  .tagline, .hide-sm { display: none; }
  .app-main { grid-template-columns: 1fr; }
  .stage-wrap { height: calc(100% - 64px); }
  .stage-tools { overflow-x: auto; }
  .panel { position: fixed; left: 0; right: 0; bottom: 0; height: 78vh; padding-bottom: env(safe-area-inset-bottom); border-radius: 16px 16px 0 0; border-left: 0; box-shadow: var(--shadow); transform: translateY(100%); transition: transform .25s; z-index: 40; padding-top: 0; }
  body.sheet-open .panel { transform: none; }
  .sheet-grabber { width: 40px; height: 4px; border-radius: 2px; background: var(--mav-line); margin: 8px auto 0; }
  .sheet-header { display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; background: #fff; padding: 12px 0 8px; z-index: 1; }
  .sheet-title { font: 700 20px var(--font-display); text-transform: uppercase; margin: 0; color: var(--mav-charcoal); }
  .sheet-close { border: 0; background: transparent; font-size: 28px; line-height: 1; cursor: pointer; }
  .sheet-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 30; }
  body.sheet-open .sheet-backdrop { display: block; }
  .mobile-bar { display: flex; gap: 8px; position: fixed; left: 0; right: 0; bottom: 0; padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); background: #fff; border-top: 1px solid var(--mav-line); z-index: 20; }
  .mobile-bar .btn { flex: 1; }
  .mobile-bar .btn-icon { flex: 0 0 44px; }
  .scene-grid { grid-template-columns: repeat(4, 1fr); }
  .color-grid { grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); max-height: none; }
  .swatch .lbl { font-size: 12.5px; }
  .swatch .lbl small { font-size: 11px; }
  .scene-card span { font-size: 11.5px; }
}
@media (prefers-reduced-motion: reduce) { .panel { transition: none; } }
