/* ============================================================
   HPB clip review — shadcn/ui look-alike (default "zinc" theme).
   Tokens are shadcn's own HSL design tokens, as native CSS
   variables. Follows the OS light/dark preference. No build step,
   no runtime CDN dependency.
   ============================================================ */
:root {
  --background:            0 0% 100%;
  --foreground:            240 10% 3.9%;
  --card:                  0 0% 100%;
  --card-foreground:       240 10% 3.9%;
  --popover:               0 0% 100%;
  --popover-foreground:    240 10% 3.9%;
  --primary:               240 5.9% 10%;
  --primary-foreground:    0 0% 98%;
  --secondary:             240 4.8% 95.9%;
  --secondary-foreground:  240 5.9% 10%;
  --muted:                 240 4.8% 95.9%;
  --muted-foreground:      240 3.8% 46.1%;
  --accent:                240 4.8% 95.9%;
  --accent-foreground:     240 5.9% 10%;
  --destructive:           0 72% 51%;
  --destructive-foreground: 0 0% 98%;
  --border:                240 5.9% 90%;
  --input:                 240 5.9% 90%;
  --ring:                  240 5.9% 10%;
  --radius: 0.5rem;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --background:            240 10% 3.9%;
    --foreground:            0 0% 98%;
    --card:                  240 10% 3.9%;
    --card-foreground:       0 0% 98%;
    --popover:               240 10% 3.9%;
    --popover-foreground:    0 0% 98%;
    --primary:               0 0% 98%;
    --primary-foreground:    240 5.9% 10%;
    --secondary:             240 3.7% 15.9%;
    --secondary-foreground:  0 0% 98%;
    --muted:                 240 3.7% 15.9%;
    --muted-foreground:      240 5% 64.9%;
    --accent:                240 3.7% 15.9%;
    --accent-foreground:     0 0% 98%;
    --destructive:           0 62.8% 45%;
    --destructive-foreground: 0 0% 98%;
    --border:                240 3.7% 15.9%;
    --input:                 240 3.7% 15.9%;
    --ring:                  240 4.9% 83.9%;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body {
  background: hsl(var(--background));
  color: hsl(var(--foreground));
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
.muted { color: hsl(var(--muted-foreground)); }
.error { color: hsl(var(--destructive)); }
::selection { background: hsl(var(--accent)); }

/* ---------- shadcn primitives ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 36px; padding: 0 16px; border-radius: calc(var(--radius) - 2px);
  font: inherit; font-size: 14px; font-weight: 500; line-height: 1;
  border: 1px solid transparent; cursor: pointer; white-space: nowrap;
  transition: background-color .15s, color .15s, border-color .15s;
}
.btn:focus-visible { outline: none; box-shadow: 0 0 0 2px hsl(var(--background)), 0 0 0 4px hsl(var(--ring)); }
.btn.primary { background: hsl(var(--primary)); color: hsl(var(--primary-foreground)); }
.btn.primary:hover { background: hsl(var(--primary) / 0.9); }
.btn.primary:disabled { opacity: .5; cursor: not-allowed; }
.btn.quiet { background: hsl(var(--background)); border-color: hsl(var(--border)); color: hsl(var(--foreground)); }
.btn.quiet:hover { background: hsl(var(--accent)); color: hsl(var(--accent-foreground)); }

.btn-icon {
  display: inline-flex; align-items: center; justify-content: center;
  height: 36px; width: 36px; border-radius: 9999px;
  border: 1px solid hsl(var(--border)); background: hsl(var(--background)); color: hsl(var(--foreground));
  cursor: pointer; transition: background-color .15s, border-color .15s;
}
.btn-icon:hover { background: hsl(var(--accent)); }
.btn-icon:focus-visible { outline: none; box-shadow: 0 0 0 2px hsl(var(--background)), 0 0 0 4px hsl(var(--ring)); }
.btn-icon svg { width: 18px; height: 18px; display: block; }

.kbd {
  display: inline-flex; align-items: center; height: 18px; min-width: 18px; padding: 0 5px;
  border: 1px solid hsl(var(--border)); border-radius: 4px;
  font: 11px ui-monospace, SFMono-Regular, Menlo, monospace;
  color: hsl(var(--muted-foreground)); background: hsl(var(--muted));
}
.btn.primary .kbd {
  border-color: hsl(var(--primary-foreground) / 0.3);
  background: hsl(var(--primary-foreground) / 0.15);
  color: hsl(var(--primary-foreground));
}

/* ---------- Login / card pages ---------- */
.centered { min-height: 100%; display: flex; align-items: center; justify-content: center; padding: 24px; }
.card {
  background: hsl(var(--card)); color: hsl(var(--card-foreground));
  border: 1px solid hsl(var(--border)); border-radius: var(--radius);
  padding: 24px; width: 100%; max-width: 400px; box-shadow: 0 1px 2px rgba(0,0,0,.05);
}
h1 { font-size: 20px; font-weight: 600; margin: 0 0 4px; letter-spacing: -0.01em; }
label { display: block; margin: 16px 0 0; font-size: 13px; color: hsl(var(--foreground)); font-weight: 500; }
input {
  width: 100%; margin-top: 6px; height: 36px; padding: 0 12px;
  background: transparent; border: 1px solid hsl(var(--input)); border-radius: calc(var(--radius) - 2px);
  color: hsl(var(--foreground)); font: inherit; font-size: 14px;
}
input::placeholder { color: hsl(var(--muted-foreground)); }
input:focus-visible { outline: none; border-color: hsl(var(--ring)); box-shadow: 0 0 0 2px hsl(var(--background)), 0 0 0 4px hsl(var(--ring)); }

button { font: inherit; }
.login button {
  margin-top: 24px; width: 100%; height: 36px; border-radius: calc(var(--radius) - 2px);
  border: 1px solid transparent; cursor: pointer;
  background: hsl(var(--primary)); color: hsl(var(--primary-foreground)); font-size: 14px; font-weight: 500;
}
.login button:hover { background: hsl(var(--primary) / 0.9); }

/* ---------- Admin top bar ---------- */
.topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 20px; border-bottom: 1px solid hsl(var(--border)); background: hsl(var(--background));
}
.spacer { flex: 1; }
.inline { margin: 0; display: inline; }
button.ghost {
  background: hsl(var(--background)); border: 1px solid hsl(var(--border)); color: hsl(var(--foreground));
  height: 32px; padding: 0 12px; font-size: 13px; border-radius: calc(var(--radius) - 2px); cursor: pointer;
}
button.ghost:hover { background: hsl(var(--accent)); }

/* ============================================================
   Review console — resizable two-pane split
   ============================================================ */
body.app { overflow: hidden; height: 100vh; }
.app-split { display: flex; height: 100vh; height: 100dvh; overflow: hidden; background: hsl(var(--background)); }

/* --- left: video, full pane --- */
.pane-video {
  flex: 0 0 58%; min-width: 320px; background: hsl(var(--muted));
  display: flex; align-items: center; justify-content: center; overflow: hidden;
}
.pane-video video { width: 100%; height: 100%; object-fit: contain; }
.pane-video .placeholder { color: hsl(240 5% 64.9%); font-size: 13px; }

/* --- draggable handle (shadcn ResizableHandle) --- */
.resizer { flex: 0 0 1px; position: relative; cursor: col-resize; z-index: 2; touch-action: none; background: hsl(var(--border)); }
.resizer::before {
  content: ""; position: absolute; top: 0; bottom: 0; left: -5px; right: -5px;
}
.resizer .grip {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: 16px; height: 44px; border-radius: 8px;
  border: 1px solid hsl(var(--border)); background: hsl(var(--background));
  display: flex; align-items: center; justify-content: center; color: hsl(var(--muted-foreground));
}
.resizer .grip svg { width: 13px; height: 13px; display: block; }
.resizer:hover .grip, .resizer.dragging .grip { border-color: hsl(var(--ring)); }

/* --- right: fields pane --- */
.pane-fields { flex: 1 1 0; min-width: 380px; display: flex; flex-direction: column; min-height: 0; }

.fields-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 24px 12px 12px; flex-shrink: 0;
}
.cliphead {
  display: inline-flex; align-items: center;
  padding: 3px 11px; border-radius: 9999px;
  border: 1px solid transparent;
  background: hsl(var(--primary)); color: hsl(var(--primary-foreground));
  font-size: 13px; font-weight: 600; line-height: 1.4;
  font-variant-numeric: tabular-nums; letter-spacing: 0;
}

