/* ==========================================================================
   Design tokens
   ========================================================================== */
:root{
  --bg: #12161a;
  --bg-raised: #171c21;
  --panel: #1b2126;
  --panel-border: #2c353c;
  --grid-line: #222b31;

  --ink: #e9edf0;
  --ink-dim: #8b98a3;
  --ink-faint: #5b6870;

  --amber: #ffb454;
  --amber-dim: #8a6a3a;
  --cyan: #5fd4d6;
  --red: #ff6b5e;
  --green: #6fd88a;

  --mono: "IBM Plex Mono", "SF Mono", Menlo, Consolas, monospace;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;

  --amber-ink: #241a0a;

  --radius: 3px;
  --panel-pad: 22px;
}

/* Light theme — instrument screens (camera box, oscilloscope) stay
   dark in both themes on purpose, like a real hardware display. */
:root[data-theme="light"]{
  --bg: #eef1f3;
  --bg-raised: #ffffff;
  --panel: #f7f8fa;
  --panel-border: #d7dde2;
  --grid-line: #e3e7ea;

  --ink: #1b2126;
  --ink-dim: #55616a;
  --ink-faint: #8b98a3;

  --amber: #a3660b;
  --amber-dim: #d8b184;
  --amber-ink: #fff8ef;
  --cyan: #0e7f81;
  --red: #c23f34;
  --green: #1f8a45;
}

*{ box-sizing: border-box; }
html{ -webkit-text-size-adjust: 100%; }

html, body{
  overflow-x: hidden;
  max-width: 100%;
}

img, video, canvas, iframe, embed, object, svg{
  max-width: 100%;
}

