/* Clip Engine. Dark theme. Every colour lives in :root. */

:root {
  color-scheme: dark;

  --bg: #0a0c11;
  --bg-glow: rgba(57, 121, 251, 0.10);
  --surface: #12151c;
  --surface-2: #181c25;
  --surface-3: #202532;
  --border: #242a36;
  --border-strong: #363e4f;
  --text: #e9ecf2;
  --text-muted: #a3abbb;
  --text-faint: #717a8c;

  --accent: #3979FB;
  --accent-hover: #5189fc;
  --accent-active: #2f68de;
  --accent-soft: rgba(57, 121, 251, 0.14);
  --accent-border: rgba(57, 121, 251, 0.5);
  --accent-text: #8fb4ff;
  --on-accent: #ffffff;

  --success: #3ecf8e;
  --success-soft: rgba(62, 207, 142, 0.12);
  --success-border: rgba(62, 207, 142, 0.35);
  --warning: #f5b94a;
  --warning-soft: rgba(245, 185, 74, 0.12);
  --warning-border: rgba(245, 185, 74, 0.35);
  --danger: #f4717c;
  --danger-strong: #e5484d;
  --danger-soft: rgba(244, 113, 124, 0.12);
  --danger-border: rgba(244, 113, 124, 0.4);

  --media-bg: #05070a;
  --overlay: rgba(4, 6, 10, 0.72);
  --topbar-bg: rgba(10, 12, 17, 0.82);
  --shadow: 0 12px 32px rgba(0, 0, 0, 0.4);
  --shadow-soft: 0 1px 2px rgba(0, 0, 0, 0.3);
  --skeleton-a: #161a23;
  --skeleton-b: #222836;

  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --topbar-h: 60px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
}

*,
*::before,
*::after { box-sizing: border-box; }

[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: radial-gradient(1100px 480px at 50% -220px, var(--bg-glow), transparent 70%) no-repeat, var(--bg);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

h1, h2, h3, h4, p, ul, ol, fieldset, legend { margin: 0; padding: 0; }
ul, ol { list-style: none; }
fieldset { border: 0; min-width: 0; }
a { color: var(--accent-text); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; }
strong { font-weight: 650; }

:focus { outline: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

.icon { flex: none; display: block; }

.sr-only {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; border: 0;
  overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}

.skip-link {
  position: absolute; left: 12px; top: -60px; z-index: 100;
  padding: 10px 14px; border-radius: var(--radius-sm);
  background: var(--accent); color: var(--on-accent); font-weight: 600;
}
.skip-link:focus { top: 12px; }

.noscript { max-width: 520px; margin: 80px auto; padding: 0 16px; text-align: center; color: var(--text-muted); }

#main:focus { outline: none; }

/* ---------- top bar ---------- */

.topbar {
  position: sticky; top: 0; z-index: 40;
  height: var(--topbar-h);
  background: var(--topbar-bg);
  -webkit-backdrop-filter: saturate(140%) blur(12px);
  backdrop-filter: saturate(140%) blur(12px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  max-width: 1440px; height: 100%; margin: 0 auto; padding: 0 24px;
  display: flex; align-items: center; gap: 12px;
}
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--text); font-weight: 700; letter-spacing: -0.01em; font-size: 16px; }
.brand:hover { text-decoration: none; }
.brand-mark { width: 26px; height: 26px; flex: none; }
.brand-mark-body { fill: var(--accent); }
.brand-mark-play { fill: var(--on-accent); }
.mock-badge {
  padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; letter-spacing: 0.02em;
  color: var(--warning); background: var(--warning-soft); border: 1px solid var(--warning-border);
}
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; min-width: 0; }
.user-name { color: var(--text-muted); font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 160px; }

/* ---------- buttons ---------- */

.btn {
  position: relative;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 40px; padding: 0 16px;
  border: 1px solid transparent; border-radius: 10px;
  font-size: 14px; font-weight: 600; line-height: 1; white-space: nowrap;
  background: transparent; color: var(--text);
  transition: background-color 0.15s, border-color 0.15s, color 0.15s, opacity 0.15s, transform 0.05s;
  -webkit-tap-highlight-color: transparent;
}
.btn:hover { text-decoration: none; }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; }
.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn-primary:active:not(:disabled) { background: var(--accent-active); }
.btn-primary:focus-visible { outline-offset: 3px; }
.btn-secondary { background: var(--surface-2); border-color: var(--border-strong); }
.btn-secondary:hover:not(:disabled) { background: var(--surface-3); }
.btn-ghost { color: var(--text-muted); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); color: var(--text); }
.btn-ghost-danger:hover:not(:disabled) { background: var(--danger-soft); color: var(--danger); }
.btn-danger { background: var(--danger-strong); color: var(--on-accent); }
.btn-danger:hover:not(:disabled) { opacity: 0.9; }
.btn-lg { min-height: 46px; padding: 0 20px; font-size: 15px; border-radius: 12px; }
.btn-sm { min-height: 34px; padding: 0 12px; font-size: 13px; border-radius: 9px; }
.btn-xs { min-height: 30px; padding: 0 10px; font-size: 12.5px; border-radius: 8px; gap: 6px; }
.btn-block { width: 100%; }