/* user popover */
.usermenu { position: relative; }
.popover {
  position: absolute; right: 0; top: calc(100% + 8px); min-width: 228px; z-index: 50;
  background: hsl(var(--popover)); color: hsl(var(--popover-foreground));
  border: 1px solid hsl(var(--border)); border-radius: var(--radius); padding: 6px;
  box-shadow: 0 10px 30px -12px rgba(0,0,0,.35), 0 4px 10px -6px rgba(0,0,0,.18);
}
.pop-id { padding: 8px 8px 6px; }
.pop-name { font-size: 14px; font-weight: 600; }
.pop-sub { font-size: 12px; color: hsl(var(--muted-foreground)); margin-top: 2px; font-variant-numeric: tabular-nums; word-break: break-all; }
.pop-sep { height: 1px; background: hsl(var(--border)); margin: 6px 0; }
.pop-item {
  display: flex; width: 100%; align-items: center; gap: 8px; height: 34px; padding: 0 8px;
  border-radius: calc(var(--radius) - 2px); background: transparent; border: none;
  color: hsl(var(--foreground)); font: inherit; font-size: 13px; cursor: pointer; text-align: left;
}
.pop-item:hover { background: hsl(var(--accent)); }
.pop-item.danger { color: hsl(var(--destructive)); }
.pop-item.danger:hover { background: hsl(var(--destructive) / 0.1); }
.pop-item svg { width: 15px; height: 15px; }

