/* PolicySky design system — from the internal UI/UX Replication Guide (§18).
   Dark is the studio default; JS resolves light/dark/system and stamps
   data-theme before first paint. */

:root {
  --brand-cyan: #69D6FF;
  --brand-blue: #3B8EFF;
  --brand-navy: #062462;
  --background: #EFEFEF;
  --foreground: #0A0A0A;
  --surface: #FFFFFF;
  --surface-subtle: #F2F2F2;
  --surface-sidebar: #F7F7F7;
  --text-muted: #737373;
  --border: #E3E3E3;
  --danger: #E53935;
  --danger-soft: #FBE7E5;
  --success: #18BE6B;
  --success-soft: #E2F6EC;
  --warn: #A16207;
  --warn-soft: #FBF0D9;
  --info-soft: #E4F3FD;
  --accent-text: #062462;
  --radius-card: 12px;
  --radius-control: 10px;
  --radius-small: 8px;
  --shadow-card: 0 1px 3px rgba(0, 0, 0, 0.07);
  --shadow-floating: 0 20px 35px rgba(0, 0, 0, 0.14);
  --gradient-primary: linear-gradient(135deg, var(--brand-cyan), var(--brand-blue));
  --glow-focus: 0 0 0 3px rgba(105, 214, 255, 0.18), 0 0 20px rgba(105, 214, 255, 0.10);
}
[data-theme="dark"] {
  --background: #0B0C0F;
  --foreground: #E2E3E6;
  --surface: #17181C;
  --surface-subtle: #202126;
  --surface-sidebar: #0B0C0F;
  --text-muted: #85878E;
  --border: #292A2F;
  --danger: #E06060;
  --danger-soft: rgba(198, 40, 40, 0.16);
  --success: #2FCF7F;
  --success-soft: rgba(24, 190, 107, 0.14);
  --warn: #E0A458;
  --warn-soft: rgba(224, 164, 88, 0.13);
  --info-soft: rgba(105, 214, 255, 0.10);
  --accent-text: #5ACCF2;
  --shadow-card: 0 1px 3px rgba(0, 0, 0, 0.45);
  --shadow-floating: 0 20px 35px rgba(0, 0, 0, 0.55);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--background);
  color: var(--foreground);
  font-family: "Poppins", -apple-system, sans-serif;
  font-size: 14px;
  line-height: 1.6;
}
button { font-family: inherit; }
a { color: var(--accent-text); }

/* ---- controls ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 40px; padding: 0 16px; border-radius: var(--radius-control);
  border: 1px solid transparent; font-size: 14px; font-weight: 600; cursor: pointer;
  transition: transform 150ms ease, box-shadow 150ms ease, filter 150ms ease;
}
.btn:active { transform: scale(0.98); }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(105, 214, 255, 0.3); }
.btn:disabled { opacity: 0.5; pointer-events: none; }
.btn-primary { background: var(--gradient-primary); color: var(--brand-navy); border: 0; }
.btn-primary:hover { filter: brightness(1.03); box-shadow: 0 8px 24px rgba(59, 142, 255, 0.25); }
.btn-secondary { background: var(--brand-blue); color: #fff; border: 0; }
.btn-outline { background: transparent; color: var(--foreground); border: 1px solid var(--border); font-weight: 500; }
.btn-outline:hover { background: var(--surface-subtle); }
.btn-danger { background: var(--danger); color: #fff; border: 0; }
.btn-sm { min-height: 32px; padding: 0 12px; font-size: 12.5px; border-radius: 8px; }

.input, textarea.input, select.input {
  width: 100%; min-height: 40px; padding: 8px 12px;
  border: 1px solid var(--border); border-radius: var(--radius-control);
  background: var(--surface-subtle); color: var(--foreground);
  font-family: inherit; font-size: 14px;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}
.input:focus { outline: none; border-color: var(--brand-cyan); box-shadow: var(--glow-focus); }
textarea.input { resize: vertical; min-height: 84px; }
label.lbl { display: block; font-size: 13px; font-weight: 500; margin: 0 0 6px; }
.help { font-size: 12px; color: var(--text-muted); }

.card {
  border: 1px solid var(--border); border-radius: var(--radius-card);
  background: var(--surface); box-shadow: var(--shadow-card);
}

.badge {
  display: inline-block; font-size: 12px; font-weight: 600;
  border-radius: 999px; padding: 2px 10px; white-space: nowrap;
}
.b-proc { background: var(--info-soft); color: var(--accent-text); }
.b-good { background: var(--success-soft); color: var(--success); }
.b-warn { background: var(--warn-soft); color: var(--warn); }
.b-fail { background: var(--danger-soft); color: var(--danger); }
.b-neutral { background: var(--surface-subtle); color: var(--text-muted); }

.grad-text { color: var(--accent-text); font-weight: 600; }
.mono { font-family: Menlo, Consolas, monospace; font-size: 0.88em; }

/* ---- app shell ---- */
.shell { display: flex; height: 100vh; }
.sidebar {
  width: 250px; flex: none; background: var(--surface-sidebar);
  border-right: 1px solid var(--border); display: flex; flex-direction: column;
  padding: 14px 10px; overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 6px 10px 16px; }
