/*
 * Public site: rooms gallery, visualizer, pattern designer — in the Asket family
 * language (see base.css): the type scale tokens, 32 px controls, flat cards on the
 * grouped background. Translucent bars only on the functional layer: the navigation
 * bar, the tab bar and the controls floating over the room photo.
 */
@import url("base.css");

.glass {
  background: var(--material);
  -webkit-backdrop-filter: blur(20px) saturate(160%); backdrop-filter: blur(20px) saturate(160%);
  box-shadow: var(--shadow-2);
}

/* ── Navigation bar (gallery, designer) ───────────────────── */

.site-header {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 16px;
  min-height: 52px; padding: 0 max(20px, env(safe-area-inset-left));
  background: var(--material);
  -webkit-backdrop-filter: blur(20px) saturate(160%); backdrop-filter: blur(20px) saturate(160%);
  border-bottom: 1px solid var(--separator);
}
.brand { display: inline-flex; align-items: center; gap: 8px; color: var(--label); }
.brand:hover { text-decoration: none; }
.brand img { height: 26px; width: auto; }
.brand .app-icon { width: 24px; height: 24px; }
.brand .wordmark { font-size: 17px; }
.site-nav { display: flex; gap: 2px; }
.site-nav a { display: inline-flex; align-items: center; gap: 6px; min-height: 32px; padding: 0 12px; border-radius: var(--r-m); color: var(--label-2); font-size: var(--text-body); font-weight: 500; }
.site-nav a:hover { background: var(--fill-3); color: var(--label); text-decoration: none; }
.site-nav a[aria-current="page"] { color: var(--label); background: var(--selection); font-weight: 600; }
.site-nav .icon { display: none; }

/* Tab bar on compact widths (tab-bars.md: top-level sections, always visible) */
@media (max-width: 700px) {
  /* backdrop-filter would make the header the containing block for the fixed tab bar */
  .site-header { -webkit-backdrop-filter: none; backdrop-filter: none; background: var(--material-thick); }
  .site-nav {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    justify-content: space-around; gap: 0;
    padding: 6px 12px max(8px, env(safe-area-inset-bottom));
    background: var(--material);
    -webkit-backdrop-filter: blur(20px) saturate(160%); backdrop-filter: blur(20px) saturate(160%);
    border-top: 1px solid var(--separator);
  }
  .site-nav a { flex: 1; flex-direction: column; gap: 2px; min-height: 46px; padding: 4px 0; font-size: var(--text-caption); line-height: 1; font-weight: 500; color: var(--label-2); background: none !important; justify-content: center; }
  .site-nav a[aria-current="page"] { color: var(--tint-text); font-weight: 600; }
  .site-nav .icon { display: block; width: 24px; height: 24px; }
  .has-tabbar { padding-bottom: calc(64px + env(safe-area-inset-bottom)); }
}

/* ── Rooms gallery ────────────────────────────────────────── */

