/* ===== ShortsScript — modern dark UI ===== */
:root {
  --bg: #0b0d12;
  --bg-soft: #10131b;
  --panel: #151926;
  --panel-2: #1a2032;
  --border: rgba(255, 255, 255, .08);
  --border-strong: rgba(255, 255, 255, .14);
  --text: #eef1f8;
  --text-dim: #9aa3b8;
  --text-faint: #626c85;
  --accent: #ff4d5a;
  --accent-2: #ff7a59;
  --accent-grad: linear-gradient(135deg, #ff4d5a, #ff7a59);
  --ok: #34d399;
  --warn: #fbbf24;
  --err: #f87171;
  --radius: 14px;
  --shadow: 0 12px 32px rgba(0, 0, 0, .45);
  --sidebar-w: 300px;
  --drawer-w: min(520px, 92vw);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  font-family: Pretendard Variable, Pretendard, -apple-system, BlinkMacSystemFont, "Segoe UI", "Malgun Gothic", sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
#app { display: flex; height: 100vh; }
button { font: inherit; color: inherit; cursor: pointer; background: none; border: none; }
input { font: inherit; }
code { font-family: ui-monospace, Consolas, monospace; font-size: .85em; color: var(--text-dim); }

/* ===== scrollbar ===== */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #2a3147; border-radius: 8px; border: 2px solid var(--bg); }
::-webkit-scrollbar-track { background: transparent; }

/* ===== sidebar ===== */
.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 20px 16px;
  background: var(--bg-soft);
  border-right: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 12px; padding: 2px 4px; }
.brand-logo {
  width: 38px; height: 38px; border-radius: 11px;
  background: var(--accent-grad);
  display: grid; place-items: center;
  font-size: 15px; color: #fff;
  box-shadow: 0 6px 18px rgba(255, 77, 90, .35);
}
.brand-name { font-weight: 800; font-size: 17px; letter-spacing: -.02em; }
.brand-sub { font-size: 11.5px; color: var(--text-faint); margin-top: 1px; }

.add-channel, .single-fetch { display: flex; gap: 8px; }
.add-channel input, .single-fetch input {
  flex: 1;
  min-width: 0;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 11px;
  padding: 10px 13px;
  color: var(--text);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.add-channel input:focus, .single-fetch input:focus {
  border-color: rgba(255, 77, 90, .55);
  box-shadow: 0 0 0 3px rgba(255, 77, 90, .15);
}
.add-channel input::placeholder, .single-fetch input::placeholder { color: var(--text-faint); }
.add-channel button, .single-fetch button {
  width: 42px; border-radius: 11px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  display: grid; place-items: center;
  color: var(--text-dim);
  transition: all .15s;
}
.add-channel button {
  background: var(--accent-grad); color: #fff; border: none;
  box-shadow: 0 4px 14px rgba(255, 77, 90, .3);
}
.add-channel button:hover { filter: brightness(1.1); }
.single-fetch button:hover { color: var(--text); border-color: var(--border-strong); }
.add-channel button:disabled { opacity: .5; cursor: wait; }

.channel-list { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; margin: 0 -4px; padding: 0 4px; }
.channel-item {
  display: flex; align-items: center; gap: 11px;
  padding: 10px;
  border-radius: 12px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background .15s, border-color .15s;
  position: relative;
}
.channel-item:hover { background: var(--panel); }
.channel-item.active { background: var(--panel-2); border-color: var(--border); }
.channel-item img { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; background: var(--panel-2); }
.channel-item .ci-name { font-size: 13.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.channel-item .ci-sub { font-size: 11.5px; color: var(--text-faint); margin-top: 2px; }
.channel-item .ci-del {
  margin-left: auto;
  color: var(--text-faint);
  width: 28px; height: 28px; border-radius: 8px;
  display: grid; place-items: center;
  opacity: 0; transition: all .15s;
}
.channel-item:hover .ci-del { opacity: 1; }
.channel-item .ci-del:hover { color: var(--err); background: rgba(248, 113, 113, .12); }
.channel-item .ci-spin {
  margin-left: auto;
  width: 14px; height: 14px;
  border: 2px solid var(--border-strong);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.channel-list-empty { text-align: center; color: var(--text-faint); font-size: 12.5px; padding: 30px 10px; line-height: 1.6; }
.sidebar-foot { font-size: 11px; color: var(--text-faint); text-align: center; padding-top: 8px; border-top: 1px solid var(--border); }

/* ===== main ===== */
.main { flex: 1; min-width: 0; display: flex; }
.main-scroll { flex: 1; overflow-y: auto; padding: 34px 40px 80px; }

.empty-state { text-align: center; margin-top: 16vh; }
.empty-icon { font-size: 56px; margin-bottom: 18px; }
.empty-state h1 { font-size: 30px; font-weight: 800; letter-spacing: -.03em; }
.empty-state p { color: var(--text-dim); margin-top: 12px; line-height: 1.7; }

/* ===== channel header ===== */
.channel-header { display: flex; align-items: center; gap: 18px; margin-bottom: 22px; }
.channel-avatar {
  width: 72px; height: 72px; border-radius: 50%;
  object-fit: cover; background: var(--panel-2);
  border: 2px solid var(--border-strong);
}
.channel-info { flex: 1; min-width: 0; }
.channel-info h1 { font-size: 26px; font-weight: 800; letter-spacing: -.02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.channel-meta { color: var(--text-dim); font-size: 13px; margin-top: 6px; display: flex; gap: 14px; flex-wrap: wrap; }
.channel-meta b { color: var(--text); }
.channel-actions { display: flex; gap: 8px; align-items: center; }

.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 15px;
  border-radius: 11px;
  font-size: 13px; font-weight: 600;
  transition: all .15s;
  white-space: nowrap;
}
.btn.ghost { background: var(--panel); border: 1px solid var(--border); color: var(--text-dim); }
.btn.ghost:hover { color: var(--text); border-color: var(--border-strong); background: var(--panel-2); }
.btn.primary { background: var(--accent-grad); color: #fff; border: none; box-shadow: 0 4px 14px rgba(255, 77, 90, .3); }
.btn.tiny { padding: 5px 10px; font-size: 12px; border-radius: 8px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.dropdown { position: relative; }
.dropdown-menu {
  position: absolute; right: 0; top: calc(100% + 6px);
  background: var(--panel-2);
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  box-shadow: var(--shadow);
  min-width: 200px;
  padding: 6px;
  z-index: 40;
  display: none;
}
.dropdown-menu.open { display: block; }
.dropdown-menu button {
  display: block; width: 100%; text-align: left;
  padding: 9px 12px; border-radius: 8px;
  font-size: 13px; color: var(--text-dim);
}
.dropdown-menu button:hover { background: rgba(255, 255, 255, .06); color: var(--text); }

/* ===== toolbar ===== */
.toolbar { display: flex; align-items: center; gap: 14px; margin-bottom: 20px; flex-wrap: wrap; }
.searchbox {
  flex: 1; min-width: 220px; max-width: 420px;
  display: flex; align-items: center; gap: 9px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 11px;
  padding: 0 13px;
  color: var(--text-faint);
  transition: border-color .15s;
}
.searchbox:focus-within { border-color: var(--border-strong); }
.searchbox input { flex: 1; background: none; border: none; outline: none; color: var(--text); padding: 10px 0; }
.filter-tabs { display: flex; gap: 4px; background: var(--panel); border: 1px solid var(--border); border-radius: 11px; padding: 3px; }
.filter-tabs .tab { padding: 7px 13px; border-radius: 8px; font-size: 12.5px; font-weight: 600; color: var(--text-faint); transition: all .15s; }
.filter-tabs .tab.active { background: var(--panel-2); color: var(--text); }
.filter-tabs .tab .n { opacity: .6; font-weight: 500; margin-left: 3px; }
.stats { font-size: 12.5px; color: var(--text-faint); margin-left: auto; }
.stats b { color: var(--text); }

/* ===== sync progress ===== */
.sync-progress {
  display: flex; align-items: center; gap: 14px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 11px 16px;
  margin-bottom: 18px;
}
.sync-progress-text { font-size: 13px; color: var(--text-dim); display: flex; gap: 10px; min-width: 0; }
.sync-progress-text #syncLabel { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sync-progress-text #syncCount { color: var(--text); font-weight: 700; white-space: nowrap; }
.bar { flex: 1; height: 7px; background: var(--panel-2); border-radius: 6px; overflow: hidden; }
.bar-fill {
  height: 100%; width: 0%;
  background: var(--accent-grad);
  border-radius: 6px;
  transition: width .4s ease;
}

/* ===== video grid ===== */
.video-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
  gap: 16px;
}
.video-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: transform .18s ease, border-color .18s, box-shadow .18s;
  animation: cardIn .3s ease both;
}
@keyframes cardIn { from { opacity: 0; transform: translateY(8px); } }
.video-card:hover {
  transform: translateY(-3px);
  border-color: var(--border-strong);
  box-shadow: var(--shadow);
}
.video-card.selected { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent), var(--shadow); }
.vc-thumb { position: relative; aspect-ratio: 9 / 12.6; background: var(--panel-2); }
.vc-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.vc-dur {
  position: absolute; right: 7px; bottom: 7px;
  background: rgba(0, 0, 0, .75);
  font-size: 11px; font-weight: 700;
  padding: 2.5px 6px; border-radius: 6px;
}
.vc-badge {
  position: absolute; left: 7px; top: 7px;
  font-size: 10.5px; font-weight: 700;
  padding: 3px 8px; border-radius: 20px;
  backdrop-filter: blur(6px);
}
.vc-badge.ok { background: rgba(52, 211, 153, .18); color: var(--ok); border: 1px solid rgba(52, 211, 153, .35); }
.vc-badge.no { background: rgba(248, 113, 113, .15); color: var(--err); border: 1px solid rgba(248, 113, 113, .3); }
.vc-badge.pend { background: rgba(251, 191, 36, .15); color: var(--warn); border: 1px solid rgba(251, 191, 36, .3); }
.vc-body { padding: 10px 12px 12px; }
.vc-title {
  font-size: 12.8px; font-weight: 600; line-height: 1.45;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  min-height: 37px;
}
.vc-views { font-size: 11.5px; color: var(--text-faint); margin-top: 6px; }

.grid-empty { text-align: center; color: var(--text-faint); padding: 60px 0; font-size: 14px; }

/* ===== search results ===== */
.search-results { display: flex; flex-direction: column; gap: 8px; margin-bottom: 20px; }
.sr-head { display: flex; align-items: center; justify-content: space-between; color: var(--text-dim); font-size: 13px; padding: 2px 4px; }
.sr-head button { color: var(--text-faint); font-size: 12px; }
.sr-head button:hover { color: var(--text); }
.sr-item {
  text-align: left;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 15px;
  transition: border-color .15s;
}
.sr-item:hover { border-color: var(--border-strong); }
.sr-title { font-size: 13.5px; font-weight: 700; }
.sr-snippet { font-size: 12.5px; color: var(--text-dim); margin-top: 5px; line-height: 1.55; }
.sr-snippet mark { background: rgba(255, 77, 90, .25); color: #ffd7db; border-radius: 3px; padding: 0 2px; }

/* ===== drawer ===== */
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: var(--drawer-w);
  background: var(--bg-soft);
  border-left: 1px solid var(--border);
  z-index: 60;
  transform: translateX(102%);
  transition: transform .28s cubic-bezier(.4, 0, .2, 1);
  display: flex;
}
.drawer.open { transform: translateX(0); }
.drawer-inner { flex: 1; overflow-y: auto; padding: 26px 26px 60px; }
.drawer-backdrop {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, .5);
  z-index: 55;
  opacity: 0; pointer-events: none;
  transition: opacity .25s;
}
.drawer-backdrop.open { opacity: 1; pointer-events: auto; }

.dw-close {
  position: sticky; top: 0; float: right;
  width: 34px; height: 34px; border-radius: 10px;
  background: var(--panel-2); border: 1px solid var(--border);
  color: var(--text-dim);
  display: grid; place-items: center;
  z-index: 2;
}
.dw-close:hover { color: var(--text); border-color: var(--border-strong); }
.dw-title { font-size: 19px; font-weight: 800; letter-spacing: -.02em; line-height: 1.4; margin: 4px 44px 10px 0; }
.dw-link { font-size: 12.5px; color: var(--accent); text-decoration: none; }
.dw-link:hover { text-decoration: underline; }
.dw-meta { display: flex; flex-wrap: wrap; gap: 7px; margin: 14px 0; }
.chip {
  font-size: 11.5px; font-weight: 600;
  color: var(--text-dim);
  background: var(--panel);
  border: 1px solid var(--border);
  padding: 5px 10px; border-radius: 20px;
}
.chip.accent { color: #ffb3b9; background: rgba(255, 77, 90, .1); border-color: rgba(255, 77, 90, .3); }
.chip.ok { color: var(--ok); }
.dw-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 18px 0 6px; }
.dw-sep { height: 1px; background: var(--border); margin: 18px 0; }
.dw-section-label { font-size: 12px; font-weight: 700; color: var(--text-faint); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 10px; }
.dw-fulltext {
  font-size: 14px; line-height: 1.85; color: #cfd6e4;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px;
  white-space: pre-wrap;
  word-break: keep-all;
}
.segments { display: flex; flex-direction: column; gap: 2px; }
.seg {
  display: flex; gap: 12px;
  padding: 8px 10px;
  border-radius: 9px;
  transition: background .12s;
  align-items: baseline;
}
.seg:hover { background: var(--panel); }
.seg-time {
  flex-shrink: 0;
  font-family: ui-monospace, Consolas, monospace;
  font-size: 11.5px; font-weight: 600;
  color: var(--accent);
  cursor: pointer;
  opacity: .85;
}
.seg-time:hover { opacity: 1; text-decoration: underline; }
.seg-text { font-size: 13.5px; line-height: 1.65; color: #cfd6e4; word-break: keep-all; }

/* ===== modal (preview) ===== */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, .6);
  z-index: 70;
  display: grid; place-items: center;
  padding: 24px;
}
.modal {
  width: min(680px, 100%);
  max-height: 86vh;
  overflow-y: auto;
  background: var(--bg-soft);
  border: 1px solid var(--border-strong);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 26px;
  animation: modalIn .22s ease;
}
@keyframes modalIn { from { opacity: 0; transform: scale(.97); } }
.modal .dw-close { position: absolute; }
.modal-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 16px; }

