/* Dark theme — slate + amber, SVG icon system. */
:root {
  --bg: #0b1222;
  --surface: #141d31;
  --surface-2: #1b263f;
  --surface-3: #243352;
  --accent: #f59e0b;
  --accent-2: #fbbf24;
  --text: #f1f5f9;
  --text-2: #cbd5e1;
  --muted: #8b9bb4;
  --border: rgba(148, 163, 184, .15);
  --border-2: rgba(148, 163, 184, .3);
  --danger: #f87171;
  --ok: #34d399;
  --radius: 12px;
  --radius-sm: 9px;
  --shadow: 0 12px 32px rgba(2, 6, 23, .55);
  --amber-ink: #1a1205;       /* amber 바탕 위 글자 */
  --sel-bg: #2a210e;          /* 고른 줄 */
  --danger-strong: #dc2626;   /* 되돌릴 수 없는 확정 단추 */
  --warn: #f59e0b;
  /* 종류별 타일: 바탕 / 그림 */
  --k-dir-bg: #3a2a0c;   --k-dir: #fbbf24;
  --k-video-bg: #2a2350; --k-video: #c4b5fd;
  --k-img-bg: #0f3a3a;   --k-img: #5eead4;
  --k-audio-bg: #3d1830; --k-audio: #f9a8d4;
  --k-zip-bg: #243352;   --k-zip: #cbd5e1;
  --k-doc-bg: #13284a;   --k-doc: #93c5fd;
  --k-file-bg: #1e293b;  --k-file: #94a3b8;
  /* 두 축 막대: 넓은 화면은 위(appbar), 폰은 아래(tabbar). 안 쓰는 쪽은 0 이다. */
  --appbar-h: 64px;
  --tabbar-h: 0px;
}
@media (max-width: 640px) {
  :root { --appbar-h: 0px; --tabbar-h: calc(64px + env(safe-area-inset-bottom)); }
}

* { box-sizing: border-box; }
html { scrollbar-color: var(--surface-3) var(--bg); }
html, body { margin: 0; height: 100%; }
body {
  font-family: "Pretendard Variable", Pretendard, Inter, -apple-system, BlinkMacSystemFont, system-ui, "Segoe UI", Roboto, "Noto Sans KR", sans-serif;
  background:
    radial-gradient(1100px 700px at 85% -10%, rgba(245, 158, 11, .07), transparent 60%),
    radial-gradient(900px 600px at -10% 110%, rgba(96, 165, 250, .06), transparent 55%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  letter-spacing: -0.01em;
}
.hidden { display: none !important; }
/* 파일 입력: display:none 대신 시각적 은닉 — 일부 모바일 브라우저는
   display:none 입력의 선택창을 띄우지 않는다. label 활성화는 항상 동작. */
.offscreen {
  position: absolute; width: 1px; height: 1px; margin: -1px;
  clip-path: inset(50%); overflow: hidden; white-space: nowrap;
}
.error { color: var(--danger); min-height: 1.2em; margin: 0.3em 0 0; }

button, .btn {
  font: inherit; color: var(--text);
  border: 1px solid var(--border-2); background: var(--surface); border-radius: var(--radius-sm);
  padding: 0.5rem 0.9rem; cursor: pointer; min-height: 44px; min-width: 44px;
  display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
  transition: background .15s, border-color .15s, filter .15s;
  -webkit-tap-highlight-color: transparent;
}
button:hover, .btn:hover { background: var(--surface-2); }
button:active, .btn:active { transform: translateY(1px); }
button:focus-visible, .btn:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}
.iconbtn { padding: 0.5rem; }
.iconbtn svg, .btn svg { width: 20px; height: 20px; }

/* 잘라내기/복사 클립보드 붙여넣기 — 라벨이 길어질 수 있어 말줄임 */
#btn-paste span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#btn-paste { max-width: min(46vw, 260px); }

/* Login */
#login-view { display: flex; align-items: center; justify-content: center; min-height: 100vh; min-height: 100dvh; }
.card {
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
  border: 1px solid var(--border); border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 2.2rem 2rem; width: min(92vw, 380px); display: flex; flex-direction: column; gap: 0.8rem;
}
.logo {
  width: 56px; height: 56px; border-radius: 15px; margin: 0 auto;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(180deg, rgba(245, 158, 11, .22), rgba(245, 158, 11, .1));
  border: 1px solid rgba(245, 158, 11, .35); color: var(--accent-2);
}
.logo svg { width: 28px; height: 28px; }
.card h1 { margin: 0; font-size: 1.3rem; text-align: center; }
.card-sub { margin: -0.4rem 0 0.4rem; text-align: center; color: var(--muted); font-size: 0.85rem; }
.card input { font: inherit; padding: 0.65rem 0.7rem; border: 1px solid var(--border-2); border-radius: var(--radius-sm); background: rgba(11, 18, 34, .6); color: var(--text); }
.card input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.login-remember { display: flex; align-items: center; gap: 0.5rem; font-size: 0.92rem; color: var(--text); cursor: pointer; }
.login-remember span { color: var(--muted); font-size: 0.82rem; margin-left: auto; }
.card .login-remember input { width: 18px; height: 18px; padding: 0; margin: 0; accent-color: var(--accent); }
.card button {
  background: linear-gradient(180deg, var(--accent-2), var(--accent));
  color: #231303; border: none; font-weight: 700; width: 100%; margin-top: 0.3rem;
  box-shadow: 0 4px 14px rgba(245, 158, 11, .25);
}
.card button:hover { filter: brightness(1.07); background: linear-gradient(180deg, var(--accent-2), var(--accent)); }

/* 두 축 막대 — 넓은 화면: 위에 고정, 가운데 세그먼트. 폰: 아래 탭(아래 미디어 쿼리). */
#app-view { padding-top: var(--appbar-h); }
#appbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 9; height: var(--appbar-h);
  display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; gap: 1rem;
  padding: 0 1.25rem; background: rgba(11, 18, 34, .92);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 0.75rem; min-width: 0; }
.brand-logo {
  flex: none; width: 34px; height: 34px; border-radius: 10px; background: var(--accent); color: var(--amber-ink);
  display: inline-flex; align-items: center; justify-content: center;
}
.brand-logo svg { width: 20px; height: 20px; }
.brand-name { font-size: 1.06rem; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#axis {
  display: flex; gap: 4px; padding: 4px; border-radius: 14px;
  background: rgba(20, 29, 49, .8); border: 1px solid rgba(148, 163, 184, .2);
}
#axis button {
  /* 관리자는 축이 넷이다 — 좁은 데스크톱 폭에서 브랜드를 밀어내지 않게 줄어든다. */
  width: clamp(96px, 11vw, 148px); height: 44px; min-height: 44px; padding: 0; gap: 0.6rem; border: 0; border-radius: 10px;
  background: transparent; color: var(--text-2); font-size: 0.94rem; font-weight: 700;
}
#axis button:hover { background: var(--surface-3); color: var(--text); }
#axis button[aria-current="page"] { background: var(--accent); color: var(--amber-ink); }
.axis-ic { display: inline-flex; align-items: center; justify-content: center; }
.axis-ic svg { width: 20px; height: 20px; }

