/* GoldTube - soft card design system */
@font-face {
  font-family: 'Pretendard';
  src: url('/static/fonts/PretendardVariable.woff2') format('woff2-variations');
  font-weight: 45 920;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Pretendard Static';
  src: url('/static/fonts/Pretendard-Regular.woff2') format('woff2');
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Pretendard Static';
  src: url('/static/fonts/Pretendard-SemiBold.woff2') format('woff2');
  font-weight: 600; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Pretendard Static';
  src: url('/static/fonts/Pretendard-Bold.woff2') format('woff2');
  font-weight: 700; font-style: normal; font-display: swap;
}

:root {
  --bg: #ffffff;
  --text: #37352f;
  --muted: #787774;
  --muted-strong: #5f5e5a;
  --border: #e9e9e7;
  --accent: #2383e2;
  --accent-soft: #eaf3fd;
  --accent-strong: #1a6ec0;
  --radius: 10px;
  --radius-lg: 14px;
  --radius-sm: 7px;

  --surface: #fbfbfa;
  --surface-2: #f7f7f5;
  --hover: rgba(55, 53, 47, 0.055);
  --active: rgba(55, 53, 47, 0.09);
  --shadow-sm: 0 1px 2px rgba(15, 15, 15, 0.05), 0 2px 6px rgba(15, 15, 15, 0.04);
  --shadow-md: 0 2px 6px rgba(15, 15, 15, 0.06), 0 8px 24px rgba(15, 15, 15, 0.07);
  --shadow-lg: 0 8px 32px rgba(15, 15, 15, 0.12);

  --green: #0f7b6c;
  --green-soft: #e7f5f1;
  --amber: #9a6700;
  --amber-soft: #fdf3e0;
  --red: #c14a3c;
  --red-soft: #fbeceb;
  --purple: #6940a5;
  --purple-soft: #f2eefb;

  --sidebar-w: 250px;
  --sidebar-collapsed-w: 66px;
  --topbar-h: 56px;
  --font: 'Pretendard', 'Pretendard Static', -apple-system, BlinkMacSystemFont,
          'Segoe UI', system-ui, 'Apple SD Gothic Neo', 'Noto Sans KR', sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
::selection { background: rgba(35, 131, 226, 0.18); }
h1, h2, h3, h4 { margin: 0; font-weight: 700; letter-spacing: -0.011em; }
p { margin: 0; }
svg { flex-shrink: 0; }

/* scrollbars */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(55,53,47,.16); border-radius: 8px; border: 3px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: rgba(55,53,47,.28); background-clip: content-box; }

/* ---------------------------------------------------------------- layout */
.app-shell { display: flex; min-height: 100vh; min-height: 100dvh; }

.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; height: 100dvh;
  transition: width .18s ease, flex-basis .18s ease;
  z-index: 60;
}
body.sidebar-collapsed .sidebar { width: var(--sidebar-collapsed-w); flex-basis: var(--sidebar-collapsed-w); }

.sidebar-head {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 14px 10px; min-height: var(--topbar-h);
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1; }
.brand-mark {
  width: 30px; height: 30px; border-radius: 8px; flex-shrink: 0;
  background: linear-gradient(140deg, #ffce6a, #f0a62c 55%, #d98216);
  display: grid; place-items: center; color: #3a2a06;
  box-shadow: 0 1px 3px rgba(180, 120, 20, .35);
}
.brand-name { font-weight: 700; font-size: 15.5px; letter-spacing: -.02em; white-space: nowrap; }
.brand-sub { font-size: 11px; color: var(--muted); white-space: nowrap; margin-top: -3px; }
body.sidebar-collapsed .brand-text { display: none; }

.icon-btn {
  width: 30px; height: 30px; border-radius: var(--radius-sm);
  border: none; background: transparent; color: var(--muted);
  display: grid; place-items: center; cursor: pointer;
  transition: background .12s ease, color .12s ease;
}
.icon-btn:hover { background: var(--hover); color: var(--text); }
.icon-btn:active { background: var(--active); }

.sidebar-nav { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 4px 8px 10px; }
.nav-section { margin-top: 12px; }
.nav-label {
  font-size: 11px; font-weight: 600; color: var(--muted);
  padding: 6px 10px 4px; letter-spacing: .02em; white-space: nowrap;
}
body.sidebar-collapsed .nav-label { opacity: 0; height: 10px; overflow: hidden; padding: 0; }

.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 10px; border-radius: var(--radius-sm);
  color: var(--muted-strong); font-size: 14.5px; font-weight: 500;
  cursor: pointer; margin-bottom: 2px; position: relative;
  transition: background .12s ease, color .12s ease;
  white-space: nowrap;
}
.nav-item:hover { background: var(--hover); color: var(--text); }
.nav-item.active { background: var(--accent-soft); color: var(--accent-strong); font-weight: 600; }
.nav-item.active svg { color: var(--accent); }
.nav-item svg { color: var(--muted); transition: color .12s ease; }
.nav-item:hover svg { color: var(--text); }
.nav-text { overflow: hidden; text-overflow: ellipsis; }
.nav-badge {
  margin-left: auto; background: var(--accent); color: #fff;
  font-size: 11px; font-weight: 700; border-radius: 20px; padding: 1px 7px; min-width: 20px; text-align: center;
}
body.sidebar-collapsed .nav-text, body.sidebar-collapsed .nav-badge { display: none; }
body.sidebar-collapsed .nav-item { justify-content: center; padding: 8px; }

