:root {
  --bg: #080b0d;
  --panel: rgba(18, 23, 26, 0.82);
  --panel-strong: #12171a;
  --line: rgba(255, 255, 255, 0.1);
  --muted: #97a1a6;
  --text: #f7fbfb;
  --cyan: #77f3e3;
  --cyan-strong: #24d6c0;
  --lime: #c9ff62;
  --danger: #ff8b7b;
  --radius: 24px;
  font-family: Inter, ui-rounded, "SF Pro Rounded", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg);
  font-synthesis: none;
}

* { box-sizing: border-box; }
html { background: var(--bg); scroll-behavior: smooth; }
body { margin: 0; min-height: 100vh; overflow-x: hidden; background: radial-gradient(circle at 50% -10%, #163333 0, var(--bg) 38rem); }
button, input, select, textarea { font: inherit; }
button, select, input[type="range"], input[type="checkbox"], .drop-zone { touch-action: manipulation; }
button { color: inherit; }
.skip-link { position: fixed; top: 8px; left: 8px; z-index: 100; transform: translateY(-150%); padding: 10px 14px; background: white; color: black; border-radius: 10px; }
.skip-link:focus { transform: translateY(0); }

.ambient { position: fixed; z-index: -1; width: 18rem; height: 18rem; border-radius: 50%; filter: blur(90px); opacity: .13; pointer-events: none; }
.ambient--one { background: var(--cyan); top: 12rem; left: -10rem; }
.ambient--two { background: var(--lime); top: 42rem; right: -13rem; }

.topbar { position: sticky; top: 0; z-index: 20; display: flex; justify-content: space-between; align-items: center; padding: max(14px, env(safe-area-inset-top)) 18px 12px; background: linear-gradient(to bottom, rgba(8,11,13,.96), rgba(8,11,13,.76)); backdrop-filter: blur(20px); border-bottom: 1px solid rgba(255,255,255,.05); }
.brand { display: inline-flex; gap: 9px; align-items: center; color: var(--text); text-decoration: none; font-weight: 760; letter-spacing: -.02em; }
.brand svg { width: 27px; height: 27px; fill: none; stroke: var(--cyan); stroke-width: 1.6; }
.connect-button { display: inline-flex; align-items: center; gap: 8px; min-height: 42px; padding: 0 16px; border: 1px solid rgba(119,243,227,.34); border-radius: 999px; background: rgba(119,243,227,.09); font-size: .88rem; font-weight: 740; cursor: pointer; }
.connect-button:active { transform: scale(.97); }
.connect-button.is-connected { color: #06110f; background: var(--cyan); border-color: var(--cyan); }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); box-shadow: 0 0 0 4px rgba(151,161,166,.1); }
.is-connected .status-dot { background: #0d6659; box-shadow: 0 0 0 4px rgba(13,102,89,.15); }

.studio { width: min(100%, 760px); margin: 0 auto; padding: 20px 14px 80px; }
.intro { display: flex; justify-content: space-between; gap: 20px; align-items: flex-start; padding: 12px 5px 22px; }
.eyebrow { margin: 0 0 6px; color: var(--cyan); font-size: .72rem; font-weight: 850; letter-spacing: .15em; text-transform: uppercase; }
h1 { max-width: 560px; margin: 0; font-size: clamp(2.25rem, 11vw, 4.3rem); line-height: .94; letter-spacing: -.06em; }
.intro > div > p:last-child { max-width: 600px; margin: 16px 0 0; color: #bac3c6; line-height: 1.5; font-size: .98rem; }
.icon-button { display: grid; place-items: center; flex: 0 0 auto; width: 44px; height: 44px; border: 1px solid var(--line); border-radius: 50%; background: rgba(255,255,255,.04); cursor: pointer; }
.icon-button svg { width: 21px; fill: none; stroke: currentColor; stroke-width: 1.8; }

.compatibility { margin-bottom: 14px; padding: 16px; border: 1px solid rgba(255,139,123,.35); border-radius: 18px; background: rgba(255,139,123,.08); }
.compatibility strong { color: #ffd0ca; }
.compatibility p { margin: 6px 0 0; color: #d8c6c3; font-size: .86rem; line-height: 1.45; }

.display-card { position: relative; padding: 24px 18px 17px; overflow: hidden; border: 1px solid rgba(119,243,227,.14); border-radius: 30px; background: linear-gradient(145deg, rgba(20,28,31,.94), rgba(10,14,16,.94)); box-shadow: 0 24px 70px rgba(0,0,0,.35); }
.display-card::before { content: ""; position: absolute; inset: -40% 20% 35%; background: radial-gradient(circle, rgba(119,243,227,.16), transparent 62%); pointer-events: none; }
.display-shell { position: relative; width: min(70vw, 330px); aspect-ratio: 1; margin: 0 auto 24px; display: grid; place-items: center; perspective: 600px; }
.display-bezel { position: relative; z-index: 2; width: 78%; aspect-ratio: 1; padding: 10px; border: 1px solid rgba(255,255,255,.16); border-radius: 16px; background: #020303; box-shadow: 0 0 50px rgba(119,243,227,.14), inset 0 0 0 2px #0d1415; transform: rotateX(3deg); }
#displayCanvas { display: block; width: 100%; height: 100%; border-radius: 8px; background: #000; image-rendering: pixelated; }
.glass-sheen { position: absolute; inset: 10px; border-radius: 8px; background: linear-gradient(125deg, rgba(255,255,255,.08), transparent 35%); pointer-events: none; }
.cube-lines { position: absolute; inset: 1%; z-index: 3; border: 1px solid rgba(174,255,246,.22); transform: rotate(45deg) scale(.67); pointer-events: none; }
.cube-lines::before, .cube-lines::after, .cube-lines span { content: ""; position: absolute; inset: 0; border: 1px solid rgba(174,255,246,.12); }
.cube-lines::before { transform: translate(13%, -13%); }
.cube-lines::after { transform: translate(-13%, 13%); }
.display-meta { position: relative; z-index: 4; display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; }
.display-meta > div { display: flex; flex-direction: column; gap: 7px; }
.display-meta strong { font-size: 1.18rem; }
.display-meta p { margin: 0; color: var(--muted); font-size: .75rem; font-variant-numeric: tabular-nums; }
.connection-pill { width: max-content; padding: 4px 8px; border-radius: 999px; background: rgba(255,255,255,.07); color: #b9c2c5; font-size: .68rem; font-weight: 740; text-transform: uppercase; letter-spacing: .08em; }
.connection-pill.is-live { background: rgba(119,243,227,.13); color: var(--cyan); }

.mode-tabs { position: sticky; top: 68px; z-index: 15; display: grid; grid-template-columns: repeat(3, 1fr); gap: 5px; margin: 16px 0; padding: 5px; border: 1px solid var(--line); border-radius: 18px; background: rgba(10,14,16,.86); backdrop-filter: blur(18px); }
.mode-tab { min-width: 0; min-height: 52px; display: flex; justify-content: center; align-items: center; gap: 6px; padding: 8px 5px; border: 0; border-radius: 13px; background: transparent; color: #8f999d; font-size: clamp(.72rem, 3vw, .86rem); font-weight: 760; cursor: pointer; }
.mode-tab svg { width: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; }
.mode-tab.is-active { color: #051310; background: var(--cyan); box-shadow: 0 7px 24px rgba(36,214,192,.15); }

.control-panel { margin-top: 14px; padding: 20px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); backdrop-filter: blur(18px); }
.control-panel[hidden] { display: none; }
.section-heading { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 16px; }
.section-heading h2 { margin: 0; font-size: 1.28rem; letter-spacing: -.025em; }
.text-button { padding: 8px; border: 0; background: transparent; color: var(--cyan); font-weight: 750; cursor: pointer; }
.play-button { display: inline-flex; align-items: center; gap: 5px; min-height: 42px; padding: 0 14px; border: 1px solid rgba(119,243,227,.25); border-radius: 999px; background: rgba(119,243,227,.08); font-size: .82rem; font-weight: 780; cursor: pointer; }
.play-button svg { width: 18px; fill: currentColor; }
.play-button[aria-pressed="true"] { background: var(--cyan); color: #06110f; }
.play-button:disabled { opacity: .38; cursor: default; }

.draw-wrap { width: 100%; overflow: hidden; border: 1px solid rgba(119,243,227,.16); border-radius: 20px; background: #020303; }
#drawCanvas { display: block; width: 100%; aspect-ratio: 1; background: #000; image-rendering: pixelated; touch-action: none; cursor: crosshair; }
.draw-wrap p { margin: 0; padding: 10px 13px; border-top: 1px solid var(--line); color: var(--muted); font-size: .74rem; text-align: center; }
.control-row { display: grid; grid-template-columns: 1fr auto; gap: 14px; align-items: end; margin-top: 16px; }
.range-control { display: grid; gap: 9px; color: #cfd6d8; font-size: .82rem; font-weight: 700; }
.range-control span { display: flex; justify-content: space-between; }
.range-control--wide { margin-top: 16px; }
input[type="range"] { width: 100%; accent-color: var(--cyan-strong); }
.segmented { display: flex; padding: 3px; border: 1px solid var(--line); border-radius: 12px; background: rgba(0,0,0,.25); }
.segmented button { min-height: 37px; padding: 0 12px; border: 0; border-radius: 9px; background: transparent; color: var(--muted); font-size: .76rem; font-weight: 760; cursor: pointer; }
.segmented button.is-active { color: white; background: rgba(255,255,255,.1); }

.field { display: grid; gap: 8px; }
.field > span { color: #bdc5c7; font-size: .76rem; font-weight: 730; }
textarea, select { width: 100%; border: 1px solid var(--line); border-radius: 14px; outline: none; background: rgba(0,0,0,.27); color: white; }
textarea { min-height: 130px; padding: 14px; resize: vertical; font-size: 1.08rem; line-height: 1.35; text-transform: uppercase; }
textarea:focus, select:focus { border-color: rgba(119,243,227,.55); box-shadow: 0 0 0 3px rgba(119,243,227,.08); }
select { height: 46px; padding: 0 38px 0 12px; }
.two-up { display: grid; grid-template-columns: 1fr 1fr; gap: 11px; margin-top: 14px; }
.template-row { display: flex; gap: 8px; margin-top: 11px; overflow-x: auto; scrollbar-width: none; }
.template-row button { flex: 0 0 auto; padding: 9px 12px; border: 1px solid var(--line); border-radius: 999px; background: rgba(255,255,255,.04); color: #c6ced0; font-size: .72rem; cursor: pointer; }
.fine-print { margin: 13px 0 0; color: #778286; font-size: .7rem; }

.drop-zone { min-height: 190px; display: grid; place-items: center; align-content: center; gap: 7px; padding: 20px; border: 1px dashed rgba(119,243,227,.34); border-radius: 20px; background: rgba(119,243,227,.035); text-align: center; cursor: pointer; }
.drop-zone input { position: absolute; opacity: 0; pointer-events: none; }
.drop-zone svg { width: 31px; fill: none; stroke: var(--cyan); stroke-width: 1.5; }
.drop-zone strong { margin-top: 5px; }
.drop-zone span { color: var(--muted); font-size: .73rem; }
.drop-zone.is-dragging { border-color: var(--cyan); background: rgba(119,243,227,.09); }
.media-name { margin: 12px 0 0; padding: 10px 12px; overflow: hidden; border-radius: 12px; background: rgba(255,255,255,.05); color: #cfd7d8; font-size: .78rem; text-overflow: ellipsis; white-space: nowrap; }
.toggle-grid { display: grid; gap: 9px; margin-top: 16px; }
.toggle-row { display: flex; justify-content: space-between; align-items: center; gap: 16px; min-height: 58px; padding: 11px 13px; border: 1px solid var(--line); border-radius: 15px; background: rgba(0,0,0,.18); }
.toggle-row > span { display: grid; gap: 3px; }
.toggle-row strong { font-size: .8rem; }
.toggle-row small { color: var(--muted); font-size: .68rem; line-height: 1.25; }
.toggle-row input { width: 42px; height: 24px; accent-color: var(--cyan-strong); }
.settings-panel { margin-top: 14px; }

.footer { display: flex; justify-content: space-between; gap: 12px; padding: 24px max(18px, env(safe-area-inset-right)) max(28px, env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-left)); border-top: 1px solid var(--line); color: #778286; font-size: .72rem; }
.footer button { padding: 0; border: 0; background: transparent; color: var(--cyan); cursor: pointer; }

.help-dialog { width: min(92vw, 570px); max-height: min(86vh, 760px); padding: 20px; overflow: auto; border: 1px solid rgba(255,255,255,.14); border-radius: 26px; background: #101518; color: white; box-shadow: 0 30px 100px rgba(0,0,0,.6); }
.help-dialog::backdrop { background: rgba(0,0,0,.72); backdrop-filter: blur(8px); }
.dialog-head { display: flex; justify-content: space-between; align-items: center; }
.dialog-head h2 { margin: 0; }
.dialog-head .icon-button { font-size: 1.5rem; }
.setup-steps { display: grid; gap: 18px; margin: 24px 0; padding: 0; list-style: none; }
.setup-steps li { display: grid; grid-template-columns: 32px 1fr; gap: 12px; }
.setup-steps li > span { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: rgba(119,243,227,.12); color: var(--cyan); font-weight: 830; }
.setup-steps strong { display: block; }
.setup-steps p, .browser-note p { margin: 5px 0 0; color: #aeb8ba; font-size: .82rem; line-height: 1.45; }
.setup-steps a, .source-link { color: var(--cyan); font-size: .8rem; }
.browser-note { padding: 14px; border-radius: 15px; background: rgba(255,255,255,.045); }
.source-link { display: inline-block; margin-top: 18px; }
.toast { position: fixed; z-index: 100; right: 14px; bottom: max(18px, env(safe-area-inset-bottom)); left: 14px; max-width: 500px; margin: auto; padding: 13px 16px; border: 1px solid rgba(119,243,227,.24); border-radius: 14px; background: rgba(18,24,27,.96); box-shadow: 0 16px 50px rgba(0,0,0,.48); color: #e7eeee; font-size: .82rem; text-align: center; }

@media (min-width: 700px) {
  .topbar { padding-right: 28px; padding-left: 28px; }
  .studio { padding-top: 32px; }
  .display-card { padding: 30px; }
  .control-panel { padding: 25px; }
  .toggle-grid { grid-template-columns: 1fr 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}