/* field list — collapsed rows, focused row expands (no scroll) */
.fields-scroll { flex: 1; min-height: 0; overflow-y: auto; padding: 14px 14px 6px; display: flex; flex-direction: column; gap: 6px; }
.field { border-radius: var(--radius); }
.field.focused { background: hsl(var(--muted)); padding-top: 4px; padding-bottom: 12px; }
.field.voided { opacity: 0.5; }
.field.voided .row { cursor: default; }

.field .row {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px;
  border-radius: var(--radius); cursor: pointer;
}
body:not(.kbd-nav) .field:not(.focused):not(.voided) .row:hover { background: hsl(var(--accent)); }
.field.focused .row { cursor: default; padding-bottom: 4px; }
.field .fnum {
  flex-shrink: 0; min-width: 18px; text-align: center;
  font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums;
  color: hsl(var(--muted-foreground));
}
.field.focused .fnum { color: hsl(var(--foreground)); }
.field .name { font-size: 13.5px; font-weight: 600; color: hsl(var(--foreground)); letter-spacing: -0.005em; text-transform: capitalize; }
.field .grow { flex: 1; }
.field .chosen { font-size: 13px; color: hsl(var(--muted-foreground)); text-align: right; }
.field .chosen.empty { color: hsl(var(--muted-foreground)); opacity: .6; }

.tag { display: inline-flex; align-items: center; height: 18px; padding: 0 8px; border-radius: 9999px; font-size: 11px; font-weight: 500; flex-shrink: 0; }
.tag.suggested { background: hsl(var(--secondary)); color: hsl(var(--secondary-foreground)); }
.tag.edited { background: transparent; border: 1px solid hsl(var(--border)); color: hsl(var(--foreground)); }
.tag.na { background: transparent; color: hsl(var(--muted-foreground)); font-style: italic; }