/* collapsed tooltips */
.nav-item[data-tip]::after {
  content: attr(data-tip);
  position: absolute; left: calc(100% + 10px); top: 50%; transform: translateY(-50%) scale(.96);
  background: #2f2e2b; color: #fff; font-size: 12.5px; font-weight: 500;
  padding: 5px 9px; border-radius: 7px; white-space: nowrap;
  opacity: 0; pointer-events: none; transition: opacity .12s ease, transform .12s ease;
  box-shadow: var(--shadow-md); z-index: 90;
}
body.sidebar-collapsed .nav-item:hover::after { opacity: 1; transform: translateY(-50%) scale(1); }
body:not(.sidebar-collapsed) .nav-item::after { display: none; }

.sidebar-foot { border-top: 1px solid var(--border); padding: 8px; }
.user-chip {
  display: flex; align-items: center; gap: 10px; padding: 7px 8px;
  border-radius: var(--radius-sm); cursor: default;
}
.avatar {
  width: 28px; height: 28px; border-radius: 50%; flex-shrink: 0;
  background: var(--accent); color: #fff; display: grid; place-items: center;
  font-size: 13px; font-weight: 700;
}
.user-meta { min-width: 0; flex: 1; }
.user-name { font-size: 13.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 11px; color: var(--muted); }
body.sidebar-collapsed .user-meta, body.sidebar-collapsed .sidebar-foot form { display: none; }
body.sidebar-collapsed .user-chip { justify-content: center; padding: 7px 0; }

/* main */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: var(--topbar-h); position: sticky; top: 0; z-index: 40;
  background: rgba(255,255,255,.86); backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px; padding: 0 18px;
}
.topbar h1 { font-size: 16px; font-weight: 700; }
.topbar-spacer { flex: 1; }
.hamburger { display: none; }

.content { padding: 22px 22px 120px; max-width: 1180px; width: 100%; margin: 0 auto; }
.page-head { margin-bottom: 18px; }
.page-title { font-size: 25px; font-weight: 800; letter-spacing: -.022em; }
.page-desc { color: var(--muted); font-size: 14px; margin-top: 4px; }

/* ---------------------------------------------------------------- cards */
.card {
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 18px; box-shadow: var(--shadow-sm);
}
.card + .card { margin-top: 14px; }
.card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.card-title { font-size: 15px; font-weight: 700; }
.card-desc { font-size: 13px; color: var(--muted); margin-top: 2px; }
.card-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }

.grid { display: grid; gap: 14px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-auto { grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }
.grid-start { align-items: start; }

.stat {
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 16px; box-shadow: var(--shadow-sm);
  display: flex; flex-direction: column; gap: 6px;
}
.stat-top { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12.5px; font-weight: 600; }
.stat-icon { width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center; background: var(--surface-2); color: var(--muted-strong); }
.stat-value { font-size: 25px; font-weight: 800; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.stat-sub { font-size: 12px; color: var(--muted); }

/* ---------------------------------------------------------------- buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 8px 14px; border-radius: var(--radius); border: 1px solid var(--border);
  background: #fff; color: var(--text); font-size: 14px; font-weight: 600;
  cursor: pointer; transition: background .12s ease, border-color .12s ease, transform .08s ease, box-shadow .12s ease;
  white-space: nowrap; box-shadow: var(--shadow-sm);
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
.btn-ghost { background: transparent; border-color: transparent; box-shadow: none; color: var(--muted-strong); }
.btn-ghost:hover { background: var(--hover); color: var(--text); }
.btn-accent { color: var(--red); border-color: #f0d9d6; background: #fff; font-weight: 600; }
.btn-accent:hover { background: var(--red-soft); }
.btn-danger { color: var(--red); border-color: #f0d9d6; background: #fff; }
.btn-danger:hover { background: var(--red-soft); }
.btn-sm { padding: 5px 10px; font-size: 13px; border-radius: var(--radius-sm); }
.btn-lg { padding: 11px 20px; font-size: 15px; }
.btn-block { width: 100%; }

/* ---------------------------------------------------------------- forms */
.field { margin-bottom: 14px; }
.field:last-child { margin-bottom: 0; }
.label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.hint { font-size: 12.5px; color: var(--muted); margin-top: 5px; line-height: 1.5; }
.input, .select, .textarea {
  width: 100%; padding: 9px 12px; border: 1px solid var(--border);
  border-radius: var(--radius); background: var(--surface);
  transition: border-color .12s ease, box-shadow .12s ease, background .12s ease;
  font-size: 14.5px;
}
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--accent); background: #fff;
  box-shadow: 0 0 0 3px rgba(35,131,226,.14);
}
.textarea { min-height: 110px; resize: vertical; line-height: 1.6; }
.select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23787774' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; padding-right: 32px; }
.input-group { display: flex; gap: 8px; }
.input-group .input { flex: 1; }

.switch-row { display: flex; align-items: center; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--border); }
.switch-row:last-child { border-bottom: none; }
.switch-info { flex: 1; min-width: 0; }
.switch-title { font-size: 14px; font-weight: 600; }
.switch-desc { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.switch { position: relative; width: 40px; height: 23px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch-track {
  position: absolute; inset: 0; background: #d6d5d1; border-radius: 20px;
  cursor: pointer; transition: background .16s ease;
}
.switch-track::after {
  content: ''; position: absolute; top: 2.5px; left: 2.5px; width: 18px; height: 18px;
  background: #fff; border-radius: 50%; transition: transform .16s ease;
  box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.switch input:checked + .switch-track { background: var(--accent); }
.switch input:checked + .switch-track::after { transform: translateX(17px); }
.switch input:focus-visible + .switch-track { box-shadow: 0 0 0 3px rgba(35,131,226,.2); }

.range-row { display: flex; align-items: center; gap: 12px; }
input[type=range] {
  -webkit-appearance: none; appearance: none; flex: 1; height: 4px;
  background: var(--border); border-radius: 4px; outline: none;
}
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 17px; height: 17px; border-radius: 50%;
  background: var(--accent); cursor: pointer; box-shadow: 0 1px 3px rgba(0,0,0,.25);
}
input[type=range]::-moz-range-thumb { width: 17px; height: 17px; border: none; border-radius: 50%; background: var(--accent); cursor: pointer; }
.range-value { font-variant-numeric: tabular-nums; font-weight: 700; font-size: 13.5px; min-width: 62px; text-align: right; }

/* chips */
.chip-row { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px;
  border: 1px solid var(--border); border-radius: 20px; background: #fff;
  font-size: 13.5px; font-weight: 500; cursor: pointer;
  transition: all .12s ease; box-shadow: var(--shadow-sm);
}
.chip:hover { background: var(--surface-2); }
.chip.selected { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-strong); font-weight: 600; }
.chip.selected svg { color: var(--accent); }
.chip input[type=checkbox] { position: absolute; width: 1px; height: 1px; opacity: 0; }
.chip:has(input[type=checkbox]:checked) {
  border-color: var(--accent); background: var(--accent-soft);
  color: var(--accent-strong); font-weight: 600;
}
.chip:focus-within { outline: 2px solid var(--accent-soft); outline-offset: 1px; }

/* device-code (YouTube authorisation) */
.device-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 30px; font-weight: 700; letter-spacing: 5px; text-align: center;
  padding: 14px 10px; border: 1px dashed var(--border); border-radius: var(--radius);
  background: #fff; user-select: all;
}
@media (max-width: 520px) { .device-code { font-size: 23px; letter-spacing: 3px; } }