.btn.is-loading { color: transparent !important; pointer-events: none; }
.btn.is-loading > * { visibility: hidden; }
.btn.is-loading::after {
  content: ""; position: absolute; left: 50%; top: 50%; width: 16px; height: 16px; margin: -8px 0 0 -8px;
  border-radius: 50%; border: 2px solid var(--text-muted); border-top-color: transparent;
  animation: spin 0.7s linear infinite;
}
.btn-primary.is-loading::after, .btn-danger.is-loading::after { border-color: var(--on-accent); border-top-color: transparent; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: 34px; height: 34px; padding: 0; border: 0; border-radius: 9px;
  background: transparent; color: var(--text-faint);
  transition: background-color 0.15s, color 0.15s;
}
.icon-btn:hover:not(:disabled) { background: var(--surface-3); color: var(--text); }
.icon-btn-danger:hover:not(:disabled) { background: var(--danger-soft); color: var(--danger); }
.icon-btn.is-loading { opacity: 0.5; }

.spinner {
  display: inline-block; flex: none; width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid var(--accent); border-top-color: transparent;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.splash { display: flex; align-items: center; justify-content: center; gap: 12px; min-height: 50vh; color: var(--text-muted); }

/* ---------- page scaffolding ---------- */

.page { max-width: 1240px; margin: 0 auto; padding: 28px 24px 96px; }
.page-job { max-width: 1440px; }
.page.page-narrow { max-width: 780px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }
.page-head-stack { align-items: flex-start; margin-bottom: 20px; }
.page-title { font-size: 26px; line-height: 1.2; font-weight: 700; letter-spacing: -0.02em; overflow-wrap: anywhere; }
.page-sub { margin-top: 6px; color: var(--text-muted); }

.back-link { display: inline-flex; align-items: center; gap: 6px; margin-bottom: 16px; padding: 4px 6px 4px 0; color: var(--text-muted); font-size: 14px; font-weight: 500; }
.back-link:hover { color: var(--text); text-decoration: none; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 20px; box-shadow: var(--shadow-soft); }
.card + .card { margin-top: 16px; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.card-title { display: flex; align-items: center; gap: 8px; font-size: 16px; font-weight: 650; letter-spacing: -0.01em; }
.card-title .icon { color: var(--accent); }
.card-sub { margin-top: 4px; color: var(--text-muted); font-size: 14px; }

.empty { grid-column: 1 / -1; display: flex; flex-direction: column; align-items: center; text-align: center; gap: 10px; padding: 56px 20px; border: 1px dashed var(--border-strong); border-radius: var(--radius-lg); background: var(--surface); }
.empty-icon { display: grid; place-items: center; width: 56px; height: 56px; border-radius: 16px; background: var(--accent-soft); color: var(--accent); }
.empty-title { font-size: 18px; font-weight: 650; }
.empty-body { max-width: 420px; color: var(--text-muted); margin-bottom: 6px; }

/* ---------- form fields ---------- */

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field + .field { margin-top: 18px; }
.field-label { font-size: 13px; font-weight: 600; color: var(--text-muted); }
.field-hint { font-size: 13px; color: var(--text-faint); }
.field-error { font-size: 13.5px; color: var(--danger); }
.input {
  width: 100%; min-height: 42px; padding: 9px 12px;
  background: var(--bg); border: 1px solid var(--border-strong); border-radius: 10px;
  color: var(--text); font-size: 15px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.input::placeholder, .chat-input::placeholder { color: var(--text-faint); }
.input:hover { border-color: var(--text-faint); }
.input:focus, .input:focus-visible { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); border-radius: 10px; }
.input:disabled { opacity: 0.6; }
.input-lg { min-height: 48px; font-size: 16px; }
select.input { appearance: none; -webkit-appearance: none; padding-right: 36px; background-image: linear-gradient(45deg, transparent 50%, var(--text-muted) 50%), linear-gradient(135deg, var(--text-muted) 50%, transparent 50%); background-position: calc(100% - 19px) 50%, calc(100% - 14px) 50%; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; }
.textarea { min-height: 120px; resize: vertical; line-height: 1.5; }
.form-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 18px; }

/* ---------- pills, scores, stepper ---------- */

.pill {
  display: inline-flex; align-items: center; gap: 6px; flex: none;
  padding: 3px 10px; border-radius: 999px; border: 1px solid var(--border-strong);
  font-size: 12px; font-weight: 600; line-height: 1.4; white-space: nowrap;
  color: var(--text-muted); background: var(--surface-2);
}
.pill-working, .pill-accent { color: var(--accent-text); background: var(--accent-soft); border-color: var(--accent-border); }
.pill-success { color: var(--success); background: var(--success-soft); border-color: var(--success-border); }
.pill-danger { color: var(--danger); background: var(--danger-soft); border-color: var(--danger-border); }
.pill-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.3; } }

