:root {
  --bg: #f2f2f7;
  --card: rgba(255, 255, 255, 0.82);
  --solid: #ffffff;
  --text: #1c1c1e;
  --muted: #6e6e73;
  --line: rgba(60, 60, 67, 0.14);
  --accent: #5e5ce6;
  --accent-2: #0a84ff;
  --hot: #ff375f;
  --good: #30d158;
  --warn: #ff9f0a;
  --grad: linear-gradient(120deg, #ff375f 0%, #bf5af2 38%, #5e5ce6 64%, #0a84ff 100%);
  --radius: 22px;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.06), 0 12px 32px rgba(0, 0, 0, 0.08);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Helvetica Neue", "Segoe UI", system-ui, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --card: rgba(28, 28, 30, 0.82);
    --solid: #1c1c1e;
    --text: #f5f5f7;
    --muted: #98989d;
    --line: rgba(235, 235, 245, 0.12);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.5), 0 16px 40px rgba(0, 0, 0, 0.5);
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font); -webkit-font-smoothing: antialiased; }
body { min-height: 100vh; }
[hidden] { display: none !important; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
svg { width: 22px; height: 22px; flex: none; }
h1 { font-size: clamp(34px, 6vw, 52px); font-weight: 800; letter-spacing: -0.03em; margin: 0; line-height: 1.05; }
h2 { font-size: 24px; font-weight: 700; letter-spacing: -0.02em; margin: 0; }
h3 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin: 0 0 10px; font-weight: 600; }
.eyebrow { margin: 0 0 4px; font-size: 13px; font-weight: 600; color: var(--muted); letter-spacing: 0.02em; }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background: radial-gradient(1200px 600px at 10% -10%, rgba(255, 55, 95, 0.35), transparent 60%),
              radial-gradient(900px 600px at 110% 10%, rgba(10, 132, 255, 0.35), transparent 60%),
              radial-gradient(900px 700px at 50% 120%, rgba(191, 90, 242, 0.35), transparent 60%), var(--bg); }
.login-card { width: min(420px, 100%); background: var(--card); backdrop-filter: saturate(180%) blur(30px); -webkit-backdrop-filter: saturate(180%) blur(30px);
  border: 1px solid var(--line); border-radius: 30px; padding: 36px 28px 28px; box-shadow: var(--shadow); }
.login-card h1 { font-size: 38px; }
.sub { color: var(--muted); margin: 8px 0 26px; font-size: 17px; }
.brand-mark { width: 60px; height: 60px; border-radius: 18px; background: var(--grad); display: grid; place-items: center; color: #fff; margin-bottom: 18px; box-shadow: 0 10px 30px rgba(94, 92, 230, 0.45); }
.brand-mark svg { width: 32px; height: 32px; }
.brand-mark.big { width: 84px; height: 84px; border-radius: 24px; margin: 0 auto 20px; }
.brand-mark.big svg { width: 44px; height: 44px; }
form label { display: block; margin-bottom: 14px; }
label > span { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 6px; }
input[type=email], input[type=password], select {
  width: 100%; font: inherit; font-size: 17px; color: var(--text); background: var(--solid); border: 1px solid var(--line);
  border-radius: 12px; padding: 12px 14px; outline: none; transition: border-color .15s, box-shadow .15s; appearance: none; -webkit-appearance: none; }
select { background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 34px; }
input:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(94, 92, 230, 0.2); }
.err { color: var(--hot); min-height: 20px; margin: 12px 0 0; font-size: 15px; }

.btn { font: inherit; font-size: 16px; font-weight: 600; border: 0; border-radius: 14px; padding: 12px 18px; cursor: pointer; display: inline-flex; align-items: center; gap: 8px;
  justify-content: center; background: var(--solid); color: var(--text); border: 1px solid var(--line); transition: transform .12s ease, box-shadow .2s, background .2s; }
.btn:hover { box-shadow: 0 6px 18px rgba(0, 0, 0, 0.1); }
.btn:active { transform: scale(0.97); }
.btn:focus-visible, .icon-btn:focus-visible, .tile:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.btn.primary { background: var(--grad); color: #fff; border: 0; box-shadow: 0 10px 24px rgba(94, 92, 230, 0.35); }
.btn.wide { width: 100%; padding: 14px; font-size: 17px; margin-top: 6px; }
.btn.on { background: var(--hot); color: #fff; border-color: transparent; }
.icon-btn { width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--line); background: var(--card); color: var(--text); display: grid; place-items: center; cursor: pointer;
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); transition: transform .12s; }
.icon-btn:active { transform: scale(0.94); }
.icon-btn.on { background: var(--accent); color: #fff; border-color: transparent; }

/* console */
.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: flex-end; justify-content: space-between; gap: 16px;
  padding: calc(env(safe-area-inset-top) + 28px) clamp(16px, 4vw, 40px) 18px; background: linear-gradient(to bottom, var(--bg) 70%, transparent); }
