/* Streamdzy theme — black, silver and charcoal with a fine textured surface. Shared by the desktop app and the Web Studio.
   Principles: one thing at a time, large touch-friendly controls, quiet colour (silver on black), colour only for state
   (red = recording, white glow = live). Textures are pure CSS (no images): brushed-metal lines + film grain. */
:root {
  color-scheme: dark;
  --black: #000;
  --ink: #0b0b0c;
  --charcoal-900: #141415;
  --charcoal-800: #1c1c1e;
  --charcoal-700: #242426;
  --charcoal-600: #2c2c2f;
  --charcoal-500: #3a3a3d;
  --silver-100: #f5f5f7;
  --silver-300: #d6d6db;
  --silver-500: #a1a1a8;
  --silver-700: #6e6e75;
  --line: rgba(255, 255, 255, .09);
  --line-strong: rgba(255, 255, 255, .16);
  --rec: #ff453a;
  --ok: #8fe3ad;
  --warn: #ffd479;
  --radius: 18px;
  --radius-sm: 12px;
  --font: "SF Pro Display", "SF Pro Text", -apple-system, BlinkMacSystemFont, "Segoe UI Variable Display", "Segoe UI Variable Text", "Segoe UI", system-ui, sans-serif;
  /* film grain (SVG turbulence, tiled) */
  --grain: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='180' height='180'><filter id='n' x='0' y='0'><feTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 1  0 0 0 0 1  0 0 0 0 1  0 0 0 .5 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  /* brushed metal: fine horizontal-grain lines */
  --brushed: repeating-linear-gradient(90deg, rgba(255,255,255,.028) 0 1px, rgba(0,0,0,.06) 1px 2px, rgba(255,255,255,0) 2px 5px);
  --panel-bg: var(--brushed), linear-gradient(180deg, #2b2b2e 0%, #1d1d20 100%);
  --panel-edge: inset 0 1px 0 rgba(255,255,255,.10), inset 0 -1px 0 rgba(0,0,0,.45), 0 12px 40px rgba(0,0,0,.45);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  font: 15px/1.45 var(--font); color: var(--silver-100); letter-spacing: -.003em;
  background:
    radial-gradient(1200px 700px at 50% -10%, #26262a 0%, rgba(38,38,42,0) 60%),
    radial-gradient(900px 600px at 50% 120%, #1a1a1d 0%, rgba(26,26,29,0) 55%),
    #060607;
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased; overflow: hidden;
}
body::before { content: ""; position: fixed; inset: 0; background-image: var(--grain); opacity: .055; mix-blend-mode: overlay; pointer-events: none; z-index: 1; }
h1, h2, h3 { font-weight: 600; letter-spacing: -.015em; margin: 0; }
button { font: inherit; color: inherit; }
::selection { background: rgba(255,255,255,.25); }
:focus-visible { outline: 2px solid var(--silver-100); outline-offset: 2px; border-radius: 10px; }
::-webkit-scrollbar { width: 10px; height: 10px; } ::-webkit-scrollbar-thumb { background: var(--charcoal-500); border-radius: 8px; border: 2px solid transparent; background-clip: padding-box; }

/* ───────── shell ───────── */
#shell { position: relative; z-index: 2; height: 100%; display: grid; grid-template-rows: auto 1fr auto; padding: 14px 22px 22px; gap: 12px; }
.topbar { display: flex; align-items: center; gap: 10px; min-height: 44px; }
.wordmark { font-weight: 700; letter-spacing: .34em; font-size: 12.5px; color: var(--silver-300); text-transform: uppercase; user-select: none; }
.wordmark i { font-style: normal; color: var(--silver-700); }
.wordmark { display: inline-flex; align-items: center; }
.brand-mark { width: 22px; height: 22px; margin-right: 10px; flex: none; }
.topbar .spacer { flex: 1; }
.chip {
  display: inline-flex; align-items: center; gap: 8px; height: 36px; padding: 0 14px; border-radius: 999px; cursor: pointer;
  background: var(--brushed), linear-gradient(180deg, #343437, #232326); border: 1px solid var(--line); color: var(--silver-100);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.08), 0 1px 2px rgba(0,0,0,.5); transition: transform .12s ease, filter .15s ease;
}
.chip:hover { filter: brightness(1.12); } .chip:active { transform: scale(.97); }
.chip svg { width: 17px; height: 17px; }
.chip[aria-pressed="true"] { background: linear-gradient(180deg, #e9e9ee, #bdbdc4); color: #111; border-color: transparent; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--silver-700); display: inline-block; }
.dot.on { background: var(--ok); box-shadow: 0 0 10px rgba(143,227,173,.6); }

/* stage: the picture is the app */
.stage-area { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 0; gap: 14px; }
#stage-slot {
  position: relative; max-width: min(100%, calc((100vh - 250px) * 16 / 9)); width: 100%; aspect-ratio: 16 / 9; border-radius: 22px; overflow: hidden;
  background: #000; border: 1px solid var(--line-strong);
  box-shadow: 0 0 0 1px rgba(0,0,0,.8), 0 30px 80px rgba(0,0,0,.6), inset 0 0 60px rgba(0,0,0,.35);
}
#stage-slot::after { content: ""; position: absolute; inset: 0; pointer-events: none; background-image: var(--grain); opacity: .035; mix-blend-mode: screen; }
#stage-slot #canvas-wrap { position: absolute; inset: 0; width: 100%; height: 100%; }
#stage-slot #out { width: 100%; height: 100%; object-fit: contain; display: block; border-radius: 0; box-shadow: none; }
body.simple #stage-slot #overlay { display: none; }
.caption { min-height: 24px; color: var(--silver-500); font-size: 14px; display: flex; align-items: center; gap: 10px; }
.caption b { color: var(--silver-100); font-weight: 600; }
.caption .rec-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--rec); box-shadow: 0 0 12px var(--rec); animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .35; } }
.empty {
  position: absolute; inset: 0; display: none; flex-direction: column; gap: 14px; align-items: center; justify-content: center; text-align: center; padding: 24px;
  background: radial-gradient(600px 300px at 50% 40%, rgba(255,255,255,.05), transparent 70%), rgba(0,0,0,.55); z-index: 3;
}
.empty.show { display: flex; } .empty h2 { font-size: 26px; } .empty p { margin: 0; color: var(--silver-500); max-width: 38ch; }

/* dock: the only always-visible controls */
.dock {
  justify-self: center; display: flex; align-items: center; gap: 6px; padding: 10px 14px; border-radius: 28px;
  background: var(--panel-bg); border: 1px solid var(--line); box-shadow: var(--panel-edge); position: relative;
}
.dock::after { content: ""; position: absolute; inset: 0; border-radius: inherit; background-image: var(--grain); opacity: .05; mix-blend-mode: overlay; pointer-events: none; }
.dock .sep { width: 1px; height: 38px; background: var(--line); margin: 0 6px; }
.tool { display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 66px; padding: 6px 8px; border: 0; background: none; cursor: pointer; border-radius: 14px; color: var(--silver-300); }
.tool .ico { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; background: linear-gradient(180deg, #3b3b3f, #28282b); box-shadow: inset 0 1px 0 rgba(255,255,255,.12), 0 1px 3px rgba(0,0,0,.6); transition: transform .12s ease, background .2s ease; }
.tool:hover .ico { filter: brightness(1.15); } .tool:active .ico { transform: scale(.94); }
.tool svg { width: 21px; height: 21px; stroke: currentColor; }
.tool small { font-size: 11.5px; color: var(--silver-500); letter-spacing: .01em; }
.tool[aria-pressed="true"] .ico { background: linear-gradient(180deg, #ededf1, #c3c3ca); color: #111; }
.tool.off .ico { background: linear-gradient(180deg, #4a2a2c, #341c1e); color: #ffb3ae; }
.tool.record .ico { width: 60px; height: 60px; background: linear-gradient(180deg, #f2f2f5, #c9c9d0); }
.tool.record .ico::before { content: ""; width: 24px; height: 24px; border-radius: 50%; background: var(--rec); transition: all .18s ease; box-shadow: 0 0 0 0 rgba(255,69,58,.4); }
.tool.record.on .ico::before { border-radius: 7px; width: 22px; height: 22px; box-shadow: 0 0 0 6px rgba(255,69,58,.22); }
.tool.live .ico { width: 60px; height: 60px; font-weight: 700; font-size: 12px; letter-spacing: .04em; }
.tool.live.on .ico { background: linear-gradient(180deg, #fff, #d9d9de); color: #000; box-shadow: 0 0 0 5px rgba(255,255,255,.14), 0 0 28px rgba(255,255,255,.35); }
.meter-ring { position: absolute; inset: -3px; border-radius: 50%; border: 2px solid transparent; }

/* ───────── sheets (modal panels) ───────── */
dialog.sheet {
  width: min(560px, 94vw); max-height: min(86vh, 760px); padding: 0; border: 1px solid var(--line-strong); border-radius: 26px; color: var(--silver-100);
  background: var(--panel-bg); box-shadow: var(--panel-edge), 0 40px 120px rgba(0,0,0,.7); overflow: hidden;
}
dialog.sheet::backdrop { background: rgba(0,0,0,.55); backdrop-filter: blur(14px) saturate(.8); }
dialog.sheet[open] { animation: rise .22s cubic-bezier(.2,.8,.2,1); } @keyframes rise { from { transform: translateY(14px) scale(.985); opacity: 0; } }
.sheet-head { display: flex; align-items: center; gap: 10px; padding: 18px 20px 12px; }
.sheet-head h2 { font-size: 20px; flex: 1; }
.sheet-body { padding: 4px 20px 22px; overflow: auto; max-height: calc(min(86vh, 760px) - 70px); }
.x { width: 32px; height: 32px; border-radius: 50%; border: 0; cursor: pointer; background: rgba(255,255,255,.1); color: var(--silver-300); font-size: 16px; line-height: 1; }
.x:hover { background: rgba(255,255,255,.18); }
.group { background: rgba(0,0,0,.28); border: 1px solid var(--line); border-radius: var(--radius); margin: 10px 0; overflow: hidden; }
.group > .row, .row-item { display: flex; align-items: center; gap: 12px; padding: 13px 16px; min-height: 52px; border-top: 1px solid var(--line); }
.group > .row:first-child, .group > .row-item:first-child { border-top: 0; }
.row-item { cursor: pointer; width: 100%; background: none; border-left: 0; border-right: 0; border-bottom: 0; text-align: left; }
.row-item:hover { background: rgba(255,255,255,.04); }
.row-item .t { flex: 1; } .row-item .t b { display: block; font-weight: 600; } .row-item .t span { color: var(--silver-500); font-size: 13px; }
.row-item .chev { color: var(--silver-700); }
.ico-sq { width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; background: linear-gradient(180deg, #4a4a4f, #333337); flex: none; }
.ico-sq svg { width: 19px; height: 19px; stroke: var(--silver-100); }
.muted { color: var(--silver-500); } .small { font-size: 13px; }
.status { font-size: 12.5px; padding: 3px 10px; border-radius: 999px; background: rgba(255,255,255,.08); color: var(--silver-300); }
.status.ok { color: #0c2b18; background: var(--ok); } .status.busy { color: #2f2300; background: var(--warn); }

.btn { height: 40px; padding: 0 18px; border-radius: 12px; border: 1px solid var(--line-strong); cursor: pointer; font-weight: 600;
  background: var(--brushed), linear-gradient(180deg, #3d3d41, #2a2a2d); box-shadow: inset 0 1px 0 rgba(255,255,255,.1); }
.btn:hover { filter: brightness(1.12); } .btn:disabled { opacity: .45; cursor: default; }
.btn.primary { background: linear-gradient(180deg, #f6f6f9, #c9c9d0); color: #0b0b0c; border-color: transparent; }
.btn.quiet { background: transparent; border-color: var(--line); font-weight: 500; }
.seg { display: inline-flex; padding: 3px; border-radius: 12px; background: rgba(0,0,0,.4); border: 1px solid var(--line); gap: 2px; flex-wrap: wrap; }
.seg button { border: 0; height: 34px; padding: 0 16px; border-radius: 9px; cursor: pointer; background: none; color: var(--silver-300); font-weight: 500; }
.seg button[aria-pressed="true"] { background: linear-gradient(180deg, #ededf1, #c3c3ca); color: #0b0b0c; font-weight: 600; box-shadow: 0 1px 2px rgba(0,0,0,.5); }
input[type=text], input[type=password], input[type=url], select {
  width: 100%; height: 42px; padding: 0 14px; border-radius: 12px; border: 1px solid var(--line); background: rgba(0,0,0,.38); color: var(--silver-100); font: inherit;
}
input[type=range] { width: 100%; accent-color: var(--silver-100); }
input[type=checkbox] { accent-color: var(--silver-100); width: 18px; height: 18px; }
label.field { display: block; margin: 12px 0 6px; color: var(--silver-500); font-size: 13px; }
.switch { appearance: none; width: 46px; height: 28px; border-radius: 999px; background: #3a3a3d; position: relative; cursor: pointer; border: 0; transition: background .2s; flex: none; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: transform .2s; box-shadow: 0 1px 3px rgba(0,0,0,.5); }
.switch:checked { background: #d9d9de; } .switch:checked::after { transform: translateX(18px); background: #111; }
/* the general checkbox rule above (18 px) outranks .switch, which squashed every switch and let its knob stick out */
input[type="checkbox"].switch { width: 46px; height: 28px; }

/* camera / device cards in the Connect hub */
.device { display: flex; align-items: center; gap: 14px; padding: 12px 14px; border-top: 1px solid var(--line); }
.device:first-child { border-top: 0; }
.device .meta { flex: 1; min-width: 0; } .device .meta b { display: block; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } .device .meta span { color: var(--silver-500); font-size: 13px; }
.qr { width: 188px; height: 188px; border-radius: 16px; background: #fff; padding: 10px; flex: none; }
.how { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 14px; color: var(--silver-300); }
.how b { color: var(--silver-100); width: 22px; height: 22px; display: grid; place-items: center; border-radius: 50%; background: rgba(255,255,255,.12); font-size: 12px; }
.sd-toast { position: fixed; z-index: 50; right: 22px; bottom: 22px; background: var(--panel-bg); border: 1px solid var(--line-strong); border-radius: 18px; padding: 14px 16px; box-shadow: var(--panel-edge); max-width: 380px; }

/* ───────── the old editor, shown only under “Edit” ───────── */
body.simple #legacy { display: none; }
body:not(.simple) #shell { display: none; }
body:not(.simple) { overflow: hidden; }
#legacy { position: absolute; inset: 0; z-index: 2; display: grid; grid-template-columns: 210px 1fr 300px; background: transparent; }
#legacy .edit-close { position: absolute; top: 10px; right: 320px; z-index: 5; }
body:not(.simple) #scenes, body:not(.simple) #inspector { background: var(--panel-bg); border-color: var(--line); }
body:not(.simple) #toolbar { background: transparent; border-bottom: 1px solid var(--line); }
body:not(.simple) #toolbar button, body:not(.simple) #devices button, body:not(.simple) .panel-head button { background: var(--brushed), linear-gradient(180deg, #3d3d41, #2a2a2d); border: 1px solid var(--line-strong); color: var(--silver-100); border-radius: 10px; }
body:not(.simple) select, body:not(.simple) input[type=text], body:not(.simple) input[type=number], body:not(.simple) input[type=password] { background: rgba(0,0,0,.4); border: 1px solid var(--line); color: var(--silver-100); border-radius: 10px; }
body:not(.simple) #stage { background: transparent; }
body:not(.simple) #btn-record.on, body:not(.simple) #btn-live.on { background: linear-gradient(180deg, #f6f6f9, #c9c9d0); color: #0b0b0c; }

/* legacy dialogs share the sheet look */
dialog:not(.sheet) { background: var(--panel-bg); color: var(--silver-100); border: 1px solid var(--line-strong); border-radius: 22px; padding: 20px; box-shadow: var(--panel-edge); }
dialog:not(.sheet)::backdrop { background: rgba(0,0,0,.55); backdrop-filter: blur(12px); }

@media (max-width: 760px) {
  #shell { padding: 10px 12px 14px; }
  .tool { min-width: 54px; } .tool small { display: none; } .dock { gap: 2px; padding: 8px 10px; }
  #stage-slot { max-width: 100%; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* panels opened from Settings (Go live, Recordings, Voice, Games & apps, Remote, Health check) */
#sd-dialog .sheet-head .x#sd-back { order: -1; font-size: 22px; line-height: 1; }
#sd-dialog h3 { font-size: 12px; letter-spacing: .09em; text-transform: uppercase; color: var(--silver-500); margin: 20px 2px 8px; font-weight: 600; }
#sd-dialog .row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 4px 0; border: 0; min-height: 0; }
#sd-dialog .box { background: rgba(0,0,0,.28); border: 1px solid var(--line); border-radius: 16px; padding: 12px 14px; margin: 10px 0; }
#sd-dialog .note, #sd-dialog .msg { color: var(--silver-500); font-size: 13px; margin: 6px 2px; }
#sd-dialog .ok { color: var(--ok); } #sd-dialog .warn { color: var(--warn); } #sd-dialog .bad { color: #ff9f98; }
#sd-dialog .kv { display: grid; grid-template-columns: auto 1fr; gap: 5px 16px; font-size: 13.5px; margin: 8px 2px; }
#sd-dialog .kv b { color: var(--silver-500); font-weight: 500; }
#sd-dialog label { display: block; margin: 12px 2px 6px; color: var(--silver-500); font-size: 13px; }
#sd-dialog label.row { display: flex; align-items: center; color: var(--silver-100); font-size: 14px; }
#sd-dialog button.act { height: 38px; padding: 0 16px; border-radius: 12px; border: 1px solid var(--line-strong); cursor: pointer; font-weight: 600; background: var(--brushed), linear-gradient(180deg, #3d3d41, #2a2a2d); color: var(--silver-100); box-shadow: inset 0 1px 0 rgba(255,255,255,.1); margin: 2px 6px 2px 0; }
#sd-dialog button.act:hover { filter: brightness(1.12); } #sd-dialog button.act:disabled { opacity: .45; }
#sd-dialog button.act.pri { background: linear-gradient(180deg, #f6f6f9, #c9c9d0); color: #0b0b0c; border-color: transparent; }
#sd-dialog pre { white-space: pre-wrap; max-height: 260px; overflow: auto; background: rgba(0,0,0,.5); padding: 10px; border-radius: 12px; font-size: 11.5px; color: var(--silver-300); }
#sd-dialog code { background: rgba(0,0,0,.4); padding: 2px 6px; border-radius: 6px; font-size: 12.5px; word-break: break-all; }
#sd-dialog img { border-radius: 14px; background: #fff; padding: 6px; }
/* Go live: the two modes */
#sd-dialog .modes { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px; margin: 8px 0 4px; }
#sd-dialog .mode { text-align: left; font: inherit; color: var(--silver-100); cursor: pointer; background: rgba(0,0,0,.28); border: 1px solid var(--line); border-radius: 16px; padding: 12px 14px; }
#sd-dialog .mode b { display: block; font-size: 15px; margin-bottom: 4px; }
#sd-dialog .mode span { display: block; color: var(--silver-500); font-size: 12.5px; line-height: 1.4; }
#sd-dialog .mode.sel { border-color: var(--silver-300); background: linear-gradient(180deg, rgba(255,255,255,.08), rgba(255,255,255,.02)); box-shadow: inset 0 1px 0 rgba(255,255,255,.12); }
#sd-dialog .mode:disabled { opacity: .45; cursor: default; }
.sd-toast b { display: block; margin-bottom: 4px; }
.sd-toast button { height: 34px; padding: 0 14px; border-radius: 10px; border: 1px solid var(--line-strong); cursor: pointer; background: linear-gradient(180deg, #3d3d41, #2a2a2d); color: var(--silver-100); margin: 4px 6px 0 0; }
.sd-actions { display: flex; flex-wrap: wrap; }

/* layout overrides for the legacy stylesheet */
body { display: block !important; grid-template-columns: none !important; }
#legacy { grid-template-columns: 220px minmax(0, 1fr) 320px; }
/* the Connect hub replaces these two shortcuts (kept in the DOM for the control API) */
#btn-iriun, #btn-camo { display: none !important; }

/* legacy button classes must not leak into the new shell */
#shell button.tool, #shell button.chip { background: none; border: 0; animation: none !important; }
#shell button.chip { background: var(--brushed), linear-gradient(180deg, #343437, #232326); border: 1px solid var(--line); }
#shell button.chip[aria-pressed="true"] { background: linear-gradient(180deg, #e9e9ee, #bdbdc4); }
#shell button.tool:hover { border: 0; }
#shell .tool.record, #shell .tool.live { color: var(--silver-300); }
dialog.sheet button.btn, dialog.sheet button.chip { animation: none !important; }
dialog.sheet button.btn.primary { background: linear-gradient(180deg, #f6f6f9, #c9c9d0); color: #0b0b0c; }

.btn, .chip, .seg button, .tool small { white-space: nowrap; /* btn */ }
.group > .row > .t { min-width: 0; }

/* polish pass */
.switch { padding: 0 !important; border: 0 !important; margin: 0; min-width: 46px; background: #4a4a4e; }
.switch:checked { background: #e4e4e9; }
.seg { flex-wrap: nowrap; }
.group > .row { flex-wrap: wrap; row-gap: 8px; }
.group > .row > .t { flex: 1 1 170px; }
.group > .row-item, .row-item { border: 0; border-top: 1px solid var(--line); border-radius: 0; background: transparent; padding: 13px 16px; }
.group > .row-item:first-child { border-top: 0; }
.row-item:hover { background: rgba(255,255,255,.05); }
.row-item .chev { font-size: 20px; }
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, #a1a1a8 50%), linear-gradient(135deg, #a1a1a8 50%, transparent 50%); background-position: calc(100% - 20px) 18px, calc(100% - 14px) 18px; background-size: 6px 6px; background-repeat: no-repeat; padding-right: 34px; }
.sheet-body .group { box-shadow: inset 0 1px 0 rgba(255,255,255,.04); }

/* quiet by default: panels show options and buttons; the "?" button (help.js) brings the explanations back */
dialog.sheet:not(.help) :is(.note:not(label > .note), .row-item .muted, .t > .small.muted, .row-item .t > span, .how, .tnote) { display: none !important; }
.help-btn { font-size: 15px; font-weight: 700; }
.help-btn.on { background: var(--silver-100); color: #0b0b0c; }
.more { cursor: pointer; color: var(--silver-500); font-size: 13px; padding: 6px 0; }
#u-empty p { display: none; }
dialog.sheet:not(.help) .mode span { display: none; }
.hd { color: var(--silver-500); }
.tname { color: var(--silver-500); }
/* the editor shows the pictures and tools only; the numbers behind them (monitor strip) come with "?" */
#legacy .edit-help { position: absolute; top: 10px; right: 392px; z-index: 5; }
#legacy:not(.help) #monitor { display: none; }
#legacy.help .edit-help { background: var(--silver-100); color: #0b0b0c; }
body:not(.simple) #toolbar { padding-right: 150px; }
