/* Hemrit
   Layout: ritbord – pappersyta som fyller skärmen, verktygslist vid tummen,
   blyertsgul accent för det som är aktivt, mått i mono som på en arkitektritning. */
:root {
  --paper: #eef0ec;
  --surface: #ffffff;
  --surface-2: #f6f7f4;
  --ink: #1d2320;
  --muted: #687069;
  --line: #d6dbd4;
  --grid: #e2e6e0;
  --grid-major: #cdd3cb;
  --wall: #262c29;
  --accent: #e0a21f;
  --accent-ink: #2e2104;
  --accent-soft: #f6e6bd;
  --danger: #c2462f;
  --measure: #2b6cb0;
  --floor-oak: #ece2cf;
  --floor-pine: #f1e7d2;
  --floor-tile: #e2e6e7;
  --floor-carpet: #e5e0e3;
  --floor-concrete: #dfdfdb;
  --shadow: 0 10px 30px rgba(24, 30, 26, 0.14), 0 2px 6px rgba(24, 30, 26, 0.08);

  --font-display: "Archivo", "Helvetica Neue", Arial, sans-serif;
  --font-body: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;

  --r: 12px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #151918;
    --surface: #202624;
    --surface-2: #1a1f1d;
    --ink: #e7eae6;
    --muted: #97a099;
    --line: #333b37;
    --grid: #1d2220;
    --grid-major: #2b322f;
    --wall: #dfe3de;
    --accent: #f2b93f;
    --accent-ink: #251a02;
    --accent-soft: #3d321a;
    --danger: #ef6a52;
    --measure: #6aa6e6;
    --floor-oak: #2f2b23;
    --floor-pine: #322e24;
    --floor-tile: #262c2d;
    --floor-carpet: #2c282b;
    --floor-concrete: #272826;
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.45), 0 2px 6px rgba(0, 0, 0, 0.3);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #151918;
  --surface: #202624;
  --surface-2: #1a1f1d;
  --ink: #e7eae6;
  --muted: #97a099;
  --line: #333b37;
  --grid: #1d2220;
  --grid-major: #2b322f;
  --wall: #dfe3de;
  --accent: #f2b93f;
  --accent-ink: #251a02;
  --accent-soft: #3d321a;
  --danger: #ef6a52;
  --measure: #6aa6e6;
  --floor-oak: #2f2b23;
  --floor-pine: #322e24;
  --floor-tile: #262c2d;
  --floor-carpet: #2c282b;
  --floor-concrete: #272826;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.45), 0 2px 6px rgba(0, 0, 0, 0.3);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html {
  height: 100%;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