.top h1 { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
main { padding: 0 clamp(16px, 4vw, 40px) 60px; }
.empty { text-align: center; padding: 12vh 20px; color: var(--muted); max-width: 460px; margin: 0 auto; }
.empty h2 { color: var(--text); margin-bottom: 8px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(360px, 100%), 1fr)); gap: 20px; }
.tile { position: relative; border-radius: var(--radius); overflow: hidden; background: #000; box-shadow: var(--shadow); cursor: pointer; aspect-ratio: 16 / 9;
  transition: transform .2s ease, box-shadow .2s; border: 0; padding: 0; color: #fff; text-align: left; }
.tile:hover { transform: translateY(-3px); box-shadow: 0 2px 4px rgba(0,0,0,.1), 0 22px 44px rgba(0,0,0,.18); }
.tile canvas, .video-wrap canvas { width: 100%; height: 100%; display: block; object-fit: contain; background: #000; }
.tile .meta { position: absolute; inset: auto 0 0 0; padding: 40px 16px 14px; background: linear-gradient(to top, rgba(0,0,0,.72), transparent); display: flex; align-items: flex-end; justify-content: space-between; gap: 10px; }
.tile .name { font-size: 19px; font-weight: 700; letter-spacing: -0.01em; }
.tile .info { font-size: 13px; opacity: .8; margin-top: 2px; }
.pill { font-size: 12px; font-weight: 700; border-radius: 999px; padding: 5px 10px; background: rgba(255,255,255,.18); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); display: inline-flex; gap: 5px; align-items: center; white-space: nowrap; }
.pill svg { width: 13px; height: 13px; }
.pill.good { background: rgba(48, 209, 88, .85); }
.pill.warn { background: rgba(255, 159, 10, .9); }
.pill.bad { background: rgba(255, 55, 95, .9); }
.tile .badges { position: absolute; top: 12px; left: 12px; right: 12px; display: flex; justify-content: space-between; }
.rec-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--hot); animation: blink 1.2s infinite; }
@keyframes blink { 50% { opacity: .25; } }

/* stage */
.stage { position: fixed; inset: 0; z-index: 20; background: var(--bg); display: grid; grid-template-columns: 1fr 380px; overflow: auto; }
.stage-video { padding: calc(env(safe-area-inset-top) + 20px) 24px 24px; display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.stage-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; }
.row { display: flex; gap: 10px; }
.video-wrap { position: relative; border-radius: var(--radius); overflow: hidden; background: #000; box-shadow: var(--shadow); cursor: crosshair; aspect-ratio: 16 / 9; width: 100%; }
#stage-canvas-slot { position: absolute; inset: 0; }
.af-mark { position: absolute; width: 64px; height: 64px; transform: translate(-50%, -50%); color: #ffd60a; pointer-events: none; animation: af .5s ease-out; }
.af-mark svg { width: 64px; height: 64px; }
@keyframes af { from { transform: translate(-50%, -50%) scale(1.5); opacity: 0; } }
.panel { background: var(--card); backdrop-filter: blur(30px); -webkit-backdrop-filter: blur(30px); border-left: 1px solid var(--line); padding: calc(env(safe-area-inset-top) + 24px) 22px 30px; display: flex; flex-direction: column; gap: 22px; }
.actions { display: grid; gap: 10px; }
.btn.shoot { background: var(--grad); color: #fff; border: 0; font-size: 17px; padding: 15px; }
.group { border-top: 1px solid var(--line); padding-top: 18px; }
.fields { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.fields label { margin: 0; }
.fields .slider { grid-column: 1 / -1; }
input[type=range] { width: 100%; accent-color: var(--accent); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips button { font: inherit; font-size: 14px; font-weight: 600; border-radius: 999px; padding: 8px 14px; border: 1px solid var(--line); background: var(--solid); color: var(--text); cursor: pointer; }
.chips button.on { background: var(--accent); color: #fff; border-color: transparent; }
.seg { display: grid; grid-template-columns: 1fr 1fr; background: var(--solid); border: 1px solid var(--line); border-radius: 12px; padding: 3px; }
.seg button { font: inherit; font-size: 15px; font-weight: 600; border: 0; background: transparent; color: var(--text); padding: 9px; border-radius: 9px; cursor: pointer; }
.seg button.on { background: var(--accent); color: #fff; }
.hint { color: var(--muted); font-size: 14px; display: flex; align-items: center; gap: 8px; margin: 0; }
.hint svg { width: 18px; height: 18px; }
.toast { position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 24px); transform: translateX(-50%); z-index: 40; background: var(--solid); color: var(--text);
  border: 1px solid var(--line); box-shadow: var(--shadow); padding: 12px 18px; border-radius: 14px; font-weight: 600; font-size: 15px; }
.toast.bad { background: var(--hot); color: #fff; border-color: transparent; }

@media (max-width: 900px) {
  .stage { grid-template-columns: 1fr; }
  .panel { border-left: 0; border-top: 1px solid var(--line); padding-top: 22px; }
  .stage-video { padding: calc(env(safe-area-inset-top) + 14px) 14px 0; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
