/* Deeplexi CAD Viewer — live deeplexi.com / Day One design language
   Tokens from deeplexi-dayone (ink/mute/line/mist + Montserrat + DM Sans).
   Dark canvas + measure overlays kept usable. NO Hostinger deploy. */
:root {
  --ink: #1D1E20;
  --void: #0a0b0c;
  --mist: #f5f5f5;
  --line: #e6e6e6;
  --mute: #6b6e73;
  --bg: #1D1E20;
  --bg2: #252628;
  --bg3: #2a2b2e;
  --teal: #2dd4bf;
  --teal-dim: #14b8a6;
  --text: #e8eaed;
  --danger: #f87171;
  --warn: #fbbf24;
  --panel-w: 320px;
  --banner-h: 56px;
  --radius: 12px;
  --font: "DM Sans", system-ui, sans-serif;
  --display: "Montserrat", system-ui, sans-serif;
  --mono: "DM Sans", ui-monospace, monospace;
}
* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%;
  background: var(--bg); color: var(--text);
  font-family: var(--font); overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
button, select, input { font: inherit; color: inherit; }
button {
  background: var(--bg3); border: 1px solid #3a3b3e; border-radius: 999px;
  padding: 0.4rem 0.85rem; cursor: pointer; color: var(--text);
  letter-spacing: 0.02em;
}
button:hover { border-color: var(--teal); color: var(--teal); }
button.active { background: #134e4a; border-color: var(--teal); color: var(--teal); }
button:disabled { opacity: 0.45; cursor: not-allowed; }

/* Live-site header: light sticky bar, BrandMark left, meta + status right */
#banner {
  height: var(--banner-h);
  display: flex; align-items: center; gap: 1rem;
  padding: 0 1.25rem;
  background: #fff;
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(8px);
  color: var(--mute);
  font-size: 13px;
  letter-spacing: 0.02em;
  z-index: 20;
}
#banner .brand {
  display: inline-flex; align-items: center;
  text-decoration: none; flex-shrink: 0;
}
#banner .brand-logo {
  /* The live CDN PNG is a square capture with transparent breathing room.
     Crop that room so the visible wordmark lands at ~34px high. */
  width: 88px; height: 36px; object-fit: cover;
  object-position: center 43%; display: block;
}
#banner .brand-meta {
  display: flex; align-items: center; gap: 0.45rem;
  flex: 1; min-width: 0; flex-wrap: wrap;
  color: #0d141a;
}
#banner .brand-meta strong {
  font-family: var(--display);
  font-weight: 600;
  font-size: 13px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink);
}
#banner .brand-meta .sep { opacity: 0.45; }
#banner .pill {
  margin-left: auto;
  background: #3f1d1d; color: var(--danger);
  border: 1px solid #7f1d1d;
  border-radius: 999px; padding: 0.2rem 0.65rem;
  font-size: 11px; font-weight: 500; letter-spacing: 0.04em;
  flex-shrink: 0;
}

#app {
  display: grid;
  grid-template-columns: var(--panel-w) 1fr;
  height: calc(100% - var(--banner-h));
}
#sidebar {
  background: var(--bg2); border-right: 1px solid #333; overflow-y: auto;
  padding: 0.75rem; display: flex; flex-direction: column; gap: 0.75rem;
}
#viewport-wrap { position: relative; min-width: 0; min-height: 0; background: var(--void); }
#viewport { width: 100%; height: 100%; display: block; touch-action: none; }
#hud {
  position: absolute; left: 12px; bottom: 12px; right: 12px;
  display: flex; flex-wrap: wrap; gap: 0.4rem; pointer-events: none;
}
#hud .badge {
  pointer-events: none; background: rgba(10, 11, 12, 0.88);
  border: 1px solid #3a3b3e;
  border-radius: 999px; padding: 0.28rem 0.65rem; font-size: 11px; color: var(--mute);
  font-family: var(--mono); letter-spacing: 0.02em;
}
#hud .badge.teal { color: var(--teal); border-color: #134e4a; }
#hud .badge.warn { color: var(--warn); }
#hud .badge.danger { color: var(--danger); }

