/* Solskyddsbyggare – lugnt och enkelt: vitt, tunna grå linjer, en accentfärg på det som är valt. */
:root {
  --accent: #2f6fed;
  --on-accent: #fff;
  --ink: #1d2327;
  --paper: #fff;
  --bg: #f5f6f7;
  --muted: #667078;
  --soft: #f3f5f6;
  --border: #dde1e4;
  --line: 1px solid var(--border);
  --tint: color-mix(in srgb, var(--accent) 10%, #fff);
  --r: 8px;
  --top: 56px;
  color-scheme: light;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.4;
  -webkit-text-size-adjust: 100%;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--paper); color: var(--ink); }
body { min-height: 100vh; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; }
[hidden] { display: none !important; }

button, .btnlike {
  cursor: pointer; background: var(--paper); border: var(--line); border-radius: var(--r); padding: 0.55em 0.95em; font-weight: 500;
  text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 0.4em; line-height: 1.2;
  min-height: 42px; -webkit-tap-highlight-color: transparent; transition: background 0.12s, border-color 0.12s;
}
button:hover, .btnlike:hover { background: var(--soft); border-color: #c6ccd1; }
button.primary { background: var(--accent); color: var(--on-accent); border-color: transparent; font-weight: 600; }
button.primary:hover { filter: brightness(0.94); background: var(--accent); }
button.ghost { border-color: transparent; }
button.link { border: 0; padding: 0; min-height: 0; background: none; text-decoration: underline; font-weight: 500; border-radius: 0; }
button.link:hover { background: none; }
button.big { width: 100%; font-size: 1.05rem; padding: 0.85em; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
input, select, textarea { border: var(--line); border-radius: var(--r); background: var(--paper); padding: 0.5em 0.65em; width: 100%; min-height: 42px; }
textarea { resize: vertical; }
label { display: block; font-size: 0.85rem; font-weight: 500; }
label > input, label > select, label > textarea { margin-top: 4px; font-weight: 400; font-size: 1rem; }
.row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }

/* Topp */
header.top { height: var(--top); display: flex; align-items: center; gap: 12px; padding: 0 16px; border-bottom: var(--line); background: var(--paper); }
.brand { display: flex; align-items: center; height: 100%; text-decoration: none; font-weight: 700; font-size: 1.1rem; }
.brand img { height: 28px; width: auto; display: block; }
.brand .mark { display: inline-block; width: 14px; height: 14px; background: var(--accent); margin-right: 8px; border-radius: 4px; }
.badge { background: var(--tint); font-weight: 600; font-size: 0.78rem; padding: 3px 9px; border-radius: 99px; }
.spacer { flex: 1; }

/* Layout */
.app { display: grid; grid-template-columns: minmax(0, 1fr) 420px; height: calc(100vh - var(--top)); height: calc(100dvh - var(--top)); }
.stage { display: flex; flex-direction: column; border-right: var(--line); min-width: 0; min-height: 0; }
.viewport { position: relative; flex: 1; min-height: 0; overflow: hidden; background: #cfd6dc; }
#gl { position: absolute; left: 0; top: 0; width: 100%; height: 100%; display: block; touch-action: none; }
.panel { overflow-y: auto; overscroll-behavior: contain; background: var(--paper); }

/* Knappar i 3D-vyn */
.tools { position: absolute; top: 12px; left: 12px; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; max-width: calc(100% - 24px); }
.tools button, .tools .vinkel { min-height: 40px; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12); border-color: transparent; }
.tools button:not(.primary) { background: var(--paper); }
.seg { display: inline-flex; border-radius: var(--r); box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12); }
.tools .seg button { border-radius: 0; box-shadow: none; }
.tools .seg button:first-child { border-radius: var(--r) 0 0 var(--r); }
.tools .seg button:last-child { border-radius: 0 var(--r) var(--r) 0; }
.tools .seg button + button { border-left: var(--line); }
.tools .seg button.on { background: var(--ink); color: #fff; }
.vinkel { display: inline-flex; align-items: center; gap: 10px; background: var(--paper); border-radius: var(--r); padding: 0 12px; font-size: 0.9rem; }
.vinkel input { width: 130px; margin: 0; }
.vinkel output { width: 2.4em; text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); }
.vyinfo { position: absolute; left: 12px; bottom: 12px; max-width: min(440px, calc(100% - 24px)); background: var(--paper); border-radius: var(--r); box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12); padding: 10px 12px; margin: 0; font-size: 0.88rem; }
.vyinfo b { display: block; font-weight: 600; }
.hus { position: absolute; right: 12px; bottom: 12px; display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
.hus > button { min-height: 40px; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12); border-color: transparent; background: var(--paper); }
.hus > button[aria-expanded=true] { background: var(--ink); color: #fff; }
.huspanel { width: 300px; max-width: calc(100vw - 24px); max-height: calc(100% - 60px); overflow-y: auto; background: var(--paper); border-radius: var(--r); box-shadow: 0 4px 18px rgba(0, 0, 0, 0.18); padding: 14px; font-size: 0.88rem; }
.huspanel p.lead { margin: 0 0 10px; color: var(--muted); }
.huspanel h4 { margin: 12px 0 6px; font-size: 0.85rem; font-weight: 500; }
.huspanel h4:first-of-type { margin-top: 0; }
.huspanel .swatches { gap: 8px; }
.huspanel .sw { width: 30px; height: 30px; }
.huspanel .sw.on { box-shadow: 0 0 0 2px var(--paper), 0 0 0 3.5px var(--ink); }
.huspanel .val { display: flex; flex-wrap: wrap; gap: 6px; }
.huspanel .val button { min-height: 32px; padding: 0.25em 0.7em; font-size: 0.85rem; }
.huspanel .val button.on { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); background: var(--tint); }
.loading { position: absolute; inset: 0; display: grid; place-items: center; background: var(--bg); color: var(--muted); }

