:root {
  --bg: #000000;
  --fg: #ffffff;
  --panel: #15171c;
  --panel-2: #1d2027;
  --line: #2a2f3a;
  --accent: #4f8cff;
  --accent-2: #2bd4a8;
  --danger: #ff5468;
  --muted: #8a90a0;
  --radius: 14px;
  --safe: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #000;
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, system-ui, sans-serif;
}

/* ---------------- stage (the scrolling text) ---------------- */

#stage {
  position: fixed;
  top: 0; right: 0; bottom: 0; left: 0;
  overflow: hidden;
  background: #000;
  background: var(--bg);
  transform-origin: 50% 50%;
}

#scroller {
  position: absolute;
  left: 50%;
  top: 0;
  transform: translateX(-50%);
  will-change: transform;
}

#text {
  white-space: pre-wrap;
  word-break: break-word;
  font-weight: 400;
  margin: 0;
}
#text.bold { font-weight: 800; }

/* word spans for voice tracking */
span.word { border-radius: 4px; transition: background 0.12s, color 0.12s, opacity 0.12s; }
span.word.word-past {
  background: rgba(79, 140, 255, 0.17);
  opacity: 0.72;
}
span.word.word-current {
  background: rgba(255, 50, 70, 0.88);
  color: #fff !important;
  padding: 0 3px;
  margin: 0 -3px;
  box-shadow: 0 0 0 1px rgba(255, 50, 70, 0.55);
}

/* mirror transforms */
#stage.mirror-h { transform: scaleX(-1); }
#stage.mirror-v { transform: scaleY(-1); }
#stage.mirror-h.mirror-v { transform: scale(-1, -1); }

/* reading indicator */
#indicator {
  position: fixed;
  left: 0; right: 0;
  top: 50%;
  pointer-events: none;
  display: none;
}
#indicator.on { display: block; }
#indicator .bar {
  position: absolute;
  left: 0; right: 0;
  height: 0;
  border-top: 2px solid rgba(255, 80, 104, 0.55);
}
#indicator .tri {
  position: absolute;
  top: -9px;
  width: 0; height: 0;
  border-top: 9px solid transparent;
  border-bottom: 9px solid transparent;
}
#indicator .tri.l { left: 0; border-left: 14px solid var(--danger); }
#indicator .tri.r { right: 0; border-right: 14px solid var(--danger); }

#empty {
  position: fixed;
  top: 0; right: 0; bottom: 0; left: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: var(--muted);
  font-size: 22px;
  padding: 24px;
  pointer-events: none;
}

/* ---------------- floating mouse controls ---------------- */

#dock {
  position: fixed;
  left: 50%;
  bottom: 18px;
  bottom: calc(18px + var(--safe));
  transform: translateX(-50%);
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 10px 12px;
  background: rgba(20, 22, 28, 0.82);
  border: 1px solid var(--line);
  border-radius: 999px;
  backdrop-filter: blur(10px);
  z-index: 30;
  transition: opacity .25s;
}
#dock.dim { opacity: 0.12; }
#dock.dim:hover { opacity: 1; }

.bigbtn {
  appearance: none;
  border: none;
  background: var(--panel-2);
  color: var(--fg);
  width: 64px; height: 64px;
  border-radius: 50%;
  font-size: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  user-select: none;
  transition: transform .06s, background .15s;
}
.bigbtn:hover { background: #262b35; }
.bigbtn:active { transform: scale(0.92); }
.bigbtn.play { width: 84px; height: 84px; background: var(--accent); font-size: 30px; }
.bigbtn.play.playing { background: var(--danger); }
.bigbtn .lbl { display: flex; flex-direction: column; align-items: center; line-height: 1; }
.bigbtn .lbl b { font-size: 22px; }
.bigbtn .lbl span { font-size: 10px; color: rgba(255,255,255,.7); margin-top:3px; }

#speedReadout {
  position: fixed;
  left: 50%;
  bottom: 96px;
  bottom: calc(96px + var(--safe));
  transform: translateX(-50%);
  font-size: 13px;
  color: var(--muted);
  background: rgba(0,0,0,.4);
  padding: 4px 10px;
  border-radius: 999px;
  z-index: 30;
  opacity: 0;
  transition: opacity .2s;
}
#speedReadout.show { opacity: 1; }