.scores { display: flex; flex-wrap: wrap; gap: 6px; }
.score { display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border-radius: 7px; background: var(--surface-2); border: 1px solid var(--border); font-size: 11.5px; color: var(--text-muted); }
.score-value { font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }
.score-high .score-value { color: var(--success); }
.score-low .score-value { color: var(--warning); }

.stepper { display: flex; align-items: center; margin-bottom: 24px; }
.stepper-wrap .stepper { margin-bottom: 20px; }
.step { display: flex; align-items: center; gap: 10px; flex: 1 1 auto; min-width: 0; color: var(--text-faint); font-size: 13px; font-weight: 600; }
.step:first-child { flex: 0 0 auto; }
.step + .step::before { content: ""; flex: 1 1 auto; min-width: 12px; height: 2px; border-radius: 2px; background: var(--border-strong); }
.step.is-done::before, .step.is-current::before { background: var(--accent); }
.step-dot {
  display: grid; place-items: center; flex: none; width: 28px; height: 28px; border-radius: 50%;
  border: 2px solid var(--border-strong); background: var(--surface); font-size: 12.5px; font-variant-numeric: tabular-nums;
}
.step-label { white-space: nowrap; }
.step.is-done { color: var(--text-muted); }
.step.is-done .step-dot { background: var(--accent-soft); border-color: var(--accent-border); color: var(--accent-text); }
.step.is-current { color: var(--text); }
.step.is-current .step-dot { background: var(--accent); border-color: var(--accent); color: var(--on-accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.step.is-working .step-dot { animation: ring 1.6s ease-in-out infinite; }
@keyframes ring { 0%, 100% { box-shadow: 0 0 0 3px var(--accent-soft); } 50% { box-shadow: 0 0 0 7px var(--accent-soft); } }

/* ---------- toasts and dialog ---------- */

.toasts { position: fixed; left: 50%; bottom: 20px; z-index: 80; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 8px; width: min(440px, calc(100vw - 32px)); pointer-events: none; }
.toast {
  pointer-events: auto; display: flex; align-items: flex-start; gap: 10px; width: 100%;
  padding: 12px 12px 12px 14px; border-radius: var(--radius); border: 1px solid var(--border-strong);
  background: var(--surface-3); box-shadow: var(--shadow); font-size: 14px;
  opacity: 0; transform: translateY(8px); transition: opacity 0.2s, transform 0.2s;
}
.toast.is-in { opacity: 1; transform: none; }
.toast > .icon { margin-top: 1px; }
.toast-error { border-color: var(--danger-border); }
.toast-error > .icon { color: var(--danger); }
.toast-success > .icon { color: var(--success); }
.toast-info > .icon { color: var(--accent-text); }
.toast-text { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.toast-close { flex: none; display: grid; place-items: center; width: 24px; height: 24px; border: 0; border-radius: 6px; background: transparent; color: var(--text-faint); }
.toast-close:hover { color: var(--text); background: var(--surface-2); }

.dialog { width: min(420px, calc(100vw - 32px)); padding: 24px; border: 1px solid var(--border-strong); border-radius: var(--radius-lg); background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.dialog::backdrop { background: var(--overlay); }
.dialog-title { font-size: 18px; font-weight: 650; }
.dialog-body { margin-top: 8px; color: var(--text-muted); overflow-wrap: anywhere; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; flex-wrap: wrap; }

/* ---------- skeletons ---------- */

.sk, .ghost { background: linear-gradient(100deg, var(--skeleton-a) 30%, var(--skeleton-b) 50%, var(--skeleton-a) 70%); background-size: 300% 100%; animation: shimmer 1.6s linear infinite; border-radius: 8px; }
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } }
.sk-pill { width: 96px; height: 22px; border-radius: 999px; }
.sk-line-lg { width: 70%; height: 20px; margin-top: 16px; }
.sk-line { width: 45%; height: 14px; margin-top: 12px; flex: 1; }
.sk-icon { width: 36px; height: 36px; border-radius: 10px; flex: none; }

/* ---------- login ---------- */

.login { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.login-card { width: min(400px, 100%); display: flex; flex-direction: column; gap: 8px; padding: 32px 28px; background: var(--surface); border: 1px solid var(--border); border-radius: 20px; box-shadow: var(--shadow); }
.login-mark { width: 44px; height: 44px; margin-bottom: 6px; }
.login-title { font-size: 24px; font-weight: 700; letter-spacing: -0.02em; }
.login-sub { color: var(--text-muted); margin-bottom: 14px; }
.login-notice { padding: 10px 12px; margin-bottom: 8px; border-radius: 10px; background: var(--warning-soft); border: 1px solid var(--warning-border); color: var(--warning); font-size: 13.5px; }
.login-card .btn { margin-top: 10px; }

/* ---------- home ---------- */

.job-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 16px; }
.job-card {
  position: relative; display: flex; flex-direction: column; gap: 12px; min-width: 0;
  padding: 18px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  transition: border-color 0.15s, transform 0.15s, background-color 0.15s;
}
.job-card:not(.is-skeleton):hover { border-color: var(--border-strong); background: var(--surface-2); }
.job-card:focus-within { border-color: var(--accent-border); }
.job-card.is-skeleton { min-height: 150px; gap: 0; }
.job-card-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 34px; }
.job-card-delete { position: relative; z-index: 2; margin-right: -6px; }
.job-card-title { font-size: 17px; font-weight: 650; line-height: 1.3; letter-spacing: -0.01em; overflow-wrap: anywhere; }
.stretched-link { color: var(--text); }
.stretched-link:hover { text-decoration: none; }
.stretched-link::after { content: ""; position: absolute; inset: 0; z-index: 1; border-radius: var(--radius-lg); }
.stretched-link:focus-visible { outline: none; }
.stretched-link:focus-visible::after { outline: 2px solid var(--accent); outline-offset: 2px; }
.job-card-clips { display: flex; flex-direction: column; gap: 8px; }
.job-card-clips-text { display: flex; align-items: center; gap: 7px; color: var(--text-muted); font-size: 14px; }
.mini-bar { height: 4px; border-radius: 4px; background: var(--surface-3); overflow: hidden; }
.mini-bar span { display: block; height: 100%; border-radius: 4px; background: var(--accent); }
.job-card-foot { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-top: auto; padding-top: 12px; border-top: 1px solid var(--border); color: var(--text-faint); font-size: 12.5px; }

/* ---------- wizard ---------- */

.wiz-layout { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 20px; align-items: start; }
.wiz-main { min-width: 0; }
.wiz-side { position: sticky; top: calc(var(--topbar-h) + 20px); display: flex; flex-direction: column; gap: 16px; }
.wiz-side .field + .field { margin-top: 0; }
.wiz-setup { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 18px; }
.wiz-setup .field + .field { margin-top: 0; }
.wiz-missing { min-height: 20px; text-align: center; margin-top: -6px; }

.seg-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 6px; }
.seg { position: relative; display: block; cursor: pointer; min-width: 0; }
.seg input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.seg-body { display: flex; align-items: center; gap: 10px; height: 100%; padding: 12px; border: 1px solid var(--border-strong); border-radius: var(--radius); background: var(--bg); color: var(--text-muted); transition: border-color 0.15s, background-color 0.15s, color 0.15s; }
.seg:hover .seg-body { border-color: var(--text-faint); }
.seg-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.seg-text strong { color: var(--text); font-size: 14px; }
.seg-text small { font-size: 12px; color: var(--text-faint); }
.seg input:checked + .seg-body { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-text); }
.seg input:focus-visible + .seg-body { outline: 2px solid var(--accent); outline-offset: 2px; }