/* Header */
header {
  position: sticky; top: var(--appbar-h); z-index: 5; display: flex; align-items: center; flex-wrap: wrap; gap: 0.4rem;
  background: rgba(11, 18, 34, .85); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 0.5rem 0.75rem; padding-top: max(0.5rem, env(safe-area-inset-top));
}
@media (min-width: 641px) {
  header { padding-top: 0.5rem; } /* 위쪽 안전 영역은 appbar 가 받는다 */
}
#breadcrumb {
  display: flex; flex-wrap: wrap; gap: 0.1rem; align-items: center; min-width: 0;
  min-height: 40px; padding: 0 0.35rem; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--border);
}
#breadcrumb a {
  color: var(--text-2); text-decoration: none; padding: 0.3rem 0.45rem; border-radius: 999px;
  display: inline-flex; align-items: center;
}
#breadcrumb a:hover { background: var(--surface-2); color: var(--text); }
#breadcrumb a:last-child { color: var(--accent-2); font-weight: 600; }
#breadcrumb .sep { color: var(--muted); padding: 0 0.1rem; }
#breadcrumb a svg { width: 17px; height: 17px; }
.spacer { flex: 1; }
/* 주 동작: amber. 올리기처럼 이 화면에서 가장 자주 하는 일 하나에만 쓴다. */
.btn.primary, button.primary {
  background: var(--accent); border-color: var(--accent); color: var(--amber-ink); font-weight: 700;
}
.btn.primary:hover, button.primary:hover { background: var(--accent-2); border-color: var(--accent-2); }
/* 되돌릴 수 없는 확정(휴지통 비우기·영구 삭제) */
button.danger { background: var(--danger-strong); border-color: var(--danger-strong); color: #fff; font-weight: 700; }
button.danger:hover { background: #b91c1c; border-color: #b91c1c; }

/* File list */
#file-list { list-style: none; margin: 0 auto; padding: 0.75rem 0.5rem; display: grid; gap: 0.4rem; }
#file-list li {
  display: flex; align-items: center; gap: 0.7rem; padding: 0.5rem 0.6rem;
  background: var(--surface); border: 1px solid transparent; cursor: pointer;
  border-radius: var(--radius); transition: background .12s, border-color .12s;
}
#file-list li:active { background: var(--surface-2); border-color: var(--border-2); }
@media (hover: hover) {
  #file-list li:hover { background: var(--surface-2); border-color: var(--border); }
  .rowbtns button:hover { background: var(--surface-3); color: var(--text); border-color: var(--border-2); }
}
/* 탐색기식 조작: 고른 줄·키보드 위치·잘라낸 항목·놓을 자리. hover 뒤에 둬야 이긴다. */
#file-list li {
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
  scroll-margin: calc(8rem + var(--appbar-h)) 0 calc(3rem + var(--tabbar-h));
}
#file-list li.sel, #file-list li.sel:hover { background: var(--sel-bg); border-color: var(--accent); }
#file-list li.cursor { box-shadow: inset 0 0 0 1px var(--accent); }
/* 잘라낸 줄: 상자는 또렷하게 두고 내용만 흐린다 — 고르기는 계속 된다. */
#file-list li.cut { border-style: dashed; border-color: var(--border-2); }
#file-list li.cut > :not(.entry-check) { opacity: .55; }
#file-list li.cut .entry-name::after {
  content: "잘라냄"; margin-left: 0.5rem; padding: 0.05rem 0.45rem; border-radius: 999px; vertical-align: 1px;
  font-size: 0.72rem; font-weight: 700; color: var(--accent-2); background: rgba(245, 158, 11, .16);
}
#file-list li.drop, #breadcrumb a.drop { outline: 2px solid var(--accent); outline-offset: -2px; background: var(--surface-3); }
main { min-height: 70vh; } /* 빈 곳 우클릭·끌어 고르기·파일 놓기가 닿을 자리 */
body.dropping main { outline: 2px dashed var(--accent); outline-offset: -6px; border-radius: var(--radius); }
.band {
  position: absolute; z-index: 6; pointer-events: none;
  border: 1px solid var(--accent); background: color-mix(in srgb, var(--accent) 15%, transparent);
}
#ctxmenu {
  position: fixed; z-index: 40; min-width: 190px; padding: 0.35rem; display: grid; gap: 0.15rem;
  background: linear-gradient(180deg, var(--surface-3), var(--surface-2));
  border: 1px solid var(--border-2); border-radius: var(--radius); box-shadow: var(--shadow);
}
#ctxmenu button {
  justify-content: flex-start; width: 100%; padding: 0.4rem 0.7rem; border: 0;
  background: transparent; color: var(--text); font-size: 0.92rem; text-align: left; cursor: pointer;
  border-radius: calc(var(--radius) - 2px);
}
#ctxmenu button:hover, #ctxmenu button:focus-visible { background: var(--surface-3); }
#ctxmenu hr { border: 0; border-top: 1px solid var(--border); margin: 0.2rem 0.3rem; }
.drag-ghost {
  position: fixed; z-index: 41; pointer-events: none; transform: translate(-50%, -140%);
  padding: 0.35rem 0.7rem; border-radius: var(--radius); white-space: nowrap;
  background: var(--accent); color: #111; font-weight: 600; font-size: 0.9rem; box-shadow: var(--shadow);
}
/* 여러 개 고르기: 줄마다 상자가 늘 있다. label 이 줄 왼쪽 끝부터 위아래 전체를 받아
   손가락이 상자를 조금 빗나가도 줄 탭(열기)이 되지 않는다. */
.entry-check, .selbar-allwrap {
  flex: none; display: flex; align-items: center; cursor: pointer;
}
.entry-check { align-self: stretch; margin: -0.5rem -0.3rem -0.5rem -0.6rem; padding: 0 0.3rem 0 0.6rem; }
.selbar-allwrap { padding: 0.3rem 0.4rem 0.3rem 0.6rem; margin-left: -0.6rem; }
.entry-check input, .selbar-allwrap input {
  width: 20px; height: 20px; margin: 0; accent-color: var(--accent); cursor: pointer;
}
#selbar { flex-wrap: nowrap; } /* 고른 개수가 늘어도 줄이 바뀌어 높이가 변하면 안 된다 */
#selbar, #sharebar {
  flex-basis: 100%; display: flex; align-items: center; flex-wrap: wrap; gap: 0.4rem;
  margin-top: 0.45rem; padding-top: 0.45rem; border-top: 1px solid var(--border);
}
#sharebar.hidden { display: none; }
#selbar-count, #sharebar-msg { color: var(--muted); font-size: 0.9rem; }
#selbar .spacer, #sharebar .spacer { display: block; } /* 좁은 화면에서 헤더용 규칙에 지워지지 않게 */
#selbar button, #sharebar button { padding: 0.35rem 0.6rem; min-height: 34px; font-size: 0.88rem; }
/* 꺼진 단추는 흐리게 하지 않고 점선 — 글자 대비를 지키면서 "아직 못 누름"을 보인다. */
#selbar button:disabled { border-style: dashed; background: transparent; color: var(--muted); cursor: default; }
#selbar button:disabled:active { transform: none; }
#selbar-count { white-space: nowrap; font-variant-numeric: tabular-nums; }
#selbar.has-sel #selbar-count { color: var(--accent-2); font-weight: 700; }
#selbar-del:not(:disabled) { color: #fca5a5; border-color: rgba(248, 113, 113, .45); }
#selbar-del:not(:disabled):hover { background: rgba(220, 38, 38, .16); }
@media (max-width: 640px) {
  /* 좁은 화면에서는 글자를 빼고 그림만 남겨 한 줄에 들어가게 한다. */
  #selbar .btn span { display: none; }
  #selbar button { padding: 0.35rem 0.45rem; min-width: 36px; }
  #selbar { gap: 0.25rem; }
}

.entry-icon {
  width: 40px; height: 40px; border-radius: 10px; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
}
.entry-icon svg { width: 20px; height: 20px; }
.icon-dir   { background: var(--k-dir-bg);   color: var(--k-dir); }
.icon-img   { background: var(--k-img-bg);   color: var(--k-img); }
.icon-video { background: var(--k-video-bg); color: var(--k-video); }
.icon-audio { background: var(--k-audio-bg); color: var(--k-audio); }
.icon-zip   { background: var(--k-zip-bg);   color: var(--k-zip); }
.icon-doc   { background: var(--k-doc-bg);   color: var(--k-doc); }
.icon-file  { background: var(--k-file-bg);  color: var(--k-file); }
.entry-name { flex: 1; min-width: 0; overflow-wrap: anywhere; font-size: 0.95rem; font-weight: 500; }
.entry-size, .entry-date { color: var(--muted); font-size: 0.8rem; flex: none; font-variant-numeric: tabular-nums; }
.entry-date { display: none; }
.rowbtns { flex: none; display: flex; gap: 0.2rem; }
.rowbtns button { padding: 0.4rem; min-height: 36px; min-width: 36px; border-radius: 9px; background: transparent; border-color: transparent; color: var(--muted); }
.rowbtns button svg { width: 17px; height: 17px; }
.empty {
  display: flex; flex-direction: column; align-items: center; gap: 0.75rem;
  width: min(100% - 2rem, 28rem); margin: 2rem auto; padding: 2.5rem 1rem; color: var(--muted);
  border: 1.5px dashed var(--border-2); border-radius: 16px; text-align: center;
}
.empty svg {
  width: 56px; height: 56px; padding: 14px; border-radius: 16px;
  background: var(--k-dir-bg); color: var(--k-dir);
}
.empty span { color: var(--text-2); font-weight: 600; }