/* ---------------- voice status bar ---------------- */

#voiceStatus {
  position: fixed;
  bottom: calc(108px + var(--safe));
  left: 50%;
  transform: translateX(-50%);
  background: rgba(20, 22, 28, 0.92);
  border: 1px solid var(--danger);
  color: var(--fg);
  padding: 5px 14px;
  border-radius: 999px;
  font-size: 12px;
  max-width: 80vw;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  z-index: 31;
  display: none;
  pointer-events: none;
}
#voiceStatus.show { display: block; }

/* ---------------- top bar ---------------- */

#topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  z-index: 25;
  transition: opacity .25s, transform .25s;
  flex-wrap: nowrap;
}
#topbar.hidden { opacity: 0; transform: translateY(-100%); pointer-events: none; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: rgba(20, 22, 28, 0.82);
  border: 1px solid var(--line);
  padding: 7px 12px;
  border-radius: 999px;
  font-size: 13px;
  backdrop-filter: blur(10px);
  white-space: nowrap;
}
.pill b { font-variant-numeric: tabular-nums; letter-spacing: .5px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.dot.live { background: var(--accent-2); box-shadow: 0 0 8px var(--accent-2); }
.dot.off { background: var(--danger); }

.spacer { flex: 1; }

.iconbtn {
  appearance: none;
  border: 1px solid var(--line);
  background: rgba(20, 22, 28, 0.82);
  color: var(--fg);
  height: 38px;
  min-width: 38px;
  padding: 0 12px;
  border-radius: 10px;
  font-size: 14px;
  cursor: pointer;
  backdrop-filter: blur(10px);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
}
.iconbtn:hover { background: #262b35; }
.iconbtn.role { font-weight: 600; }
.iconbtn.role.control { border-color: var(--accent); color: var(--accent); }
.iconbtn.role.display { border-color: var(--accent-2); color: var(--accent-2); }

/* voice button active state */
.iconbtn.voice-active {
  border-color: var(--danger);
  color: var(--danger);
  animation: voicePulse 1.4s ease-in-out infinite;
}
@keyframes voicePulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 80, 104, 0); }
  50% { box-shadow: 0 0 0 4px rgba(255, 80, 104, 0.3); }
}

/* auto-speed button — dim when voice is off, accent when active */
#voiceAutoBtn { opacity: 0.4; }
#voiceAutoBtn.active {
  opacity: 1;
  border-color: var(--accent);
  color: var(--accent);
  animation: voicePulse 2s ease-in-out infinite;
}

/* ---------------- framing (кадрирование) ---------------- */

/* На пульте: пунктирная рамка — зона, которую видит планшет после кадрирования */
#frameGhost {
  position: fixed;
  display: none;
  border: 2px dashed rgba(79, 140, 255, 0.55);
  border-radius: 6px;
  pointer-events: none;
  z-index: 4;
}

/* На пульте: горизонтальная полоса — часть текста, реально видимая на планшете */
#tabletBand {
  position: fixed;
  display: none;
  left: 0; right: 0;
  border-top: 1px solid rgba(94, 226, 160, 0.5);
  border-bottom: 1px solid rgba(94, 226, 160, 0.5);
  background: rgba(94, 226, 160, 0.05);
  pointer-events: none;
  z-index: 3;
}
#tabletBandLabel {
  position: absolute;
  right: 8px;
  top: 4px;
  font-size: 11px;
  color: rgba(94, 226, 160, 0.85);
  background: rgba(0, 0, 0, 0.55);
  padding: 2px 8px;
  border-radius: 10px;
}