.crumbs { display: flex; align-items: center; gap: 2px; margin: 0 -6px 10px; padding: 2px 0; overflow-x: auto; white-space: nowrap; scrollbar-width: none; }
.crumbs::-webkit-scrollbar { display: none; }
.crumb { flex: none; padding: 5px 8px; border: 0; border-radius: 7px; background: transparent; color: var(--accent-text); font-size: 13.5px; font-weight: 600; }
button.crumb:hover { background: var(--accent-soft); }
.crumb.is-current { color: var(--text); }
.crumb-sep { flex: none; color: var(--text-faint); display: inline-flex; }

.drive-list { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--bg); min-height: 120px; }
.drive-list > li + li { border-top: 1px solid var(--border); }
.drive-row { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 58px; padding: 10px 14px; border: 0; background: transparent; text-align: left; transition: background-color 0.12s; }
button.drive-row:hover { background: var(--surface-2); }
button.drive-row:focus-visible { outline-offset: -2px; border-radius: 0; }
.drive-row.is-selected { background: var(--accent-soft); }
.drive-row.is-selected:hover { background: var(--accent-soft); }
.drive-row.is-skeleton { pointer-events: none; }
.drive-icon { display: grid; place-items: center; flex: none; width: 36px; height: 36px; border-radius: 10px; background: var(--surface-2); color: var(--text-muted); }
.drive-folder .drive-icon { color: var(--accent-text); background: var(--accent-soft); }
.drive-main { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.drive-name { font-weight: 550; overflow-wrap: anywhere; line-height: 1.35; }
.drive-meta { font-size: 12.5px; color: var(--text-faint); font-variant-numeric: tabular-nums; }
.drive-end { flex: none; display: inline-flex; align-items: center; color: var(--text-faint); }
.drive-badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px; border-radius: 999px; background: var(--accent); color: var(--on-accent); font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; }
.drive-radio { width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--border-strong); }
.drive-empty { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 36px 16px; color: var(--text-muted); text-align: center; }