body {
  height: 100%;
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 14px/1.45 var(--font-body);
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
}
[hidden] { display: none !important; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
button:focus-visible, input:focus-visible, textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

#app { height: 100%; display: grid; grid-template-rows: auto 1fr auto; }

/* ---------- toppfält ---------- */
.topbar {
  display: flex; align-items: center; gap: 6px;
  padding: 8px 10px 8px 14px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  min-width: 0;
}
.brand { display: flex; align-items: center; gap: 7px; flex: 0 1 auto; min-width: 0; text-align: left; border-radius: 10px; padding: 2px 4px 2px 0; }
.brand-text { display: grid; min-width: 0; line-height: 1.1; }
.brand-proj { font-size: 11px; color: var(--muted); max-width: 24vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.brand-mark { width: 22px; height: 22px; stroke: var(--ink); stroke-width: 2; fill: var(--accent); }
.brand-name {
  font-family: var(--font-display);
  font-weight: 800;
  font-stretch: 118%;
  font-variation-settings: "wdth" 118;
  font-size: 18px;
  letter-spacing: -0.01em;
}
.variant-btn {
  display: flex; align-items: center; gap: 4px;
  min-width: 0; max-width: 52vw;
  margin-left: 2px;
  padding: 6px 6px 6px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-2);
  font-weight: 500; font-size: 13px;
}
.variant-btn span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.variant-btn svg { width: 18px; height: 18px; }
.spacer { flex: 1; }
.icon-btn {
  width: 38px; height: 40px; flex: none;
  display: grid; place-items: center;
  border-radius: 10px;
  color: var(--ink);
}
.icon-btn:hover { background: var(--surface-2); }
.icon-btn:disabled { opacity: 0.3; cursor: default; }

/* ---------- scen ---------- */
#stage { position: relative; overflow: hidden; min-height: 0; }
#planwrap, #view3d { position: absolute; inset: 0; }
#plan, .view3d-canvas { display: block; touch-action: none; }
.view3d-canvas { position: absolute; inset: 0; }
#view3d.is-picking .view3d-canvas { cursor: crosshair; }

.stage-top {
  position: absolute; top: 10px; left: 12px; right: 12px;
  display: flex; justify-content: space-between; align-items: center;
  pointer-events: none;
}
.stage-top > * { pointer-events: auto; }
.stage-left { display: flex; align-items: center; gap: 8px; min-width: 0; }
.area-chip {
  display: grid; justify-items: start; gap: 0;
  height: 42px; padding: 4px 12px; min-width: 0;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: var(--shadow); text-align: left; line-height: 1.15;
}
.area-total { font-size: 14px; font-weight: 600; color: var(--ink); white-space: nowrap; }
.area-sub { font-size: 10.5px; color: var(--muted); white-space: nowrap; letter-spacing: 0.02em; }
.area-list { display: grid; gap: 2px; }
.area-row {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: baseline; gap: 12px;
  padding: 11px 6px; border-bottom: 1px solid var(--line); text-align: left; width: 100%;
}
.area-row.child { padding-left: 26px; }
.area-row.child .area-name::before { content: "└ "; color: var(--muted); }
.area-row.child.deep { padding-left: 46px; }
.area-name { font-weight: 500; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.area-val { font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-size: 13.5px; }
.area-note { font-size: 11.5px; color: var(--muted); grid-column: 1 / -1; margin-top: -2px; }
.area-sum { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; padding: 14px 6px 4px; font-weight: 700; font-size: 15px; }
.area-sum .area-val { font-size: 15px; }
.area-find { width: 100%; margin-top: 14px; display: flex; align-items: center; justify-content: center; gap: 8px; }
.area-find svg { width: 18px; height: 18px; }
.area-find + .props-tip { margin-top: 8px; text-align: center; }
.float-btn {
  width: 42px; height: 42px; display: grid; place-items: center;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: var(--shadow);
}
.seg {
  display: flex; padding: 3px; gap: 2px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: var(--shadow);
}
.seg button {
  min-width: 48px; height: 34px; border-radius: 9px;
  font-family: var(--font-display); font-weight: 700; font-size: 14px; letter-spacing: 0.04em;
  color: var(--muted);
}
.seg button.on { background: var(--ink); color: var(--paper); }

.hint {
  position: absolute; top: 62px; left: 50%;
  transform: translate(-50%, -6px);
  width: max-content; max-width: calc(100% - 136px);
  padding: 7px 12px;
  background: var(--ink); color: var(--paper);
  border-radius: 10px;
  font-size: 12.5px; text-align: center; text-wrap: balance;
  opacity: 0; pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
}
.hint.show { opacity: 0.94; transform: translate(-50%, 0); }

/* ---------- joystick ---------- */
.joy {
  position: absolute; width: 110px; height: 110px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.7);
  background: rgba(20, 24, 22, 0.18);
  pointer-events: none;
}
.joy-knob {
  position: absolute; left: 50%; top: 50%;
  width: 46px; height: 46px; border-radius: 50%;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.25);
  transform: translate(-50%, -50%);
}

