* {
  box-sizing: border-box;
}
body {
  margin: 0;
  font:
    15px/1.4 Inter,
    -apple-system,
    BlinkMacSystemFont,
    Arial,
    sans-serif;
  color: #292e29;
  background: #f8f7f3;
}
header,
.row,
.compare,
.demos {
  display: flex;
  align-items: center;
  gap: 12px;
}
header {
  height: 64px;
  background: #fff;
  padding: 0 3vw;
  border-bottom: 1px solid #dedfd8;
}
header strong {
  font:
    26px Georgia,
    serif;
}
header span {
  margin-right: auto;
  color: #686d63;
}
button,
select,
input[type='search'],
.upload {
  font: inherit;
  color: inherit;
  border: 1px solid #c9cdc3;
  border-radius: 7px;
  padding: 8px 12px;
  background: #fff;
  cursor: pointer;
}
button:hover,
.active,
.upload {
  background: #23443c;
  color: white;
}
main {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  height: calc(100dvh - 64px);
}
.stage {
  background: #d9d7cf;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  place-items: center;
  padding: 20px;
  overflow: hidden;
}
#frame {
  position: relative;
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
}
canvas {
  grid-area: 1/1;
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
}
#marks {
  cursor: crosshair;
  touch-action: manipulation;
}
.compare {
  border-radius: 10px;
  background: white;
  padding: 8px 16px;
  margin-top: 12px;
}
aside {
  padding: 24px;
  overflow: auto;
  background: #fdfcf8;
}
h1,
h2 {
  font-family: Georgia, serif;
  font-weight: 500;
  margin: 5px 0 12px;
}
h1 {
  font-size: 32px;
}
small {
  color: #5a685a;
  letter-spacing: 2px;
}
#status {
  color: #4c675d;
  min-height: 2.5em;
}
label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
aside > label,
.row {
  margin: 6px 0;
  flex-wrap: wrap;
}
.row button {
  font-size: 13px;
}
aside > label select {
  max-width: 210px;
}
h2 {
  margin-top: 20px;
}
#search {
  width: 100%;
}
#list,
.demos {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 12px;
}
#list button,
.demos button {
  text-align: left;
  padding: 5px;
}
#list img,
.demos img {
  display: block;
  width: 100%;
  height: 92px;
  border-radius: 4px;
  object-fit: cover;
  margin-bottom: 5px;
}
#list span {
  display: block;
  font-size: 11px;
}
.upload input {
  display: none;
}
dialog {
  border: 0;
  border-radius: 14px;
  padding: 24px;
  width: min(430px, 92vw);
}
dialog::backdrop {
  background: #18221cd4;
}
#pair img {
  width: 150px;
}
button:disabled {
  opacity: 0.5;
}
input[type='range'] {
  accent-color: #356354;
}
#welcome p {
  color: #5a655b;
}
@media (max-width: 800px) {
  main {
    display: block;
    height: auto;
  }
  .stage {
    height: 52dvh;
    padding: 6px;
    position: sticky;
    top: 0;
    z-index: 1;
  }
  aside {
    padding: 15px;
  }
  header {
    padding: 8px;
    height: 56px;
    gap: 6px;
  }
  header strong {
    font-size: 19px;
    margin-right: auto;
  }
  header span {
    display: none;
  }
  header button {
    font-size: 12px;
  }
  #list {
    grid-template-columns: repeat(3, 1fr);
  }
}
.stage,
#frame {
  min-height: 0;
  min-width: 0;
}
#frame #original,
#frame canvas {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
}
.compare {
  z-index: 1;
}
#details {
  margin: 10px 0;
  font-size: 13px;
}
#details a {
  display: block;
  color: #335849;
  margin-top: 4px;
}
#shareResult {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 12px 0;
}
#shareResult input {
  width: 100%;
  padding: 8px;
}
#shareResult a {
  color: #335849;
}
.stage.expanded {
  position: fixed;
  inset: 0;
  z-index: 6;
  height: 100dvh;
}
.compare button {
  font-size: 12px;
  padding: 4px 8px;
}
#recent:not(:empty) {
  margin: 14px 0;
}
#recent small {
  display: block;
  letter-spacing: 0;
}
#recent img {
  width: 46px;
  height: 42px;
  object-fit: cover;
}
#recent button {
  padding: 2px;
  line-height: 0;
  margin-right: 4px;
}
#tileControls:not([hidden]),
#measureForm {
  display: grid;
  gap: 10px;
}
#measureForm input {
  width: 8ch;
  padding: 6px;
}
#measureInfo {
  font-size: 13px;
  color: #455e51;
}
[hidden] {
  display: none !important;
}
#applied {
  margin: 12px 0;
  font-size: 14px;
}
#applied summary {
  cursor: pointer;
  color: #34594f;
}
#appliedList {
  display: grid;
  gap: 4px;
  margin-top: 6px;
}
#appliedList button {
  text-align: left;
  font-size: 13px;
}
.manager {
  max-width: 720px;
  padding: 24px;
  margin: auto;
}
.manager form,
.manager section {
  display: grid;
  gap: 14px;
}
.manager input:not([type='checkbox']) {
  padding: 8px;
  max-width: 100%;
  border: 1px solid #b8beb2;
  border-radius: 5px;
}
.manager fieldset {
  border: 1px solid #c9cdc3;
  border-radius: 8px;
}
.manager fieldset label {
  margin: 6px;
}
.manager input[type='number'] {
  width: 95px;
}
.manager button {
  justify-self: start;
}
#measureTransfer img {
  display: block;
}
#measureTransfer a {
  color: #34594f;
}
#xrOverlay {
  position: fixed;
  inset: 0;
  color: white;
}
#reticle {
  position: absolute;
  inset: 50% auto auto 50%;
  transform: translate(-50%, -50%);
  font-size: 42px;
}
#xrOverlay footer {
  position: absolute;
  bottom: 7%;
  left: 4%;
  right: 4%;
  padding: 16px;
  border-radius: 12px;
  background: #182821d9;
  text-align: center;
  color: white;
}