.slots { display: flex; flex-direction: column; }
.slots.is-duo { border: 1px solid var(--border-strong); border-radius: var(--radius); background: var(--bg); overflow: hidden; }
.slot { padding: 14px; min-width: 0; }
.slots.is-solo .slot { border: 1px solid var(--border-strong); border-radius: var(--radius); background: var(--bg); }
.slot-head { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 8px; margin-bottom: 10px; }
.slot-pos { padding: 2px 8px; border-radius: 6px; background: var(--accent); color: var(--on-accent); font-size: 10.5px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; }
.slot-guest .slot-pos { background: var(--surface-3); color: var(--text); }
.slot-role { font-weight: 650; font-size: 14px; }
.slot-where { flex-basis: 100%; font-size: 12.5px; color: var(--text-faint); }
.slot-file { display: flex; align-items: center; gap: 10px; padding: 8px 6px 8px 8px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border); }
.slot-file .drive-icon { width: 32px; height: 32px; background: var(--accent-soft); color: var(--accent-text); }
.slot-file .drive-name { font-size: 13.5px; }
.slot-empty { padding: 12px; border: 1px dashed var(--border-strong); border-radius: 10px; color: var(--text-faint); font-size: 13.5px; text-align: center; }
.slot-swap { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 0 14px; }
.slot-swap::before, .slot-swap::after { content: ""; flex: 1; border-top: 1px dashed var(--border-strong); }
.slots-note { color: var(--warning); margin-top: -6px; }

/* ---------- step 2 (draft) ---------- */

.plan-card { border-color: var(--accent-border); background: linear-gradient(180deg, var(--accent-soft), transparent 140px), var(--surface); }
.plan-card .card-title { margin-bottom: 14px; }
.plan-text { display: flex; flex-direction: column; gap: 10px; color: var(--text); overflow-wrap: anywhere; }
.plan-text h4 { font-size: 15px; font-weight: 650; }
.plan-text ul { display: flex; flex-direction: column; gap: 7px; }
.plan-text li { position: relative; padding-left: 20px; }
.plan-text li::before { content: ""; position: absolute; left: 4px; top: 0.62em; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
.source-list { display: flex; flex-direction: column; gap: 6px; margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--border); font-size: 13.5px; }
.source-list li { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; }
.source-role { color: var(--text-faint); font-weight: 600; }
.source-name { color: var(--text-muted); overflow-wrap: anywhere; min-width: 0; }
.source-dur { color: var(--text-faint); font-variant-numeric: tabular-nums; }
.eta-row { display: flex; align-items: flex-start; gap: 10px; margin: 16px 0; padding: 12px 16px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface); color: var(--text-muted); }
.eta-row .icon { color: var(--accent); margin-top: 2px; }
.eta-row strong { color: var(--text); }

/* ---------- job page ---------- */

.job-layout { display: grid; grid-template-columns: minmax(0, 1fr) 400px; gap: 28px; align-items: start; }
.job-main { min-width: 0; }
.job-title-row { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 12px; }
.job-pill { display: inline-flex; }

.banner { display: flex; align-items: flex-start; gap: 12px; padding: 14px 16px; margin-bottom: 16px; border-radius: var(--radius); border: 1px solid var(--border-strong); background: var(--surface); }
.banner > .icon { margin-top: 1px; }
.banner-title { font-weight: 600; overflow-wrap: anywhere; }
.banner-sub { margin-top: 2px; font-size: 13.5px; color: var(--text-muted); }
.banner-danger { border-color: var(--danger-border); background: var(--danger-soft); }
.banner-danger > .icon { color: var(--danger); }
.banner-warning { border-color: var(--warning-border); background: var(--warning-soft); color: var(--warning); }
.banner-success { border-color: var(--success-border); background: var(--success-soft); }
.banner-success > .icon { color: var(--success); }