body{
  margin: 0;
  background: var(--bg);
  background-image:
    linear-gradient(var(--grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
  background-size: 28px 28px;
  color: var(--ink);
  font-family: var(--sans);
  line-height: 1.5;
}

a{ color: var(--cyan); text-decoration: none; }
a:hover{ text-decoration: underline; }

:focus-visible{
  outline: 2px solid var(--amber);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce){
  *, *::before, *::after{
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}

.mono{ font-family: var(--mono); }

/* ==========================================================================
   Page shell / layout grid (console + ad rails)
   ========================================================================== */
.page{
  max-width: 1400px;
  margin: 0 auto;
  padding: 18px;
}

@media (max-width: 480px){
  .page{ padding: 12px; }
  .console{ padding: 16px; }
}

.layout{
  display: grid;
  grid-template-columns: minmax(0,180px) minmax(0,1fr) minmax(0,180px);
  gap: 20px;
  align-items: start;
}

@media (max-width: 1100px){
  .layout{ grid-template-columns: 1fr; }
  .rail{ display: none; }
}

.rail{ position: sticky; top: 18px; display: flex; flex-direction: column; gap: 20px; }

/* ==========================================================================
   Site header
   ========================================================================== */
.site-header{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 0 20px;
  flex-wrap: wrap;
}

.brand{
  display: flex;
  align-items: baseline;
  gap: 10px;
  font-family: var(--mono);
  letter-spacing: 0.02em;
}
.brand__mark{
  color: var(--amber);
  font-size: 1.4rem;
  font-weight: 600;
}
.brand__sub{
  color: var(--ink-faint);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
}

.header-status{
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--ink-dim);
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--panel-border);
  padding: 6px 12px;
  border-radius: var(--radius);
  background: var(--bg-raised);
}
.theme-toggle{
  font-family: var(--mono);
  font-size: 1rem;
  line-height: 1;
  background: var(--bg-raised);
  color: var(--ink-dim);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  padding: 8px 10px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.theme-toggle:hover{ border-color: var(--amber-dim); color: var(--ink); }

.dot{
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--ink-faint);
  box-shadow: 0 0 0 rgba(0,0,0,0);
}
.dot--live{ background: var(--green); box-shadow: 0 0 8px var(--green); animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse{ 0%,100%{ opacity: 1;} 50%{ opacity: .45; } }

/* ==========================================================================
   Console frame (the signature bench-panel look)
   ========================================================================== */
.console{
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  position: relative;
  padding: var(--panel-pad);
}
.console::before, .console::after,
.module::before, .module::after{
  content: "";
  position: absolute;
  width: 14px; height: 14px;
  pointer-events: none;
}
.console::before{ top: -1px; left: -1px; border-top: 2px solid var(--amber); border-left: 2px solid var(--amber); }
.console::after{ bottom: -1px; right: -1px; border-bottom: 2px solid var(--amber); border-right: 2px solid var(--amber); }

.console-head{
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}
.console-head h1{
  font-size: clamp(1.4rem, 2.4vw, 1.9rem);
  margin: 0;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.console-head p{
  margin: 6px 0 0;
  color: var(--ink-dim);
  font-size: 0.95rem;
  max-width: 52ch;
}
.build-tag{
  font-family: var(--mono);
  font-size: 0.68rem;
  color: var(--ink-faint);
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

/* ==========================================================================
   Modules (camera / mic / speaker panels)
   ========================================================================== */
.modules{
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  min-width: 0;
}
@media (max-width: 720px){ .modules{ grid-template-columns: 1fr; } }

.module{
  position: relative;
  background: var(--bg-raised);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  padding: 16px;
  min-width: 0;
}
.module::before{ top: -1px; left: -1px; border-top: 1px solid var(--panel-border); border-left: 1px solid var(--panel-border); }
.module::after{ bottom: -1px; right: -1px; border-bottom: 1px solid var(--panel-border); border-right: 1px solid var(--panel-border); }

.module-head{
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.module-head h2{
  font-family: var(--mono);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin: 0;
  color: var(--ink-dim);
}

.status-chip{
  font-family: var(--mono);
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 3px 8px;
  border-radius: 2px;
  border: 1px solid var(--panel-border);
  color: var(--ink-faint);
}
.status-chip[data-state="testing"]{ color: var(--amber); border-color: var(--amber-dim); }
.status-chip[data-state="ok"]{ color: var(--green); border-color: var(--green); }
.status-chip[data-state="fail"]{ color: var(--red); border-color: var(--red); }

.video-frame{
  position: relative;
  aspect-ratio: 4 / 3;
  background: #05070a;
  border-radius: 2px;
  overflow: hidden;
  border: 1px solid var(--panel-border);
}
.video-frame video{
  width: 100%; height: 100%;
  object-fit: cover;
  transform: scaleX(-1); /* mirror, like a mirror/webcam preview */
}
.video-frame .rec-dot{
  position: absolute; top: 10px; left: 10px;
  display: flex; align-items: center; gap: 6px;
  font-family: var(--mono); font-size: 0.66rem; color: var(--red);
  text-transform: uppercase; letter-spacing: 0.08em;
  background: rgba(5,7,10,0.6);
  padding: 3px 7px; border-radius: 2px;
}
.video-frame .rec-dot .dot{ background: var(--red); box-shadow: 0 0 6px var(--red); }
.video-frame .meta{
  position: absolute; bottom: 10px; right: 10px;
  font-family: var(--mono); font-size: 0.66rem; color: var(--ink-dim);
  background: rgba(5,7,10,0.6);
  padding: 3px 7px; border-radius: 2px;
}
.video-frame .empty-state{
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  color: var(--ink-faint); font-family: var(--mono); font-size: 0.75rem;
  text-align: center; padding: 20px;
}

canvas.scope{
  width: 100%; height: 160px;
  display: block;
  background: #05070a;
  border-radius: 2px;
  border: 1px solid var(--panel-border);
}

.meter-row{
  display: flex; align-items: center; gap: 10px;
  margin-top: 10px;
  font-family: var(--mono); font-size: 0.68rem; color: var(--ink-faint);
}
.meter-track{
  flex: 1; height: 8px;
  background: #05070a;
  border: 1px solid var(--panel-border);
  border-radius: 2px;
  overflow: hidden;
  position: relative;
}
.meter-fill{
  height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--cyan), var(--amber) 75%, var(--red) 92%);
  transition: width 60ms linear;
}

.module-foot{
  margin-top: 12px;
  display: flex; gap: 8px; flex-wrap: wrap; align-items: center;
  min-width: 0;
}
.module-foot select{ flex: 1 1 auto; min-width: 0; }

select, button.btn{
  font-family: var(--mono);
  font-size: 0.72rem;
  background: var(--panel);
  color: var(--ink);
  border: 1px solid var(--panel-border);
  border-radius: 2px;
  padding: 7px 10px;
  cursor: pointer;
  max-width: 100%;
}
select{
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
select:hover, button.btn:hover{ border-color: var(--amber-dim); }
button.btn--primary{
  background: var(--amber);
  color: var(--amber-ink);
  border-color: var(--amber);
  font-weight: 600;
}
button.btn--primary:hover{ filter: brightness(1.08); }
button.btn:disabled{ opacity: 0.4; cursor: not-allowed; }

.hint{ font-size: 0.78rem; color: var(--ink-faint); margin-top: 8px; }

/* ==========================================================================
   Permission / error notices
   ========================================================================== */
.notice{
  margin-top: 16px;
  border: 1px solid var(--panel-border);
  border-left: 3px solid var(--red);
  background: var(--bg-raised);
  padding: 12px 14px;
  border-radius: 2px;
  font-size: 0.85rem;
  color: var(--ink-dim);
  display: none;
}
.notice.is-visible{ display: block; }
.notice strong{ color: var(--ink); }

/* ==========================================================================
   Results reveal + next stops (the bounce-catcher)
   ========================================================================== */
.results{
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px dashed var(--panel-border);
  display: none;
}
.results.is-visible{ display: block; }

.results-banner{
  display: flex; align-items: center; gap: 12px;
  font-family: var(--mono);
  font-size: 0.95rem;
  color: var(--green);
  margin-bottom: 16px;
}
.results-banner .dot{ background: var(--green); box-shadow: 0 0 8px var(--green); }

.next-stops h3{
  font-family: var(--mono);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-dim);
  margin: 0 0 12px;
}
.stop-grid{
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
}
.stop-card{
  display: block;
  background: var(--bg-raised);
  border: 1px solid var(--panel-border);
  border-radius: 2px;
  padding: 14px;
  color: var(--ink);
}
.stop-card:hover{ border-color: var(--amber-dim); text-decoration: none; }
.stop-card__title{ font-weight: 600; font-size: 0.92rem; margin-bottom: 4px; }
.stop-card__blurb{ font-size: 0.8rem; color: var(--ink-dim); }

/* ==========================================================================
   Share bar
   ========================================================================== */
.share-bar{
  margin-top: 18px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
.share-bar__label{
  font-family: var(--mono);
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-faint);
  margin-right: 4px;
}
.share-btn{
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--ink);
  background: var(--bg-raised);
  border: 1px solid var(--panel-border);
  border-radius: 2px;
  padding: 7px 10px;
  cursor: pointer;
  text-decoration: none;
}
.share-btn:hover{ border-color: var(--cyan); color: var(--cyan); text-decoration: none; }
.share-btn.is-copied{ border-color: var(--green); color: var(--green); }

.remind-box{
  margin-top: 10px;
  font-size: 0.8rem;
  color: var(--ink-dim);
}
.remind-box a{ font-family: var(--mono); font-size: 0.75rem; }

/* ==========================================================================
   Ad slots
   ========================================================================== */
.ad-slot{
  position: relative;
  width: 100%;
  min-width: 0;
  min-height: var(--ad-h, 90px);
  max-width: var(--ad-w, 100%);
  margin: 0 auto;
  background: var(--bg-raised);
  border: 1px dashed var(--panel-border);
  border-radius: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden; /* clip any fixed-width ad markup (e.g. a 728px iframe) instead of letting it push the page wider than the viewport */
}
.ad-slot > *{ max-width: 100%; }
.ad-slot__tag{
  position: absolute;
  top: 4px; left: 6px;
  font-family: var(--mono);
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-faint);
}
.ad-slot__placeholder{
  font-family: var(--mono);
  font-size: 0.68rem;
  color: var(--ink-faint);
}
.ad-slot--inline{ margin: 22px auto; }

/* ==========================================================================
   Legal pages (privacy / terms)
   ========================================================================== */
.legal-page{
  max-width: 74ch;
  margin: 0 auto;
}
.legal-page h1{
  font-size: clamp(1.5rem, 2.6vw, 2rem);
  margin: 0 0 4px;
}
.legal-updated{
  color: var(--ink-faint);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 24px;
}
.legal-page h2{
  font-size: 1.02rem;
  margin: 28px 0 8px;
  color: var(--ink);
}
.legal-page p, .legal-page li{
  color: var(--ink-dim);
  font-size: 0.92rem;
  line-height: 1.7;
}
.legal-page ul{ padding-left: 20px; }
.legal-page code{
  font-family: var(--mono);
  font-size: 0.85em;
  background: var(--bg-raised);
  border: 1px solid var(--panel-border);
  padding: 1px 5px;
  border-radius: 2px;
}

/* ==========================================================================
   Footer
   ========================================================================== */
.site-footer{
  margin-top: 30px;
  padding-top: 20px;
  border-top: 1px solid var(--panel-border);
  color: var(--ink-faint);
  font-size: 0.78rem;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.site-footer a{ color: var(--ink-dim); }