/* ===== toasts ===== */
.toasts {
  position: fixed; bottom: 22px; left: 50%;
  transform: translateX(-50%);
  display: flex; flex-direction: column; gap: 8px;
  z-index: 90;
  align-items: center;
}
.toast {
  background: var(--panel-2);
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 11px 18px;
  font-size: 13px; font-weight: 600;
  color: var(--text);
  animation: toastIn .25s ease;
  max-width: 90vw;
}
.toast.err { border-color: rgba(248, 113, 113, .5); color: #ffb4b4; }
.toast.ok { border-color: rgba(52, 211, 153, .5); color: #a7f3d0; }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } }

/* skeleton */
.skeleton { border-radius: var(--radius); background: linear-gradient(100deg, var(--panel) 40%, var(--panel-2) 50%, var(--panel) 60%); background-size: 200% 100%; animation: shimmer 1.2s infinite; aspect-ratio: 9 / 14; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ===== responsive ===== */
@media (max-width: 900px) {
  #app { flex-direction: column; }
  .sidebar { width: 100%; min-width: 0; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 12px 14px; }
  .brand { padding: 0; }
  .add-channel { flex: 1; min-width: 200px; }
  .single-fetch { display: none; }
  .channel-list { flex-direction: row; overflow-x: auto; overflow-y: hidden; margin: 0; }
  .channel-item { flex-shrink: 0; }
  .sidebar-foot { display: none; }
  .main-scroll { padding: 20px 16px 60px; }
  .channel-header { flex-wrap: wrap; }
  .channel-actions { width: 100%; }
}
