/* ---------- frame ---------- */
#app { min-height: 100dvh; display: flex; flex-direction: column; }
header.top {
  position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 10px;
  padding: calc(8px + env(safe-area-inset-top)) 14px 8px; background: rgba(11,13,18,.94); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
header .logo { font-size: 18px; }
header .status { font-size: 13px; }
.rec-pill { min-height: 34px; padding: 0 12px; border-radius: 999px; background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 700; font-variant-numeric: tabular-nums; }
.rec-pill .dot { background: #fff; }

/* ---------- monitor (previews) ---------- */
.monitor { padding: 10px 14px; background: var(--bg); }
.previews { display: grid; grid-template-columns: 16fr 5.0625fr; gap: 8px; align-items: start; }
.pv { position: relative; background: #000; border-radius: 12px; overflow: hidden; border: 1px solid var(--line); }
.pv-land { aspect-ratio: 16 / 9; }
.pv-port { aspect-ratio: 9 / 16; }
.pv video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.pv-tag { position: absolute; left: 6px; top: 6px; font-size: 10px; font-weight: 700; background: rgba(0,0,0,.6); padding: 2px 6px; border-radius: 6px; }
.monitor-bar { display: flex; align-items: center; gap: 8px; margin-top: 6px; font-size: 13px; }

/* phone / narrow: video pinned on top, options scroll below, tabs at the bottom */
@media (max-width: 899px) {
  .monitor { position: sticky; top: 51px; z-index: 20; border-bottom: 1px solid var(--line); }
  .previews { max-height: 30dvh; grid-template-columns: auto auto; justify-content: center; }
  .pv-land { height: min(30dvh, calc((100vw - 36px) * 0.76 * 9 / 16)); width: auto; }
  .pv-port { height: min(30dvh, calc((100vw - 36px) * 0.76 * 9 / 16)); width: auto; }
  .panel main { padding: 0 14px calc(90px + env(safe-area-inset-bottom)); }
  .tabbar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line);
  }
}

/* computer / tablet landscape: video on the left, options on the right */
@media (min-width: 900px) {
  #app { height: 100dvh; }
  .workspace { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(400px, 1fr); }
  .monitor { overflow: auto; padding: 18px; border-right: 1px solid var(--line); display: flex; flex-direction: column; justify-content: center; }
  .previews { gap: 12px; }
  .panel { display: flex; flex-direction: column; min-height: 0; }
  .tabbar { border-bottom: 1px solid var(--line); }
  .panel main { flex: 1; overflow: auto; padding: 0 18px 30px; }
}

.tabbar { display: grid; grid-template-columns: repeat(4, 1fr); background: rgba(16,19,26,.97); backdrop-filter: blur(12px); }
.tabbar button { flex-direction: column; gap: 2px; min-height: 54px; background: none; border: none; border-radius: 0; color: var(--muted); font-size: 12px; }
.tabbar button b { font-size: 18px; font-weight: 400; }
.tabbar button.active { color: var(--text); box-shadow: inset 0 -2px 0 var(--accent); }
.tabbar button.active b { color: var(--accent); }
@media (max-width: 899px) { .tabbar button.active { box-shadow: inset 0 2px 0 var(--accent); } }

/* ---------- live tab ---------- */
.layouts { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.layouts button { flex-direction: column; min-height: 74px; padding: 8px 4px; font-size: 11px; gap: 6px; white-space: normal; line-height: 1.1; }
.layouts svg { width: 44px; height: 26px; }
.layouts svg rect { fill: var(--muted); }
.layouts button.on svg rect { fill: var(--accent); }
.layouts svg rect.bgr { fill: #39425a; }
.layouts button.on svg rect.bgr { fill: #7a2c43; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.seg button { border: none; border-radius: 0; min-height: 38px; background: var(--panel-2); }
.seg button.on { background: var(--accent); color: #fff; }

.demo { position: relative; aspect-ratio: 16 / 9; width: 168px; flex: none; border-radius: 10px; overflow: hidden; background: #000; border: 1px solid var(--line); }
.demo .scene { position: absolute; inset: 0; display: grid; place-items: center; font: 800 28px/1 Inter, system-ui, sans-serif; color: #fff; }
.demo .a { background: linear-gradient(135deg, #3d8bff, #1b2a4a); }
.demo .b { background: linear-gradient(135deg, #ff3d6e, #4a1b2a); }

.record-row { display: grid; grid-template-columns: 1fr auto auto; gap: 8px; }
.record-btn { min-height: 56px; font-size: 17px; }
.record-btn.stop { background: #fff; color: #111; border-color: #fff; }

.player { display: grid; gap: 10px; }
.player .now { display: flex; gap: 10px; align-items: center; }
.player .now img, .player .now .icon { width: 56px; height: 56px; border-radius: 10px; object-fit: cover; background: var(--panel-2); display: grid; place-items: center; font-size: 24px; flex: none; }

/* ---------- library ---------- */
.crumbs { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; font-size: 14px; margin: 14px 0 10px; }
.crumbs button { min-height: 32px; padding: 0 8px; background: none; border: none; color: var(--muted); }
.crumbs button:last-child { color: var(--text); font-weight: 600; }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; }
.files { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 10px; margin-top: 12px; }
.file {
  position: relative; display: flex; flex-direction: column; align-items: stretch; gap: 6px; padding: 6px; min-height: 0;
  border-radius: 12px; background: var(--panel); border: 1px solid var(--line); text-align: left; white-space: normal;
}
.file .art { position: relative; aspect-ratio: 4 / 3; border-radius: 8px; overflow: hidden; background: var(--panel-2); display: grid; place-items: center; font-size: 34px; }
.file .art img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.file .name { font-size: 12px; line-height: 1.25; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; word-break: break-word; }
.file .badge { position: absolute; left: 5px; bottom: 5px; font-size: 10px; font-weight: 700; background: rgba(0,0,0,.7); padding: 2px 6px; border-radius: 6px; }
.file .onair { position: absolute; right: 5px; top: 5px; background: var(--accent); font-size: 9px; font-weight: 800; padding: 2px 6px; border-radius: 6px; }
.file.folder .art { background: none; font-size: 54px; }
.file.selected { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, var(--panel)); }
.file .check { position: absolute; right: 10px; top: 10px; width: 24px; height: 24px; border-radius: 50%; border: 2px solid #fff; background: rgba(0,0,0,.5); z-index: 2; }
.file.selected .check { background: var(--accent); border-color: var(--accent); }
.file.selected .check::after { content: '✓'; color: #fff; font-size: 14px; display: grid; place-items: center; height: 100%; }
.file .bar { position: absolute; left: 8px; right: 8px; bottom: 8px; height: 5px; border-radius: 3px; background: rgba(255,255,255,.2); overflow: hidden; }
.file .bar i { display: block; height: 100%; background: var(--accent); }
.file.failed .art { outline: 2px solid var(--accent); }
.selbar { position: sticky; bottom: 8px; display: flex; gap: 8px; align-items: center; margin-top: 12px; padding: 10px; border-radius: 14px; background: var(--panel-2); border: 1px solid var(--accent); }

/* ---------- graphics & people ---------- */
.person { display: grid; gap: 10px; }
.person .head { display: flex; gap: 10px; align-items: center; }
.person .avatar { width: 44px; height: 44px; border-radius: 50%; background: var(--panel-2) center/cover; display: grid; place-items: center; font-weight: 700; flex: none; }
.person .sub-card { display: grid; gap: 8px; padding: 10px; border-radius: 12px; background: var(--panel-2); }
.person.offline { opacity: .55; }
.kv { display: grid; grid-template-columns: 92px 1fr; gap: 6px 10px; align-items: center; }
.pad { position: relative; width: 100%; aspect-ratio: 16 / 9; border-radius: 10px; overflow: hidden; background: #000 center/contain no-repeat; touch-action: none; cursor: grab; }
.pad .crop { position: absolute; border: 2px solid #fff; box-shadow: 0 0 0 9999px rgba(0,0,0,.55); border-radius: 4px; pointer-events: none; }
.pad .hint { position: absolute; left: 8px; bottom: 6px; font-size: 11px; color: #fff; text-shadow: 0 1px 2px #000; pointer-events: none; }
.invite { display: grid; gap: 8px; }
.invite code { display: block; padding: 10px; border-radius: 10px; background: var(--panel-2); font-size: 12px; word-break: break-all; }
.empty { text-align: center; padding: 22px; color: var(--muted); border: 1px dashed var(--line); border-radius: var(--radius); }
.help { font-size: 13px; color: var(--muted); margin: 6px 2px; }
