:root {
  color-scheme: light;
  --ink: #171717;
  --muted: #68686a;
  --line: #dddddf;
  --surface: #ffffff;
  --canvas: #f7f7f5;
  --sunken: #eeeeef;
  --brand: #e9184f;
  --brand-dark: #b90f3c;
  --good: #18794e;
  --warning: #a15c00;
  --danger: #b42318;
  --shadow: 0 12px 32px rgb(23 23 23 / 8%);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
  line-height: 1.45;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--canvas); color: var(--ink); }
button, input, select, textarea { font: inherit; letter-spacing: 0; }
button { cursor: pointer; }
img { display: block; object-fit: contain; }
[hidden] { display: none !important; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  background: rgb(255 255 255 / 92%);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(18px);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; font-weight: 800; }
.brand img { width: 132px; height: 44px; }
.brand span { padding-left: 10px; border-left: 1px solid var(--line); }
.topbar-actions { display: flex; align-items: center; gap: 16px; }
.status-dot { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); font-size: 13px; font-weight: 700; }
.status-dot i { width: 8px; height: 8px; border-radius: 50%; background: var(--warning); }
.status-dot.connected i { background: var(--good); }

.workspace { display: grid; grid-template-columns: 220px minmax(0, 1fr); min-height: calc(100vh - 72px); }
.sidebar { position: sticky; top: 72px; height: calc(100vh - 72px); display: flex; flex-direction: column; gap: 4px; padding: 24px 14px; border-right: 1px solid var(--line); background: var(--surface); }
.nav-item { display: flex; justify-content: space-between; align-items: center; min-height: 42px; padding: 0 12px; border: 0; border-radius: 6px; background: transparent; color: var(--muted); text-align: left; font-weight: 700; }
.nav-item span { min-width: 25px; padding: 2px 7px; border-radius: 999px; background: var(--sunken); color: var(--ink); text-align: center; font-size: 12px; }
.nav-item:hover, .nav-item.active { background: var(--sunken); color: var(--ink); }
.nav-item.active { box-shadow: inset 3px 0 var(--brand); }
.nav-item.disconnect { margin-top: auto; }
main { min-width: 0; padding: 36px clamp(22px, 4vw, 58px) 80px; }
.view { display: none; }
.view.active { display: block; }
.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 28px; }
.page-heading h1 { margin: 0; font-family: Georgia, "Times New Roman", serif; font-size: clamp(34px, 4vw, 52px); line-height: 1; }
.eyebrow { margin: 0 0 8px; color: var(--brand); font-size: 12px; font-weight: 900; text-transform: uppercase; }
.provider-summary, .provider-settings { display: flex; flex-wrap: wrap; gap: 8px; }
.provider-chip { padding: 7px 10px; border: 1px solid var(--line); border-radius: 5px; background: var(--surface); color: var(--muted); font-size: 12px; font-weight: 800; }
.provider-chip.ready { color: var(--good); border-color: rgb(24 121 78 / 35%); }
.provider-settings-panel { display: grid; gap: 8px; }
.provider-form { display: grid; grid-template-columns: minmax(170px, .7fr) minmax(220px, 1fr) auto auto; align-items: end; gap: 8px 12px; padding: 14px 0; border-top: 1px solid var(--line); }
.provider-form > div { grid-row: 1 / span 2; align-self: center; }
.provider-form strong, .provider-form span { display: block; }
.provider-form span { margin-top: 3px; color: var(--muted); font-size: 12px; }
.provider-form label { color: var(--muted); font-size: 12px; font-weight: 800; }
.provider-form .form-error { grid-column: 2 / -1; }

.button { min-height: 42px; padding: 0 17px; border: 1px solid transparent; border-radius: 6px; font-weight: 800; }
.button.primary { background: var(--brand); color: white; box-shadow: 0 8px 20px rgb(233 24 79 / 20%); }
.button.primary:hover { background: var(--brand-dark); }
.button.secondary { background: var(--ink); color: white; }
.button:disabled { cursor: not-allowed; opacity: .45; box-shadow: none; }
.icon-button { width: 38px; height: 38px; border: 0; border-radius: 50%; background: var(--sunken); font-size: 25px; line-height: 1; }
.text-button { border: 0; background: transparent; color: var(--brand); font-weight: 800; }

