/* Screencast Studio: dark, call-app style */
:root {
  --bg: #0d0f14; --panel: #151821; --panel2: #1c2030; --line: #262b3b; --ink: #eef0f6; --muted: #8d93a8;
  --accent: #6c8cff; --rec: #ff4d5e; --ok: #39d38b; --warn: #ffb547; --r: 14px;
  --top-h: 56px; --bar-h: 86px; --panel-w: 340px;
  font-family: 'Inter', system-ui, -apple-system, sans-serif; color: var(--ink); color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; background: var(--bg); overflow: hidden; }
body { font-size: 14px; -webkit-tap-highlight-color: transparent; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 1px solid var(--line); background: var(--panel2); border-radius: 10px; padding: 8px 13px; font-weight: 600; transition: background .15s, border-color .15s, transform .1s, opacity .15s; }
button:hover { border-color: #39405a; background: #232839; }
button:active { transform: scale(.97); }
button:disabled { opacity: .35; pointer-events: none; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.primary:hover { background: #5a7bff; }
button.big { padding: 13px 26px; font-size: 16px; border-radius: 14px; }
button.ghost { background: none; border-color: transparent; }
button.ghost:hover { background: var(--panel2); }
button.icon-only { padding: 7px 9px; }
button.small { padding: 5px 10px; font-size: 13px; }
button.wide { width: 100%; margin-top: 8px; }
button.danger { color: #ff8a95; }
button.magic { background: linear-gradient(120deg, #7b5cff, #ff5ca8); border: 0; color: #fff; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
a { color: #9db2ff; }
h2 { font-size: 17px; margin: 0; }
h3 { font-size: 11.5px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 20px 0 8px; }
.hint { color: var(--muted); font-size: 12.5px; line-height: 1.5; margin: 6px 0; }
[hidden] { display: none !important; }

/* ---------- top ---------- */
#top { height: calc(var(--top-h) + env(safe-area-inset-top, 0px)); padding: env(safe-area-inset-top, 0px) 14px 0; display: flex; align-items: center; gap: 10px; border-bottom: 1px solid var(--line); background: var(--panel); }
.brand { display: flex; align-items: center; gap: 10px; font-size: 15.5px; white-space: nowrap; }
.logo { width: 26px; height: 18px; border-radius: 5px; background: #2a2f3d; position: relative; box-shadow: inset 0 0 0 2px #3a4155; }
.logo::after { content: ''; position: absolute; width: 8px; height: 8px; border-radius: 50%; background: var(--rec); left: 9px; top: 5px; }
.status { font-size: 12.5px; color: var(--muted); padding: 5px 11px; border-radius: 99px; background: var(--panel2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.status.live { color: #fff; background: var(--rec); }
.status.paused { color: #1b1300; background: var(--warn); }
.spacer { flex: 1; }
.count { background: var(--accent); color: #fff; border-radius: 99px; font-size: 11px; padding: 1px 7px; margin-left: 4px; }
.mobile-only { display: none !important; }

/* ---------- main ---------- */
#app { height: calc(100% - var(--top-h) - var(--bar-h) - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px)); display: grid; grid-template-columns: 1fr var(--panel-w); }
#stageWrap { position: relative; min-width: 0; min-height: 0; padding: 18px; }
#stage { position: relative; width: 100%; height: 100%; border-radius: 18px; overflow: hidden; background: #07080b; box-shadow: inset 0 0 0 1px var(--line); }
#out { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; touch-action: none; }
body.recording #stage { box-shadow: inset 0 0 0 2px var(--rec); }
.hello { position: absolute; inset: 0; display: grid; place-items: center; padding: 20px; background: radial-gradient(ellipse at 50% 30%, #1a2034 0%, #07080b 70%); }
.hello-card { text-align: center; max-width: 380px; }
.hello-card h1 { font-size: 26px; margin: 18px 0 8px; letter-spacing: -.01em; }
.hello-card p { color: var(--muted); line-height: 1.5; margin: 0 0 18px; }
.hello-card .hint { margin-top: 14px; }
.hello-art { width: 120px; height: 78px; margin: 0 auto; border-radius: 12px; background: #1f2433; box-shadow: inset 0 0 0 3px #343b52; position: relative; }
.hello-art span { position: absolute; right: -14px; bottom: -14px; width: 46px; height: 46px; border-radius: 50%; background: linear-gradient(135deg, #ffb18a, #ff6f91); box-shadow: 0 0 0 3px #fff, 0 6px 18px rgba(0,0,0,.4); }
.hello-art::before { content: ''; position: absolute; left: 50%; top: 50%; width: 18px; height: 18px; margin: -9px; border-radius: 50%; background: var(--rec); box-shadow: 0 0 0 6px rgba(255,77,94,.25); }
.countdown { position: absolute; inset: 0; display: grid; place-items: center; font-size: 150px; font-weight: 800; color: #fff; background: rgba(0,0,0,.45); text-shadow: 0 10px 40px rgba(0,0,0,.5); }
.countdown.pop { animation: pop .9s ease-out; }
@keyframes pop { from { transform: scale(1.5); opacity: 0; } 30% { opacity: 1; } to { transform: scale(.9); opacity: .9; } }
.rec-badge { position: absolute; top: 14px; left: 14px; display: flex; align-items: center; gap: 8px; background: rgba(0,0,0,.6); backdrop-filter: blur(6px); padding: 7px 12px; border-radius: 99px; font-weight: 700; font-variant-numeric: tabular-nums; }
.rec-badge i { width: 10px; height: 10px; border-radius: 50%; background: var(--rec); animation: blink 1.2s infinite; }
.rec-badge.paused i { background: var(--warn); animation: none; }
.rec-badge small { color: var(--muted); font-weight: 500; }
@keyframes blink { 50% { opacity: .25; } }

/* ---------- panel ---------- */
#panel { background: var(--panel); border-left: 1px solid var(--line); overflow-y: auto; padding: 16px 16px 30px; overscroll-behavior: contain; }
.panel-head { display: flex; align-items: center; justify-content: space-between; }
.opts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.opts.four { grid-template-columns: repeat(4, 1fr); }
.opts.two { grid-template-columns: 1fr 1fr; }
.opts.three { grid-template-columns: repeat(3, 1fr); }
.opts.stack { grid-template-columns: 1fr; }
.opt { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 8px 9px; text-align: left; min-width: 0; }
.opts.four .opt, .opts.three .opt, .opts.two .opt { align-items: center; text-align: center; }
.opt b { font-size: 13px; } .opt small { color: var(--muted); font-size: 11px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.opts.stack .opt small { white-space: normal; }
.opt.on { background: rgba(108,140,255,.16); border-color: var(--accent); }
.opt.on small { color: #b9c6ff; }
.opt small.size { color: #c9d3ff; font-weight: 700; font-size: 11.5px; }
.opt.on small.size { color: #fff; }
.opts:not(.stack) .opt { align-items: center; text-align: center; }
.estimate { margin-top: 12px; padding: 12px 14px; border-radius: 12px; background: linear-gradient(135deg, rgba(108,140,255,.16), rgba(108,140,255,.05)); border: 1px solid rgba(108,140,255,.3); }
.est-big { font-size: 15px; } .est-big b { font-size: 22px; }
.est-row { font-size: 12.5px; margin-top: 4px; } .est-row.muted { color: var(--muted); font-size: 11.5px; }
.matrix-wrap { margin-top: 10px; } .matrix-wrap summary, details summary { cursor: pointer; color: #9db2ff; font-size: 12.5px; font-weight: 600; margin: 6px 0; }
.tscroll { overflow-x: auto; }
.matrix { border-collapse: collapse; width: 100%; font-size: 11.5px; font-variant-numeric: tabular-nums; }
.matrix th, .matrix td { padding: 5px 4px; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; }
.matrix th:first-child { text-align: left; } .matrix th small { color: var(--muted); font-weight: 400; }
.matrix td.on { background: rgba(108,140,255,.25); color: #fff; font-weight: 700; border-radius: 6px; }
.field { display: grid; gap: 5px; margin: 10px 0; font-size: 12.5px; color: var(--muted); font-weight: 600; }
select, input[type=text], input[type=password], input[type=number], textarea { width: 100%; padding: 8px 10px; border-radius: 10px; border: 1px solid var(--line); background: #0f1219; color: var(--ink); font-weight: 400; font-size: 13.5px; }
textarea { resize: vertical; }
.check { display: flex; gap: 9px; align-items: flex-start; margin: 10px 0; font-size: 13px; line-height: 1.4; cursor: pointer; }
.check input { margin-top: 2px; accent-color: var(--accent); width: 16px; height: 16px; flex: none; }
.check.tight { margin-top: 30px; }
.row-label { font-size: 12px; color: var(--muted); font-weight: 600; margin: 10px 0 6px; }
.meter { height: 5px; border-radius: 9px; background: #0f1219; overflow: hidden; margin-top: -2px; }
.meter i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--ok), #c5f04a, var(--warn)); transition: width .08s; }
#camSettings.dim { opacity: .45; }
.opts.frames { grid-template-columns: repeat(5, 1fr); margin-bottom: 6px; } .opts.frames .opt { padding: 7px 3px; } .opts.frames .opt b { font-size: 11.5px; }
.opt .shape { display: block; border: 2px solid currentColor; border-radius: 3px; opacity: .7; margin-bottom: 3px; }
.minimap { position: relative; margin-top: 10px; border-radius: 10px; overflow: hidden; background: #07080b; border: 1px solid var(--line); touch-action: none; }
.minimap canvas { display: block; width: 100%; height: auto; cursor: grab; }
.minimap span { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); font-size: 12px; pointer-events: none; }
.slider { display: grid; grid-template-columns: 60px 1fr 42px; align-items: center; gap: 8px; margin: 10px 0 4px; font-size: 12.5px; color: var(--muted); font-weight: 600; }
.slider input { accent-color: var(--accent); width: 100%; } .slider output { text-align: right; font-variant-numeric: tabular-nums; }
.row2 { display: flex; gap: 8px; } .row2 button { flex: 1; }

/* ---------- control bar ---------- */
#bar { height: calc(var(--bar-h) + env(safe-area-inset-bottom, 0px)); padding: 0 12px env(safe-area-inset-bottom, 0px); display: flex; align-items: center; justify-content: center; gap: 12px; border-top: 1px solid var(--line); background: var(--panel); }
.round { width: 64px; height: 64px; border-radius: 50%; padding: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; background: var(--panel2); position: relative; }
.round span { font-size: 10px; font-weight: 600; color: var(--muted); }
.round.on { background: #2a3350; border-color: #4a5a90; } .round.on span { color: #c9d3ff; }
.round.off { background: #3a1f25; border-color: #5a2b33; color: #ffb3bb; }
#micBtn.on { box-shadow: 0 0 0 calc(var(--lvl, 0) * 7px) rgba(57,211,139,.35); }
.round.rec { width: 76px; height: 76px; background: #fff; border: 0; }
.round.rec i { width: 30px; height: 30px; border-radius: 50%; background: var(--rec); transition: transform .15s; }
.round.rec span { color: #333; }
.round.rec:hover i { transform: scale(1.1); }
.round.stop:not(:disabled) { background: var(--rec); border-color: var(--rec); color: #fff; } .round.stop:not(:disabled) span { color: #fff; }

/* ---------- drawer & modal ---------- */
.drawer, .modal { position: fixed; inset: 0; background: rgba(5,6,10,.6); z-index: 20; display: flex; justify-content: flex-end; }
.modal { justify-content: center; align-items: center; padding: 16px; z-index: 25; }
.drawer-card { width: min(520px, 100%); height: 100%; background: var(--panel); border-left: 1px solid var(--line); padding: calc(16px + env(safe-area-inset-top, 0px)) 18px 30px; overflow-y: auto; }
.drawer-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 4px; }
.rec-card { margin-top: 16px; padding: 12px; border-radius: var(--r); background: var(--panel2); border: 1px solid var(--line); }
.rec-card video, .nresult video { width: 100%; border-radius: 10px; background: #000; display: block; max-height: 300px; }
.rec-meta { margin: 10px 2px 4px; font-size: 12.5px; color: var(--muted); } .rec-meta b { color: var(--ink); }
.rec-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.empty { color: var(--muted); text-align: center; padding: 40px 0; }
.sheet { width: min(640px, 100%); max-height: calc(100% - 16px); overflow-y: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 20px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.step-row { margin: 14px 0 6px; }
.nstatus { font-size: 13px; color: var(--muted); min-height: 1.2em; margin: 6px 0; }
.nstatus.ok { color: var(--ok); } .nstatus.err { color: #ff8a95; } .nstatus.warn { color: var(--warn); }
.script { margin-top: 10px; }
.script-head { display: flex; flex-direction: column; gap: 2px; margin: 14px 0 8px; } .script-head small { color: var(--muted); }
.line { display: grid; grid-template-columns: 66px 1fr auto; gap: 8px; align-items: start; margin-bottom: 8px; }
.line input { padding: 8px 6px; text-align: center; }
.line-info { margin: -4px 0 10px 74px; font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; } .line-info.bad { color: var(--warn); }
.line-warn { display: flex; gap: 8px; align-items: center; justify-content: space-between; margin: -2px 0 10px 74px; padding: 8px 10px; border-radius: 10px; background: rgba(255,181,71,.1); color: var(--warn); font-size: 12.5px; }
progress { width: 100%; height: 8px; accent-color: var(--accent); margin-top: 8px; }
.toast { position: fixed; left: 50%; top: calc(var(--top-h) + 14px + env(safe-area-inset-top, 0px)); transform: translateX(-50%); background: #fff; color: #111; padding: 10px 16px; border-radius: 12px; z-index: 40; font-weight: 600; box-shadow: 0 10px 30px rgba(0,0,0,.4); max-width: calc(100% - 32px); text-align: center; }
#camVid { position: fixed; left: -9999px; top: 0; width: 160px; height: 90px; }

/* ---------- narrow ---------- */
@media (max-width: 900px) {
  #app { grid-template-columns: 1fr; }
  #panel { position: fixed; z-index: 15; right: 0; top: calc(var(--top-h) + env(safe-area-inset-top, 0px)); bottom: calc(var(--bar-h) + env(safe-area-inset-bottom, 0px)); width: min(380px, 100%); transform: translateX(100%); transition: transform .25s; box-shadow: -20px 0 40px rgba(0,0,0,.4); }
  body.show-panel #panel { transform: none; }
  .mobile-only { display: inline-flex !important; }
  #stageWrap { padding: 10px; }
}
@media (max-width: 560px) {
  :root { --bar-h: 76px; }
  .brand b { display: none; }
  #bar { gap: 6px; }
  .round { width: 54px; height: 54px; } .round.rec { width: 64px; height: 64px; }
  .round svg { width: 19px; height: 19px; }
  .countdown { font-size: 100px; }
  .grid2 { grid-template-columns: 1fr; } .check.tight { margin-top: 0; }
}
