/* ══════════════════════════════════════════════════════════════
   ShowTime Media Downloader — 시네마틱 다크 콘솔
   순흑 캔버스 · 포스터 중심 레일 · 크림슨→앰버 핫 액센트 · 필름 그레인
   ══════════════════════════════════════════════════════════════ */

/* ══════════════════════════════════════════════════════════════
   ShowTime Media Downloader — Netflix 스타일
   #141414 캔버스 · 순수 레드 액센트 · 주황 없음
   ══════════════════════════════════════════════════════════════ */

:root {
  color-scheme: dark;

  /* Netflix 표면 */
  --ink-0:  #141414;      /* 페이지 바탕 */
  --ink-1:  #181818;      /* 카드 본체 */
  --ink-2:  #1f1f1f;      /* 올라온 면 */
  --ink-3:  #2a2a2a;      /* 입력/트랙 */
  --ink-4:  #333333;      /* 경계 강조 */

  --line:   #262626;
  --line-2: #3a3a3a;

  --text:   #ffffff;
  --text-2: #d2d2d2;
  --muted:  #b3b3b3;      /* Netflix 보조 텍스트 */
  --faint:  #777777;

  /* 액센트 — Netflix 레드 하나만. 주황 없음. */
  --red:      #e50914;
  --red-hi:   #f6121d;
  --red-dim:  rgba(229, 9, 20, .16);
  --red-line: rgba(229, 9, 20, .45);
  --flame:    linear-gradient(90deg, #e50914 0%, #b20710 100%);

  /* 상태 */
  --ok:      #46d369;     /* Netflix 매치 스코어 그린 */
  --ok-dim:  rgba(70, 211, 105, .15);
  --warn:    #e5b109;
  --warn-dim: rgba(229, 177, 9, .15);
  --bad:     #e87c7c;
  --bad-dim: rgba(232, 124, 124, .15);

  /* 이전 이름 호환 */
  --hot: var(--red);
  --hot-2: var(--red);
  --hot-dim: var(--red-dim);
  --hot-line: var(--red-line);
  --mint: var(--ok);
  --mint-dim: var(--ok-dim);
  --gold: var(--warn);
  --gold-dim: var(--warn-dim);

  --r-sm: 4px;
  --r:    6px;            /* Netflix는 모서리를 거의 안 굴린다 */
  --r-lg: 8px;

  --shadow-1: 0 2px 6px rgba(0, 0, 0, .55);
  --shadow-2: 0 12px 32px rgba(0, 0, 0, .75);
  --shadow-3: 0 24px 64px rgba(0, 0, 0, .9);

  --sans: "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont,
          "Apple SD Gothic Neo", "Noto Sans KR", "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, monospace;

  --rail-gap: 6px;
  --poster-w: 178px;
  --shell-x: clamp(16px, 3.7vw, 60px);
}

* { box-sizing: border-box; }

/* 한국어는 어절 중간에서 끊기면 읽기 나빠진다.
   keep-all 로 어절을 붙여두고, 끊을 데가 없는 긴 문자열(주소 등)만 강제로 넘긴다. */
body { word-break: keep-all; overflow-wrap: break-word; }
[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--ink-0);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  font-variant-numeric: tabular-nums;
  overflow-x: hidden;
}


h1, h2, h3 { margin: 0; font-weight: 800; letter-spacing: -.028em; }
p { margin: 0; }

/* 섹션 라벨 — 대문자 + 넓은 자간의 에디토리얼 이어브로우 */
.eyebrow {
  display: inline-flex; align-items: center; gap: 9px;
  font-size: 12px; font-weight: 700;
  letter-spacing: .02em;
  color: var(--muted);
}
.eyebrow::before {
  content: ""; width: 4px; height: 17px; border-radius: 1px;
  background: var(--red);
}

.muted { color: var(--muted); font-size: 12.5px; }

code {
  font-family: var(--mono); font-size: .9em;
  background: var(--ink-2); border: 1px solid var(--line);
  border-radius: 5px; padding: 1.5px 6px; color: var(--text-2);
}

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

::selection { background: var(--hot); color: #fff; }

::-webkit-scrollbar { width: 11px; height: 11px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--ink-4); border-radius: 99px; border: 3px solid var(--ink-0); }
::-webkit-scrollbar-thumb:hover { background: var(--line-2); }

/* ══ 상단바 ══════════════════════════════════════════ */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 80;
  display: flex; align-items: center; gap: 22px;
  padding: 14px var(--shell-x);
  transition: background .3s, border-color .3s, backdrop-filter .3s;
  border-bottom: 1px solid transparent;
  background: linear-gradient(180deg, rgba(0,0,0,.78) 0%, rgba(0,0,0,0) 100%);
}
.topbar.is-stuck {
  background: var(--ink-0);
  border-bottom-color: transparent;
}

.brand { display: flex; align-items: center; gap: 11px; text-decoration: none; color: inherit; }
.brand-mark {
  width: 32px; height: 32px; flex: none;
  display: grid; place-items: center;
  border-radius: 9px;
  background: var(--red);
  color: #fff;
  box-shadow: 0 3px 12px -2px rgba(229, 9, 20, .55);
}
.brand-mark svg { width: 18px; height: 18px; }
.brand-word {
  font-size: 15px; font-weight: 850; letter-spacing: -.03em;
  white-space: nowrap;
}
.brand-word em { font-style: normal; color: var(--hot); }