/* Operator preview based on the actual display viewport reported over WS. */
#tabletPreview {
  position: fixed;
  right: 14px;
  bottom: 78px;
  display: none;
  z-index: 12;
  padding: 8px;
  border: 1px solid rgba(94, 226, 160, .5);
  border-radius: 10px;
  background: rgba(5, 8, 12, .92);
  box-shadow: 0 8px 30px rgba(0, 0, 0, .45);
  color: #fff;
}
.tablet-preview-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
  font-size: 11px;
  color: rgba(94, 226, 160, .95);
}
.preview-status {
  margin-left: auto;
  padding: 1px 6px;
  border-radius: 999px;
  background: rgba(94, 226, 160, .12);
  color: var(--accent-2);
}
#tabletPreview.stale {
  border-color: rgba(255, 194, 78, .75);
}
#tabletPreview.stale .preview-status {
  background: rgba(255, 194, 78, .14);
  color: #ffd27a;
}
#tabletPreview.offline {
  border-color: rgba(255, 88, 88, .75);
}
#tabletPreview.offline .preview-status {
  background: rgba(255, 88, 88, .14);
  color: #ff9d9d;
}
#tabletPreviewToggle {
  appearance: none;
  width: 22px;
  height: 20px;
  border: 1px solid rgba(255, 255, 255, .2);
  border-radius: 5px;
  background: rgba(255, 255, 255, .08);
  color: #fff;
  cursor: pointer;
}
#tabletPreviewScreen {
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, .22);
  border-radius: 5px;
  background: #000;
}
#tabletPreview.collapsed #tabletPreviewScreen { display: none; }
#tabletPreview.collapsed .tablet-preview-head { margin-bottom: 0; }
#tabletPreviewLine {
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  z-index: 2;
  border-top: 1px solid rgba(255, 80, 80, .75);
}
#tabletPreviewScroller {
  position: absolute;
  left: 50%;
  top: 0;
  will-change: transform;
}
#tabletPreviewText {
  white-space: pre-wrap;
  overflow-wrap: break-word;
  margin: 0 auto;
}

.compat-status {
  margin-top: 8px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}
.compat-status.ok { border-color: rgba(94, 226, 160, .45); color: var(--accent-2); }
.compat-status.warn { border-color: rgba(255, 194, 78, .5); color: #ffd27a; }
.compat-status.bad { border-color: rgba(255, 88, 88, .5); color: #ff9d9d; }
#diagStatus { white-space: pre-line; }

#montageMenu {
  position: fixed;
  top: 58px;
  right: 14px;
  display: none;
  width: min(360px, calc(100vw - 28px));
  z-index: 55;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(21, 23, 28, .98);
  box-shadow: 0 16px 50px rgba(0, 0, 0, .55);
}
#montageMenu.show { display: block; }
#montageMenu label { display:block; margin-bottom:6px; color:var(--muted); font-size:12px; }
#montageMenu input { width:100%; margin-bottom:10px; }
.montage-actions { display:flex; gap:6px; flex-wrap:wrap; margin-top:7px; }
#montageSummary { margin:10px 0 0; }

/* За пределами кадра (на планшете) — чёрный фон зеркальной зоны */
body { background: #000; }

/* ---------------- settings panel ---------------- */

#panel {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: 92vw;
  max-width: 420px;
  background: var(--panel);
  border-left: 1px solid var(--line);
  z-index: 40;
  transform: translateX(100%);
  transition: transform .28s cubic-bezier(.4,0,.2,1);
  display: flex;
  flex-direction: column;
}
#panel.open { transform: translateX(0); }

#panel header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}
#panel header h2 { margin: 0; font-size: 16px; }
#panel .body { overflow-y: auto; padding: 8px 18px 28px; }

.group { padding: 14px 0; border-bottom: 1px solid var(--line); }
.group:last-child { border-bottom: none; }
.group > .glabel {
  font-size: 11px;
  letter-spacing: .8px;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 10px;
}

.field { margin-bottom: 14px; }
.field:last-child { margin-bottom: 0; }
.field .row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.field label { font-size: 14px; }
.field .val { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }

textarea#scriptInput {
  width: 100%;
  min-height: 160px;
  resize: vertical;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--fg);
  padding: 12px;
  font-size: 15px;
  line-height: 1.5;
  font-family: inherit;
}

input[type="range"] { width: 100%; accent-color: var(--accent); }
input[type="color"] {
  width: 44px; height: 32px; padding: 0;
  border: 1px solid var(--line); border-radius: 8px; background: none; cursor: pointer;
}
select, input[type="text"] {
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--fg);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 14px;
}