.progress-card { margin-bottom: 24px; }
.progress-top { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.progress-stage { font-size: 17px; font-weight: 650; letter-spacing: -0.01em; overflow-wrap: anywhere; }
.progress-bar { position: relative; height: 10px; border-radius: 10px; background: var(--surface-3); overflow: hidden; }
.progress-fill { display: block; height: 100%; min-width: 10px; border-radius: 10px; background: var(--accent); transition: width 0.8s ease; }
.progress-bar.is-indeterminate .progress-fill { width: 30% !important; animation: slide 1.4s ease-in-out infinite; }
@keyframes slide { 0% { transform: translateX(-110%); } 100% { transform: translateX(360%); } }
.progress-foot { display: flex; justify-content: space-between; gap: 12px; margin-top: 10px; font-size: 14px; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.progress-eta { color: var(--text); font-weight: 600; }
.progress-note { margin-top: 12px; font-size: 13px; color: var(--text-faint); }

.section-head { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.section-title { font-size: 19px; font-weight: 650; letter-spacing: -0.01em; }
.section-sub { color: var(--text-muted); font-size: 14px; margin-bottom: 4px; }
.count-badge { padding: 2px 9px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); color: var(--text-muted); font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; }

.clip-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 18px; margin-top: 14px; align-items: start; }
.clip-grid:empty { display: none; }
.clip-card { display: flex; flex-direction: column; min-width: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; }
.clip-media { position: relative; width: 100%; aspect-ratio: 9 / 16; background: var(--media-bg); }
.clip-media video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: var(--media-bg); display: block; }
.media-state { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; padding: 20px; text-align: center; color: var(--text-muted); font-size: 14px; font-weight: 550; overflow-wrap: anywhere; }
.media-wait { background: linear-gradient(100deg, var(--skeleton-a) 30%, var(--skeleton-b) 50%, var(--skeleton-a) 70%); background-size: 300% 100%; }
.media-wait.is-rendering { animation: shimmer 1.8s linear infinite; color: var(--text); }
.media-failed { background: var(--danger-soft); color: var(--danger); font-weight: 500; }
.clip-body { display: flex; flex-direction: column; gap: 12px; padding: 14px; min-width: 0; }
.clip-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.clip-head .pill { margin-left: auto; }
.clip-num { display: inline-block; padding: 1px 8px; border-radius: 6px; background: var(--accent-soft); color: var(--accent-text); font-size: 12px; font-weight: 700; white-space: nowrap; }
.clip-dur { display: inline-flex; align-items: center; gap: 4px; color: var(--text-faint); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.clip-title { font-size: 15px; font-weight: 650; line-height: 1.35; overflow-wrap: anywhere; }
.hook { padding: 10px 12px; border-radius: 10px; background: var(--bg); border: 1px solid var(--border); border-left: 3px solid var(--accent); }
.hook-label { display: block; font-size: 11px; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; color: var(--text-faint); margin-bottom: 4px; }
.hook-text { font-weight: 700; line-height: 1.3; overflow-wrap: anywhere; }
.hook-text span { display: block; }
.sched-list { display: flex; flex-direction: column; gap: 6px; padding: 10px 12px; border-radius: 10px; background: var(--success-soft); border: 1px solid var(--success-border); font-size: 13px; }
.sched-list li { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 7px; }
.sched-list .icon { color: var(--success); }
.sched-list span { color: var(--text-muted); font-variant-numeric: tabular-nums; }

.expand { border-top: 1px solid var(--border); padding-top: 10px; }
.expand + .expand { margin-top: -2px; }
.expand summary, .notmade summary { display: flex; align-items: center; gap: 6px; cursor: pointer; list-style: none; font-size: 13.5px; font-weight: 600; color: var(--text-muted); border-radius: 6px; }
.expand summary::-webkit-details-marker, .notmade summary::-webkit-details-marker { display: none; }
.expand summary:hover, .notmade summary:hover { color: var(--text); }
.expand summary .icon, .notmade summary .icon { transition: transform 0.15s; }
.expand[open] summary .icon, .notmade[open] summary > .icon { transform: rotate(90deg); }
.expand-body { display: flex; flex-direction: column; align-items: flex-start; gap: 10px; margin-top: 10px; }
.expand-text { width: 100%; max-height: 220px; overflow-y: auto; padding: 10px 12px; border-radius: 10px; background: var(--bg); border: 1px solid var(--border); font-size: 13.5px; white-space: pre-wrap; overflow-wrap: anywhere; color: var(--text); }
.clip-actions { display: flex; flex-wrap: wrap; gap: 6px; padding-top: 12px; border-top: 1px solid var(--border); }

.ghost-wrap { margin-top: 14px; }
.ghost-row { display: grid; grid-template-columns: repeat(3, minmax(0, 200px)); gap: 18px; opacity: 0.55; }
.ghost { aspect-ratio: 9 / 16; border-radius: var(--radius-lg); animation: none; }
.ghost-wrap.is-working .ghost { animation: shimmer 1.8s linear infinite; }
.ghost-wrap:not(.is-working) .ghost-row { display: none; }
.ghost-text { margin-top: 16px; color: var(--text-muted); }

.notmade { margin-top: 28px; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); }
.notmade summary { padding: 16px 18px; font-size: 15px; color: var(--text); }
.notmade summary:focus-visible { outline-offset: -2px; border-radius: var(--radius-lg); }
.notmade-list { display: flex; flex-direction: column; padding: 0 18px 6px; }
.notmade-item { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 16px 0; border-top: 1px solid var(--border); }
.notmade-main { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.notmade-title { display: flex; align-items: baseline; flex-wrap: wrap; gap: 6px 8px; font-weight: 600; overflow-wrap: anywhere; }
.notmade-reason { color: var(--text-muted); font-size: 14px; overflow-wrap: anywhere; }

/* ---------- chat ---------- */

.chat {
  position: sticky; top: calc(var(--topbar-h) + 20px);
  display: flex; flex-direction: column; min-width: 0;
  height: calc(100vh - var(--topbar-h) - 40px);
  height: calc(100dvh - var(--topbar-h) - 40px);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  overflow: hidden; scroll-margin-top: calc(var(--topbar-h) + 12px);
}
.chat-head { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--border); flex: none; }
.chat-head-icon { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; background: var(--accent-soft); color: var(--accent-text); flex: none; }
.chat-title { font-size: 15px; font-weight: 650; line-height: 1.2; }
.chat-sub { font-size: 12.5px; color: var(--text-faint); }
.chat-log-wrap { position: relative; flex: 1 1 auto; min-height: 0; display: flex; }
.chat-log { flex: 1; min-width: 0; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 12px; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
.chat-log:focus-visible { outline-offset: -2px; border-radius: 0; }
.chat-msgs { display: flex; flex-direction: column; gap: 12px; }
.chat-empty { margin: auto; max-width: 260px; text-align: center; color: var(--text-faint); font-size: 14px; }
.msg { display: flex; flex-direction: column; max-width: 88%; min-width: 0; }
.msg-bubble { padding: 10px 13px; border-radius: 14px; font-size: 14.5px; line-height: 1.45; overflow-wrap: anywhere; }
.msg-time { margin-top: 3px; font-size: 11px; color: var(--text-faint); font-variant-numeric: tabular-nums; }
.msg-user { align-self: flex-end; align-items: flex-end; }
.msg-user .msg-bubble { background: var(--accent); color: var(--on-accent); border-bottom-right-radius: 5px; }
.msg-user.is-sending { opacity: 0.75; }
.msg-assistant { align-self: flex-start; align-items: flex-start; }
.msg-assistant .msg-bubble { background: var(--surface-2); border: 1px solid var(--border); border-bottom-left-radius: 5px; }
.msg-system { align-self: center; align-items: center; max-width: 94%; }
.msg-system .msg-bubble { padding: 3px 10px; background: transparent; color: var(--text-faint); font-size: 12.5px; text-align: center; }
.dots { display: inline-flex; gap: 4px; align-items: center; height: 20px; }
.dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--text-muted); animation: bounce 1.2s ease-in-out infinite; }
.dots i:nth-child(2) { animation-delay: 0.15s; }
.dots i:nth-child(3) { animation-delay: 0.3s; }
@keyframes bounce { 0%, 60%, 100% { transform: none; opacity: 0.5; } 30% { transform: translateY(-4px); opacity: 1; } }
.chat-jump { position: absolute; left: 50%; bottom: 10px; transform: translateX(-50%); display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--accent-border); background: var(--surface-3); color: var(--accent-text); font-size: 12.5px; font-weight: 600; box-shadow: var(--shadow); }

