:root {
  color-scheme: light;
  --ink: #162027;
  --muted: #5f6f79;
  --line: #d3d9dc;
  --panel: rgba(103, 121, 133, 0.94);
  --chrome: rgba(101, 118, 129, 0.94);
  --accent: #13bed0;
  --accent-dark: #006f78;
  --green: #76b842;
  --green-dark: #3d6b23;
  --danger: #b3261e;
  --shadow: 0 18px 48px rgba(0, 0, 0, 0.24);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #cfd7dc;
  color: var(--ink);
}

button, input, select, textarea { font: inherit; }

button, select, input {
  min-height: 36px;
  border: 1px solid #c9d0d3;
  border-radius: 0;
  background: #fff;
  color: var(--ink);
}

button {
  cursor: pointer;
  padding: 0 12px;
  font-weight: 700;
}

button.active, .tool-grid button:hover, .preset-row button:hover { filter: brightness(0.9); }

label {
  display: grid;
  gap: 6px;
  color: rgba(255, 255, 255, 0.86);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

input, select {
  width: 100%;
  padding: 0 10px;
}

textarea {
  width: 100%;
  height: 170px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 0;
  padding: 10px;
  color: #263033;
  background: #fafbfa;
  line-height: 1.4;
}

.app {
  display: grid;
  grid-template-columns: 330px minmax(540px, 1fr) 332px;
  grid-template-rows: 58px minmax(0, 1fr) 58px;
  height: 100vh;
  min-height: 760px;
  background:
    linear-gradient(rgba(186, 196, 202, 0.42), rgba(186, 196, 202, 0.42)),
    url("./photos/toy-closet.jpeg") center / cover fixed;
}

.global-header {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 28px;
  padding: 0 14px;
  background: var(--chrome);
  color: #fff;
  box-shadow: 0 2px 14px rgba(0, 0, 0, 0.18);
  z-index: 3;
}

.logo-mark {
  font-size: 26px;
  line-height: 1;
  font-weight: 850;
  letter-spacing: 0;
}

.logo-mark span { color: #16d0e4; }

.folder-button {
  position: relative;
  width: 58px;
  border: 0;
  background: transparent;
}

.folder-button span,
.folder-button span::before {
  position: absolute;
  display: block;
  content: "";
  border: 2px solid #fff;
}

.folder-button span {
  left: 12px;
  top: 14px;
  width: 28px;
  height: 18px;
  transform: skewX(-12deg);
}

.folder-button span::before {
  left: 1px;
  top: -8px;
  width: 12px;
  height: 7px;
  border-bottom: 0;
}

.sidebar, .inspector {
  overflow: auto;
  padding: 12px 10px 68px;
  background: rgba(103, 121, 133, 0.88);
}

.workspace {
  display: grid;
  grid-template-rows: auto 1fr;
  min-width: 0;
  padding: 12px;
  background: rgba(238, 243, 245, 0.18);
}

.brand { display: none; }

.panel {
  background: var(--panel);
  border: 0;
  border-radius: 0;
  padding: 14px;
  margin-bottom: 12px;
  color: #fff;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.14);
}

.compact { padding-bottom: 12px; }

.panel-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.brand h1, .topbar h2, .panel h2 {
  margin: 0;
  letter-spacing: 0;
}

.panel h2 { font-size: 16px; color: #fff; }
.panel-title span, #assumptionBadge {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.78);
  font-weight: 800;
}

.topbar p, .hint {
  color: rgba(255, 255, 255, 0.78);
  margin: 6px 0 0;
  line-height: 1.35;
}

.grid-2, .grid-3 {
  display: grid;
  gap: 10px;
}

.grid-2 { grid-template-columns: 1fr 1fr; }
.grid-3 { grid-template-columns: repeat(3, 1fr); }

.tool-grid, .preset-row {
  display: grid;
  gap: 8px;
}

.tool-grid { grid-template-columns: 1fr 1fr 1fr; }
.preset-row { grid-template-columns: repeat(3, 1fr); margin-top: 8px; }
.preset-row button { padding: 0 8px; font-size: 12px; }

.tool-grid button,
.preset-row button,
.view-actions button {
  min-height: 44px;
  border: 0;
  border-radius: 0;
  background: var(--accent);
  color: #fff;
  font-size: 16px;
}

.tool-grid button:nth-child(3n),
.preset-row button:nth-child(3n) { background: var(--accent-dark); }
.tool-grid button:nth-child(3n + 1),
.preset-row button:nth-child(3n + 1) { background: var(--green); }
.tool-grid button:nth-child(3n + 2),
.preset-row button:nth-child(3n + 2) { background: var(--green-dark); }
.view-actions button.active { background: var(--accent-dark); }

.geometry-editor { display: grid; gap: 10px; }

.geo-card {
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 0;
  padding: 10px;
  background: rgba(255, 255, 255, 0.1);
}

.geo-card h3 {
  margin: 0 0 10px;
  font-size: 13px;
  letter-spacing: 0;
  color: #fff;
}

.geo-card .grid-3 { gap: 8px; }
.geo-card input { min-height: 34px; padding: 0 8px; }

.quiet {
  min-height: 32px;
  color: #fff;
  border-color: transparent;
  background: var(--accent-dark);
}

.danger {
  min-height: 32px;
  color: var(--danger);
  background: #fff8f7;
  border-color: #f2c7c1;
}

.empty {
  color: rgba(255, 255, 255, 0.78);
  font-size: 13px;
  line-height: 1.4;
}

.photo-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 5px;
  margin-top: 10px;
}

.photo-strip button {
  aspect-ratio: 1;
  padding: 0;
  overflow: hidden;
  border-radius: 0;
  border-color: rgba(255, 255, 255, 0.35);
}

.photo-strip img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: var(--panel);
  border: 0;
  border-radius: 0;
  padding: 16px 20px;
  margin-bottom: 12px;
  color: #fff;
}

