:root {
  color-scheme: dark;
  --bg: #141110;
  --panel: #1c1917;
  --raised: #26211d;
  --ink: #ece5d8;
  --muted: #b9ae9e;
  --accent: #d9a827;
  --line: #433b33;
  font-family: system-ui, sans-serif;
  font-size: 15px;
  color: var(--ink);
  background: var(--bg);
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
}
button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}
button,
select,
input,
textarea {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 8px;
  min-height: 44px;
  padding: 9px 12px;
}
button {
  cursor: pointer;
}
button:hover,
button[aria-pressed="true"] {
  background: var(--raised);
  border-color: var(--accent);
}
button:disabled {
  opacity: 0.45;
  cursor: default;
}
.primary {
  background: var(--accent);
  color: #211700;
  border-color: var(--accent);
  font-weight: 650;
}
.primary:hover {
  background: #edc358;
}
a {
  color: var(--accent);
}
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}
h1,
h2 {
  font-family: Georgia, serif;
  font-weight: 400;
  line-height: 1.2;
  margin: 8px 0 16px;
}
h1 {
  font-size: 24px;
}
h2 {
  font-size: 30px;
}
p {
  line-height: 1.6;
  color: var(--muted);
}
label {
  display: flex;
  gap: 7px;
  align-items: center;
}
label:has(input:not([type="checkbox"])),
label:has(textarea) {
  align-items: stretch;
  flex-direction: column;
  margin: 12px 0;
}
label > span {
  font-size: 13px;
  color: var(--muted);
}
input[type="checkbox"] {
  accent-color: var(--accent);
  min-height: 20px;
  width: 18px;
  height: 18px;
}
input[type="color"] {
  padding: 3px;
  width: 100%;
}
textarea {
  min-height: 82px;
  resize: vertical;
}
input,
select {
  min-width: 0;
}
.project-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 20px;
  background: var(--panel);
  flex-wrap: wrap;
}
.brand {
  font:
    28px Georgia,
    serif;
  color: var(--ink);
  text-decoration: none;
  margin-right: 16px;
}
.brand span {
  display: block;
  font:
    11px system-ui,
    sans-serif;
  color: var(--muted);
  margin-top: 3px;
}
.project-picker {
  flex: 1;
  min-width: 170px;
  max-width: 320px;
}
.project-picker select {
  width: 100%;
}
#save-status {
  font-size: 12px;
  color: var(--muted);
  flex: 1;
  min-width: 100px;
}
.wide {
  width: 100%;
  margin: 8px 0;
}
.toolbar {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
  padding: 12px 16px;
}
.toolbar.editing {
  padding-top: 0;
  font-size: 13px;
}
.segmented {
  display: flex;
  gap: 2px;
}
.segmented button {
  border-radius: 6px;
}
.toolbar select {
  max-width: 100px;
}
main {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 350px;
  align-items: start;
}
.workspace {
  min-width: 0;
}
#viewport {
  height: calc(100svh - 255px);
  min-height: 460px;
  position: relative;
  background: #c6dfef;
  overflow: hidden;
}
#viewport canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}
#canvas-caption {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 9px 16px;
  font-size: 12px;
  background: #f4f1e2dc;
  color: #333d39;
  pointer-events: none;
}
#graphics-error {
  position: absolute;
  inset: 25%;
  z-index: 3;
  color: #222;
  background: #fff;
  padding: 20px;
}
#viewport[data-graphics="lost"]:after {
  content: "Restoring graphics…";
  position: absolute;
  inset: 30%;
  background: white;
  color: #222;
  padding: 30px;
}
.rotate-handle {
  position: absolute;
  transform: translate(-50%, -50%);
  border: 2px solid white;
  border-radius: 50%;
  width: 46px;
  height: 46px;
  padding: 0;
  background: #76642c;
  color: white;
  font: 28px system-ui;
  box-shadow: 0 2px 8px #0005;
  touch-action: none;
}
.bottomline {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 12px 16px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 12px;
}
.bottomline > span:first-child {
  flex: 1;
  min-width: 200px;
}
.bottomline button {
  font-size: 12px;
}
aside {
  padding: 0 18px 24px;
  border-left: 1px solid var(--line);
  background: var(--panel);
  max-height: calc(100svh - 86px);
  overflow: auto;
  scrollbar-gutter: stable;
}
.sidebar-tabs {
  display: flex;
  gap: 3px;
  padding: 12px 0;
  position: sticky;
  top: 0;
  background: var(--panel);
  z-index: 2;
}
.sidebar-tabs button {
  flex: 1;
  font-size: 13px;
  padding: 8px;
}
.section-heading {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
}
.section-heading h1 {
  max-width: 200px;
}
#total {
  white-space: nowrap;
  color: var(--accent);
}
.product-photo {
  width: 100%;
  aspect-ratio: 4/3;
  object-fit: contain;
  background: #f5f3ee;
  border-radius: 10px;
}
.item-row {
  display: flex;
  width: 100%;
  text-align: left;
  gap: 12px;
  align-items: center;
  margin: 5px 0;
  border-color: transparent;
}
.item-row img {
  width: 56px;
  height: 56px;
  object-fit: contain;
  background: #f5f3ee;
  border-radius: 6px;
}
.item-row span {
  flex: 1;
}
.item-row small {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-top: 4px;
}
.item-row[aria-pressed="true"] {
  border-color: var(--accent);
}
.product-entry {
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}
.product-entry h3 {
  font-weight: 500;
  font-size: 17px;
  margin: 8px 0;
}
.product-entry p {
  font-size: 13px;
  margin: 6px 0;
}
.price {
  font-size: 20px;
  color: var(--ink);
}
.meta {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.6;
}
.fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.fields.dimensions {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.fields input {
  width: 100%;
}
.fields label {
  margin: 8px 0;
}
input[type="range"] {
  width: 100%;
  padding: 0;
  accent-color: var(--accent);
}
.actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 20px;
}
.actions button {
  flex: 1;
}
.error {
  color: #ffa99c;
}
.danger {
  color: #ffb5a9;
}
#notice {
  background: #51401d;
  padding: 10px 20px;
  line-height: 1.4;
  font-size: 14px;
}
dialog {
  border: 1px solid #62594c;
  border-radius: 14px;
  background: var(--panel);
  color: var(--ink);
  padding: 26px;
  width: min(600px, calc(100vw - 24px));
  max-height: 90svh;
  overflow: auto;
}
dialog::backdrop {
  background: #050606b8;
}
dialog form > label {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  margin: 14px 0;
}
#rooms-dialog {
  width: min(760px, calc(100vw - 24px));
}
.room-editor {
  border-bottom: 1px solid var(--line);
  padding-bottom: 20px;
  margin-bottom: 20px;
}
.room-editor .fields {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.window-editor {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  padding: 10px;
  background: var(--raised);
  border-radius: 8px;
  margin: 8px 0;
}
.window-editor label {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  margin: 0;
}
#review-photo .product-photo {
  max-height: 220px;
}
#draft-review {
  background: var(--raised);
  padding: 15px;
  border-radius: 10px;
  margin-top: 15px;
}
#draft-review li {
  margin: 8px 0;
  line-height: 1.5;
}
#import-status,
#analysis-status {
  line-height: 1.5;
  margin: 12px 0;
  font-size: 13px;
}
[hidden] {
  display: none !important;
}
@media (max-width: 1100px) {
  main {
    grid-template-columns: minmax(0, 1fr) 310px;
  }
  .project-header {
    padding: 12px;
  }
  .toolbar {
    gap: 8px;
  }
  #viewport {
    height: calc(100svh - 300px);
  }
}
@media (max-width: 760px) {
  main {
    display: block;
  }
  .project-header {
    gap: 8px;
  }
  .brand {
    font-size: 24px;
    margin-right: auto;
  }
  .project-picker {
    order: 2;
    max-width: none;
    flex: 1 1 55%;
  }
  #new-project {
    order: 2;
    flex: 1;
  }
  #save-status {
    order: 3;
    flex-basis: 100%;
  }
  .project-header button {
    font-size: 13px;
    padding: 8px;
  }
  #viewport {
    height: 480px;
    min-height: 480px;
  }
  .toolbar {
    padding: 10px;
    gap: 6px;
  }
  .toolbar button,
  .toolbar select {
    font-size: 12px;
    padding: 8px;
  }
  .toolbar.editing {
    font-size: 12px;
  }
  aside {
    max-height: none;
    border: 0;
    border-top: 1px solid var(--line);
    padding: 0 16px 24px;
  }
  .sidebar-tabs {
    position: static;
  }
  #canvas-caption {
    font-size: 11px;
  }
  .bottomline {
    padding: 10px;
  }
  .product-photo {
    max-height: 260px;
  }
  .room-editor .fields {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  dialog {
    padding: 20px;
  }
  .fields.dimensions {
    gap: 5px;
  }
  .fields label > span {
    font-size: 11px;
  }
}
@media (prefers-reduced-motion: no-preference) {
  button {
    transition: background 0.12s;
  }
}
/* Saved assets and a compact, task-based workspace. */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.menu {
  position: relative;
}
summary {
  cursor: pointer;
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: 8px;
  line-height: 1.4;
  padding: 10px 0;
}
summary:before {
  content: "+";
  color: var(--accent);
  font-size: 20px;
}
details[open] > summary:before {
  content: "−";
}
.menu > summary {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 12px;
}
.menu-content {
  position: absolute;
  z-index: 20;
  right: 0;
  top: calc(100% + 6px);
  width: 260px;
  max-height: 70svh;
  overflow: auto;
  padding: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 12px 40px #0008;
  display: grid;
  gap: 8px;
}
.menu-content button {
  text-align: left;
}
.menu-content label {
  margin: 6px 0;
}
.view-options-content {
  right: auto;
  left: 0;
  width: 310px;
}
.menu-content fieldset {
  border: 1px solid var(--line);
  border-radius: 8px;
  display: flex;
  gap: 10px;
  padding: 8px;
}
.menu-content fieldset label {
  font-size: 13px;
}
.history-controls {
  display: flex;
  gap: 4px;
  margin-left: auto;
}
#viewport {
  height: calc(100svh - 205px);
}
.mobile-dock,
.sheet-close {
  display: none;
}
.filter-row {
  display: flex;
  gap: 6px;
  overflow: auto;
  padding: 8px 0 14px;
  scrollbar-width: thin;
}
.filter-row button {
  white-space: nowrap;
  font-size: 12px;
  min-height: 36px;
  padding: 6px 10px;
}
.import-details,
.brief-details {
  border-block: 1px solid var(--line);
  margin: 10px 0 18px;
  padding: 6px 0;
}
#catalog-count {
  padding: 8px 0;
}
.product-entry .product-photo {
  max-height: 170px;
}
.product-entry {
  padding: 14px 0 20px;
}
.upload-tray {
  background: var(--raised);
  border: 1px dashed #766752;
  border-radius: 10px;
  padding: 15px;
  gap: 12px;
}
.upload-tray input {
  font-size: 13px;
  width: 100%;
  padding: 6px;
  background: transparent;
  border: 0;
}
.upload-tray small {
  color: var(--muted);
  line-height: 1.5;
}
#asset-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.asset-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  min-width: 0;
}
.asset-card label {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  margin: 0;
}
.asset-card img,
.file-kind {
  width: 100%;
  height: 110px;
  object-fit: cover;
  background: var(--raised);
}
.file-kind {
  display: grid;
  place-items: center;
  font-size: 24px;
  color: var(--muted);
}
.asset-card label > span:not(.file-kind) {
  padding: 8px;
  font-size: 11px;
  overflow-wrap: anywhere;
}
.asset-card p {
  padding: 0 8px;
  font-size: 11px;
}
.asset-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 8px 8px;
  font-size: 12px;
  gap: 4px;
}
.asset-actions button {
  padding: 4px 6px;
  font-size: 11px;
  min-height: 32px;
}
.generation-form {
  border-top: 1px solid var(--line);
  padding-top: 20px;
  margin-top: 20px;
}
.generation-form h2 {
  font-size: 25px;
}
.credit-notice {
  padding: 10px 12px;
  background: #d9a82713;
  border-left: 2px solid var(--accent);
  font-size: 12px;
  line-height: 1.5;
}
.generation-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px;
  margin: 12px 0;
}
.generation-card h3 {
  margin: 0;
  font:
    22px Georgia,
    serif;
}
.generation-card p,
.generation-card li {
  font-size: 13px;
}
.generation-card ul {
  padding-left: 18px;
}
.help-inline {
  border-radius: 50%;
  min-height: 34px;
  width: 34px;
  padding: 4px;
  flex: none;
}
.help-tabs {
  display: flex;
  gap: 6px;
  overflow: auto;
  margin: 16px 0;
}
.help-tabs button {
  flex: 1;
  white-space: nowrap;
}
.help-illustration {
  width: 100%;
  max-height: 190px;
  background: var(--raised);
  border-radius: 10px;
}
[data-help-pane] svg {
  width: 100%;
  height: 160px;
  background: var(--raised);
  border-radius: 10px;
  color: var(--accent);
}
[data-help-pane] p {
  font-size: 16px;
  max-width: 46ch;
}
.creation-ai {
  margin-top: 20px;
}
.creation-ai label {
  margin: 12px 0;
}
#project-dialog details {
  border-top: 1px solid var(--line);
  padding: 5px 0;
}
@media (max-width: 760px) {
  :root {
    font-size: 16px;
  }
  .project-header {
    padding: 8px 10px;
    gap: 8px;
    flex-wrap: nowrap;
    height: 64px;
  }
  .brand,
  #save-status {
    display: none;
  }
  .project-picker {
    order: 0;
    flex: 1;
    min-width: 0;
    max-width: none;
  }
  .project-picker select {
    font-size: 14px;
    padding: 9px 6px;
    text-overflow: ellipsis;
  }
  .project-header #save,
  .project-header .menu > summary {
    padding: 9px 12px;
    font-size: 14px;
  }
  #view-toolbar {
    height: 54px;
    padding: 5px 10px;
    justify-content: flex-end;
  }
  #view-options .menu-content {
    left: auto;
    right: 0;
  }
  .menu-content .segmented {
    display: flex;
    gap: 4px;
  }
  .menu-content .segmented button {
    flex: 1;
    font-size: 13px;
  }
  .menu-content .history-controls {
    margin: 0;
  }
  .menu-content .history-controls button {
    flex: 1;
  }
  #viewport {
    height: calc(100svh - 182px);
    min-height: 330px;
  }
  #canvas-caption {
    font-size: 11px;
    padding: 8px 12px;
    right: 0;
  }
  .bottomline {
    display: none;
  }
  .mobile-dock {
    display: flex;
    position: fixed;
    z-index: 30;
    bottom: 0;
    left: 0;
    right: 0;
    height: 64px;
    padding: 8px 10px max(8px, env(safe-area-inset-bottom));
    gap: 6px;
    background: var(--panel);
    border-top: 1px solid var(--line);
  }
  .mobile-dock button {
    flex: 1;
    font-size: 14px;
  }
  #inspector {
    display: none;
    position: fixed;
    z-index: 25;
    bottom: 64px;
    left: 0;
    right: 0;
    max-height: 66svh;
    overflow: auto;
    border: 1px solid var(--line);
    border-radius: 16px 16px 0 0;
    padding: 12px 16px 24px;
    box-shadow: 0 -10px 35px #0005;
    scrollbar-gutter: auto;
  }
  body.sheet-open #inspector {
    display: block;
  }
  .sheet-close {
    display: block;
    margin: 0 0 10px auto;
    font-size: 13px;
    min-height: 36px;
  }
  .sidebar-tabs {
    display: none;
  }
  #notice {
    position: fixed;
    left: 10px;
    right: 10px;
    bottom: 76px;
    z-index: 35;
    border-radius: 10px;
    max-height: 100px;
    overflow: auto;
    padding: 10px 14px;
    font-size: 13px;
    pointer-events: none;
  }
  body.sheet-open #notice {
    position: static;
    max-height: 80px;
    font-size: 12px;
  }
  #catalog-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
  }
  .product-entry {
    min-width: 0;
  }
  .product-entry h3 {
    font-size: 14px;
  }
  .product-entry .product-photo {
    height: 120px;
  }
  .product-entry .price {
    font-size: 15px;
  }
  .product-entry .meta {
    font-size: 10px;
  }
  .product-entry button {
    font-size: 12px;
  }
  dialog {
    max-height: 92svh;
    padding: 20px;
  }
}
.menu:not([open]) > .menu-content {
  display: none;
}
@media (max-width: 760px) {
  .help-tabs {
    gap: 4px;
  }
  .help-tabs button {
    padding: 8px 7px;
    font-size: 13px;
  }
}

