:root {
  --bg: #f4f4f1;
  --surface: #ffffff;
  --text: #171717;
  --muted: #73736d;
  --border: #d8d8d2;
  --black: #111111;
  --radius: 4px;
  --header-height: 72px;
  font-family: Arial, Helvetica, sans-serif;
}

* { box-sizing: border-box; }

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
}

body {
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  min-height: 0;
  display: grid;
  grid-template-rows: var(--header-height) minmax(0, 1fr);
  overflow: hidden;
}

button { font: inherit; }

.site-header {
  position: relative;
  z-index: 20;
  min-width: 0;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 0 max(28px, env(safe-area-inset-right)) 0 max(28px, env(safe-area-inset-left));
  background: var(--black);
  color: #fff;
  border-bottom: 1px solid #2b2b2b;
}

.telos-logo {
  display: block;
  flex: 0 0 auto;
  width: 148px;
  max-height: 40px;
  object-fit: contain;
  filter: invert(1);
  visibility: visible;
}

.reset-view {
  position: relative;
  z-index: 21;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  appearance: none;
  border: 0;
  min-height: 44px;
  padding: 10px 0 10px 18px;
  background: transparent;
  color: #fff;
  font-size: 11px;
  letter-spacing: .16em;
  text-transform: uppercase;
  opacity: .72;
  visibility: visible;
  cursor: pointer;
  transition: opacity 160ms ease;
}

.reset-view:hover { opacity: 1; }
.reset-view:focus-visible { outline: 1px solid rgba(255,255,255,.75); outline-offset: 4px; }

.layout {
  position: relative;
  min-width: 0;
  min-height: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  grid-template-rows: minmax(0, 1fr);
}

.viewport {
  position: relative;
  z-index: 1;
  min-width: 0;
  min-height: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #dfe4e8;
}

.viewport canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

/* The app still writes loader diagnostics here. Keep it available to assistive
   tech and the loading overlay while removing the old floating status chip. */
.status {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.loading-overlay {
  position: absolute;
  z-index: 8;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 32px;
  background:
    radial-gradient(circle at 68% 32%, rgba(255,247,226,.42), transparent 34%),
    linear-gradient(180deg, rgba(210,220,228,.97), rgba(236,233,226,.97));
  opacity: 1;
  visibility: visible;
  transition: opacity 520ms cubic-bezier(.4,0,.2,1), visibility 520ms step-end;
}

.loading-overlay[hidden] { display: none; }
.loading-overlay.is-complete {
  opacity: 0;
  pointer-events: none;
}

.loading-card {
  width: min(430px, 100%);
  padding: 28px 30px 26px;
  background: rgba(255,255,255,.82);
  border: 1px solid rgba(17,17,17,.10);
  box-shadow: 0 18px 55px rgba(35,40,44,.10);
  backdrop-filter: blur(18px);
}

.loading-eyebrow {
  margin-bottom: 12px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .17em;
  color: rgba(23,23,23,.52);
}

.loading-title {
  margin-bottom: 28px;
  font-size: 24px;
  line-height: 1.08;
  font-weight: 500;
  letter-spacing: -.025em;
}

.loading-meta {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 10px;
  font-size: 11px;
  color: rgba(23,23,23,.63);
}

#loading-percent {
  flex: 0 0 auto;
  font-variant-numeric: tabular-nums;
  color: rgba(23,23,23,.88);
}

.loading-track {
  position: relative;
  width: 100%;
  height: 3px;
  overflow: hidden;
  background: rgba(17,17,17,.13);
}

.loading-fill {
  position: absolute;
  inset: 0;
  transform: scaleX(0);
  transform-origin: left center;
  background: var(--black);
  will-change: transform;
}

.loading-note {
  margin-top: 13px;
  max-width: 320px;
  font-size: 10px;
  line-height: 1.45;
  color: rgba(23,23,23,.45);
}

.loading-overlay.is-error .loading-card {
  border-color: rgba(134,42,42,.28);
}

.loading-overlay.is-error .loading-fill {
  background: #7f2f2f;
}

.viewer-help {
  position: absolute;
  z-index: 2;
  left: 24px;
  bottom: 22px;
  font-size: 12px;
  color: rgba(28,28,25,.68);
  pointer-events: none;
}

.panel {
  position: relative;
  z-index: 10;
  display: block;
  min-width: 0;
  min-height: 0;
  width: 100%;
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior-y: contain;
  scrollbar-gutter: stable;
  -webkit-overflow-scrolling: touch;
  background: var(--surface);
  border-left: 1px solid var(--border);
  padding: 28px 28px max(32px, env(safe-area-inset-bottom));
}

