:root {
  --bg-1: #dcd8d0;
  --bg-2: #a59f94;
  --ink: #1c1b19;
  --muted: #6b6861;
  --card: rgba(252, 251, 249, 0.86);
  --line: rgba(28, 27, 25, 0.1);
  --accent: #d5677a; /* placeholder brand accent */
  --ok: #3f6b57;
  --warn: #a8690f;
  --warn-bg: #fbf0d9;
  --radius: 18px;
  --shadow: 0 1px 2px rgba(28, 27, 25, 0.06), 0 12px 32px rgba(28, 27, 25, 0.1);
  --font: 'Avenir Next', 'Segoe UI', system-ui, -apple-system, 'Helvetica Neue', Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
  background: var(--bg-2);
  color: var(--ink);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

button {
  font: inherit;
  color: inherit;
}

#app {
  position: fixed;
  inset: 0;
  background: radial-gradient(120% 90% at 55% 38%, var(--bg-1) 0%, #c6c1b7 48%, var(--bg-2) 100%);
}

#stage {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  outline: none;
  transition: opacity 0.6s ease;
}

.is-loading #stage {
  opacity: 0;
}

/* ── Dimension labels ─────────────────────────────────────────────────── */
#labels {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.dim {
  position: absolute;
  left: 0;
  top: 0;
  padding: 3px 9px 3px;
  border-radius: 999px;
  background: var(--ink);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.01em;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  will-change: transform;
  box-shadow: 0 2px 8px rgba(28, 27, 25, 0.18);
}

.dim.is-estimate {
  background: var(--warn-bg);
  color: #6f4508;
  box-shadow: inset 0 0 0 1px rgba(168, 105, 15, 0.45), 0 2px 8px rgba(28, 27, 25, 0.12);
}

/* ── Brand ────────────────────────────────────────────────────────────── */
.brand {
  position: absolute;
  top: calc(16px + env(safe-area-inset-top));
  left: calc(16px + env(safe-area-inset-left));
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 16px 9px 10px;
  border-radius: 999px;
  background: var(--card);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: var(--shadow);
}

.brand-mark {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #f1a3b0, var(--accent) 70%);
  box-shadow: inset 0 0 0 4px rgba(255, 255, 255, 0.55);
}

.brand-text {
  display: grid;
  line-height: 1.15;
}