.model-status { position:absolute; top:45%; left:12%; right:12%; text-align:center; color:#263c48; background:#f3f5f4; padding:16px; border-radius:8px; z-index:3; }
.model-status[hidden] { display:none; }

.gate-signin {
  margin-left: 4px;
  font-weight: 600;
}
/* A group member's Tools panel (apartments/member.js) and a tool's labels on the plan. */
.overlay-labels {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}
.overlay-label {
  position: absolute;
  transform: translate(-50%, -50%);
  background: #fff;
  color: #111;
  padding: 2px 6px;
  border-radius: 4px;
  font: 600 12px/1.3 system-ui, sans-serif;
  white-space: nowrap;
  box-shadow: 0 1px 3px #0004;
}
#tool-stage iframe {
  display: block;
  width: 100%;
  min-height: 120px;
  border: 0;
  border-radius: 10px;
  background: #fff;
}
#tool-list:empty {
  display: none;
}
@media (max-width: 760px) {
  /* A tool draws on the plan, so while its sheet is open the header and View & tools share one 48px row, the sheet
     stays under 30% of the screen and the plan takes the rest. */
  body.tool-sheet.sheet-open .project-header {
    height: 48px;
    padding: 4px 136px 4px 8px;
    gap: 6px;
  }
  body.tool-sheet.sheet-open .project-picker select,
  body.tool-sheet.sheet-open .project-header #save,
  body.tool-sheet.sheet-open .project-header .menu > summary,
  body.tool-sheet.sheet-open #view-options > summary {
    padding: 7px 8px;
    font-size: 13px;
  }
  body.tool-sheet.sheet-open #view-toolbar {
    position: fixed;
    z-index: 20;
    top: 0;
    right: 0;
    height: 48px;
    padding: 4px 8px;
    background: none;
  }
  body.tool-sheet.sheet-open #notice {
    position: fixed;
    top: 52px;
    bottom: auto;
  }
  body.tool-sheet.sheet-open #inspector {
    max-height: 30svh;
    padding-top: 6px;
  }
  body.tool-sheet.sheet-open .sheet-close {
    min-height: 30px;
    margin-bottom: 4px;
    padding: 4px 10px;
  }
  body.tool-sheet.sheet-open #tools-panel .section-heading {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
  }
  body.tool-sheet.sheet-open #viewport {
    height: calc(70svh - 112px);
    min-height: 0;
  }
}
/* While a member's tool draws on the plan, the drag hint would cover its bottom row. */
body.tool-active #canvas-caption {
  display: none;
}
/* After a finger drags a piece in a member's editor (member.js): its name and a Details button over the plan. */
#selection-bar {
  position: absolute;
  z-index: 4;
  left: 8px;
  right: 8px;
  bottom: 8px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 6px 6px 14px;
  background: var(--panel);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 4px 14px #0005;
}
#selection-bar[hidden] {
  display: none;
}
#selection-bar span {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
}
/* A group app's card picture (member.js snapshot mode, apts/<id>/edit?snapshot=1): the plan from above, nothing else. */
html[data-snapshot] body > :not(main),
html[data-snapshot] main > :not(.workspace),
html[data-snapshot] .workspace > :not(#viewport),
html[data-snapshot] #viewport > :not(canvas, .overlay-labels) {
  display: none !important;
}
html[data-snapshot] #viewport {
  position: fixed;
  inset: 0;
  height: auto;
  min-height: 0;
  pointer-events: none;
}
/* A member's editor on a phone: View & tools scrolls to Undo and Redo above the dock (its top sits about 123px down),
   and above the tool sheet while that is open. */
@media (max-width: 760px) {
  body[data-member] #view-options .menu-content {
    max-height: calc(100svh - 196px);
  }
  body[data-member].tool-sheet.sheet-open #view-options .menu-content {
    max-height: calc(70svh - 124px);
  }
}
/* A long press or a slow drag on a member's room moves the view, so it selects no text and pops no Copy bubble. */
body[data-member] #viewport,
body[data-member] #viewport * {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