/* ---------- egenskapspanel ---------- */
.props {
  position: absolute; left: 10px; right: 10px; bottom: 10px;
  max-width: 560px; margin: 0 auto;
  max-height: min(calc(100% - 70px), 54%); overflow-y: auto; overscroll-behavior: contain;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 10px 10px 12px 14px;
  display: grid; gap: 10px;
}
.props-head { display: flex; align-items: center; gap: 8px; min-width: 0; }
.props-id { flex: 1; min-width: 0; }
.props-title {
  font-family: var(--font-display); font-weight: 700; font-stretch: 108%;
  font-variation-settings: "wdth" 108;
  font-size: 16px; line-height: 1.2;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.props-meta { font-size: 11.5px; color: var(--muted); }
.props-tip { margin: 0; font-size: 12px; color: var(--muted); }
.chip {
  flex: none; padding: 3px 8px; border-radius: 999px;
  font-size: 11px; font-weight: 600;
}
.chip.danger { background: color-mix(in srgb, var(--danger) 14%, transparent); color: var(--danger); }
.props-actions { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; margin-right: -4px; }
.props-actions::-webkit-scrollbar { display: none; }
/* Med mus går det inte att svepa i sidled: lägg knappar och val på flera rader i stället */
@media (hover: hover) and (pointer: fine) {
  .props-actions { flex-wrap: wrap; overflow-x: visible; margin-right: 0; }
  .chips { flex-wrap: wrap; overflow-x: visible; }
}
.act {
  display: flex; align-items: center; gap: 6px; flex: none;
  height: 38px; padding: 0 12px 0 10px;
  border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface-2);
  font-size: 13px; font-weight: 500; white-space: nowrap;
}
.act svg { width: 18px; height: 18px; }
.act.on { background: var(--accent-soft); border-color: var(--accent); }
.act.danger { color: var(--danger); }
.props-more { display: grid; gap: 10px; padding-top: 2px; }
.field-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(90px, 1fr)); gap: 8px; }
.field { display: grid; gap: 4px; font-size: 11.5px; color: var(--muted); font-weight: 500; letter-spacing: 0.02em; }
.field input[type="number"], .field input[type="text"], .modal textarea {
  width: 100%; min-width: 0; height: 40px; padding: 0 10px;
  border: 1px solid var(--line); border-radius: 9px;
  background: var(--surface-2); color: var(--ink);
  font: 500 15px var(--font-mono);
  -webkit-user-select: text; user-select: text;
}
.field input[type="text"] { font-family: var(--font-body); }
.field input[type="range"] { width: 100%; accent-color: var(--accent); height: 28px; }
.swatches { display: flex; flex-wrap: wrap; gap: 7px; }
.sw {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--c); border: 1px solid rgba(0, 0, 0, 0.18);
  box-shadow: inset 0 0 0 2px var(--surface);
  position: relative;
}
.sw.on { outline: 2px solid var(--accent); outline-offset: 2px; }
.sw.custom {
  background: conic-gradient(#e05a47, #e0c147, #5ab06a, #4a8fd6, #9a63c9, #e05a47);
  overflow: hidden; cursor: pointer;
}
.sw.custom input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; cursor: pointer; }
.floor-pick { display: flex; flex-wrap: wrap; gap: 6px; }
.floor-chip {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 11px 6px 7px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface-2);
  font-size: 12.5px;
}
.floor-chip.on { border-color: var(--accent); background: var(--accent-soft); }
.floor-dot { width: 18px; height: 18px; border-radius: 50%; border: 1px solid rgba(0, 0, 0, 0.15); }
.floor-oak { background: repeating-linear-gradient(0deg, #c9a46f 0 4px, #b98f58 4px 5px); }
.floor-pine { background: repeating-linear-gradient(0deg, #e0c08d 0 4px, #cfa96f 4px 5px); }
.floor-tile { background: #dfe1df; background-image: linear-gradient(#a9acaa 1px, transparent 1px), linear-gradient(90deg, #a9acaa 1px, transparent 1px); background-size: 6px 6px; }
.floor-carpet { background: #a8a096; }
.floor-concrete { background: #b6b6b0; }

/* ---------- verktygsfält ---------- */
.toolbar {
  display: grid; grid-template-columns: repeat(7, 1fr);
  background: var(--surface);
  border-top: 1px solid var(--line);
  padding: 6px 4px 8px;
}
.toolbar.three { grid-template-columns: repeat(7, 1fr); }
.toolbar button {
  display: grid; justify-items: center; gap: 2px;
  padding: 4px 0 2px; min-width: 0;
  font-size: 10.5px; font-weight: 500; color: var(--muted);
  letter-spacing: 0.01em;
}
.toolbar button svg {
  width: 44px; height: 32px; padding: 5px 11px;
  border-radius: 10px;
  transition: background 0.15s;
}
.toolbar button span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.toolbar button.on { color: var(--ink); }
.toolbar button.on svg { background: var(--accent); color: var(--accent-ink); }
.toolbar button.accent svg { background: var(--ink); color: var(--paper); }

/* ---------- bottenark ---------- */
.sheet-backdrop {
  position: fixed; inset: 0; background: rgba(15, 18, 16, 0.38);
  opacity: 0; transition: opacity 0.2s; z-index: 20;
}
.sheet-backdrop.open { opacity: 1; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 21;
  max-width: 640px; margin: 0 auto;
  max-height: 78%;
  display: flex; flex-direction: column;
  background: var(--surface);
  border-radius: 18px 18px 0 0;
  box-shadow: var(--shadow);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  transform: translateY(100%); transition: transform 0.22s ease-out;
}
.sheet.open { transform: translateY(0); }
.sheet-grip { width: 40px; height: 4px; border-radius: 2px; background: var(--line); margin: 8px auto 0; flex: none; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 6px 8px 4px 18px; flex: none; }
.sheet-head h2, .modal h2 {
  margin: 0;
  font-family: var(--font-display); font-weight: 750; font-stretch: 112%;
  font-variation-settings: "wdth" 112;
  font-size: 19px; letter-spacing: -0.005em; text-wrap: balance;
}
.sheet-body { overflow-y: auto; padding: 4px 16px 18px; -webkit-overflow-scrolling: touch; }
.sheet-lead { margin: 0 0 12px; color: var(--muted); font-size: 13px; max-width: 60ch; }

.chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 10px; margin: 0 -16px; padding-left: 16px; padding-right: 16px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip-tab {
  flex: none; padding: 7px 13px; border-radius: 999px;
  border: 1px solid var(--line); font-size: 13px; font-weight: 500;
}
.chip-tab.on { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.cat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
.cat-card {
  display: grid; justify-items: start; gap: 2px;
  padding: 8px 10px 10px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--surface-2);
  text-align: left; min-width: 0;
}
.cat-card:active { border-color: var(--accent); }
.cat-card canvas { width: 100%; height: auto; aspect-ratio: 4 / 3; max-width: 100%; background: var(--paper); border-radius: 8px; margin-bottom: 6px; }
.cat-name { font-weight: 600; font-size: 13px; }
.cat-dim { font-size: 11px; color: var(--muted); }

.var-list { display: grid; gap: 6px; }
.var-row {
  display: flex; align-items: center; gap: 2px;
  border: 1px solid var(--line); border-radius: 12px; padding-right: 4px;
  background: var(--surface-2);
}
.var-row.on { border-color: var(--accent); background: var(--accent-soft); }
.var-pick { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; padding: 12px; text-align: left; }
.radio { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--muted); flex: none; }
.var-row.on .radio { border-color: var(--accent); box-shadow: inset 0 0 0 4px var(--surface); background: var(--accent); }
.var-name { flex: 1; min-width: 0; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.var-count { font-size: 11.5px; color: var(--muted); flex: none; }
.sheet-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }

.menu-proj { display: grid; gap: 2px; margin-bottom: 12px; }
.menu-proj .label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.menu-proj strong { font-size: 15px; }
.menu-list { display: grid; }
.menu-list button {
  display: flex; align-items: center; gap: 12px;
  padding: 13px 4px; border-bottom: 1px solid var(--line); text-align: left; font-size: 14.5px;
}
.menu-list button:last-child { border-bottom: 0; }
.menu-list button.danger { color: var(--danger); }
.menu-foot { margin: 10px 0 0; font-size: 12px; color: var(--muted); }

.proj-list { display: grid; gap: 8px; }
.proj-row {
  display: flex; align-items: center; gap: 2px;
  border: 1px solid var(--line); border-radius: 12px; padding-right: 4px;
  background: var(--surface-2);
}
.proj-row.on { border-color: var(--accent); background: var(--accent-soft); }
.proj-open { flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px; padding: 8px; text-align: left; }
.proj-open canvas { width: 64px; height: 48px; flex: none; border-radius: 8px; background: var(--paper); }
.proj-info { display: grid; min-width: 0; gap: 1px; }
.proj-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.proj-meta { font-size: 11.5px; color: var(--muted); }

/* ---------- knappar, modal, toast ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 42px; padding: 0 16px; border-radius: 11px;
  border: 1px solid var(--line); background: var(--surface-2);
  font-weight: 600; font-size: 14px;
}
.btn svg { width: 18px; height: 18px; }
.btn.primary { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.btn.danger { color: var(--danger); }
.file-btn { position: relative; overflow: hidden; cursor: pointer; }
.file-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

.modal {
  position: fixed; inset: 0; z-index: 30;
  display: grid; place-items: center; padding: 16px;
  background: rgba(15, 18, 16, 0.45);
}
.modal-card {
  width: 100%; max-width: 420px;
  background: var(--surface); border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 18px 18px 14px;
  display: grid; gap: 12px;
}
.modal-body { display: grid; gap: 12px; }
.modal-body p { margin: 0; color: var(--muted); max-width: 60ch; }
.modal textarea { height: auto; padding: 8px 10px; font-size: 12px; resize: vertical; }
.modal-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }

.toast {
  position: fixed; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom, 0px)); z-index: 40;
  transform: translate(-50%, 10px);
  max-width: calc(100% - 32px); width: max-content;
  padding: 10px 14px; border-radius: 11px;
  background: var(--ink); color: var(--paper);
  font-size: 13px; text-align: center;
  opacity: 0; pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }


/* ---------- material och zoom ---------- */
.field-note { margin: -4px 0 0; font-size: 12px; color: var(--muted); }
.swatches.named { margin-top: 4px; align-items: center; }
.mat-pick { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.mat-chip {
  display: flex; align-items: center; gap: 6px;
  padding: 5px 10px 5px 6px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface-2);
  font-size: 12.5px; color: var(--ink); font-weight: 500;
}
.mat-chip.on { border-color: var(--accent); background: var(--accent-soft); }
.mat-dot { width: 18px; height: 18px; border-radius: 50%; border: 1px solid rgba(0, 0, 0, 0.18); background: var(--c); }
.mat-wood { background: repeating-linear-gradient(80deg, var(--c) 0 3px, color-mix(in srgb, var(--c) 75%, #000) 3px 4px); }
.mat-fabric { background: repeating-linear-gradient(0deg, var(--c) 0 1px, color-mix(in srgb, var(--c) 85%, #000) 1px 2px); }
.mat-leather { background: radial-gradient(circle at 35% 30%, color-mix(in srgb, var(--c) 70%, #fff), var(--c) 60%); }
.mat-metal { background: linear-gradient(135deg, color-mix(in srgb, var(--c) 50%, #fff), var(--c) 50%, color-mix(in srgb, var(--c) 60%, #fff)); }
.mat-gloss { background: radial-gradient(circle at 30% 25%, #fff 0 15%, var(--c) 40%); }
.floor-pick { margin-top: 4px; }

.zoom-ctl {
  position: absolute; right: 12px; top: 62px;
  display: grid; overflow: hidden;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: var(--shadow);
}
.zoom-ctl button { width: 42px; height: 40px; display: grid; place-items: center; }
.zoom-ctl button + button { border-top: 1px solid var(--line); }


/* ---------- köksinredning ---------- */
.kit { display: grid; gap: 10px; padding: 10px 0 2px; border-top: 1px solid var(--line); }
.kit-list { display: grid; gap: 4px; }
.kit-row { display: grid; grid-template-columns: minmax(0, 7.5em) minmax(0, 1fr) 3.6em 32px; align-items: center; gap: 8px; }
.kit-name { display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 500; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kit-row input[type="range"] { width: 100%; min-width: 0; accent-color: var(--accent); }
.kit-x { font-size: 11.5px; color: var(--muted); text-align: right; }
.kit-dot { width: 12px; height: 12px; border-radius: 3px; flex: none; border: 1px solid rgba(0, 0, 0, 0.2); }
.kit-sink { background: #cdd6db; }
.kit-hob { background: #1f2124; }
.kit-oven { background: #2a2d30; border-radius: 50%; }
.kit-dishwasher { background: #9fb0b8; border-radius: 50%; }
.kit-drawers { background: repeating-linear-gradient(0deg, var(--surface-2) 0 3px, var(--muted) 3px 4px); border-radius: 50%; }
.kit-add { display: flex; flex-wrap: wrap; gap: 6px; }
.kit-add .floor-chip svg { width: 15px; height: 15px; }
.icon-btn.small { width: 32px; height: 32px; }
.icon-btn.small svg { width: 16px; height: 16px; }


/* ---------- reglage ---------- */
.sfield { display: grid; gap: 2px; }
.sfield-top { display: flex; justify-content: space-between; align-items: baseline; font-size: 11.5px; color: var(--muted); font-weight: 500; letter-spacing: 0.02em; }
.sfield-val {
  font-size: 13px; color: var(--ink); font-weight: 600; font-family: var(--font-mono);
  background: none; border: 0; padding: 2px 4px; margin: -2px -4px; border-radius: 6px; cursor: pointer;
  text-decoration: underline dotted; text-underline-offset: 3px; text-decoration-color: var(--muted);
}
.sfield-val:hover { background: var(--surface-2); }
.room-dims { padding-top: 0; }
.sfield-row { display: grid; grid-template-columns: 36px minmax(0, 1fr) 36px; align-items: center; gap: 6px; }
.sfield-row input[type="range"] { width: 100%; min-width: 0; height: 32px; accent-color: var(--accent); }
.step { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 10px; border: 1px solid var(--line); background: var(--surface-2); }
.step svg { width: 16px; height: 16px; }
.step:active { background: var(--accent-soft); border-color: var(--accent); }


/* ---------- kakel ---------- */
.tile-pick { display: grid; gap: 8px; padding: 8px 10px 10px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2); }
.tile-pick .swatches.named { gap: 6px; }
.tile-pick .sw { width: 28px; height: 28px; }
.room-tabs { margin-top: -2px; }


/* ---------- dela, bild och fler verktyg ---------- */
.menu-big { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 8px; }
.menu-big .btn { height: 48px; }
.menu-apps { display: grid; gap: 6px; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.menu-apps .label, .menu-proj .label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.app-link {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2);
  color: var(--ink); text-decoration: none;
}
.app-link > span { display: grid; min-width: 0; }
.app-link strong { font-size: 14px; }
.app-text { font-size: 12.5px; color: var(--muted); }
.app-link svg { width: 18px; height: 18px; color: var(--muted); }
.menu-foot a { color: var(--ink); }

/* ---------- dina andra tjänster ---------- */
.app-mark {
  flex: none; display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 10px;
  background: var(--c); color: #fff; font: 800 17px var(--font-display);
}
.app-card {
  display: flex; align-items: center; gap: 12px; padding: 10px 10px 10px 12px;
  border: 1px solid var(--line); border-radius: 14px; background: var(--surface-2);
  color: var(--ink); text-decoration: none;
}
.app-card .app-body { display: grid; min-width: 0; flex: 1; }
.app-card strong { font-size: 14.5px; }
.app-go {
  flex: none; padding: 6px 12px; border-radius: 999px; font-size: 12.5px; font-weight: 600;
  background: var(--ink); color: var(--paper);
}
.menu-apps.top { margin-top: 6px; padding-top: 0; border-top: 0; }
.share-promo { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); display: grid; gap: 6px; }
.share-promo .label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.promo-tip {
  position: absolute; left: 10px; right: 10px; top: 62px; z-index: 6;
  max-width: 460px; margin: 0 auto;
  display: flex; align-items: flex-start; gap: 12px; padding: 12px 10px 12px 12px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow);
  opacity: 0; transform: translateY(-8px); transition: opacity 0.25s ease, transform 0.25s ease;
}
.promo-tip.in { opacity: 1; transform: none; }
.promo-tip .promo-body { flex: 1; min-width: 0; display: grid; gap: 8px; }
.promo-tip p { margin: 0; font-size: 13.5px; line-height: 1.45; }
.promo-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.promo-actions .btn { height: 36px; font-size: 13.5px; text-decoration: none; }
.promo-never { background: none; border: 0; padding: 4px 2px; font-size: 12.5px; color: var(--muted); text-decoration: underline; cursor: pointer; }
.promo-x { flex: none; width: 30px; height: 30px; border: 0; border-radius: 8px; background: none; color: var(--muted); font-size: 22px; line-height: 1; cursor: pointer; }
.stage-right { display: flex; align-items: center; gap: 8px; }
.export-preview { width: 100%; max-height: 52vh; object-fit: contain; border-radius: 10px; border: 1px solid var(--line); background: #fff; -webkit-user-select: auto; user-select: auto; -webkit-touch-callout: default; }


/* ---------- spara som fil ---------- */
.backup-banner {
  position: absolute; left: 10px; right: 10px; top: 62px; z-index: 6;
  max-width: 520px; margin: 0 auto;
  display: grid; gap: 10px; padding: 12px 12px 12px 14px;
  background: var(--surface); border: 1px solid var(--accent); border-radius: 14px; box-shadow: var(--shadow);
}
.backup-banner p { margin: 0; font-size: 13.5px; }
.backup-actions { display: flex; justify-content: flex-end; gap: 8px; }
.backup-actions .btn { height: 38px; font-size: 13.5px; }
.proj-meta.ok { color: var(--muted); }
.proj-meta.warn { color: var(--ink); background: var(--accent-soft); border-radius: 6px; padding: 0 6px; justify-self: start; }

@media (min-width: 760px) {
  .toolbar { grid-template-columns: repeat(7, 84px); justify-content: center; }
  .toolbar.three { grid-template-columns: repeat(7, 84px); }
  .props { left: auto; right: 14px; bottom: 14px; width: 380px; margin: 0; max-height: calc(100% - 160px); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; }
}

/* ---------- guidad tur ---------- */
.tour-ui { position: absolute; inset: 0; z-index: 7; pointer-events: none; }
.tour-cap {
  position: absolute; left: 50%; top: 70px; transform: translate(-50%, -6px);
  display: grid; justify-items: center; gap: 2px; padding: 10px 20px; border-radius: 16px;
  background: color-mix(in srgb, var(--surface) 88%, transparent); backdrop-filter: blur(8px);
  border: 1px solid var(--line); box-shadow: var(--shadow); opacity: 0; transition: opacity 0.5s ease, transform 0.5s ease;
  max-width: calc(100% - 40px); text-align: center;
}
.tour-cap.in { opacity: 1; transform: translate(-50%, 0); }
.tour-cap strong { font: 700 20px var(--font-display); }
.tour-cap span { font-size: 13px; color: var(--muted); font-family: var(--font-mono); }
.tour-bar { position: absolute; left: 50%; bottom: 34px; transform: translateX(-50%); display: flex; gap: 8px; pointer-events: auto; }
.tour-bar .btn { height: 42px; box-shadow: var(--shadow); white-space: nowrap; }
.tour-hint { position: absolute; left: 0; right: 0; bottom: 10px; margin: 0; text-align: center; font-size: 12px; color: var(--ink); text-shadow: 0 0 6px var(--paper), 0 0 2px var(--paper); }

/* ---------- visning (mottagaren av en delad guidad tur) ---------- */
.own-btn { display: none; height: 36px; padding: 0 14px; font-size: 13.5px; white-space: nowrap; }
body.viewer .own-btn { display: inline-flex; }
body.viewer #btn-variant, body.viewer #btn-undo, body.viewer #btn-redo, body.viewer #btn-menu,
body.viewer .stage-right, body.viewer #tools3d [data-view="2d"],
body.viewer #tools3d [data-action="variants"], body.viewer .promo-tip { display: none !important; }
body.viewer #btn-projects { pointer-events: none; }
body.viewer .toolbar.three { grid-template-columns: repeat(5, 1fr); }
@media (min-width: 760px) { body.viewer .toolbar.three { grid-template-columns: repeat(5, 92px); } }
.vw-card {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 8;
  width: min(380px, calc(100% - 32px)); padding: 22px 22px 18px; display: grid; gap: 10px; text-align: center;
  background: var(--surface); border: 1px solid var(--line); border-radius: 20px; box-shadow: var(--shadow);
}
.vw-card.bottom { top: auto; bottom: 92px; transform: translateX(-50%); text-align: left; padding-right: 44px; }
.vw-card h2 { margin: 0; font: 700 22px/1.2 var(--font-display); }
.vw-card.bottom h2 { font-size: 18px; }
.vw-card p { margin: 0; color: var(--muted); font-size: 14px; }
.vw-kicker { font: 600 11px var(--font-mono); text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.vw-meta { font-family: var(--font-mono); }
.vw-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 6px; }
.vw-card.bottom .vw-actions { justify-content: flex-start; }
.vw-foot { font-size: 12px !important; }
.vw-close { position: absolute; right: 8px; top: 8px; width: 32px; height: 32px; border: 0; background: none; color: var(--muted); font-size: 22px; cursor: pointer; }