.brand-text strong {
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.brand-text span {
  font-size: 11.5px;
  color: var(--muted);
}

/* ── Toolbar ──────────────────────────────────────────────────────────── */
.tools {
  position: absolute;
  top: calc(16px + env(safe-area-inset-top));
  right: calc(16px + env(safe-area-inset-right));
  display: flex;
  gap: 6px;
  padding: 5px;
  border-radius: 999px;
  background: var(--card);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: var(--shadow);
}

.chip {
  appearance: none;
  border: 0;
  min-height: 38px;
  padding: 0 14px;
  border-radius: 999px;
  background: transparent;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}

.chip:hover {
  background: rgba(28, 27, 25, 0.06);
}

.chip.is-on {
  background: var(--ink);
  color: #fff;
}

.chip:focus-visible,
.tab:focus-visible,
.panel-head:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ── Tabs ─────────────────────────────────────────────────────────────── */
.tabs {
  position: absolute;
  left: 50%;
  bottom: calc(16px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  display: flex;
  gap: 4px;
  max-width: calc(100% - 24px);
  padding: 5px;
  border-radius: 999px;
  background: rgba(28, 27, 25, 0.92);
  box-shadow: var(--shadow);
  overflow-x: auto;
  scrollbar-width: none;
}

.tabs::-webkit-scrollbar {
  display: none;
}

.tab {
  appearance: none;
  border: 0;
  flex: none;
  min-height: 42px;
  padding: 0 18px;
  border-radius: 999px;
  background: transparent;
  color: rgba(255, 255, 255, 0.72);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}

.tab:hover {
  color: #fff;
}

.tab.is-on {
  background: #fbfaf8;
  color: var(--ink);
}

/* ── Spec panel ───────────────────────────────────────────────────────── */
.panel {
  position: absolute;
  top: calc(84px + env(safe-area-inset-top));
  left: calc(16px + env(safe-area-inset-left));
  width: 348px;
  max-height: calc(100% - 190px);
  display: flex;
  flex-direction: column;
  border-radius: var(--radius);
  background: var(--card);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.panel-head {
  appearance: none;
  border: 0;
  background: transparent;
  width: 100%;
  text-align: left;
  padding: 18px 20px 14px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 2px 12px;
  align-items: center;
  cursor: default;
}

.panel-kicker {
  grid-column: 1 / -1;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

.panel-title {
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 999px;
  background: var(--warn-bg);
  color: #6f4508;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.badge::before {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--warn);
}

.panel-chevron {
  display: none;
}

.panel-body {
  padding: 0 20px 18px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.panel-blurb {
  margin: 0 0 14px;
  font-size: 13.5px;
  line-height: 1.5;
  color: #47443f;
}

.rows {
  margin: 0;
  padding: 0;
  list-style: none;
  border-top: 1px solid var(--line);
}

.rows li {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 2px 12px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}

.rows .k {
  color: var(--muted);
}

.rows .v {
  grid-column: 1;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.rows .s {
  grid-row: 1 / span 2;
  grid-column: 2;
  align-self: center;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.s-published {
  background: rgba(63, 107, 87, 0.12);
  color: var(--ok);
}

.s-provided {
  background: rgba(28, 27, 25, 0.08);
  color: var(--ink);
}

.s-estimate {
  background: var(--warn-bg);
  color: #6f4508;
}

.note {
  margin: 12px 0 0;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(28, 27, 25, 0.045);
  font-size: 12.5px;
  line-height: 1.5;
  color: #47443f;
}

/* ── Hint and loader ──────────────────────────────────────────────────── */
.hint {
  position: absolute;
  right: calc(20px + env(safe-area-inset-right));
  bottom: calc(26px + env(safe-area-inset-bottom));
  margin: 0;
  font-size: 12px;
  color: rgba(28, 27, 25, 0.6);
  transition: opacity 0.5s;
  pointer-events: none;
}

.hint.is-hidden {
  opacity: 0;
}

.loader {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 14px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
  transition: opacity 0.4s;
  pointer-events: none;
}

.loader span {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px solid rgba(28, 27, 25, 0.15);
  border-top-color: var(--ink);
  animation: spin 0.9s linear infinite;
}

#app:not(.is-loading) .loader {
  opacity: 0;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ── Phones and narrow windows: panel becomes a bottom sheet ──────────── */
@media (max-width: 860px) {
  .brand {
    top: calc(10px + env(safe-area-inset-top));
    left: calc(10px + env(safe-area-inset-left));
    padding: 6px 12px 6px 7px;
    gap: 8px;
  }
  .brand-mark {
    width: 24px;
    height: 24px;
  }
  .brand-text span {
    display: none;
  }
  .brand-text strong {
    font-size: 11px;
  }
  .tools {
    top: calc(10px + env(safe-area-inset-top));
    right: calc(10px + env(safe-area-inset-right));
    gap: 2px;
    padding: 4px;
  }
  .chip {
    min-height: 34px;
    padding: 0 11px;
    font-size: 12px;
  }
  #tool-reset {
    display: none;
  }
  .tabs {
    left: calc(8px + env(safe-area-inset-left));
    right: calc(8px + env(safe-area-inset-right));
    bottom: calc(10px + env(safe-area-inset-bottom));
    transform: none;
    max-width: none;
    gap: 2px;
  }
  .tab {
    flex: 1 0 auto;
    min-height: 42px;
    padding: 0 9px;
    font-size: 12.5px;
  }
  .panel {
    top: auto;
    left: calc(8px + env(safe-area-inset-left));
    right: calc(8px + env(safe-area-inset-right));
    bottom: calc(68px + env(safe-area-inset-bottom));
    width: auto;
    max-height: min(58%, 460px);
  }
  .panel-head {
    padding: 12px 14px 12px 16px;
    grid-template-columns: 1fr auto auto;
    cursor: pointer;
  }
  .panel-kicker {
    font-size: 10px;
  }
  .panel-title {
    font-size: 19px;
  }
  .panel-chevron {
    display: block;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: rgba(28, 27, 25, 0.07);
    position: relative;
    transition: transform 0.25s;
  }
  .panel-chevron::before {
    content: '';
    position: absolute;
    left: 10px;
    top: 11px;
    width: 7px;
    height: 7px;
    border-left: 2px solid var(--ink);
    border-top: 2px solid var(--ink);
    transform: rotate(45deg);
  }
  .panel.is-open .panel-chevron {
    transform: rotate(180deg);
  }
  .panel-body {
    display: none;
    padding: 0 16px 14px;
  }
  .panel.is-open .panel-body {
    display: block;
  }
  .hint {
    display: none;
  }
  .dim {
    font-size: 11px;
    padding: 2px 7px;
  }
}

@media (max-width: 1180px) {
  .hint {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    animation-duration: 0.01s !important;
  }
}

/* ═══════════════════════════════════════════════════════════════════════
   Setup Explorer (index.html)
   ═══════════════════════════════════════════════════════════════════════ */
.brand-text a {
  color: inherit;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

/* ── Segmented controls: camera presets and layouts ───────────────────── */
.seg {
  display: flex;
  gap: 3px;
  padding: 5px;
  border-radius: 999px;
  box-shadow: var(--shadow);
  overflow-x: auto;
  scrollbar-width: none;
}

.seg::-webkit-scrollbar {
  display: none;
}

.seg-btn {
  appearance: none;
  border: 0;
  flex: none;
  min-height: 38px;
  padding: 0 14px;
  border-radius: 999px;
  background: transparent;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}

.seg-btn:focus-visible,
.cta:focus-visible,
.icon-btn:focus-visible,
.text-btn:focus-visible,
.spec-row:focus-visible,
.pin:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.seg-light {
  background: var(--card);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.seg-light .seg-btn:hover {
  background: rgba(28, 27, 25, 0.06);
}

.seg-light .seg-btn.is-on {
  background: var(--ink);
  color: #fff;
}

#presets {
  position: absolute;
  top: calc(16px + env(safe-area-inset-top));
  right: calc(16px + env(safe-area-inset-right));
  max-width: calc(100% - 300px);
}

/* Bottom-left dock. The bottom-right corner stays clear for the hosting badge. */
:root {
  --badge-clear: 64px; /* height reserved for the badge on phones */
}

.dock {
  position: absolute;
  left: calc(16px + env(safe-area-inset-left));
  bottom: calc(16px + env(safe-area-inset-bottom));
  display: flex;
  align-items: center;
  gap: 8px;
}

.actions {
  display: flex;
  gap: 4px;
  padding: 5px;
  border-radius: 999px;
  background: var(--card);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: var(--shadow);
}

.cta {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-height: 52px;
  padding: 0 20px;
  border: 0;
  border-radius: 999px;
  background: var(--ink);
  color: #fff;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform 0.15s;
}

.cta:hover {
  transform: translateY(-1px);
}

.has-specs .cta {
  background: #fbfaf8;
  color: var(--ink);
}

/* ── Measurements & Materials sheet ───────────────────────────────────── */
.sheet {
  position: absolute;
  top: calc(84px + env(safe-area-inset-top));
  left: calc(16px + env(safe-area-inset-left));
  bottom: calc(84px + env(safe-area-inset-bottom));
  width: 372px;
  display: flex;
  flex-direction: column;
  border-radius: var(--radius);
  background: var(--card);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.sheet[hidden] {
  display: none;
}

.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 16px 12px 20px;
}

.kicker {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

.sheet-head h2 {
  margin: 0;
  font-size: 21px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.icon-btn {
  appearance: none;
  flex: none;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: rgba(28, 27, 25, 0.07);
  cursor: pointer;
  transition: background 0.2s, opacity 0.2s;
}

.icon-btn:hover {
  background: rgba(28, 27, 25, 0.13);
}

.icon-btn:disabled {
  opacity: 0.35;
  cursor: default;
}

.sheet-body {
  padding: 0 20px 18px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.foot-card {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 14px;
  padding: 14px 16px;
  border-radius: 14px;
  background: rgba(63, 107, 87, 0.1);
  box-shadow: inset 0 0 0 1px rgba(63, 107, 87, 0.28);
}

.foot-card div {
  display: grid;
  gap: 1px;
}

.foot-card div:first-child {
  grid-column: 1 / -1;
}

.foot-card span {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ok);
}

.foot-card strong {
  font-size: 15px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.foot-card div:first-child strong {
  font-size: 19px;
}

.sheet-sub,
.sheet-foot {
  margin: 12px 0 4px;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--muted);
}

.spec-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.spec-list li {
  border-top: 1px solid var(--line);
}

.spec-row {
  appearance: none;
  width: 100%;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 12px;
  padding: 14px 6px 14px 4px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  text-align: left;
  cursor: pointer;
  transition: background 0.2s;
}

.spec-row:hover,
.spec-row.is-on {
  background: rgba(28, 27, 25, 0.045);
}

.num,
.pin {
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--ink);
  color: #fff;
  font-size: 12.5px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.spec-main {
  display: grid;
  gap: 3px;
}

.spec-main strong {
  font-size: 15px;
  font-weight: 600;
}

.spec-main em {
  font-style: normal;
  font-size: 12.5px;
  color: var(--muted);
}

.whd {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin: 5px 0 4px;
}

.whd b {
  padding: 3px 8px;
  border-radius: 7px;
  background: rgba(28, 27, 25, 0.07);
  font-size: 12.5px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.whd i {
  margin-left: 3px;
  font-style: normal;
  font-size: 10px;
  font-weight: 700;
  color: var(--muted);
}

.whd .wt {
  background: var(--ink);
  color: #fff;
}

.spec-text {
  font-size: 13px;
  line-height: 1.5;
  color: #47443f;
}

/* ── Numbered pins over the equipment ─────────────────────────────────── */
#pins {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.pin {
  appearance: none;
  position: absolute;
  left: 0;
  top: 0;
  border: 2px solid #fff;
  width: 30px;
  height: 30px;
  padding: 0;
  cursor: pointer;
  pointer-events: auto;
  box-shadow: 0 2px 10px rgba(28, 27, 25, 0.3);
  will-change: transform;
}

/* ── Logo badge: frosted glass rectangle ──────────────────────────────── */
.brand.brand-logo {
  padding: 12px 20px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.32);
  backdrop-filter: blur(16px) saturate(1.3);
  -webkit-backdrop-filter: blur(16px) saturate(1.3);
  border: 1px solid rgba(255, 255, 255, 0.55);
  box-shadow: 0 1px 2px rgba(28, 27, 25, 0.05), 0 8px 24px rgba(28, 27, 25, 0.08);
}

/* Logo links to the main website. */
.brand-logo a {
  display: block;
  border-radius: 4px;
  transition: opacity 0.2s;
}

.brand-logo a:hover {
  opacity: 0.7;
}

.brand-logo a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
}

/* ── Battery callout and its footnote ─────────────────────────────────── */
.callout {
  display: none;
  position: absolute;
  left: 0;
  top: 0;
  padding: 6px 11px;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
  pointer-events: none;
  will-change: transform;
  box-shadow: 0 2px 10px rgba(28, 27, 25, 0.22);
}

.callout sup {
  margin-left: 1px;
  font-size: 0.85em;
}

.brand-logo img {
  display: block;
  height: 30px;
  width: auto;
}

/* ── Explorer on phones and narrow windows ────────────────────────────── */
@media (max-width: 860px) {
  #presets {
    top: calc(56px + env(safe-area-inset-top));
    left: calc(8px + env(safe-area-inset-left));
    right: calc(8px + env(safe-area-inset-right));
    max-width: none;
    padding: 4px;
  }
  #presets .seg-btn {
    flex: 1 0 auto;
    min-height: 36px;
    padding: 0 11px;
    font-size: 12.5px;
  }
  .cta {
    position: fixed;
    top: calc(10px + env(safe-area-inset-top));
    right: calc(10px + env(safe-area-inset-right));
    min-height: 40px;
    padding: 0 14px;
    font-size: 12.5px;
  }
  .dock {
    left: calc(8px + env(safe-area-inset-left));
    right: calc(8px + env(safe-area-inset-right));
    bottom: calc(var(--badge-clear) + env(safe-area-inset-bottom));
  }
  .actions {
    flex: 1;
    justify-content: space-between;
  }
  .actions .chip {
    flex: 1;
    justify-content: center;
    min-height: 40px;
    font-size: 13px;
  }
  .sheet {
    top: auto;
    left: 0;
    right: 0;
    bottom: 0;
    width: auto;
    height: 56%;
    border-radius: 22px 22px 0 0;
    z-index: 5;
    padding-bottom: env(safe-area-inset-bottom);
  }
  .sheet-head {
    padding: 14px 12px 10px 18px;
  }
  .sheet-head h2 {
    font-size: 18px;
  }
  .sheet-body {
    padding: 0 16px calc(var(--badge-clear) + 8px);
  }
  .brand.brand-logo {
    top: calc(10px + env(safe-area-inset-top));
    left: calc(10px + env(safe-area-inset-left));
    padding: 9px 14px;
  }
  .callout {
    font-size: 11px;
    padding: 5px 9px;
  }
  .brand-logo img {
    height: 22px;
  }
}

/* Light note labels in the scene, e.g. "Clearance". */
.dim.is-note {
  background: rgba(252, 251, 249, 0.92);
  color: #a3465a;
  box-shadow: inset 0 0 0 1px rgba(213, 103, 122, 0.55), 0 2px 8px rgba(28, 27, 25, 0.12);
}

/* ── Opened from disk: explain instead of spinning forever ────────────── */
.is-file .loader {
  pointer-events: auto;
  letter-spacing: normal;
  text-transform: none;
}

.file-note {
  max-width: 380px;
  margin: 0 16px;
  padding: 22px 24px;
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow);
  color: var(--ink);
  text-align: left;
}

.file-note strong {
  display: block;
  margin-bottom: 6px;
  font-size: 17px;
  font-weight: 600;
}

.file-note p {
  margin: 0;
  font-size: 14px;
  font-weight: 400;
  line-height: 1.5;
  color: #47443f;
}