.brand .sq {
  width: 28px; height: 28px; border-radius: 8px; background: var(--gradient-primary);
  display: flex; align-items: center; justify-content: center;
  color: var(--brand-navy); font-weight: 700; font-size: 15px; flex: none;
}
.brand .wm { font-weight: 600; font-size: 14px; }
.brand .wm span { color: var(--text-muted); font-weight: 400; }
.nav-group { margin: 12px 0 4px; padding: 0 10px; font-size: 10.5px; font-weight: 600;
  letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-muted); }
.nav-item {
  display: flex; align-items: center; gap: 8px; width: 100%; text-align: left;
  padding: 8px 10px; margin: 1px 0; border: 0; border-left: 2px solid transparent;
  border-radius: var(--radius-small); background: none; color: var(--foreground);
  font-size: 13.5px; font-weight: 500; cursor: pointer; min-height: 36px;
}
.nav-item:hover { background: var(--surface-subtle); }
.nav-item.active {
  color: var(--accent-text);
  background: rgba(105, 214, 255, 0.10);
  border-left: 2px solid var(--brand-cyan);
  border-radius: 0 var(--radius-small) var(--radius-small) 0;
}
.nav-item .price { margin-left: auto; font-size: 11px; color: var(--text-muted); font-weight: 400; }
.sidebar-foot { margin-top: auto; padding: 10px; font-size: 11px; color: var(--text-muted); }

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  display: flex; align-items: center; gap: 12px; padding: 10px 20px;
  border-bottom: 1px solid var(--border); background: var(--surface);
}
.topbar .title { font-size: 15px; font-weight: 600; }
.topbar .spacer { flex: 1; }
.userchip { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.userchip .avatar {
  width: 30px; height: 30px; border-radius: 50%; background: var(--gradient-primary);
  color: var(--brand-navy); font-weight: 700; font-size: 12px;
  display: flex; align-items: center; justify-content: center;
}
.content { flex: 1; overflow-y: auto; padding: 24px; }
.page { max-width: 1280px; margin: 0 auto; }

.workspace { display: grid; grid-template-columns: 380px minmax(0, 1fr); gap: 24px; }
.workspace.rev { grid-template-columns: minmax(0, 1fr) 330px; }
.menu-btn { display: none; font-size: 16px; padding: 4px 10px; }
.scrim { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.45); z-index: 55; border: 0; }
@media (max-width: 900px) {
  .workspace, .workspace.rev { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; width: 280px; z-index: 60;
    transform: translateX(-102%); transition: transform 0.22s ease;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
  }
  .sidebar.open { transform: translateX(0); }
  .menu-btn { display: inline-flex; align-items: center; }
  .topbar { padding: 10px 12px; flex-wrap: wrap; row-gap: 6px; }
  .content { padding: 14px; }
  #who { display: none; }
}
@media (pointer: coarse) {
  .nav-item { min-height: 44px; }
  .btn { min-height: 40px; }
  .btn-sm { min-height: 38px; }
  .cap-handle { width: 26px; }
  .cap-timeline { height: 54px; }
}