.opts { display: flex; flex-wrap: wrap; gap: 6px; padding: 2px 10px 0; }
.opt {
  display: inline-flex; align-items: center; gap: 9px; height: 30px; padding: 0 11px;
  border: 1px solid hsl(var(--border)); border-radius: calc(var(--radius) - 2px);
  font-size: 13px; color: hsl(var(--foreground)); background: hsl(var(--background));
  cursor: pointer; user-select: none; white-space: nowrap;
  transition: background-color .12s, border-color .12s, color .12s;
}
.opt:hover { background: hsl(var(--accent)); }
.opt.sel { background: hsl(var(--primary)); border-color: hsl(var(--primary)); color: hsl(var(--primary-foreground)); }
.opt .dot { width: 5px; height: 5px; border-radius: 50%; background: hsl(var(--muted-foreground)); flex-shrink: 0; }
.opt.sel .dot { background: hsl(var(--primary-foreground)); opacity: .8; }
.opt .num {
  display: inline-flex; align-items: center; justify-content: center;
  height: 17px; min-width: 17px; padding: 0 4px;
  border: 1px solid hsl(var(--border)); border-radius: 4px;
  font: 11px ui-monospace, SFMono-Regular, Menlo, monospace;
  color: hsl(var(--muted-foreground)); background: hsl(var(--muted));
  font-variant-numeric: tabular-nums;
}
.opt.sel .num {
  border-color: hsl(var(--primary-foreground) / 0.3);
  background: hsl(var(--primary-foreground) / 0.15);
  color: hsl(var(--primary-foreground));
}

.hint { padding: 8px 10px 2px; font-size: 12.5px; line-height: 1.45; color: hsl(var(--muted-foreground)); }

/* structured, formatted help (e.g. activity level bands) */
.glossary { padding: 8px 10px 2px; display: grid; grid-template-columns: max-content 1fr; gap: 5px 12px; font-size: 12.5px; line-height: 1.45; }
.glossary .lead { grid-column: 1 / -1; margin: 0 0 3px; color: hsl(var(--muted-foreground)); }
.glossary .term { font-weight: 600; color: hsl(var(--foreground)); white-space: nowrap; }
.glossary .desc { margin: 0; color: hsl(var(--muted-foreground)); }

/* --- bottom: notes + action bar --- */
.fields-foot { flex-shrink: 0; }
.notes { padding: 12px 24px 6px; }
.notes .lbl { display: flex; align-items: center; gap: 6px; font-size: 12px; color: hsl(var(--muted-foreground)); margin-bottom: 6px; }
.notes textarea {
  width: 100%; resize: none; height: 40px; padding: 8px 12px; font: inherit; font-size: 13px;
  background: transparent; border: 1px solid hsl(var(--input)); border-radius: calc(var(--radius) - 2px); color: hsl(var(--foreground));
}
.notes textarea::placeholder { color: hsl(var(--muted-foreground)); }
.notes textarea:focus-visible { outline: none; border-color: hsl(var(--ring)); box-shadow: 0 0 0 3px hsl(var(--ring) / 0.4); }

.actionbar { display: flex; align-items: center; gap: 12px; padding: 12px 24px; }
.actionbar .grow { flex: 1; }
.gate { font-size: 13px; color: hsl(var(--muted-foreground)); font-variant-numeric: tabular-nums; }
.gate.ready { color: hsl(var(--foreground)); font-weight: 500; }

/* --- done + toast --- */
.done-wrap { height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; background: hsl(var(--background)); }
.done-wrap .card { text-align: left; }
.done-wrap h1 { margin-bottom: 10px; }
.done-wrap p { color: hsl(var(--muted-foreground)); margin: 0 0 8px; }
.done-wrap .btn { margin-top: 14px; }
.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%) translateY(8px); z-index: 60;
  background: hsl(var(--foreground)); color: hsl(var(--background)); border-radius: calc(var(--radius) - 2px);
  padding: 10px 16px; font-size: 13px; box-shadow: 0 12px 32px -12px rgba(0,0,0,.6);
  opacity: 0; transition: opacity .15s, transform .15s; pointer-events: none; max-width: 80vw;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err { background: hsl(var(--destructive)); color: hsl(var(--destructive-foreground)); }

/* --- small screens: stack the split --- */
@media (max-width: 820px) {
  .app-split { flex-direction: column; }
  .pane-video { flex: 0 0 38vh; min-width: 0; width: 100%; }
  .resizer { display: none; }
  .pane-fields { min-width: 0; }
}
