body {
  font-size: 14px;
}
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 185px;
  padding: 22px 14px;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 26px;
  background: var(--panel);
}
.brand {
  font-size: 21px;
  font-weight: 700;
  display: flex;
  gap: 9px;
  align-items: center;
  text-decoration: none;
  color: var(--text);
}
nav {
  display: grid;
  gap: 5px;
}
nav a {
  padding: 9px 10px;
  color: var(--muted);
  text-decoration: none;
  border-radius: 6px;
}
nav a.active {
  background: #243c3b;
  color: var(--accent);
}
.home {
  margin-top: auto;
  font-size: 12px;
  color: var(--muted);
}
main {
  margin: 0 0 0 185px;
  max-width: 1250px;
  padding: 22px 26px 90px;
}
h1 {
  font-size: 23px;
  margin: 0 0 18px;
  letter-spacing: 0;
}
h1 small {
  font-size: 14px;
  color: var(--muted);
  font-weight: 400;
  margin-left: 10px;
}
h2 {
  font-size: 15px;
  margin: 0 0 10px;
}
p {
  margin: 8px 0;
}
.card {
  padding: 16px;
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 8px;
  margin: 14px 0;
}
.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}
.stat {
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 8px;
}
.stat strong {
  font-size: 23px;
  display: block;
}
.stat span,
.sources {
  font-size: 12px;
  color: var(--muted);
}
.measurements {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}
label {
  font-weight: 600;
  display: block;
}
textarea {
  width: 100%;
  margin-top: 8px;
  min-height: 95px;
  resize: vertical;
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
  font: inherit;
}
.heading,
.planbar,
.legend {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.badge {
  color: var(--muted);
  font-size: 11px;
}
.tabs,
.tools,
.toolbar,
.room-buttons {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
}
button {
  font: inherit;
  cursor: pointer;
  padding: 7px 11px;
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 6px;
}
button:hover,
button[aria-pressed="true"] {
  border-color: var(--accent);
  color: var(--accent);
}
button:disabled {
  opacity: 0.5;
  cursor: default;
}
#viewport {
  margin-top: 12px;
  background: #e9ede6;
  height: clamp(280px, 52vh, 580px);
  overflow: hidden;
  border-radius: 8px;
  touch-action: none;
  cursor: grab;
}
#viewport:active {
  cursor: grabbing;
}
#drawing,
#model {
  width: 100%;
  height: 100%;
  display: block;
}
#drawing[hidden],
#model[hidden],
[hidden] {
  display: none !important;
}
.floor {
  stroke: #d2d9ce;
  stroke-width: 1;
}
.room {
  cursor: pointer;
}
.room text {
  font: 12px system-ui;
  fill: #253d36;
  pointer-events: none;
}
.room .area {
  font-size: 11px;
  fill: #63736a;
}
.room.selected .floor {
  stroke: #167761;
  stroke-width: 3;
}
.walls {
  stroke: #53655b;
  stroke-width: 5;
  fill: none;
  stroke-linecap: square;
}
.legend {
  font-size: 11px;
  color: var(--accent);
  margin: 8px 0 12px;
}
.legend .waste {
  color: #df9a71;
}
#gesture {
  color: var(--muted);
}
.room-buttons button {
  font-size: 12px;
  padding: 5px 9px;
}
#room-note ul {
  padding-left: 20px;
  margin-bottom: 0;
}
#room-note h2 {
  margin-bottom: 5px;
}
#room-note small {
  color: var(--accent);
}
.toolbar {
  position: sticky;
  top: 0;
  padding: 8px 0;
  background: var(--bg);
  z-index: 2;
}
.brief-section {
  border: 1px solid var(--line);
  border-radius: 8px;
  margin: 12px 0;
  background: var(--panel);
  overflow: hidden;
}
.brief-section h2 {
  padding: 12px 14px;
  margin: 0;
  border-bottom: 1px solid var(--line);
}
.editor {
  padding: 12px 14px;
  min-height: 95px;
  outline: none;
}
.editor:focus {
  box-shadow: inset 0 0 0 1px var(--accent);
}
.editor p:first-child {
  margin-top: 0;
}
.editor p:last-child {
  margin-bottom: 0;
}
#savebar {
  position: fixed;
  bottom: 0;
  left: 185px;
  right: 0;
  background: var(--panel);
  border-top: 1px solid var(--line);
  padding: 10px 26px;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 14px;
  z-index: 5;
}
#status {
  color: var(--muted);
  font-size: 12px;
}
#save {
  background: #225749;
}
#error {
  border: 1px solid var(--danger);
  padding: 12px;
  margin-bottom: 15px;
  color: var(--danger);
}
@media (max-width: 700px) {
  .sidebar {
    position: static;
    width: auto;
    padding: 12px 14px;
    gap: 12px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .brand {
    font-size: 18px;
  }
  nav {
    display: flex;
    gap: 4px;
  }
  nav a {
    padding: 7px 9px;
    font-size: 12px;
  }
  .home {
    position: absolute;
    right: 15px;
    top: 17px;
  }
  main {
    margin: 0;
    padding: 18px 14px 80px;
  }
  .stats {
    grid-template-columns: repeat(2, 1fr);
  }
  .measurements {
    grid-template-columns: 1fr;
  }
  .heading {
    align-items: flex-start;
  }
  .heading h1 {
    font-size: 21px;
  }
  .badge {
    max-width: 140px;
    text-align: right;
  }
  .planbar {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
  }
  .tabs button {
    padding: 7px 9px;
    font-size: 12px;
  }
  .tools {
    align-self: flex-end;
  }
  #viewport {
    height: 340px;
  }
  .legend {
    flex-wrap: wrap;
    gap: 5px;
  }
  #savebar {
    left: 0;
    padding: 10px 14px;
  }
}
@media print {
  body {
    background: white;
    color: black;
  }
  .sidebar,
  #overview,
  #plan,
  #savebar,
  .toolbar,
  #print,
  #error,
  #loading {
    display: none !important;
  }
  main {
    margin: 0;
    padding: 0;
    max-width: none;
  }
  #brief {
    display: block !important;
  }
  h1 {
    font-size: 20pt;
  }
  .brief-section {
    background: white;
    border-color: #ccc;
    break-inside: avoid;
  }
  .editor {
    min-height: 0;
  }
  .brief-section h2 {
    border-color: #ccc;
  }
  .heading:after {
    content: "Altamira · Nice · Phase 1";
    font-size: 10pt;
  }
  button {
    display: none;
  }
}

