/* ============================================================
   YouTube 분석 — 디자인 시스템
   ============================================================ */
:root {
  --bg: #08090c;
  --bg-elev: #0e1015;
  --panel: #111319;
  --panel-2: #151821;
  --line: #1e222c;
  --line-soft: #191d25;
  --txt: #e8ebf2;
  --txt-dim: #9aa2b4;
  --txt-faint: #6b7385;
  --acc: #ff3d3d;
  --acc-soft: rgba(255, 61, 61, 0.12);
  --pos: #3ddc97;
  --pos-soft: rgba(61, 220, 151, 0.12);
  --warn: #f5b544;
  --warn-soft: rgba(245, 181, 68, 0.12);
  --sky: #5aa9ff;
  --sky-soft: rgba(90, 169, 255, 0.12);
  --radius: 12px;
  --shadow: 0 18px 45px rgba(0, 0, 0, 0.45);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--txt);
  font-family: Pretendard, -apple-system, BlinkMacSystemFont, "Segoe UI", "Apple SD Gothic Neo",
    "Malgun Gothic", "Noto Sans KR", sans-serif;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

body { padding-bottom: 64px; }

a { color: inherit; text-decoration: none; }

button, input, select {
  font-family: inherit;
  font-size: 13px;
  color: inherit;
}

.num { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }

/* ---------------------------------------------------------- layout */
.wrap { max-width: 1520px; margin: 0 auto; padding: 0 24px; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(8, 9, 12, 0.86);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  display: flex;
  align-items: center;
  gap: 20px;
  height: 60px;
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 210px; }
.brand-mark {
  width: 30px; height: 30px; border-radius: 9px;
  background: linear-gradient(145deg, #ff5151, #cb1f1f);
  display: grid; place-items: center;
  box-shadow: 0 4px 14px rgba(255, 61, 61, 0.28);
}
.brand-mark svg { width: 16px; height: 16px; color: #fff; }
.brand-title { font-size: 14.5px; font-weight: 700; letter-spacing: -0.01em; line-height: 1.1; }
.brand-sub { font-size: 10.5px; color: var(--txt-faint); letter-spacing: 0.04em; }

.nav {
  display: flex;
  gap: 2px;
  padding: 3px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
}
.nav button {
  border: 0; background: transparent; color: var(--txt-dim);
  padding: 7px 14px; border-radius: 7px; cursor: pointer;
  font-size: 13px; font-weight: 600; white-space: nowrap;
  display: inline-flex; align-items: center; gap: 6px;
  transition: background 0.15s, color 0.15s;
}
.nav button:hover { color: var(--txt); }
.nav button.active { background: var(--panel-2); color: #fff; box-shadow: inset 0 0 0 1px var(--line); }
.nav button .pill {
  font-size: 11px; font-weight: 700; padding: 1px 6px; border-radius: 20px;
  background: var(--acc-soft); color: #ff7b7b;
}

.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.stamp { font-size: 11.5px; color: var(--txt-faint); }
.stamp b { color: var(--txt-dim); font-weight: 600; }

/* ---------------------------------------------------------- buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 32px; padding: 0 12px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--panel-2); color: var(--txt);
  font-size: 12.5px; font-weight: 600; cursor: pointer;
  transition: background 0.15s, border-color 0.15s, opacity 0.15s;
  white-space: nowrap;
}
.btn:hover { background: #1b1f29; border-color: #2a3040; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn svg { width: 15px; height: 15px; }
.btn-primary { background: var(--acc); border-color: #e03232; color: #fff; }
.btn-primary:hover { background: #ff5252; border-color: #ff5252; }
.btn-ghost { background: transparent; }
.btn-xs { height: 26px; padding: 0 8px; font-size: 11.5px; border-radius: 6px; }
.btn-icon { width: 32px; padding: 0; }

/* ---------------------------------------------------------- controls */
.field {
  height: 32px; padding: 0 10px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
  color: var(--txt); font-size: 12.5px; outline: none;
}
.field:focus { border-color: #39425a; box-shadow: 0 0 0 3px rgba(90, 169, 255, 0.1); }
select.field { appearance: none; padding-right: 26px; cursor: pointer;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7385' stroke-width='2.5'><path d='M6 9l6 6 6-6'/></svg>");
  background-repeat: no-repeat; background-position: right 9px center;
}
input[type="date"].field { color-scheme: dark; }
input[type="date"].field::-webkit-calendar-picker-indicator { filter: invert(0.6); cursor: pointer; }

.seg { display: inline-flex; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 2px; }
.seg button {
  border: 0; background: transparent; color: var(--txt-dim); cursor: pointer;
  height: 26px; padding: 0 10px; border-radius: 6px; font-size: 12px; font-weight: 600;
}
.seg button:hover { color: var(--txt); }
.seg button.active { background: var(--panel-2); color: #fff; box-shadow: inset 0 0 0 1px var(--line); }

/* ---------------------------------------------------------- cards */
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.section-head {
  display: flex; align-items: center; gap: 10px;
  margin: 26px 0 12px;
}
.section-head h2 { margin: 0; font-size: 15px; font-weight: 700; letter-spacing: -0.01em; }
.section-head .hint { font-size: 12px; color: var(--txt-faint); }
.section-head .spacer { flex: 1; }

/* ---------------------------------------------------------- KPI */
.kpis { display: grid; grid-template-columns: repeat(6, 1fr); gap: 10px; }
.kpi {
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  padding: 12px 14px;
}
.kpi-label { font-size: 11.5px; color: var(--txt-faint); display: flex; align-items: center; gap: 5px; }
.kpi-value { font-size: 20px; font-weight: 700; letter-spacing: -0.02em; margin-top: 4px; }
.kpi-sub { font-size: 11px; color: var(--txt-faint); margin-top: 2px; }
.kpi-value small { font-size: 12px; font-weight: 600; color: var(--txt-dim); margin-left: 2px; }

/* ---------------------------------------------------------- toolbar */
.toolbar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 10px 12px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
}
.toolbar .divider { width: 1px; height: 20px; background: var(--line); margin: 0 2px; }
.toolbar .grow { flex: 1; }
.search-wrap { position: relative; }
.search-wrap svg { position: absolute; left: 9px; top: 9px; width: 14px; height: 14px; color: var(--txt-faint); }
.search-wrap input { padding-left: 29px; width: 220px; }

/* ---------------------------------------------------------- table */
.table-wrap {
  margin-top: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.table-scroll { overflow-x: auto; }
table.grid { width: 100%; border-collapse: separate; border-spacing: 0; }
table.grid thead th {
  position: sticky; top: 60px; z-index: 5;
  background: #0f1218;
  color: var(--txt-faint);
  font-size: 11px; font-weight: 600; letter-spacing: 0.03em;
  text-align: left; padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
table.grid thead th.sortable { cursor: pointer; user-select: none; }
table.grid thead th.sortable:hover { color: var(--txt-dim); }
table.grid thead th.active { color: var(--txt); }
table.grid thead th .arrow { font-size: 9px; margin-left: 3px; opacity: 0.8; }
table.grid tbody tr { cursor: pointer; }
table.grid tbody tr:hover { background: #141821; }
table.grid tbody td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: middle;
  white-space: nowrap;
}
table.grid tbody tr:last-child td { border-bottom: 0; }
td.r, th.r { text-align: right; }
td.title-cell { white-space: normal; min-width: 260px; max-width: 420px; }
.v-title {
  font-size: 13px; font-weight: 600; line-height: 1.35; color: #eef1f7;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.v-meta { font-size: 11px; color: var(--txt-faint); margin-top: 3px; display: flex; gap: 6px; align-items: center; }

.chip {
  display: inline-flex; align-items: center; gap: 5px;
  height: 21px; padding: 0 8px; border-radius: 20px;
  font-size: 11.5px; font-weight: 600;
  background: var(--panel-2); border: 1px solid var(--line); color: var(--txt-dim);
}
.chip .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--sky); flex: none; }
.chip .nm { max-width: 170px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip.red .dot { background: var(--acc); }
.chip.green { background: var(--pos-soft); border-color: rgba(61, 220, 151, 0.22); color: var(--pos); }
.chip.amber { background: var(--warn-soft); border-color: rgba(245, 181, 68, 0.22); color: var(--warn); }
.chip.muted { background: transparent; color: var(--txt-faint); }
.chip.solid { background: var(--panel-2); }

.thumb { position: relative; display: block; border-radius: 6px; overflow: hidden; background: #0a0c10; }
.thumb img { display: block; width: 100%; height: 100%; object-fit: cover; }
.thumb-16 { width: 68px; height: 38px; }
.thumb-9x16 { width: 30px; height: 53px; }
.thumb .dur {
  position: absolute; right: 3px; bottom: 3px;
  background: rgba(0, 0, 0, 0.82); color: #fff; font-size: 9.5px; font-weight: 600;
  padding: 1px 3px; border-radius: 3px;
}
.thumb-pair { display: flex; gap: 4px; align-items: center; }

.mult { font-weight: 700; font-size: 12.5px; }
.mult.hot { color: var(--pos); }
.mult.cold { color: #ff7b7b; }
.mult.mid { color: var(--txt-dim); }

.bar { height: 4px; border-radius: 4px; background: var(--line); overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--sky); border-radius: 4px; }

.empty {
  padding: 56px 20px; text-align: center; color: var(--txt-faint); font-size: 13px;
}
.empty b { color: var(--txt-dim); }

/* pagination */
.pager {
  display: flex; align-items: center; gap: 6px;
  padding: 10px 12px; border-top: 1px solid var(--line-soft);
  background: #0f1218;
}
.pager .info { font-size: 11.5px; color: var(--txt-faint); margin-right: auto; }
.pager button {
  min-width: 28px; height: 28px; padding: 0 8px; border-radius: 6px;
  background: transparent; border: 1px solid transparent; color: var(--txt-dim);
  font-size: 12px; font-weight: 600; cursor: pointer;
}
.pager button:hover:not(:disabled) { background: var(--panel-2); color: var(--txt); }
.pager button.active { background: var(--panel-2); color: #fff; border-color: var(--line); }
.pager button:disabled { opacity: 0.35; cursor: default; }

/* ---------------------------------------------------------- channels */
.add-panel { padding: 16px; display: flex; gap: 14px; align-items: flex-start; flex-wrap: wrap; }
.add-panel .form { display: flex; gap: 8px; flex: 1; min-width: 320px; }
.add-panel .form input { flex: 1; height: 38px; font-size: 13px; }
.add-panel .form .btn { height: 38px; padding: 0 16px; }
.add-title { font-size: 13.5px; font-weight: 700; margin-bottom: 3px; }
.add-hint { font-size: 11.5px; color: var(--txt-faint); }
.add-status { font-size: 12px; color: var(--txt-dim); margin-top: 8px; min-height: 16px; }
.add-status.error { color: #ff7b7b; }
.progress { height: 3px; background: var(--line); border-radius: 4px; overflow: hidden; margin-top: 8px; width: 100%; }
.progress > i { display: block; height: 100%; width: 0; background: var(--acc); transition: width 0.25s; }

.ch-table td { vertical-align: middle; }
.ch-avatar { width: 34px; height: 34px; border-radius: 50%; object-fit: cover; background: var(--panel-2); }
.ch-name { font-size: 13.5px; font-weight: 700; }
.ch-handle { font-size: 11px; color: var(--txt-faint); }
.mini-bar { height: 6px; border-radius: 4px; background: var(--line); overflow: hidden; display: flex; }
.mini-bar i { display: block; height: 100%; }

.chart-box { padding: 14px 16px 6px; }
.chart-box h3 { margin: 0 0 2px; font-size: 13px; font-weight: 700; }
.chart-box p { margin: 0 0 10px; font-size: 11.5px; color: var(--txt-faint); }
.chart-canvas { height: 190px; position: relative; }

/* ---------------------------------------------------------- drawer */
.scrim {
  position: fixed; inset: 0; background: rgba(4, 5, 8, 0.62);
  opacity: 0; pointer-events: none; transition: opacity 0.2s; z-index: 60;
}
.scrim.on { opacity: 1; pointer-events: auto; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: 480px; max-width: 94vw;
  background: var(--bg-elev); border-left: 1px solid var(--line);
  z-index: 61; transform: translateX(102%); transition: transform 0.24s ease;
  display: flex; flex-direction: column; box-shadow: var(--shadow);
}
.drawer.on { transform: none; }
.drawer-head {
  display: flex; align-items: center; gap: 8px;
  padding: 14px 16px; border-bottom: 1px solid var(--line);
}
.drawer-body { overflow-y: auto; padding: 16px; }
.drawer-foot { padding: 12px 16px; border-top: 1px solid var(--line); display: flex; gap: 8px; }
.d-title { font-size: 15px; font-weight: 700; line-height: 1.4; }
.d-sub { font-size: 12px; color: var(--txt-faint); margin-top: 6px; display: flex; gap: 8px; flex-wrap: wrap; }
.d-kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 16px; }
.d-kpi { background: var(--panel); border: 1px solid var(--line); border-radius: 9px; padding: 10px 12px; }
.d-kpi .l { font-size: 11px; color: var(--txt-faint); }
.d-kpi .v { font-size: 17px; font-weight: 700; margin-top: 2px; }
.d-block { margin-top: 18px; }
.d-block h4 { margin: 0 0 8px; font-size: 12px; color: var(--txt-dim); font-weight: 700; letter-spacing: 0.02em; }
.d-media { display: flex; gap: 10px; }
.d-media .frame { border-radius: 8px; overflow: hidden; background: #000; }
.d-media .f16 { flex: 1; aspect-ratio: 16 / 9; }
.d-media .f9 { width: 104px; aspect-ratio: 9 / 16; }
.d-media img { width: 100%; height: 100%; object-fit: cover; display: block; }
.meter-row { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; font-size: 12px; }
.meter-row .k { width: 74px; color: var(--txt-faint); }
.meter-row .bar { flex: 1; height: 6px; }
.meter-row .v { width: 62px; text-align: right; font-weight: 700; }
.kw { display: flex; flex-wrap: wrap; gap: 6px; }
.kw span {
  font-size: 11.5px; padding: 3px 8px; border-radius: 6px;
  background: var(--panel-2); border: 1px solid var(--line); color: var(--txt-dim);
}
.kw span b { color: var(--txt); font-weight: 600; }
.cmt { padding: 9px 0; border-bottom: 1px solid var(--line-soft); }
.cmt:last-child { border-bottom: 0; }
.cmt-head { display: flex; gap: 8px; align-items: center; font-size: 11.5px; color: var(--txt-faint); }
.cmt-head b { color: var(--txt-dim); font-weight: 600; }
.cmt-text { font-size: 12.5px; line-height: 1.55; color: #d7dbe6; margin-top: 4px; white-space: pre-wrap; word-break: break-word; }

/* ---------------------------------------------------------- modal */
.modal {
  position: fixed; inset: 0; z-index: 70; display: none;
  align-items: center; justify-content: center; padding: 40px;
  background: rgba(3, 4, 6, 0.8);
}
.modal.on { display: flex; }
.modal-card {
  background: var(--bg-elev); border: 1px solid var(--line); border-radius: 14px;
  max-width: min(880px, 92vw); max-height: 90vh; overflow: hidden; box-shadow: var(--shadow);
  display: flex; flex-direction: column;
}
.modal-head { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.modal-head .t { font-size: 13px; font-weight: 600; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.modal-body { padding: 14px; overflow: auto; display: flex; gap: 14px; justify-content: center; align-items: flex-start; flex-wrap: wrap; }
.modal-body img { max-height: 68vh; border-radius: 8px; display: block; }

/* ---------------------------------------------------------- toast */
.toast-wrap { position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%); z-index: 90; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast {
  background: #1b1f29; border: 1px solid #2c3342; color: var(--txt);
  padding: 9px 14px; border-radius: 9px; font-size: 12.5px;
  box-shadow: var(--shadow); animation: toast-in 0.18s ease;
}
.toast.error { border-color: #5a2a2d; background: #241618; color: #ffb4b4; }
@keyframes toast-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.spin { animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.hidden { display: none !important; }

@media (max-width: 1180px) {
  .kpis { grid-template-columns: repeat(3, 1fr); }
  .brand { min-width: 0; }
}
@media (max-width: 760px) {
  .wrap { padding: 0 14px; }
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .search-wrap input { width: 150px; }
  .nav button span.lbl { display: none; }
}