.upload-panel { margin-bottom: 28px; padding: 24px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); box-shadow: var(--shadow); }
.section-heading, .list-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.section-heading h2, .list-header h2, .settings-section h2 { margin: 0; font-size: 20px; }
.source-tabs { display: inline-flex; gap: 3px; margin: 22px 0 18px; padding: 3px; border-radius: 6px; background: var(--sunken); }
.source-tab { min-height: 36px; padding: 0 18px; border: 0; border-radius: 4px; background: transparent; color: var(--muted); font-weight: 800; }
.source-tab.active { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgb(0 0 0 / 10%); }
.upload-form { display: grid; gap: 17px; }
.upload-form label, .inline-form label { display: grid; gap: 7px; color: var(--muted); font-size: 13px; font-weight: 800; }
input, select, textarea { width: 100%; border: 1px solid #cfcfd2; border-radius: 5px; background: white; color: var(--ink); outline: none; }
input, select { height: 44px; padding: 0 12px; }
textarea { resize: vertical; padding: 11px 12px; }
input:focus, select:focus, textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgb(233 24 79 / 10%); }
.form-grid { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 14px; }
.caption-picker { min-width: 0; margin: 0; padding: 0; border: 0; }
.caption-picker legend { margin-bottom: 8px; color: var(--muted); font-size: 13px; font-weight: 800; }
.caption-options { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.caption-option { display: grid; grid-template-columns: 20px minmax(0, 1fr); align-items: center; gap: 9px; min-height: 86px; padding: 11px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); cursor: pointer; }
.caption-option:has(input:checked) { border-color: var(--brand); box-shadow: 0 0 0 3px rgb(233 24 79 / 10%); }
.caption-option input { width: 18px; height: 18px; margin: 0; accent-color: var(--brand); }
.caption-option > span, .caption-option strong, .caption-preview { display: block; min-width: 0; }
.caption-option strong { margin-bottom: 7px; font-size: 13px; }
.caption-preview { overflow: hidden; padding: 7px 8px; border-radius: 4px; font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; text-align: center; white-space: nowrap; }
.caption-preview.none { background: var(--sunken); color: var(--muted); font-size: 11px; font-weight: 700; }
.caption-preview.classic { background: rgb(18 18 18 / 88%); color: white; font-size: 13px; font-weight: 700; }
.caption-preview.bold { background: #242424; color: white; font-size: 14px; font-weight: 900; text-transform: uppercase; text-shadow: 1px 1px 0 #000, -1px -1px 0 #000; }
.drop-zone { min-height: 150px; place-content: center; justify-items: center; padding: 25px; border: 1px dashed #a9aaae; border-radius: 6px; background: #fafafa; text-align: center; }
.drop-zone input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.drop-zone strong { color: var(--ink); font-size: 17px; }
.drop-zone span, .drop-zone em { color: var(--muted); font-size: 12px; font-style: normal; }
.drop-zone em { margin-top: 10px; color: var(--brand); font-weight: 800; }
.drop-zone.dragging { border-color: var(--brand); background: rgb(233 24 79 / 5%); }
.progress-row { display: grid; grid-template-columns: minmax(120px, 1fr) auto; align-items: center; gap: 12px; }
progress { width: 100%; accent-color: var(--brand); }
.form-error { min-height: 18px; margin: 0; color: var(--danger); font-size: 13px; font-weight: 700; }
.form-error.success { color: var(--good); }

.split-layout { display: grid; grid-template-columns: minmax(300px, .8fr) minmax(420px, 1.4fr); gap: 26px; align-items: start; }
.job-list-section, .job-detail { min-width: 0; }
.job-list { display: grid; gap: 8px; margin-top: 14px; }
.job-row { display: grid; grid-template-columns: 1fr auto; gap: 12px; width: 100%; min-height: 82px; padding: 14px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); color: var(--ink); text-align: left; }
.job-row:hover, .job-row.active { border-color: var(--ink); }
.job-row strong, .job-row span { display: block; }
.job-row span { margin-top: 4px; color: var(--muted); font-size: 12px; }
.job-state { align-self: start; padding: 5px 8px; border-radius: 4px; background: var(--sunken); color: var(--muted); font-size: 11px; font-weight: 900; text-transform: uppercase; }
.job-state.ready { background: rgb(24 121 78 / 10%); color: var(--good); }
.job-state.failed { background: rgb(180 35 24 / 10%); color: var(--danger); }
.job-detail { min-height: 310px; padding: 22px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.detail-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; padding-bottom: 18px; border-bottom: 1px solid var(--line); }
.detail-heading h2 { margin: 0; font-size: 23px; }
.detail-heading p { margin: 5px 0 0; color: var(--muted); font-size: 13px; }
.clip-list { display: grid; gap: 22px; margin-top: 22px; }
.clip-item { display: grid; grid-template-columns: minmax(160px, 240px) minmax(220px, 1fr); gap: 18px; padding-bottom: 22px; border-bottom: 1px solid var(--line); }
.clip-item:last-child { border-bottom: 0; padding-bottom: 0; }
.clip-item video { width: 100%; aspect-ratio: 9 / 16; max-height: 390px; border-radius: 6px; background: #111; object-fit: contain; }
.clip-editor { min-width: 0; display: grid; align-content: start; gap: 12px; }
.clip-editor h3 { margin: 0; font-size: 18px; }
.clip-editor h3, .clip-editor .clip-meta, .toggle-row { overflow-wrap: anywhere; }
.clip-editor textarea { min-width: 0; }
.clip-meta { color: var(--muted); font-size: 12px; }
.toggle-row, .channel-choice { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; font-weight: 700; }
.toggle-row input, .channel-choice input { width: 18px; height: 18px; accent-color: var(--brand); }
.clip-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.clip-actions .button { min-height: 38px; }
.approve { background: var(--ink); color: white; }
.reject { border-color: var(--line); background: white; color: var(--muted); }
.publish-panel { display: grid; gap: 10px; padding: 12px; border: 1px solid var(--line); border-radius: 6px; background: #fafafa; }
.channel-choices { display: grid; gap: 7px; }

.empty-state, .empty-detail { display: grid; place-items: center; align-content: center; min-height: 230px; color: var(--muted); text-align: center; }
.empty-state strong, .empty-detail strong { color: var(--ink); font-size: 17px; }
.empty-state span, .empty-detail span { margin-top: 6px; font-size: 13px; }
.clip-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 520px), 1fr)); gap: 18px; align-items: start; }
.clip-grid .job-detail { min-width: 0; padding: 18px; }
.clip-grid .clip-item { grid-template-columns: minmax(170px, 220px) minmax(0, 1fr); }
.settings-section { display: grid; grid-template-columns: minmax(180px, .45fr) minmax(300px, 1fr); gap: 28px; padding: 26px 0; border-top: 1px solid var(--line); }
.settings-copy p { margin: 7px 0 0; color: var(--muted); font-size: 13px; }
.inline-form { display: grid; grid-template-columns: minmax(200px, 1fr) auto; gap: 9px 12px; align-items: end; }
.inline-form label { grid-column: 1; }
.inline-form .button { grid-column: 2; grid-row: 1; align-self: end; margin-top: 20px; }
.channel-list { grid-column: 2; display: grid; gap: 8px; }
.channel-row { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-top: 1px solid var(--line); }
.channel-row img { width: 34px; height: 34px; border-radius: 50%; background: var(--sunken); }
.channel-row div { min-width: 0; flex: 1; }
.channel-row strong, .channel-row span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.channel-row span { color: var(--muted); font-size: 12px; text-transform: capitalize; }
.channel-row input { width: 20px; height: 20px; accent-color: var(--brand); }