.tray {
  border-top: 1px solid var(--border); background: var(--surface);
  padding: 8px 20px; display: flex; align-items: center; gap: 8px;
  min-height: 48px; overflow-x: auto;
}
.tray .lbl-jobs { font-size: 10.5px; font-weight: 600; letter-spacing: 0.1em;
  color: var(--text-muted); flex: none; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; flex: none;
  font-size: 12px; font-weight: 500; border-radius: 999px; padding: 4px 12px;
  border: 1px solid var(--border); background: var(--surface); cursor: pointer;
}
.chip .dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }

.grid-assets { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 12px; }
.asset { border: 1px solid var(--border); border-radius: var(--radius-small);
  overflow: hidden; background: var(--surface); cursor: pointer;
  transition: transform 150ms ease, border-color 150ms ease; }
.asset:hover { transform: translateY(-3px); border-color: rgba(105, 214, 255, 0.5); }
.asset img { width: 100%; aspect-ratio: 9/16; object-fit: cover; display: block;
  background: var(--surface-subtle); }
.asset .cap { padding: 6px 8px; font-size: 11px; color: var(--text-muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

table.tbl { border-collapse: collapse; width: 100%; font-size: 13.5px; }
.tbl th { text-align: left; font-size: 10.5px; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--text-muted); padding: 10px 14px; border-bottom: 1px solid var(--border);
  background: var(--surface-subtle); }
.tbl td { padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }

.overlay { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.8);
  display: flex; align-items: center; justify-content: center; z-index: 50; padding: 16px; }
.dialog { width: min(calc(100vw - 32px), 460px); max-height: 90vh; overflow-y: auto;
  padding: 24px; border: 1px solid var(--border); border-radius: var(--radius-card);
  background: var(--surface); box-shadow: 0 24px 60px rgba(0, 0, 0, 0.25); }
.dialog h3 { margin: 0 0 6px; font-size: 18px; }

input.slider { width: 100%; accent-color: var(--brand-cyan); height: 28px; }

/* ---- caption studio ---- */
.cap-canvas { position: relative; background: #000; border-radius: 10px; overflow: hidden;
  margin: 0 auto; touch-action: none; }
.cap-canvas video { width: 100%; height: 100%; display: block; }
.cap-layer { position: absolute; inset: 0; pointer-events: none; }
.cap-safe { position: absolute; border: 1.5px dashed var(--success); border-radius: 6px;
  opacity: .7; }
.cap-clear { position: absolute; background: rgba(198, 40, 40, .14); }
.cap-clear .lbl-clear { position: absolute; inset: auto 0 4px 0; text-align: center;
  font-size: 9px; color: var(--danger); letter-spacing: .04em; }
.cap-guide { position: absolute; background: var(--brand-cyan); opacity: 0; transition: opacity 80ms; }
.cap-guide.v { width: 1.5px; top: 0; bottom: 0; }
.cap-guide.h { height: 1.5px; left: 0; right: 0; }
.cap-guide.on { opacity: .9; }
.cap-pill { position: absolute; transform: translate(-50%, -50%); pointer-events: auto;
  cursor: grab; white-space: pre-wrap; text-align: center; max-width: 86%;
  font-weight: 700; line-height: 1.25; user-select: none; border-radius: .18em;
  padding: .12em .4em; outline: 1.5px solid transparent; }
