:root {
  --bg: #ffffff;
  --bg-alt: #f6f8fa;
  --bg-dark: #0b1220;
  --bg-dark-alt: #101a2e;
  --ink: #0f172a;
  --ink-soft: #4b5768;
  --ink-faint: #8492a6;
  --border: #e3e8ef;
  --accent: #0891b2;
  --accent-dark: #0e7490;
  --accent-soft: #e6fbff;
  --accent-ink: #063b47;
  --wall: #cbd5c0;
  --furniture: #c98a4b;
  --railing: #64748b;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.06), 0 8px 24px -12px rgba(15, 23, 42, 0.18);
  --maxw: 1180px;

  /* theme-swappable surface tokens (light defaults) */
  --card-bg: #ffffff;
  --viewer-bg: #eef2f6;
  --nav-bg: rgba(255, 255, 255, 0.88);
  --overlay-bg: rgba(255, 255, 255, 0.9);
  --img-frame: #f1f5f9;
  --scheme: light;

  font-size: 16px;
}

/* ---------- dark theme ----------
   Applied either by explicit choice (data-theme="dark") or, absent a
   stored choice, by the OS preference — guarded so an explicit "light"
   choice always wins over prefers-color-scheme. Two plain (non-nested)
   rules rather than nested CSS, so this works on older browsers too. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b1220;
    --bg-alt: #0f1826;
    --bg-dark: #060a13;
    --bg-dark-alt: #0a0f1b;
    --ink: #e7edf7;
    --ink-soft: #aab6c9;
    --ink-faint: #7c8aa3;
    --border: #223049;
    --accent: #22d3ee;
    --accent-dark: #67e8f9;
    --accent-soft: rgba(34, 211, 238, 0.14);
    --accent-ink: #a5f3fc;
    --card-bg: #101a2c;
    --viewer-bg: #0d1524;
    --nav-bg: rgba(11, 18, 32, 0.82);
    --overlay-bg: rgba(16, 26, 44, 0.88);
    --img-frame: #16223a;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 12px 28px -14px rgba(0, 0, 0, 0.6);
    --scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0b1220;
  --bg-alt: #0f1826;
  --bg-dark: #060a13;
  --bg-dark-alt: #0a0f1b;
  --ink: #e7edf7;
  --ink-soft: #aab6c9;
  --ink-faint: #7c8aa3;
  --border: #223049;
  --accent: #22d3ee;
  --accent-dark: #67e8f9;
  --accent-soft: rgba(34, 211, 238, 0.14);
  --accent-ink: #a5f3fc;
  --card-bg: #101a2c;
  --viewer-bg: #0d1524;
  --nav-bg: rgba(11, 18, 32, 0.82);
  --overlay-bg: rgba(16, 26, 44, 0.88);
  --img-frame: #16223a;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 12px 28px -14px rgba(0, 0, 0, 0.6);
  --scheme: dark;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  transition: background-color 0.2s ease, color 0.2s ease;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

.wrap {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 24px;
}

a { color: var(--accent-dark); }
img { max-width: 100%; display: block; }

h1, h2, h3, h4 { line-height: 1.2; margin: 0 0 0.5em; font-weight: 700; letter-spacing: -0.01em; }
h2 { font-size: clamp(1.6rem, 2.4vw, 2.1rem); }
h3 { font-size: 1.2rem; }
p { margin: 0 0 1em; color: var(--ink-soft); }

.eyebrow {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent-dark);
  background: var(--accent-soft);
  padding: 4px 10px;
  border-radius: 999px;
  margin-bottom: 14px;
}

.section-head { max-width: 680px; margin-bottom: 40px; }
.section-head p { font-size: 1.03rem; }

section { padding: 88px 0; }
section.alt { background: var(--bg-alt); }
section.dark { background: var(--bg-dark); color: #fff; }
section.dark p { color: #b9c4d6; }
section.dark .section-head h2 { color: #fff; }

/* ---------- nav ---------- */
header.nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--nav-bg);
  backdrop-filter: saturate(180%) blur(10px);
  border-bottom: 1px solid var(--border);
}
.nav-inner {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 24px;
  height: 62px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  font-size: 0.98rem;
  color: var(--ink);
  text-decoration: none;
  white-space: nowrap;
}
.brand .dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}
.navlinks {
  display: flex;
  gap: 22px;
  align-items: center;
  flex-wrap: wrap;
}
.navlinks a {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--ink-soft);
  text-decoration: none;
}
.navlinks a:hover { color: var(--accent-dark); }
.navlinks .btn { color: #fff; }

.nav-controls { display: flex; align-items: center; gap: 10px; flex: none; }
.lang-switch {
  display: flex; border: 1px solid var(--border); border-radius: 999px;
  padding: 2px; background: var(--bg-alt);
}
.lang-switch button {
  border: none; background: transparent; cursor: pointer;
  font-family: inherit; font-size: 0.76rem; font-weight: 800;
  padding: 5px 10px; border-radius: 999px; color: var(--ink-faint);
  letter-spacing: 0.02em;
}
.lang-switch button[aria-pressed="true"] { background: var(--card-bg); color: var(--accent-dark); box-shadow: var(--shadow); }
.theme-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--bg-alt);
  color: var(--ink-soft); cursor: pointer; flex: none; padding: 0;
}
.theme-btn:hover { color: var(--accent-dark); border-color: var(--accent); }
.theme-btn svg { width: 16px; height: 16px; }
.theme-btn .i-moon { display: none; }
:root[data-theme="dark"] .theme-btn .i-sun { display: none; }
:root[data-theme="dark"] .theme-btn .i-moon { display: block; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff !important;
  font-weight: 700;
  font-size: 0.88rem;
  text-decoration: none;
  border: 1px solid transparent;
  transition: transform 0.15s ease, background 0.15s ease;
}
.btn:hover { background: var(--accent-dark); transform: translateY(-1px); }
.btn.ghost {
  background: transparent;
  color: var(--ink) !important;
  border-color: var(--border);
}
.btn.ghost:hover { border-color: var(--accent); color: var(--accent-dark) !important; }
.btn.on-dark.ghost { color: #fff !important; border-color: #2a3a56; }
.btn.on-dark.ghost:hover { border-color: var(--accent); }

/* ---------- hero ---------- */
.hero {
  background:
    radial-gradient(1100px 500px at 15% -10%, rgba(8, 145, 178, 0.28), transparent 60%),
    radial-gradient(700px 400px at 100% 0%, rgba(8, 145, 178, 0.14), transparent 60%),
    var(--bg-dark);
  color: #fff;
  padding: 96px 0 72px;
  position: relative;
  overflow: hidden;
}
.hero::after {
  content: "";
  position: absolute; inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.045) 1px, transparent 1px);
  background-size: 42px 42px;
  mask-image: radial-gradient(90% 60% at 50% 20%, black, transparent 75%);
  pointer-events: none;
}
.hero-inner { position: relative; z-index: 1; display: grid; grid-template-columns: 1.15fr 0.85fr; gap: 48px; align-items: center; }
.hero h1 { font-size: clamp(2.1rem, 4vw, 3.1rem); margin-bottom: 18px; }
.hero .lead { font-size: 1.12rem; color: #c4cede; max-width: 560px; }
.hero .cta-row { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 28px; }
.hero-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-top: 40px; max-width: 520px; }
.hero-stats .stat { border-left: 2px solid var(--accent); padding-left: 12px; }
.hero-stats .stat b { display: block; font-size: 1.35rem; }
.hero-stats .stat span { font-size: 0.78rem; color: #93a1b8; }

.hero-photo {
  position: relative;
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 30px 60px -25px rgba(0,0,0,0.6);
  border: 1px solid #223255;
  aspect-ratio: 3/4;
}
.hero-photo img { width: 100%; height: 100%; object-fit: cover; }
.hero-photo .cap {
  position: absolute; left: 0; right: 0; bottom: 0;
  padding: 14px 16px;
  font-size: 0.78rem;
  color: #dbe4f3;
  background: linear-gradient(transparent, rgba(0,0,0,0.75));
}

/* ---------- feature cards ---------- */
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 22px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 22px; }
.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 26px;
  box-shadow: var(--shadow);
}
.card .icon {
  width: 40px; height: 40px;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent-dark);
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 16px;
}
.card h3 { margin-bottom: 8px; }
.card p { margin-bottom: 0; font-size: 0.94rem; }