.connection { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 20px; background: rgb(247 247 245 / 96%); }
.connection-panel { width: min(420px, 100%); display: grid; gap: 16px; padding: 30px; border: 1px solid var(--line); border-radius: 8px; background: white; box-shadow: var(--shadow); }
.connection-panel img { width: 176px; height: 58px; }
.connection-panel h1 { margin: 6px 0; font-family: Georgia, "Times New Roman", serif; font-size: 32px; }
.connection-panel label { color: var(--muted); font-size: 13px; font-weight: 800; }
.toast { position: fixed; right: 22px; bottom: 22px; z-index: 80; max-width: 420px; padding: 13px 16px; border-radius: 6px; background: var(--ink); color: white; box-shadow: var(--shadow); font-size: 13px; font-weight: 700; }

@media (max-width: 980px) {
  .workspace { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: auto 12px 12px; z-index: 30; height: 62px; flex-direction: row; align-items: center; overflow-x: auto; padding: 7px; border: 1px solid rgb(255 255 255 / 45%); border-radius: 8px; background: rgb(24 24 24 / 92%); box-shadow: var(--shadow); backdrop-filter: blur(18px); }
  .nav-item { flex: 0 0 auto; color: #ddd; }
  .nav-item:hover, .nav-item.active { background: #3b3b3d; color: white; box-shadow: none; }
  .nav-item span { background: #555; color: white; }
  .nav-item.disconnect { margin: 0 0 0 auto; }
  main { padding-bottom: 100px; }
  .split-layout { grid-template-columns: 1fr; }
  .job-detail { min-height: 0; }
}

@media (max-width: 680px) {
  .topbar { height: 64px; padding: 0 14px; }
  .brand img { width: 110px; }
  .brand span, #service-status { display: none; }
  main { padding: 24px 14px 96px; }
  .page-heading { align-items: flex-start; flex-direction: column; }
  .page-heading h1 { font-size: 38px; }
  .upload-panel, .job-detail { padding: 17px; }
  .form-grid, .settings-section { grid-template-columns: 1fr; }
  .caption-options { grid-template-columns: 1fr; }
  .clip-item, .clip-grid .clip-item { grid-template-columns: 1fr; }
  .clip-item video { max-height: 68vh; }
  .channel-list { grid-column: 1; }
  .inline-form { grid-template-columns: 1fr; }
  .inline-form label, .inline-form .button { grid-column: 1; grid-row: auto; margin: 0; }
  .provider-form { grid-template-columns: 1fr; }
  .provider-form > div, .provider-form .form-error { grid-column: 1; grid-row: auto; }
  .sidebar { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); width: calc(100% - 24px); overflow: hidden; }
  body:has(#upload-panel:not([hidden])) .sidebar { display: none; }
  .nav-item { width: 100%; min-width: 0; justify-content: center; overflow: hidden; padding: 3px; font-size: 11px; line-height: 1.05; text-align: center; white-space: normal; }
  .nav-item span { display: none; }
  .nav-item.disconnect { display: none; }
}