.nav { display: flex; gap: 4px; }
.nav-item {
  appearance: none; border: 0; background: transparent;
  font: inherit; font-size: 13px; font-weight: 650;
  color: var(--muted); cursor: pointer;
  padding: 7px 14px; border-radius: 9px;
  position: relative;
  transition: color .18s, background .18s;
}
.nav-item:hover { color: var(--text); background: rgba(255,255,255,.05); }
.nav-item.is-active { color: var(--text); }
.nav-item.is-active::after {
  content: ""; position: absolute; left: 14px; right: 14px; bottom: 1px;
  height: 2px; border-radius: 2px; background: var(--red);
}
.nav-badge {
  display: inline-block; min-width: 17px; padding: 0 5px;
  margin-left: 6px; border-radius: 99px;
  background: var(--hot); color: #fff;
  font-size: 10px; font-weight: 800; line-height: 17px; text-align: center;
}

.top-right { margin-left: auto; display: flex; align-items: center; gap: 9px; }

.pulse {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 11px; font-weight: 600; color: var(--muted);
  padding: 5px 11px 5px 9px;
  border: 1px solid var(--line); border-radius: 99px;
  background: rgba(255,255,255,.03);
  white-space: nowrap;
}
.pulse i { width: 6px; height: 6px; border-radius: 50%; background: var(--faint); flex: none; }
.pulse[data-state="live"] i { background: var(--mint); box-shadow: 0 0 0 3px var(--mint-dim); }
.pulse[data-state="connecting"] i { background: var(--gold); animation: blink 1.3s ease-in-out infinite; }
.pulse[data-state="offline"] i { background: var(--red); }
@keyframes blink { 0%,100%{opacity:1} 50%{opacity:.3} }

.icon-btn {
  appearance: none; width: 33px; height: 33px; flex: none;
  display: grid; place-items: center;
  border: 1px solid var(--line); border-radius: 9px;
  background: rgba(255,255,255,.03); color: var(--text-2);
  cursor: pointer; transition: all .18s;
}
.icon-btn:hover { background: rgba(255,255,255,.08); color: var(--text); border-color: var(--line-2); }
.icon-btn svg { width: 16px; height: 16px; }

/* ══ 레이아웃 ════════════════════════════════════════ */
.view { padding-bottom: 90px; animation: fade-up .45s cubic-bezier(.2,.7,.3,1) both; }
@keyframes fade-up { from { opacity: 0; transform: translateY(14px) } }

.wrap { padding-inline: var(--shell-x); }

/* ══ 히어로 ══════════════════════════════════════════ */
.hero {
  position: relative;
  padding: 108px var(--shell-x) 34px;
  overflow: hidden;
  isolation: isolate;
}
.hero::before {
  content: ""; position: absolute; inset: 0; z-index: -2;
  background:
    radial-gradient(90% 130% at 8% -20%, rgba(229,9,20,.16) 0%, transparent 55%),
    var(--ink-0);
}
.hero::after {
  content: ""; position: absolute; inset: 0; z-index: -1;
  background: linear-gradient(180deg, transparent 55%, var(--ink-0) 100%);
}

.hero-top { display: flex; align-items: flex-end; justify-content: space-between; gap: 28px; flex-wrap: wrap; }

.hero-title {
  font-size: clamp(30px, 4.6vw, 52px);
  line-height: 1.04;
  font-weight: 850;
  letter-spacing: -.042em;
  margin-top: 12px;
}
.hero-title em { font-style: normal; color: var(--red); }
.hero-sub { color: var(--text-2); font-size: 14.5px; margin-top: 12px; max-width: 54ch; }

.stat-row { display: flex; gap: 30px; flex-wrap: wrap; }
.stat { display: flex; flex-direction: column; gap: 2px; }
.stat b {
  font-size: clamp(22px, 2.6vw, 30px); font-weight: 850; letter-spacing: -.04em;
  line-height: 1.1;
}
.stat span { font-size: 10.5px; letter-spacing: .16em; text-transform: uppercase; color: var(--faint); font-weight: 700; }
.stat.is-hot b { color: var(--red); }

/* 명령 입력줄 */
.command {
  margin-top: 26px;
  display: flex; gap: 10px; flex-wrap: wrap;
  align-items: flex-start;
}
.command-field { position: relative; flex: 1 1 420px; min-width: 260px; }
.command-field textarea {
  width: 100%; min-height: 52px; max-height: 190px;
  padding: 15px 16px;
  font: inherit; font-family: var(--mono); font-size: 12.8px; line-height: 1.6;
  color: var(--text);
  background: rgba(255,255,255,.045);
  border: 1px solid var(--line-2);
  border-radius: var(--r);
  resize: vertical;
  transition: border-color .2s, background .2s, box-shadow .2s;
  backdrop-filter: blur(6px);
}
.command-field textarea:focus {
  outline: none; background: rgba(255,255,255,.07);
  border-color: var(--hot-line);
  box-shadow: 0 0 0 4px var(--hot-dim);
}
.command-field textarea::placeholder { color: var(--faint); }

/* ══ 버튼 ════════════════════════════════════════════ */
.btn {
  appearance: none;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: inherit; font-size: 13px; font-weight: 700; letter-spacing: -.01em;
  padding: 13px 20px; border-radius: var(--r);
  border: 1px solid transparent; cursor: pointer; white-space: nowrap;
  transition: transform .12s cubic-bezier(.2,.8,.3,1), background .18s, border-color .18s, opacity .18s, box-shadow .18s;
}
.btn:active:not(:disabled) { transform: scale(.975); }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn svg { width: 16px; height: 16px; flex: none; }
.btn-sm { padding: 7px 13px; font-size: 12px; border-radius: 9px; }
.btn-sm svg { width: 13px; height: 13px; }
.btn-block { width: 100%; }