/* ---------- pipeline strip ---------- */
.pipeline {
  display: flex;
  align-items: stretch;
  gap: 0;
  flex-wrap: wrap;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: #fff;
}
.pipeline .step {
  flex: 1 1 150px;
  padding: 20px 18px;
  position: relative;
  border-right: 1px solid var(--border);
}
.pipeline .step:last-child { border-right: none; }
.pipeline .step .n {
  font-size: 0.72rem; font-weight: 800; color: var(--accent-dark);
  letter-spacing: 0.08em;
}
.pipeline .step h4 { margin: 6px 0 6px; font-size: 0.98rem; }
.pipeline .step p { font-size: 0.84rem; margin: 0; }
.pipeline .step::after {
  content: "\2192";
  position: absolute; right: -11px; top: 50%; transform: translateY(-50%);
  color: var(--ink-faint); font-size: 1rem; z-index: 2; background: var(--card-bg);
  width: 20px; text-align: center;
}
.pipeline .step:last-child::after { content: ""; }

/* ---------- 3D explorer ---------- */
.explorer {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--card-bg);
  box-shadow: var(--shadow);
}
.room-list {
  border-right: 1px solid var(--border);
  padding: 14px;
  max-height: 560px;
  overflow-y: auto;
  background: var(--bg-alt);
}
.room-btn {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 4px;
  cursor: pointer;
  font-family: inherit;
}
.room-btn:hover { background: var(--card-bg); border-color: var(--border); }
.room-btn.active { background: var(--card-bg); border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.room-btn .t { font-weight: 700; font-size: 0.92rem; color: var(--ink); }
.room-btn .s { font-size: 0.76rem; color: var(--ink-faint); margin-top: 2px; }

.viewer-pane { position: relative; min-height: 560px; background: var(--viewer-bg); }
#three-canvas-holder { position: absolute; inset: 0; }
#three-canvas-holder canvas { display: block; width: 100%; height: 100%; }

.viewer-hint {
  position: absolute; top: 14px; right: 14px;
  background: rgba(15, 23, 42, 0.72); color: #fff;
  font-size: 0.72rem; padding: 6px 10px; border-radius: 999px;
  pointer-events: none;
}
.viewer-legend {
  position: absolute; bottom: 14px; left: 14px;
  display: flex; gap: 14px;
  background: var(--overlay-bg);
  backdrop-filter: blur(4px);
  border: 1px solid var(--border);
  padding: 8px 12px; border-radius: 10px;
  font-size: 0.76rem;
}
.viewer-legend span { display: inline-flex; align-items: center; gap: 6px; }
.swatch { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

.room-info {
  position: absolute; bottom: 14px; right: 14px; left: auto;
  max-width: 300px;
  background: var(--overlay-bg);
  border: 1px solid var(--border);
  padding: 12px 14px; border-radius: 10px;
  font-size: 0.82rem;
}
.room-info b { display: block; margin-bottom: 2px; font-size: 0.9rem; }
.room-info .dims { color: var(--ink-faint); font-size: 0.76rem; margin-bottom: 4px; }

/* ---------- gallery ---------- */
.gallery { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.gallery figure {
  margin: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--card-bg);
  box-shadow: var(--shadow);
  cursor: zoom-in;
}
.gallery figure img { width: 100%; aspect-ratio: 4/3; object-fit: cover; background: var(--img-frame); }
.gallery figcaption { padding: 10px 14px; font-size: 0.82rem; color: var(--ink-soft); }
.gallery figcaption b { display: block; color: var(--ink); font-size: 0.85rem; }

.compare-row { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-bottom: 18px; }
.compare-row figure { margin: 0; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--card-bg); }
.compare-row img { width: 100%; display: block; }
.compare-row figcaption { padding: 10px 14px; font-size: 0.82rem; }
.tag { display: inline-block; font-size: 0.68rem; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase; padding: 2px 8px; border-radius: 999px; margin-bottom: 4px; }
.tag.bad { background: rgba(239,68,68,0.15); color: #ef4444; }
.tag.good { background: rgba(34,197,94,0.15); color: #22c55e; }

/* ---------- video gallery ---------- */
.video-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.video-card { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--card-bg); box-shadow: var(--shadow); }
.video-card video { width: 100%; aspect-ratio: 16/9; background: #000; display: block; }
.video-card .vc-body { padding: 12px 14px; }
.video-card .vc-body b { font-size: 0.9rem; }
.video-card .vc-body p { margin: 4px 0 0; font-size: 0.8rem; }
.video-card.wide { grid-column: span 3; }
.video-card.wide video { aspect-ratio: 16/9; }

/* ---------- code / links section ---------- */
.link-card {
  display: flex; align-items: center; gap: 18px;
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 22px; background: var(--card-bg); box-shadow: var(--shadow);
}
.link-card .icon {
  width: 46px; height: 46px; flex: none; border-radius: 12px;
  background: var(--accent-soft); color: var(--accent-dark);
  display: flex; align-items: center; justify-content: center;
}
.stack-list { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.chip {
  font-size: 0.78rem; font-weight: 600; color: var(--ink-soft);
  border: 1px solid var(--border); padding: 5px 11px; border-radius: 999px;
  background: var(--bg-alt);
}

/* ---------- lightbox ---------- */
#lightbox {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(8, 12, 22, 0.88);
  display: none; align-items: center; justify-content: center;
  padding: 40px; cursor: zoom-out;
}
#lightbox.open { display: flex; }
#lightbox img { max-width: 92vw; max-height: 86vh; border-radius: 8px; box-shadow: 0 20px 60px rgba(0,0,0,0.5); }
#lightbox .lb-cap { position: absolute; bottom: 24px; left: 0; right: 0; text-align: center; color: #cbd5e1; font-size: 0.85rem; }

/* ---------- footer ---------- */
footer {
  background: var(--bg-dark-alt);
  color: #93a1b8;
  padding: 44px 0 30px;
  font-size: 0.86rem;
}
footer .foot-inner { display: flex; justify-content: space-between; align-items: center; gap: 20px; flex-wrap: wrap; }
footer a { color: #cdd8ec; }
.foot-brand { display: flex; align-items: center; gap: 10px; color: #fff; font-weight: 700; }

/* ---------- reveal animation ---------- */
.reveal { opacity: 0; transform: translateY(18px); transition: opacity 0.6s ease, transform 0.6s ease; }
.reveal.in { opacity: 1; transform: translateY(0); }

/* ---------- responsive ---------- */
@media (max-width: 980px) {
  .hero-inner { grid-template-columns: 1fr; }
  .hero-photo { max-width: 420px; }
  .grid-3, .video-grid { grid-template-columns: repeat(2, 1fr); }
  .video-card.wide { grid-column: span 2; }
  .gallery { grid-template-columns: repeat(2, 1fr); }
  .compare-row { grid-template-columns: 1fr; }
  .explorer { grid-template-columns: 1fr; }
  .room-list { max-height: 220px; display: flex; flex-wrap: wrap; gap: 8px; }
  .room-btn { width: auto; flex: 1 1 140px; }
  .navlinks { display: none; }
}
@media (max-width: 640px) {
  section { padding: 60px 0; }
  .grid-3, .grid-2, .video-grid, .gallery { grid-template-columns: 1fr; }
  .video-card.wide { grid-column: span 1; }
  .pipeline { flex-direction: column; }
  .pipeline .step { border-right: none; border-bottom: 1px solid var(--border); }
  .pipeline .step::after { content: "\2193"; right: 16px; top: auto; bottom: -11px; }
}