/* badges */
.badge {
  display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px;
  border-radius: 20px; font-size: 12px; font-weight: 600;
  background: var(--surface-2); color: var(--muted-strong);
}
.badge-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-ready, .badge-done { background: var(--green-soft); color: var(--green); }
.badge-running, .badge-queued { background: var(--accent-soft); color: var(--accent-strong); }
.badge-failed, .badge-error { background: var(--red-soft); color: var(--red); }
.badge-draft, .badge-interrupted, .badge-cancelled { background: var(--amber-soft); color: var(--amber); }
.badge-cc { background: var(--purple-soft); color: var(--purple); }

/* tables */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius-lg); background: #fff; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
thead th {
  text-align: left; font-size: 12px; font-weight: 700; color: var(--muted);
  padding: 10px 14px; border-bottom: 1px solid var(--border); background: var(--surface);
  white-space: nowrap; cursor: pointer; user-select: none;
}
thead th.no-sort { cursor: default; }
tbody td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--surface); }
.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }

/* progress */
.progress { height: 6px; background: var(--surface-2); border-radius: 20px; overflow: hidden; }
.progress-bar {
  height: 100%; border-radius: 20px; width: 0;
  background: linear-gradient(90deg, var(--accent), #57a8ee);
  transition: width .45s cubic-bezier(.4,0,.2,1);
  position: relative; overflow: hidden;
}
.progress-bar::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.45), transparent);
  animation: shimmer 1.4s infinite;
}
@keyframes shimmer { 0% { transform: translateX(-100%); } 100% { transform: translateX(100%); } }
.progress.done .progress-bar::after { display: none; }