#regionTools {
  border: 0;
  padding: 0;
  margin: 10px 0;
}
#regionTools legend {
  margin-bottom: 5px;
}
#regionTools [aria-pressed='true'] {
  background: #23443c;
  color: white;
}
#marks.selecting-region {
  touch-action: none;
}

:root {
  --ink: #24352f;
  --paper: #fffefa;
  --line: #dfdfd4;
  --pine: #244c40;
}
body:has(#frame) {
  color: var(--ink);
  background: var(--paper);
}
body:has(#frame) header {
  border-color: var(--line);
  background: var(--paper);
  padding-inline: clamp(12px, 3vw, 46px);
}
header strong {
  letter-spacing: -0.045em;
}
#download,
.upload {
  color: #fff;
  background: var(--pine);
  border-color: var(--pine);
}
header button,
.compare button {
  border-radius: 20px;
}
.stage {
  position: relative;
  background: #e8e6de;
  padding: clamp(8px, 1.4vw, 24px);
}
#original {
  box-shadow: 0 5px 30px #35352814;
}
.compare {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 24px;
  gap: 10px;
  padding: 5px 8px;
}
.compare label {
  font-size: 13px;
  white-space: nowrap;
}
.compare button {
  background: transparent;
  border-color: transparent;
  padding: 6px 9px;
}
.compare button:hover {
  background: var(--pine);
}
.compare button:focus-visible,
button:focus-visible,
.sectionHead a:focus-visible {
  outline: 2px solid #34745e;
  outline-offset: 2px;
}
aside {
  background: var(--paper);
  padding: 22px;
  scrollbar-width: thin;
}
aside h1 {
  font-size: 27px;
  margin: 0;
  letter-spacing: -0.04em;
}
aside h2 {
  font-size: 23px;
  letter-spacing: -0.035em;
  margin: 14px 0 10px;
}
#status {
  font-size: 13px;
  margin: 5px 0 8px;
  min-height: 1.5em;
}
aside > label {
  display: flex;
}
#surface {
  flex: 1;
  max-width: 100%;
}
#list {
  max-height: min(43vh, 440px);
  overflow-y: auto;
  padding: 2px 3px 6px;
  scrollbar-width: thin;
  align-content: start;
}
#list button {
  padding: 4px 4px 8px;
  overflow: hidden;
  border: 1px solid var(--line);
  font-weight: 550;
  text-align: left;
}
#list img {
  height: 82px;
}
#list span {
  color: #666e62;
  font-weight: 400;
}
#list button:is(.active, :hover) span {
  color: #ddede3;
}
#editing {
  border-top: 1px solid var(--line);
  margin-top: 20px;
  padding-top: 4px;
}
#editing summary,
#facets summary,
#wallCopy summary {
  cursor: pointer;
  font-size: 13px;
  padding: 6px 0;
}
#quadGuide {
  display: flex;
  grid-row: 2;
  margin-top: 6px;
  max-width: 98%;
  align-items: center;
  gap: 5px;
  padding: 5px 8px;
  background: var(--ink);
  color: #fff;
  border-radius: 20px;
  font-size: 13px;
}
#quadGuide button {
  color: var(--ink);
  background: var(--paper);
  border: 0;
  padding: 4px 7px;
  border-radius: 15px;
  font-size: 12px;
}
#marks.placing-corners {
  touch-action: none;
}
#welcome {
  padding: clamp(20px, 4vw, 34px);
  background: var(--paper);
}
#welcome h2 {
  font-size: 34px;
  letter-spacing: -0.045em;
  margin: 0;
}
@media (max-width: 800px) {
  .stage {
    position: sticky;
    height: 48dvh;
    padding: 5px;
  }
  aside {
    padding: 16px;
  }
  .compare {
    gap: 2px;
    flex-wrap: wrap;
    justify-content: center;
    margin: 3px 0;
    padding: 3px;
  }
  .compare label,
  .compare button {
    font-size: 11px;
  }
  .compare input[type='range'] {
    width: 70px;
  }
  #catalogPanel,
  #editing {
    scroll-margin-top: 49dvh;
  }
  #list {
    max-height: 42dvh;
  }
  #list img {
    height: 65px;
  }
  header button {
    padding: 6px 7px;
  }
}

