@font-face { font-family: 'Jost'; src: url('../fonts/jost-latin-400-normal.woff2') format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Jost'; src: url('../fonts/jost-latin-500-normal.woff2') format('woff2'); font-weight: 500; font-display: swap; }
@font-face { font-family: 'Marianina'; src: url('../fonts/MarianinaFY-Medium.otf') format('opentype'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Marianina'; src: url('../fonts/MarianinaFY-Bold.otf') format('opentype'); font-weight: 700; font-display: swap; }

:root {
  --ink: #000;
  --muted: #6b6b6b;
  --line: #e4e2de;
  --soft: #f6f5f2;
  --bg: #fff;
  --warn: #9a3412;
  --header: 76px;
  --panel: 380px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body.dnd { user-select: none; -webkit-user-select: none; }
html, body { margin: 0; height: 100%; }
body {
  font-family: 'Jost', Arial, sans-serif;
  font-size: 15px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

.label, h1, h2, button, .button, label, summary, .site-header a {
  font-family: 'Marianina', Arial, sans-serif;
  text-transform: uppercase;
  letter-spacing: 1px;
}

/* Header */
.site-header {
  height: var(--header);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 0 28px;
  border-bottom: 1px solid var(--line);
  background: #fff;
  position: relative;
  z-index: 5;
}
.site-header a { color: var(--ink); text-decoration: none; font-size: 13px; font-weight: 700; }
.site-header .logo { justify-self: center; display: block; }
.site-header .logo img { height: 22px; display: block; }
.site-header .appt { justify-self: end; border-bottom: 1px solid var(--ink); padding-bottom: 2px; }
.site-header .back { display: inline-flex; align-items: center; gap: 8px; }
.site-header .back svg { display: block; }

/* Layout */
.app {
  display: grid;
  grid-template-columns: 1fr var(--panel);
  height: calc(100vh - var(--header));
  height: calc(100dvh - var(--header));
}
.stage { position: relative; background: var(--soft); overflow: hidden; }
#scene { display: block; width: 100%; height: 100%; touch-action: none; cursor: grab; }
#scene.dragging { cursor: grabbing; }
#scene.over { cursor: pointer; }

.stage-tools { position: absolute; top: 18px; left: 18px; display: flex; gap: 6px; align-items: center; }
.stage-tools .sep { width: 10px; }
.stage-tools .icon { width: 34px; height: 34px; padding: 0; font-family: 'Jost', Arial, sans-serif; font-size: 18px; }
.stage-tools button { background: rgba(255,255,255,.92); }
.stage-hint {
  position: absolute; left: 18px; bottom: 14px; margin: 0;
  font-size: 13px; color: var(--muted);
  pointer-events: none;
}
.dims {
  position: absolute; right: 18px; bottom: 14px;
  font-family: 'Marianina', Arial, sans-serif; text-transform: uppercase; letter-spacing: 1px;
  font-size: 12px; font-weight: 700;
  background: rgba(255,255,255,.92); padding: 6px 10px;
}

/* Panel */
.panel { border-left: 1px solid var(--line); background: #fff; display: flex; flex-direction: column; min-height: 0; }
.panel-inner { flex: 1; overflow-y: auto; min-height: 0; }
.panel-inner { padding: 28px 28px 40px; }
h1 { font-size: 26px; font-weight: 400; line-height: 1.15; margin: 0 0 10px; }
h2 { font-size: 14px; font-weight: 700; margin: 0 0 12px; }
.intro { margin: 0 0 8px; }
.small { font-size: 13px; color: var(--muted); margin: 6px 0 0; }
.block { border-top: 1px solid var(--line); padding: 22px 0; }
.block:first-of-type { margin-top: 18px; }

/* Buttons */
button, .button {
  appearance: none;
  border: 1px solid var(--ink);
  background: #fff;
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
  padding: 9px 14px;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
  display: inline-block;
  line-height: 1.2;
  transition: background .15s, color .15s;
}
button:hover, .button:hover { background: var(--ink); color: #fff; }
button:disabled { opacity: .3; cursor: not-allowed; background: #fff; color: var(--ink); }
button.primary { background: var(--ink); color: #fff; }
button.primary:hover { background: #333; }
button.ghost { border-color: transparent; color: var(--muted); padding-left: 0; padding-right: 0; }
button.ghost:hover { background: none; color: var(--ink); }

/* Fields */
.field { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 0 0 14px; }
.field.col { flex-direction: column; align-items: stretch; }
.field label { font-size: 12px; font-weight: 700; }
select, input[type=number] {
  font: inherit; font-size: 14px;
  border: 1px solid var(--line); background: #fff; padding: 7px 10px; color: var(--ink);
  border-radius: 0;
}
select:focus, input:focus { outline: 1px solid var(--ink); }
.unit { display: flex; align-items: center; gap: 6px; }
.unit input { width: 90px; }
.unit span { color: var(--muted); font-size: 13px; }
.stepper { display: flex; align-items: center; }
.stepper button { width: 34px; height: 34px; padding: 0; font-size: 16px; }
.stepper output { width: 40px; text-align: center; font-weight: 500; }
.range { display: flex; align-items: center; gap: 10px; }
.range input { width: 140px; accent-color: #000; }
.range output { width: 52px; text-align: right; font-size: 13px; }
.choices { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.choices.three { grid-template-columns: 1fr 1fr 1fr; }
.choices button { font-size: 11px; padding: 10px 8px; }
.choices button[aria-pressed=true] { background: var(--ink); color: #fff; }
details.wall summary { cursor: pointer; font-size: 12px; font-weight: 700; margin-bottom: 12px; list-style: none; }
details.wall summary::after { content: ' +'; }
details.wall[open] summary::after { content: ' −'; }

/* Tiles */
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 12px 0 16px; }
.tile {
  aspect-ratio: 1 / 1;
  display: flex; flex-direction: column; align-items: center; justify-content: space-between;
  padding: 12px 10px 10px; border: 1px solid var(--line); background: #fff;
  font-family: 'Jost', Arial, sans-serif; text-transform: none; letter-spacing: 0; font-weight: 400;
  text-align: center; cursor: grab; user-select: none; -webkit-user-select: none;
  touch-action: manipulation;
}
.tile:hover { background: #fff; color: var(--ink); border-color: var(--ink); }
.tile:active { cursor: grabbing; }
.tile svg { width: 62%; height: auto; flex: 1; min-height: 0; max-height: 50%; }
.tile .t-name { font-size: 13px; line-height: 1.25; margin-top: 6px; }
.tile .t-meta { font-size: 11px; color: var(--muted); line-height: 1.3; }
.tile .t-price { font-size: 13px; font-weight: 500; margin-top: 4px; }
details.pal-group { border-top: 1px solid var(--line); }
details.pal-group summary {
  cursor: pointer; list-style: none; padding: 14px 0; display: flex; justify-content: space-between;
  font-size: 12px; font-weight: 700;
}
details.pal-group summary::-webkit-details-marker, details.wall summary::-webkit-details-marker { display: none; }
details.pal-group .tiles { margin-top: 0; }
.note { font-size: 13px; background: var(--soft); padding: 10px 12px; margin: 10px 0 4px; }

/* Drag and drop */
.drag-chip {
  position: fixed; left: 0; top: 0; z-index: 30; pointer-events: none;
  background: var(--ink); color: #fff; font-size: 13px; padding: 6px 10px;
  transform: translate(-50%, -140%); display: none; white-space: nowrap;
}
.drop-hint {
  position: absolute; top: 18px; right: 18px; background: var(--ink); color: #fff;
  font-family: 'Marianina', Arial, sans-serif; text-transform: uppercase; letter-spacing: 1px; font-size: 12px; font-weight: 700;
  padding: 8px 12px; display: none;
}
body.dnd, body.dnd * { cursor: grabbing !important; }
body.dnd .drop-hint { display: block; }

/* Sticky call to action */
.cta-bar { border-top: 1px solid var(--ink); background: #fff; padding: 14px 28px 16px; }
.cta-total { display: flex; align-items: baseline; gap: 10px; margin-bottom: 10px; }
.cta-total span { font-family: 'Marianina', Arial, sans-serif; text-transform: uppercase; letter-spacing: 1px; font-weight: 700; font-size: 13px; }
.cta-total strong { font-size: 22px; font-weight: 500; }
.cta-total .cta-details { margin-left: auto; font-size: 13px; color: var(--muted); }
.cta-buttons { display: grid; grid-template-columns: 1.2fr 1fr; gap: 8px; }
.cta-buttons > * { padding: 12px 8px; font-size: 11px; display: flex; align-items: center; justify-content: center; }

/* Selected */
.selected { background: var(--soft); padding: 14px; }
.sel-name { font-weight: 500; }
.sel-meta { font-size: 13px; color: var(--muted); }
.selected .field { margin: 10px 0 0; }
.selected select { max-width: 60%; }
.sel-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.sel-actions .icon { width: 34px; height: 34px; padding: 0; font-family: 'Jost', Arial, sans-serif; font-size: 16px; }

/* Summary */
.lines { list-style: none; padding: 0; margin: 0 0 10px; }
.lines li { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.lines li span:last-child { white-space: nowrap; }
.lines li.empty { color: var(--muted); }
.total { display: flex; justify-content: space-between; align-items: baseline; padding: 10px 0 0; }
.total span { font-family: 'Marianina', Arial, sans-serif; text-transform: uppercase; letter-spacing: 1px; font-weight: 700; font-size: 14px; }
.total strong { font-size: 22px; font-weight: 500; }
.warnings p { font-size: 13px; color: var(--warn); margin: 8px 0 0; }
.actions { display: grid; gap: 8px; margin: 18px 0 8px; }
.actions .row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.actions .primary { padding: 14px; font-size: 13px; }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 20px);
  background: var(--ink); color: #fff; padding: 10px 16px; font-size: 14px;
  opacity: 0; pointer-events: none; transition: .2s; z-index: 20; max-width: 90vw;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* Mobile */
@media (max-width: 860px) {
  :root { --header: 60px; }
  .site-header { padding: 0 16px; }
  .site-header .logo img { height: 16px; }
  .site-header .back span { display: none; }
  .site-header .appt { display: none; }
  .site-header .logo img { max-width: 46vw; }
  .app { display: block; height: auto; }
  .stage { height: 52vh; height: 52svh; position: sticky; top: 0; z-index: 2; }
  .panel { border-left: 0; overflow: visible; }
  .panel-inner { padding: 22px 18px 40px; }
  .stage-hint { display: none; }
  .panel { display: block; }
  .panel-inner { overflow: visible; }
  .cta-bar { position: sticky; bottom: 0; padding: 12px 18px 14px; z-index: 3; }
  .stage-tools { top: 12px; left: 12px; }
}

/* Inspiration page */
.crumb { display: inline-block; font-size: 13px; color: var(--muted); text-decoration: none; margin-bottom: 14px; }
.crumb:hover { color: var(--ink); }
.button.primary { background: var(--ink); color: #fff; }
.button.primary:hover { background: #333; }
.gallery { max-width: 1320px; margin: 0 auto; padding: 56px 28px 80px; }
.gallery-intro { max-width: 640px; margin: 0 auto 48px; text-align: center; }
.gallery-intro h1 { font-size: 34px; margin-bottom: 14px; }
.gallery-intro p { margin: 0 0 24px; }
.gallery-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.gallery-actions .button { padding: 14px 22px; font-size: 13px; }
.presets { display: grid; grid-template-columns: repeat(3, 1fr); gap: 28px; }
.preset { display: flex; flex-direction: column; }
.preset-img { display: block; aspect-ratio: 9 / 7; background: var(--soft); overflow: hidden; }
.preset-img img { width: 100%; height: 100%; object-fit: cover; display: block; opacity: 0; transition: opacity .4s, transform .6s; }
.preset.ready .preset-img img { opacity: 1; }
.preset-img:hover img { transform: scale(1.03); }
.preset-body { padding: 16px 0 0; display: flex; flex-direction: column; flex: 1; }
.preset-body h2 { font-size: 18px; font-weight: 400; margin: 0 0 6px; }
.preset-body p { margin: 0 0 16px; color: var(--muted); font-size: 14px; flex: 1; }
.preset-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.preset-price { font-size: 18px; font-weight: 500; }
.gallery-outro { max-width: 640px; margin: 56px auto 0; text-align: center; }
.gallery-outro .note { margin-bottom: 20px; }
.gallery-outro .button { padding: 14px 22px; font-size: 13px; }
@media (max-width: 1000px) { .presets { grid-template-columns: 1fr 1fr; } }
@media (max-width: 640px) {
  .presets { grid-template-columns: 1fr; }
  .gallery { padding: 36px 18px 60px; }
  .gallery-intro h1 { font-size: 26px; }
}

/* Selection card in the 3D view */
.sel-card {
  position: absolute; left: 18px; bottom: 44px; width: 330px; z-index: 4;
  background: #fff; border: 1px solid var(--ink); padding: 14px 16px 16px;
}
.sel-card .sel-name { font-weight: 500; padding-right: 28px; }
.sel-card .sel-meta { font-size: 13px; color: var(--muted); }
.sel-card .field { margin: 10px 0 0; }
.sel-card select { max-width: 64%; }
.sel-card .sel-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.sel-card .sel-actions .icon { width: 34px; height: 34px; padding: 0; font-family: 'Jost', Arial, sans-serif; font-size: 16px; }
.sel-close { position: absolute; top: 8px; right: 8px; width: 28px; height: 28px; padding: 0; border: 0; font-family: 'Jost', Arial, sans-serif; font-size: 20px; line-height: 1; }

/* Header button */
.site-header .appt-btn { justify-self: end; font-size: 12px; padding: 9px 14px; }

/* Template drawer */
.drawer-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.25); opacity: 0; pointer-events: none; transition: opacity .25s; z-index: 40; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(440px, 100vw); background: #fff; z-index: 41;
  transform: translateX(100%); transition: transform .3s ease; overflow-y: auto; padding: 24px 28px 40px;
}
body.drawer-open .drawer { transform: none; }
body.drawer-open .drawer-backdrop { opacity: 1; pointer-events: auto; }
.drawer-head { display: flex; justify-content: space-between; align-items: center; }
.drawer-head h2 { font-size: 18px; font-weight: 400; margin: 0; }
.drawer-head .icon { width: 34px; height: 34px; padding: 0; font-family: 'Jost', Arial, sans-serif; font-size: 20px; }
.drawer-list { display: grid; gap: 22px; margin-top: 18px; }
.tpl {
  display: block; width: 100%; text-align: left; padding: 0; border: 0; background: none;
  font-family: 'Jost', Arial, sans-serif; text-transform: none; letter-spacing: 0; font-weight: 400; cursor: pointer;
}
.tpl:hover { background: none; color: var(--ink); }
.tpl .tpl-img { display: block; aspect-ratio: 9 / 7; background: var(--soft); overflow: hidden; }
.tpl img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .5s; }
.tpl:hover img { transform: scale(1.03); }
.tpl .tpl-row { display: flex; justify-content: space-between; align-items: baseline; margin-top: 10px; gap: 10px; }
.tpl .tpl-name { font-family: 'Marianina', Arial, sans-serif; text-transform: uppercase; letter-spacing: 1px; font-size: 15px; }
.tpl .tpl-price { font-weight: 500; }
.tpl .tpl-text { display: block; font-size: 13px; color: var(--muted); margin-top: 2px; }

/* Palette sub headings */
.tile-heading {
  grid-column: 1 / -1; margin: 8px 0 0; font-family: 'Jost', Arial, sans-serif; font-weight: 500;
  font-size: 13px; color: var(--muted); text-transform: none; letter-spacing: 0;
}
.tile-heading:first-child { margin-top: 0; }

@media (max-width: 860px) {
  .site-header .appt-btn { font-size: 10px; padding: 7px 9px; }
  .sel-card { left: 10px; right: 10px; bottom: 10px; width: auto; padding: 12px; }
  .sel-card .sel-actions .icon { width: 30px; height: 30px; }
}

/* Call to action bar in black */
.cta-bar { background: var(--ink); color: #fff; border-top: 0; }
.cta-total .cta-details { color: rgba(255,255,255,.65); }
.cta-total .cta-details:hover { color: #fff; }
.cta-buttons .primary { background: #fff; color: var(--ink); border-color: #fff; }
.cta-buttons .primary:hover { background: #e9e6e0; border-color: #e9e6e0; }
.cta-buttons .button { background: transparent; color: #fff; border-color: rgba(255,255,255,.7); }
.cta-buttons .button:hover { background: #fff; color: var(--ink); border-color: #fff; }

/* Minimal icon buttons */
.stage-tools .icon, .sel-card .sel-actions .icon, .sel-close, .drawer-head .icon {
  display: inline-flex; align-items: center; justify-content: center;
  border-color: var(--line); background: #fff; color: var(--ink);
}
.stage-tools .icon, .sel-card .sel-actions .icon { width: 32px; height: 32px; }
.stage-tools .icon:hover, .sel-card .sel-actions .icon:hover, .drawer-head .icon:hover { background: #fff; color: var(--ink); border-color: var(--ink); }
.sel-close { border: 0; }
.sel-close:hover { background: none; color: var(--ink); }
.stage-tools .icon:disabled { opacity: .35; border-color: var(--line); }
.icon svg { display: block; }

/* Larger button text */
button, .button { font-size: 13px; }
.choices button { font-size: 12px; }
.site-header .appt-btn { font-size: 13px; }
.stage-tools button { font-size: 13px; }
.cta-buttons > * { font-size: 13px; }
.sel-card .sel-actions .text { font-size: 13px; }
@media (max-width: 860px) {
  .site-header .appt-btn { font-size: 11px; }
  .cta-buttons > * { font-size: 12px; }
}

/* Overlays on the 3D view: never fully opaque. Chrome skips drawing the 3D view behind
   fully opaque layers and gets the position wrong (mirrored), which leaves a blank patch. */
.stage .sel-card, .stage select { background-color: rgba(255,255,255,.99) !important; }
.stage button, .stage .icon { background-color: rgba(255,255,255,.99); }
.stage button:hover, .stage button[aria-pressed=true] { background-color: rgba(0,0,0,.99); color: #fff; }
.stage .icon:hover, .stage .sel-close:hover { background-color: rgba(255,255,255,.99); color: var(--ink); }
.stage .sel-close { background-color: transparent; }
.stage .dims { background: rgba(255,255,255,.92); }
.drop-hint, .drag-chip, .toast { background: rgba(0,0,0,.99); }

/* Add rail */
.rail-add { display: flex; gap: 8px; align-items: stretch; }
.rail-add #rail-length-field { flex: 0 0 auto; }
.rail-add select { height: 100%; min-height: 42px; }
.rail-add #rail-tiles { flex: 1; display: flex; }
.add-rail {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 10px;
  padding: 0 14px; min-height: 42px; cursor: grab; user-select: none; -webkit-user-select: none; touch-action: manipulation;
}
.add-rail .plus { display: block; flex: 0 0 auto; }
.add-rail .add-price { font-family: 'Jost', Arial, sans-serif; text-transform: none; letter-spacing: 0; font-weight: 400; opacity: .7; }
.brackets-field { margin-top: 22px; }

/* One height for every button and dropdown */
:root { --btn-h: 40px; }
button, .button, select {
  height: var(--btn-h); min-height: 0; box-sizing: border-box;
  display: inline-flex; align-items: center; justify-content: center;
  padding-top: 0; padding-bottom: 0;
}
select { padding: 0 10px; display: inline-block; }
.add-rail, .rail-add select { height: var(--btn-h); min-height: 0; }
.choices button, .cta-buttons > *, .actions .primary, .gallery-actions .button { height: var(--btn-h); padding-top: 0; padding-bottom: 0; }
.stage-tools .icon, .sel-card .sel-actions .icon, .drawer-head .icon { width: var(--btn-h); height: var(--btn-h); }
.site-header .appt-btn { height: var(--btn-h); padding-top: 0; padding-bottom: 0; }
/* not buttons in the visual sense: keep their own size */
.tile { display: flex; height: auto; }
.tpl { display: block; height: auto; }
.sel-close { width: 28px; height: 28px; }
button.ghost { height: auto; }
@media (max-width: 860px) {
  .site-header .appt-btn { height: 34px; }
  .sel-card .sel-actions .icon { width: 36px; height: 36px; }
}

/* Thin plus that turns into a minus */
details.pal-group summary { position: relative; align-items: center; }
details.pal-group summary::before, details.pal-group summary::after {
  content: ''; position: absolute; right: 1px; top: 50%; width: 12px; height: 1px; background: var(--ink);
  transition: transform .28s cubic-bezier(.4,0,.2,1);
}
details.pal-group summary::before { transform: rotate(90deg); }
details.pal-group.is-open summary::before { transform: rotate(0deg); }

/* Phone */
@media (max-width: 860px) {
  .site-header .back { display: none; }
  .cta-bar { position: static; }
  /* selection as a bar at the bottom of the screen, below the 3D view */
  .stage .sel-card {
    position: fixed; left: 0; right: 0; bottom: 0; top: auto; width: auto; z-index: 30;
    border: 0; border-top: 1px solid var(--ink); background-color: #fff !important;
    padding: 12px 16px calc(14px + env(safe-area-inset-bottom));
  }
  .sel-card .sel-meta { margin-bottom: 2px; }
  .sel-card .field { margin-top: 8px; }
  .sel-card .sel-actions { margin-top: 10px; }
  body.has-selection .panel { padding-bottom: 200px; }
  .site-header { grid-template-columns: 1fr auto; }
  .site-header .logo { justify-self: start; }
  .site-header .logo img { height: 14px; }
}
