:root {
  --ink: #1f2a2e;
  --mute: #6b7377;
  --line: #e2ded6;
  --bg: #f6f4ef;
  --card: #fff;
  --acc: #2f6f68;
  --acc-ink: #fff;
  --warn: #b5532c;
  --r: 12px;
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial,
    sans-serif;
  color: var(--ink);
}
* {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  height: 100%;
  background: var(--bg);
}
body {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
button {
  font: inherit;
  color: inherit;
  cursor: pointer;
}
button:disabled {
  opacity: 0.35;
  cursor: default;
}

.top {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
  min-height: 56px;
}
.brand {
  font-weight: 800;
  font-size: 20px;
  letter-spacing: 0.02em;
  color: var(--ink);
  text-decoration: none;
}
.title {
  color: var(--mute);
  font-size: 14px;
}
.title em {
  font-style: normal;
  font-size: 11px;
  background: #e9efe9;
  color: var(--acc);
  padding: 2px 6px;
  border-radius: 6px;
  margin-left: 4px;
}
.actions {
  margin-left: auto;
  display: flex;
  gap: 8px;
  align-items: center;
}
.icon {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--card);
  font-size: 18px;
}
.ghost {
  height: 38px;
  padding: 0 14px;
  border-radius: 19px;
  border: 1px solid var(--line);
  background: var(--card);
  font-weight: 600;
}
.primary {
  height: 38px;
  padding: 0 18px;
  border-radius: 19px;
  border: 0;
  background: var(--acc);
  color: var(--acc-ink);
  font-weight: 700;
}