.surfaceBar,
.sectionHead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.surfaceBar h1 {
  font-size: 23px;
}
.surfaceBar select {
  min-width: 0;
  width: 70%;
}
.sectionHead a {
  white-space: nowrap;
  color: var(--pine);
  font-size: 12px;
  text-underline-offset: 3px;
}
.catalogTools {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px;
  align-items: start;
}
.catalogTools #facets[open] {
  grid-column: 1/-1;
}
.catalogTools #facets summary {
  padding: 9px 8px;
  background: #f0f1e9;
  border-radius: 7px;
}
#catalogPanel {
  border-top: 1px solid var(--line);
  margin-top: 14px;
}
.stage:has(#quadGuide:not([hidden])) .compare {
  display: none;
}
@media (max-width: 800px) {
  #catalogPanel {
    margin-top: 8px;
  }
  .sectionHead h2 {
    margin-top: 9px;
  }
  #list {
    margin-top: 8px;
  }
}

/* Room selection and the two ends of a phone transfer share one dialog. */
#welcome {
  color: var(--ink);
  width: min(610px, calc(100vw - 28px));
  max-height: calc(100dvh - 28px);
  padding: clamp(20px, 3.2vw, 36px);
  border: 1px solid #deded3;
  border-radius: 18px;
  box-shadow: 0 24px 96px #10231f38;
}
#welcome::backdrop { background: #232a27a8; backdrop-filter: blur(4px); }
.roomHeading { display: flex; align-items: center; gap: 12px; }
#welcome h2 { font-size: clamp(30px, 4vw, 39px); line-height: 1.1; }
#roomTitle:focus { outline: none; }
#roomBack, #close {
  padding: 0;
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 50%;
  font: 22px/1 system-ui, sans-serif;
}
#close { margin-inline-start: auto; }
#roomIntro { margin: 10px 0 22px; font-size: 14px; }
#roomIntro:empty, #pair:empty { display: none; }
#roomActions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
#roomActions button {
  display: flex; align-items: center; gap: 13px; padding: 15px 16px;
  text-align: start; font-weight: 600; background: #f6f5ef;
  border: 1px solid #dcded3; border-radius: 10px; color: var(--ink);
}
#roomActions button:hover { border-color: #6e8877; background: #ecf0e8; }
#roomActions small { display: block; font-size: 12px; font-weight: 400; letter-spacing: 0; }
.uploadIcon, .phoneIcon { flex: none; position: relative; display: inline-block; color: var(--pine); }
.uploadIcon { width: 23px; border-bottom: 2px solid; text-align: center; font: 25px/1 system-ui; }
.phoneIcon { width: 16px; height: 24px; margin-inline: 4px 3px; border: 1.7px solid; border-radius: 4px; }
.phoneIcon::after { content: ''; position: absolute; bottom: 2px; left: 4px; right: 4px; border-top: 1.5px solid; }
#sampleRooms { border-top: 1px solid var(--line); margin-top: 23px; padding-top: 18px; }
#sampleRooms h3 { font: 500 21px Georgia, serif; margin: 0 0 10px; }
#welcome .demos { gap: 12px; margin: 0; }
#welcome .demos button { padding: 0; overflow: hidden; position: relative; border: 0; border-radius: 9px; background: #282821; }
#welcome .demos img { display: block; margin: 0; height: clamp(130px, 18vw, 200px); border-radius: 0; object-position: center 78%; }
#welcome .demos span {
  position: absolute; bottom: 0; inset-inline: 0; padding: 26px 13px 10px;
  background: linear-gradient(transparent,#161b16ca); color: #fff; font: 500 20px Georgia, serif;
}
#welcome .demos button:hover span { text-decoration: underline; text-underline-offset: 4px; }
#welcome #recent:not(:empty) { margin: 19px 0 0; }
#welcome #recent small { margin-bottom: 7px; font-size: 13px; }
#welcome #recent button { display: inline-flex; align-items: center; gap: 5px; padding: 3px 7px 3px 3px; font-size: 12px; line-height: 1.25; margin-bottom: 4px; }
#welcome #recent img { width: 31px; height: 31px; border-radius: 4px; }
#qrPanel { display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 20px; padding: 16px; border: 1px solid var(--line); border-radius: 12px; }
#qrImage { display: grid; place-items: center; width: 170px; max-width: 100%; aspect-ratio: 1; background: #fff; }
#qrImage img { width: 100%; image-rendering: pixelated; }
#qrPanel ol { margin: 0; padding-left: 1.4em; font-size: 14px; }
#qrPanel li + li { margin-top: 10px; }
#qrPanel li::marker { color: var(--pine); font-weight: 650; }
#pair { font-size: 14px; margin: 14px 0 0; }
#renewQr { margin-top: 12px; }
#welcome[data-mode='receive'] { max-width: 410px; }
#welcome[data-mode='receive'] #roomActions { grid-template-columns: 1fr; }
#roomBusy { position: absolute; z-index: 2; background: var(--paper); color: var(--pine); border-radius: 20px; padding: 10px 16px; box-shadow: 0 3px 20px #16231e19; }
#list button { position: relative; }
#list button:not(.active):hover { background: #f1f3eb; color: var(--ink); border-color: #7e9183; }
#list button:not(.active):hover span { color: #4a584f; }
#list button.active::after { content: '✓'; position: absolute; right: 8px; top: 8px; width: 21px; height: 21px; text-align: center; border-radius: 50%; background: var(--pine); color: white; }
@media (max-width: 520px) {
  #welcome { padding: 20px; }
  #roomActions { gap: 7px; }
  #roomActions button { padding: 12px 9px; gap: 7px; font-size: 13px; }
  #roomActions small { font-size: 11px; }
  #qrPanel { grid-template-columns: 1fr; justify-items: center; gap: 10px; }
  #qrPanel ol { width: min(100%, 250px); }
}

#welcome #recent button { max-width: 100%; }
#welcome #recent button span { max-width: 15ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

[data-language] {
  min-inline-size: 36px;
  padding: 5px 9px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}

.roomHeading [data-language] {
  margin-inline-start: auto;
}
.roomHeading #close { margin-inline-start: 0; }

@media (max-width: 480px) {
  html[lang='en'] body:has(#frame) header { padding-inline: 8px; }
  html[lang='en'] header button { line-height: 1.15; }
}