.panel::-webkit-scrollbar { width: 10px; }
.panel::-webkit-scrollbar-track { background: transparent; }
.panel::-webkit-scrollbar-thumb {
  background: rgba(17,17,17,.16);
  border: 3px solid transparent;
  border-radius: 999px;
  background-clip: padding-box;
}
.panel::-webkit-scrollbar-thumb:hover { background-color: rgba(17,17,17,.28); }

h1 {
  margin: 0 0 8px;
  font-size: 26px;
  line-height: 1.1;
  font-weight: 500;
  letter-spacing: -.03em;
}

.intro {
  margin: 0 0 32px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--muted);
}

.control-section {
  padding: 24px 0;
  border-top: 1px solid var(--border);
}

.control-section h2 {
  margin: 0 0 14px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.size-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.size-button {
  min-height: 68px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 8px 6px;
  background: #fff;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 140ms ease, color 140ms ease, border-color 140ms ease;
}

.size-button:hover { border-color: #999992; }
.size-button:focus-visible,
.finish-button:focus-visible { outline: 2px solid #5a5a56; outline-offset: 2px; }
.size-button.active { background: var(--black); border-color: var(--black); color: #fff; }
.size-name { font-size: 15px; font-weight: 600; }
.size-dim { margin-top: 5px; font-size: 9px; line-height: 1.2; opacity: .65; text-align: center; }

.finish-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.finish-button {
  min-height: 54px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  background: #fff;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  text-align: left;
  font-size: 11px;
  line-height: 1.25;
  transition: border-color 140ms ease, background 140ms ease, box-shadow 140ms ease;
}

.finish-button:hover { border-color: #999992; }
.finish-button.active { border-color: #242421; box-shadow: inset 0 0 0 1px #242421; background: #fafaf8; }

.finish-copy {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.finish-copy > span {
  overflow: hidden;
  text-overflow: ellipsis;
}

.finish-copy small {
  font-size: 9px;
  line-height: 1.2;
  color: var(--muted);
  letter-spacing: .02em;
}

.swatch {
  flex: 0 0 22px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--swatch);
  border: 1px solid rgba(0,0,0,.13);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.28);
}

.spec-row {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  padding: 7px 0;
  font-size: 12px;
}

.spec-row span:first-child { color: var(--muted); }

.quote-button {
  width: 100%;
  min-height: 48px;
  margin-top: 24px;
  margin-bottom: 2px;
  border: 0;
  border-radius: var(--radius);
  background: var(--black);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
  cursor: pointer;
}

/* Unfolded foldables and medium tablets: keep side-by-side, widen controls a little. */
@media (min-width: 761px) and (max-width: 1180px) {
  .layout {
    grid-template-columns: minmax(0, 1fr) clamp(330px, 38vw, 410px);
  }

  .panel {
    padding-left: 22px;
    padding-right: 22px;
  }
}

/* Phones and narrow foldables: 3D viewer on top, inspector below as its own scrollable region. */
@media (max-width: 760px) {
  :root { --header-height: 60px; }

  .site-header {
    padding-left: max(18px, env(safe-area-inset-left));
    padding-right: max(18px, env(safe-area-inset-right));
  }

  .telos-logo { width: 122px; max-height: 34px; }
  .reset-view { font-size: 10px; padding-left: 12px; }

  .layout {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(280px, 48dvh) minmax(0, 1fr);
  }

  .viewport {
    min-width: 0;
    min-height: 0;
  }

  .loading-overlay { padding: 20px; }
  .loading-card { padding: 22px 22px 20px; }
  .loading-title { margin-bottom: 22px; font-size: 21px; }
  .loading-note { max-width: 280px; }

  .panel {
    min-width: 0;
    min-height: 0;
    height: 100%;
    border-left: 0;
    border-top: 1px solid var(--border);
    padding: 22px 20px max(28px, env(safe-area-inset-bottom));
  }

  h1 { font-size: 24px; }
  .intro { margin-bottom: 24px; }
  .control-section { padding: 20px 0; }
  .viewer-help { left: 16px; bottom: 14px; font-size: 11px; }
}

/* Very narrow phones: one finish per row, larger touch targets. */
@media (max-width: 480px) {
  .finish-grid { grid-template-columns: 1fr; }
  .finish-button { min-height: 52px; }
  .size-dim { font-size: 8.5px; }
  .panel { padding-left: 16px; padding-right: 16px; }
}

/* Extremely short viewports still keep the header and panel usable. */
@media (max-height: 560px) and (min-width: 761px) {
  :root { --header-height: 56px; }
  .layout { grid-template-columns: minmax(0, 1fr) clamp(320px, 38vw, 390px); }
  .panel { padding-top: 18px; padding-bottom: max(20px, env(safe-area-inset-bottom)); }
  .control-section { padding: 16px 0; }
  .intro { margin-bottom: 20px; }
}