.plan-box { flex: none; max-height: 46%; overflow-y: auto; margin: 0 12px 4px; padding: 14px; border-radius: var(--radius); border: 1px solid var(--accent-border); background: linear-gradient(180deg, var(--accent-soft), transparent 120px), var(--surface-2); box-shadow: 0 0 0 3px var(--accent-soft); scrollbar-width: thin; }
.plan-box-head { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 12px; }
.plan-box-icon { display: grid; place-items: center; flex: none; width: 30px; height: 30px; border-radius: 9px; background: var(--accent); color: var(--on-accent); }
.plan-box-title { font-size: 15px; font-weight: 650; line-height: 1.25; }
.plan-box-sub { font-size: 12.5px; color: var(--text-muted); }
.plan-items { display: flex; flex-direction: column; gap: 10px; }
.plan-item { padding: 10px 12px; border-radius: 10px; background: var(--bg); border: 1px solid var(--border); }
.plan-item-title { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 8px; font-weight: 600; font-size: 13.5px; overflow-wrap: anywhere; }
.plan-slots { display: flex; flex-direction: column; gap: 3px; margin-top: 6px; font-size: 13px; }
.plan-slots li { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.plan-slots strong { font-weight: 600; color: var(--text-muted); }
.plan-slots span { font-variant-numeric: tabular-nums; }
.plan-note { margin-top: 10px; font-size: 13px; color: var(--text-muted); overflow-wrap: anywhere; }
.plan-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }

.chat-foot { flex: none; padding: 10px 12px 10px; border-top: 1px solid var(--border); background: var(--surface); }
.chips { display: flex; gap: 6px; margin: 0 -12px 10px; padding: 2px 12px; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--border-strong); background: var(--surface-2); color: var(--text-muted); font-size: 12.5px; font-weight: 550; white-space: nowrap; transition: border-color 0.15s, color 0.15s, background-color 0.15s; }
.chip:hover { border-color: var(--accent-border); color: var(--accent-text); background: var(--accent-soft); }
.chip:focus-visible { border-radius: 999px; outline-offset: 1px; }
.chat-form { display: flex; align-items: flex-end; gap: 8px; padding: 6px 6px 6px 12px; border-radius: 14px; border: 1px solid var(--border-strong); background: var(--bg); transition: border-color 0.15s, box-shadow 0.15s; }
.chat-form:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.chat-input { flex: 1; min-width: 0; max-height: 160px; min-height: 36px; padding: 7px 0; border: 0; background: transparent; resize: none; font-size: 15px; line-height: 1.45; }
.chat-input:focus, .chat-input:focus-visible { outline: none; }
.chat-input:disabled { opacity: 0.6; }
.chat-send { display: grid; place-items: center; flex: none; width: 36px; height: 36px; border: 0; border-radius: 10px; background: var(--accent); color: var(--on-accent); transition: background-color 0.15s, opacity 0.15s; }
.chat-send:hover:not(:disabled) { background: var(--accent-hover); }
.chat-send:disabled { opacity: 0.4; }
.chat-hint { margin-top: 6px; text-align: center; font-size: 11.5px; color: var(--text-faint); }

.chat-fab { position: fixed; right: 16px; bottom: 16px; z-index: 30; display: none; align-items: center; gap: 8px; min-height: 46px; padding: 0 18px; border: 0; border-radius: 999px; background: var(--accent); color: var(--on-accent); font-weight: 650; box-shadow: var(--shadow); }
.chat-fab-dot { position: absolute; top: 4px; right: 6px; width: 11px; height: 11px; border-radius: 50%; background: var(--danger-strong); border: 2px solid var(--bg); }

/* ---------- responsive ---------- */

@media (max-width: 1020px) {
  .job-layout { grid-template-columns: minmax(0, 1fr); gap: 24px; }
  .chat { position: static; height: auto; }
  .chat-log-wrap { flex: none; }
  .chat-log { max-height: 56vh; min-height: 200px; }
  .plan-box { max-height: none; }
  .chat-fab:not([hidden]) { display: inline-flex; }
  .chat-hint { display: none; }
  .wiz-layout { grid-template-columns: minmax(0, 1fr); }
  .wiz-side { position: static; }
}

@media (max-width: 640px) {
  body { font-size: 15px; }
  .topbar-inner { padding: 0 16px; }
  .user-name { display: none; }
  .page { padding: 20px 16px 104px; }
  .page-title { font-size: 22px; }
  .page-head { margin-bottom: 18px; }
  .page-head > .btn { width: 100%; }
  .card { padding: 16px; }
  .job-grid { grid-template-columns: minmax(0, 1fr); }
  .seg-row { grid-template-columns: minmax(0, 1fr); }
  .step { gap: 6px; font-size: 12.5px; }
  .step-label { display: none; }
  .step.is-labelled .step-label { display: inline; }
  .step + .step::before { min-width: 8px; }
  .clip-grid { grid-template-columns: minmax(0, 1fr); }
  .clip-media { width: min(100%, 300px); margin: 14px auto 0; border-radius: var(--radius); overflow: hidden; }
  .ghost-row { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
  .notmade-item { flex-direction: column; }
  .toasts { bottom: 76px; }
  .form-actions .btn { flex: 1 1 auto; }
  .input, .chat-input { font-size: 16px; }
  .drive-row { padding: 10px 12px; gap: 10px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; scroll-behavior: auto !important; }
}