input[type=range] { -webkit-appearance: none; appearance: none; background: transparent; border: 0; padding: 0; min-height: 28px; }
input[type=range]::-webkit-slider-runnable-track { height: 4px; background: var(--border); border-radius: 2px; }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 20px; height: 20px; background: var(--paper); border: 2px solid var(--ink); border-radius: 50%; margin-top: -8px; }
input[type=range]::-moz-range-track { height: 4px; background: var(--border); border-radius: 2px; }
input[type=range]::-moz-range-thumb { width: 16px; height: 16px; background: var(--paper); border: 2px solid var(--ink); border-radius: 50%; }

/* Pris */
.pricebox { position: sticky; top: 0; z-index: 3; background: var(--paper); border-bottom: var(--line); padding: 16px 20px; }
.price-label { font-size: 0.85rem; color: var(--muted); }
.price { font-size: 1.75rem; font-weight: 700; line-height: 1.15; margin: 2px 0 8px; font-variant-numeric: tabular-nums; }
.price small { font-size: 0.6em; }
.rot { display: flex; justify-content: space-between; gap: 10px; font-size: 0.92rem; padding-top: 2px; }
.rot b { font-weight: 600; }
.price-sub { font-size: 0.8rem; color: var(--muted); margin-top: 6px; }
.lines { width: 100%; border-collapse: collapse; font-size: 0.85rem; margin-top: 10px; }
.lines td { padding: 4px 0; border-bottom: var(--line); vertical-align: top; }
.lines td:last-child { text-align: right; white-space: nowrap; padding-left: 8px; font-variant-numeric: tabular-nums; }
.lines tr.sum td { font-weight: 700; border-bottom: 0; padding-top: 6px; font-size: 1rem; }

/* Panelens steg */
section.block { border-bottom: var(--line); padding: 18px 20px; }
section.block h2 { font-size: 1rem; font-weight: 600; margin: 0 0 12px; display: flex; gap: 8px; align-items: center; }
section.block h2 em { font-style: normal; }
section.block h2 span { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: var(--soft); color: var(--muted); font-size: 0.78rem; font-weight: 600; }

.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.tile { padding: 10px 6px 8px; display: flex; flex-direction: column; align-items: center; gap: 4px; min-height: 92px; font-weight: 500; font-size: 0.88rem; text-align: center; }
.tile small { font-weight: 400; font-size: 0.74rem; color: var(--muted); }
.tile svg { width: 44px; height: 32px; stroke: currentColor; fill: none; stroke-width: 1.5; }
.tile.fill { display: none; }
.tile.on { border-color: var(--ink); background: var(--tint); box-shadow: inset 0 0 0 1px var(--ink); }