button {
  width: auto;
  min-height: 36px;
  margin: 0;
  letter-spacing: normal;
}
#viewport {
  user-select: none;
}
.tools,
.tabs {
  flex-wrap: wrap;
}
.room-buttons {
  margin-bottom: 10px;
}
.room-buttons button {
  min-height: 36px;
}
#invite-form {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}
#invite-name {
  font: inherit;
  padding: 0.6rem;
  min-width: 0;
}
#invitations .card,
#contributions .card {
  display: flex;
  gap: 0.6rem;
  align-items: center;
  flex-wrap: wrap;
  margin: 0.6rem 0;
}
#contributions textarea {
  width: 100%;
  min-height: 5rem;
  font: inherit;
  padding: 0.5rem;
}
#invitations strong {
  flex: 1;
  min-width: 12rem;
}

#viewport { position:relative; }
.survey-markers { position:absolute;inset:0;pointer-events:none;overflow:hidden; }
.survey-marker { position:absolute;transform:translate(-50%,-50%);pointer-events:auto;border-radius:50%;min-height:26px;width:26px;padding:0;background:#a64223;color:white;border:2px solid white;font-size:12px; }
.survey-marker.active { background:#126c59;outline:2px solid #126c59; }
.survey-badge { cursor:pointer; }
.survey-badge circle { fill:#a64223;stroke:white;stroke-width:1.5; }
.survey-badge.active circle { fill:#126c59;stroke:#126c59;stroke-width:3; }
.survey-badge text { fill:white;font:11px system-ui;pointer-events:none; }
.survey-card select { width:100%;margin:12px 0; }
.survey-fields { display:grid;grid-template-columns:repeat(auto-fit,minmax(210px,1fr));gap:14px;margin-bottom:16px; }
.survey-fields input,.survey-card select { font:inherit;background:var(--panel);color:var(--text);border:1px solid var(--line);border-radius:6px;padding:10px;min-width:0; }
.survey-fields input { display:block;width:100%;margin-top:5px; }
.survey-form { display:block; }
.survey-current { white-space:pre-wrap;overflow-wrap:anywhere; }
.contribution-fields { width:100%;border-collapse:collapse; }
.contribution-fields td,.contribution-fields th { text-align:left;padding:6px;border-bottom:1px solid var(--line);overflow-wrap:anywhere; }
@media(max-width:700px){.survey-fields{grid-template-columns:1fr}.contribution-fields{font-size:12px}}

.survey-backdrop { position:fixed;inset:0;background:#0008;z-index:90; }
body.survey-open { overflow:hidden; }
.survey-sidebar { position:fixed;inset:var(--survey-top,0px) 0 auto auto;z-index:91;width:min(440px,calc(100% - 24px));height:var(--survey-height,100dvh);margin:0;border-radius:0;overflow:hidden;padding:20px;background:var(--panel);box-shadow:-12px 0 40px #0005;display:flex;flex-direction:column; }
.survey-sidebar>h2,.survey-sidebar>select { flex-shrink:0; }
.survey-sidebar h2 { margin:0 42px 12px 0;font-size:18px; }
.survey-sidebar .survey-close { position:absolute;right:12px;top:10px;font-size:24px;padding:4px 12px; }
.survey-sidebar .survey-fields { grid-template-columns:1fr;gap:12px; }
.survey-sidebar .survey-task { display:block;padding-left:25px;position:relative; }
.survey-sidebar .survey-task::before { content:'☐';position:absolute;left:0;color:var(--muted); }
.survey-sidebar .survey-task.completed::before { content:'☑';color:var(--accent); }
.survey-sidebar .survey-form { display:flex;flex-direction:column;flex:1;min-height:0; }
.survey-sidebar .survey-scroll { overflow-y:auto;flex:1;min-height:0;overscroll-behavior:contain; }
.survey-sidebar .survey-scroll>label { display:block;margin:16px 0; }
.survey-sidebar textarea { display:block;min-height:90px;width:100%;margin-top:5px; }
.survey-sidebar .survey-photo-task input { display:block;width:100%;margin-top:8px; }
.survey-sidebar .survey-footer { flex-shrink:0;background:var(--panel);padding:12px 0 max(12px,env(safe-area-inset-bottom));border-top:1px solid var(--line); }
.survey-sidebar .survey-footer button { width:100%; }
.survey-sidebar .survey-footer p:empty { display:none; }
.survey-hint { display:block;color:var(--muted);font-size:12px;margin-top:4px; }
.survey-photo-action { margin:4px 0 12px;text-align:left;font-size:12px; }

.survey-marker.surface-floor { border-radius:5px; }
.survey-badge.surface-floor rect { fill:#a64223;stroke:white;stroke-width:1.5; }
.survey-badge.surface-floor.active rect, .survey-badge.surface-floor.complete rect { fill:#126c59; }
.survey-badge.complete circle { fill:#126c59; }

.survey-marker.complete { background:#126c59; }
.survey-photo-row { display:flex;align-items:center;gap:6px; }
.survey-photo-row .survey-photo-task { flex:1;min-width:0; }
.survey-photo-row .survey-photo-remove { flex:none;width:36px;height:36px;padding:0;border:0;background:transparent;color:inherit;font-size:24px;line-height:1; }