.gallery { max-width: 1200px; margin: 0 auto; padding: 32px 24px 64px; }
.gallery h1 { margin: 0; font-size: var(--text-title1); line-height: var(--lh-title1); font-weight: 700; letter-spacing: -0.01em; }
.gallery .lede { margin: 4px 0 20px; color: var(--label-2); }
.chips { display: flex; gap: 6px; overflow-x: auto; padding: 2px 0 20px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; min-height: 32px; padding: 0 14px; border: 0; border-radius: 999px; background: var(--fill-3); color: var(--label); font-size: var(--text-footnote); font-weight: 600; display: inline-flex; align-items: center; }
.chip:hover { background: var(--fill-2); text-decoration: none; }
.chip[aria-pressed="true"] { background: var(--label); color: var(--window); }
@media (pointer: coarse) { .chip { min-height: 40px; } }
.room-grid { display: grid; gap: 24px 20px; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.room-card { display: grid; gap: 10px; color: var(--label); }
.room-card:hover { text-decoration: none; }
.room-card .ph { aspect-ratio: 3 / 2; border-radius: var(--r-l); overflow: hidden; background: var(--stage); box-shadow: var(--shadow-1); }
.room-card .ph img { width: 100%; height: 100%; object-fit: cover; transition: transform 0.4s cubic-bezier(0.2, 0.8, 0.2, 1); }
.room-card:hover .ph img { transform: scale(1.02); }
.room-card .meta { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; padding: 0 2px; }
.room-card .name { font-size: var(--text-title3); line-height: var(--lh-title3); font-weight: 600; }
.room-card .cat { font-size: var(--text-footnote); color: var(--label-2); }
.room-card .go { display: none; }
.site-footer { text-align: center; color: var(--label-2); font-size: var(--text-caption); padding: 24px 16px 40px; }

/* ── Visualizer layout ────────────────────────────────────── */

.viz { display: grid; height: 100dvh; grid-template-columns: minmax(0, 1fr) 376px; background: var(--bg); overflow: hidden; }
.stage { position: relative; min-width: 0; min-height: 0; background: var(--stage); display: grid; place-items: center; overflow: hidden; }
.stage-inner { position: relative; }
.stage canvas { display: block; width: 100%; height: 100%; touch-action: manipulation; }
.stage canvas.can-pick { cursor: pointer; }
.skeleton { position: absolute; inset: 0; background: linear-gradient(100deg, transparent 30%, rgba(255,255,255,.28) 50%, transparent 70%) var(--stage); background-size: 200% 100%; animation: shimmer 1.4s linear infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* Toolbar floating over the photo */
.stage-toolbar {
  position: absolute; top: max(12px, env(safe-area-inset-top)); left: 12px; right: 12px; z-index: 4;
  display: flex; align-items: center; gap: 8px; pointer-events: none;
}
.stage-toolbar > * { pointer-events: auto; }
.stage-toolbar .btn { --control-h: 36px; border-radius: 10px; background: var(--material); color: var(--label); -webkit-backdrop-filter: blur(20px) saturate(160%); backdrop-filter: blur(20px) saturate(160%); box-shadow: var(--shadow-2); }
.stage-toolbar .btn-icon { width: 36px; min-width: 36px; }
.stage-toolbar .btn:hover { background: var(--material-thick); }
.stage-toolbar .btn[aria-pressed="true"] { background: var(--selection); color: var(--tint-text); }
.stage-toolbar .title { display: flex; align-items: center; min-height: 36px; padding: 0 12px; border-radius: 10px; font-weight: 600; max-width: 34vw; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.tb-group { display: flex; border-radius: 10px; overflow: hidden; padding: 0; }
.tb-group .btn { box-shadow: none !important; border-radius: 0; background: transparent !important; -webkit-backdrop-filter: none !important; backdrop-filter: none !important; }
.tb-group .btn:hover { background: var(--fill-3) !important; }
@media (pointer: coarse) { .stage-toolbar .btn { --control-h: 44px; } .stage-toolbar .btn-icon { width: 44px; min-width: 44px; } }

.surface-pin {
  position: absolute; z-index: 2; transform: translate(-50%, -50%);
  min-height: 28px; padding: 0 10px; border: 0; border-radius: var(--r-m);
  font-size: var(--text-footnote); font-weight: 600; white-space: nowrap; color: var(--label);
  background: var(--material); -webkit-backdrop-filter: blur(20px) saturate(160%); backdrop-filter: blur(20px) saturate(160%);
  box-shadow: var(--shadow-2); transition: opacity var(--base), background-color var(--fast);
}
.surface-pin::before { content: ""; position: absolute; inset: -7px; }
.surface-pin[aria-pressed="true"] { background: var(--tint-fill); color: var(--on-tint); }
.stage.pins-hidden .surface-pin { opacity: 0; pointer-events: none; }
.stage-status { position: absolute; left: 50%; bottom: 16px; transform: translateX(-50%); z-index: 3; padding: 8px 14px; border-radius: 12px; font-size: var(--text-footnote); font-weight: 600; display: none; align-items: center; gap: 8px; }
.stage-status.show { display: inline-flex; }
.stage canvas.zoomed { cursor: grab; touch-action: none; }
.stage canvas.panning { cursor: grabbing; }
.zoom-ctl { position: absolute; right: 12px; bottom: 16px; z-index: 3; display: flex; align-items: center; border-radius: 10px; padding: 2px; }
.zoom-ctl .btn { --control-h: 32px; background: transparent; color: var(--label); }
.zoom-ctl .btn:hover:not(:disabled) { background: var(--fill-3); }
.zoom-ctl .zoom-value { min-width: 54px; padding: 0 4px; font-size: var(--text-footnote); justify-content: center; }
.surface-pin.off-view { display: none; }
.webgl-error { max-width: 420px; padding: 24px; text-align: center; color: var(--label-2); }
.webgl-error h2 { color: var(--label); font-size: var(--text-title3); font-weight: 600; }

/* Download menu */
.menu-wrap { position: relative; }
.menu-wrap .menu { position: absolute; right: 0; top: calc(100% + 6px); z-index: 20; min-width: 260px; display: grid; gap: 1px; background: var(--surface-raised); -webkit-backdrop-filter: none; backdrop-filter: none; }
.menu button { display: flex; align-items: center; gap: 10px; padding: 6px 10px; min-height: 40px; border: 0; border-radius: var(--r-m); background: transparent; text-align: left; font-size: var(--text-body); font-weight: 500; color: var(--label); }
.menu button .icon { width: 18px; height: 18px; color: var(--label-2); }
.menu button:hover, .menu button:focus-visible { background: var(--tint-fill); color: var(--on-tint); outline: none; }
.menu button:hover .icon, .menu button:focus-visible .icon { color: inherit; }
.menu button:hover small, .menu button:focus-visible small { color: inherit; opacity: 0.85; }
.menu small { display: block; font-weight: 400; font-size: var(--text-caption); color: var(--label-2); margin-top: 1px; }

/* Compare */
.compare { position: absolute; inset: 0; z-index: 1; cursor: ew-resize; touch-action: none; }
.compare img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: fill; pointer-events: none; user-select: none; }
.compare-handle { position: absolute; top: 0; bottom: 0; width: 44px; margin-left: -22px; display: grid; place-items: center; }
.compare-handle::before { content: ""; position: absolute; top: 0; bottom: 0; left: 21px; width: 2px; background: #fff; box-shadow: 0 0 0 0.5px rgba(0,0,0,.3); }
.compare-handle span { position: relative; width: 34px; height: 34px; border-radius: 50%; background: #fff; box-shadow: var(--shadow-2); }
.compare-handle span::before, .compare-handle span::after { content: ""; position: absolute; top: 11px; border: 6px solid transparent; }
.compare-handle span::before { left: 3px; border-right-color: #3a3a3c; }
.compare-handle span::after { right: 3px; border-left-color: #3a3a3c; }
.compare-tag { position: absolute; top: 12px; padding: 4px 8px; border-radius: var(--r-s); font-size: var(--text-caption); font-weight: 600; pointer-events: none; }
.compare-tag.left { left: 12px; } .compare-tag.right { right: 12px; }
.compare-bar { position: absolute; left: 50%; top: calc(max(12px, env(safe-area-inset-top)) + 48px); transform: translateX(-50%); z-index: 3; display: flex; gap: 8px; align-items: center; padding: 6px; border-radius: 12px; }
.compare-bar .segmented { min-width: 200px; }

/* ── Inspector (desktop: trailing panel; compact: bottom sheet) ── */

.inspector { display: flex; flex-direction: column; min-height: 0; background: var(--bg); border-left: 1px solid var(--separator); }
.inspector-scroll { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 12px 12px 8px; display: flex; flex-direction: column; gap: 10px; }
.inspector-footer { display: flex; gap: 8px; padding: 10px 12px max(12px, env(safe-area-inset-bottom)); background: var(--material); -webkit-backdrop-filter: blur(20px) saturate(160%); backdrop-filter: blur(20px) saturate(160%); border-top: 1px solid var(--separator); }
.inspector-footer .btn-primary { flex: 1; --control-h: 40px; }
.sheet-grabber { display: none; }

/* Each section is one inset group card */
.inspector .section { background: var(--surface); border-radius: var(--r-l); padding: 16px; }
.inspector #secSurface { background: transparent; padding: 0; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; min-height: 28px; }
.section-title { margin: 0; font-family: var(--font); font-size: var(--text-body); line-height: var(--lh-body); font-weight: 600; }
.section-value { font-size: var(--text-footnote); color: var(--label-2); }
.section-head .btn { --control-h: 28px; }
.more-btn { display: none; }

#surfaceTabs { --seg-h: 32px; }

/* Current selection */
.selection { display: flex; gap: 12px; align-items: center; }
.selection .swatch-box { width: 56px; height: 56px; }
.selection .info { min-width: 0; flex: 1; }
.selection .pname { font-size: var(--text-title3); line-height: var(--lh-title3); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.selection .pmeta { font-size: var(--text-footnote); color: var(--label-2); margin-top: 1px; }
.selection .pprice { font-size: var(--text-footnote); margin-top: 2px; font-weight: 600; }
.selection-actions { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }

/* Swatches keep the tile's real proportions — the product's signature */
.swatch-box { display: grid; place-items: center; }
.swatch { display: block; background: var(--fill-3) center / cover no-repeat; border-radius: 2px; box-shadow: 0 0 0 1px rgb(0 0 0 / 0.08), 0 1px 3px rgb(0 0 0 / 0.14); }

.tile-tools { display: grid; gap: 8px; margin-bottom: 10px; }
.filters { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; }
.filters::-webkit-scrollbar { display: none; }
.filters .select { width: auto; flex: none; min-height: 28px; padding: 0 26px 0 10px; font-size: var(--text-footnote); font-weight: 600; border-radius: var(--r-m); background-color: var(--fill-3); border-color: transparent; background-position: calc(100% - 14px) 55%, calc(100% - 9px) 55%; }
.filters .select.active { background-color: var(--selection); color: var(--tint-text); }
@media (pointer: coarse) { .filters .select { min-height: 40px; } }
.tile-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 4px; list-style: none; padding: 0; margin: 0; }
.tile-option { display: grid; gap: 5px; justify-items: center; align-content: start; width: 100%; padding: 8px 4px 6px; border: 0; border-radius: var(--r-m); background: transparent; text-align: center; color: var(--label); }
.tile-option:hover { background: var(--fill-4); }
.tile-option[aria-pressed="true"] { background: var(--selection); box-shadow: inset 0 0 0 1.5px var(--tint-ui); }
.tile-option .swatch-box { width: 60px; height: 60px; }
.tile-option .tname { font-size: var(--text-footnote); font-weight: 600; line-height: var(--lh-footnote); max-width: 100%; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.tile-option .tsize { font-size: var(--text-caption); color: var(--label-2); }
.tile-empty { color: var(--label-2); padding: 16px 0; text-align: center; }

.layout-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(74px, 1fr)); gap: 6px; }
.layout-option { display: grid; gap: 4px; justify-items: center; padding: 8px 4px 6px; border: 0; border-radius: var(--r-m); background: var(--bg); font-size: var(--text-caption); font-weight: 500; line-height: var(--lh-caption); color: var(--label); }
.layout-option:hover { background: var(--fill-3); }
.layout-option canvas { width: 48px; height: 48px; }
.layout-option[aria-pressed="true"] { background: var(--selection); box-shadow: inset 0 0 0 1.5px var(--tint-ui); font-weight: 600; }

/* Rows inside inspector groups (grout, finish) */
.row { display: flex; align-items: center; gap: 12px; min-height: 36px; }
.row + .row { margin-top: 10px; }
.row .grow, .row > .grow { flex: 1; min-width: 0; }
.row-hint { display: block; font-size: var(--text-footnote); line-height: var(--lh-footnote); color: var(--label-2); }
.row-title { display: block; font-weight: 600; }
.look-rows { margin-top: 14px; }
.look-block { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--separator); }
.section-head + .look-block { margin-top: 0; padding-top: 0; border-top: 0; }
.look-block .section-head { margin-bottom: 8px; }
.look-block .range-row { margin-top: 8px; }
.look-block + .look-block { margin-top: 4px; padding-top: 0; border-top: 0; }
.range-row { display: grid; grid-template-columns: auto minmax(0, 1fr) 44px; align-items: center; gap: 12px; margin-top: 6px; }
.range-row label { color: var(--label-2); }
.range-row .num { text-align: right; color: var(--label-2); font-size: var(--text-footnote); }
.joint-icon { width: 24px; height: 24px; flex: none; fill: var(--fill-3); stroke: var(--label-2); stroke-width: 1.2; }
.color-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.color-dot { position: relative; width: 28px; height: 28px; border-radius: 50%; border: 0; padding: 0; }
.color-dot::after { content: ""; position: absolute; inset: -7px; }
.color-dot { --dot-edge: rgba(0,0,0,.2); }
@media (prefers-color-scheme: dark) { .color-dot, .color-custom { --dot-edge: rgba(255,255,255,.35); } }
.color-dot, .color-custom { box-shadow: inset 0 0 0 1px var(--dot-edge); }
.color-dot[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--tint-ui); }
.color-custom { position: relative; width: 28px; height: 28px; border-radius: 50%; overflow: hidden; background: conic-gradient(#ff3b30, #ffcc00, #34c759, #5ac8fa, #007aff, #af52de, #ff3b30); }
.color-custom input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; cursor: pointer; }
#effectModes { margin-bottom: 4px; }
.finish-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 6px; }
.finish-option { display: grid; justify-items: center; gap: 6px; padding: 8px 4px; border: 0; border-radius: var(--r-m); background: var(--bg); color: var(--label); font-size: var(--text-caption); line-height: var(--lh-caption); font-weight: 500; }
.finish-option:hover { background: var(--fill-3); }
.finish-option[aria-pressed="true"] { background: var(--selection); box-shadow: inset 0 0 0 1.5px var(--tint-ui); font-weight: 600; }
.finish-chip { position: relative; width: 36px; height: 36px; border-radius: 4px; background: var(--fill-3) center / cover no-repeat; box-shadow: 0 0 0 1px rgb(0 0 0 / 0.08); overflow: hidden; }
.finish-chip::after { content: ""; position: absolute; inset: 0; }
.finish-chip[data-f="high_glossy"]::after { background: linear-gradient(135deg, rgb(255 255 255 / 0.85) 0 18%, transparent 36%, transparent 62%, rgb(255 255 255 / 0.35) 72%, transparent 82%); }
.finish-chip[data-f="glossy"]::after { background: linear-gradient(135deg, rgb(255 255 255 / 0.55) 0 14%, transparent 34%); }
.finish-chip[data-f="marble"]::after { background: radial-gradient(circle at 30% 25%, rgb(255 255 255 / 0.55), transparent 55%); filter: blur(1px); }
.finish-chip[data-f="matt"]::after { background: rgb(255 255 255 / 0.12); }
.finish-chip[data-f="sugar"]::after { background-image: radial-gradient(circle, rgb(255 255 255 / 0.95) 0.6px, transparent 1.2px); background-size: 5px 5px; }
.finish-chip[data-f="carving"]::after { background: repeating-linear-gradient(135deg, transparent 0 6px, rgb(255 255 255 / 0.7) 6px 7.5px, rgb(0 0 0 / 0.15) 7.5px 8.5px, transparent 8.5px 13px); }
#finishNote { margin-top: 10px; }
#carveStyleNote { margin: -4px 0 10px; }
#btnMoveLight[aria-pressed="true"] { background: var(--selection); font-weight: 600; }
.stage.light-mode canvas { cursor: crosshair; }

/* ── Sheets on the public site ───────────────────────────── */

/* ── Render transition (reveal() in visualizer.js), in the manner of ChatGPT's image generation:
   the picture drops to a soft, grainy placeholder while the tiles are prepared, then the new
   render is uncovered from the top down behind a blurred edge that travels down the image.   */
@property --reveal { syntax: "<percentage>"; inherits: false; initial-value: 0%; }

.ai-layer { position: absolute; inset: 0; z-index: 1; pointer-events: none; overflow: hidden; }
.ai-layer .reveal-canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.ai-layer #revealCanvas { transition: filter 700ms var(--ease), transform 900ms var(--ease); }
.ai-layer.thinking #revealCanvas, .ai-layer.developing #revealCanvas { filter: blur(28px) saturate(0.8) brightness(1.03); transform: scale(1.08); }
.ai-layer .dev-soft { opacity: 0; filter: blur(28px) saturate(0.9); transform: scale(1.08); }
.ai-layer .dev-sharp { opacity: 0;
  -webkit-mask-image: linear-gradient(180deg, #000 calc(var(--reveal) - 14%), rgb(0 0 0 / 0.35) calc(var(--reveal) - 5%), transparent var(--reveal));
  mask-image: linear-gradient(180deg, #000 calc(var(--reveal) - 14%), rgb(0 0 0 / 0.35) calc(var(--reveal) - 5%), transparent var(--reveal)); }
/* Fine grain over the still-forming part */
.gen-grain { position: absolute; inset: 0; opacity: 0; mix-blend-mode: soft-light; transition: opacity 600ms var(--ease);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='1.1' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.9'/%3E%3C/svg%3E"); }
.ai-layer.thinking .gen-grain { opacity: 0.45; }
.ai-layer.developing .gen-grain { opacity: 0.45;
  -webkit-mask-image: linear-gradient(180deg, transparent calc(var(--grain-at, 0%) - 4%), #000 calc(var(--grain-at, 0%) + 6%));
  mask-image: linear-gradient(180deg, transparent calc(var(--grain-at, 0%) - 4%), #000 calc(var(--grain-at, 0%) + 6%)); }
.ai-layer.settled .reveal-canvas, .ai-layer.settled .gen-grain { display: none; }

.stage.revealing .stage-status { display: none !important; }

/* Status: one line of text with a quiet shimmer passing through it */
.render-pill { position: absolute; left: 50%; bottom: 16px; transform: translateX(-50%); z-index: 4; padding: 7px 16px; border-radius: 999px; font-size: var(--text-footnote); font-weight: 500; white-space: nowrap; transition: opacity 300ms var(--ease); }
.render-pill[hidden] { display: none; }
#renderPillText { background: linear-gradient(90deg, var(--label-3) 0%, var(--label-3) 38%, var(--label) 50%, var(--label-3) 62%, var(--label-3) 100%);
  background-size: 250% 100%; -webkit-background-clip: text; background-clip: text; color: transparent; animation: gen-shimmer 1.9s linear infinite; }
.render-pill.done #renderPillText { animation: none; background: none; color: var(--label-2); }
@keyframes gen-shimmer { from { background-position: 100% 0; } to { background-position: -150% 0; } }

/* Download image: the studio's main output */
.stage-toolbar .tb-download { --control-h: 36px; border-radius: 10px; background: var(--tint-fill); color: var(--on-tint); box-shadow: var(--shadow-2); -webkit-backdrop-filter: none; backdrop-filter: none; }
.stage-toolbar .tb-download:hover { background: var(--tint-fill); filter: brightness(1.1); }
@media (pointer: coarse) { .stage-toolbar .tb-download { --control-h: 44px; } }
.inspector-footer .btn { --control-h: 40px; }
.inspector-footer .btn:not(.btn-primary) { flex: 0 0 auto; }
dialog.export-sheet { width: min(900px, calc(100vw - 32px)); }
.export-sheet .sheet-body { grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); align-items: start; gap: 20px; }
.export-sheet .sheet-actions { grid-column: 1 / -1; padding-top: 4px; border-top: 1px solid var(--separator); padding-top: 16px; }
.export-controls { display: grid; gap: 16px; }
.export-left { display: grid; gap: 10px; position: sticky; top: 0; }
.export-rooms { display: grid; gap: 16px; }
.ex-tile { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.ex-tile .swatch { width: 28px; height: 28px; }
.export-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; max-height: 340px; overflow-y: auto; }
.export-grid li { position: relative; border-radius: var(--r-m); overflow: hidden; background: var(--stage); box-shadow: 0 0 0 1px var(--separator); }
.export-grid label { display: block; cursor: pointer; }
.export-grid img, .export-grid canvas { display: block; width: 100%; aspect-ratio: 3 / 2; object-fit: cover; }
.export-grid .rname { display: flex; align-items: center; gap: 6px; padding: 6px 8px; font-size: var(--text-footnote); font-weight: 600; background: var(--surface-raised); }
.export-grid input { width: 15px; height: 15px; margin: 0; accent-color: var(--tint-fill); }
.export-grid li.off img { opacity: 0.35; }
.export-grid .done { margin-left: auto; color: var(--green); font-weight: 700; }
.export-progress { margin: 0; min-height: 18px; font-size: var(--text-footnote); color: var(--label-2); }

/* The render veil: a light sweep over an image being made (see reveal() in visualizer.js) */
.render-veil { position: absolute; inset: 0; pointer-events: none; opacity: 0; transition: opacity 300ms var(--ease); overflow: hidden;
  background: rgb(255 255 255 / 0.08); -webkit-backdrop-filter: blur(5px); backdrop-filter: blur(5px); }
.render-veil .scan { position: absolute; top: 0; left: 0; height: 2px; width: 40%; background: color-mix(in srgb, var(--tint) 85%, #fff);
  animation: veil-line 1.4s var(--ease) infinite; }
@keyframes veil-line { from { transform: translateX(-100%); } to { transform: translateX(250%); } }
.busy .render-veil, .render-veil.on { opacity: 1; }
.export-grid li .render-veil { opacity: 0; }
.export-grid li.rendering .render-veil { opacity: 1; }
@media (max-width: 760px) { .export-sheet .sheet-body { grid-template-columns: minmax(0, 1fr); } }
.export-preview { position: relative; border-radius: var(--r-m); overflow: hidden; background: var(--stage); box-shadow: 0 0 0 1px var(--separator); }
.export-preview canvas { display: block; width: 100%; height: auto; }
.export-opts { background: var(--bg); }
.export-opts .group-row { cursor: pointer; }


.share-top { display: flex; gap: 16px; align-items: center; }
.share-qr { width: 128px; height: 128px; flex: none; border-radius: var(--r-m); background: #fff; image-rendering: pixelated; box-shadow: 0 0 0 1px var(--separator); }
.share-link { display: flex; gap: 8px; }
.share-actions { flex-wrap: wrap; }
.calc-inputs { display: flex; align-items: end; gap: 8px; }
.calc-inputs .field { flex: 1; }
.calc-x { padding-bottom: 12px; color: var(--label-2); }
.calc-result { padding: 16px; border-radius: var(--r-l); background: var(--bg); }
.calc-big { font-size: var(--text-title1); line-height: var(--lh-title1); font-weight: 700; }
.calc-list { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; margin: 8px 0 0; }
.calc-list dt { color: var(--label-2); }
.calc-list dd { margin: 0; text-align: right; font-weight: 600; }
.calc-price { color: var(--tint-text); }
.calc-empty, .calc-note { margin: 0; color: var(--label-2); }
.calc-note { margin-top: 8px; font-size: var(--text-footnote); }
.inline-inputs { display: flex; align-items: center; gap: 6px; }
.inline-inputs .input { width: 84px; }

/* Arrange editor */
dialog.arrange-dialog { width: min(1180px, calc(100vw - 32px)); height: min(820px, calc(100dvh - 32px)); max-height: none; }
dialog.arrange-dialog[open] { display: flex; flex-direction: column; }
.arrange-dialog .sheet-head p { margin: 2px 0 0; color: var(--label-2); font-size: var(--text-footnote); }
.arrange { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) 340px; }
.plan-wrap { min-width: 0; min-height: 0; display: grid; place-items: center; align-content: center; gap: 8px; padding: 20px; background: var(--stage); }
.plan-box { position: relative; box-shadow: var(--shadow-2); }
.plan-canvas, .plan-overlay { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.plan-canvas { cursor: crosshair; touch-action: none; }
.plan-overlay { pointer-events: none; }
.plan-caption { font-size: var(--text-footnote); color: var(--label-2); text-align: center; }
.plan-controls { overflow-y: auto; padding: 12px; background: var(--bg); display: flex; flex-direction: column; gap: 10px; border-left: 1px solid var(--separator); }
.plan-controls .section { background: var(--surface); border-radius: var(--r-l); padding: 16px; }
.face-palette { display: grid; grid-template-columns: repeat(auto-fill, minmax(54px, 1fr)); gap: 6px; }
.face-palette button { position: relative; padding: 4px; border: 0; border-radius: var(--r-m); background: var(--bg); display: grid; place-items: center; min-height: 62px; }
.face-palette button[aria-checked="true"] { box-shadow: inset 0 0 0 1.5px var(--tint-ui); background: var(--selection); }
.face-palette img { max-width: 100%; max-height: 58px; border-radius: 2px; box-shadow: 0 1px 2px rgba(0,0,0,.15); }
.plan-controls .segmented > button { padding: 0 6px; flex: 1 1 auto; }
.rot-row { display: flex; align-items: center; gap: 8px; margin-top: 10px; }
.rot-row .rot-label { font-size: var(--text-footnote); color: var(--label-2); }
.rot-row .segmented { flex: 1; }
.face-palette img { transition: transform var(--base) var(--ease); }
.blank-tools { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 10px; }
.face-palette .face-clear { gap: 2px; }
.face-palette .clear-swatch { position: static; width: 26px; height: 40px; border-radius: 2px; padding: 0; background: repeating-linear-gradient(135deg, #e6e4df 0 5px, #c8c6c0 5px 6px); box-shadow: 0 0 0 1px var(--separator); }
.face-palette .clear-label { position: static; background: none; font-size: var(--text-caption); font-weight: 600; padding: 0; }
.face-palette span { position: absolute; right: 5px; bottom: 4px; font-size: 11px; font-weight: 700; background: var(--surface); border-radius: var(--r-xs); padding: 0 4px; }
.start-picker { position: relative; width: 132px; height: 86px; border-radius: var(--r-m); background: var(--bg); box-shadow: inset 0 0 0 1px var(--separator); }
.start-picker button { position: absolute; width: 26px; height: 26px; border-radius: 50%; border: 1.5px solid var(--label-3); background: var(--surface); padding: 0; }
.start-picker button::after { content: ""; position: absolute; inset: -9px; }
.start-picker button[aria-checked="true"] { background: var(--tint-ui); border-color: var(--tint-ui); box-shadow: inset 0 0 0 4px var(--surface); }
.start-picker .sp-tl { left: 6px; top: 6px; } .start-picker .sp-tr { right: 6px; top: 6px; }
.start-picker .sp-bl { left: 6px; bottom: 6px; } .start-picker .sp-br { right: 6px; bottom: 6px; }
.start-picker .sp-c { left: calc(50% - 13px); top: calc(50% - 13px); }
.arrange-foot { display: flex; gap: 8px; align-items: center; padding: 10px 16px; border-top: 1px solid var(--separator); }

/* ── Pattern designer ─────────────────────────────────────── */

.designer-body { height: 100dvh; display: flex; flex-direction: column; overflow: hidden; }
.designer { flex: 1; min-height: 0; display: grid; grid-template-columns: 340px minmax(0, 1fr); }
.designer-side { overflow-y: auto; padding: 12px; background: var(--bg); border-right: 1px solid var(--separator); display: flex; flex-direction: column; gap: 10px; }
.designer-side .section { background: var(--surface); border-radius: var(--r-l); padding: 16px; }
.designer-side .tile-grid { grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); }
.designer-arrange { min-height: 0; }

/* ── Kiosk ────────────────────────────────────────────────── */

.kiosk-only { display: none !important; }
body.kiosk .kiosk-only { display: revert !important; }
body.kiosk .kiosk-hide { display: none !important; }
body.kiosk .share-qr { width: 220px; height: 220px; }
body.kiosk .share-top { flex-direction: column; text-align: center; }
.kiosk-idle { position: fixed; inset: 0; z-index: 200; display: grid; place-items: center; background: rgb(0 0 0 / 0.45); }
.kiosk-idle-card { background: var(--surface-raised); border-radius: var(--r-xl); padding: 28px; text-align: center; box-shadow: var(--shadow-3); max-width: 340px; }
.kiosk-idle-card h2 { margin: 0 0 6px; font-size: var(--text-title2); line-height: var(--lh-title2); font-weight: 700; }
.kiosk-idle-card p { color: var(--label-2); margin: 0 0 18px; }

/* ── Compact width: stage on top, inspector as a bottom sheet ── */

@media (max-width: 860px) {
  .viz { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); }
  .stage { height: 100dvh; align-items: start; padding-top: calc(max(12px, env(safe-area-inset-top)) + 52px); padding-bottom: calc(var(--sheet-peek, 316px) + 8px); }
  .stage-inner { align-self: center; }
  .stage-toolbar .hide-compact { display: none; }
  .zoom-ctl { display: none; }   /* pinch instead; the sheet covers the corner */

  .inspector {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
    height: var(--sheet-peek, 316px); border-left: 0; border-radius: var(--r-xl) var(--r-xl) 0 0;
    box-shadow: 0 -1px 0 var(--separator), 0 -8px 30px rgb(0 0 0 / 0.12);
    transition: height 0.32s cubic-bezier(0.2, 0.8, 0.2, 1);
  }
  .inspector.expanded { height: 88dvh; }
  .inspector.dragging { transition: none; }
  .sheet-grabber { display: grid; place-items: center; width: 100%; height: 22px; border: 0; background: transparent; flex: none; touch-action: none; }
  .sheet-grabber::before { content: ""; width: 36px; height: 5px; border-radius: 3px; background: var(--label-4); }
  .inspector-scroll { padding-top: 0; }
  #secSurface { order: 1; } #secTiles { order: 2; } #secSelection { order: 3; } #secLayout { order: 4; } #secFinish { order: 4; } #secEffect { order: 5; } #secGrout { order: 6; } #secLook { order: 7; }
  .inspector:not(.expanded) .inspector-scroll { overflow: hidden; }
  .inspector:not(.expanded) :is(#secSelection, #secLayout, #secFinish, #secEffect, #secGrout, #secLook, .tile-tools, #tileCount) { display: none; }
  .inspector:not(.expanded) #secTiles { padding: 10px 12px; }
  .inspector.expanded .more-btn { display: none; }
  .more-btn { display: inline-flex; margin-left: auto; }
  .more-btn .icon { width: 14px; height: 14px; }
  .tile-grid.compact-tray { grid-auto-flow: column; grid-template-columns: none; grid-auto-columns: 88px; overflow-x: auto; scrollbar-width: none; }
  .tile-grid.compact-tray::-webkit-scrollbar { display: none; }
  .inspector.expanded .tile-grid.compact-tray { grid-auto-flow: row; grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); grid-auto-columns: auto; overflow: visible; }
  .inspector-footer { padding-top: 8px; }

  .compare-bar { left: 12px; right: 12px; transform: none; border-radius: var(--r-l); padding: 8px; flex-wrap: wrap; }
  .compare-bar .segmented { flex: 1 1 100%; }
  .compare-bar .btn { flex: 1; }

  dialog.sheet:not(.arrange-dialog) { width: 100vw; max-width: 100vw; margin: auto 0 0; border-radius: var(--r-xl) var(--r-xl) 0 0; max-height: 92dvh; padding-bottom: env(safe-area-inset-bottom); }
  dialog.arrange-dialog { width: 100vw; max-width: 100vw; height: 100dvh; max-height: 100dvh; margin: 0; border-radius: 0; }
  .arrange { grid-template-columns: 1fr; grid-template-rows: minmax(220px, 46dvh) auto; overflow-y: auto; }
  .plan-controls { border-left: 0; overflow: visible; }

  .designer-body { height: auto; overflow: visible; }
  .designer { grid-template-columns: minmax(0, 1fr); }
  .designer-arrange { display: contents; }
  .designer-arrange .plan-wrap { order: 1; min-height: 260px; }
  .designer-side { order: 2; border-right: 0; overflow: visible; min-width: 0; }
  .designer-arrange .plan-controls { order: 3; min-width: 0; }
  .designer-side .tile-grid { grid-auto-flow: column; grid-template-columns: none; grid-auto-columns: 84px; overflow-x: auto; }
}

@media (max-width: 520px) {
  .stage-toolbar .title { display: none; }
}

/* ── Upload a tile (company staff only) ─────────────────── */
.upload-tile { --control-h: 36px; justify-content: center; }
.upload-sheet .sheet-body { display: grid; gap: 14px; }
.up-drop { position: relative; display: grid; justify-items: center; gap: 6px; padding: 20px 16px; text-align: center; border: 1.5px dashed var(--field-border, var(--separator)); border-radius: var(--r-l); background: var(--bg); color: var(--label-2); font-size: var(--text-footnote); cursor: pointer; transition: border-color var(--fast), background var(--fast); }
.up-drop:hover, .up-drop.over { border-color: var(--tint-ui, var(--tint-fill)); background: var(--selection); }
.up-drop:focus-within { outline: 2px solid var(--tint-ui, var(--tint-fill)); outline-offset: 2px; }
.up-drop strong { color: var(--label); font-size: var(--text-body); font-weight: 600; overflow-wrap: anywhere; }
.up-drop span { max-width: 44ch; }
.up-drop input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.up-faces { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }
.up-faces img { height: 64px; width: auto; border-radius: 4px; box-shadow: 0 0 0 1px var(--separator); }
.up-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.up-size-note { margin-top: 6px; font-size: var(--text-footnote); line-height: 1.4; color: var(--label-2); }
.up-size-note:empty { display: none; }
.up-size-note.ok { color: var(--green); }
.up-size-note.need { color: var(--label); font-weight: 500; }
.up-size-note.bad { color: var(--red); font-weight: 500; }
.up-size-note .check { display: flex; align-items: center; gap: 6px; margin-top: 4px; font-weight: 500; color: var(--label); }
#upSize[aria-invalid="true"] { box-shadow: inset 0 0 0 1px var(--tint-fill); }