.dim { margin-bottom: 14px; }
.dim .head { display: flex; justify-content: space-between; align-items: center; font-weight: 500; }
.dim .head input { width: 88px; min-height: 36px; text-align: right; padding: 0.3em 0.5em; margin: 0; }
.dim .head label { display: flex; align-items: center; gap: 6px; font-size: 0.88rem; color: var(--muted); }
.dim .head label input { color: var(--ink); }
.dim .hint { font-size: 0.8rem; color: var(--muted); margin-top: 2px; }
.dim input[type=range] { width: 100%; }

.coll { margin-bottom: 14px; }
.coll h3 { font-size: 0.88rem; font-weight: 500; margin: 0 0 8px; display: flex; justify-content: space-between; }
.coll h3 small { font-weight: 400; color: var(--muted); }
.swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.sw { width: 44px; height: 44px; border: var(--line); border-radius: 50%; padding: 0; min-height: 0; background-size: 100% 100%; }
.sw:hover { border-color: #aab2b8; }
.sw.on { box-shadow: 0 0 0 2px var(--paper), 0 0 0 4px var(--ink); }
.selname { margin-top: 10px; font-size: 0.88rem; }

.opts { display: grid; gap: 8px; }
.opt { display: flex; align-items: center; gap: 10px; padding: 10px 12px; text-align: left; font-weight: 400; min-height: 46px; width: 100%; justify-content: flex-start; }
.opt .p { margin-left: auto; font-variant-numeric: tabular-nums; color: var(--muted); white-space: nowrap; font-size: 0.9rem; }
.opt .box { width: 18px; height: 18px; border: 1.5px solid #9aa3aa; border-radius: 4px; flex: none; background: var(--paper); }
.opt.radio .box { border-radius: 50%; }
.opt.on { border-color: var(--ink); background: var(--tint); box-shadow: inset 0 0 0 1px var(--ink); }
.opt.on .box { border-color: var(--ink); background: var(--ink); box-shadow: inset 0 0 0 3px #fff; }
.opt.dis { color: #9aa3aa; cursor: default; }
.opt.dis:hover { background: var(--paper); border-color: var(--border); }
.opts .info, .info { margin: 2px 0 0; font-size: 0.85rem; color: var(--muted); }
.info .link { color: var(--ink); }
.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 400; font-size: 0.92rem; margin-top: 14px; cursor: pointer; }
.check input { width: 18px; height: 18px; min-height: 0; margin: 2px 0 0; accent-color: var(--ink); flex: none; }
.rng { display: flex; align-items: center; gap: 10px; margin-top: 10px; font-size: 0.88rem; }
.rng input { flex: 1; }

h3.sub { font-size: 0.88rem; font-weight: 500; margin: 20px 0 8px; }
h3.sub small { font-weight: 400; color: var(--muted); margin-left: 6px; }

/* Hjälp mig välja */
.guide { background: var(--soft); border-radius: var(--r); padding: 12px; margin-bottom: 14px; }
.guide-q { margin: 0 0 8px; font-size: 0.9rem; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { min-height: 34px; font-size: 0.85rem; padding: 0.3em 0.8em; border-radius: 99px; }
.chip.on { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.guide-a { margin: 10px 0 0; font-size: 0.9rem; }
.guide-a .alt { display: block; margin-top: 6px; }

.steg { margin: 0; padding-left: 1.3em; font-size: 0.9rem; color: var(--muted); }
.steg li { margin-bottom: 6px; }
.steg b { color: var(--ink); font-weight: 600; }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid2 .span2 { grid-column: 1 / -1; }

.cta .row > * { flex: 1; }
.foot { padding: 14px 20px 24px; display: flex; justify-content: space-between; font-size: 0.82rem; color: var(--muted); gap: 12px; }

/* Mobilfält */
.mobilebar { display: none; }

/* Dialoger */
dialog { border: 0; border-radius: 12px; padding: 0; width: min(560px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); background: var(--paper); color: var(--ink); box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25); }
dialog::backdrop { background: rgba(20, 24, 28, 0.45); }
dialog form { display: flex; flex-direction: column; max-height: calc(100dvh - 28px); }
dialog header { display: flex; align-items: center; justify-content: space-between; border-bottom: var(--line); padding: 10px 10px 10px 20px; }
dialog h3 { margin: 0; font-size: 1.05rem; font-weight: 600; }
dialog .x { min-height: 36px; width: 40px; padding: 0; font-size: 1.3rem; border-color: transparent; }
.dlgbody { padding: 20px; overflow-y: auto; }
dialog footer { display: flex; justify-content: flex-end; gap: 8px; border-top: var(--line); padding: 12px 20px; }
.summary { background: var(--soft); border-radius: var(--r); padding: 10px; margin-bottom: 14px; display: flex; gap: 12px; align-items: center; font-size: 0.92rem; }
.summary img { width: 120px; height: 80px; object-fit: cover; border-radius: 6px; }
.summary b { display: block; font-weight: 600; }
#shareUrl { margin-top: 6px; font-size: 0.85rem; }
.qr { margin-top: 14px; display: flex; gap: 14px; align-items: center; }
.qr img, .qr svg { width: 140px; height: 140px; image-rendering: pixelated; border: var(--line); border-radius: var(--r); }
.leadcard { border: var(--line); border-radius: var(--r); overflow: hidden; }
.leadcard .lh { display: flex; justify-content: space-between; background: var(--soft); border-bottom: var(--line); padding: 8px 12px; font-weight: 600; font-size: 0.88rem; gap: 8px; }
.leadcard .lb { padding: 12px; display: grid; grid-template-columns: 1fr 1fr; gap: 12px; font-size: 0.88rem; }
.leadcard .lb img { width: 100%; border-radius: 6px; display: block; }
.leadcard dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 3px 10px; }
.leadcard dt { color: var(--muted); }
.leadcard dd { margin: 0; }
.tag { display: inline-block; background: var(--soft); border-radius: 99px; padding: 1px 8px; font-size: 0.76rem; font-weight: 500; }
.tag.acc { background: var(--tint); }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 200%); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: var(--r); font-size: 0.92rem; transition: transform 0.25s, visibility 0.25s; z-index: 50; visibility: hidden; }
.toast.show { transform: translate(-50%, 0); visibility: visible; }
@media (max-width: 900px) { .toast { bottom: 90px; } }

/* Säljarläge – större touchytor för iPad */
body.seller .opt, body.seller .tile { min-height: 54px; }
body.seller .sw { width: 52px; height: 52px; }

/* Mobil */
@media (max-width: 900px) {
  .app { display: block; height: auto; }
  .stage { position: sticky; top: 0; z-index: 5; height: 52vh; height: 52svh; border-right: 0; border-bottom: var(--line); background: var(--paper); }
  .panel { overflow: visible; padding-bottom: 76px; }
  .pricebox { position: static; padding: 14px 16px; }
  section.block { padding: 16px; }
  .tools { top: 8px; left: 8px; gap: 6px; }
  .tools button, .tools .vinkel { min-height: 36px; padding: 0.4em 0.7em; font-size: 0.85rem; }
  .vinkel input { width: 110px; }
  .vyinfo { left: 8px; bottom: 8px; font-size: 0.82rem; padding: 8px 10px; }
  .hus { right: 8px; bottom: 8px; }
  .hus > button { min-height: 36px; padding: 0.4em 0.7em; font-size: 0.85rem; }
  .huspanel { width: 270px; padding: 12px; }
  .viewport:has(.vyinfo:not([hidden])) .hus { display: none; }
  .mobilebar { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; background: var(--paper); border-top: var(--line); padding: 8px 16px calc(8px + env(safe-area-inset-bottom)); align-items: center; gap: 12px; justify-content: space-between; }
  .mobilebar small { display: block; font-size: 0.75rem; color: var(--muted); }
  .mobilebar b { font-size: 1rem; font-weight: 600; }
  header.top { --top: 50px; height: 50px; }
}
@media (max-width: 420px) {
  .tiles { grid-template-columns: repeat(2, 1fr); }
  .grid2 { grid-template-columns: 1fr; }
}

/* Inbäddad (iframe): desktop = fast höjd med egen scroll i panelen, mobil = automatisk höjd */
@media (max-width: 899px) {
  html.embed body { min-height: 0; }
  html.embed .app { display: block; height: auto; }
  html.embed .stage { position: relative; height: auto; border-bottom: var(--line); }
  html.embed .viewport { flex: none; aspect-ratio: 4 / 3.6; }
  html.embed .panel { overflow: visible; padding-bottom: 0; }
  html.embed .mobilebar { display: none; }
}

/* Inbäddad: värdsidan har redan sidhuvud och logga */
html.embed header.top { display: none; }
html.embed { --top: 0px; }
html.embed .app { height: 100vh; }
