/* Shadebox simulator. Everything inside .panel is the device UI and is what
   gets ported to QML; the toolbar/bezel are simulator chrome. Tokens below are
   the design system to carry over (colors, sizes, radii). */
:root {
  --bg: #0b0d10;
  --panel: #14191f;
  --panel-2: #1b222a;
  --line: #27303a;
  --text: #e9eef3;
  --muted: #8b97a4;
  --dim: #5b6573;
  --accent: #4da3ff;
  --green: #2fd27a;
  --amber: #ffb020;
  --red: #ff4d55;
  --grey: #4a5360;
  --radius: 10px;
  --tap: 48px;           /* minimum touch target */
  --rail: 76px;
  --status: 36px;
  --font: -apple-system, "Inter", "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, monospace;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body {
  background: #2a2f36;
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
button { font: inherit; color: inherit; }

/* ---- simulator chrome ---- */
.sim-toolbar {
  display: flex; gap: 16px; align-items: center; flex-wrap: wrap;
  padding: 8px 16px; background: #1d2127; border-bottom: 1px solid #333a43;
  font-size: 13px; color: #c7cdd4;
}
.sim-toolbar select, .sim-toolbar button {
  background: #2b313a; color: #e6e9ed; border: 1px solid #3c444f; border-radius: 6px; padding: 3px 8px;
}
.sim-dev { display: inline-flex; gap: 6px; align-items: center; }
.sim-conn { margin-left: auto; }
.sim-conn.ok { color: var(--green); }
.sim-conn.bad { color: var(--red); }
.sim-stage { position: relative; height: calc(100% - 44px); overflow: hidden; }
.bezel {
  padding: var(--bezel, 9px); background: #050607; border-radius: 14px;
  box-shadow: 0 30px 80px rgba(0,0,0,.55), inset 0 0 0 2px #1a1d21;
  position: absolute; left: 50%; top: 50%;
  transform-origin: center center;
}

/* ---- device panel ---- */
.panel {
  position: relative; overflow: hidden;
  width: 800px; height: 480px;
  background: var(--bg);
  display: grid;
  grid-template-columns: var(--rail) 1fr;
  grid-template-rows: var(--status) 1fr;
  grid-template-areas: "status status" "rail content";
  user-select: none;
  font-size: 15px;
}
.panel.portrait {
  grid-template-columns: 1fr;
  grid-template-rows: var(--status) 1fr 64px;
  grid-template-areas: "status" "content" "rail";
}

.statusbar {
  grid-area: status; display: flex; align-items: center; justify-content: space-between;
  padding: 0 10px; background: #0f1317; border-bottom: 1px solid var(--line);
}
.sb-unit { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.role {
  display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 6px;
  background: var(--accent); color: #001428; font-weight: 800;
}
.sb-right { display: flex; align-items: center; gap: 6px; }
.pill {
  font-size: 12px; padding: 3px 8px; border-radius: 999px; background: var(--panel-2);
  color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums;
}
.pill.ok { color: var(--green); }
.pill.warn { color: var(--amber); }
.pill.bad { color: #fff; background: var(--red); }
.sb-clock { font-variant-numeric: tabular-nums; font-weight: 600; padding-left: 4px; }

.rail {
  grid-area: rail; display: flex; flex-direction: column;
  background: #0f1317; border-right: 1px solid var(--line);
}
.portrait .rail { flex-direction: row; border-right: 0; border-top: 1px solid var(--line); }
.rail button {
  flex: 1; border: 0; background: none; color: var(--muted);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  font-size: 11px; min-height: var(--tap); cursor: pointer;
}
.rail button i { font-style: normal; font-size: 20px; line-height: 1; }
.rail button.active { color: var(--text); background: var(--panel-2); box-shadow: inset 3px 0 0 var(--accent); }
.portrait .rail button.active { box-shadow: inset 0 3px 0 var(--accent); }

.content { grid-area: content; overflow-y: auto; padding: 10px; scrollbar-width: none; }
.content::-webkit-scrollbar { display: none; }

h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 4px 2px 8px; font-weight: 600; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.row { display: flex; gap: 10px; align-items: center; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); }
.ellipsis { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* buttons */
.btn {
  min-height: var(--tap); padding: 0 16px; border-radius: var(--radius);
  background: var(--panel-2); border: 1px solid var(--line); cursor: pointer; font-weight: 600;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.btn:active { filter: brightness(1.3); }
.btn.primary { background: var(--accent); color: #001428; border-color: transparent; }
.btn.danger { background: transparent; color: var(--red); border-color: var(--red); }
.btn.on { background: var(--amber); color: #2a1a00; border-color: transparent; }
.btn[disabled] { opacity: .4; pointer-events: none; }
.seg { display: flex; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.seg button { flex: 1; min-height: 40px; border: 0; background: var(--panel); color: var(--muted); cursor: pointer; padding: 0 10px; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button.active { background: var(--accent); color: #001428; font-weight: 700; }

/* ---- home ---- */
.cams { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px; }
.portrait .cams { grid-template-columns: 1fr; }
.cam { padding: 0; overflow: hidden; display: flex; flex-direction: column; cursor: pointer; }
.cam-head { padding: 10px 12px; display: flex; align-items: center; gap: 10px; color: #071018; }
.cam-head .letter { font-size: 34px; font-weight: 800; line-height: 1; }
.cam-head .name { font-weight: 700; font-size: 16px; }
.cam-head .state { font-size: 12px; font-weight: 600; opacity: .8; }
.c-green .cam-head { background: var(--green); }
.c-amber .cam-head { background: var(--amber); }
.c-red .cam-head { background: var(--red); color: #fff; }
.c-grey .cam-head { background: var(--grey); color: var(--text); }
.cam-body { padding: 10px 12px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.counts { display: grid; grid-template-columns: repeat(3, 1fr); text-align: center; }
.counts b { display: block; font-size: 26px; font-variant-numeric: tabular-nums; line-height: 1.1; }
.counts span { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.counts .err b { color: var(--red); }
.link { font-size: 12px; display: flex; align-items: center; gap: 6px; color: var(--muted); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--grey); flex: none; }
.dot.green { background: var(--green); } .dot.amber { background: var(--amber); }
.dot.red { background: var(--red); } .dot.blue { background: var(--accent); }
.last { font-size: 12px; }
.bars { display: inline-flex; align-items: flex-end; gap: 2px; height: 14px; }
.bars i { width: 4px; border-radius: 1px; background: var(--grey); display: block; }
.bars i.on { background: var(--green); }
.bar { height: 6px; border-radius: 3px; background: var(--panel-2); overflow: hidden; }
.bar > div { height: 100%; background: var(--accent); transition: width .5s linear; }
.summary { margin-top: 10px; display: flex; gap: 10px; align-items: center; }
.summary .card { flex: 1; display: flex; align-items: center; gap: 10px; min-height: 56px; }
.banner { padding: 8px 12px; border-radius: var(--radius); margin-bottom: 10px; font-weight: 600; }
.banner.amber { background: rgba(255,176,32,.15); color: var(--amber); }
.banner.red { background: rgba(255,77,85,.15); color: var(--red); }

/* ---- clips ---- */
.filters { display: flex; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.filters .seg button { min-height: 36px; font-size: 13px; }
.clip-row {
  display: flex; align-items: center; gap: 10px; min-height: 52px; padding: 6px 10px;
  border-bottom: 1px solid var(--line); cursor: pointer;
}
.clip-row:active { background: var(--panel-2); }
.clip-row .cambadge { width: 26px; height: 26px; border-radius: 6px; display: grid; place-items: center; background: var(--panel-2); font-weight: 800; font-size: 13px; flex: none; }
.clip-row .meta { font-size: 12px; color: var(--muted); }
.clip-row .flag { color: var(--amber); }
.state-tag { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; padding: 2px 6px; border-radius: 4px; background: var(--panel-2); color: var(--muted); }
.state-tag.done { color: var(--green); }
.state-tag.uploading, .state-tag.verifying, .state-tag.queued, .state-tag.received { color: var(--amber); }
.state-tag.error { color: #fff; background: var(--red); }
.empty { text-align: center; color: var(--dim); padding: 40px 0; }

/* ---- sheet (clip detail / dialogs) ---- */
.sheet {
  position: absolute; inset: var(--status) 0 0 0; background: var(--bg); z-index: 5;
  display: flex; flex-direction: column; padding: 10px; gap: 10px;
}
.sheet-head { display: flex; align-items: center; gap: 10px; }
.sheet-body { flex: 1; display: grid; grid-template-columns: 1.25fr 1fr; gap: 10px; min-height: 0; }
.portrait .sheet-body { grid-template-columns: 1fr; overflow-y: auto; }
.player { background: #000; border-radius: var(--radius); overflow: hidden; display: grid; place-items: center; min-height: 0; }
.player { position: relative; }
.player video { width: 100%; height: 100%; object-fit: contain; display: block; }
.sheet.fsmode { inset: 0; padding: 0; z-index: 8; }
.player.fs { position: absolute; inset: 0; border-radius: 0; z-index: 3; }
/* touch video controls (no browser chrome) */
.vctl { position: absolute; inset: 0; opacity: 0; pointer-events: none; transition: opacity .2s;
  background: linear-gradient(180deg, rgba(0,0,0,.35) 0%, rgba(0,0,0,0) 30%, rgba(0,0,0,0) 55%, rgba(0,0,0,.7) 100%); }
.vctl.show { opacity: 1; pointer-events: auto; }
.vbtn { position: absolute; border: 0; cursor: pointer; display: grid; place-items: center; color: #fff; background: rgba(0,0,0,.45);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
.vbtn svg { fill: currentColor; }
.vplay { left: 50%; top: 50%; width: 76px; height: 76px; margin: -38px 0 0 -38px; border-radius: 50%; }
.vplay svg { width: 40px; height: 40px; }
.vfs { right: 10px; top: 10px; width: 52px; height: 52px; border-radius: 12px; }
.vfs svg { width: 28px; height: 28px; }
.vbar { position: absolute; left: 0; right: 0; bottom: 0; display: flex; align-items: center; gap: 12px; padding: 0 16px 6px; height: 56px; }
.vtime { font-variant-numeric: tabular-nums; font-size: 14px; font-weight: 600; color: #fff; min-width: 40px; text-align: center; }
.vscrub { flex: 1; height: 48px; display: flex; align-items: center; cursor: pointer; touch-action: none; }
.vtrack { position: relative; width: 100%; height: 8px; border-radius: 4px; background: rgba(255,255,255,.3); }
.vfill { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 4px; background: var(--accent); }
.vknob { position: absolute; top: 50%; width: 22px; height: 22px; margin: -11px 0 0 -11px; border-radius: 50%; background: #fff; box-shadow: 0 2px 6px rgba(0,0,0,.4); }
.player.fs .vplay { width: 96px; height: 96px; margin: -48px 0 0 -48px; }
.player.fs .vplay svg { width: 50px; height: 50px; }
.player.fs .vbar { height: 72px; padding: 0 24px 10px; }
.detail { overflow-y: auto; display: flex; flex-direction: column; gap: 8px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; font-size: 12px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; word-break: break-all; }
.stars button { background: none; border: 0; font-size: 26px; color: var(--dim); cursor: pointer; padding: 0 2px; min-height: 40px; }
.stars button.on { color: var(--amber); }
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
textarea, input[type=text], input[type=number] {
  width: 100%; background: var(--panel-2); color: var(--text); border: 1px solid var(--line);
  border-radius: 8px; padding: 10px; font: inherit; min-height: 44px;
}
textarea { resize: none; height: 64px; }
input[type=range] { width: 100%; accent-color: var(--accent); height: 32px; }
.field { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }

/* ---- settings-ish screens ---- */
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.portrait .grid2 { grid-template-columns: 1fr; }
.big-ip { font-size: 34px; font-weight: 800; font-family: var(--mono); letter-spacing: -.01em; }
.profile { display: flex; align-items: center; gap: 10px; min-height: var(--tap); padding: 6px 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel); cursor: pointer; text-align: left; width: 100%; }
.profile.active { border-color: var(--accent); background: rgba(77,163,255,.1); }
.profile small { color: var(--muted); display: block; font-size: 11px; }
.qr { background: #fff; border-radius: 8px; padding: 6px; width: 132px; height: 132px; display: grid; place-items: center; flex: none; }
.qr img, .qr svg { width: 120px; height: 120px; image-rendering: pixelated; }
.log { font-family: var(--mono); font-size: 11px; line-height: 1.5; }
.log div { display: flex; gap: 8px; border-bottom: 1px solid #1a2028; padding: 2px 0; }
.log .warning { color: var(--amber); } .log .error { color: var(--red); }
.toggle { display: flex; align-items: center; justify-content: space-between; min-height: var(--tap); gap: 10px; }
.switch { width: 52px; height: 30px; border-radius: 15px; background: var(--grey); position: relative; border: 0; cursor: pointer; flex: none; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: left .15s; }
.switch.on { background: var(--green); }
.switch.on::after { left: 25px; }

.toast {
  position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); z-index: 9;
  background: #e9eef3; color: #0b0d10; padding: 10px 16px; border-radius: 999px; font-weight: 600; font-size: 13px;
  box-shadow: 0 6px 20px rgba(0,0,0,.5); max-width: 90%;
}