.app {
  flex: 1;
  display: flex;
  min-height: 0;
}
.stage {
  position: relative;
  flex: 1;
  min-width: 0;
}
#c {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}
.labels {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.lbl {
  position: absolute;
  transform: translate(-50%, -50%);
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 1px 6px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.lbl.dark {
  background: var(--ink);
  color: #fff;
  border-color: var(--ink);
}

.viewbar {
  position: absolute;
  left: 12px;
  bottom: 12px;
  display: flex;
  gap: 4px;
  background: var(--card);
  border-radius: 22px;
  padding: 4px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
}
.viewbar button {
  border: 0;
  background: none;
  height: 34px;
  padding: 0 12px;
  border-radius: 17px;
  font-weight: 600;
  font-size: 13px;
}
.viewbar button.on {
  background: var(--ink);
  color: #fff;
}
.hint {
  position: absolute;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  margin: 0;
  font-size: 12px;
  color: var(--mute);
  background: rgba(255, 255, 255, 0.8);
  padding: 4px 10px;
  border-radius: 10px;
  pointer-events: none;
}

.selbar {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  align-items: center;
  background: var(--card);
  border-radius: var(--r);
  padding: 8px 12px;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.12);
  max-width: calc(100% - 24px);
}
.sel-name b {
  display: block;
  font-size: 14px;
}
.sel-name span {
  font-size: 12px;
  color: var(--mute);
}
.sel-opts {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.sel-opts select {
  height: 32px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
  padding: 0 6px;
  font: inherit;
  font-size: 13px;
}
.sel-btns {
  display: flex;
  gap: 6px;
}
.sel-btns button {
  height: 32px;
  padding: 0 10px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
  font-size: 13px;
}
.sel-btns .danger {
  color: var(--warn);
}
.warn {
  position: absolute;
  top: 12px;
  right: 12px;
  max-width: 280px;
  background: #fff4ee;
  color: var(--warn);
  border: 1px solid #f1c9b6;
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 13px;
}
.selbar:not([hidden]) ~ .warn {
  top: auto;
  bottom: 60px;
}

.panel {
  width: 360px;
  flex: none;
  background: var(--card);
  border-left: 1px solid var(--line);
  overflow-y: auto;
  padding: 0 16px 16px;
  position: relative;
}
.grip {
  display: none;
}
.tabs {
  position: sticky;
  top: 0;
  background: var(--card);
  display: flex;
  gap: 4px;
  padding: 12px 0 8px;
  z-index: 2;
}
.tabs button {
  flex: 1;
  border: 0;
  background: var(--bg);
  height: 36px;
  border-radius: 18px;
  font-weight: 600;
  font-size: 13px;
}
.tabs button[aria-selected="true"] {
  background: var(--ink);
  color: #fff;
}
.panel h3 {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--mute);
  margin: 18px 0 8px;
}
.templates {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.templates button {
  text-align: left;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 10px;
  padding: 10px;
}
.templates button b {
  display: block;
}
.templates button span {
  font-size: 12px;
  color: var(--mute);
}
.templates button.on {
  border-color: var(--acc);
  box-shadow: inset 0 0 0 1px var(--acc);
}
.dim {
  display: grid;
  grid-template-columns: 64px 1fr 64px auto;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  margin: 6px 0;
}
.dim input[type="number"] {
  width: 64px;
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 6px;
  font: inherit;
}
.row {
  display: flex;
  gap: 8px;
  align-items: center;
}
.row select {
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 8px;
  font: inherit;
  background: #fff;
}
.row input[type="range"] {
  flex: 1;
}
.note {
  font-size: 12px;
  color: var(--mute);
}
.foot {
  font-size: 11px;
  color: var(--mute);
  margin-top: 24px;
}

.cat h4 {
  margin: 16px 0 8px;
  font-size: 14px;
}
.cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.card {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  padding: 10px;
  text-align: left;
}
.card .ic {
  font-size: 22px;
}
.card b {
  display: block;
  font-size: 13px;
  margin-top: 4px;
}
.card span {
  font-size: 12px;
  color: var(--mute);
}
.card:hover {
  border-color: var(--acc);
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.chips button {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 16px;
  padding: 6px 10px;
  font-size: 13px;
}
.chips button.on {
  background: var(--ink);
  color: #fff;
  border-color: var(--ink);
}
.swatches {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}
.sw {
  border: 2px solid transparent;
  border-radius: 10px;
  padding: 0;
  background: none;
  text-align: center;
  font-size: 11px;
  color: var(--mute);
}
.sw canvas,
.sw i {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  border-radius: 8px;
  border: 1px solid var(--line);
}
.sw.on {
  border-color: var(--acc);
}
.sw span {
  display: block;
  padding: 3px 0;
  line-height: 1.2;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(20, 26, 28, 0.5);
  display: grid;
  place-items: center;
  z-index: 50;
  padding: 16px;
}
.sheet {
  background: #fff;
  border-radius: 16px;
  padding: 20px;
  width: min(560px, 100%);
  max-height: 100%;
  overflow: auto;
}
.sheet h2 {
  margin: 0 0 12px;
  font-size: 20px;
}
.sheet img {
  width: 100%;
  border-radius: 10px;
  display: block;
}
.sheet ul {
  padding-left: 18px;
  font-size: 14px;
}
.btns {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}
.err {
  color: var(--warn);
  font-size: 13px;
}
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  background: var(--ink);
  color: #fff;
  padding: 10px 16px;
  border-radius: 20px;
  font-size: 14px;
  z-index: 60;
}

@media (max-width: 760px) {
  .title {
    display: none;
  }
  .top {
    padding: 8px 12px;
    gap: 8px;
  }
  .ghost {
    padding: 0 10px;
  }
  .primary {
    padding: 0 12px;
  }
  .app {
    flex-direction: column;
  }
  .stage {
    flex: 1 1 55%;
  }
  .panel {
    width: 100%;
    flex: 0 0 45%;
    border-left: 0;
    border-top: 1px solid var(--line);
    border-radius: 16px 16px 0 0;
    box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.06);
    transition: flex-basis 0.2s;
  }
  .panel.min {
    flex-basis: 64px;
    overflow: hidden;
  }
  .grip {
    display: block;
    width: 44px;
    height: 5px;
    border-radius: 3px;
    background: var(--line);
    border: 0;
    margin: 8px auto 0;
    padding: 0;
  }
  .tabs {
    padding-top: 6px;
  }
  .hint {
    display: none;
  }
  .viewbar {
    bottom: 8px;
    left: 8px;
  }
  .viewbar button {
    padding: 0 9px;
  }
  .selbar {
    top: 8px;
    padding: 6px 8px;
    gap: 6px;
  }
  .warn {
    left: 8px;
    right: 8px;
    max-width: none;
    top: auto;
    bottom: 54px;
  }
  .swatches {
    grid-template-columns: repeat(4, 1fr);
  }
}

[hidden] { display: none !important; }

@media (max-width: 760px) { .long { display: none; } }

/* AI-foto */
.viewbar .ai { background: linear-gradient(135deg, #2f6f68, #3f8d7c); color: #fff; }
.sheet.wide { width: min(980px, 100%); }
.cmp { position: relative; border-radius: 10px; overflow: hidden; background: #ddd; line-height: 0; }
.cmp img { width: 100%; display: block; }
.cmp .after { position: absolute; inset: 0; overflow: hidden; clip-path: inset(0 0 0 50%); }
.cmp .after img { width: 100%; height: 100%; object-fit: cover; }
.cmp input[type="range"] { position: absolute; left: 0; right: 0; bottom: 10px; width: 80%; margin: 0 10%; }
.ai-wait { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(20, 26, 28, 0.45); color: #fff; font-size: 15px; line-height: 1.4; text-align: center; }
.ai-wait i { width: 40px; height: 40px; border-radius: 50%; border: 4px solid rgba(255, 255, 255, 0.3); border-top-color: #fff; animation: spin 1s linear infinite; margin: 0 auto 10px; display: block; }
.ai-wait span { display: block; padding: 0 16px; }
@keyframes spin { to { transform: rotate(360deg); } }
.btnlink { display: inline-flex; align-items: center; text-decoration: none; color: inherit; }

/* touch: større mål på telefoner */
@media (pointer: coarse) {
  .sel-btns button, .sel-opts select { height: 40px; font-size: 14px; }
  .viewbar button { height: 40px; }
  .sw span { font-size: 12px; }
  .icon { width: 42px; height: 42px; }
}
@media (max-width: 760px) {
  .selbar { flex-wrap: nowrap; overflow-x: auto; max-width: calc(100% - 16px); left: 8px; transform: none; }
  .sel-name span { display: none; }
  .sel-opts { flex-wrap: nowrap; }
  .sel-opts select { max-width: 116px; }
  .sel-btns button { padding: 0 8px; }
}

/* fra fotos */
.templates .fromphoto { border-style: dashed; border-color: var(--acc); }
.ph-pick { display: block; border: 2px dashed var(--line); border-radius: 12px; padding: 18px; text-align: center; cursor: pointer; font-weight: 600; margin: 8px 0; }
.ph-pick input { display: none; }
.ph-thumbs { display: flex; gap: 8px; flex-wrap: wrap; }
.ph-thumbs img { width: 96px; height: 96px; object-fit: cover; border-radius: 8px; }
.ph-res { background: var(--bg); border-radius: 10px; padding: 10px 12px; font-size: 14px; margin: 10px 0; }
.ph-res ul { margin: 6px 0 0; padding-left: 18px; }
.ph-keep { display: flex; gap: 8px; align-items: center; font-size: 14px; margin: 6px 0; }
.lbl.util { background: #e8f2f1; border-color: #9cc5bf; color: #1f4f49; font-weight: 600; }

/* fotos → nyt badeværelse */
.sheet { position: relative; }
.sheet .x { position: absolute; top: 8px; right: 10px; border: 0; background: none; font-size: 26px; line-height: 1; color: var(--mute); }
.btns.col { flex-direction: column; align-items: stretch; gap: 10px; margin-top: 14px; }
.big { height: 48px; font-size: 16px; display: flex; align-items: center; justify-content: center; }
.link { border: 0; background: none; color: var(--mute); text-decoration: underline; font-size: 14px; padding: 6px; }
label.btnlink { display: inline-flex; align-items: center; justify-content: center; height: 38px; padding: 0 16px; border-radius: 19px; cursor: pointer; }
label.primary.btnlink { background: var(--acc); color: #fff; font-weight: 700; }
label.ghost.btnlink { border: 1px solid var(--line); background: #fff; font-weight: 600; }
.ph-prog { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--mute); }
.ph-prog i { flex: 1; height: 6px; background: var(--line); border-radius: 3px; position: relative; overflow: hidden; }
.ph-prog i::after { content: ""; position: absolute; inset: 0; width: var(--p, 0%); background: var(--acc); }
.ph-grid { display: grid; grid-template-columns: 150px 1fr; gap: 12px; align-items: center; }
.ph-grid svg { width: 150px; height: 150px; }
.ph-shot { position: relative; margin: 8px 0; }
.ph-shot img { width: 100%; max-height: 260px; object-fit: contain; border-radius: 10px; background: #eee; }
.ph-q { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.ph-q span { font-size: 12px; padding: 3px 8px; border-radius: 10px; background: #e7f3ec; color: #24613f; }
.ph-q span.bad { background: #fff1ea; color: var(--warn); }
.styles { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; margin: 10px 0; }
.styles button { border: 1px solid var(--line); background: #fff; border-radius: 10px; padding: 8px; text-align: left; }
.styles button b { display: block; font-size: 14px; }
.styles button span { font-size: 12px; color: var(--mute); }
.styles button.on { border-color: var(--acc); box-shadow: inset 0 0 0 1px var(--acc); }
.styles.small { grid-template-columns: repeat(5, auto); gap: 4px; margin: 6px 0 0; }
.styles.small button { padding: 4px 8px; }
.styles.small button span { display: none; }
.ph-wait { display: grid; justify-items: center; gap: 8px; padding: 24px 0; }
.ph-wait i { width: 42px; height: 42px; border-radius: 50%; border: 4px solid var(--line); border-top-color: var(--acc); animation: spin 1s linear infinite; }
.reno { position: absolute; left: 12px; top: 12px; max-width: min(560px, calc(100% - 24px)); background: #fff; border-radius: 12px; padding: 10px 34px 10px 12px; box-shadow: 0 4px 18px rgba(0,0,0,.12); font-size: 14px; z-index: 3; }
.reno .x { position: absolute; top: 4px; right: 6px; border: 0; background: none; font-size: 22px; color: var(--mute); }
.reno-scale { display: flex; gap: 8px; align-items: center; margin-top: 6px; }
.reno-scale input { flex: 1; }
.reno .note { margin: 6px 0 0; }
.reno:not([hidden]) ~ .selbar { top: auto; bottom: 60px; }
@media (max-width: 760px) { .ph-grid { grid-template-columns: 100px 1fr; } .ph-grid svg { width: 100px; height: 100px; } .styles.small { grid-template-columns: repeat(3, auto); } }

.swrow { display: inline-flex; align-items: center; gap: 5px; }
.swrow em { font-style: normal; font-size: 12px; color: var(--mute); margin-right: 2px; }
.dot { width: 26px; height: 26px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px var(--line); padding: 0; }
.dot.on { box-shadow: 0 0 0 2px var(--acc); }
.hint { font-size: 12px; color: var(--mute); }
@media (pointer: coarse) { .dot { width: 32px; height: 32px; } }
.btns.left { justify-content: flex-start; margin: 8px 0; }
a.btnlink { height: 38px; padding: 0 14px; border-radius: 19px; border: 1px solid var(--line); text-decoration: none; color: inherit; font-weight: 600; display: inline-flex; align-items: center; }

/* linje-ikoner */
svg.ic { width: 1.15em; height: 1.15em; vertical-align: -0.2em; margin-right: 0.4em; flex: none; }
.icon svg.ic { margin: 0; width: 20px; height: 20px; }
.lbl svg.ic { width: 1em; height: 1em; margin-right: 0.25em; }
.warn svg.ic { margin-right: 0.3em; }

/* katalog med 3D-miniaturer + træk ind i rummet */
.card { display: flex; flex-direction: column; align-items: stretch; padding: 6px; cursor: grab; user-select: none; -webkit-user-select: none; touch-action: pan-y; }
.card img { width: 100%; aspect-ratio: 1; height: auto; border-radius: 7px; background: #f1efea; display: block; object-fit: cover; }
.card b { margin-top: 6px; font-weight: 600; line-height: 1.25; }
.card span { margin-top: 2px; }
.dragchip { position: fixed; z-index: 50; width: 72px; height: 72px; border-radius: 10px; pointer-events: none; transform: translate(-50%, -60%); box-shadow: 0 6px 20px rgba(0,0,0,.2); opacity: .9; }
body.dragging, body.dragging * { cursor: grabbing !important; }
.placebar { z-index: 6; }
.placebar.bad .sel-name span { color: var(--warn); }
.placebar .ok { background: var(--acc); color: #fff; border-color: var(--acc); }
.placebar .ok:disabled { opacity: .45; }
.placebar:not([hidden]) ~ .warn { top: auto; bottom: 60px; }
@media (max-width: 760px) { .placebar .sel-btns button { height: 40px; padding: 0 14px; } }
@media (max-width: 760px) { .placebar .sel-name span { display: block; font-size: 12px; } .placebar { flex-wrap: wrap; } }
@media (min-width: 761px) { .hint { left: auto; right: 14px; transform: none; } }

/* ét kendt mål i banneret */
.reno-measure { margin-top: 8px; }
.reno-measure label { display: block; font-size: 13px; font-weight: 600; }
.reno-measure label span { font-weight: 400; color: var(--mute); }
.reno-measure .row { display: flex; gap: 6px; margin-top: 4px; }
.reno-measure select, .reno-measure input { height: 34px; border: 1px solid var(--line); border-radius: 8px; background: #fff; font: inherit; font-size: 13px; padding: 0 6px; }
.reno-measure select { flex: 1; min-width: 0; }
.reno-measure input { width: 76px; }
.reno-measure button { height: 34px; padding: 0 12px; border-radius: 8px; border: 0; background: var(--acc); color: #fff; font-weight: 600; }
@media (max-width: 760px) { .reno-measure input { font-size: 16px; } }
@media (max-width: 760px) {
  .reno { left: 8px; right: 8px; top: 8px; max-width: none; padding: 8px 30px 8px 10px; font-size: 13px; }
  .reno .note, .reno-measure label span { display: none; }
  .reno .styles.small { display: flex; flex-wrap: nowrap; overflow-x: auto; gap: 6px; margin-top: 6px; }
  .reno .styles.small button { flex: none; white-space: nowrap; padding: 6px 10px; min-height: 0; }
  .reno .styles.small button small, .reno .styles.small button span { display: none; }
  .reno-scale { margin-top: 4px; }
}
@keyframes flashm { from { background: #e3f0ee; } to { background: transparent; } }
.reno-measure.flash { animation: flashm 1.2s ease-out; border-radius: 8px; }

/* Demo: forfatter */
.by { font-size: 12px; color: var(--mute); text-decoration: none; border: 1px solid var(--line); border-radius: 999px; padding: 3px 9px; white-space: nowrap; }
.by:hover { color: var(--ink); border-color: var(--ink); }
.foot a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
@media (max-width: 760px) { .by { font-size: 11px; padding: 2px 7px; } }
@media (max-width: 420px) { .title { display: none; } }
.brand { white-space: nowrap; }
