:root {
  --ink: #241c2c;
  --muted: #746b7b;
  --paper: #fbfaf8;
  --panel: rgba(255,255,255,.82);
  --line: #ded8e3;
  --violet: #7251a6;
  --violet-dark: #3d2d57;
  --lilac: #d9caee;
  --mint: #b8dfd0;
  --coral: #efaa97;
  --gold: #d9b86a;
  --shadow: 0 22px 60px rgba(52,35,69,.10);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 88% 4%, rgba(217,202,238,.72), transparent 30rem),
    radial-gradient(circle at 8% 40%, rgba(184,223,208,.42), transparent 25rem),
    var(--paper);
  font-family: Poppins, Inter, ui-sans-serif, system-ui, -apple-system, sans-serif;
  min-height: 100vh;
}
button, input, textarea { font: inherit; }
button { touch-action: manipulation; }

.topbar {
  min-height: 66px;
  padding: 12px max(20px, env(safe-area-inset-right)) 12px max(20px, env(safe-area-inset-left));
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(114,81,166,.14);
  background: rgba(251,250,248,.82);
  backdrop-filter: blur(18px);
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; font-weight: 750; }
.brand svg { width: 34px; height: 34px; fill: var(--violet); }
.evidence-tag { padding: 7px 10px; border-radius: 999px; background: #f0ebf7; color: var(--violet-dark); font-size: 11px; letter-spacing: .04em; }

main { width: min(1120px, calc(100% - 32px)); margin: 0 auto; }
.hero { padding: clamp(58px, 10vw, 116px) 0 50px; max-width: 850px; }
.eyebrow { margin: 0 0 10px; color: var(--violet); font-size: 11px; font-weight: 800; letter-spacing: .16em; text-transform: uppercase; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 22px; font-size: clamp(45px, 9vw, 92px); line-height: .96; letter-spacing: -.055em; font-weight: 720; }
h1 em { color: var(--violet); font-family: Georgia, serif; font-weight: 400; }
.lede { max-width: 720px; color: var(--muted); font-size: clamp(16px, 2.2vw, 21px); line-height: 1.7; }
.hero-actions { margin-top: 30px; display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
button { border: 0; border-radius: 14px; padding: 13px 18px; cursor: pointer; font-weight: 750; }
button:disabled { cursor: not-allowed; opacity: .45; }
.primary, .record { color: white; background: var(--violet-dark); box-shadow: 0 9px 24px rgba(61,45,87,.22); }
.secondary { color: var(--violet-dark); background: #eee7f5; }
.status { font-size: 13px; color: var(--muted); }
.status::before { content: ''; display: inline-block; width: 8px; height: 8px; margin-right: 7px; border-radius: 50%; background: var(--gold); }
.status.ready::before { background: #4aaa7b; }
.status.error::before { background: #cc665d; }

.metric-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 18px; }
.metric, .panel { border: 1px solid rgba(114,81,166,.16); background: var(--panel); box-shadow: var(--shadow); }
.metric { padding: 18px; border-radius: 18px; }
.metric span, .channels span { display: block; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .08em; }
.metric strong { display: block; margin-top: 9px; font: 700 clamp(25px, 4vw, 38px)/1 ui-monospace, monospace; color: var(--violet-dark); }
.metric small { display: block; margin-top: 7px; color: var(--muted); }

.panel { border-radius: 24px; overflow: hidden; }
.panel-heading { display: flex; justify-content: space-between; align-items: flex-start; padding: 24px 24px 15px; }
.panel-heading h2 { margin: 0; font-size: clamp(22px, 4vw, 34px); letter-spacing: -.035em; }
.legend { display: flex; gap: 8px; }
.legend span { width: 28px; height: 28px; display: grid; place-items: center; border-radius: 50%; font: 700 12px ui-monospace, monospace; }
.legend .x { background: #f9ded6; color: #9d4939; }
.legend .y { background: #d9eee6; color: #287659; }
.legend .z { background: #e6dcf3; color: #62418c; }
canvas { display: block; width: 100%; height: 260px; background: linear-gradient(180deg, rgba(242,237,247,.55), rgba(255,255,255,.3)); }
.channels { display: grid; grid-template-columns: repeat(6, 1fr); border-top: 1px solid var(--line); }
.channels div { padding: 16px; border-right: 1px solid var(--line); }
.channels div:last-child { border: 0; }
.channels strong { display: block; margin-top: 7px; font: 700 17px ui-monospace, monospace; }
.channels small { color: var(--muted); font-size: 10px; }

.workspace { display: grid; grid-template-columns: 1.5fr .8fr; gap: 18px; margin-top: 18px; }
.form-grid { padding: 0 24px 24px; display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
label { display: grid; gap: 7px; color: var(--muted); font-size: 12px; font-weight: 650; }
label.wide { grid-column: 1 / -1; }
input, textarea { width: 100%; border: 1px solid var(--line); border-radius: 12px; padding: 12px 13px; color: var(--ink); background: rgba(251,250,248,.7); outline: none; }
input:focus, textarea:focus { border-color: var(--violet); box-shadow: 0 0 0 3px rgba(114,81,166,.11); }
textarea { resize: vertical; }
.record-panel { padding-bottom: 24px; }
.record-panel > p, .record-panel > button, .record-state { margin-left: 24px; margin-right: 24px; }
.record-panel > p { color: var(--muted); font-size: 13px; line-height: 1.65; }
.record-state { display: flex; gap: 9px; align-items: center; margin-top: 22px; margin-bottom: 16px; }
#recordDot { width: 11px; height: 11px; border-radius: 50%; background: #aaa2ae; }
#recordDot.live { background: #d45a51; box-shadow: 0 0 0 7px rgba(212,90,81,.13); animation: pulse 1.3s infinite; }
.record-panel button { width: calc(100% - 48px); margin-bottom: 10px; }
.fineprint { margin-bottom: 0; font-size: 11px !important; }
@keyframes pulse { 50% { transform: scale(.75); } }

.boundary { margin: 80px auto; padding: clamp(28px, 6vw, 60px); border-radius: 28px; color: white; background: var(--violet-dark); }
.boundary .eyebrow { color: var(--lilac); }
.boundary h2 { font-size: clamp(30px, 5vw, 52px); letter-spacing: -.04em; }
.boundary p:last-child { max-width: 780px; color: #d9d1e1; line-height: 1.75; }
.install-panel { margin: -44px 0 80px; padding: clamp(24px, 5vw, 42px); display: flex; align-items: center; justify-content: space-between; gap: 30px; }
.install-panel h2 { margin-bottom: 10px; font-size: clamp(25px, 4vw, 38px); letter-spacing: -.035em; }
.install-panel p { max-width: 680px; color: var(--muted); line-height: 1.65; }
.install-panel .checksum { margin-bottom: 0; overflow-wrap: anywhere; font: 11px/1.6 ui-monospace, monospace; }
.install-button { flex: 0 0 auto; padding: 14px 18px; border-radius: 14px; color: white; background: var(--violet-dark); box-shadow: 0 9px 24px rgba(61,45,87,.22); text-decoration: none; font-weight: 750; text-align: center; }
footer { padding: 30px 20px calc(30px + env(safe-area-inset-bottom)); color: var(--muted); text-align: center; font-size: 12px; }

@media (max-width: 800px) {
  .metric-grid { grid-template-columns: 1fr 1fr; }
  .channels { grid-template-columns: repeat(3, 1fr); }
  .channels div:nth-child(3) { border-right: 0; }
  .channels div:nth-child(-n+3) { border-bottom: 1px solid var(--line); }
  .workspace { grid-template-columns: 1fr; }
  .install-panel { align-items: stretch; flex-direction: column; }
}
@media (max-width: 520px) {
  main { width: min(100% - 22px, 1120px); }
  .topbar { min-height: 58px; }
  .evidence-tag { max-width: 135px; text-align: center; font-size: 9px; }
  .hero { padding-top: 50px; }
  .metric { padding: 14px; }
  .metric strong { font-size: 24px; }
  .panel-heading { padding: 19px 17px 13px; }
  .form-grid { padding: 0 17px 17px; grid-template-columns: 1fr; }
  label.wide { grid-column: auto; }
  .record-panel > p, .record-panel > button, .record-state { margin-left: 17px; margin-right: 17px; }
  .record-panel button { width: calc(100% - 34px); }
  canvas { height: 220px; }
}