/* job pill */
.job-pills {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: max(16px, env(safe-area-inset-bottom)); z-index: 80;
  display: flex; flex-direction: column; gap: 8px; align-items: center;
  width: min(460px, calc(100vw - 24px)); pointer-events: none;
}
.job-pill {
  pointer-events: auto; width: 100%;
  background: #fff; border: 1px solid var(--border); border-radius: 22px;
  box-shadow: var(--shadow-lg); padding: 9px 14px; cursor: pointer;
  display: flex; align-items: center; gap: 11px;
  animation: pillIn .28s cubic-bezier(.2,.9,.3,1.2);
}
@keyframes pillIn { from { opacity: 0; transform: translateY(14px) scale(.96); } to { opacity: 1; transform: none; } }
.job-pill:hover { border-color: #dcdbd8; }
.pill-spinner { width: 18px; height: 18px; color: var(--accent); animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.pill-body { flex: 1; min-width: 0; }
.pill-title { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pill-step { font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pill-pct { font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--accent); }
.pill-progress { height: 3px; margin-top: 5px; background: var(--surface-2); border-radius: 3px; overflow: hidden; }
.pill-progress > div { height: 100%; background: var(--accent); border-radius: 3px; transition: width .4s ease; }

/* toasts */
.toasts {
  position: fixed; top: 14px; right: 14px; z-index: 100;
  display: flex; flex-direction: column; gap: 8px; width: min(360px, calc(100vw - 28px));
}
.toast {
  background: #fff; border: 1px solid var(--border); border-left: 3px solid var(--accent);
  border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 11px 13px;
  display: flex; gap: 10px; align-items: flex-start;
  animation: toastIn .26s cubic-bezier(.2,.9,.3,1.2);
}
.toast.leaving { animation: toastOut .2s ease forwards; }
@keyframes toastIn { from { opacity: 0; transform: translateX(24px); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateX(24px); } }
.toast-success { border-left-color: var(--green); }
.toast-success .toast-icon { color: var(--green); }
.toast-error { border-left-color: var(--red); }
.toast-error .toast-icon { color: var(--red); }
.toast-warn { border-left-color: var(--amber); }
.toast-warn .toast-icon { color: var(--amber); }
.toast-icon { color: var(--accent); margin-top: 1px; }
.toast-body { flex: 1; min-width: 0; }
.toast-title { font-size: 13.5px; font-weight: 700; }
.toast-msg { font-size: 12.5px; color: var(--muted); margin-top: 2px; word-break: break-word; }

/* empty / loading */
.empty { text-align: center; padding: 46px 20px; }
.empty-icon {
  width: 52px; height: 52px; border-radius: 16px; margin: 0 auto 14px;
  background: var(--surface-2); color: var(--muted); display: grid; place-items: center;
}
.empty-title { font-size: 15.5px; font-weight: 700; }
.empty-desc { font-size: 13.5px; color: var(--muted); margin-top: 5px; max-width: 380px; margin-inline: auto; }
.empty-action { margin-top: 16px; }

.skeleton {
  background: linear-gradient(90deg, var(--surface-2) 25%, #f0efed 37%, var(--surface-2) 63%);
  background-size: 400% 100%; animation: skeleton 1.3s ease infinite; border-radius: var(--radius-sm);
}
@keyframes skeleton { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }
.skel-line { height: 13px; margin-bottom: 9px; }
.skel-card { height: 96px; border-radius: var(--radius-lg); }

.spinner { width: 18px; height: 18px; animation: spin .9s linear infinite; color: var(--accent); }
.loading-row { display: flex; align-items: center; gap: 9px; color: var(--muted); font-size: 13.5px; padding: 14px; justify-content: center; }

/* project cards */
.project-card {
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius-lg);
  overflow: hidden; box-shadow: var(--shadow-sm); cursor: pointer;
  transition: box-shadow .16s ease, transform .16s ease, border-color .16s ease;
  display: flex; flex-direction: column;
}
.project-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); border-color: #dedddb; }
.thumb {
  aspect-ratio: 9 / 16; background: var(--surface-2); position: relative; overflow: hidden;
  display: grid; place-items: center; color: var(--muted);
}
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb-badge {
  position: absolute; right: 8px; bottom: 8px; background: rgba(0,0,0,.72); color: #fff;
  border-radius: 6px; padding: 2px 7px; font-size: 11.5px; font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.project-body { padding: 12px 13px 13px; flex: 1; display: flex; flex-direction: column; gap: 6px; }
.project-title { font-size: 14.5px; font-weight: 700; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.project-meta { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); margin-top: auto; flex-wrap: wrap; }

/* source rows */
.source-item { display: flex; gap: 12px; padding: 12px; border: 1px solid var(--border); border-radius: var(--radius); background: #fff; align-items: flex-start; }
.source-thumb { width: 92px; aspect-ratio: 16/9; border-radius: var(--radius-sm); background: var(--surface-2); object-fit: cover; flex-shrink: 0; }
.source-main { flex: 1; min-width: 0; }
.source-title { font-size: 14px; font-weight: 600; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.source-meta { font-size: 12px; color: var(--muted); margin-top: 4px; display: flex; gap: 10px; flex-wrap: wrap; }

/* video preview */
.video-wrap { background: #171614; border-radius: var(--radius-lg); overflow: hidden; display: grid; place-items: center; }
.video-wrap video { width: 100%; max-height: 72vh; display: block; }

/* toolbar */
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.search-box { position: relative; flex: 1; min-width: 190px; }
.search-box svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.search-box .input { padding-left: 34px; }

/* pagination */
.pagination { display: flex; gap: 6px; align-items: center; justify-content: center; margin-top: 18px; flex-wrap: wrap; }
.page-btn {
  min-width: 34px; height: 34px; padding: 0 9px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: #fff; font-size: 13.5px; font-weight: 600;
  cursor: pointer; display: grid; place-items: center;
}
.page-btn:hover:not(:disabled) { background: var(--surface-2); }
.page-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.page-btn:disabled { opacity: .4; cursor: not-allowed; }
.page-info { font-size: 13px; color: var(--muted); margin: 0 8px; font-variant-numeric: tabular-nums; }

/* tabs */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 16px; overflow-x: auto; }
.tab {
  padding: 9px 13px; font-size: 14px; font-weight: 600; color: var(--muted);
  cursor: pointer; border-bottom: 2px solid transparent; white-space: nowrap;
  transition: color .12s ease, border-color .12s ease;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--accent-strong); border-bottom-color: var(--accent); }

/* modal */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(15,15,15,.42); z-index: 110;
  display: grid; place-items: center; padding: 18px;
  animation: fadeIn .16s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: #fff; border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  width: min(520px, 100%); max-height: 86vh; overflow-y: auto; padding: 20px;
  animation: modalIn .22s cubic-bezier(.2,.9,.3,1.1);
}
@keyframes modalIn { from { opacity: 0; transform: translateY(14px) scale(.97); } to { opacity: 1; transform: none; } }
.modal-title { font-size: 17px; font-weight: 700; margin-bottom: 6px; }
.modal-desc { font-size: 13.5px; color: var(--muted); margin-bottom: 16px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; }

/* status dot */
.status-line { display: flex; align-items: center; gap: 8px; font-size: 13px; padding: 9px 12px; border-radius: var(--radius); background: var(--surface-2); }
.status-line.ok { background: var(--green-soft); color: var(--green); }
.status-line.err { background: var(--red-soft); color: var(--red); }
.status-line.warn { background: var(--amber-soft); color: var(--amber); }

.kv { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; border-bottom: 1px solid var(--border); font-size: 13.5px; }
.kv:last-child { border-bottom: none; }
.kv-key { color: var(--muted); }
.kv-val { font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; word-break: break-word; }

.log-view {
  background: #1f1e1c; color: #e6e4e0; border-radius: var(--radius); padding: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px;
  line-height: 1.65; max-height: 340px; overflow-y: auto; white-space: pre-wrap; word-break: break-word;
}
.log-line.error { color: #ff9b8f; }
.log-line.warn { color: #ffd48a; }
.log-line.success { color: #8ee0b7; }

.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.strong { font-weight: 700; }
.nowrap { white-space: nowrap; }
.text-right { text-align: right; }
.flex { display: flex; }
.items-center { align-items: center; }
.gap-6 { gap: 6px; } .gap-8 { gap: 8px; } .gap-12 { gap: 12px; }
.mt-8 { margin-top: 8px; } .mt-12 { margin-top: 12px; } .mt-16 { margin-top: 16px; } .mt-24 { margin-top: 24px; }
.mb-8 { margin-bottom: 8px; } .mb-12 { margin-bottom: 12px; } .mb-16 { margin-bottom: 16px; }
.hidden { display: none !important; }

/* login */
.login-page {
  min-height: 100vh; min-height: 100dvh; display: grid; place-items: center;
  padding: 20px; background: linear-gradient(170deg, #fdfcfa, #f6f5f2 60%, #f1efeb);
}
.login-card {
  width: min(400px, 100%); background: #fff; border: 1px solid var(--border);
  border-radius: 18px; padding: 30px 26px; box-shadow: var(--shadow-md);
}
.login-brand { display: flex; flex-direction: column; align-items: center; gap: 12px; margin-bottom: 22px; }
.login-brand .brand-mark { width: 46px; height: 46px; border-radius: 13px; }
.login-title { font-size: 21px; font-weight: 800; letter-spacing: -.02em; }
.login-sub { font-size: 13.5px; color: var(--muted); text-align: center; }
.login-error {
  background: var(--red-soft); color: var(--red); border-radius: var(--radius);
  padding: 9px 12px; font-size: 13px; font-weight: 600; margin-bottom: 14px;
  display: flex; align-items: center; gap: 8px;
}
.login-foot { text-align: center; margin-top: 18px; font-size: 12px; color: var(--muted); }

/* drawer (mobile) */
.drawer-backdrop {
  position: fixed; inset: 0; background: rgba(15,15,15,.35); z-index: 55;
  opacity: 0; pointer-events: none; transition: opacity .2s ease;
}
body.drawer-open .drawer-backdrop { opacity: 1; pointer-events: auto; }

@media (max-width: 860px) {
  .sidebar {
    position: fixed; left: 0; top: 0; height: 100dvh;
    transform: translateX(-102%); transition: transform .24s cubic-bezier(.3,.8,.3,1);
    width: 268px; flex-basis: 268px; box-shadow: var(--shadow-lg);
  }
  body.drawer-open .sidebar { transform: none; }
  body.sidebar-collapsed .sidebar { width: 268px; flex-basis: 268px; }
  body.sidebar-collapsed .nav-text, body.sidebar-collapsed .nav-badge,
  body.sidebar-collapsed .brand-text, body.sidebar-collapsed .user-meta,
  body.sidebar-collapsed .sidebar-foot form { display: block; }
  body.sidebar-collapsed .nav-item { justify-content: flex-start; padding: 7px 10px; }
  body.sidebar-collapsed .nav-label { opacity: 1; height: auto; padding: 6px 10px 4px; }
  body.sidebar-collapsed .user-chip { justify-content: flex-start; padding: 7px 8px; }
  .hamburger { display: grid; }
  .sidebar-collapse-btn { display: none; }
  .content { padding: 16px 14px 130px; }
  .page-title { font-size: 21px; }
  .grid-3, .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-2 { grid-template-columns: 1fr; }
  .grid-auto { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
  .topbar { padding: 0 12px; }
  .toasts { top: auto; bottom: max(84px, calc(env(safe-area-inset-bottom) + 78px)); right: 12px; left: 12px; width: auto; }
  .modal { padding: 17px; }
}
@media (max-width: 520px) {
  .grid-3, .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat-value { font-size: 21px; }
  .source-thumb { width: 74px; }
  .btn { padding: 8px 12px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}
