: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;
  }
}