/* 전송 현황 패널 (하단 고정) */
#transfers {
  position: fixed; left: 0; right: 0; bottom: var(--tabbar-h); z-index: 9;
  background: rgba(15, 23, 42, .96); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--border-2); border-radius: 18px 18px 0 0; box-shadow: 0 -12px 32px rgba(0, 0, 0, .4);
  padding: 0.6rem 0.75rem 0.6rem;
  max-height: 42vh; display: flex; flex-direction: column; gap: 0.4rem;
}
.transfers-head { display: flex; align-items: center; gap: 0.4rem; flex: none; }
@media (min-width: 641px) {
  #transfers { padding-bottom: calc(0.6rem + env(safe-area-inset-bottom)); }
}
#transfers-title { font-weight: 800; font-size: 0.98rem; }
#transfers-list { overflow-y: auto; display: grid; gap: 0.4rem; align-content: start; }
#transfers.min #transfers-list { display: none; }
.iconbtn.sm { padding: 0.3rem; min-height: 34px; min-width: 34px; }
.iconbtn.sm svg { width: 16px; height: 16px; }
.transfer-item { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 0.6rem 0.75rem; flex: none; }
.transfer-item.error { border-color: rgba(248, 113, 113, .45); }
.transfer-item.done .status { color: var(--ok); }
.tr-top { display: flex; align-items: center; gap: 0.4rem; }
.tr-top .name { flex: 1; min-width: 0; overflow-wrap: anywhere; font-size: 0.9rem; }
.tr-cancel { padding: 0.3rem; min-height: 34px; min-width: 34px; background: transparent; border-color: transparent; color: var(--muted); }
.tr-cancel svg { width: 15px; height: 15px; }
.transfer-item.error .bar > div { background: var(--danger); }
.transfer-item .bar { height: 6px; border-radius: 999px; background: var(--surface-3); margin-top: 0.4rem; overflow: hidden; }
.transfer-item .bar > div { height: 100%; width: 0; background: linear-gradient(90deg, #f59e0b, #fbbf24); border-radius: 999px; transition: width .2s; }
.transfer-item .status { font-size: 0.78rem; color: var(--muted); margin-top: 0.25rem; font-variant-numeric: tabular-nums; }
.transfer-item.done .bar > div { background: var(--ok); }
.transfer-item.error .status { color: var(--danger); }
main { padding-bottom: var(--tabbar-h); }
body.transfers-open main { padding-bottom: calc(46vh + var(--tabbar-h)); }

/* 치명 오류 배너 (처리 못한 예외 표시 — 클릭하면 닫힘) */
#fatal {
  position: fixed; top: 0; left: 0; right: 0; z-index: 20;
  background: #7f1d1d; color: #fecaca; cursor: pointer;
  padding: 0.6rem 0.9rem; padding-top: max(0.6rem, env(safe-area-inset-top));
  font-size: 0.85rem; overflow-wrap: anywhere;
}

/* Preview overlay */
#preview {
  position: fixed; inset: 0; z-index: 10; background: rgba(2, 6, 23, .88);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  display: flex; align-items: center; justify-content: center;
}
.preview-body { max-width: 96vw; max-height: 96vh; display: flex; flex-direction: column; gap: 0.5rem; }
.preview-body img { max-width: 96vw; max-height: 78vh; object-fit: contain; border-radius: var(--radius); }
/* nowrap — 절대배치 버튼이 폰 폭에서 좁게 잡혀 "닫기"가 두 줄로 떨어졌다 */
.preview-close {
  position: absolute; top: max(0.75rem, env(safe-area-inset-top)); right: 0.75rem;
  background: rgba(15, 23, 42, .8); color: var(--text); border-color: var(--border-2);
  white-space: nowrap;
}
.preview-close svg { flex: none; width: 18px; height: 18px; }

/* 커스텀 비디오 플레이어 — 썸네일 스크러빙·배속·자막은 네이티브 controls로
   불가능해 직접 만들었다. idle 상태(2.6초 무입력)에서는 컨트롤·제목·커서를 지운다. */
/* overflow:hidden 을 뺐다 — CC/배속 팝업이 위로 뜰 때 플레이어 상단에 잘렸다.
   둥근 모서리는 video 에 상속시켜 유지한다(전체화면은 radius 0 이 내려온다). */
.vplayer {
  position: relative; background: #000;
  width: min(1100px, 96vw); border-radius: var(--radius);
}
/* touch-action:none — 세로 드래그를 브라우저가 스크롤로 가로채면 밝기 제스처가
   pointercancel 로 끊긴다. 커스텀 플레이어라 video 위에서 스크롤할 일은 없다. */
.vplayer video { display: block; width: 100%; max-height: 74vh; background: #000; border-radius: inherit; touch-action: none; }
.vplayer:fullscreen { width: 100%; height: 100%; border-radius: 0; display: flex; align-items: center; justify-content: center; }
.vplayer:fullscreen video { height: 100%; max-height: 100vh; object-fit: contain; }
/* 화면 비율(app.js setFit): 꽉 채우기는 가장자리를 자르고, 늘리기는 비율을 버린다.
   자막은 영상 밖 #v-subs 에 그리므로 잘리지 않는다. */
.vplayer[data-fit="cover"] video { object-fit: cover; }
.vplayer[data-fit="fill"] video { object-fit: fill; }
.vplayer:fullscreen .v-controls { padding-bottom: max(0.55rem, env(safe-area-inset-bottom)); }
#v-title {
  position: absolute; top: 0; left: 0; right: 0; z-index: 2;
  padding: 0.8rem 1rem; padding-top: max(0.8rem, env(safe-area-inset-top));
  font-size: 0.9rem; font-weight: 600; overflow-wrap: anywhere;
  padding-right: 6.5rem; /* 오른쪽 위 비율·잠금 단추 자리 */
  background: linear-gradient(180deg, rgba(2, 6, 23, .75), transparent);
  transition: opacity .25s; pointer-events: none;
}
.v-controls {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 2;
  padding: 1.4rem 0.7rem 0.55rem;
  background: linear-gradient(0deg, rgba(2, 6, 23, .88), transparent);
  transition: opacity .25s;
}
.vplayer.idle .v-controls, .vplayer.idle #v-title { opacity: 0; pointer-events: none; }
.vplayer.idle { cursor: none; }
/* 자막은 브라우저가 아니라 앱이 그린다(app.js renderSubs). 컨트롤이 보이면 그 위로 올린다. */
.v-subs {
  position: absolute; left: 4%; right: 4%; bottom: 6%; z-index: 1;
  text-align: center; pointer-events: none; transition: bottom .25s;
  font-size: calc(var(--sub-base, 16px) * var(--sub-scale, 1)); line-height: 1.3;
}
.vplayer:not(.idle) .v-subs { bottom: 5.5rem; }
.v-subs > div { margin-top: 0.15em; }
/* JASSUB 은 캔버스 상자를 <video> 바로 뒤에 position:relative 로 붙인다 — 전체화면의
   flex 플레이어에서는 그 상자가 영상을 옆으로 민다. 겹쳐 놓고 캔버스 위치는 JASSUB 이
   영상 상자를 재서 맞춘다. 크기 줄은 ASS 에 듣지 않는다(스크립트가 글자 크기를 정한다). */