.segmented { display: flex; gap: 6px; flex-wrap: wrap; }
.segmented button {
  flex: 1;
  min-width: 64px;
  appearance: none;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--fg);
  padding: 9px 8px;
  border-radius: 9px;
  font-size: 13px;
  cursor: pointer;
}
.segmented button.active { border-color: var(--accent); background: rgba(79,140,255,.16); color: #cfe0ff; }

.toggle {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 0;
}
.toggle .sw {
  width: 46px; height: 28px; border-radius: 999px; background: var(--panel-2);
  border: 1px solid var(--line); position: relative; cursor: pointer; transition: background .15s;
  flex-shrink: 0;
}
.toggle .sw::after {
  content: ""; position: absolute; top: 2px; left: 2px;
  width: 22px; height: 22px; border-radius: 50%; background: var(--muted); transition: .15s;
}
.toggle .sw.on { background: rgba(79,140,255,.3); border-color: var(--accent); }
.toggle .sw.on::after { left: 20px; background: var(--accent); }

.btn {
  appearance: none; border: 1px solid var(--line); background: var(--panel-2);
  color: var(--fg); border-radius: 10px; padding: 10px 14px; font-size: 14px; cursor: pointer;
}
.btn:hover { background: #262b35; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.full { width: 100%; }
.btn.ghost { background: transparent; }
.btn:disabled, .iconbtn:disabled { opacity: .45; cursor: not-allowed; }

/* ---------------- welcome / first-run overlay ---------------- */

#welcomeOverlay {
  position: fixed; inset: 0; z-index: 50;
  display: none; align-items: center; justify-content: center;
  padding: 24px;
}
#welcomeOverlay.show { display: flex; }

.welcome-card {
  width: 100%; max-width: 560px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 28px; box-shadow: 0 20px 60px rgba(0,0,0,.5);
}
.welcome-card h2 { margin: 0 0 10px; font-size: 22px; }
.welcome-card .hint { margin-bottom: 16px; }
.welcome-card textarea {
  width: 100%; min-height: 140px; resize: vertical;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px;
  color: var(--fg); font-size: 15px; padding: 12px; box-sizing: border-box;
}
.welcome-actions { display: flex; gap: 10px; margin-top: 14px; }
.welcome-actions .btn.primary { flex: 1; font-size: 16px; padding: 12px 14px; }

.hint { font-size: 12px; color: var(--muted); line-height: 1.5; }
.kbd {
  display: inline-block; padding: 1px 7px; border-radius: 6px;
  border: 1px solid var(--line); background: var(--panel-2);
  font-size: 12px;
}

.maprow { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.maprow .act { font-size: 13px; }
.maprow .keys { display: flex; gap: 6px; align-items: center; }
.maprow .learn { font-size: 12px; padding: 6px 10px; }
.maprow.learning .learn { border-color: var(--accent-2); color: var(--accent-2); }

#roomShare { display: flex; gap: 8px; align-items: center; }
#roomShare input { flex: 1; }

.code { font-variant-numeric: tabular-nums; letter-spacing: 2px; font-weight: 700; color: var(--accent-2); }

#qrwrap { margin-top: 12px; display: flex; gap: 14px; align-items: center; }
#qrwrap canvas, #qrwrap img { background: #fff; border-radius: 8px; padding: 6px; }

.scrim {
  position: fixed; top: 0; right: 0; bottom: 0; left: 0;
  background: rgba(0,0,0,.5); z-index: 35;
  opacity: 0; pointer-events: none; transition: opacity .25s;
}
.scrim.show { opacity: 1; pointer-events: auto; }

.flash {
  position: fixed; top: 14px; left: 50%; transform: translateX(-50%);
  background: var(--panel-2); border: 1px solid var(--line); color: var(--fg);
  padding: 10px 16px; border-radius: 10px; z-index: 60; font-size: 14px;
  opacity: 0; transition: opacity .2s, transform .2s;
  white-space: nowrap;
}
.flash.show { opacity: 1; transform: translateX(-50%) translateY(4px); }

/* ---------------- editor page ---------------- */

body.editor-page {
  overflow: auto;
  background: var(--panel);
}

.ed-root {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  max-width: 1400px;
  margin: 0 auto;
  padding: 16px;
  gap: 14px;
}

.ed-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}
.ed-header h1 { margin: 0; font-size: 18px; flex: 1; }

.ed-panels {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  flex: 1;
  min-height: 0;
}

.ed-panel {
  display: flex;
  flex-direction: column;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

.ed-panel-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .6px;
}

.ed-panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  font-size: 15px;
  line-height: 1.65;
  white-space: pre-wrap;
  word-break: break-word;
}

