/* Reel Autopilot dashboard — tokens copied from Vinerate (dark only). */
:root {
  --bg: #100d0c; --sidebar: #17100e; --sidebar-accent: #2a1c17; --sidebar-border: #33241e;
  --card: #171210; --raised: #251b17; --popover: #2d211b; --input-border: #43302a; --border: #2c1f1a;
  --fg: #fff8f3; --muted: #c4b3a9; --dim: #75635a;
  --primary: #ff7a1a; --primary-ink: #241713; --ring: #ffb178;
  --cta: linear-gradient(to right, #ff7a1a 0%, #f45b7f 62%, #e96aa8 100%);
  --success: #2ecc71; --danger: #ff5c6c; --warn: #ffb020; --info: #5aa9ff;
  --radius: 12px; --sidebar-w: 256px;
  --font: Inter, "Inter Fallback", system-ui, sans-serif; --font-ar: Cairo, var(--font);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--fg); font: 16px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
[dir="auto"], [lang="ar"], .ar { font-family: var(--font-ar); }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
input, textarea, select { font: inherit; color: var(--fg); background: transparent; border: 1px solid var(--input-border); border-radius: 10px; padding: 10px 12px; width: 100%; outline: none; }
input:focus, textarea:focus { border-color: var(--ring); box-shadow: 0 0 0 3px rgba(255, 122, 26, .18); }
textarea { min-height: 110px; resize: vertical; line-height: 1.6; }
::placeholder { color: var(--dim); }
[hidden] { display: none !important; }

/* layout */
.app { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }
.sidebar { background: var(--sidebar); border-right: 1px solid var(--sidebar-border); padding: 18px 12px; display: flex; flex-direction: column; gap: 8px; position: sticky; top: 0; height: 100vh; }
.brand { font-weight: 700; padding: 4px 10px 12px; display: flex; align-items: center; gap: 6px; }
.brand .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--primary); }
.nav-label { font-size: 11px; letter-spacing: .08em; color: var(--dim); padding: 14px 10px 4px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 10px; color: var(--muted); }
.nav a svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 1.8; }
.nav a:hover { background: var(--sidebar-accent); color: var(--fg); }
.nav a.active { background: var(--sidebar-accent); color: var(--fg); box-shadow: inset 0 0 0 1px #3c2c25; }
.nav a .count { margin-left: auto; font-size: 12px; color: var(--dim); }
.side-bottom { margin-top: auto; display: flex; flex-direction: column; gap: 6px; }
.health { background: var(--raised); border-radius: var(--radius); padding: 12px; font-size: 13px; display: flex; gap: 10px; align-items: center; }
.health .pulse { width: 22px; height: 22px; border-radius: 50%; background: rgba(255, 122, 26, .18); display: grid; place-items: center; color: var(--primary); }
.health small { display: block; color: var(--dim); }
.whoami-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 10px; }
.whoami-row #whoami { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.whoami-row .nav-label { padding: 0; }
main { padding: 0 32px 48px; min-width: 0; }
.topbar { display: flex; align-items: center; justify-content: space-between; height: 56px; border-bottom: 1px solid var(--border); margin: 0 -32px 24px; padding: 0 32px; font-weight: 600; font-size: 15px; }
.topbar .right { display: flex; gap: 14px; color: var(--muted); font-size: 13px; font-weight: 500; }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 16px; border-radius: 10px; font-weight: 600; font-size: 14px; transition: .15s; white-space: nowrap; }
.btn-primary { background: var(--primary); color: var(--primary-ink); }
.btn-primary:hover { filter: brightness(1.08); }
.btn:disabled { opacity: .5; cursor: not-allowed; filter: none; }
.btn-cta { background: var(--cta); color: #fff; padding: 12px 22px; border-radius: 12px; font-size: 15px; box-shadow: 0 8px 24px rgba(255, 122, 26, .25); }
.btn-cta:disabled { opacity: .55; cursor: wait; box-shadow: none; }
.btn-ghost { background: var(--raised); color: var(--fg); border: 1px solid var(--input-border); }
.btn-ghost:hover { background: var(--popover); }
.btn-danger { color: var(--danger); border: 1px solid rgba(255, 92, 108, .35); }
.btn-sm { padding: 6px 10px; font-size: 13px; }

/* hero + form card */
.kicker { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); background: var(--raised); border-radius: 999px; padding: 4px 10px; }
h1 { font-size: 30px; line-height: 1.15; margin: 14px 0 8px; font-weight: 700; letter-spacing: -.01em; }
.lede { color: var(--muted); margin: 0 0 20px; }
.card { background: var(--card); border: 1px solid var(--border); border-radius: 16px; padding: 20px; }
.card.glow { box-shadow: 0 0 0 1px rgba(255, 122, 26, .12), 0 30px 80px -40px rgba(255, 122, 26, .35); }
.tabs { display: inline-flex; gap: 6px; background: var(--raised); padding: 4px; border-radius: 12px; margin-bottom: 14px; }
.tab { padding: 8px 14px; border-radius: 9px; color: var(--muted); font-weight: 500; display: inline-flex; gap: 8px; align-items: center; }
.tab.active { background: var(--popover); color: var(--primary); box-shadow: inset 0 0 0 1px #4a3329; }
.tab svg { width: 15px; height: 15px; stroke: currentColor; fill: none; stroke-width: 1.8; }
.drop { display: block; margin-bottom: 12px; border: 1px dashed var(--input-border); border-radius: 12px; padding: 22px; text-align: center; color: var(--muted); background: rgba(0, 0, 0, .15); cursor: pointer; }
.drop.over { border-color: var(--primary); color: var(--fg); }
.drop strong { color: var(--fg); }
.drop input { display: none; }
.file-pill { display: inline-flex; gap: 8px; align-items: center; margin-top: 10px; background: var(--raised); padding: 6px 10px; border-radius: 999px; font-size: 13px; }
.settings { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 14px 0; padding: 12px; background: var(--raised); border-radius: 12px; }
.settings label { font-size: 13px; color: var(--muted); }
.chips { display: inline-flex; gap: 6px; }
.chip { white-space: nowrap; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--input-border); color: var(--muted); font-size: 13px; }
.chip.active { border-color: var(--primary); color: var(--fg); background: rgba(255, 122, 26, .12); }
.settings input { width: 200px; padding: 7px 10px; }
.optional-link { color: var(--muted); font-size: 13px; text-decoration: underline dotted; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.hint { color: var(--dim); font-size: 13px; }
.progress { height: 6px; background: var(--raised); border-radius: 3px; overflow: hidden; margin-top: 10px; }
.progress i { display: block; height: 100%; width: 0; background: var(--cta); transition: width .2s; }
.error { color: var(--danger); font-size: 13px; }

/* reels grid */
h2 { font-size: 22px; margin: 0; }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin: 16px 0; }
.toolbar input { max-width: 260px; padding: 8px 12px; }
.toolbar .chips { flex-wrap: wrap; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; }
.reel { background: var(--card); border: 1px solid var(--border); border-radius: 14px; overflow: hidden; cursor: pointer; transition: transform .15s, border-color .15s; }
.reel:hover { transform: translateY(-2px); border-color: #3c2c25; }
.thumb { height: 220px; background: var(--raised); position: relative; display: grid; place-items: center; color: var(--dim); overflow: hidden; }
.thumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.thumb .badges { position: absolute; left: 8px; bottom: 8px; display: flex; gap: 4px; }
.badge { font-size: 11px; background: rgba(0, 0, 0, .6); padding: 2px 6px; border-radius: 6px; color: var(--fg); }
.thumb .play { position: relative; width: 42px; height: 42px; border-radius: 50%; background: rgba(0, 0, 0, .55); display: grid; place-items: center; color: var(--fg); }
.thumb .fail { text-align: center; font-size: 13px; color: var(--muted); padding: 12px; }
.thumb .fail b { display: block; color: var(--fg); margin-bottom: 8px; }
/* HeyGen consent: amber, not red — it's a to-do for a person, not a failure of the pipeline */
.thumb .consent { text-align: center; font-size: 13px; color: var(--muted); padding: 12px 12px 34px; display: flex; flex-direction: column; gap: 6px; align-items: center; background: linear-gradient(180deg, rgba(255, 176, 32, .10), transparent 70%); position: absolute; inset: 0; justify-content: center; }
.thumb .consent b { color: var(--warn); }
.consent-actions { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin-top: 4px; }
.btn-consent { background: rgba(255, 176, 32, .14); color: var(--warn); border: 1px solid rgba(255, 176, 32, .45); }
.btn-consent:hover { background: rgba(255, 176, 32, .22); }
.consent-block { border: 1px solid rgba(255, 176, 32, .35); background: rgba(255, 176, 32, .06); border-radius: 12px; padding: 12px 14px; }
.consent-block h4 { color: var(--warn); }
.consent-block p { margin: 0 0 10px; font-size: 14px; color: var(--fg); }
.consent-block .consent-actions { justify-content: flex-start; margin: 0 0 8px; }
.consent-block p.hint { margin: 0; font-size: 13px; color: var(--dim); }
.meta { padding: 10px 12px 12px; }
.meta .title { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.meta .sub { display: flex; gap: 6px; align-items: center; font-size: 12px; color: var(--muted); margin-top: 6px; flex-wrap: wrap; }
.pill { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; padding: 2px 8px; border-radius: 999px; background: var(--raised); color: var(--muted); }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.ok { color: var(--success); } .pill.err { color: var(--danger); } .pill.busy { color: var(--primary); } .pill.wait { color: var(--warn); } .pill.info { color: var(--info); }
.pill.busy::before { animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { opacity: .3; } }
.empty { color: var(--dim); padding: 40px; text-align: center; border: 1px dashed var(--border); border-radius: 14px; }

/* drawer */
.overlay { position: fixed; inset: 0; background: rgba(0, 0, 0, .55); display: flex; justify-content: flex-end; z-index: 20; }
.drawer { width: min(560px, 100%); height: 100%; overflow: auto; background: var(--sidebar); border-left: 1px solid var(--sidebar-border); padding: 20px 22px 40px; }
.drawer h3 { margin: 0; font-size: 18px; }
.drawer video { width: 100%; max-height: 420px; background: #000; border-radius: 12px; margin-top: 14px; }
.drawer .imgs { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
.drawer .imgs { align-items: start; }
.drawer .imgs img { width: 100%; max-height: 300px; object-fit: contain; background: #000; border-radius: 10px; border: 1px solid var(--border); }
.block { margin-top: 16px; }
.block h4 { margin: 0 0 6px; font-size: 12px; letter-spacing: .06em; color: var(--dim); text-transform: uppercase; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.block h4 .btn { text-transform: none; letter-spacing: 0; }
.block pre { white-space: pre-wrap; background: var(--raised); padding: 10px 12px; border-radius: 10px; font: 13px/1.6 var(--font-ar); margin: 0; }
.block pre.log { font-family: ui-monospace, monospace; font-size: 12px; max-height: 220px; overflow: auto; color: var(--muted); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 18px; }
.links a { color: var(--primary); }

/* characters */
.chars { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; }
.chars dl { margin: 10px 0 0; font-size: 13px; }
.chars dt { color: var(--dim); } .chars dd { margin: 0 0 8px; font-family: ui-monospace, monospace; font-size: 12px; word-break: break-all; }
.char-tools { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.char-card { padding: 0; overflow: hidden; display: flex; flex-direction: column; }
.char-card .char-body { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.char-card .name { display: flex; align-items: baseline; gap: 8px; font-weight: 600; }
.char-card .name small { color: var(--dim); font-weight: 400; font-family: ui-monospace, monospace; font-size: 11px; }
.char-card .tags { display: flex; gap: 6px; flex-wrap: wrap; }
.char-card .actions { margin-top: auto; padding-top: 10px; }
.warn-line { color: var(--warn); font-size: 12px; }
/* a look / face thumbnail: the name sits under the image, so a broken (expired) preview still reads */
.lthumb { position: relative; background: var(--raised); display: grid; place-items: center; overflow: hidden; color: var(--muted); text-align: center; font-size: 12px; padding: 8px; }
.lthumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.lthumb .ph { max-width: 100%; overflow-wrap: anywhere; }
.char-card .lthumb { height: 230px; font-size: 14px; }
.char-card .lthumb .ph b { display: block; font-size: 30px; color: var(--dim); }
.lthumb .corner { position: absolute; right: 6px; top: 6px; }
.look-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 10px; margin: 10px 0 18px; }
.look-tile { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; background: var(--card); text-align: left; transition: border-color .15s, transform .15s; }
.look-tile:hover { border-color: #4a3329; transform: translateY(-1px); }
.look-tile .lthumb { height: 150px; }
.look-tile .lname { font-size: 12px; padding: 6px 8px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.look-tile.current { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(255, 122, 26, .35); }
.look-tile.current .lname { color: var(--fg); }
.look-tile:disabled { opacity: .6; cursor: wait; }
.group-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 14px; font-weight: 600; font-size: 14px; }
.group-head .hint { font-weight: 400; }
/* New Reel: this reel's look */
.look-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: -4px 0 14px; padding: 10px 12px; background: var(--raised); border-radius: 12px; }
.look-row label { font-size: 13px; color: var(--muted); }
.look-strip { display: flex; gap: 8px; overflow-x: auto; max-width: 100%; padding: 2px; }
.look-mini { flex: 0 0 auto; width: 54px; height: 72px; border-radius: 9px; border: 1px solid var(--input-border); padding: 0; overflow: hidden; }
.look-mini .lthumb { width: 100%; height: 100%; padding: 2px; font-size: 9px; line-height: 1.2; }
.look-mini.active { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(255, 122, 26, .45); }
/* edit form */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 14px; }
.form-grid .full { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: var(--muted); }
.field input, .field select, .field textarea { font-size: 14px; }
.field textarea { min-height: 80px; }
select { background: var(--card); }
.switch { display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--fg); cursor: pointer; }
.switch input { width: 18px; height: 18px; accent-color: var(--primary); }
.face-pick { display: flex; gap: 12px; align-items: center; }
.face-pick .lthumb { width: 72px; height: 96px; border-radius: 10px; flex: 0 0 auto; }
.spinner { width: 13px; height: 13px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin .8s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

/* login */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-wrap .card { width: min(380px, 100%); }

@media (max-width: 767px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; top: auto; bottom: 0; left: 0; right: 0; height: auto; flex-direction: row; align-items: center; padding: 8px 10px calc(8px + env(safe-area-inset-bottom)); gap: 4px; border-right: 0; border-top: 1px solid var(--sidebar-border); z-index: 10; }
  .brand, .nav-label, .side-bottom, .sidebar .btn-primary { display: none; }
  .nav { display: flex; flex: 1; justify-content: space-around; }
  .nav a { flex-direction: column; gap: 2px; font-size: 11px; padding: 6px 12px; position: relative; }
  .nav a .count { position: absolute; top: 2px; right: 4px; margin: 0; font-size: 10px; }
  .settings label { flex-basis: 100%; }
  main { padding: 0 16px calc(90px + env(safe-area-inset-bottom)); }
  .topbar { margin: 0 -16px 16px; padding: 0 16px; }
  h1 { font-size: 24px; }
  .settings input { width: 100%; }
  .drawer { width: 100%; padding: 16px 16px 40px; }
  .grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .form-grid { grid-template-columns: 1fr; }
  .look-grid { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); }
  .thumb { height: 200px; }
}
.scope-picker { flex-wrap: wrap; margin-top: 14px; }

/* share row + toast */
#d-share-row { margin-top: 8px; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(12px); z-index: 50;
  background: var(--popover); color: var(--fg); border: 1px solid var(--input-border); padding: 10px 16px;
  border-radius: 999px; font-size: 13px; box-shadow: 0 12px 30px -10px rgba(0, 0, 0, .5);
  opacity: 0; transition: opacity .2s, transform .2s; pointer-events: none; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