.vplayer > .JASSUB { position: absolute !important; inset: 0; z-index: 1; pointer-events: none; }
.vplayer.ass .v-size { display: none; }
.v-subs span {
  white-space: pre-line; color: #fff; background: rgba(0, 0, 0, .8);
  padding: 0 0.25em; -webkit-box-decoration-break: clone; box-decoration-break: clone;
}
.v-spinner {
  position: absolute; top: 50%; left: 50%; z-index: 3;
  width: 46px; height: 46px; margin: -23px 0 0 -23px;
  border: 3px solid rgba(255, 255, 255, .25); border-top-color: var(--accent-2);
  border-radius: 50%; animation: vspin .8s linear infinite;
}
@keyframes vspin { to { transform: rotate(360deg); } }
.v-error {
  position: absolute; inset: 0; z-index: 4;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 0.8rem; background: rgba(2, 6, 23, .85); text-align: center; padding: 1rem;
}
.v-error p { margin: 0; color: var(--danger); overflow-wrap: anywhere; }

/* 밝기 표시기: 왼쪽 절반을 세로로 쓰는 동안만 뜬다. 브라우저가 화면 밝기를
   못 바꿔 video 에 brightness 필터를 거는 방식이라, 지금 값이 몇 %인지
   눈으로 확인시켜야 사용자가 어디까지 내렸는지 안다. */
.v-bright {
  position: absolute; top: 50%; left: 0.9rem; z-index: 3;
  transform: translateY(-50%); pointer-events: none;
  display: flex; flex-direction: column; align-items: center; gap: 0.45rem;
  padding: 0.6rem 0.5rem; border-radius: 999px;
  background: rgba(2, 6, 23, .72); box-shadow: var(--shadow);
}
.v-bright svg { width: 18px; height: 18px; }
.v-bright-track {
  position: relative; width: 5px; height: 96px;
  border-radius: 999px; background: rgba(255, 255, 255, .22);
}
#v-bright-fill {
  position: absolute; left: 0; right: 0; bottom: 0; height: 100%;
  border-radius: 999px; background: linear-gradient(0deg, var(--accent), var(--accent-2));
}
#v-bright-val { font-size: 0.75rem; font-variant-numeric: tabular-nums; }

/* 건너뛰기 표시: 화면 절반을 두 번 짚으면 그쪽에 "+5초"/"−5초" 가 잠깐 뜬다.
   연타하면 누적 초가 보인다. */
.v-skip {
  position: absolute; top: 50%; z-index: 3; transform: translateY(-50%);
  pointer-events: none; padding: 0.45rem 0.9rem; border-radius: 999px;
  background: rgba(2, 6, 23, .72); box-shadow: var(--shadow);
  font-size: 0.95rem; font-weight: 600; font-variant-numeric: tabular-nums;
}
.v-skip.left { left: 18%; }
.v-skip.right { right: 18%; }
.v-skip.center { left: 50%; transform: translate(-50%, -50%); }

/* 화면 잠금: 잠그면 컨트롤을 그리지 않고 방패가 모든 터치를 받는다. 방패를 짚으면
   잠금 단추만 컨트롤처럼 잠깐 나왔다가 사라진다. */
.v-shield { display: none; position: absolute; inset: 0; z-index: 5; touch-action: none; }
.vplayer.locked .v-shield { display: block; }
.vplayer.locked .v-controls, .vplayer.locked #v-title, .vplayer.locked .v-skipchap, .vplayer.locked .v-upnext { display: none; }
.v-lock, .v-fit {
  position: absolute; z-index: 6; right: 0.6rem; top: max(0.5rem, env(safe-area-inset-top));
  display: flex; align-items: center; gap: 0.35rem;
  min-height: 40px; min-width: 40px; padding: 0.35rem 0.6rem; border-radius: 999px;
  background: rgba(2, 6, 23, .55); border-color: transparent; color: var(--text-2);
  transition: opacity .25s;
}
.v-lock svg, .v-fit svg { width: 19px; height: 19px; }
/* 컨트롤 막대는 360px 화면에서 이미 꽉 차서 비율 단추는 잠금 단추 왼쪽에 둔다 */
.v-fit { right: calc(1rem + 40px); }
.vplayer.idle .v-fit { opacity: 0; pointer-events: none; }
.vplayer.locked .v-fit { display: none; }
.v-lock .ic-shut, .v-lock span { display: none; }
.vplayer.locked .v-lock { color: var(--accent-2); }
.vplayer.locked .v-lock .ic-open { display: none; }
.vplayer.locked .v-lock .ic-shut, .vplayer.locked .v-lock span { display: inline; }
.vplayer.locked .v-lock span { font-size: 0.85rem; font-weight: 600; }
.vplayer.idle .v-lock { opacity: 0; pointer-events: none; }

/* 시크바: 터치 드래그와 마우스 hover 썸네일을 같은 영역에서 처리한다 */
#v-seekwrap { position: relative; height: 18px; display: flex; align-items: center; touch-action: none; cursor: pointer; }
#v-seek { position: relative; width: 100%; height: 5px; border-radius: 999px; background: rgba(255, 255, 255, .18); }
#v-buffer, #v-fill { position: absolute; top: 0; bottom: 0; left: 0; width: 0; border-radius: 999px; }
#v-buffer { background: rgba(255, 255, 255, .22); }
#v-fill { background: linear-gradient(90deg, var(--accent), var(--accent-2)); }
#v-dot {
  position: absolute; top: 50%; left: 0; width: 13px; height: 13px;
  transform: translate(-50%, -50%); border-radius: 50%; background: var(--accent-2);
  box-shadow: 0 1px 6px rgba(2, 6, 23, .6);
}
#v-thumb {
  position: absolute; bottom: calc(100% + 8px); width: 160px; height: 90px;
  transform: translateX(-50%); pointer-events: none;
  border: 1px solid var(--border-2); border-radius: 8px; overflow: hidden;
  background: #000; box-shadow: var(--shadow);
}
#v-thumb-img { width: 160px; height: 90px; background-repeat: no-repeat; }
#v-thumb-time {
  position: absolute; bottom: 4px; left: 50%; transform: translateX(-50%);
  background: rgba(2, 6, 23, .85); border-radius: 6px; padding: 0.05rem 0.4rem;
  font-size: 0.75rem; font-variant-numeric: tabular-nums; white-space: nowrap;
}

/* 컨트롤 바 */
.v-bar { display: flex; align-items: center; gap: 0.15rem; margin-top: 0.15rem; position: relative; }
.vbtn {
  background: transparent; border-color: transparent; color: var(--text-2);
  min-height: 36px; min-width: 36px; padding: 0.3rem; border-radius: 9px;
}
.vbtn:hover { background: rgba(255, 255, 255, .08); color: var(--text); }
.vbtn svg { width: 19px; height: 19px; }
#v-cc.on { color: var(--accent-2); }
#v-time { font-size: 0.82rem; color: var(--text-2); font-variant-numeric: tabular-nums; margin-left: 0.3rem; white-space: nowrap; }
#v-vol { width: 80px; accent-color: var(--accent); }
.v-speedwrap { position: relative; }
/* 자막 메뉴는 버튼이 아니라 막대 오른쪽 끝에 맞춘다 — 라벨이 길어 넓어진 메뉴를
   버튼 오른쪽에 맞추면 360px 화면에서 왼쪽 밖으로 밀려난다. */