.panel h2 {
  margin: 0 0 0.4rem; font-size: 11px;
  font-family: var(--display);
  text-transform: uppercase; letter-spacing: 0.1em; color: var(--mute);
  font-weight: 600;
}
.panel {
  background: var(--bg3); border: 1px solid #333; border-radius: var(--radius); padding: 0.65rem;
}
.row { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-top: 0.35rem; }
.row.stack { flex-direction: column; }
label.file-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
  background: #134e4a; border: 1px solid var(--teal); color: var(--teal);
  border-radius: 999px; padding: 0.55rem 0.95rem; cursor: pointer; font-weight: 600;
  letter-spacing: 0.02em;
}
label.file-btn input { display: none; }
.hint { font-size: 12px; color: var(--mute); line-height: 1.45; margin: 0.35rem 0 0; }
.hint code { font-family: var(--mono); color: var(--teal); font-size: 11px; }
.status { font-size: 12px; min-height: 1.2em; }
.status.ok { color: var(--teal); }
.status.err { color: var(--danger); }
.status.warn { color: var(--warn); }

table.matrix { width: 100%; border-collapse: collapse; font-size: 11px; }
table.matrix th, table.matrix td {
  text-align: left; padding: 0.25rem 0.2rem; border-bottom: 1px solid #333; vertical-align: top;
}
table.matrix th { color: var(--mute); font-weight: 600; }
.tag { display: inline-block; border-radius: 4px; padding: 0 0.3rem; font-family: var(--mono); font-size: 10px; }
.tag.open { background: #134e4a; color: var(--teal); }
.tag.convert { background: #3b2f1a; color: var(--warn); }
.tag.reject { background: #3f1d1d; color: var(--danger); }

#measure-readout {
  font-family: var(--mono); font-size: 13px; color: var(--teal); margin-top: 0.4rem;
  white-space: pre-wrap;
}
.disclaimer {
  font-size: 11px; color: var(--mute); border-left: 2px solid var(--teal-dim);
  padding-left: 0.5rem; margin-top: 0.4rem; line-height: 1.35;
}

#mobile-sheet {
  display: none; position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  background: var(--bg2); border-top: 1px solid #333; border-radius: 16px 16px 0 0;
  max-height: 55vh; overflow-y: auto; padding: 0.75rem;
  padding-bottom: calc(0.75rem + env(safe-area-inset-bottom));
}
#mobile-sheet .grab {
  width: 40px; height: 4px; background: #555; border-radius: 2px; margin: 0 auto 0.6rem;
}
#mobile-toggle {
  display: none; position: absolute; right: 12px; top: 12px; z-index: 15;
  background: #134e4a; border-color: var(--teal); color: var(--teal);
}

@media (max-width: 820px) {
  #app { grid-template-columns: 1fr; }
  #sidebar { display: none; }
  #mobile-sheet.open { display: block; }
  #mobile-toggle { display: inline-flex; }
  #banner { gap: 0.65rem; padding: 0 0.85rem; }
  #banner .brand-meta span:not(.sep) { display: none; }
  #banner .brand-meta .sep { display: none; }
}

.snap-tier.active { outline: 2px solid var(--teal, #2dd4bf); background: rgba(45,212,191,0.12); }
#snap-hover-label { font-variant-numeric: tabular-nums; color: #94a3b8; }

.dim-table-wrap { max-height: 12rem; overflow: auto; margin-top: 0.35rem; }
.dim-table td, .dim-table th { font-size: 0.75rem; padding: 0.25rem 0.35rem; }
.dim-swatch { display:inline-block; width:0.55rem; height:0.55rem; border-radius:2px; margin-right:0.3rem; vertical-align:middle; }
.dim-del { background:transparent; border:none; color:#f87171; cursor:pointer; font-size:0.85rem; padding:0 0.25rem; }
.dim-del:hover { color:#fecaca; }
.dim-empty td { color:#64748b; font-style:italic; }
.dim-val { font-variant-numeric: tabular-nums; white-space: nowrap; }