.ed-panel-body textarea {
  width: 100%;
  height: 100%;
  min-height: 300px;
  resize: none;
  background: transparent;
  border: none;
  outline: none;
  color: var(--fg);
  font: inherit;
  white-space: pre-wrap;
}

.diff-add { background: rgba(43, 212, 168, 0.25); border-radius: 3px; }
.diff-del { background: rgba(255, 84, 104, 0.25); text-decoration: line-through; border-radius: 3px; }

.ed-voice-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.ed-voice-bar .voice-label {
  flex: 1 1 340px;
  font-size: 13px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ed-log {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 14px;
  font-size: 12px;
  color: var(--muted);
  max-height: 100px;
  overflow-y: auto;
}

.ed-tov {
  background: var(--panel);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  padding: 16px;
  white-space: pre-wrap;
  font-size: 13px;
  line-height: 1.65;
  max-height: 400px;
  overflow-y: auto;
  display: none;
}
.ed-tov.show { display: block; }

/* ---------------- progress HUD (controller only) ---------------- */

#hud {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 20;
  pointer-events: none;
  display: none;
}
#hud.on { display: block; }

#hudBar {
  height: 3px;
  background: rgba(255,255,255,.08);
  width: 100%;
}
#hudFill {
  height: 3px;
  background: var(--accent);
  width: 0%;
  transition: width .3s linear;
}

#hudRow {
  display: flex;
  gap: 6px;
  padding: 6px 14px 0;
  pointer-events: auto;
}

.hud-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(20,22,28,.78);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 12px;
  backdrop-filter: blur(8px);
  white-space: nowrap;
}

/* ---------------- end-of-text banner ---------------- */

#endBanner {
  position: fixed;
  left: 50%;
  bottom: calc(110px + var(--safe));
  transform: translateX(-50%) translateY(20px);
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(20,22,28,.92);
  border: 1px solid var(--accent-2);
  color: var(--fg);
  padding: 10px 16px;
  border-radius: 14px;
  font-size: 14px;
  z-index: 31;
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s, transform .25s;
  white-space: nowrap;
}
#endBanner.show {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(-50%) translateY(0);
}
#endRestartBtn {
  appearance: none;
  border: 1px solid var(--accent-2);
  background: rgba(43,212,168,.15);
  color: var(--accent-2);
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 13px;
  cursor: pointer;
}
#endRestartBtn:hover { background: rgba(43,212,168,.3); }

/* ---------------- connect tablet modal ---------------- */

#connectModal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.94);
  width: 92vw;
  max-width: 480px;
  max-height: 90vh;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  z-index: 50;
  display: flex;
  flex-direction: column;
  opacity: 0;
  pointer-events: none;
  transition: opacity .22s, transform .22s;
  overflow: hidden;
}
#connectModal.show {
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, -50%) scale(1);
}

.conn-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}
.conn-header h3 { margin: 0; font-size: 16px; }

.conn-body {
  padding: 16px 18px 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.conn-url {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 10px 14px;
  font-size: 13px;
  font-family: ui-monospace, Menlo, Consolas, "Courier New", monospace;
  word-break: break-all;
  color: var(--accent);
  margin-bottom: 4px;
}

.conn-qr-row {
  display: flex;
  gap: 18px;
  align-items: flex-start;
}
#connectQR {
  background: #fff;
  border-radius: 10px;
  padding: 8px;
  flex-shrink: 0;
}
.conn-code-col { flex: 1; }

.conn-steps {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.conn-step {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 13px;
  line-height: 1.5;
}
.conn-n {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
}

@media (max-width: 700px) {
  .ed-panels { grid-template-columns: 1fr; }
  .bigbtn { width: 56px; height: 56px; font-size: 21px; }
  .bigbtn.play { width: 72px; height: 72px; }
  #topbar { gap: 6px; padding: 8px 10px; }
  .pill { padding: 5px 8px; font-size: 12px; }
}

@media (max-width: 980px) {
  #tabletPreview { right: 8px; bottom: 70px; }
}