.btn-hot { background: var(--red); color: #fff; }
.btn-hot:hover:not(:disabled) { background: var(--red-hi); }

/* 여러 편을 한꺼번에 고를 때 눈에 띄게 */
.btn-warn { background: var(--warn); color: #141414; }
.btn-warn:hover:not(:disabled) { background: #f5c518; }

.btn-solid { background: var(--text); color: var(--ink-0); }
.btn-solid:hover:not(:disabled) { background: #fff; }

.btn-ghost { background: rgba(109,109,110,.5); border-color: transparent; color: var(--text); }
.btn-ghost:hover:not(:disabled) { background: rgba(109,109,110,.75); }

.btn-quiet { background: transparent; border-color: var(--line); color: var(--muted); }
.btn-quiet:hover:not(:disabled) { color: var(--text); border-color: var(--line-2); background: rgba(255,255,255,.04); }

.btn-danger { background: var(--red-dim); color: var(--red); }
.btn-danger:hover:not(:disabled) { background: rgba(255,92,92,.26); }

/* ══ 레일 ════════════════════════════════════════════ */
.rail { margin-top: 34px; position: relative; }
.rail-head {
  display: flex; align-items: baseline; gap: 12px;
  padding-inline: var(--shell-x);
  margin-bottom: 13px;
}
.rail-head h2 { font-size: 18px; font-weight: 800; letter-spacing: -.032em; }
.rail-head .count { font-size: 12px; color: var(--faint); font-weight: 600; }
.rail-head .spacer { flex: 1; }
.rail-head .src {
  font-size: 10px; letter-spacing: .14em; text-transform: uppercase;
  color: var(--faint); font-weight: 700;
  border: 1px solid var(--line); border-radius: 99px; padding: 2px 9px;
}

.rail-viewport { position: relative; }
.rail-track {
  display: flex; gap: var(--rail-gap);
  padding: 6px var(--shell-x) 18px;
  overflow-x: auto;
  scroll-snap-type: x proximity;
  scroll-behavior: smooth;
  scrollbar-width: none;
}
.rail-track::-webkit-scrollbar { display: none; }

.rail-nav {
  position: absolute; top: 0; bottom: 24px;
  width: calc(var(--shell-x) + 26px);
  display: grid; place-items: center;
  border: 0; cursor: pointer; z-index: 4;
  color: var(--text);
  opacity: 0; transition: opacity .22s;
  background: linear-gradient(90deg, var(--ink-0) 30%, transparent 100%);
}
.rail-nav.next { right: 0; background: linear-gradient(270deg, var(--ink-0) 30%, transparent 100%); }
.rail-nav.prev { left: 0; }
.rail-viewport:hover .rail-nav { opacity: 1; }
.rail-nav:disabled { opacity: 0 !important; pointer-events: none; }
.rail-nav svg { width: 26px; height: 26px; filter: drop-shadow(0 2px 6px rgba(0,0,0,.8)); }

/* ══ 포스터 카드 ═════════════════════════════════════ */
.poster {
  position: relative; flex: none;
  width: var(--poster-w);
  scroll-snap-align: start;
  cursor: pointer;
  border: 0; padding: 0; background: none; text-align: left;
  color: inherit; font: inherit;
  transition: transform .28s cubic-bezier(.2,.8,.3,1);
}
.poster:hover, .poster:focus-visible { transform: translateY(-6px) scale(1.045); z-index: 5; }

.poster-art {
  position: relative;
  aspect-ratio: 2 / 3;
  border-radius: var(--r);
  overflow: hidden;
  background: linear-gradient(150deg, var(--ink-3), var(--ink-1));
  box-shadow: var(--shadow-1);
  transition: box-shadow .28s;
}
.poster:hover .poster-art { box-shadow: var(--shadow-3), 0 0 0 1px rgba(255,255,255,.12); }

/* 포스터가 로드되면 대체 글자를 가려야 하므로 이미지를 위층에 올린다 */
.poster-art img {
  position: relative; z-index: 1;
  width: 100%; height: 100%; object-fit: cover; display: block;
  transition: transform .5s cubic-bezier(.2,.8,.3,1), filter .28s;
}
.poster:hover .poster-art img { transform: scale(1.07); filter: brightness(.5); }

.poster-art .fallback {
  position: absolute; inset: 0; z-index: 0;
  display: grid; place-items: center;
  padding: 14px;
  font-size: 30px; font-weight: 850; color: rgba(255,255,255,.14);
  letter-spacing: -.05em;
}
/* 제목을 담은 대체 포스터 — 이미지가 없어도 카드가 비어 보이지 않게 */
.poster-art .fallback span {
  font-size: 15px; font-weight: 800; line-height: 1.35;
  letter-spacing: -.02em; text-align: center;
  color: rgba(255,255,255,.86);
  display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical;
  overflow: hidden; word-break: keep-all;
}

/* 상단 배지 */
.poster-flags { position: absolute; z-index: 3; top: 8px; left: 8px; right: 8px; display: flex; gap: 5px; }
.flag {
  font-size: 9.5px; font-weight: 800; letter-spacing: .09em; text-transform: uppercase;
  padding: 3px 7px; border-radius: 5px;
  background: rgba(8,9,12,.72); color: var(--text-2);
  backdrop-filter: blur(6px);
}
.flag.new { background: var(--hot); color: #fff; }
.flag.rate { margin-left: auto; color: var(--gold); }

/* 호버 시 뜨는 액션 */
.poster-actions {
  position: absolute; z-index: 3; inset: auto 0 0 0;
  padding: 10px;
  display: flex; gap: 6px;
  opacity: 0; transform: translateY(8px);
  transition: opacity .24s, transform .24s;
}
.poster:hover .poster-actions, .poster:focus-within .poster-actions { opacity: 1; transform: none; }

/* 호버 시 하단 스크림 — 버튼이 밝은 포스터 위에서도 읽히게 */
.poster-art::after {
  content: ""; position: absolute; z-index: 2; inset: auto 0 0 0; height: 55%;
  background: linear-gradient(180deg, transparent, rgba(8,9,12,.86));
  opacity: 0; transition: opacity .24s; pointer-events: none;
}
.poster:hover .poster-art::after, .poster:focus-within .poster-art::after { opacity: 1; }

.p-act {
  appearance: none; border: 0; cursor: pointer;
  height: 32px; border-radius: 8px;
  display: inline-flex; align-items: center; justify-content: center; gap: 5px;
  font: inherit; font-size: 11.5px; font-weight: 750;
  background: #fff; color: #141414;
  transition: background .16s, transform .12s;
  flex: 1;
}
.p-act:hover { background: rgba(255,255,255,.82); }
.p-act:active { transform: scale(.94); }
.p-act svg { width: 13px; height: 13px; }
.p-act.ghost { flex: none; width: 32px; background: rgba(20,23,31,.9); color: var(--text); backdrop-filter: blur(8px); }
.p-act.ghost:hover { background: rgba(38,43,56,.95); }
.p-act.done { background: var(--ok); color: #141414; pointer-events: none; }
.p-act.busy { background: var(--ink-3); color: var(--muted); pointer-events: none; }
/* 구독 중 — 켜져 있다는 걸 한눈에 알아야 다시 누르지 않는다 */
.p-act.sub.on { background: var(--red); color: #fff; }
.p-act.sub.on:hover { background: var(--red-hi); }
.p-act:disabled { opacity: .55; pointer-events: none; }

.poster-meta { padding: 9px 2px 0; }
.poster-title {
  font-size: 12.8px; font-weight: 650; line-height: 1.35;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}
.poster-sub {
  margin-top: 3px; font-size: 10.5px; color: var(--faint);
  display: flex; align-items: center; gap: 6px;
}

/* 선택 가능한 카드 (분석 결과) */
.poster.selectable .poster-art { outline: 2px solid transparent; outline-offset: -2px; }
.poster.is-picked .poster-art { outline-color: var(--hot); }
.poster.is-picked .poster-title { color: var(--hot); }
.poster .tick {
  position: absolute; z-index: 4; top: 8px; right: 8px;
  width: 22px; height: 22px; border-radius: 50%;
  display: grid; place-items: center;
  background: rgba(8,9,12,.7); border: 1.5px solid rgba(255,255,255,.4);
  backdrop-filter: blur(6px);
  transition: background .18s, border-color .18s, transform .18s;
}
.poster.is-picked .tick { background: var(--hot); border-color: var(--hot); transform: scale(1.06); }
.poster .tick svg { width: 12px; height: 12px; color: #fff; opacity: 0; transition: opacity .18s; }
.poster.is-picked .tick svg { opacity: 1; }
.poster.is-owned .poster-art img { filter: grayscale(.7) brightness(.5); }

/* ══ 작업 타일 (이어보기 스타일) ═════════════════════ */
.tile {
  position: relative; flex: none;
  width: 268px;
  scroll-snap-align: start;
  border-radius: var(--r);
  overflow: hidden;
  background: var(--ink-2);
  border: 1px solid var(--line);
  transition: transform .24s cubic-bezier(.2,.8,.3,1), border-color .24s;
}
.tile:hover { transform: translateY(-4px); border-color: var(--line-2); }
.tile[data-status="done"], .tile[data-status="skipped"] { border-color: rgba(61,220,151,.3); }
.tile[data-status="failed"] { border-color: rgba(255,92,92,.4); }
.tile[data-status="cancelled"] { opacity: .5; }
.tile[data-status="downloading"], .tile[data-status="decrypting"], .tile[data-status="merging"] {
  border-color: var(--hot-line);
}

.tile-art {
  position: relative; aspect-ratio: 16 / 9;
  background: linear-gradient(140deg, var(--ink-3), var(--ink-1));
  display: grid; place-items: center; overflow: hidden;
}
.tile-art img { width: 100%; height: 100%; object-fit: cover; opacity: .42; }
.tile-glyph { position: absolute; font-size: 34px; font-weight: 850; color: rgba(255,255,255,.1); letter-spacing: -.05em; }

.tile-state {
  position: absolute; top: 9px; left: 9px;
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 10px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase;
  padding: 4px 8px; border-radius: 6px;
  background: rgba(8,9,12,.78); backdrop-filter: blur(8px);
  color: var(--text-2);
}
.tile[data-status="done"] .tile-state,
.tile[data-status="skipped"] .tile-state { color: var(--mint); }
.tile[data-status="failed"] .tile-state { color: var(--red); }
.tile[data-status="downloading"] .tile-state,
.tile[data-status="decrypting"] .tile-state,
.tile[data-status="merging"] .tile-state,
.tile[data-status="preparing"] .tile-state { color: var(--hot-2); }

.tile-act {
  position: absolute; top: 9px; right: 9px;
  width: 26px; height: 26px; border-radius: 7px;
  display: grid; place-items: center;
  border: 0; cursor: pointer;
  background: rgba(8,9,12,.78); color: var(--text-2);
  backdrop-filter: blur(8px);
  opacity: 0; transition: opacity .2s, color .18s, background .18s;
}
.tile:hover .tile-act { opacity: 1; }
.tile-act:hover { background: var(--red-dim); color: var(--red); }
.tile-act svg { width: 13px; height: 13px; }

.tile-bar { position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: rgba(255,255,255,.1); }
.tile-fill { height: 100%; width: 0; background: var(--red); transition: width .4s cubic-bezier(.3,0,.2,1); }
.tile[data-status="done"] .tile-fill, .tile[data-status="skipped"] .tile-fill { background: var(--mint); }
.tile[data-status="failed"] .tile-fill { background: var(--red); }

.tile-body { padding: 11px 12px 12px; }
.tile-name {
  font-size: 12.8px; font-weight: 680; line-height: 1.35;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.tile-line {
  margin-top: 5px; display: flex; align-items: center; gap: 8px;
  font-size: 10.5px; color: var(--faint); font-family: var(--mono);
}
.tile-line .pct { margin-left: auto; font-weight: 800; color: var(--text-2); }
.tile[data-status="done"] .tile-line .pct { color: var(--mint); }
.tile-err {
  margin-top: 7px; font-size: 10.5px; color: var(--red);
  overflow-wrap: anywhere;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}

/* ══ 전체 진행 바 ════════════════════════════════════ */
.overview {
  margin: 0 var(--shell-x);
  padding: 16px 18px;
  border: 1px solid var(--line); border-radius: var(--r);
  background: linear-gradient(180deg, var(--ink-2), var(--ink-1));
  display: flex; flex-direction: column; gap: 11px;
}
.overview-top { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.chips { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.chip {
  font-size: 11px; font-weight: 700;
  padding: 3px 9px; border-radius: 99px;
  border: 1px solid var(--line-2); color: var(--muted);
}
.chip.hot  { background: var(--hot-dim);  color: var(--hot-2); border-color: transparent; }
.chip.ok   { background: var(--mint-dim); color: var(--mint); border-color: transparent; }
.chip.bad  { background: var(--red-dim);  color: var(--red);  border-color: transparent; }
.overview-stats {
  margin-left: auto; display: flex; gap: 16px; flex-wrap: wrap;
  font-family: var(--mono); font-size: 11.5px; color: var(--muted);
}
.meter { height: 6px; border-radius: 99px; background: rgba(255,255,255,.08); overflow: hidden; }
.meter-fill { height: 100%; width: 0; background: var(--red); border-radius: 99px; transition: width .45s cubic-bezier(.3,0,.2,1); }
.meter-fill.ok { background: var(--mint); }
.meter-fill.bad { background: var(--red); }

/* ══ 패널 / 카드 (설정) ═════════════════════════════ */
.panel {
  background: var(--ink-1);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  overflow: hidden;
  margin-bottom: 18px;
}
.panel-head {
  padding: 20px 22px 16px;
  border-bottom: 1px solid var(--line);
  display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap;
}
.panel-head h2 { font-size: 17px; margin-top: 9px; }
.panel-head .muted { margin-top: 5px; max-width: 62ch; }
.panel-body { padding: 22px; display: flex; flex-direction: column; gap: 20px; }

.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 18px; }

/* ══ 폼 ══════════════════════════════════════════════ */
.field { display: flex; flex-direction: column; gap: 8px; }
.field-label {
  font-size: 11px; font-weight: 750; letter-spacing: .12em; text-transform: uppercase;
  color: var(--faint);
  display: flex; align-items: baseline; gap: 8px;
}
.field-label small { letter-spacing: 0; text-transform: none; font-weight: 500; color: var(--faint); font-size: 11px; }

input[type="text"], input[type="password"], input[type="number"], textarea, select {
  width: 100%; font: inherit; font-size: 13px; color: var(--text);
  background: var(--ink-2); border: 1px solid var(--line-2);
  border-radius: 10px; padding: 11px 13px;
  transition: border-color .18s, background .18s, box-shadow .18s;
}
select {
  appearance: none; cursor: pointer; padding-right: 32px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%237f8798' stroke-width='2.4' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; background-size: 15px;
}
input:focus, textarea:focus, select:focus {
  outline: none; background: var(--ink-3); border-color: var(--hot-line);
  box-shadow: 0 0 0 3px var(--hot-dim);
}
input::placeholder, textarea::placeholder { color: var(--faint); }
.mono-input { font-family: var(--mono); font-size: 12px; }

.path-row { display: flex; gap: 8px; }
.path-row input { flex: 1; min-width: 0; font-family: var(--mono); font-size: 12px; }

.range-row { display: flex; align-items: center; gap: 14px; }
.range-row input[type="range"] { flex: 1; accent-color: var(--hot); min-width: 0; }
.range-row output {
  min-width: 46px; text-align: right;
  font-family: var(--mono); font-size: 12.5px; font-weight: 800; color: var(--text-2);
}

/* 토글 */
.switch { display: flex; align-items: flex-start; gap: 13px; padding: 11px; border-radius: 11px; cursor: pointer; transition: background .16s; }
.switch:hover { background: rgba(255,255,255,.035); }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch-track {
  width: 40px; height: 23px; flex: none; margin-top: 1px;
  border-radius: 99px; background: var(--ink-4); border: 1px solid var(--line-2);
  position: relative; transition: background .2s, border-color .2s;
}
.switch-knob {
  position: absolute; top: 2px; left: 2px; width: 17px; height: 17px;
  border-radius: 50%; background: var(--muted);
  transition: transform .22s cubic-bezier(.3,1.4,.5,1), background .2s;
}
.switch input:checked + .switch-track { background: var(--hot); border-color: transparent; }
.switch input:checked + .switch-track .switch-knob { transform: translateX(17px); background: #fff; }
.switch input:focus-visible + .switch-track { outline: 2px solid var(--hot); outline-offset: 3px; }
.switch-text strong { display: block; font-size: 13px; font-weight: 700; }
.switch-text small { font-size: 11.5px; color: var(--muted); }

/* ══ 규칙 편집기 ═════════════════════════════════════ */
.rules { display: flex; flex-direction: column; gap: 9px; }
.rule {
  border: 1px solid var(--line); border-radius: var(--r);
  background: var(--ink-2);
  padding: 12px 13px;
  display: flex; flex-direction: column; gap: 10px;
  transition: border-color .18s, opacity .18s;
}
.rule.is-off { opacity: .48; }
.rule:hover { border-color: var(--line-2); }
.rule-top { display: flex; align-items: center; gap: 10px; }
.rule-order {
  width: 22px; height: 22px; flex: none; border-radius: 6px;
  display: grid; place-items: center;
  background: var(--ink-4); color: var(--muted);
  font-size: 11px; font-weight: 800;
}
.rule.is-on .rule-order { background: var(--red); color: #fff; }
.rule-desc { flex: 1; min-width: 0; font-size: 12.5px; color: var(--text-2); overflow-wrap: anywhere; }
.rule-btns { display: flex; gap: 4px; flex: none; }
.rule-grid {
  display: grid;
  grid-template-columns: 130px 150px 1fr;
  gap: 8px;
}
.rule-dest { display: flex; gap: 8px; }
.rule-dest input { flex: 1; min-width: 0; font-family: var(--mono); font-size: 12px; }
@media (max-width: 760px) { .rule-grid { grid-template-columns: 1fr; } }

.rule-tester {
  border: 1px dashed var(--line-2); border-radius: var(--r);
  padding: 14px; display: flex; flex-direction: column; gap: 11px;
  background: rgba(255,255,255,.02);
}
.tester-row { display: flex; gap: 8px; flex-wrap: wrap; }
.tester-row select { flex: 0 0 150px; }
.tester-row input { flex: 1; min-width: 180px; }
.tester-out {
  font-size: 12px; display: flex; flex-direction: column; gap: 5px;
  padding: 11px 13px; border-radius: 10px; background: var(--ink-2);
}
.tester-out .why { color: var(--hot-2); font-weight: 700; }
.tester-out code { background: transparent; border: 0; padding: 0; color: var(--text); }

/* ══ 사이트 카드 ═════════════════════════════════════ */
.sites { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 14px; }
.site {
  border: 1px solid var(--line); border-radius: var(--r);
  background: var(--ink-2); padding: 15px;
  display: flex; flex-direction: column; gap: 12px;
}
.site-top { display: flex; align-items: center; gap: 10px; }
.site-name { font-size: 14px; font-weight: 800; letter-spacing: -.02em; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--faint); flex: none; }
.dot.ok { background: var(--mint); box-shadow: 0 0 0 3px var(--mint-dim); }
.dot.fail { background: var(--red); box-shadow: 0 0 0 3px var(--red-dim); }
.site-base { font-family: var(--mono); font-size: 12px; color: var(--text-2); overflow-wrap: anywhere; }
.site-note { font-size: 11px; color: var(--faint); }

/* ══ 모달 ════════════════════════════════════════════ */
.modal { border: 0; padding: 0; background: transparent; max-width: min(820px, 94vw); width: 100%; }
.modal::backdrop { background: rgba(4,5,8,.78); backdrop-filter: blur(6px); }
.modal-inner {
  display: flex; flex-direction: column;
  background: var(--ink-1); border: 1px solid var(--line-2);
  border-radius: var(--r-lg); box-shadow: var(--shadow-3);
  overflow: hidden; max-height: min(80vh, 660px);
  animation: pop .26s cubic-bezier(.2,.9,.3,1);
}
@keyframes pop { from { opacity: 0; transform: scale(.965) translateY(10px) } }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 17px 19px; border-bottom: 1px solid var(--line); }
.modal-head h3 { font-size: 16px; }
.modal-path { display: flex; gap: 8px; padding: 13px 19px; border-bottom: 1px solid var(--line); background: var(--ink-2); }
.modal-body { display: grid; grid-template-columns: 205px 1fr; flex: 1; min-height: 250px; }
.modal-foot {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 14px 19px; border-top: 1px solid var(--line); background: var(--ink-2);
}
.modal-foot .right { margin-left: auto; display: flex; gap: 8px; }

.fs-roots { border-right: 1px solid var(--line); padding: 10px; overflow-y: auto; display: flex; flex-direction: column; gap: 3px; background: var(--ink-2); }
.fs-root {
  appearance: none; border: 0; background: transparent; text-align: left;
  font: inherit; font-family: var(--mono); font-size: 11.5px; color: var(--muted);
  padding: 8px 10px; border-radius: 8px; cursor: pointer;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.fs-root:hover { background: var(--ink-3); color: var(--text); }
.fs-root.is-active { background: var(--hot-dim); color: var(--hot-2); font-weight: 700; }
.fs-list-wrap { overflow-y: auto; min-height: 0; }
.fs-list { list-style: none; margin: 0; padding: 10px; display: flex; flex-direction: column; gap: 2px; }
.fs-item { display: flex; align-items: center; gap: 10px; padding: 9px 11px; border-radius: 8px; cursor: pointer; font-size: 13px; transition: background .14s; }
.fs-item:hover { background: var(--ink-2); }
.fs-item svg { width: 15px; height: 15px; color: var(--hot-2); flex: none; }
.fs-item.is-up svg { color: var(--muted); }
.fs-item span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fs-empty { padding: 30px; text-align: center; color: var(--faint); font-size: 12.5px; }
.fs-meta { font-size: 11px; color: var(--faint); font-family: var(--mono); }
@media (max-width: 640px) {
  .modal-body { grid-template-columns: 1fr; }
  .fs-roots { flex-direction: row; border-right: 0; border-bottom: 1px solid var(--line); overflow-x: auto; }
}

/* ══ 로그 ════════════════════════════════════════════ */
.logbox { border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; background: var(--ink-1); }
.logbox summary {
  list-style: none; cursor: pointer; padding: 14px 18px;
  display: flex; align-items: center; gap: 11px;
}
.logbox summary::-webkit-details-marker { display: none; }
.logbox summary h3 { font-size: 13px; font-weight: 750; }
.logbox summary .caret { color: var(--faint); transition: transform .2s; display: inline-block; }
.logbox[open] summary .caret { transform: rotate(90deg); }
.logbox[open] summary { border-bottom: 1px solid var(--line); }
.log {
  margin: 0; padding: 14px 18px; max-height: 330px; overflow: auto;
  font-family: var(--mono); font-size: 11px; line-height: 1.65;
  color: var(--text-2); background: var(--ink-0);
  white-space: pre-wrap; overflow-wrap: anywhere;
}
.log:empty::after { content: "로그가 없습니다."; color: var(--faint); }
.check-inline { display: inline-flex; align-items: center; gap: 7px; font-size: 11.5px; color: var(--muted); cursor: pointer; margin-left: auto; }
.check-inline input { accent-color: var(--hot); }

/* ══ 빈 상태 ═════════════════════════════════════════ */
.empty {
  padding: 56px 24px; text-align: center;
  border: 1px dashed var(--line-2); border-radius: var(--r-lg);
  margin: 0 var(--shell-x);
}
.empty-glyph { font-size: 32px; opacity: .28; }
.empty h3 { margin-top: 12px; font-size: 16px; }
.empty p { margin-top: 7px; color: var(--muted); font-size: 13px; }

/* 스켈레톤 */
.skeleton { background: linear-gradient(100deg, var(--ink-2) 30%, var(--ink-3) 50%, var(--ink-2) 70%); background-size: 220% 100%; animation: sweep 1.4s linear infinite; }
@keyframes sweep { to { background-position: -220% 0 } }
.sk-poster { width: var(--poster-w); flex: none; }
.sk-poster .sk-art { aspect-ratio: 2/3; border-radius: var(--r); }
.sk-poster .sk-line { height: 10px; border-radius: 4px; margin-top: 9px; }
.sk-poster .sk-line.short { width: 55%; margin-top: 6px; }

/* ══ 토스트 ══════════════════════════════════════════ */
.toasts {
  position: fixed; right: 20px; bottom: 20px; z-index: 950;
  display: flex; flex-direction: column; gap: 9px;
  max-width: min(390px, calc(100vw - 40px));
}
.toast {
  display: flex; align-items: flex-start; gap: 11px;
  padding: 13px 15px; border-radius: var(--r);
  background: var(--ink-2); border: 1px solid var(--line-2);
  box-shadow: var(--shadow-2);
  font-size: 12.8px; overflow-wrap: anywhere;
  animation: toast-in .26s cubic-bezier(.2,.9,.3,1);
}
.toast::before { content: ""; width: 3px; align-self: stretch; flex: none; border-radius: 99px; background: var(--flame); }
.toast.ok::before { background: var(--mint); }
.toast.bad::before { background: var(--red); }
.toast.warn::before { background: var(--gold); }
.toast.is-out { animation: toast-out .2s ease forwards; }
@keyframes toast-in { from { opacity: 0; transform: translateX(24px) } }
@keyframes toast-out { to { opacity: 0; transform: translateX(16px) } }

/* ══ 로그인 ══════════════════════════════════════════ */
.auth-body { display: grid; place-items: center; min-height: 100svh; padding: 24px; position: relative; overflow: hidden; }
.auth-body::before {
  content: ""; position: absolute; inset: -20%;
  background:
    radial-gradient(52% 52% at 24% 24%, rgba(229, 9, 20, .34) 0%, transparent 62%),
    radial-gradient(44% 44% at 80% 72%, rgba(229, 9, 20, .18) 0%, transparent 62%),
    radial-gradient(60% 60% at 55% 10%, rgba(0, 0, 0, .6) 0%, transparent 70%);
  filter: blur(24px);
  animation: drift 22s ease-in-out infinite alternate;
}
@keyframes drift {
  from { transform: translate3d(-2%, -1%, 0) scale(1) }
  to   { transform: translate3d(3%, 2%, 0) scale(1.1) }
}

.auth-card {
  position: relative; z-index: 2;
  width: 100%; max-width: 384px;
  display: flex; flex-direction: column; gap: 17px;
  padding: 34px 30px 28px;
  border-radius: var(--r-lg);
  background: rgba(13, 15, 20, .82);
  border: 1px solid rgba(255,255,255,.09);
  box-shadow: var(--shadow-3), inset 0 1px 0 rgba(255,255,255,.07);
  backdrop-filter: blur(26px) saturate(160%);
  -webkit-backdrop-filter: blur(26px) saturate(160%);
}
.auth-card > * { animation: rise .55s cubic-bezier(.2,.8,.3,1) both; }
.auth-card > *:nth-child(1) { animation-delay: .04s }
.auth-card > *:nth-child(2) { animation-delay: .10s }
.auth-card > *:nth-child(3) { animation-delay: .16s }
.auth-card > *:nth-child(4) { animation-delay: .22s }
.auth-card > *:nth-child(5) { animation-delay: .28s }
@keyframes rise { from { opacity: 0; transform: translateY(12px) } }

.auth-brand { display: flex; align-items: center; gap: 13px; }
.auth-brand .brand-mark { width: 44px; height: 44px; border-radius: 13px; }
.auth-brand .brand-mark svg { width: 24px; height: 24px; }
.auth-brand h1 { font-size: 19px; letter-spacing: -.035em; line-height: 1.15; }
.auth-brand h1 em { font-style: normal; color: var(--hot); }
.auth-brand p { font-size: 10.5px; letter-spacing: .2em; text-transform: uppercase; color: var(--faint); font-weight: 700; margin-top: 3px; }

.auth-error { font-size: 12.5px; color: var(--red); background: var(--red-dim); border-radius: 10px; padding: 10px 13px; }

/* ══ 접근성 ══════════════════════════════════════════ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important; animation-iteration-count: 1 !important;
    transition-duration: .01ms !important; scroll-behavior: auto !important;
  }
  body::after { animation: none; }
}

@media (max-width: 720px) {
  :root { --poster-w: 132px; }
  .nav-item { padding: 7px 10px; font-size: 12.5px; }
  .brand-word { display: none; }
  .overview-stats { margin-left: 0; }
  .tile { width: 232px; }
}

/* ══ 검색 ════════════════════════════════════════════ */
.search { display: flex; align-items: center; }
.search-open { display: none; }

.search-box {
  display: flex; align-items: center; gap: 8px;
  height: 33px; padding: 0 10px;
  border: 1px solid var(--line); border-radius: 9px;
  background: rgba(0,0,0,.55);
  transition: width .26s cubic-bezier(.2,.7,.3,1), border-color .18s, background .18s;
  width: 250px;
}
.search-box:focus-within {
  border-color: var(--line-2);
  background: rgba(0,0,0,.86);
  width: 320px;
}
.search-icon { width: 15px; height: 15px; flex: none; color: var(--muted); }
.search-box input {
  appearance: none; border: 0; background: transparent; outline: none;
  font: inherit; font-size: 13px; color: var(--text);
  width: 100%; min-width: 0; padding: 0;
}
.search-box input::placeholder { color: var(--faint); }
.search-box input::-webkit-search-cancel-button { display: none; }
.search-clear {
  appearance: none; border: 0; background: transparent; cursor: pointer;
  display: grid; place-items: center; flex: none;
  width: 18px; height: 18px; border-radius: 50%;
  color: var(--faint);
}
.search-clear:hover { color: var(--text); background: rgba(255,255,255,.1); }
.search-clear svg { width: 11px; height: 11px; }

/* 포스터 그리드 (검색 결과) */
.grid-posters {
  display: grid; gap: 15px 13px;
  grid-template-columns: repeat(auto-fill, minmax(158px, 1fr));
}
.grid-posters .poster { width: auto; }

.res-badge {
  display: inline-block; margin-left: 7px; padding: 1px 7px;
  border-radius: 99px; font-size: 10px; font-weight: 800; letter-spacing: .02em;
  background: rgba(255,255,255,.09); color: var(--muted);
}
.res-badge.site { background: var(--red-dim); color: #ff6b73; }

/* ══ 계정 ════════════════════════════════════════════ */
.acct-new {
  display: grid; gap: 8px;
  grid-template-columns: minmax(170px, 1fr) 116px minmax(150px, 1.3fr) auto;
  align-items: center;
}
.acct {
  display: flex; align-items: center; gap: 13px; flex-wrap: wrap;
  padding: 13px 15px;
  background: var(--ink-1); border: 1px solid var(--line); border-radius: var(--r);
}
.acct.is-off { opacity: .5; }
.acct-avatar {
  width: 34px; height: 34px; flex: none; border-radius: 8px;
  display: grid; place-items: center;
  background: var(--ink-3); color: var(--text);
  font-weight: 850; font-size: 14px; text-transform: uppercase;
}
.acct.is-admin .acct-avatar { background: var(--red); color: #fff; }
.acct-id { font-weight: 750; font-size: 14px; }
.acct-sub { font-size: 11.5px; color: var(--faint); margin-top: 3px; }
.acct-tags { display: flex; gap: 5px; flex-wrap: wrap; margin-top: 5px; }
.acct-tag {
  font-size: 10px; font-weight: 750; letter-spacing: .02em;
  padding: 2px 7px; border-radius: 99px;
  background: rgba(255,255,255,.07); color: var(--muted);
}
.acct-tag.warn { background: var(--warn-dim); color: var(--warn); }
.acct-tag.ok   { background: var(--ok-dim);   color: var(--ok); }
.acct-tag.hot  { background: var(--red-dim);  color: #ff6b73; }
.acct-btns { margin-left: auto; display: flex; gap: 6px; flex-wrap: wrap; }

/* ══ 첫 로그인 비밀번호 변경 ═════════════════════════ */
.modal-sm { max-width: min(440px, 94vw); }
.pwgate-body { padding: 20px 19px; display: flex; flex-direction: column; gap: 15px; }
.pwgate-body .muted { font-size: 12.5px; line-height: 1.6; }
.pwgate-err {
  font-size: 12.5px; color: var(--red);
  background: var(--red-dim); border: 1px solid var(--red-line);
  border-radius: var(--r); padding: 9px 12px;
}

@media (max-width: 900px) {
  .search-box { width: 190px; }
  .search-box:focus-within { width: 220px; }
  .acct-new { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 640px) {
  .search-open { display: grid; }
  .search-box {
    position: absolute; top: 100%; right: var(--shell-x); left: var(--shell-x);
    width: auto; display: none;
    background: var(--ink-1); box-shadow: var(--shadow-2);
  }
  .search.is-open .search-box { display: flex; width: auto; }
  .search.is-open .search-box:focus-within { width: auto; }
  .acct-new { grid-template-columns: 1fr; }
}

/* 카테고리 표시 이름 — 그 자리에서 바로 고친다 */
.cat-name {
  flex: 1; min-width: 0;
  font: inherit; font-size: 13px; font-weight: 650; color: var(--text);
  background: transparent; border: 1px solid transparent; border-radius: 6px;
  padding: 4px 8px;
}
.cat-name:hover { border-color: var(--line); }
.cat-name:focus { border-color: var(--line-2); background: rgba(255,255,255,.05); outline: none; }

/* 구독 다이얼로그 — 어디로 받을지 한눈에 읽히게 */
.dest-preview {
  font-family: var(--mono); font-size: 12.5px; line-height: 1.5;
  color: var(--text); background: rgba(255,255,255,.05);
  border: 1px solid var(--line); border-radius: var(--r);
  padding: 10px 12px; overflow-wrap: anywhere; word-break: break-all;
}

/* 회차 타일 — 작품 포스터 위에 회차 번호를 얹는다 */
.poster.selectable .poster-art img { filter: brightness(.42); }
.poster-art .fallback.ep-no {
  z-index: 2; background: none;
  font-size: 34px; color: rgba(255,255,255,.9);
  text-shadow: 0 2px 10px rgba(0,0,0,.9);
}
.poster.selectable:hover .poster-art img { filter: brightness(.3); }
