:root {
  --bg: #f4f5f8;
  --panel: #ffffff;
  --text: #171922;
  --muted: #6d7280;
  --line: #e5e7ee;
  --accent: #6d5dfc;
  --accent-dark: #5746eb;
  --danger: #c93b48;
  --success: #117a4f;
  --shadow: 0 16px 45px rgba(24, 26, 38, 0.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); }
a { color: inherit; text-decoration: none; }
button, input, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .55; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  min-height: 70px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 12px max(24px, calc((100vw - 1280px) / 2));
  background: rgba(255, 255, 255, 0.94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
}

.topbar nav { display: flex; align-items: center; gap: 18px; }
.topbar nav form { margin: 0; }
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 760; letter-spacing: -.02em; }
.brand small { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .12em; }
.brand-large { font-size: 20px; }
.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 11px;
  color: white;
  background: linear-gradient(145deg, #7d6cff, #4e3dde);
  box-shadow: 0 8px 22px rgba(109, 93, 252, .28);
}

.page-shell { width: min(1280px, calc(100% - 40px)); margin: 0 auto; padding: 46px 0 80px; }
.narrow-page { width: min(760px, calc(100% - 40px)); }
.page-heading, .detail-heading, .section-heading, .title-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}
.page-heading { margin-bottom: 28px; }
.page-heading h1, .detail-heading h1 { margin: 2px 0 5px; font-size: clamp(30px, 4vw, 46px); line-height: 1.08; letter-spacing: -.04em; }
.page-heading p, .detail-heading p { margin: 0; color: var(--muted); }
.eyebrow { margin: 0 0 5px !important; color: var(--accent) !important; font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: .12em; }
.back-link { display: inline-block; margin-bottom: 12px; color: var(--muted); font-size: 14px; }
.muted { color: var(--muted); }

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 10px 17px;
  border: 1px solid transparent;
  border-radius: 11px;
  font-weight: 720;
  transition: transform .15s ease, box-shadow .15s ease, background .15s ease;
}
.button:hover:not(:disabled) { transform: translateY(-1px); }
.button-primary { color: white; background: var(--accent); box-shadow: 0 10px 24px rgba(109, 93, 252, .24); }
.button-primary:hover:not(:disabled) { background: var(--accent-dark); }
.button-secondary { background: #ece9ff; color: #4e3dde; }
.button-ghost { background: white; border-color: var(--line); }
.button-danger { color: white; background: var(--danger); }
.button-small { min-height: 36px; padding: 7px 12px; border-radius: 9px; font-size: 13px; }
.button-full { width: 100%; }

.metric-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 28px; }
.metric-grid-four { grid-template-columns: repeat(4, 1fr); }
.metric { min-width: 0; padding: 20px; border: 1px solid var(--line); border-radius: 15px; background: var(--panel); }
.metric span { display: block; margin-bottom: 7px; color: var(--muted); font-size: 13px; }
.metric strong { font-size: 27px; letter-spacing: -.04em; }

