:root {
  --bg: #101216; --card: #191c22; --line: #2a2f3a; --text: #e8eaf0; --muted: #9aa3b2;
  --accent: #f0a832; --accent-text: #1a1206;
  --ok: #22c55e; --warn: #f59e0b; --err: #ef4444;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif; }
a { color: var(--accent); }
.ur { font-family: 'Noto Nastaliq Urdu', 'Noto Naskh Arabic', Tahoma, system-ui, sans-serif; line-height: 2; }
.hidden { display: none !important; }
.center { text-align: center; }

/* sticky header with brand */
.top { position: sticky; top: 0; z-index: 10; display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 20px; background: var(--bg); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-mark { width: 38px; height: 38px; flex: none; display: grid; place-items: center; background: var(--accent); color: var(--accent-text); font-weight: 800; font-size: 15px; border-radius: 10px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.brand-text strong { font-size: 16px; }
.brand-sub { font-size: 12px; color: var(--muted); }
.top-right { display: flex; align-items: center; gap: 14px; }
.worker-pill { display: inline-flex; align-items: center; gap: 7px; padding: 5px 12px; border: 1px solid var(--line); border-radius: 999px; font-size: 13px; color: var(--muted); white-space: nowrap; }
.worker-pill .dot { width: 8px; height: 8px; border-radius: 50%; background: #6b7280; flex: none; }
.worker-pill.on { color: #bbf7d0; border-color: #166534; }
.worker-pill.on .dot { background: var(--ok); }
.worker-pill.off { color: #fca5a5; border-color: #7f1d1d; }
.worker-pill.off .dot { background: var(--err); }
.logout { color: var(--muted); text-decoration: none; font-size: 14px; }
.logout:hover { color: var(--text); }

/* two-column dashboard layout */
.wrap { max-width: 1240px; margin: 0 auto; padding: 20px; }
.layout { display: grid; grid-template-columns: 360px minmax(0, 1fr); gap: 20px; align-items: start; }
.panel-col { position: sticky; top: 84px; }
.jobs-col { min-width: 0; }
.section-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 12px; }
.section-head h2 { margin: 0; font-size: 18px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 18px; margin-bottom: 16px; }
.panel-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.panel-head h2 { margin: 0; font-size: 18px; }
.panel-en { font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.lead { color: var(--muted); font-size: 14px; margin: 6px 0 14px; }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login .card { width: 100%; max-width: 360px; display: grid; gap: 12px; }
.login .brand { justify-content: center; margin-bottom: 4px; }
.login p.ur { margin: 0; text-align: center; }

input, select, textarea, button { font: inherit; color: inherit; }
input[type=url], input[type=text], input[type=password], input[type=number], select, textarea {
  width: 100%; background: #0c0e12; border: 1px solid var(--line); border-radius: 14px; padding: 10px 12px; min-width: 0;
  transition: border-color .18s, box-shadow .18s, background .18s;
}
input[type=url]:hover, input[type=text]:hover, input[type=password]:hover, input[type=number]:hover, select:hover, textarea:hover { border-color: #3d4356; }
input[type=url]:focus, input[type=text]:focus, input[type=password]:focus, input[type=number]:focus, select:focus, textarea:focus {
  border-color: var(--accent); box-shadow: 0 0 0 4px rgba(240,168,50,.18); outline: 0;
}
/* Native selects keep a soft, premium look when the custom dropdown below
   is not running (no-JS): the browser arrow is replaced by an amber chevron. */
select { appearance: none; -webkit-appearance: none; cursor: pointer; padding-right: 38px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16' fill='none'%3E%3Cpath d='M4 6l4 4 4-4' stroke='%23f0a832' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; background-size: 16px;
}
select::-ms-expand { display: none; }
input[type=color] { width: 100%; height: 42px; background: none; border: 1px solid var(--line); border-radius: 10px; }

/* Searchable caption-language picker: a text box with a dropdown list.
   The list opens with a soft fade-and-slide, and the chevron on the box
   turns while it is open. */
.lang-picker { position: relative; }
.lang-picker .lang-search { width: 100%; cursor: text; padding-right: 38px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16' fill='none'%3E%3Cpath d='M4 6l4 4 4-4' stroke='%23f0a832' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; background-size: 16px;
}
.lang-picker.open .lang-search { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(240,168,50,.18); }
.lang-picker .lang-search::placeholder { color: var(--muted); }
.lang-list { position: absolute; left: 0; right: 0; top: calc(100% + 8px); z-index: 50; margin: 0; padding: 6px; list-style: none;
  background: var(--card); border: 1px solid #3d4356; border-radius: 16px;
  box-shadow: 0 4px 12px rgba(0,0,0,.3), 0 20px 48px rgba(0,0,0,.55);
  max-height: 264px; overflow-y: auto; animation: drop-in .18s ease; }
.lang-list::-webkit-scrollbar { width: 8px; }
.lang-list::-webkit-scrollbar-thumb { background: #3d4356; border-radius: 8px; }
.lang-list::-webkit-scrollbar-track { background: transparent; }
.lang-item { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-radius: 11px; cursor: pointer; font-size: 14.5px;
  transition: background .14s, color .14s; }
.lang-item:hover, .lang-item.active { background: #232833; }
.lang-item.selected { font-weight: 700; color: var(--accent); background: rgba(240,168,50,.12); }
.lang-item .lang-name { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lang-item .lang-tick { color: var(--accent); font-weight: 800; }
.lang-empty { padding: 10px; color: var(--muted); font-size: 14px; text-align: center; }
@keyframes drop-in { from { opacity: 0; transform: translateY(-6px) scale(.995); } to { opacity: 1; transform: translateY(0) scale(1); } }

/* Soft, premium dropdowns: a native <select> enhanced by JS into a button +
   a custom list (see initSoftSelect in app.js). The native select stays in
   the form, hidden, and is kept in sync - so the form posts the same value,
   and with no JS the native select simply shows instead. */
.soft-select { position: relative; }
.soft-select-native { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: 0; border: 0; opacity: 0; pointer-events: none; }
.soft-select-btn { width: 100%; display: flex; align-items: center; gap: 10px; text-align: left; cursor: pointer;
  border: 1px solid var(--line); border-radius: 14px; background: #0c0e12; color: var(--text);
  padding: 10px 12px; font-size: 15px; outline: 0; transition: border-color .18s, box-shadow .18s, background .18s; }
.soft-select-btn:hover { border-color: #3d4356; }
.soft-select-btn:focus-visible { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(240,168,50,.18); }
.soft-select.open .soft-select-btn { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(240,168,50,.18); }
.soft-select-label { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.soft-select-chev { flex: none; display: flex; color: var(--accent); transition: transform .18s ease; }
.soft-select-chev svg { width: 16px; height: 16px; }
.soft-select.open .soft-select-chev { transform: rotate(180deg); }
.soft-select-list { position: absolute; left: 0; right: 0; top: calc(100% + 8px); z-index: 50; margin: 0; padding: 6px; list-style: none;
  background: var(--card); border: 1px solid #3d4356; border-radius: 16px;
  box-shadow: 0 4px 12px rgba(0,0,0,.3), 0 20px 48px rgba(0,0,0,.55);
  max-height: 264px; overflow-y: auto; animation: drop-in .18s ease; }
.soft-select-list::-webkit-scrollbar { width: 8px; }
.soft-select-list::-webkit-scrollbar-thumb { background: #3d4356; border-radius: 8px; }
.soft-select-list::-webkit-scrollbar-track { background: transparent; }
.soft-select-item { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-radius: 11px; cursor: pointer;
  font-size: 14.5px; transition: background .14s, color .14s; }
.soft-select-item:hover, .soft-select-item.active { background: #232833; }
.soft-select-item.selected { font-weight: 700; color: var(--accent); background: rgba(240,168,50,.12); }
.soft-select-item .soft-select-name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.soft-select-item .soft-select-tick { display: none; color: var(--accent); font-weight: 800; }
.soft-select-item.selected .soft-select-tick { display: inline; }
/* The list always opens downward, capped to the room below the button (see
   the script), so it never needs to flip upward. */
button, .btn { background: var(--accent); border: 0; border-radius: 10px; padding: 10px 16px; font-weight: 600; cursor: pointer; text-decoration: none; color: var(--accent-text); display: inline-block; }
button:disabled { opacity: .5; cursor: wait; }
.btn.primary, button.primary { width: 100%; }
.btn.ghost { background: transparent; border: 1px solid var(--line); color: var(--text); padding: 6px 12px; font-size: 13px; }
.btn.danger { color: #fca5a5; }
.row { display: flex; gap: 10px; }
.row.small { margin-top: 8px; gap: 16px; }
.row.small label { display: flex; align-items: center; gap: 6px; }
.row.small input { width: 90px; }
label { display: block; }
label > span { display: block; color: var(--muted); font-size: 13px; }
.field { margin: 14px 0; }
.field > span { color: var(--muted); font-size: 13px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips button { background: transparent; border: 1px solid var(--line); color: var(--text); padding: 6px 14px; }
.chips button.on { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; align-items: end; margin: 10px 0; }
label.check { display: flex; align-items: center; gap: 8px; }
label.check span { display: inline; color: var(--text); font-size: 15px; }
details { margin-top: 10px; border-top: 1px solid var(--line); padding-top: 10px; }
details summary { cursor: pointer; color: var(--muted); }
details > label { margin-top: 10px; }
.alert { background: #3b1219; border: 1px solid #7f1d1d; color: #fecaca; padding: 10px 12px; border-radius: 10px; margin-top: 10px; white-space: pre-wrap; word-break: break-word; }
.alert.ok { background: #0f2a1a; border-color: #166534; color: #bbf7d0; }
.alert.warn { background: #2a1f08; border-color: #78350f; color: #fde68a; }
.jobsbar { margin-bottom: 12px; text-align: left; }
.empty { border: 1px dashed var(--line); border-radius: 14px; padding: 28px 16px; text-align: center; color: var(--muted); }
.job .jh { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.t { font-weight: 600; }
.sub { color: var(--muted); font-size: 13px; word-break: break-all; }
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 999px; font-size: 12px; background: #2a2f3a; white-space: nowrap; }
.badge .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex: none; }
.badge.done { background: #14532d; color: #bbf7d0; } .badge.failed { background: #7f1d1d; color: #fecaca; } .badge.processing { background: #78350f; color: #fde68a; } .badge.queued { background: #2a2f3a; color: #d1d5db; }
.bar { height: 6px; background: #0c0e12; border-radius: 99px; overflow: hidden; margin: 12px 0 4px; }
.bar i { display: block; height: 100%; background: var(--accent); transition: width .5s; }
.clips-head { font-size: 13px; color: var(--muted); border-top: 1px solid var(--line); padding-top: 12px; margin-top: 14px; }
.clips { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; margin-top: 14px; }
.clip { background: #0c0e12; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.clip-media { position: relative; background: #000; }
.clip-media video { width: 100%; aspect-ratio: 9/16; object-fit: contain; background: #000; display: block; }
.chip { position: absolute; top: 8px; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; background: rgba(0, 0, 0, .65); color: #fff; }
.chip.clip-no { left: 8px; }
.chip.clip-dur { right: 8px; }
.clip .meta { padding: 10px; display: grid; gap: 4px; }
.hook { font-size: 13px; }
.tags { font-size: 12px; color: var(--accent); word-break: break-word; }
.btns { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .panel-col { position: static; }
}
@media (max-width: 600px) {
  .row { flex-direction: column; }
  .row.small { flex-direction: row; }
}
/* Urdu text reads right-to-left */
.ur, [dir=auto] { unicode-bidi: plaintext; }
label > span.ur, .field > span.ur, p.ur, label.ur { direction: rtl; text-align: right; }