.topbar h2 { font-size: 28px; }
.topbar p { color: rgba(255, 255, 255, 0.78); }

.view-actions {
  display: inline-grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  flex: 0 0 auto;
}

.stage {
  position: relative;
  min-height: 0;
  background: rgba(245, 247, 245, 0.78);
  border: 0;
  border-radius: 0;
  overflow: hidden;
  box-shadow: var(--shadow);
}

#viewport {
  width: 100%;
  height: 100%;
  min-height: 650px;
}

.photo-view {
  position: absolute;
  inset: 0;
  margin: 0;
  background: #101414;
}

.photo-view img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.photo-view figcaption {
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: 16px;
  color: #fff;
  background: rgba(0, 0, 0, 0.5);
  border-radius: 0;
  padding: 10px 12px;
  line-height: 1.35;
}

.measurements {
  position: absolute;
  left: 14px;
  top: 14px;
  display: grid;
  gap: 8px;
  pointer-events: none;
}

.measurements div {
  width: max-content;
  max-width: min(420px, calc(100vw - 40px));
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid var(--line);
  border-radius: 0;
  padding: 7px 9px;
  font-weight: 800;
  color: #263033;
  box-shadow: 0 6px 18px rgba(23, 32, 34, 0.12);
}

.measure-panel {
  position: absolute;
  right: 14px;
  top: 14px;
  width: min(420px, calc(100% - 28px));
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid var(--line);
  border-radius: 0;
  padding: 12px;
  box-shadow: var(--shadow);
}

.measure-panel label { color: var(--muted); }
.measure-panel h2 { color: var(--ink); }
.measure-panel p {
  margin: 10px 0 0;
  color: var(--ink);
  font-weight: 800;
}

.nudge-grid, .export-actions {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.nudge-grid { grid-template-columns: repeat(6, 1fr); }
.nudge-grid button { min-height: 32px; padding: 0 6px; font-size: 12px; }
.export-actions { grid-template-columns: 1fr 1fr; margin-bottom: 10px; }

.question-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 8px;
}

.question-list li,
.fit-item,
.metric,
.part-row {
  border: 1px solid var(--line);
  border-radius: 0;
  background: rgba(255, 255, 255, 0.94);
  color: var(--ink);
}

.question-list li {
  padding: 9px;
  font-size: 13px;
  line-height: 1.35;
}

.question-list li.done {
  color: var(--muted);
  text-decoration: line-through;
}

.parts-list {
  display: grid;
  gap: 8px;
  max-height: 260px;
  overflow: auto;
}

.part-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 9px;
}

.part-row.active { border-color: var(--accent-dark); box-shadow: inset 4px 0 0 var(--accent-dark); }
.part-row strong { display: block; font-size: 13px; }
.part-row span { color: var(--muted); font-size: 12px; }
.part-row button { min-height: 30px; padding: 0 8px; }

.metrics {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 10px;
}

.fit-list { display: grid; gap: 8px; }

.fit-item {
  padding: 9px;
  font-size: 13px;
  line-height: 1.35;
}

.fit-item.ok {
  color: #1e5a35;
  background: #f2faf4;
  border-color: #c9e6d1;
}

.fit-item.warning {
  color: #7a3b00;
  background: #fff7ed;
  border-color: #f2d0aa;
}

.metric { padding: 9px; }
.metric strong { display: block; font-size: 20px; }
.metric span { color: var(--muted); font-size: 12px; }

.bottom-nav {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  background: var(--chrome);
  z-index: 3;
}

.bottom-nav button {
  min-height: 42px;
  border: 0;
  background: transparent;
  color: #fff;
  font-size: 24px;
  font-weight: 400;
}

.bottom-nav button::before {
  content: "<";
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  margin-right: 12px;
  border: 2px solid #18cbe0;
  border-radius: 50%;
  color: #18cbe0;
  font-size: 20px;
}

.bottom-nav button:last-child::before {
  content: "";
  display: none;
}

.bottom-nav button:last-child::after {
  content: ">";
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  margin-left: 12px;
  border: 2px solid #18cbe0;
  border-radius: 50%;
  color: #18cbe0;
  font-size: 20px;
}

@media (max-width: 1160px) {
  .app {
    grid-template-columns: 320px 1fr;
    grid-template-rows: 58px auto auto 58px;
    height: auto;
    min-height: 100vh;
  }

  .global-header, .bottom-nav { grid-column: 1 / -1; }
  .workspace { min-height: 680px; }

  .inspector {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
  }

  .inspector .panel { margin-bottom: 0; }
}

@media (max-width: 820px) {
  .app {
    display: block;
    min-height: 100vh;
    padding-top: 58px;
    padding-bottom: 58px;
  }

  .global-header {
    position: fixed;
    inset: 0 0 auto 0;
    height: 58px;
  }

  .bottom-nav {
    position: fixed;
    inset: auto 0 0 0;
    height: 58px;
  }

  .workspace { padding: 10px; }
  .sidebar, .inspector { padding: 10px; }
  .inspector { display: block; }
  .topbar { align-items: stretch; flex-direction: column; }
  .view-actions { width: 100%; }
  #viewport { min-height: 520px; }
  .bottom-nav button { font-size: 18px; }
}