.video-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 22px; }
.video-card { overflow: hidden; border: 1px solid var(--line); border-radius: 18px; background: var(--panel); box-shadow: 0 8px 25px rgba(25, 27, 39, .04); }
.video-poster { position: relative; display: block; aspect-ratio: 16 / 9; overflow: hidden; background: #12131b; }
.video-poster img { width: 100%; height: 100%; object-fit: cover; transition: transform .25s ease; }
.video-card:hover .video-poster img { transform: scale(1.025); }
.poster-placeholder { width: 100%; height: 100%; display: grid; place-items: center; color: white; background: radial-gradient(circle at 25% 20%, #7d6cff, #181a2b 62%); }
.poster-placeholder span { display: grid; place-items: center; width: 62px; height: 62px; border: 1px solid rgba(255,255,255,.35); border-radius: 22px; font-weight: 800; }
.duration { position: absolute; right: 10px; bottom: 10px; padding: 3px 7px; border-radius: 6px; color: white; background: rgba(0,0,0,.72); font-size: 12px; }
.video-card-body { padding: 17px; }
.video-card-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.video-card h2 { margin: 0; font-size: 18px; line-height: 1.25; }
.video-card-body p { margin: 8px 0 14px; overflow: hidden; color: var(--muted); font-size: 13px; white-space: nowrap; text-overflow: ellipsis; }
.video-meta { display: flex; justify-content: space-between; color: var(--muted); font-size: 12px; }
.status { display: inline-flex; flex: 0 0 auto; padding: 4px 8px; border-radius: 999px; font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; background: #eceef3; color: #555b68; }
.status-ready { background: #dff7ed; color: #087249; }
.status-failed { background: #ffe5e7; color: #ac2533; }
.status-processing, .status-queued, .status-uploading { background: #eeeaff; color: #5c49e5; }

.panel { padding: 24px; border: 1px solid var(--line); border-radius: 18px; background: var(--panel); box-shadow: 0 8px 30px rgba(25, 27, 39, .04); }
.stack { display: grid; gap: 17px; }
.stack hr { width: 100%; margin: 4px 0; border: 0; border-top: 1px solid var(--line); }
label { display: grid; gap: 7px; font-size: 13px; font-weight: 720; }
label small { color: var(--muted); font-weight: 450; }
input, textarea {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid #d9dce5;
  border-radius: 10px;
  outline: 0;
  color: var(--text);
  background: white;
  transition: border-color .15s ease, box-shadow .15s ease;
}
textarea { resize: vertical; }
input:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(109, 93, 252, .12); }
input[type="color"] { padding: 5px; }
input[type="checkbox"] { width: 18px; min-height: 18px; accent-color: var(--accent); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.toggle-list { display: grid; gap: 10px; }
.toggle-list label, .toggle-heading { display: flex; grid-template-columns: none; align-items: center; gap: 10px; }
.toggle-heading { font-size: 15px; }

.file-drop { min-height: 190px; place-items: center; align-content: center; padding: 28px; border: 2px dashed #cdd0dc; border-radius: 15px; text-align: center; cursor: pointer; background: #fafafe; }
.file-drop input { display: none; }
.file-drop-title { font-size: 18px; color: var(--accent); }
.file-drop span:last-child { color: var(--muted); font-weight: 450; }
.upload-progress { display: grid; gap: 9px; }
.progress-track { overflow: hidden; height: 10px; border-radius: 999px; background: #eceef3; }
.progress-track div { width: 0; height: 100%; background: linear-gradient(90deg, #6d5dfc, #9d90ff); transition: width .2s linear; }
.progress-meta { display: flex; justify-content: space-between; color: var(--muted); font-size: 13px; }

.alert { padding: 12px 14px; border-radius: 10px; font-size: 13px; }
.alert-error { background: #ffe8ea; color: #9f2531; }
.alert-success { background: #e0f7ed; color: #087249; }
.alert-info { background: #eceaff; color: #5141d0; }

.empty-state { padding: 70px 24px; border: 1px dashed #cfd2dc; border-radius: 20px; text-align: center; background: rgba(255,255,255,.62); }
.empty-state h2 { margin: 12px 0 5px; }
.empty-state p { max-width: 600px; margin: 0 auto 22px; color: var(--muted); }
.empty-icon { width: 60px; height: 60px; display: grid; place-items: center; margin: auto; border-radius: 20px; color: white; background: var(--accent); }

.auth-page { min-height: 100vh; background: radial-gradient(circle at 10% 10%, #7d6cff 0, transparent 30%), #11131d; }
.auth-shell { min-height: 100vh; display: grid; place-items: center; padding: 30px; }
.auth-card { width: min(440px, 100%); padding: 34px; border-radius: 22px; background: rgba(255,255,255,.97); box-shadow: 0 30px 90px rgba(0,0,0,.36); }
.auth-card h1 { margin: 26px 0 4px; font-size: 38px; letter-spacing: -.04em; }
.auth-card > .muted { margin: 0 0 24px; }

.detail-heading { align-items: flex-end; margin-bottom: 26px; }
.title-line { justify-content: flex-start; gap: 14px; }
.detail-grid { display: grid; grid-template-columns: minmax(0, 1.75fr) minmax(320px, .75fr); gap: 24px; align-items: start; }
.detail-main { display: grid; gap: 24px; }
.detail-sidebar { position: sticky; top: 94px; }
.preview-panel { overflow: hidden; aspect-ratio: 16 / 9; border-radius: 18px; background: #0b0c12; box-shadow: var(--shadow); }
.preview-frame { width: 100%; height: 100%; border: 0; }
.processing-card { width: 100%; height: 100%; display: grid; place-items: center; align-content: center; padding: 30px; color: white; text-align: center; }
.processing-card h2 { margin: 18px 0 4px; }
.processing-card p { max-width: 600px; margin: 0; color: #aeb2c0; white-space: pre-wrap; }
.spinner { width: 44px; height: 44px; border: 4px solid rgba(255,255,255,.18); border-top-color: #8d7fff; border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.section-heading { margin-bottom: 18px; }
.section-heading h2, .detail-sidebar h2 { margin: 0; font-size: 23px; letter-spacing: -.025em; }
.code-box { min-height: 122px; margin-bottom: 12px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; background: #151722; color: #d9dcf0; border-color: #151722; }
.lead-list { display: grid; margin-top: 10px; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.lead-list div { display: flex; justify-content: space-between; gap: 20px; padding: 11px 13px; border-bottom: 1px solid var(--line); font-size: 13px; }
.lead-list div:last-child { border-bottom: 0; }
.lead-list time { color: var(--muted); }

@media (max-width: 980px) {
  .video-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .detail-grid { grid-template-columns: 1fr; }
  .detail-sidebar { position: static; }
  .metric-grid-four { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 650px) {
  .topbar { align-items: flex-start; padding: 12px 18px; }
  .topbar nav > a:first-child { display: none; }
  .brand small { display: none; }
  .page-shell, .narrow-page { width: min(100% - 24px, 1280px); padding-top: 28px; }
  .page-heading, .detail-heading { align-items: flex-start; flex-direction: column; }
  .video-grid, .metric-grid { grid-template-columns: 1fr; }
  .metric-grid-four { grid-template-columns: repeat(2, 1fr); }
  .field-row { grid-template-columns: 1fr; }
  .auth-shell { padding: 14px; }
  .auth-card { padding: 25px; }
}