.v-ccwrap { position: static; }
#v-speed { font-size: 0.85rem; font-weight: 600; }
.v-pop {
  position: absolute; bottom: calc(100% + 8px); right: 0; z-index: 5;
  background: linear-gradient(180deg, var(--surface-3), var(--surface-2));
  border: 1px solid var(--border-2); border-radius: var(--radius-sm); box-shadow: var(--shadow);
  padding: 0.3rem; display: grid; min-width: 84px;
  /* 부모(.v-ccwrap)가 버튼 폭이라 그대로 두면 팝업이 84px 로 줄어 자막 라벨이
     줄바꿈된다. 가장 긴 라벨 폭을 따르되 화면 밖으로는 넘기지 않는다. */
  width: max-content; max-width: min(320px, calc(100vw - 2rem));
  max-height: 60vh; overflow-y: auto; /* 트랙이 많은 파일도 화면 안에서 스크롤 */
}
.v-pop button {
  min-height: 36px; background: transparent; border-color: transparent; color: var(--text-2);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: left;
}
.v-pop button:hover { background: var(--surface-3); color: var(--text); }
.v-pop button.on { color: var(--accent-2); font-weight: 700; }
/* 자막 싱크 줄: −0.5 · 현재 값(누르면 0) · +0.5 */
.v-sync { display: grid; grid-template-columns: auto 1fr auto; gap: 0.15rem; border-top: 1px solid var(--border-2); margin-top: 0.2rem; padding-top: 0.2rem; }
.v-sync button { text-align: center; font-variant-numeric: tabular-nums; }
#v-sync-val, #v-size-val { color: var(--text); }
.v-size { border-top: 0; margin-top: 0; padding-top: 0; }
/* 싱크·크기 줄은 트랙 목록을 스크롤해도 메뉴 바닥에 남는다 */
.v-adj { position: sticky; bottom: -0.3rem; margin-bottom: -0.3rem; padding-bottom: 0.3rem; background: var(--surface-2); }
/* 챕터 경계: 시크바 위의 가는 틈 */
.v-chap { position: absolute; top: -1px; bottom: -1px; width: 2px; transform: translateX(-1px); background: rgba(2, 6, 23, .85); pointer-events: none; }
/* 오프닝·요약 건너뛰기: 컨트롤이 숨어 있어도 보인다 */
.v-skipchap {
  position: absolute; right: 1rem; bottom: 5.5rem; z-index: 4;
  padding: 0.5rem 1rem; border-radius: var(--radius-sm); border: 1px solid var(--border-2);
  background: rgba(2, 6, 23, .78); color: var(--text); font-weight: 600; box-shadow: var(--shadow);
}
.v-skipchap:hover { background: rgba(2, 6, 23, .92); }
/* 다음 화: 건너뛰기와 같은 자리, 같은 생김새. 크레딧이면 건너뛰기는 안 뜬다 */
.v-upnext { position: absolute; right: 1rem; bottom: 5.5rem; z-index: 4; display: flex; gap: 0.4rem; max-width: calc(100% - 2rem); }
.v-upnext.hidden { display: none; }
.v-upnext button {
  padding: 0.5rem 1rem; border-radius: var(--radius-sm); border: 1px solid var(--border-2);
  background: rgba(2, 6, 23, .78); color: var(--text); font-weight: 600; box-shadow: var(--shadow);
}
.v-upnext button:hover { background: rgba(2, 6, 23, .92); }
#v-upnext-go { display: flex; align-items: center; gap: 0.5rem; min-width: 0; }
.v-upnext-name { font-weight: 400; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 14rem; }
.v-upnext-n:not(:empty) { min-width: 1.6em; padding: 0 0.3em; border-radius: 999px; background: var(--accent); color: #0b1220; text-align: center; font-variant-numeric: tabular-nums; }
@media (max-width: 640px) { .v-upnext-name { max-width: 7rem; } }
/* 좁은 화면: 막대는 줄바꿈도 스크롤도 안 하므로(팝업이 위로 뜬다) 버튼이 안 들어가면
   플레이어 오른쪽 밖으로 밀려 전체화면 버튼을 누를 수 없다. 360px 세로 화면에
   음성·자막 버튼까지 켠 채로 들어가도록 여백·간격·버튼 폭을 줄인다. */
@media (max-width: 640px) {
  #v-vol { display: none; }
  /* 5초 이동은 화면 양옆 두 번 탭이 한다 */
  .v-jump { display: none; }
  /* 시간은 시크바 위 왼쪽으로 올린다 — 화질·음성·자막 단추까지 켜지면 막대 한 줄에
     시간 글자(긴 영상은 "1:23:45 / 2:10:00")까지 들어갈 자리가 없다. */
  #v-time { font-size: 0.75rem; position: absolute; left: 0.2rem; bottom: calc(100% + 20px); margin: 0; pointer-events: none; }
  .v-controls { padding-left: 0.35rem; padding-right: 0.35rem; }
  .v-bar { gap: 0; }
  .vbtn { min-width: 32px; padding: 0.3rem 0.2rem; }
}

/* 모달 오버레이: 비밀번호 변경·휴지통·공유 링크·이름 충돌 */
#passwd,
#trash,
#links,
#conflict {
  position: fixed; inset: 0; z-index: 10; background: rgba(2, 6, 23, .7);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  display: flex; align-items: center; justify-content: center;
}
#passwd.hidden,
#trash.hidden,
#links.hidden,
#conflict.hidden { display: none; }