.cap-pill.sel { outline-color: var(--brand-cyan); }
.cap-pill:active { cursor: grabbing; }
.cap-timeline { position: relative; height: 44px; background: var(--surface-subtle);
  border: 1px solid var(--border); border-radius: 8px; margin-top: 10px;
  touch-action: none; cursor: pointer; }
.cap-range { position: absolute; top: 4px; bottom: 4px; background: rgba(105,214,255,.16);
  border: 1px solid rgba(105,214,255,.6); border-radius: 5px; }
.cap-handle { position: absolute; top: 0; bottom: 0; width: 10px; cursor: ew-resize;
  display: flex; align-items: center; justify-content: center; pointer-events: auto; }
.cap-handle::after { content: ""; width: 4px; height: 60%; border-radius: 2px;
  background: var(--brand-cyan); }
.cap-page-tick { position: absolute; bottom: 4px; height: 8px; border-radius: 2px;
  background: var(--brand-blue); opacity: .8; }
.cap-playhead { position: absolute; top: 0; bottom: 0; width: 1.5px;
  background: var(--foreground); opacity: .8; }
.cap-row { display: flex; gap: 6px; align-items: center; margin-bottom: 6px; }
.cap-row input[type="number"] { width: 64px; min-height: 32px; padding: 2px 6px; }
.cap-row input[type="text"] { flex: 1; min-height: 32px; padding: 2px 8px; }
.cap-row.sel { background: var(--info-soft); border-radius: 6px; }
input[type="color"].swatch { width: 34px; height: 30px; border: 1px solid var(--border);
  border-radius: 6px; background: none; padding: 2px; }

.banner-warn {
  display: flex; align-items: center; gap: 10px;
  background: var(--warn-soft); color: var(--warn);
  border: 1px solid var(--warn); border-radius: var(--radius-small);
  padding: 8px 14px; font-size: 13px; margin: 0 20px; margin-top: 10px;
}
.meter { height: 4px; border-radius: 2px; background: var(--surface-subtle); overflow: hidden; }
.meter > i { display: block; height: 100%; background: var(--gradient-primary); }
.meter.hot > i { background: var(--warn); }
.meter.full > i { background: var(--danger); }
.proj-chip {
  display: inline-flex; align-items: center; gap: 6px; max-width: 220px;
  border: 1px solid var(--border); border-radius: 999px; background: var(--surface-subtle);
  padding: 5px 12px; font-size: 12.5px; font-weight: 500; cursor: pointer;
  white-space: nowrap; overflow: hidden;
}
.picker-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 10px; max-height: 300px; overflow-y: auto; margin-top: 12px; }
.picker-grid .asset.sel { outline: 2px solid var(--brand-cyan); }
.slotbox { border: 1px dashed var(--border); border-radius: var(--radius-control);
  padding: 10px 12px; display: flex; align-items: center; gap: 10px; cursor: pointer;
  min-height: 56px; }
.slotbox:hover { border-color: var(--brand-cyan); }
.slotbox img { width: 34px; height: 56px; object-fit: cover; border-radius: 5px; }
.tabs { display: flex; gap: 6px; margin-bottom: 4px; }
.tabs .tab { border: 1px solid var(--border); background: none; color: var(--text-muted);
  border-radius: 999px; padding: 4px 12px; font-size: 12px; font-weight: 500; cursor: pointer; }
.tabs .tab.active { background: rgba(105,214,255,.12); color: var(--accent-text);
  border-color: var(--brand-cyan); }

.toast-wrap { position: fixed; right: 16px; bottom: 64px; display: flex;
  flex-direction: column; gap: 8px; z-index: 60; max-width: 380px; }
.toast { padding: 12px 16px; border-radius: var(--radius-control);
  border: 1px solid var(--border); background: var(--surface);
  box-shadow: var(--shadow-floating); font-size: 13px; }
.toast b { display: block; margin-bottom: 2px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