/* 관리 축(톱니바퀴): 토렌트처럼 축 막대 사이를 채우는 패널이다. */
#admin {
  position: fixed; inset: var(--appbar-h) 0 var(--tabbar-h); z-index: 8; overflow-y: auto;
  overscroll-behavior: contain; background: var(--bg);
  padding: max(1rem, env(safe-area-inset-top)) 16px max(1.5rem, env(safe-area-inset-bottom));
}
#admin.hidden { display: none; }
.admin-wrap { max-width: 760px; margin: 0 auto; display: grid; gap: 1rem; }
.admin-head { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; }
.admin-head h2 { margin: 0; font-size: 1.4rem; font-weight: 800; letter-spacing: -0.02em; }
#admin-tabs {
  display: flex; gap: 4px; padding: 4px; border-radius: 14px; justify-self: start; max-width: 100%;
  background: rgba(20, 29, 49, .8); border: 1px solid rgba(148, 163, 184, .2);
}
#admin-tabs button {
  min-width: 112px; height: 40px; min-height: 40px; padding: 0 1rem; border: 0; border-radius: 10px;
  background: transparent; color: var(--text-2); font-size: 0.92rem; font-weight: 700;
}
#admin-tabs button:hover { background: var(--surface-3); color: var(--text); }
#admin-tabs button[aria-selected="true"] { background: var(--accent); color: var(--amber-ink); }
#admin .passwd-body { width: auto; min-width: 0; padding: 1.2rem; gap: 0.5rem; }
#admin .passwd-body h3 { margin: 0.3rem 0 0; font-size: 1rem; }
#admin .passwd-body .hint { margin: 0 0 0.4rem; font-size: 0.88rem; }
/* 격자 칸의 기본 최소 폭은 입력 칸의 고유 폭이라, 360px 폰에서 칸이 카드 밖으로 나갔다 */
#admin .passwd-body form { max-width: 460px; grid-template-columns: minmax(0, 1fr); }
#settings-saved { color: var(--ok); }
#settings-saved:empty, #settings-error:empty { display: none; }
#conflict .passwd-body { width: min(94vw, 460px); }
#conflict .hint { margin: 0.4rem 0 0.6rem; color: var(--muted); font-size: 0.85rem; }
#conflict-list { list-style: none; margin: 0.4rem 0; padding: 0; max-height: 40vh; overflow: auto; }
#conflict-list li { padding: 0.25rem 0; overflow-wrap: anywhere; }
#conflict-list li.more { color: var(--muted); }
.conflict-acts { display: flex; flex-wrap: wrap; gap: 0.5rem; }
/* 토렌트 축: 홈(#library)처럼 축 막대 사이를 채우는 패널이다. */
#torrents {
  position: fixed; inset: var(--appbar-h) 0 var(--tabbar-h); z-index: 8; overflow-y: auto;
  overscroll-behavior: contain; background: var(--bg);
  padding: 1rem 16px max(1.5rem, env(safe-area-inset-bottom));
}
#torrents.hidden { display: none; }
.torrent-wrap { max-width: 760px; margin: 0 auto; display: grid; gap: 1rem; }
.torrent-wrap .card { width: auto; min-width: 0; padding: 1.1rem; gap: 0; }
.torrent-wrap h3 { margin: 0 0 0.6rem; }
#tsearch-form { display: flex; gap: 0.5rem; }
#tsearch-q { flex: 1; min-width: 0; }
#tsearch-go { width: auto; flex: none; margin-top: 0; }  /* .card button stretches to the row (login card) */
#tsearch-status { margin: 0.5rem 0 0; overflow-wrap: anywhere; }
#tsearch-web-label { display: flex; align-items: center; gap: 0.4rem; margin-top: 0.5rem; min-height: 36px; font-size: 0.9rem; color: var(--text-2); cursor: pointer; }
#tsearch-web { width: 18px; height: 18px; margin: 0; flex: none; accent-color: var(--accent); }
/* 거르기는 줄을 숨길 뿐 다시 그리지 않는다 — 받기·자막 확인 단추의 상태가 체크를 풀어도 남는다 */
#tsearch-list.only-web .tsearch-row:not([data-subs="web"]) { display: none; }
#tsearch-status a { color: var(--accent-2); }
#tsearch-list { list-style: none; margin: 0.4rem 0 0; padding: 0; display: grid; gap: 0.4rem; }
.tsearch-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 0.3rem 0.6rem; padding: 0.5rem 0.7rem; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; }
.tsearch-row .torrent-name, .tsearch-row .torrent-info { grid-column: 1; }
.tsearch-btns { grid-column: 2; grid-row: 1 / span 2; display: flex; gap: 0.4rem; }
.tsearch-btns button { margin-top: 0; }  /* .card button adds a top margin that drops it below the row centre */
.tsearch-subs { display: inline-block; padding: 0 0.4rem; border-radius: 6px; font-size: 0.8rem; border: 1px solid var(--border-2); color: var(--muted); }
.tsearch-subs.multi { color: var(--accent-2); border-color: var(--accent); }
.tsearch-subs.kor { color: #fff; background: var(--accent); border-color: var(--accent); font-weight: 600; }
.tsearch-subs.none { color: var(--danger); border-color: currentColor; font-weight: 600; }
/* 출처 배지와 해상도·크기·날짜 표지: 글자와 테두리는 같은 색(--c), 바탕은 그 색을 옅게.
   회색 테두리 하나였을 때는 어두운 줄 위에서 읽히지 않았다. */
.tsearch-subs.web, .tchip {
  display: inline-block; padding: 0 0.4rem; border-radius: 6px; font-size: 0.8rem; font-weight: 600;
  color: var(--c, var(--muted)); border: 1px solid var(--c, var(--border-2));
  background: color-mix(in srgb, var(--c, transparent) 16%, transparent);
}
.tsearch-subs.web[data-src="NF"] { --c: #f87171; }
.tsearch-subs.web[data-src="DSNP"] { --c: #60a5fa; }
.tsearch-subs.web[data-src="AMZN"] { --c: #22d3ee; }
.tsearch-subs.web[data-src="ATVP"] { --c: #e5e7eb; }
.tsearch-subs.web[data-src="HMAX"] { --c: #c084fc; }
.tchip { white-space: nowrap; }
.tchip.res[data-tier="uhd"] { --c: #c084fc; }
.tchip.res[data-tier="fhd"] { --c: #4ade80; }
.tchip.res[data-tier="hd"] { --c: #60a5fa; }
.tchip.res[data-tier="sd"] { --c: #94a3b8; }
.tchip.size[data-tier="s1"] { --c: #94a3b8; }   /* 1GB 미만 */
.tchip.size[data-tier="s2"] { --c: #4ade80; }   /* 1~4GB */
.tchip.size[data-tier="s3"] { --c: #facc15; }   /* 4~10GB */
.tchip.size[data-tier="s4"] { --c: #fb923c; }   /* 10~30GB */
.tchip.size[data-tier="s5"] { --c: #f87171; }   /* 30GB 이상 */
.tchip.year[data-tier="y0"] { --c: #4ade80; }   /* 올해 */
.tchip.year[data-tier="y1"] { --c: #2dd4bf; }   /* 작년 */
.tchip.year[data-tier="y2"] { --c: #60a5fa; }   /* 2~3년 전 */
.tchip.year[data-tier="y3"] { --c: #a78bfa; }   /* 4~6년 전 */
.tchip.year[data-tier="y4"] { --c: #94a3b8; }   /* 그보다 오래 */
.tsearch-btns button.secondary { background: transparent; color: var(--accent-2); border: 1px solid var(--accent); }
.torrent-peek { display: grid; gap: 0.2rem; font-size: 0.88rem; color: var(--muted); overflow-wrap: anywhere; }
.torrent-peek .tsearch-subs { justify-self: start; }
.torrent-peek strong { color: var(--text); }
.tsearch-seed { color: var(--accent-2); font-weight: 600; }
#torrent-magnet { width: 100%; }
.torrent-add { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.5rem; }
#trash .passwd-body { width: min(94vw, 560px); }
#trash .hint { margin: 0.2rem 0 0.4rem; color: var(--muted); font-size: 0.88rem; }
#trash-list,
#links-list { list-style: none; margin: 0.4rem 0; padding: 0; max-height: 50vh; overflow: auto; display: grid; gap: 0.4rem; }
#torrent-list { list-style: none; margin: 0.4rem 0 0; padding: 0; display: grid; gap: 0.4rem; }
.trash-item,
.link-item,
.torrent { display: grid; gap: 0.3rem; padding: 0.5rem 0.7rem; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; }
.torrent-name { font-weight: 600; overflow-wrap: anywhere; }
.torrent-info, .torrent-empty { color: var(--muted); font-size: 0.85rem; }
.torrent-acts { display: flex; gap: 0.4rem; justify-content: flex-end; }
#links .passwd-body { width: min(94vw, 560px); }
#links .hint { margin: 0.2rem 0 0.4rem; color: var(--muted); font-size: 0.88rem; overflow-wrap: anywhere; }
#link-form { margin: 0.4rem 0; }
.link-field { display: flex; align-items: center; gap: 0.6rem; }
.link-field select { font: inherit; padding: 0.45rem 0.6rem; border: 1px solid var(--border-2); border-radius: var(--radius-sm); background: var(--surface); color: var(--text); }
/* 토렌트 축 맨 위: 받기·자막 확인·마그넷·파일 추가가 모두 이 위치로 간다 */
#torrent-target-label { padding: 0 0.25rem; font-size: 0.9rem; color: var(--text-2); }
#torrent-target { flex: 1; min-width: 0; min-height: 40px; }
.link-copy { display: flex; gap: 0.5rem; }
.link-copy input { flex: 1; min-width: 0; }

/* 저장장치 용량 띠: 루트 목록 위에 저장장치 하나당 한 줄 */
#storage { display: grid; gap: 0.35rem; padding: 0.75rem 0.5rem 0; }
#storage.hidden { display: none; }
/* 그리드 칸의 기본 min-width 는 내용 폭이라, 줄바꿈 없는 폴더 목록이 폰에서 페이지 전체를 넓혔다 */
.store > * { min-width: 0; }
.store { min-width: 0; display: grid; gap: 0.4rem; padding: 0.7rem 0.85rem; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; }
.store-head { display: flex; justify-content: space-between; gap: 0.6rem; font-size: 0.88rem; }
.store-label { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.store-nums { color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
/* 여유 있음 초록 · 75% 넘으면 amber · 90% 넘으면 빨강 */
.store-bar { height: 8px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.store-bar i { display: block; height: 100%; border-radius: 999px; background: var(--ok); }
.store-bar i.warn { background: var(--warn); }
.store-bar i.full { background: var(--danger); }
.store-folders { color: var(--muted); font-size: 0.8rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.passwd-body {
  width: min(92vw, 340px); padding: 1.6rem;
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
  border-radius: 16px;
}
.passwd-body h3 { margin: 0 0 0.2rem; }
.passwd-body form { display: grid; gap: 0.5rem; }
.passwd-body input { font: inherit; padding: 0.6rem; border: 1px solid var(--border-2); border-radius: var(--radius-sm); background: rgba(11, 18, 34, .6); color: var(--text); }
.passwd-body input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.passwd-body input[type="checkbox"] { width: 18px; height: 18px; min-height: 0; padding: 0; accent-color: var(--accent); }
.passwd-body button[type="submit"] {
  background: linear-gradient(180deg, var(--accent-2), var(--accent));
  color: #231303; border: none; font-weight: 700;
  box-shadow: 0 4px 14px rgba(245, 158, 11, .25);
}
.passwd-body button[type="submit"]:hover { filter: brightness(1.07); }
.passwd-body label { color: var(--muted); display: flex; align-items: center; gap: 0.5rem; }
/* 패널이 스스로 스크롤하므로 목록에 높이 상한을 두지 않는다. */
#users-list { list-style: none; margin: 0.2rem 0 0.6rem; padding: 0; display: grid; gap: 0.25rem; }
#users-list { gap: 0.4rem; }
#users-list li { background: rgba(11, 18, 34, .55); border: 1px solid var(--border); border-radius: 10px; padding: 0.65rem 0.75rem; }
.user-head { display: flex; align-items: center; gap: 0.75rem; }
.user-info { flex: 1; min-width: 0; display: grid; gap: 0.4rem; }
.user-name { font-weight: 700; color: var(--text); }
/* 권한 표지: 화면은 amber, 폴더는 회색 바탕에 밝은 글자, 관리자는 채운 amber */
.user-tag { display: flex; flex-wrap: wrap; gap: 0.3rem; }
.chip {
  display: inline-flex; align-items: center; padding: 0.12rem 0.55rem; border-radius: 999px;
  font-size: 0.8rem; font-weight: 600; line-height: 1.5; overflow-wrap: anywhere;
  color: var(--text-2); background: var(--surface-3); border: 1px solid var(--border-2);
}
.chip.screen { color: var(--accent-2); background: rgba(245, 158, 11, .14); border-color: rgba(245, 158, 11, .5); }
.chip.admin { color: var(--amber-ink); background: var(--accent); border-color: var(--accent); font-weight: 700; }
/* "편집"은 .card button 의 꽉 찬 amber 대신 테두리 단추 — 저장(꽉 찬 amber)과 구분된다 */
#users-list button.user-open {
  flex: none; width: auto; margin: 0; min-height: 36px; padding: 0.35rem 0.95rem;
  background: transparent; color: var(--accent-2); border: 1px solid var(--accent);
  box-shadow: none; font-weight: 700;
}
#users-list button.user-open:hover { background: rgba(245, 158, 11, .14); filter: none; }
#users-list button.user-open[aria-expanded="true"] { background: var(--surface-3); color: var(--text); border-color: var(--border-2); }
/* 삭제는 되돌릴 수 없어 빨간 테두리 — 편집 옆에 같은 크기로 서되 색으로 갈린다 */
#users-list button.user-delete {
  flex: none; width: auto; margin: 0; min-height: 36px; padding: 0.35rem 0.95rem;
  background: transparent; color: var(--danger); border: 1px solid var(--danger);
  box-shadow: none; font-weight: 700;
}
#users-list button.user-delete:hover { background: rgba(248, 113, 113, .14); filter: none; }
.user-edit { display: grid; gap: 0.4rem; margin-top: 0.5rem; }
.user-edit.hidden { display: none; }
.paths-editor, .screens-editor { display: grid; gap: 0.4rem; }
.paths-boxes { display: flex; flex-wrap: wrap; gap: 0.3rem 0.7rem; }
.paths-boxes label { color: var(--text); font-size: 0.88rem; }
.hint { margin: 0; color: var(--muted); font-size: 0.8rem; }
#user-add-paths.hidden { display: none; }
.passwd-body textarea {
  font: inherit; padding: 0.5rem; resize: vertical;
  border: 1px solid var(--border-2); border-radius: var(--radius-sm);
  background: rgba(11, 18, 34, .6); color: var(--text);
}
.passwd-body textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

/* 좁은 화면: 저빈도 헤더 버튼을 케밥(⋮) 메뉴로 — JS가 버튼 노드를 옮겨 온다.
   라벨은 aria-label 에서 가져와 뿌린다(문자열 중복 없음). header 가 sticky
   라는 positioned 조상에 붙는다. */
#menu-pop {
  position: absolute; top: calc(100% + 6px); right: 0.6rem; z-index: 30;
  background: linear-gradient(180deg, var(--surface-3), var(--surface-2));
  border: 1px solid var(--border-2); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 0.4rem; display: grid; gap: 0.25rem; min-width: 210px;
}
#menu-pop button { justify-content: flex-start; gap: 0.55rem; width: 100%; }
#menu-pop button::after { content: attr(aria-label); font-size: 0.92rem; }
#menu-pop button svg { flex: none; }
@media (min-width: 641px) {
  #btn-menu, #menu-pop { display: none !important; }
}
@media (max-width: 640px) {
  /* 막대가 늘 둘째 줄을 차지하므로 감싼다. breadcrumb 는 flex-basis 0 이라 첫 줄의
     단추를 밀어내지 않고 말줄임으로 줄어든다. */
  header { flex-wrap: wrap; }
  .upbtn span { display: none; }
  .spacer { display: none; } /* breadcrumb 가 flex:1 을 받아 밀어낸다 */
  #breadcrumb { flex: 1; min-width: 0; overflow: hidden; flex-wrap: nowrap; }
  #breadcrumb a { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  #breadcrumb a:not(:last-child) { flex: none; } /* 마지막 조각만 말줄임 */
  #breadcrumb .sep, #breadcrumb a svg { flex: none; }
  .entry-size { display: none; }

  /* 축은 엄지가 닿는 아래 탭이 된다. 켜진 탭은 그림 뒤 알약으로 표시한다. */
  #appbar {
    top: auto; bottom: 0; height: var(--tabbar-h); padding: 0 0 env(safe-area-inset-bottom);
    display: block; border-bottom: 0; border-top: 1px solid var(--border); background: rgba(11, 18, 34, .96);
  }
  .brand, .appbar-end { display: none; }
  #axis { height: 64px; display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 0; padding: 0; border: 0; border-radius: 0; background: none; }
  #axis button {
    width: auto; height: 64px; flex-direction: column; gap: 4px; border-radius: 0;
    font-size: 0.75rem; font-weight: 600; color: var(--muted);
  }
  #axis button:hover, #axis button[aria-current="page"] { background: transparent; }
  #axis button[aria-current="page"] { color: var(--accent-2); font-weight: 700; }
  .axis-ic { width: 64px; height: 32px; border-radius: 999px; transition: background .15s; }
  #axis button[aria-current="page"] .axis-ic { background: rgba(245, 158, 11, .18); }
}

@media (min-width: 640px) {
  .entry-date { display: block; }
}
@media (min-width: 700px) {
  #file-list { max-width: 1020px; }
}

/* Dark scrollbars */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 5px; }
::-webkit-scrollbar-track { background: transparent; }

/* 홈: 드라마·영화 작품 타일 (app/library.py). 헤더(5) 위, 전송 패널(9)·플레이어(10) 아래. */
#library {
  --lib-top: 3.5rem;
  --lib-pad: clamp(1rem, 4vw, 3rem);
  position: fixed; inset: var(--appbar-h) 0 var(--tabbar-h); z-index: 8; overflow-y: auto; overflow-x: hidden;
  overscroll-behavior: contain; background: var(--bg);
  padding-bottom: max(1.5rem, env(safe-area-inset-bottom));
  word-break: keep-all; overflow-wrap: anywhere; /* 한국어 줄거리를 낱말 중간에서 끊지 않는다 */
}
#library.hidden { display: none; }
/* 머리 막대는 맨 위 그림 위에 얹힌다 — 자기 높이만큼 아래 내용을 끌어올린다. */
.lib-top {
  position: sticky; top: 0; z-index: 2; display: flex; align-items: center; gap: 0.5rem;
  height: calc(var(--lib-top) + env(safe-area-inset-top));
  margin-bottom: calc(-1 * var(--lib-top) - env(safe-area-inset-top));
  padding: env(safe-area-inset-top) var(--lib-pad) 0;
  background: linear-gradient(rgba(11, 18, 34, .92), rgba(11, 18, 34, 0));
}
#lib-account { margin-left: auto; display: flex; gap: 0.25rem; }
.lib-brand { margin: 0; font-size: 1.5rem; font-weight: 800; letter-spacing: -0.02em; }
@media (min-width: 641px) {
  .lib-brand { display: none; } /* 넓은 화면은 위 막대의 "미디어" 세그먼트가 같은 말을 한다 */
}
#lib-rows.no-feature { padding-top: calc(var(--lib-top) + env(safe-area-inset-top)); }

/* 맨 위 그림: 이어볼 작품, 없으면 그날의 작품 */
.lib-feature {
  position: relative; display: flex; align-items: flex-end;
  min-height: min(68vh, 56.25vw + 6rem); margin-bottom: 0.4rem;
  background: var(--surface);
}
.lib-feature img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.lib-feature::after {
  content: ""; position: absolute; inset: 0;
  background:
    linear-gradient(to top, var(--bg) 0%, rgba(11, 18, 34, .75) 30%, rgba(11, 18, 34, 0) 65%),
    linear-gradient(to right, rgba(11, 18, 34, .8), rgba(11, 18, 34, 0) 60%);
}
.lib-feature-body {
  position: relative; z-index: 1; display: grid; gap: 0.5rem;
  width: min(100%, 36rem); padding: 5rem var(--lib-pad) 1rem;
}
.lib-feature h2 { margin: 0; font-size: clamp(1.6rem, 4.5vw, 2.8rem); line-height: 1.15; text-wrap: balance; }
.lib-feature-ov {
  margin: 0; color: var(--text-2); line-height: 1.55;
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; overflow: hidden;
}
.lib-feature .lib-prog { max-width: 16rem; }
.lib-meta { margin: 0; color: var(--text-2); font-size: 0.92rem; }

.lib-row { margin: 0.4rem 0 1.4rem; }
.lib-row h3 { margin: 0 var(--lib-pad) 0.55rem; font-size: 1.1rem; color: var(--text); }
.lib-strip {
  display: flex; gap: 0.65rem; overflow-x: auto; padding: 0.25rem var(--lib-pad) 0.5rem;
  scroll-snap-type: x proximity; scroll-padding-inline: var(--lib-pad); scrollbar-width: thin;
}
.lib-tile {
  position: relative; flex: 0 0 auto; width: clamp(112px, 28vw, 180px); aspect-ratio: 2 / 3;
  padding: 0; overflow: hidden; border-radius: var(--radius-sm); scroll-snap-align: start;
  background: var(--surface); border: 1px solid var(--border); display: block; text-align: left;
  transition: border-color .15s, transform .2s;
}
.lib-tile.wide { width: clamp(220px, 62vw, 320px); aspect-ratio: 16 / 9; }
.lib-tile img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
/* 이름은 그림 밑에 깔려 있다가 그림이 없을 때(noart) 가운데에 보인다. 넓은 타일은 늘 그림 위다. */
.lib-cap { position: absolute; inset: 0; display: grid; align-content: end; gap: 0.15rem; padding: 0.6rem; }
.lib-name { font-weight: 700; font-size: 0.95rem; line-height: 1.25; overflow-wrap: anywhere; color: var(--text); }
.lib-sub { font-size: 0.8rem; color: var(--text-2); }
.lib-tile:not(.wide):not(.noart) .lib-cap { visibility: hidden; }
.lib-tile.noart {
  background:
    radial-gradient(120% 70% at 50% 0%, rgba(245, 158, 11, .16), transparent 70%),
    linear-gradient(170deg, var(--surface-3), var(--surface));
}
.lib-tile.noart:not(.wide) .lib-cap { align-content: center; justify-items: center; text-align: center; padding: 0.8rem; }
.lib-tile.noart:not(.wide) .lib-name { font-size: 1.02rem; }
.lib-tile.wide::after {
  content: ""; position: absolute; inset: 35% 0 0; background: linear-gradient(transparent, rgba(2, 6, 23, .92));
}
.lib-tile.wide .lib-cap { z-index: 1; padding-bottom: 0.85rem; text-shadow: 0 1px 3px rgba(0, 0, 0, .9); }
.lib-tile .lib-prog { position: absolute; left: 0.6rem; right: 0.6rem; bottom: 0.45rem; z-index: 1; }
.lib-prog { height: 3px; border-radius: 2px; background: rgba(241, 245, 249, .25); overflow: hidden; }
.lib-prog i { display: block; height: 100%; background: var(--accent); }
@media (hover: hover) {
  .lib-tile:hover { border-color: var(--accent); transform: translateY(-2px); }
}
.lib-tile:focus-visible { border-color: var(--accent); }

/* 상세: 화면 폭 그림 + 그 아래 가운데 정렬한 정보 */
.lib-hero {
  position: relative; display: flex; align-items: flex-end;
  height: min(62vh, 56.25vw); min-height: 11rem; background: var(--surface); overflow: hidden;
}
.lib-hero.noart {
  height: auto; min-height: calc(var(--lib-top) + 6rem);
  background: radial-gradient(90% 120% at 15% 0%, rgba(245, 158, 11, .14), transparent 70%), var(--surface);
}
.lib-hero img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.lib-hero::after { content: ""; position: absolute; inset: 0; background: linear-gradient(to top, var(--bg) 0%, rgba(11, 18, 34, .6) 35%, rgba(11, 18, 34, 0) 70%); }
.lib-hero h2 {
  position: relative; z-index: 1; width: min(100%, 1100px); margin: 0 auto;
  padding: 0 var(--lib-pad) 0.3rem; font-size: clamp(1.6rem, 4.5vw, 2.8rem); line-height: 1.15; text-wrap: balance;
}
.lib-info { width: min(100%, 1100px); margin: 0 auto; padding: 0 var(--lib-pad); }
.lib-acts { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0.8rem 0; }
.lib-acts .primary { background: var(--accent); color: #111; border-color: var(--accent); font-weight: 700; padding-inline: 1.3rem; }
.lib-acts .primary:hover { background: var(--accent-2); }
.lib-acts button:not(.primary, .danger) { background: rgba(36, 51, 82, .75); }
.lib-info > .lib-prog { max-width: 20rem; margin: -0.3rem 0 0.9rem; }
.lib-overview { color: var(--text-2); line-height: 1.65; margin: 0 0 1.2rem; max-width: 70ch; }
.lib-seasons {
  display: flex; gap: 0.4rem; overflow-x: auto; margin: 0 calc(-1 * var(--lib-pad)) 0.8rem;
  padding: 0.15rem var(--lib-pad) 0.35rem; scrollbar-width: none;
}
.lib-seasons button { flex: 0 0 auto; border-radius: 999px; padding-inline: 1rem; color: var(--text-2); }
.lib-seasons button[aria-pressed="true"] { background: var(--text); color: var(--bg); border-color: var(--text); font-weight: 700; }
/* 줄의 안쪽 여백만큼 바깥으로 내어 썸네일 왼쪽 끝을 제목·시즌 줄에 맞춘다. */
.lib-eps { list-style: none; margin: 0 -0.6rem; padding: 0; display: grid; gap: 0.25rem; }
.lib-ep {
  width: 100%; display: flex; align-items: flex-start; gap: 0.9rem; text-align: left;
  padding: 0.6rem; background: transparent; border-color: transparent;
}
/* 전역 button:hover 는 터치에서 마지막으로 누른 줄에 남는다 */
.lib-ep:hover { background: transparent; }
@media (hover: hover) {
  .lib-ep:hover { background: var(--surface); }
}
.lib-ep-thumb {
  position: relative; flex: 0 0 auto; width: clamp(120px, 30vw, 200px); aspect-ratio: 16 / 9;
  border-radius: 6px; overflow: hidden; background: linear-gradient(160deg, var(--surface-3), var(--surface));
}
.lib-ep-thumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.lib-ep-thumb .lib-prog { position: absolute; left: 0; right: 0; bottom: 0; border-radius: 0; }
.lib-ep-text { flex: 1 1 auto; min-width: 0; display: grid; gap: 0.25rem; align-content: start; }
.lib-ep-head { display: flex; align-items: baseline; gap: 0.5rem; min-width: 0; }
.lib-ep-label { font-weight: 700; white-space: nowrap; }
.lib-ep-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lib-ep-file { color: var(--muted); font-size: 0.85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lib-ep-ov {
  color: var(--muted); font-size: 0.86rem; line-height: 1.5;
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden;
}
.lib-ep-meta { color: var(--muted); font-size: 0.8rem; }
.lib-ep-text > .lib-prog { max-width: 12rem; }
@media (max-width: 560px) {
  .lib-ep-ov { -webkit-line-clamp: 2; font-size: 0.82rem; }
  .lib-feature-ov { -webkit-line-clamp: 2; }
}
