    *, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
    :root {
      --bg: #1a1a1a; --bg2: #242424; --bg3: #2e2e2e; --bg4: #383838;
      --accent: #e5a00d; --accent2: #f0b429;
      --text: #e5e5e5; --text2: #aaa; --text3: #666;
      --border: #333; --card-w: 160px; --card-h: 240px;
    }
    html { height: 100%; height: 100dvh; overflow: hidden; }
    body { background: var(--bg); color: var(--text); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; display: flex; height: 100vh; height: 100dvh; overflow: hidden; }

    /* SIDEBAR */
    #sidebar { width: 252px; min-width: 252px; background: #081012; display: flex; flex-direction: column; border-right: 1px solid #243238; overflow-y: auto; scrollbar-width: thin; scrollbar-color: #3c4c52 transparent; }
    #sidebar::-webkit-scrollbar { width: 8px; }
    #sidebar::-webkit-scrollbar-track { background: transparent; }
    #sidebar::-webkit-scrollbar-thumb { background: #344348; border-radius: 8px; border: 2px solid #0b1012; }
    #sidebar-logo { height: 56px; padding: 0 16px; display: flex; align-items: center; gap: 10px; border-bottom: 1px solid #223036; background: #0c1518; flex-shrink: 0; }
    #sidebar-logo svg { width: 20px; height: 20px; color: var(--accent); flex-shrink: 0; }
    #sidebar-logo span { font-size: 15px; font-weight: 800; color: #f5f7f8; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .sidebar-section { padding: 10px 0 4px; flex: 1; min-height: 0; }
    .sidebar-section > .sidebar-section-label { font-size: 12px; font-weight: 800; text-transform: uppercase; color: #8b989f; padding: 10px 16px 8px; letter-spacing: 0; }
    .server-group-header { height: 34px; display: flex; align-items: center; gap: 8px; margin: 11px 8px 4px; padding: 0 9px; color: #f3f5f6; font-size: 14px; font-weight: 800; background: #0e191d; border-top: 1px solid #1f2c31; border-bottom: 1px solid #142126; border-radius: 5px; }
    .server-group-header:first-child { margin-top: 2px; }
    .server-group-header.offline { color: #9aa5aa; }
    .server-status { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 2px rgba(229,160,13,.18); flex-shrink: 0; }
    .server-group-header.offline .server-status { background: #6b7280; box-shadow: none; }
    .server-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #f0b429; }
    .server-offline-tag { margin-left: 2px; color: #7d8a91; font-size: 12px; font-weight: 600; white-space: nowrap; }
    .server-chevron { margin-left: auto; color: #65727a; font-size: 11px; line-height: 1; }
    .lib-item { height: 36px; display: flex; align-items: center; gap: 10px; padding: 0 9px 0 25px; cursor: pointer; color: #d0d9dd; font-size: 14.5px; font-weight: 560; position: relative; border-radius: 5px; margin: 1px 7px; }
    .lib-item::before { content: ''; position: absolute; left: 0; top: 5px; bottom: 5px; width: 3px; border-radius: 0 3px 3px 0; background: transparent; }
    .lib-item:hover { background: #142025; color: #f3f6f7; }
    .lib-item.active { background: #20282d; color: #fff; box-shadow: inset 0 0 0 1px rgba(255,255,255,.035); }
    .lib-item.active::before { background: var(--accent); }
    .lib-item .lib-icon { width: 20px; height: 20px; display: inline-flex; align-items: center; justify-content: center; color: #aeb9be; flex-shrink: 0; }
    .lib-item .lib-icon svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
    .lib-item.active .lib-icon { color: var(--accent); }
    .lib-item .lib-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .lib-item .lib-actions { display: none; gap: 3px; flex-shrink: 0; }
    .lib-item:hover .lib-actions, .lib-item .lib-actions.open { display: flex; }
    .lib-action-btn { width: 24px; height: 24px; background: transparent; border: none; color: #69767d; cursor: pointer; padding: 0; border-radius: 4px; font-size: 13px; line-height: 24px; }
    .lib-action-btn:hover { color: var(--accent); background: #263136; }
    .lib-action-menu { display: none; position: fixed; z-index: 1000; min-width: 148px; padding: 6px; background: #242424; border: 1px solid #3a3a3a; border-radius: 6px; box-shadow: 0 10px 26px rgba(0,0,0,.38); }
    .lib-action-menu.open { display: flex; flex-direction: column; }
    .lib-action-menu-item { width: 100%; min-height: 30px; padding: 0 10px; border: 0; border-radius: 4px; background: transparent; color: var(--text); text-align: left; cursor: pointer; font-size: 13px; font-weight: 650; }
    .lib-action-menu-item:hover { background: #303030; color: #fff; }
    .lib-action-menu-item.danger { color: #fca5a5; }
    .lib-action-menu-item.danger:hover { background: rgba(185,28,28,.22); color: #fecaca; }
    #add-library-btn { margin: 8px 10px 12px; padding: 0 10px; height: 34px; background: #0b1417; border: 1px dashed #314147; color: #8b989f; cursor: pointer; border-radius: 5px; font-size: 13px; width: calc(100% - 20px); flex-shrink: 0; }
    #add-library-btn:hover { border-color: var(--accent); color: var(--accent); background: rgba(229,160,13,.05); }

    /* MAIN */
    #main { flex: 1; display: flex; flex-direction: column; overflow: hidden; position: relative; container-type: inline-size; }
    #topbar { display: flex; align-items: center; gap: 12px; padding: 12px 24px; border-bottom: 1px solid var(--border); background: var(--bg2); }
    /* min-width:0 이 없으면 flex 아이템의 최소 폭이 '내용 최소 폭'이라, 좁아질 때
       줄어드는 대신 CJK 는 한 글자씩 세로로 흐른다(실측: 태블릿 세로에서 제목이
       세로 한 줄로 늘어져 탑바 전체를 밀어냈다). nowrap + ellipsis 로 못 박는다. */
    #library-title { font-size: 22px; font-weight: 700; flex: 1; min-width: 0;
      white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    #tabs { display: flex; gap: 4px; }
    .tab-btn { padding: 6px 14px; background: none; border: none; color: var(--text2); cursor: pointer; font-size: 14px; border-bottom: 2px solid transparent; }
    .tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }
    #search-box { flex: 1 1 auto; min-width: 0; width: auto; padding: 6px 8px 6px 12px; background: transparent; border: none; border-radius: 20px 0 0 20px; color: var(--text); font-size: 13px; outline: none; }
    #search-wrap:focus-within { border-color: var(--accent); }
    #media-view-controls { position: relative; z-index: 20; display: flex; align-items: center; gap: 12px; color: var(--text2); flex: 0 0 auto; }
    #topbar > #media-view-controls { display: none; }
    /* #media-view-controls는 #main 기준 고정 좌표(top:74px)로 떠 있어서, 그 자리에 다른
       고정 바(스캔 진행바/다중 선택 액션바)가 뜨면 sibling flow와 무관하게 겹쳐버린다
       (실측 — 다중 선택 시 선택 바와 뷰/줌 컨트롤이 서로 얹혀 보였다). 그 바들이 보이는
       동안은 900px 이하 모바일에서 이미 쓰던 "topbar 안 일반 플로우" 배치로 되돌려
       겹치지 않게 한다. */
    #main:has(#bulk-select-bar.visible) #media-view-controls,
    #main:has(#scan-progress-bar.visible) #media-view-controls { position: relative; }
    #grid-zoom { display: flex; align-items: center; width: 122px; height: 40px; color: var(--text2); flex-shrink: 0; transition: opacity .12s; }
    #media-view-controls.zoom-disabled #grid-zoom { opacity: .28; pointer-events: none; }
    #grid-zoom-slider { -webkit-appearance: none; appearance: none; width: 122px; height: 3px; background: #454545; border-radius: 2px; outline: none; cursor: pointer; }
    #grid-zoom-slider::-webkit-slider-thumb { -webkit-appearance: none; appearance: none; width: 17px; height: 17px; border-radius: 50%; background: #d7d7d7; cursor: pointer; }
    #grid-zoom-slider::-moz-range-thumb { width: 17px; height: 17px; border-radius: 50%; background: #d7d7d7; border: none; cursor: pointer; }
    #view-menu-btn { width: 48px; height: 40px; display: flex; align-items: center; justify-content: center; gap: 4px; border: none; border-radius: 5px; background: transparent; color: #cfd4d7; cursor: pointer; position: relative; }
    #view-menu-btn:hover, #view-menu-btn[aria-expanded="true"] { background: #2b2b2b; color: #fff; }
    .view-icon { display: none; width: 24px; height: 24px; }
    body[data-media-view="grid"] .view-icon-grid, body[data-media-view="detail"] .view-icon-detail, body[data-media-view="table"] .view-icon-table { display: block; }
    .view-menu-caret { font-size: 12px; line-height: 1; color: #9aa1a5; transform: translateY(-1px); }
    #view-menu { display: none; position: absolute; top: 44px; right: 0; width: 168px; padding: 8px 0; background: #232323; border: 1px solid #393939; border-radius: 6px; box-shadow: 0 12px 32px rgba(0,0,0,.55); }
    #view-menu.open { display: block; }
    .view-menu-item { width: 100%; height: 40px; display: flex; align-items: center; gap: 8px; padding: 0 14px; border: none; background: transparent; color: #cbd1d5; font-size: 15px; text-align: left; cursor: pointer; }
    .view-menu-item:hover { background: #303030; color: #fff; }
    .view-menu-check { width: 14px; color: transparent; font-size: 12px; }
    .view-menu-item.active { color: #f2f2f2; }
    .view-menu-item.active .view-menu-check { color: var(--accent); }
    /* 검색창 + 범위 선택 톱니 */
    #search-wrap { position: relative; display: inline-flex; align-items: center; gap: 0; flex: 0 1 250px; min-width: 118px; max-width: 250px; background: var(--bg3); border: 1px solid var(--border); border-radius: 20px; overflow: visible; order: 10; }
    /* Login state and responsive modes must not reorder the right-side tools. */
    #sessions-btn { order: 20; }
    #settings-btn { order: 30; }
    #notif-bell-btn { order: 40; }
    #user-menu-btn { order: 50; }
    #search-scope-btn { width: 34px; height: 30px; margin-right: 2px; display: flex; align-items: center; justify-content: center; border: none; border-left: 1px solid rgba(255,255,255,.08); border-radius: 0 18px 18px 0; background: transparent; color: var(--text2); cursor: pointer; flex-shrink: 0; }
    #search-scope-btn:hover, #search-scope-btn[aria-expanded="true"] { background: rgba(255,255,255,.08); color: var(--text); }
    #search-scope-btn svg { width: 17px; height: 17px; }
    #search-scope-menu { display: none; position: absolute; top: 38px; right: 0; z-index: 30; width: 200px; padding: 6px 0; background: #232323; border: 1px solid #393939; border-radius: 6px; box-shadow: 0 12px 32px rgba(0,0,0,.55); }
    #search-scope-menu.open { display: block; }
    .search-scope-title { padding: 4px 14px 6px; font-size: 12px; color: #8b9296; }
    .search-scope-item { width: 100%; height: 38px; display: flex; align-items: center; gap: 8px; padding: 0 14px; border: none; background: transparent; color: #cbd1d5; font-size: 14px; text-align: left; cursor: pointer; }
    .search-scope-item:hover { background: #303030; color: #fff; }
    .search-scope-check { width: 14px; color: transparent; font-size: 12px; }
    .search-scope-item.active { color: #f2f2f2; }
    .search-scope-item.active .search-scope-check { color: var(--accent); }
    .topbar-btn { padding: 7px 14px; background: var(--accent); color: #000; border: none; border-radius: 6px; font-size: 13px; font-weight: 600; cursor: pointer; }
    .topbar-btn:hover { background: var(--accent2); }
    .topbar-btn.secondary { background: var(--bg3); color: var(--text); border: 1px solid var(--border); }
    .topbar-btn.secondary:hover { background: var(--bg4); }

    /* SCAN PROGRESS BAR */
    #scan-progress-bar { display: none; background: var(--bg2); border-bottom: 1px solid var(--border); padding: 8px 24px; }
    #scan-progress-bar.visible { display: block; }
    .scan-progress-track { height: 4px; background: var(--bg4); border-radius: 2px; overflow: hidden; margin-bottom: 6px; }
    .scan-progress-fill { height: 100%; background: var(--accent); border-radius: 2px; transition: width .3s ease; }
    .scan-progress-info { display: flex; align-items: center; gap: 12px; justify-content: space-between; font-size: 12px; color: var(--text2); }
    .scan-progress-file { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; min-width: 0; }
    #scan-progress-count { flex-shrink: 0; }

    /* CONTENT */
    #content { flex: 1; min-height: 0; overflow-y: auto; padding: 24px; -webkit-overflow-scrolling: touch; overscroll-behavior-y: contain; }
    /* 라이브러리 목록에서는 제목(topbar)과 카드 크기 컨트롤이 이미 고정되어 있다.
       필터/정렬과 전체 항목 수도 같은 머리 영역으로 묶어 카드 목록만 스크롤한다. */
    #content:has(> .browse-list-header) { padding-top: 0; }
    .browse-list-header {
      position: sticky;
      top: 0;
      z-index: 15;
      /* 카드 크기 컨트롤과 필터 버튼의 높이를 맞추고, 확보한 공간은 항목 수 아래로
         옮긴다. 마지막 자식 margin은 부모 밖으로 collapse될 수 있으므로 실제 padding으로
         고정 헤더 배경 안에 여유를 확보한다. */
      padding-top: 14px;
      padding-bottom: 20px;
      padding-right: 0;
      background: var(--bg);
    }
    .browse-list-header .show-toolbar { margin-bottom: 0; width: 100%; }
    .browse-list-header .show-toolbar > #media-view-controls { margin-left: auto; order: 100; }
    .browse-list-header .library-stat {
      /* Plex처럼 마지막 필터/정렬 카드 바로 뒤에 항목 수를 둔다. */
      margin-left: 2px;
      color: var(--text2);
      font-size: 15px;
      font-weight: 500;
      white-space: nowrap;
      padding: 0 4px;
    }

    /* BREADCRUMB */
    #breadcrumb { display: flex; align-items: center; gap: 6px; margin-bottom: 16px; font-size: 16px; color: var(--text2); }
    #breadcrumb span { cursor: pointer; }
    #breadcrumb span:hover { color: var(--accent); }
    #breadcrumb .sep { color: var(--text3); }

    /* SHOW TOOLBAR */
    .show-toolbar { display: flex; align-items: center; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
    .tb-dropdown { position: relative; display: inline-block; }
    .tb-dropdown-btn { display: flex; align-items: center; gap: 5px; padding: 5px 12px; border-radius: 6px; border: 1px solid var(--border); background: var(--bg3); color: var(--text); font-size: 13px; cursor: pointer; white-space: nowrap; }
    .tb-dropdown-btn:hover { border-color: var(--accent); }
    .tb-dropdown-btn.active { border-color: var(--accent); color: var(--accent); }
    .tb-dropdown-btn .tb-arrow { font-size: 10px; opacity: .6; }
    .tb-dropdown-menu { position: absolute; top: calc(100% + 4px); left: 0; min-width: 160px; background: var(--bg3); border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.6); z-index: 300; overflow: hidden; display: none; }
    .tb-dropdown-menu.open { display: block; }
    .tb-dropdown-item { padding: 9px 14px; font-size: 13px; cursor: pointer; color: var(--text2); display: flex; align-items: center; gap: 8px; }
    .tb-dropdown-item:hover { background: var(--bg4); color: var(--text); }
    .tb-dropdown-item.selected { color: var(--accent); font-weight: 600; }
    .tb-dropdown-item .tb-check { font-size: 11px; width: 14px; }

    /* POSTER GRID */
    .section-label { font-size: 13px; color: var(--text2); margin-bottom: 14px; }
    .poster-grid { display: flex; flex-wrap: wrap; gap: 16px; }
    .poster-card { width: var(--card-w); cursor: pointer; }
    /* 앨범 카드만 예외: 아티스트명이 카드 전체 클릭과 별개로 동작하는 자체 링크라,
       카드 전체 hover로 포스터가 확대되면 아티스트/앨범 글자에 마우스를 올려도 포스터가
       클릭되는 것처럼 보인다. :not()으로 아예 다른 규칙을 적용해 포스터 위에 마우스가
       있을 때만(자기 자신의 :hover) 확대되게 한다 — "카드 hover 시 썸네일 확대"와
       "썸네일 자체 hover 시 확대"를 같은 우선순위로 겹쳐두면(단순 덮어쓰기) 마우스가
       실제로 썸네일 위에 있을 때 카드도 함께 :hover 상태라 상위 규칙이 다시 이겨버린다. */
    .poster-grid:not(.album-grid) .poster-card:hover .poster-thumb { transform: scale(1.03); box-shadow: 0 6px 24px rgba(0,0,0,.6); }
    .album-grid .poster-thumb:hover { transform: scale(1.03); box-shadow: 0 6px 24px rgba(0,0,0,.6); }
    .poster-thumb { width: var(--card-w); height: var(--card-h); border-radius: 8px; overflow: hidden; position: relative; transition: transform .15s, box-shadow .15s; }
    .poster-bg { width: 100%; height: 100%; object-fit: cover; }
    /* 음악(아티스트/앨범): 쇼·영화 대비 작게, 세로 포스터가 아닌 멜론/플렉스식 정사각형.
       .music-grid 기본값(0.85배)은 초성/유사 아티스트처럼 별도 크기 클래스가 없는 곳의
       폴백이고, 아티스트 목록(.artist-grid)과 앨범 목록(.album-grid)은 Plex 기준 한
       화면에 9~10장 정도로 보이도록 더 크게 키운다 — 포스터 크기가 작으면 바로 아래
       아티스트명/앨범명 글자도 작아지고 줄 간격도 좁아져 클릭하기 힘들어지기 때문. */
    .poster-grid.music-grid { gap: 14px; }
    .music-grid .poster-card { width: calc(var(--card-w) * 0.85); }
    .music-grid .poster-thumb { width: calc(var(--card-w) * 0.85); height: calc(var(--card-w) * 0.85); border-radius: 6px; }
    .music-grid.artist-grid .poster-card,
    .music-grid.album-grid .poster-card { width: calc(var(--card-w) * 1.05); }
    .music-grid.artist-grid .poster-thumb,
    .music-grid.album-grid .poster-thumb { width: calc(var(--card-w) * 1.05); height: calc(var(--card-w) * 1.05); border-radius: 6px; }
    .music-grid.artist-grid .poster-title,
    .music-grid.album-grid .poster-title { font-size: 14.5px; margin-top: 14px; }
    /* Artist-detail albums are slightly smaller than the full album browser. */
    .music-grid.album-grid.artist-album-grid .poster-card { width: calc(var(--card-w) * 0.98); }
    .music-grid.album-grid.artist-album-grid .poster-thumb {
      width: calc(var(--card-w) * 0.98);
      height: calc(var(--card-w) * 0.98);
    }
    /* 앨범 카드는 포스터 바로 아래 아티스트명(크게, 클릭 가능) → 그 아래 앨범명(작게)
       순서 — Plex와 동일. 두 줄이 붙어 있으면 클릭 영역이 서로 겹치므로 앨범명 줄을
       아티스트 줄과 확실히 띄운다. */
    /* .poster-sub 뒤에 오는 기본 규칙(margin-top:2px)과 동일 명시도라 순서에 따라 밀릴 수
       있으므로 .poster-sub.album-title-row로 명시도를 올려 확실히 이긴다. */
    .poster-sub.album-title-row {
      font-size: 12px;
      line-height: 1.35;
      margin-top: 6px;
      overflow: hidden;
      display: -webkit-box;
      -webkit-line-clamp: 2;
      -webkit-box-orient: vertical;
    }
    .album-artist-link { display: inline-block; padding: 2px 0; cursor: pointer; }
    .album-artist-link:hover { color: var(--accent); text-decoration: underline; }
    /* Album titles behave like artist links: underline only while the text itself is hovered. */
    .album-grid .album-title-row:hover,
    .album-grid .poster-card > .poster-title:not(.album-artist-link):hover {
      color: var(--accent);
      text-decoration: underline;
    }
    .poster-placeholder { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; font-size: 42px; font-weight: 700; color: rgba(255,255,255,.25); letter-spacing: -2px; }
    .poster-badge { position: absolute; top: 6px; right: 6px; background: rgba(0,0,0,.75); color: var(--accent); font-size: 11px; font-weight: 700; padding: 2px 6px; border-radius: 4px; }
    .poster-title { margin-top: 8px; font-size: 13px; font-weight: 500; line-height: 1.3; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
    .poster-sub { font-size: 12px; color: var(--text2); margin-top: 2px; }
    /* card context menu (Plex-style) */
    .poster-card { position: relative; }
    .card-menu-btn { position: absolute; bottom: 6px; right: 6px; background: rgba(0,0,0,.8); border: none; color: var(--text); cursor: pointer; width: 28px; height: 28px; border-radius: 50%; font-size: 16px; line-height: 28px; text-align: center; display: none; z-index: 2; }
    .poster-card:hover .card-menu-btn { display: block; }
    .card-menu-btn:hover { background: var(--accent); color: #000; }
    .card-edit-btn { position: absolute; bottom: 6px; left: 6px; background: rgba(0,0,0,.8); border: none; color: var(--text); cursor: pointer; width: 28px; height: 28px; border-radius: 50%; display: none; z-index: 2; align-items: center; justify-content: center; }
    .poster-card:hover .card-edit-btn { display: flex; }
    .card-edit-btn:hover { background: var(--accent); color: #000; }
    .card-edit-btn svg { width: 14px; height: 14px; }
    /* Album edit/menu controls belong to the poster, not to title hover. */
    .album-grid .poster-card:hover .card-menu-btn,
    .album-grid .poster-card:hover .card-edit-btn { display: none; }
    .album-grid .poster-thumb:hover .card-menu-btn { display: block; }
    .album-grid .poster-thumb:hover .card-edit-btn { display: flex; }
    .hero-edit-btn { position: absolute; bottom: 8px; left: 8px; background: rgba(0,0,0,.8); border: none; color: var(--text); cursor: pointer; width: 30px; height: 30px; border-radius: 50%; display: flex; align-items: center; justify-content: center; z-index: 2; }
    .hero-edit-btn:hover { background: var(--accent); color: #000; }
    .hero-edit-btn svg { width: 15px; height: 15px; }
    /* 카드 드롭다운: fixed로 뷰포트 기준 위치 (JS로 좌표 계산) */
    .card-dropdown { position: fixed; background: var(--bg3); border: 1px solid var(--border); border-radius: 8px; min-width: 150px; z-index: 500; box-shadow: 0 8px 24px rgba(0,0,0,.7); display: none; overflow: hidden; }
    .card-dropdown.open { display: block; }
    .card-dropdown-item { padding: 11px 16px; font-size: 13px; cursor: pointer; color: var(--text); white-space: nowrap; }
    .card-dropdown-item:hover { background: var(--bg4); color: var(--accent); }
    @media (max-width: 640px) {
      .card-menu-btn { display: block; width: 22px; height: 22px; font-size: 13px; line-height: 22px; bottom: 4px; right: 4px; }
      .card-edit-btn { display: flex; width: 22px; height: 22px; bottom: 4px; left: 4px; }
      .card-dropdown-item { padding: 13px 16px; font-size: 14px; }
    }

    /* 카드 다중 선택 배지 — Plex 라이브러리 화면의 좌상단 체크서클과 동일한 자리/느낌.
       기존 좌하단 편집/우하단 "⋮" 메뉴와 겹치지 않게 상단 코너에 둔다. 호버 중이거나
       이미 선택된 카드에서만 보인다(선택 안 된 카드는 평소처럼 깨끗하게). */
    .card-select-badge { position: absolute; top: 6px; left: 6px; width: 18px; height: 18px; border-radius: 50%; background: rgba(0,0,0,.55); border: 1.5px solid rgba(255,255,255,.7); color: transparent; cursor: pointer; display: none; align-items: center; justify-content: center; z-index: 3; padding: 0; }
    .poster-card:hover .card-select-badge,
    .poster-thumb:hover .card-select-badge,
    .poster-card.bulk-selected .card-select-badge { display: flex; }
    .card-select-badge svg { width: 10px; height: 10px; }
    .card-select-badge:hover { border-color: var(--accent); }
    .poster-card.bulk-selected .card-select-badge { background: var(--accent); border-color: var(--accent); color: #101215; }
    .poster-card.bulk-selected .poster-thumb { outline: 3px solid var(--accent); outline-offset: -3px; }
    .card-sync-spinner { position: absolute; top: 6px; right: 6px; width: 22px; height: 22px; border-radius: 50%; background: rgba(0,0,0,.6); display: none; align-items: center; justify-content: center; z-index: 4; pointer-events: none; }
    .poster-card.card-syncing .card-sync-spinner { display: flex; }
    .card-sync-spinner::after { content: ''; width: 12px; height: 12px; border: 2px solid rgba(255,255,255,.3); border-top-color: var(--accent); border-radius: 50%; animation: spin .7s linear infinite; }
    @media (max-width: 640px) {
      .card-select-badge { width: 15px; height: 15px; top: 4px; left: 4px; }
      .card-select-badge svg { width: 8px; height: 8px; }
      .card-sync-spinner { width: 18px; height: 18px; top: 4px; right: 4px; }
      .card-sync-spinner::after { width: 10px; height: 10px; }
    }

    /* 다중 선택 액션 바 — 스캔 진행바(#scan-progress-bar)와 같은 자리(topbar 바로 아래)에
       뜨는 고정 오버레이. 선택된 게 있을 때만 보인다. */
    #bulk-select-bar { display: none; align-items: center; gap: 10px; padding: 8px 20px; background: var(--bg2); border-bottom: 1px solid var(--border); font-size: 13px; }
    #bulk-select-bar.visible { display: flex; }
    #bulk-select-count { color: var(--text); font-weight: 600; margin-right: auto; }
    .bulk-select-btn { padding: 6px 14px; border-radius: 6px; border: 1px solid var(--border); background: var(--bg3); color: var(--text); font-size: 13px; cursor: pointer; }
    .bulk-select-btn:hover { border-color: var(--accent); color: var(--accent); }
    .bulk-select-btn.danger:hover { border-color: #f55; color: #f55; }
    #bulk-select-clear-btn { background: none; border: none; color: var(--text2); cursor: pointer; font-size: 13px; }
    #bulk-select-clear-btn:hover { color: var(--text); }

    /* SHOW DETAIL */
    .show-hero { display: flex; gap: 36px; align-items: flex-start; margin-bottom: 44px; max-width: 1320px; }
    .show-hero-poster { width: 240px; min-width: 240px; height: 360px; border-radius: 8px; overflow: hidden; position: relative; background: var(--bg3); flex-shrink: 0; box-shadow: 0 14px 36px rgba(0,0,0,.38); }
    .show-hero-poster img { width: 100%; height: 100%; object-fit: cover; }
    .show-hero-poster .poster-placeholder { font-size: 58px; height: 100%; }
    .show-hero-info { flex: 1; min-width: 0; display: flex; flex-direction: column; padding-top: 2px; max-width: 1040px; }
    .show-hero-title { font-size: 30px; font-weight: 800; line-height: 1.12; margin-bottom: 14px; letter-spacing: 0; }
    .show-hero-meta { font-size: 15px; color: var(--text2); margin-bottom: 16px; }
    .show-rating { color: var(--accent); font-weight: 800; opacity: 1; }
    /* Plex Discover 평점 — 로컬 아이콘/이모지만 사용, 외부 로고 URL에 의존하지 않는다 */
    .ext-ratings-row { display: flex; align-items: center; gap: 16px; margin: 2px 0 16px; flex-wrap: wrap; }
    .ext-rating-item { display: flex; align-items: center; gap: 6px; font-size: 14px; font-weight: 700; color: var(--text); }
    .ext-rating-icon { display: inline-flex; align-items: center; justify-content: center; font-size: 12px; line-height: 1; }
    .ext-rating-icon.ext-rating-imdb { background: #f5c518; color: #000; font-weight: 800; padding: 2px 5px; border-radius: 3px; font-size: 11px; }
    .ext-rating-icon.ext-rating-tmdb { background: #01b4e4; color: #fff; font-weight: 800; padding: 2px 5px; border-radius: 3px; font-size: 10px; }
    .ext-rating-icon.ext-rating-tomato, .ext-rating-icon.ext-rating-popcorn { font-size: 15px; }
    /* 추가 기능 (예고편/클립) */
    .extras-section { margin-top: 36px; }
    .extras-grid { display: flex; gap: 14px; overflow-x: auto; scroll-behavior: smooth; padding-bottom: 8px; scrollbar-width: none; margin-top: 12px; }
    .extras-grid::-webkit-scrollbar { display: none; }
    .extras-card { flex: 0 0 220px; width: 220px; cursor: default; }
    .extras-card.clickable { cursor: pointer; }
    .extras-thumb { width: 220px; height: 124px; border-radius: 6px; background: var(--bg3); overflow: hidden; position: relative; }
    .extras-thumb img { width: 100%; height: 100%; object-fit: cover; }
    .extras-play-icon { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 20px; color: #fff; background: rgba(0,0,0,.25); opacity: 0; transition: opacity .15s; }
    .extras-card.clickable:hover .extras-play-icon { opacity: 1; }
    .extras-title { font-size: 13px; margin-top: 6px; line-height: 1.3; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
    .extras-type { font-size: 11px; color: var(--text3); margin-top: 2px; }
    /* OTT 제공자 배지 — 표시 전용 */
    .providers-section { margin-top: 32px; }
    .providers-row { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 12px; }
    /* Plex의 "더 많은 시청 방법" 카드 크기에 맞춤 — 로고+서비스명이 한 타일 안에 크게 보이도록 */
    .provider-badge { width: 158px; min-height: 100px; padding: 14px 10px; border-radius: 8px; background: var(--bg3); border: 1px solid var(--border); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; color: var(--text2); font-size: 14px; text-align: center; }
    .provider-badge img { height: 42px; max-width: 130px; object-fit: contain; }
    /* 서비스명은 2줄까지 자연스럽게 줄바꿈(잘리지 않게). 예: "Amazon Prime Video" */
    .provider-badge span { font-size: 13px; line-height: 1.3; max-width: 100%; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; word-break: keep-all; }
    .provider-badge.clickable { cursor: pointer; }
    .provider-badge.clickable:hover { border-color: var(--accent); }
    .provider-filter-bar { display: flex; align-items: center; gap: 12px; padding: 10px 14px; margin-bottom: 14px; background: var(--bg3); border: 1px solid var(--border); border-radius: 8px; font-size: 13px; color: var(--text2); }
    .provider-filter-clear { background: none; border: 1px solid var(--border); border-radius: 14px; color: var(--text2); padding: 4px 12px; font-size: 12px; cursor: pointer; }
    .provider-filter-clear:hover { color: var(--text); border-color: var(--accent); }
    .show-hero-summary { font-size: 16px; line-height: 1.75; color: var(--text); opacity: .88; margin: 12px 0 10px; max-width: 960px; }
    .summary-para { margin: 0 0 0.85em; white-space: pre-wrap; }
    .summary-para:last-child { margin-bottom: 0; }
    .summary-clamp-wrap { max-width: 960px; }
    .summary-clamped { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: var(--clamp-lines, 3); overflow: hidden; }
    .summary-clamped.summary-expanded { display: block; -webkit-line-clamp: unset; overflow: visible; }
    .summary-toggle { display: block; margin: 4px 0 10px; padding: 0; background: none; border: none; color: var(--accent); font-size: 14px; font-weight: 600; cursor: pointer; }
    .summary-toggle:hover { text-decoration: underline; }
    .selected-stream-loading { min-height: 70px; margin: 14px 0 8px; }
    .selected-stream-loading:empty::after { content: ''; display: block; width: 18px; height: 18px; border: 2px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
    .selected-stream-info { display: grid; grid-template-columns: 74px minmax(0, 1fr); gap: 7px 18px; max-width: 620px; margin: 14px 0 8px; font-size: 14px; line-height: 1.45; }
    .selected-stream-label { color: var(--text2); }
    .selected-stream-value { color: var(--text); font-weight: 600; min-width: 0; }
    .selected-stream-value.subtitle { color: #f5a900; }
    .selected-stream-loading.compact { min-height: 50px; margin: 8px 0 0; }
    .selected-stream-info.compact { grid-template-columns: 52px minmax(0, 1fr); gap: 3px 10px; margin: 0; font-size: 12px; }
    .show-hero-tagline { font-size: 14px; color: var(--text3); font-style: italic; margin-bottom: 12px; }
    .show-hero-actions { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-top: 18px; padding-top: 8px; }
    .show-action-btn { display:inline-flex; align-items:center; justify-content:center; gap:9px; min-height:42px; padding: 0 22px; border-radius: 6px; font-size: 15px; font-weight: 800; cursor: pointer; border: 1px solid transparent; background: var(--bg3); color: var(--text); }
    .show-action-btn.primary { background: var(--accent); color: #111; }
    .show-action-btn:hover { filter: brightness(1.08); }
    .show-action-icon { font-size: 14px; line-height: 1; }
    .show-icon-action { width: 42px; height: 42px; border: 0; border-radius: 50%; background: transparent; color: var(--text); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; font-size: 24px; line-height: 1; }
    .show-icon-action:hover { background: rgba(255,255,255,.10); color: var(--accent); }
    .show-icon-action svg { width: 22px; height: 22px; }
    .show-meta-panel { margin-top: 16px; padding: 14px 16px; border-radius: 8px; background: rgba(255,255,255,.045); border: 1px solid rgba(255,255,255,.08); max-width: 1040px; }
    .show-meta-panel-title { font-size: 15px; font-weight: 800; color: var(--accent); margin-bottom: 12px; }
    .show-meta-row { display: grid; grid-template-columns: 92px minmax(0, 1fr); gap: 20px; padding: 7px 0; align-items: start; }
    .show-meta-label { font-size: 13px; color: var(--text2); font-weight: 700; }
    .show-meta-value { font-size: 14px; color: var(--text); line-height: 1.55; min-width: 0; word-break: break-word; }
    .show-meta-value.mono { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 13px; color: var(--accent); }
    .analysis-warning .show-meta-value { color: #fca5a5; }
    .analysis-summary { font-weight: 800; margin-bottom: 4px; }
    .analysis-missing-item, .analysis-more { font-size: 13px; color: #fecaca; opacity: .92; }
    .show-more-dropdown .card-dropdown-item.danger { color: #f87171; }
    .show-section-title { font-size: 22px; font-weight: 800; margin: 8px 0 18px; padding-bottom: 12px; border-bottom: 1px solid var(--border); }
    .disc-title { font-size: 17px; margin-top: 26px; padding-bottom: 8px; }
    .season-tabs { display: flex; gap: 8px; margin-bottom: 20px; flex-wrap: wrap; }
    .season-tab { padding: 6px 16px; border-radius: 20px; font-size: 13px; font-weight: 600; cursor: pointer; background: var(--bg3); border: 1px solid var(--border); color: var(--text2); }
    .season-tab.active { background: var(--accent); color: #000; border-color: var(--accent); }

    /* CAST / GENRE */
    .cast-section { margin-top: 36px; position: relative; }
    .cast-carousel-wrap { position: relative; }
    .cast-grid { display: flex; gap: 14px; overflow-x: auto; scroll-behavior: smooth; padding-bottom: 8px; scrollbar-width: none; margin-top: 12px; }
    .cast-grid::-webkit-scrollbar { display: none; }
    .cast-card { flex: 0 0 130px; width: 130px; text-align: center; cursor: default; }
    .cast-photo { width: 130px; height: 130px; border-radius: 50%; background: var(--bg3); overflow: hidden; margin-bottom: 8px; }
    .cast-photo img { width: 100%; height: 100%; object-fit: cover; }
    .cast-photo-ph { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; font-size: 40px; color: var(--text3); }
    .cast-name { font-size: 13px; font-weight: 600; line-height: 1.3; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
    .cast-role { font-size: 12px; color: var(--text2); margin-top: 3px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
    .cast-card.clickable { cursor: pointer; }
    .cast-card.clickable:hover .cast-photo { outline: 2px solid var(--accent); }

    /* 인물 상세 모달 */
    .person-hero { display: flex; gap: 22px; margin-bottom: 22px; }
    .person-hero-photo { flex: 0 0 160px; width: 160px; height: 160px; border-radius: 50%; overflow: hidden; background: var(--bg3); }
    .person-hero-photo img { width: 100%; height: 100%; object-fit: cover; }
    .person-hero-info { flex: 1; min-width: 0; }
    .person-hero-name { font-size: 22px; font-weight: 800; margin-bottom: 4px; }
    .person-hero-dept { font-size: 13px; color: var(--accent); margin-bottom: 10px; }
    .person-hero-meta { font-size: 13px; color: var(--text2); line-height: 1.7; }
    .person-bio { font-size: 13px; line-height: 1.6; color: var(--text2); margin-top: 14px; max-height: 160px; overflow-y: auto; white-space: pre-wrap; }
    .person-section-title { font-size: 15px; font-weight: 700; margin: 22px 0 10px; }
    .person-credit-grid { display: flex; gap: 12px; overflow-x: auto; scroll-behavior: smooth; padding-bottom: 6px; }
    .person-credit-card { flex: 0 0 110px; width: 110px; cursor: default; }
    .person-credit-card.clickable { cursor: pointer; }
    .person-credit-card.clickable:hover .person-credit-poster { outline: 2px solid var(--accent); }
    .person-credit-poster { width: 110px; height: 165px; border-radius: 6px; background: var(--bg3); overflow: hidden; }
    .person-credit-poster img { width: 100%; height: 100%; object-fit: cover; }
    .person-credit-title { font-size: 12px; margin-top: 5px; line-height: 1.3; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
    .person-credit-sub { font-size: 11px; color: var(--text3); margin-top: 2px; }
    .person-filter-row { display: flex; gap: 6px; margin-bottom: 10px; }
    .person-filter-btn { padding: 5px 12px; border-radius: 16px; font-size: 12px; background: var(--bg3); border: 1px solid var(--border); color: var(--text2); cursor: pointer; }
    .person-filter-btn.active { background: var(--accent); color: #000; border-color: var(--accent); }
    .person-filmo-list { display: flex; flex-direction: column; }
    .person-filmo-row { display: flex; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 13px; align-items: baseline; cursor: default; }
    .person-filmo-row.clickable { cursor: pointer; }
    .person-filmo-row.clickable:hover .person-filmo-title,
    .person-filmo-row.clickable:hover .person-filmo-avail-icon { color: var(--accent); }
    .person-filmo-row.clickable:focus { outline: none; }
    .person-filmo-row.clickable:focus-visible { outline: 1px solid rgba(255,255,255,.35); }
    .person-filmo-year { flex: 0 0 44px; color: var(--text3); }
    .person-filmo-title { flex: 1; min-width: 0; }
    .person-filmo-avail-icon { display: inline-block; margin-left: 6px; font-size: 10px; color: var(--accent); vertical-align: middle; }
    .person-filmo-role { color: var(--text2); font-size: 12px; }
    .carousel-arrow { position: absolute; top: 50%; transform: translateY(-50%); width: 32px; height: 32px; border-radius: 50%; background: rgba(30,30,30,.9); border: 1px solid var(--border); color: var(--text); cursor: pointer; display: none; align-items: center; justify-content: center; font-size: 14px; z-index: 10; transition: background .15s, opacity .15s; }
    .carousel-arrow:hover { background: var(--bg4); }
    .carousel-arrow.left { left: -16px; }
    .carousel-arrow.right { right: -16px; }
    .cast-carousel-wrap:hover .carousel-arrow { display: flex; }
    .reviews-carousel-wrap:hover .carousel-arrow { display: flex; }
    .carousel-arrow.hidden { opacity: 0; pointer-events: none; }

    /* 평점 및 리뷰 — Plex 상세 페이지의 "평점 및 리뷰" 캐러셀과 동일한 위치(추가 기능 위) */
    .reviews-section { margin-top: 32px; }
    .reviews-carousel-wrap { position: relative; }
    .reviews-grid { display: flex; gap: 14px; overflow-x: auto; scroll-behavior: smooth; padding-bottom: 8px; scrollbar-width: none; margin-top: 12px; }
    .reviews-grid::-webkit-scrollbar { display: none; }
    .review-card { flex: 0 0 280px; width: 280px; background: var(--bg3); border: 1px solid var(--border); border-radius: 8px; padding: 16px; }
    .review-card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
    .review-avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--bg4); color: var(--text2); display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 700; flex-shrink: 0; }
    .review-meta { min-width: 0; }
    .review-author { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .review-stars { font-size: 12px; color: var(--accent); letter-spacing: 1px; }
    .review-text { font-size: 13px; line-height: 1.6; color: var(--text2); max-height: 96px; overflow-y: auto; white-space: pre-wrap; }
    .review-source { font-size: 11px; color: var(--text3); margin-top: 8px; }

    /* 트랙 가사 — 목록엔 format만, 본문은 모달에서 lazy-read */
    .lyric-btn { padding: 4px 12px; border-radius: 14px; font-size: 12px; background: var(--bg3); border: 1px solid var(--border); color: var(--text2); cursor: pointer; }
    .lyric-btn:hover { border-color: var(--accent); color: var(--text); }
    .lyric-modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.7); z-index: 600; display: flex; align-items: center; justify-content: center; }
    .lyric-modal { width: min(540px, 92vw); max-height: 82vh; background: var(--bg2); border: 1px solid var(--border); border-radius: 10px; display: flex; flex-direction: column; overflow: hidden; box-shadow: 0 20px 50px rgba(0,0,0,.5); }
    .lyric-modal-header { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--border); }
    .lyric-modal-title { font-size: 15px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .lyric-modal-close { background: none; border: none; color: var(--text2); font-size: 20px; cursor: pointer; line-height: 1; }
    .lyric-modal-close:hover { color: var(--text); }
    .lyric-format-tabs { display: flex; gap: 6px; padding: 12px 18px 0; }
    .lyric-format-tab { padding: 5px 14px; border-radius: 14px; font-size: 12px; background: var(--bg3); border: 1px solid var(--border); color: var(--text2); cursor: pointer; }
    .lyric-format-tab.active { background: var(--accent); color: #000; border-color: var(--accent); }
    .lyric-body { padding: 16px 18px; overflow-y: auto; white-space: pre-wrap; line-height: 1.7; font-size: 14px; color: var(--text); }
    .genre-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
    .genre-chip { padding: 4px 12px; border-radius: 20px; background: var(--bg3); border: 1px solid var(--border); font-size: 12px; color: var(--text2); }

    /* EPISODE CARDS */
    .ep-list { display: flex; flex-direction: column; gap: 8px; max-width: 1280px; }
    .ep-card { display: flex; gap: 18px; padding: 12px; border-radius: 8px; cursor: pointer; align-items: flex-start; }
    .ep-card:hover { background: var(--bg3); }
    .ep-thumb-wrap { position: relative; flex-shrink: 0; width: 210px; height: 118px; border-radius: 7px; overflow: hidden; background: var(--bg3); }
    .ep-thumb-wrap img { width: 100%; height: 100%; object-fit: cover; }
    .ep-thumb-ph { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; color: var(--text3); font-size: 12px; font-weight: 700; }
    .ep-num-badge { position: absolute; top: 7px; left: 7px; background: rgba(0,0,0,.78); color: var(--accent); font-size: 11px; font-weight: 800; padding: 3px 7px; border-radius: 4px; }
    .ep-card-info { flex: 1; min-width: 0; padding-top: 2px; }
    .ep-card-title { font-size: 16px; font-weight: 800; margin-bottom: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .ep-card-show { font-size: 13px; color: var(--accent); margin-bottom: 5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .ep-card-meta { font-size: 13px; color: var(--text2); display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 7px; }
    .ep-card-desc { font-size: 13px; color: var(--text2); line-height: 1.55; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
    .ep-card-badges { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 7px; }
    .codec-badge { display: inline-block; padding: 3px 7px; border-radius: 4px; font-size: 11px; font-weight: 700; background: #1e3a5f; color: #60a5fa; }
    .codec-badge.compat { background: #14532d; color: #4ade80; }
    .episode-stream-tags { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 8px; }
    .episode-stream-tag { display: inline-flex; align-items: center; min-height: 22px; padding: 3px 7px; border-radius: 4px; font-size: 11px; font-weight: 800; line-height: 1.2; letter-spacing: .01em; }
    .episode-stream-tag.video { background: #174a73; color: #8fd3ff; }
    .episode-stream-tag.video-detail { background: #43245e; color: #d6a5ff; }
    .episode-stream-tag.audio { background: #14532d; color: #78e99a; }
    .episode-stream-tag.subtitle { background: #5b3a08; color: #ffc857; }
    /* legacy ep-table (트랙용) */
    .season-block { margin-bottom: 32px; }
    .season-title { font-size: 16px; font-weight: 700; margin-bottom: 12px; color: var(--accent); cursor: pointer; }
    .ep-table { width: 100%; border-collapse: collapse; font-size: 13px; }
    .ep-table th { text-align: left; color: var(--text3); font-weight: 500; padding: 6px 10px; border-bottom: 1px solid var(--border); }
    .ep-table td { padding: 8px 10px; border-bottom: 1px solid #222; vertical-align: middle; }
    .ep-table tr:hover td { background: var(--bg3); }
    .ep-num { color: var(--accent); font-weight: 700; min-width: 36px; }

    /* 앨범 상세: 정사각 커버 헤더 + 트랙 목록 */
    .album-hero { margin-bottom: 28px; }
    .album-info-line { font-size: 13px; color: var(--text2); opacity: .82; margin: 8px 0 2px; }
    .album-hero-poster { width: 240px; min-width: 240px; height: 240px; }
    /* 제목 열이 여백을 흡수 → 길이·코덱·가사·재생이 우측에 밀착(코덱↔가사 간격 축소) */
    .track-table .track-title-cell { width: 100%; }
    .track-table td, .track-table th { white-space: nowrap; }
    .track-table .track-dur-cell, .track-table .track-codec-cell,
    .track-table .track-lyric-cell, .track-table .track-play-cell { padding-left: 6px; padding-right: 6px; }
    .track-play-cell { text-align: center; width: 40px; }
    .track-play-btn { width: 30px; height: 30px; border-radius: 50%; background: var(--bg3); border: 1px solid var(--border); color: var(--text); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; padding: 0; }

    /* 전체 트랙(라이브러리 평면 목록) — 제목/아티스트/앨범이 여백을 나눠 갖고 시간·재생은 고정폭 */
    .all-tracks-table th, .all-tracks-table td { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .all-tracks-table .track-title-cell, .all-tracks-table .track-artist-cell,
    .all-tracks-table .track-album-cell { max-width: 320px; }
    .all-tracks-table .track-artist-cell a, .all-tracks-table .track-album-cell a {
      color: var(--text); text-decoration: none;
    }
    .all-tracks-table .track-artist-cell a:hover, .all-tracks-table .track-album-cell a:hover {
      color: var(--accent); text-decoration: underline;
    }
    .track-play-btn:hover { background: var(--accent); border-color: var(--accent); }
    .track-play-btn svg { width: 14px; height: 14px; fill: currentColor; margin-left: 1px; }
    .sortable-th { cursor: pointer; user-select: none; }
    .sortable-th:hover { color: var(--text); }
    .sortable-th.active { color: var(--accent); }
    .sortable-th .sort-arrow { font-size: 10px; }
    .track-play-btn:hover svg { fill: #000; }

    /* 음악 플레이어 (오디오 + 앨범아트 배경 + 가사) */
    .music-player-overlay { position: fixed; inset: 0; z-index: 1000; display: flex; align-items: center; justify-content: center; }
    .music-player-overlay::after { content:''; position:absolute; inset:0; background: rgba(0,0,0,.55); }
    .music-player-bg { position: absolute; inset: 0; background-size: cover; background-position: center; filter: blur(44px) brightness(.4); transform: scale(1.2); }
    .music-player-panel { position: relative; z-index: 1; width: min(560px, 92vw); max-height: 88vh; display: flex; flex-direction: column;
        background: rgba(22,22,26,.72); backdrop-filter: blur(10px); border: 1px solid rgba(255,255,255,.12); border-radius: 16px; padding: 22px; box-shadow: 0 24px 64px rgba(0,0,0,.6); }
    .music-player-head { display: flex; gap: 16px; align-items: center; margin-bottom: 14px; }
    .music-player-cover { width: 84px; height: 84px; border-radius: 10px; object-fit: cover; box-shadow: 0 8px 22px rgba(0,0,0,.5); flex-shrink: 0; }
    .music-player-titles { min-width: 0; }
    .music-player-track-title { font-size: 20px; font-weight: 800; color: #fff; line-height: 1.2; }
    .music-player-track-sub { font-size: 13px; color: rgba(255,255,255,.7); margin-top: 5px; }
    .music-player-lyrics { flex: 1; overflow-y: auto; padding: 12px 6px; text-align: center; min-height: 180px; }
    .music-player-lyrics .lrc-line { font-size: 15px; line-height: 2; color: rgba(255,255,255,.42); transition: color .2s, transform .2s; cursor: pointer; }
    .music-player-lyrics .lrc-line:hover { color: rgba(255,255,255,.85); }
    .music-player-lyrics .lrc-line.active { color: #fff; font-weight: 700; transform: scale(1.05); }
    .music-player-txt { white-space: pre-wrap; text-align: center; color: rgba(255,255,255,.82); font-size: 14px; line-height: 1.9; font-family: inherit; margin: 0; }
    .music-player-nolyric { color: rgba(255,255,255,.5); text-align: center; padding: 34px 0; }
    .music-player-audio { width: 100%; margin-top: 14px; }
    .music-player-close { position: absolute; top: 12px; right: 14px; background: rgba(0,0,0,.4); border: none; color: #fff; width: 30px; height: 30px; border-radius: 50%; cursor: pointer; font-size: 15px; z-index: 2; }
    .music-player-close:hover { background: var(--accent); color: #000; }

    /* 음악 편집 모달 (아티스트/앨범) — 쇼·영화 편집(#edit-modal)과 동일한 좌측 세로 탭 레이아웃 */
    .music-edit-overlay { position: fixed; inset: 0; z-index: 1000; display: flex; align-items: center; justify-content: center; background: rgba(0,0,0,.7); }
    .music-edit-box { width: min(760px, 95vw); max-height: 88vh; display: flex; flex-direction: column; background: var(--bg2); border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 24px 64px rgba(0,0,0,.6); overflow: hidden; }
    .music-edit-header { padding: 18px 22px; border-bottom: 1px solid var(--border); font-size: 17px; font-weight: 700; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
    .music-edit-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .music-edit-close { background: none; border: none; color: var(--text2); font-size: 16px; cursor: pointer; }
    .music-edit-close:hover { color: var(--text); }
    .music-edit-body { display: flex; flex: 1; overflow: hidden; }
    .music-edit-tabs { width: 140px; min-width: 140px; border-right: 1px solid var(--border); padding: 12px 0; display: flex; flex-direction: column; gap: 2px; }
    .music-edit-tab { padding: 10px 16px; font-size: 13px; cursor: pointer; color: var(--text2); border-radius: 4px; margin: 0 6px; display: flex; align-items: center; gap: 8px; background: none; border: none; text-align: left; }
    .music-edit-tab:hover { background: var(--bg3); color: var(--text); }
    .music-edit-tab.active { background: var(--bg3); color: var(--accent); }
    .music-edit-tab .music-edit-tab-icon { font-size: 14px; width: 16px; text-align: center; }
    .music-edit-panelwrap { flex: 1; overflow-y: auto; padding: 20px 22px; }
    .music-edit-panel { display: none; }
    .music-edit-panel.active { display: block; }
    .music-edit-preview { margin-top: 12px; }
    .music-edit-preview img { max-width: 220px; max-height: 220px; border-radius: 8px; border: 1px solid var(--border); }
    .music-edit-footer { padding: 14px 22px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }
    .music-edit-btn { padding: 8px 18px; border-radius: 6px; border: 1px solid var(--border); background: var(--bg3); color: var(--text); font-size: 14px; cursor: pointer; }
    .music-edit-btn.primary { background: var(--accent); border-color: var(--accent); color: #000; font-weight: 700; }
    .music-edit-btn:hover { filter: brightness(1.1); }
    .music-edit-btn:disabled { opacity: .6; cursor: default; }

    /* FOLDER MANAGEMENT */
    .folder-list { display: flex; flex-direction: column; gap: 10px; }
    .folder-card { background: var(--bg2); border: 1px solid var(--border); border-radius: 8px; padding: 14px 18px; display: flex; align-items: center; gap: 16px; }
    .folder-path { flex: 1; font-size: 14px; font-family: monospace; color: var(--text); }
    .folder-meta { display: flex; gap: 16px; font-size: 12px; color: var(--text2); }
    .folder-meta span { display: flex; flex-direction: column; align-items: center; gap: 2px; }
    .folder-meta strong { font-size: 15px; color: var(--text); }
    .scan-needed { color: #f87171; font-size: 11px; }
    .folder-actions { display: flex; gap: 6px; }
    .danger-btn { padding: 5px 10px; background: none; border: 1px solid #7f1d1d; color: #f87171; border-radius: 5px; cursor: pointer; font-size: 12px; }
    .danger-btn:hover { background: #7f1d1d; }

    /* 휴지통(TRASH) */
    .trash-settings-block { padding: 2px 0 18px; margin-bottom: 18px; border-bottom: 1px solid var(--border); }
    .trash-settings-block .form-group { margin-bottom: 18px; }
    .trash-settings-block .form-group:last-of-type { margin-bottom: 14px; }
    .trash-field-help { display: block; color: var(--text2); font-size: 12px; line-height: 1.45; margin-top: 5px; }
    .trash-checkbox-row { display: flex; align-items: center; justify-content: space-between; gap: 20px; min-height: 48px; cursor: pointer; }
    .trash-checkbox-copy { display: flex; flex-direction: column; min-width: 0; }
    .trash-checkbox-title { color: var(--text); font-size: 13px; font-weight: 600; }
    #lib-allow-media-deletion.trash-checkbox { width: 18px; height: 18px; padding: 0; margin: 0 2px 0 0; flex: 0 0 18px; accent-color: var(--accent); cursor: pointer; }
    .trash-settings-block input:disabled { opacity: .55; cursor: not-allowed; }
    .trash-settings-block.is-inherited .trash-checkbox-row { cursor: default; }
    .trash-actions-row { display: flex; align-items: center; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
    .trash-summary { background: var(--bg2); border: 1px solid var(--border); border-radius: 8px; padding: 12px 14px; margin-bottom: 14px; font-size: 12.5px; display: flex; flex-direction: column; gap: 4px; }
    .trash-summary-row { display: flex; justify-content: space-between; color: var(--text2); }
    .trash-summary-row strong { color: var(--text); }
    .trash-warn-list { margin-top: 6px; color: #f87171; font-size: 11.5px; }
    .trash-list { display: flex; flex-direction: column; gap: 8px; }
    .trash-item { background: var(--bg2); border: 1px solid var(--border); border-radius: 8px; padding: 10px 14px; display: flex; align-items: center; gap: 12px; }
    .trash-item-path { flex: 1; font-size: 13px; font-family: monospace; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .trash-item-meta { display: flex; flex-direction: column; gap: 2px; font-size: 11px; color: var(--text2); min-width: 160px; }
    .trash-status-badge { display: inline-block; padding: 2px 7px; border-radius: 4px; font-size: 10.5px; font-weight: 700; width: fit-content; }
    .trash-status-badge.missing { background: #4a3a14; color: #fbbf24; }
    .trash-status-badge.trashed { background: #3a1a1a; color: #f87171; }

    /* 확인 다이얼로그 (Plex 스타일) */
    .app-dialog-backdrop { display: flex; position: fixed; inset: 0; z-index: 2147483000; isolation: isolate; align-items: center; justify-content: center; box-sizing: border-box; background: rgba(0,0,0,.7); padding: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left)); }
    .confirm-modal { background: var(--bg2); border: 1px solid var(--border); border-radius: 10px; width: 400px; max-width: 90vw; overflow: hidden; box-shadow: 0 20px 60px rgba(0,0,0,.5); }
    .confirm-modal-header { display: flex; align-items: center; gap: 10px; padding: 16px 18px; border-bottom: 1px solid var(--border); }
    .confirm-modal-icon { width: 22px; height: 22px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 800; flex-shrink: 0; background: #7f1d1d; color: #fca5a5; }
    .confirm-modal-title { flex: 1; font-size: 15px; font-weight: 700; }
    .confirm-modal-close { background: none; border: none; color: var(--text2); cursor: pointer; font-size: 15px; padding: 2px 6px; }
    .confirm-modal-close:hover { color: var(--text); }
    .confirm-modal-body { padding: 18px; font-size: 13.5px; color: var(--text2); line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; }
    .confirm-modal-footer { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 18px; }
    .confirm-danger-btn { padding: 8px 18px; background: #dc2626; border: none; color: #fff; border-radius: 6px; cursor: pointer; font-size: 13px; font-weight: 600; }
    .confirm-danger-btn:hover { background: #b91c1c; }
    .confirm-modal-icon.info { background: rgba(229,160,35,.18); color: var(--accent); }
    .confirm-modal-icon.danger { background: #7f1d1d; color: #fca5a5; }
    .app-dialog-input-wrap { padding: 0 18px 4px; }
    .app-dialog-input { box-sizing: border-box; width: 100%; min-height: 88px; max-height: 36vh; resize: vertical; padding: 10px 12px; border: 1px solid var(--border); border-radius: 6px; outline: none; background: var(--bg3); color: var(--text); font: 13px/1.5 ui-monospace,SFMono-Regular,Consolas,monospace; }
    .app-dialog-input:focus { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(229,160,35,.16); }
    .update-version-value { color: var(--text); font-weight: 650; }
    .update-badge { display: inline-flex; margin-left: 8px; padding: 3px 8px; border-radius: 999px; font-size: 11px; font-weight: 750; }
    .update-badge.current { color: #73d99b; background: rgba(54,190,110,.16); }
    .update-badge.available { color: #f8bd4f; background: rgba(229,160,35,.18); }
    .update-release-link { display: inline-flex; align-items: center; text-decoration: none; }
    .update-check-error { display: block; margin: 10px 0 0; }
    @media (max-width: 600px) {
      .app-dialog-backdrop { align-items: flex-end; padding: 8px; padding-bottom: max(8px, env(safe-area-inset-bottom)); }
      .app-dialog-modal { width: 100%; max-width: none; max-height: min(78dvh, 640px); overflow-y: auto; border-radius: 12px; }
      .confirm-modal-header { min-height: 54px; padding: 14px 16px; }
      .confirm-modal-body { padding: 16px; font-size: 14px; }
      .confirm-modal-footer { padding: 12px 16px 16px; }
      .confirm-modal-footer button { min-width: 82px; min-height: 42px; }
    }

    /* MODALS */
    .modal-backdrop { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.7); z-index: 100; align-items: center; justify-content: center; }
    .modal-backdrop.open { display: flex; }
    /* 설정 화면(#settings-overlay, z-index:700) 안에서 여는 모달은 그 위로 떠야 함 */
    #rclone-remote-modal, #direct-play-modal, #friend-modal, #folder-modal { z-index: 800; }
    .modal { background: var(--bg2); border: 1px solid var(--border); border-radius: 12px; padding: 28px; width: 520px; max-width: 95vw; max-height: 90vh; overflow-y: auto; }
    .modal h2 { font-size: 18px; margin-bottom: 20px; }
    .modal-footer { display: flex; justify-content: flex-end; gap: 8px; margin-top: 24px; }
    .form-group { margin-bottom: 14px; }
    .form-group label { display: block; font-size: 13px; color: var(--text2); margin-bottom: 5px; }
    .form-group input, .form-group select { width: 100%; padding: 8px 10px; background: var(--bg3); border: 1px solid var(--border); border-radius: 6px; color: var(--text); font-size: 14px; outline: none; }
    .form-group input:focus, .form-group select:focus { border-color: var(--accent); }

    /* MATCH MODAL */
    #match-modal { background: var(--bg2); border: 1px solid var(--border); border-radius: 12px; width: min(980px, 94vw); height: min(780px, 88vh); display: flex; flex-direction: column; overflow: hidden; }
    #match-modal-header { padding: 22px 24px 0; }
    #match-modal-header h2 { font-size: 20px; font-weight: 700; margin-bottom: 14px; }
    #match-search-row { display: flex; gap: 8px; margin-bottom: 16px; }
    #match-keyword { flex: 1; padding: 9px 12px; background: var(--bg3); border: 1px solid var(--border); border-radius: 6px; color: var(--text); font-size: 14px; outline: none; }
    #match-keyword:focus { border-color: var(--accent); }
    #match-search-btn { padding: 8px 16px; background: var(--accent); color: #000; border: none; border-radius: 6px; font-size: 13px; font-weight: 600; cursor: pointer; }
    #match-results { flex: 1; min-height: 0; overflow-y: auto; padding: 0 24px 24px; }
    .match-result { display: flex; align-items: stretch; gap: 22px; min-height: 142px; padding: 16px 14px 16px 18px; border-bottom: 1px solid var(--border); cursor: pointer; border-radius: 8px; margin-bottom: 4px; }
    .match-result:hover { background: var(--bg3); }
    .match-result-info { flex: 1; min-width: 0; padding-top: 2px; }
    .match-result-title { font-size: 17px; font-weight: 700; }
    .match-result-sub { font-size: 13px; color: var(--text2); margin-top: 4px; }
    .match-result-desc { font-size: 13px; line-height: 1.45; color: var(--text3); margin-top: 8px; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; }
    .match-result-poster { position: relative; width: 96px; height: 136px; flex-shrink: 0; align-self: center; }
    .match-result-thumb { width: 100%; height: 100%; object-fit: cover; border-radius: 5px; background: var(--bg4); }
    .match-result-score { position: absolute; top: 8px; right: 8px; min-width: 34px; padding: 3px 6px; border-radius: 12px; background: rgba(0,0,0,.72); color: var(--accent); font-size: 12px; font-weight: 800; text-align: center; }

    /* PLAYLIST ADD MODAL */
    #playlist-add-modal { background: var(--bg2); border: 1px solid var(--border); border-radius: 12px; width: min(480px, 92vw); max-height: 82vh; display: flex; flex-direction: column; overflow: hidden; }
    #playlist-add-modal-header { padding: 20px 22px 0; display: flex; align-items: center; justify-content: space-between; }
    #playlist-add-modal-header h2 { font-size: 18px; font-weight: 700; }
    #playlist-add-modal-body { flex: 1; min-height: 0; overflow-y: auto; padding: 16px 22px 22px; }
    .playlist-add-option { display: flex; align-items: center; gap: 12px; padding: 12px 10px; border-radius: 8px; cursor: pointer; border-bottom: 1px solid var(--border); }
    .playlist-add-option:hover { background: var(--bg3); }
    .playlist-add-option-title { font-size: 14px; font-weight: 600; }
    .playlist-add-option-sub { font-size: 12px; color: var(--text2); margin-top: 2px; }
    #playlist-add-search { width: 100%; padding: 9px 12px; background: var(--bg3); border: 1px solid var(--border); border-radius: 6px; color: var(--text); font-size: 14px; outline: none; margin-bottom: 12px; }
    #playlist-add-search:focus { border-color: var(--accent); }
    .playlist-add-empty { padding: 20px; color: var(--text2); text-align: center; font-size: 13px; }
    .playlist-add-status { padding: 12px; text-align: center; font-size: 13px; color: var(--text2); }

    /* EDIT MODAL (Plex 편집 스타일) */
    #edit-modal { background: var(--bg2); border: 1px solid var(--border); border-radius: 12px; width: 700px; max-width: 95vw; max-height: 88vh; display: flex; flex-direction: column; overflow: hidden; }
    #edit-modal-title { padding: 18px 22px; border-bottom: 1px solid var(--border); font-size: 17px; font-weight: 700; display: flex; align-items: center; gap: 10px; }
    #edit-modal-body { display: flex; flex: 1; overflow: hidden; }
    #edit-tabs { width: 140px; min-width: 140px; border-right: 1px solid var(--border); padding: 12px 0; display: flex; flex-direction: column; gap: 2px; }
    .edit-tab { padding: 10px 16px; font-size: 13px; cursor: pointer; color: var(--text2); border-radius: 4px; margin: 0 6px; display: flex; align-items: center; gap: 8px; }
    .edit-tab:hover { background: var(--bg3); color: var(--text); }
    .edit-tab.active { background: var(--bg3); color: var(--accent); }
    .edit-tab-icon { font-size: 14px; width: 16px; text-align: center; }
    #edit-panel { flex: 1; overflow-y: auto; padding: 20px 22px; }
    .edit-panel-section { display: none; }
    .edit-panel-section.active { display: block; }
    #edit-modal-footer { padding: 14px 22px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }

    /* LIBRARY TYPE CARDS */
    .type-cards { display: flex; gap: 10px; margin-bottom: 14px; }
    .type-card { flex: 1; padding: 12px; background: var(--bg3); border: 2px solid var(--border); border-radius: 8px; cursor: pointer; text-align: center; }
    .type-card.selected { border-color: var(--accent); background: rgba(229,160,13,.1); }
    .type-card.disabled { cursor: default; opacity: .55; }
    .type-card .icon { font-size: 24px; margin-bottom: 4px; }
    .type-card .label { font-size: 12px; color: var(--text2); }

    /* FOLDER BROWSER */
    #folder-browser { background: var(--bg2); border: 1px solid var(--border); border-radius: 12px; padding: 0; width: min(860px, 95vw); height: min(680px, 90vh); display: flex; flex-direction: column; }
    #folder-browser-header { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 10px; }
    #folder-browser-header h2 { flex: 1; font-size: 16px; }
    #folder-source-row { display: flex; align-items: center; gap: 10px; padding: 12px 20px 8px; border-bottom: 1px solid var(--border); }
    #folder-source-row label { color: var(--text2); font-size: 12px; font-weight: 700; white-space: nowrap; }
    #folder-source-select { flex: 1; width: auto; min-width: 0; }
    #folder-current-path { padding: 8px 20px; background: var(--bg3); font-family: monospace; font-size: 13px; color: var(--accent); border-bottom: 1px solid var(--border); word-break: break-all; }
    #folder-list { flex: 1; overflow-y: auto; min-height: 0; padding: 8px 0 14px; }
    .folder-entry { display: flex; align-items: center; gap: 10px; padding: 8px 20px; cursor: pointer; font-size: 14px; }
    .folder-entry:hover { background: var(--bg3); }
    .folder-entry .fe-icon { color: var(--accent); font-size: 16px; }
    #folder-browser-footer { padding: 16px 20px 22px; border-top: 1px solid var(--border); }
    #folder-manual-input { width: 100%; padding: 8px 10px; background: var(--bg3); border: 1px solid var(--border); border-radius: 6px; color: var(--text); font-family: monospace; font-size: 13px; outline: none; margin-bottom: 10px; }
    #folder-manual-input:focus { border-color: var(--accent); }

    /* SPINNER */
    .spinner { width: 36px; height: 36px; border: 3px solid var(--bg3); border-top-color: var(--accent); border-radius: 50%; animation: spin .7s linear infinite; margin: 60px auto; }
    @keyframes spin { to { transform: rotate(360deg); } }

    .empty-msg { text-align: center; color: var(--text3); padding: 60px 0; font-size: 15px; }

    /* MOBILE HAMBURGER */
    #sidebar-toggle { display: none; width: 34px; height: 34px; align-items: center; justify-content: center; background: none; border: none; color: var(--text); cursor: pointer; padding: 6px; line-height: 1; flex: 0 0 34px; }
    #sidebar-toggle svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
    #sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 50; }
    #sidebar-overlay.open { display: block; }

    /* TABLET: keep the library rail available, but let it yield the full width. */
    @media (min-width: 641px) and (max-width: 1280px) and (orientation: landscape) {
      #sidebar-toggle { display: flex; }
      #sidebar {
        transition: width .22s ease, min-width .22s ease, opacity .16s ease;
      }
      #sidebar.tablet-collapsed {
        width: 0;
        min-width: 0;
        border-right: 0;
        overflow: hidden;
        opacity: 0;
        pointer-events: none;
      }
    }

    /* JS also applies explicit modes. This is intentionally independent of
       CSS orientation because tablet "desktop site" mode can report a layout
       viewport that does not match the physical device orientation. */
    body.sidebar-tablet-mode #sidebar-toggle { display: flex; }
    body.sidebar-tablet-mode #sidebar {
      transition: width .22s ease, min-width .22s ease, opacity .16s ease;
    }
    body.sidebar-tablet-mode #sidebar.tablet-collapsed {
      width: 0;
      min-width: 0;
      border-right: 0;
      overflow: hidden;
      opacity: 0;
      pointer-events: none;
    }

    /* A portrait tablet uses an overlay drawer. Opening the library list must
       not squeeze the search/header into the remaining narrow column. */
    @media (min-width: 641px) and (max-width: 1280px) and (orientation: portrait) {
      #sidebar-toggle { display: flex; }
      #sidebar {
        position: fixed;
        left: -252px;
        top: 0;
        bottom: 0;
        width: 252px;
        min-width: 252px;
        z-index: 60;
        transition: left .25s ease;
        box-shadow: 4px 0 20px rgba(0,0,0,.5);
      }
      #sidebar.open { left: 0; }
      #topbar { padding: 10px 14px; gap: 8px; flex-wrap: nowrap; }
      #library-title, #tabs { display: none; }
      #search-wrap {
        flex: 1 1 auto;
        width: auto;
        min-width: 140px;
        max-width: none;
      }
      #sidebar-toggle { order: 0; }
      #sessions-btn, #notif-bell-btn, #user-menu-btn { flex-shrink: 0; }
      #settings-btn { flex: 0 0 auto; }
      #topbar > #media-view-controls { display: none !important; }
      #user-menu-name { display: none; }
      #user-menu-btn { gap: 0; padding: 4px; }
    }

    body.sidebar-drawer-mode #sidebar-toggle { display: flex; order: 0; }
    body.sidebar-drawer-mode #sidebar {
      position: fixed;
      left: -252px;
      top: 0;
      bottom: 0;
      width: 252px;
      min-width: 252px;
      z-index: 60;
      transition: left .25s ease;
      box-shadow: 4px 0 20px rgba(0,0,0,.5);
    }
    body.sidebar-drawer-mode #sidebar.open { left: 0; }
    body.sidebar-drawer-mode #topbar { padding: 10px 14px; gap: 8px; flex-wrap: nowrap; }
    body.sidebar-drawer-mode #library-title,
    body.sidebar-drawer-mode #tabs { display: none; }
    body.sidebar-drawer-mode #search-wrap {
      flex: 1 1 auto;
      width: auto;
      min-width: 140px;
      max-width: none;
    }
    body.sidebar-drawer-mode #sessions-btn,
    body.sidebar-drawer-mode #notif-bell-btn,
    body.sidebar-drawer-mode #user-menu-btn { flex-shrink: 0; }
    body.sidebar-drawer-mode #settings-btn { flex: 0 0 auto; }
    body.sidebar-drawer-mode #topbar > #media-view-controls { display: none !important; }
    body.sidebar-drawer-mode #user-menu-name { display: none; }
    body.sidebar-drawer-mode #user-menu-btn { gap: 0; padding: 4px; }

    /* MOBILE */
    @media (max-width: 640px) {
      :root { --card-w: 140px; --card-h: 210px; }

      body { overflow: hidden; }

      /* 사이드바: 오버레이 drawer로 */
      #sidebar {
        position: fixed; left: -252px; top: 0; bottom: 0; width: 252px; min-width: 252px; z-index: 60;
        transition: left .25s ease; box-shadow: 4px 0 20px rgba(0,0,0,.5);
      }
      #sidebar.open { left: 0; }

      /* 토글 버튼 표시 */
      #sidebar-toggle { display: flex; }

      /* 탑바 */
      #topbar { padding: 10px 12px; gap: 8px; flex-wrap: nowrap; }
      #library-title { font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 120px; }
      #tabs { gap: 2px; }
      .tab-btn { padding: 5px 8px; font-size: 12px; }
      #search-wrap { flex: 1 1 148px; min-width: 96px; max-width: 240px; }
      #search-box { width: auto; min-width: 0; font-size: 12px; padding: 5px 7px 5px 10px; }
      #search-scope-btn { width: 31px; height: 29px; }
      #sync-btn, #scan-btn, #add-folder-btn { display: none !important; }
      #player-btn { padding: 5px 8px; font-size: 12px; }
      #player-btn-label { display: none; }

      /* 콘텐츠 */
      #content {
        padding: 12px 12px calc(40px + env(safe-area-inset-bottom, 0px));
        scroll-padding-bottom: calc(40px + env(safe-area-inset-bottom, 0px));
      }
      .browse-list-header { padding-top: 8px; padding-bottom: 14px; padding-right: 0; }
      /* 모바일에서도 필터 행 안에 두며, 공간이 부족하면 toolbar의 flex-wrap을 따른다. */
      .browse-list-header .library-stat { display: inline-flex; align-items: center; }

      /* 포스터 그리드: 5열 */
      .poster-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
      .poster-grid.music-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
      .poster-card { width: 100%; }
      .poster-thumb { width: 100%; height: 0; padding-bottom: 150%; position: relative; }
      .music-grid .poster-card { width: 100%; }
      .music-grid .poster-thumb { padding-bottom: 100%; }
      .poster-bg { position: absolute; inset: 0; width: 100%; height: 100%; }
      .poster-placeholder { position: absolute; inset: 0; font-size: 22px; }
      .poster-badge { font-size: 9px; padding: 1px 4px; }
      .poster-title { font-size: 11px; margin-top: 4px; }
      .poster-sub { font-size: 10px; }

      /* 쇼 히어로 */
      .show-hero { flex-direction: column; gap: 16px; }
      .show-hero-poster { width: 140px; height: 210px; align-self: center; }
      .album-hero-poster { width: 160px; min-width: 160px; height: 160px; }
      .show-hero-title { font-size: 22px; }

      /* 에피소드 카드 */
      .ep-thumb-wrap { width: 120px; height: 68px; }
      .ep-card-title { font-size: 13px; }

      /* 배우 캐러셀 */
      .cast-card { flex: 0 0 90px; width: 90px; }
      .cast-photo { width: 90px; height: 90px; }

      /* 툴바 드롭다운 */
      .tb-dropdown-btn { font-size: 12px; padding: 4px 8px; }

      /* 모달 */
      .modal { padding: 18px; }
      #match-modal { width: 96vw; height: 86vh; }
      #edit-modal { width: 98vw; }
      .music-edit-box { width: 98vw; }
    }

    /* SETTINGS BUTTON */
    #settings-btn { display: flex; align-items: center; justify-content: center; width: 34px; height: 34px; border-radius: 6px; border: none; background: none; color: var(--text2); cursor: pointer; flex-shrink: 0; }
    #settings-btn:hover { background: var(--bg3); color: var(--text); }

    /* SETTINGS OVERLAY (Plex 스타일 전체 화면) */
    #settings-overlay { display: none; position: fixed; inset: 0; background: var(--bg); z-index: 700; }
    #settings-overlay.open { display: flex; }
    #settings-nav { width: 250px; min-width: 250px; border-right: 1px solid var(--border); display: flex; flex-direction: column; background: var(--bg); overflow-y: auto; }
    #settings-nav-header { padding: 18px 20px 12px; border-bottom: 1px solid var(--border); }
    #settings-back-btn { display: flex; align-items: center; gap: 8px; background: none; border: none; color: var(--text2); cursor: pointer; font-size: 15px; font-weight: 600; padding: 8px 12px; border-radius: 8px; margin-bottom: 10px; width: 100%; }
    #settings-back-btn:hover { background: var(--bg3); color: var(--text); }
    #settings-back-btn svg { flex-shrink: 0; }
    #settings-nav-title { font-size: 20px; font-weight: 800; color: var(--text); padding: 0 4px; }
    .settings-nav-group { padding: 12px 0 4px; }
    .settings-nav-label { font-size: 11px; font-weight: 700; color: var(--text3); text-transform: uppercase; letter-spacing: .08em; padding: 4px 20px 6px; }
    .settings-nav-item { padding: 10px 20px; font-size: 14px; color: var(--text2); cursor: pointer; border-left: 3px solid transparent; transition: background .1s, color .1s; display: flex; align-items: center; gap: 8px; }
    .settings-nav-item:hover { background: var(--bg3); color: var(--text); }
    .settings-nav-item.active { color: var(--accent); background: rgba(229,160,13,.07); border-left-color: var(--accent); }
    .status-badge { display: inline-block; margin-left: 12px; font-size: 12px; font-weight: 700; padding: 3px 10px; border-radius: 12px; vertical-align: middle; }
    .status-badge.status-on { background: rgba(74,222,128,.15); color: #4ade80; }
    .status-badge.status-off { background: var(--bg3); color: var(--text3); }
    #plex-fields-wrap.plex-fields-disabled { opacity: .4; pointer-events: none; }
    .plex-enable-row { background: rgba(229,160,13,.05); }
    .plex-enable-ctrl { display: flex; align-items: center; gap: 10px; }
    .plex-enable-state { font-size: 13px; font-weight: 700; min-width: 34px; text-align: right; }
    .plex-enable-state.on { color: #4ade80; }
    .plex-enable-state.off { color: var(--text3); }
    .toggle-switch-lg { width: 50px; height: 28px; }
    .toggle-switch-lg .toggle-slider::after { width: 20px; height: 20px; top: 4px; }
    .toggle-switch-lg input:checked + .toggle-slider::after { transform: translateX(22px); }
    .lib-modal-nav-item { padding: 9px 14px; font-size: 13.5px; color: var(--text2); cursor: pointer; border-radius: 6px; margin-bottom: 2px; }
    .lib-modal-nav-item:hover { background: var(--bg3); color: var(--text); }
    .lib-modal-nav-item.active { color: var(--accent); background: rgba(229,160,13,.1); }
    .friend-modal-nav-item { padding: 9px 14px; font-size: 13.5px; color: var(--text2); cursor: pointer; border-radius: 6px; margin-bottom: 2px; }
    .friend-modal-nav-item:hover { background: var(--bg3); color: var(--text); }
    .friend-modal-nav-item.active { color: var(--accent); background: rgba(229,160,13,.1); }
    #settings-content-panel { flex: 1; min-width: 0; display: flex; flex-direction: column; overflow: hidden; }
    #settings-mobile-nav-back { display: none; }
    #settings-content-area { flex: 1; overflow-y: auto; padding: 36px 48px; }
    .settings-page-title { font-size: 26px; font-weight: 800; margin-bottom: 28px; }
    .settings-card { background: var(--bg2); border: 1px solid var(--border); border-radius: 10px; margin-bottom: 16px; overflow: hidden; }
    .settings-card-title { font-size: 12px; font-weight: 700; color: var(--text3); text-transform: uppercase; letter-spacing: .04em; padding: 14px 20px; border-bottom: 1px solid var(--border); }
    .sfield { display: flex; align-items: center; min-height: 54px; padding: 13px 20px; border-bottom: 1px solid #1e1e1e; gap: 16px; }
    .sfield:last-child { border-bottom: none; }
    .sfield-label { flex: 1; }
    .sfield-name { font-size: 15px; color: var(--text); }
    .sfield-desc { font-size: 13px; color: var(--text2); margin-top: 3px; }
    .sfield-ctrl { flex-shrink: 0; }
    .s-select { min-width: 300px; }
    .s-number-with-unit { display: flex; align-items: center; gap: 9px; color: var(--text2); font-size: 13px; }
    .s-number-with-unit .s-input { width: 110px; }
    .settings-checkbox-row { cursor: pointer; }
    .settings-checkbox-row .sfield-label { display: flex; flex-direction: column; }
    .settings-checkbox { width: 18px; height: 18px; flex: 0 0 18px; accent-color: var(--accent); cursor: pointer; }
    .s-pills { display: flex; gap: 6px; flex-wrap: wrap; }
    .s-pill { padding: 6px 16px; border-radius: 20px; border: 1px solid var(--border); background: var(--bg3); color: var(--text2); font-size: 14px; cursor: pointer; transition: all .1s; user-select: none; }
    .s-pill:hover { border-color: var(--accent2); color: var(--text); }
    .s-pill.active { border-color: var(--accent); color: var(--accent); background: rgba(229,160,13,.12); font-weight: 600; }
    .s-input { padding: 8px 12px; background: var(--bg3); border: 1px solid var(--border); border-radius: 6px; color: var(--text); font-size: 14px; outline: none; width: 300px; }
    .s-input:focus { border-color: var(--accent); }
    .mpp-header-field { flex-direction: column; align-items: stretch; gap: 14px; padding-top: 18px; padding-bottom: 18px; }
    .mpp-header-field .sfield-ctrl { width: 100%; }
    .mpp-header-textarea {
      display: block;
      box-sizing: border-box;
      width: 100%;
      min-height: 220px;
      resize: vertical;
      overflow: auto;
      white-space: pre;
      line-height: 1.5;
      font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
    }
    .s-btn { padding: 8px 18px; border-radius: 6px; border: 1px solid var(--border); background: var(--bg3); color: var(--text2); font-size: 14px; cursor: pointer; }
    .s-btn:hover { border-color: var(--accent); color: var(--text); }
    .s-btn.primary { background: var(--accent); color: #000; border-color: transparent; font-weight: 600; }
    .s-btn.primary:hover { background: var(--accent2); }
    .settings-footer-row { display: flex; align-items: center; gap: 12px; padding: 20px 0 4px; flex-wrap: wrap; }
    .s-result { font-size: 12px; }
    .s-result.ok { color: #4caf50; }
    .s-result.fail { color: #f44336; }

    /* PLAY OVERLAY */
    .ep-thumb-wrap { position: relative; }
    .ep-play-overlay { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(0,0,0,0); transition: background .15s; pointer-events: none; border-radius: 6px; }
    .ep-thumb-wrap:hover .ep-play-overlay { background: rgba(0,0,0,.45); }
    .ep-play-btn { width: 44px; height: 44px; border-radius: 50%; background: rgba(255,255,255,.92); display: flex; align-items: center; justify-content: center; opacity: 0; transform: scale(.8); transition: opacity .15s, transform .15s; pointer-events: none; }
    .ep-thumb-wrap:hover .ep-play-btn { opacity: 1; transform: scale(1); }
    .ep-play-btn svg { width: 18px; height: 18px; fill: #111; margin-left: 3px; }

    .playback-version-count { margin-left: 9px; font-size: 11px; opacity: .82; font-weight: 700; }
    .playback-version-overlay { position: fixed; inset: 0; z-index: 10050; background: rgba(0,0,0,.62); display: flex; align-items: center; justify-content: center; padding: 18px; }
    .playback-version-dialog { width: min(560px, 100%); max-height: min(70vh, 620px); overflow: auto; border-radius: 14px; background: var(--bg2); border: 1px solid var(--border); padding: 18px; box-shadow: 0 24px 70px rgba(0,0,0,.45); }
    .playback-version-title { font-size: 18px; font-weight: 800; margin-bottom: 12px; }
    .playback-version-row { display: block; width: 100%; text-align: left; border: 0; border-radius: 9px; padding: 13px 14px; margin: 6px 0; color: var(--text); background: var(--bg3); cursor: pointer; font: inherit; }
    .playback-version-row:hover { background: var(--hover); }
    .playback-version-cancel { display: block; margin: 12px 0 0 auto; border: 0; background: transparent; color: var(--accent); padding: 8px 12px; cursor: pointer; font-weight: 700; }

    /* VIDEO MODAL */
    #video-modal { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.92); z-index: 1400; align-items: center; justify-content: center; flex-direction: column; }
    #video-modal.open { display: flex; }
    #video-modal video { max-width: 95vw; max-height: 85vh; outline: none; border-radius: 6px; background: #000; }
    #video-embed-frame { width: 90vw; height: 50.625vw; max-width: 1280px; max-height: 720px; border: none; border-radius: 6px; background: #000; }
    #video-modal-close { position: absolute; top: 16px; right: 20px; background: none; border: none; color: rgba(255,255,255,.7); font-size: 28px; cursor: pointer; line-height: 1; }
    #video-modal-close:hover { color: #fff; }
    #video-modal-title { position: absolute; top: 18px; left: 24px; font-size: 14px; color: rgba(255,255,255,.7); max-width: 60%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    #video-modal-status { display: none; position: absolute; inset: 0; z-index: 1; align-items: center; justify-content: center; flex-direction: column; gap: 14px; color: #fff; font-size: 15px; text-align: center; pointer-events: none; }
    #video-modal-status.visible { display: flex; }
    #video-modal-status .spinner { margin: 0; }
    /* 인트로/크레딧 건너뛰기 버튼 (재생 중 해당 구간에서만 표시) */
    #video-skip-btn { position: absolute; right: 4vw; bottom: 12vh; z-index: 10; padding: 10px 22px; background: rgba(20,20,20,.85); color: #fff; border: 1px solid rgba(255,255,255,.55); border-radius: 6px; font-size: 15px; font-weight: 600; cursor: pointer; backdrop-filter: blur(2px); }
    #video-skip-btn:hover { background: #fff; color: #111; border-color: #fff; }

    /* TITLE INDEX BAR (우측 ㄱㄴㄷ/ABC 인덱스) — 화면 상하 여백을 꽉 채워 항목 사이 간격을
       넓게 벌린다(centered+content-height 대신 top~bottom 고정 + space-between). */
    #title-index-bar { position: fixed; right: 20px; top: var(--title-index-top, 92px); bottom: 16px; transform: none; display: flex; flex-direction: column; justify-content: space-between; align-items: center; gap: 0px; z-index: 100; pointer-events: none; opacity: 0; transition: opacity .2s, top .15s; background: rgba(0,0,0,.45); border-radius: 10px; padding: 10px 4px; }
    /* 상단 상태줄이 나타날 때 초성바가 카드 크기 조절/진행률 UI와 겹치지 않게 한다. */
    #title-index-bar.visible { opacity: 1; pointer-events: auto; }
    .idx-char { font-size: 14px; font-weight: 700; line-height: 1.15; padding: 3px 8px; border-radius: 4px; cursor: pointer; color: #e8e8e8; text-align: center; min-width: 26px; transition: color .12s, background .12s; user-select: none; letter-spacing: 0; text-shadow: 0 1px 3px rgba(0,0,0,.8); }
    .idx-char:hover, .idx-char.active { color: var(--accent); background: rgba(229,160,13,.18); }
    .idx-char.dim { opacity: 0.25; cursor: default; }
    /* 초성 종류가 많아(예: 앨범 목록은 아티스트보다 다양함) 세로 폭을 넘칠 때 자동 축소 —
       마지막 글자가 화면 아래로 밀려나는 걸 막는다(buildTitleIndex 가 측정 후 토글). */
    #title-index-bar.compact .idx-char { font-size: 11px; padding: 1px 5px; min-width: 18px; }
    /* 모바일에서도 노출(예전엔 640px 이하에서 완전히 숨겼음) — 폭이 좁으니 여백/글자만 축소. */
    @media (max-width: 640px) {
      #title-index-bar { right: 6px; bottom: 12px; padding: 8px 2px; }
      .idx-char { font-size: 12px; padding: 2px 5px; min-width: 20px; }
    }

    /* AUTH OVERLAY */
    #auth-overlay { display: none; position: fixed; inset: 0; background: var(--bg); z-index: 1000; align-items: center; justify-content: center; }
    #auth-overlay.open { display: flex; }
    .auth-box { background: var(--bg2); border: 1px solid var(--border); border-radius: 12px; padding: 40px 36px; width: 360px; max-width: 90vw; }
    .auth-box h2 { font-size: 20px; font-weight: 700; margin-bottom: 6px; }
    .auth-box p { font-size: 13px; color: var(--text2); margin-bottom: 24px; }
    .auth-field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
    .auth-field label { font-size: 13px; color: var(--text2); }
    .auth-field input { background: var(--bg3); border: 1px solid var(--border); border-radius: 6px; padding: 9px 12px; color: var(--text); font-size: 14px; outline: none; }
    .auth-field input:focus { border-color: var(--accent); }
    .auth-submit { width: 100%; padding: 10px; background: var(--accent); color: #000; border: none; border-radius: 6px; font-size: 14px; font-weight: 700; cursor: pointer; margin-top: 8px; }
    .auth-submit:hover { background: var(--accent2); }
    .auth-error { color: #f55; font-size: 13px; margin-top: 8px; display: none; }
    .auth-error.show { display: block; }

    /* USER MENU (topbar) */
    #user-menu-btn { display: flex; align-items: center; gap: 6px; background: var(--bg3); border: 1px solid var(--border); border-radius: 20px; padding: 5px 12px; cursor: pointer; font-size: 13px; color: var(--text); }
    #user-menu-btn:hover { border-color: var(--accent); }
    .avatar-circle { border-radius: 50%; overflow: hidden; display: flex; align-items: center; justify-content: center; font-weight: 700; color: #fff; flex-shrink: 0; background: var(--accent); }
    .avatar-circle img { width: 100%; height: 100%; object-fit: cover; display: block; }
    #user-menu-popup { display: none; position: fixed; background: var(--bg2); border: 1px solid var(--border); border-radius: 8px; min-width: 180px; z-index: 400; box-shadow: 0 4px 20px rgba(0,0,0,.5); }
    #user-menu-popup.open { display: block; }
    .user-menu-item { padding: 10px 16px; cursor: pointer; font-size: 14px; color: var(--text2); border-radius: 4px; margin: 4px; }
    .user-menu-item:hover { background: var(--bg3); color: var(--text); }
    .user-menu-sep { border: none; border-top: 1px solid var(--border); margin: 4px 0; }

    /* SESSIONS (topbar — 전 서버 합산 동시 시청자, Plex 대시보드 드롭다운과 동일 패턴) */
    :root { --sess-green: #2ecc71; --sess-green-dim: #1e8449; }
    /* Plex 참조처럼 항상 녹색 원형 아이콘 — 세션 유무와 무관하게 "연결됨" 신호로 고정한다.
       배지(숫자)만 값이 바뀐다. width/height/box-sizing을 명시해 어떤 이유로든(예: 다른
       규칙과의 우선순위 충돌) 폭이 찌그러져도 최소 크기를 보장한다. */
    #sessions-btn { position: relative; display: flex; align-items: center; justify-content: center; box-sizing: border-box; width: 34px; height: 34px; min-width: 34px; min-height: 34px; border-radius: 50%; border: none; background: var(--sess-green); color: #0b1a10; cursor: pointer; flex-shrink: 0; }
    #sessions-btn:hover { background: var(--sess-green-dim); }
    #sessions-badge { position: absolute; top: -3px; right: -3px; min-width: 15px; height: 15px; padding: 0 3px; border-radius: 8px; background: var(--accent); color: #101215; font-size: 10px; font-weight: 700; line-height: 15px; text-align: center; box-shadow: 0 0 0 2px var(--bg); }
    /* position은 JS가 sessionsBtn 기준으로 top/right px를 매번 계산해 넣는다(고정폭 안전을
       위해 min-width/max-width를 함께 박아 둔다 — 버튼 rect가 0일 때(display:none 타이밍)
       right 계산이 어긋나도 팝업 자체가 찌그러진 폭으로 렌더되는 사고를 막는다). */
    #sessions-popup { display: none; position: fixed; box-sizing: border-box; background: var(--bg2); border: 1px solid var(--border); border-radius: 8px; width: 380px; min-width: 380px; max-width: 380px; max-height: 480px; overflow-x: hidden; overflow-y: auto; z-index: 400; box-shadow: 0 4px 20px rgba(0,0,0,.5); }
    #sessions-popup.open { display: block; }
    #sessions-popup-header { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid var(--border); font-size: 13px; font-weight: 700; color: var(--text); white-space: nowrap; }
    .sess-server-group-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 16px 4px; }
    .sess-server-name { font-size: 11px; font-weight: 700; color: var(--text3); text-transform: uppercase; letter-spacing: .04em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
    .sess-dashboard-link { flex-shrink: 0; border: none; background: none; color: var(--accent2); font-size: 11px; font-weight: 700; cursor: pointer; padding: 2px 4px; white-space: nowrap; }
    .sess-dashboard-link:hover { text-decoration: underline; }
    .sess-item { padding: 8px 16px; border-bottom: 1px solid #1e1e1e; }
    .sess-item:last-child { border-bottom: none; }
    .sess-item-title { font-size: 13px; color: var(--text); font-weight: 600; margin-bottom: 2px; }
    .sess-item-meta { font-size: 11.5px; color: var(--text2); line-height: 1.5; }
    .sess-empty { padding: 24px 16px; text-align: center; color: var(--text2); font-size: 13px; }

    /* 동시 시청 대시보드(#!/sessions, #content 내부 전체 화면 뷰) — 예전 sessions.html의
       상세 뷰를 SPA 안으로 이식. 팝업(.sess-*)과 클래스를 분리해(sess-dash-*) 서로
       스타일이 섞이지 않게 한다. */
    .sess-dash-wrap { max-width: 1440px; margin: 0 auto; padding: 24px 28px 64px; }
    .sess-dash-head { margin-bottom: 4px; }
    .sess-dash-sub { font-size: 13px; color: var(--text2); }
    .sess-dash-h2 { font-size: 15px; margin: 32px 0 12px; color: var(--text2); font-weight: 600; }
    .sess-dash-muted { color: var(--text2); font-size: 12px; }
    .sess-dash-status-off { color: #d66f6f; }
    .sess-dash-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 340px)); gap: 16px; align-items: start; justify-content: start; }
    .sess-dash-grid .sess-dash-empty { grid-column: 1 / -1; width: 100%; }
    .sess-dash-card { min-width: 0; overflow: hidden; background: var(--bg2); border: 1px solid var(--border); border-radius: 10px; }
    .sess-dash-card-main { display: flex; min-height: 174px; }
    .sess-dash-poster { position: relative; flex: 0 0 112px; width: 112px; min-height: 174px; overflow: hidden; border: 0; padding: 0; background: linear-gradient(145deg, #25282b, #121416); color: inherit; }
    .sess-dash-detail { cursor: pointer; outline: none; }
    .sess-dash-poster img { display: block; width: 100%; height: 100%; min-height: 174px; object-fit: cover; }
    .sess-dash-poster-fallback { display: flex; align-items: center; justify-content: center; width: 100%; height: 100%; min-height: 174px; color: var(--text3); font-size: 24px; }
    .sess-dash-poster-fallback[hidden] { display: none; }
    .sess-dash-card-info { min-width: 0; flex: 1; padding: 12px 12px 10px; }
    .sess-dash-title { overflow: hidden; color: var(--text); font-size: 14px; font-weight: 700; line-height: 1.35; text-overflow: ellipsis; white-space: nowrap; }
    .sess-dash-episode { margin-top: 4px; overflow: hidden; color: var(--text2); font-size: 12px; line-height: 1.35; text-overflow: ellipsis; white-space: nowrap; }
    .sess-dash-duration { margin-top: 4px; color: var(--text3); font-size: 11.5px; }
    .sess-dash-device { margin-top: 12px; overflow: hidden; color: var(--text); font-size: 12px; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
    .sess-dash-badges { display: flex; gap: 4px; margin-top: 6px; overflow: hidden; flex-wrap: wrap; }
    .sess-dash-tech, .sess-dash-progress-text { margin-top: 5px; overflow: hidden; color: var(--text3); font-size: 10.5px; text-overflow: ellipsis; white-space: nowrap; }
    .sess-dash-bar { height: 3px; background: var(--bg3); border-radius: 2px; margin-top: 7px; overflow: hidden; }
    .sess-dash-bar > div { height: 100%; background: var(--accent); }
    .sess-dash-meta { margin-top: 6px; display: flex; gap: 14px; flex-wrap: wrap; }
    .sess-dash-control { display: block; width: 100%; min-height: 34px; padding: 9px 12px; border: 0; border-top: 1px solid var(--border); background: rgba(0,0,0,.18); color: var(--text2); font: inherit; font-size: 11px; cursor: pointer; text-align: left; transition: background .12s ease, color .12s ease; }
    .sess-dash-control-label { display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%; }
    .sess-dash-control-label > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .sess-dash-control-stop { display: none; width: 100%; color: #fff; font-weight: 700; text-align: center; }
    .sess-dash-control:hover, .sess-dash-control:focus-visible { background: rgba(151,32,46,.48); color: #fff; outline: none; }
    .sess-dash-control:hover .sess-dash-control-label, .sess-dash-control:focus-visible .sess-dash-control-label { display: none; }
    .sess-dash-control:hover .sess-dash-control-stop, .sess-dash-control:focus-visible .sess-dash-control-stop { display: block; }
    .sess-dash-empty { padding: 40px 0; text-align: center; color: var(--text2); }
    .sess-dash-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
    .sess-dash-table th, .sess-dash-table td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--border); }
    .sess-dash-table th { color: var(--text2); font-weight: 600; }
    .sess-dash-history-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 10px 10px 14px; }
    .sess-dash-history-row > span { min-width: 0; line-height: 1.5; }
    .sess-dash-delete-col { width: 30px; padding-left: 2px !important; padding-right: 2px !important; text-align: right !important; }
    .sess-dash-history-delete { display: inline-flex; flex: 0 0 26px; align-items: center; justify-content: center; width: 26px; height: 26px; padding: 0; border: 0; border-radius: 6px; background: transparent; color: var(--text3); font-size: 18px; line-height: 1; cursor: pointer; }
    .sess-dash-history-delete:hover, .sess-dash-history-delete:focus-visible { background: rgba(151,32,46,.48); color: #fff; outline: none; }
    .sess-dash-history-delete:disabled { opacity: .35; cursor: wait; }
    .sd-badge { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; vertical-align: 1px; }
    .sd-b-direct { background: #123c22; color: #6fd68a; }
    .sd-b-trans  { background: #3c2d12; color: #e8b45a; }
    .sd-b-pause  { background: var(--bg3); color: var(--text2); }
    .sd-b-play   { background: #16324a; color: #6fb8e8; }
    .sd-b-server { background: #2a2233; color: #c39ce8; }
    .sess-stop-overlay { position: fixed; inset: 0; z-index: 1200; display: flex; align-items: center; justify-content: center; padding: 20px; background: rgba(0,0,0,.7); }
    .sess-stop-dialog { width: min(480px, 100%); overflow: hidden; border: 1px solid var(--border); border-radius: 10px; background: var(--bg2); box-shadow: 0 18px 60px rgba(0,0,0,.6); }
    .sess-stop-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 16px 18px; border-bottom: 1px solid var(--border); color: var(--text); }
    .sess-stop-header strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .sess-stop-close { flex: 0 0 auto; border: 0; background: none; color: var(--text2); font-size: 24px; line-height: 1; cursor: pointer; }
    .sess-stop-body { padding: 18px; }
    .sess-stop-user { margin-bottom: 18px; color: var(--text2); font-size: 13px; }
    .sess-stop-body label { display: block; margin-bottom: 7px; color: var(--text); font-size: 12px; font-weight: 600; }
    .sess-stop-body label span { color: var(--text3); font-weight: 400; }
    .sess-stop-body textarea { box-sizing: border-box; width: 100%; resize: vertical; min-height: 92px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 6px; background: var(--bg1); color: var(--text); font: inherit; font-size: 13px; }
    .sess-stop-body textarea:focus { border-color: var(--accent); outline: none; }
    .sess-stop-error { margin-top: 10px; color: #ef7777; font-size: 12px; }
    .sess-stop-actions { display: flex; justify-content: flex-end; gap: 8px; padding: 0 18px 18px; }
    @media (max-width: 720px) {
      .sess-dash-wrap { padding: 18px 16px 48px; }
      .sess-dash-grid { grid-template-columns: minmax(0, 1fr); }
      .sess-dash-card { width: 100%; }
    }

    /* NOTIFICATIONS (topbar) */
    #notif-bell-btn { position: relative; display: flex; align-items: center; justify-content: center; width: 34px; height: 34px; border-radius: 6px; border: none; background: none; color: var(--text2); cursor: pointer; flex-shrink: 0; }
    #notif-bell-btn:hover { background: var(--bg3); color: var(--text); }
    #notif-badge { position: absolute; top: 2px; right: 2px; min-width: 15px; height: 15px; padding: 0 3px; border-radius: 8px; background: #e5484d; color: #fff; font-size: 10px; font-weight: 700; line-height: 15px; text-align: center; }
    #notif-popup { display: none; position: fixed; background: var(--bg2); border: 1px solid var(--border); border-radius: 8px; width: 360px; max-height: 480px; overflow-y: auto; z-index: 400; box-shadow: 0 4px 20px rgba(0,0,0,.5); }
    #notif-popup.open { display: block; }
    #notif-popup-header { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid var(--border); font-size: 13px; font-weight: 700; color: var(--text); }
    #notif-popup-header a { color: var(--accent); font-size: 12px; font-weight: 400; cursor: pointer; }
    .notif-item { position: relative; padding: 12px 44px 12px 16px; border-bottom: 1px solid #1e1e1e; }
    .notif-item:last-child { border-bottom: none; }
    .notif-item.unread { background: rgba(229,160,13,.06); }
    .notif-delete-btn { position: absolute; top: 10px; right: 10px; display: flex; align-items: center; justify-content: center; width: 24px; height: 24px; border: none; border-radius: 6px; background: transparent; color: var(--text3); font-size: 16px; line-height: 1; cursor: pointer; opacity: 0; transition: opacity .12s ease, background .12s ease, color .12s ease; }
    .notif-item:hover .notif-delete-btn, .notif-delete-btn:focus-visible { opacity: 1; }
    .notif-delete-btn:hover { background: var(--bg3); color: var(--text); }
    .notif-item-title { font-size: 13px; color: var(--text); font-weight: 600; margin-bottom: 3px; }
    .notif-item-body { font-size: 12px; color: var(--text2); line-height: 1.5; }
    .notif-item-time { font-size: 11px; color: var(--text3); margin-top: 4px; }
    .notif-item-actions { display: flex; gap: 8px; margin-top: 8px; }
    .notif-empty { padding: 24px 16px; text-align: center; color: var(--text2); font-size: 13px; }

    /* ADMIN PANEL */
    #admin-panel { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.7); z-index: 600; align-items: flex-start; justify-content: center; padding-top: 60px; }
    #admin-panel.open { display: flex; }
    .admin-box { background: var(--bg); border: 1px solid var(--border); border-radius: 12px; width: 720px; max-width: 95vw; max-height: 80vh; display: flex; flex-direction: column; overflow: hidden; }
    .admin-header { display: flex; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--border); gap: 12px; }
    .admin-header h3 { flex: 1; font-size: 16px; font-weight: 700; }
    .admin-close { background: none; border: none; color: var(--text2); font-size: 20px; cursor: pointer; }
    .admin-tabs { display: flex; border-bottom: 1px solid var(--border); background: var(--bg2); }
    .admin-tab { padding: 10px 20px; cursor: pointer; font-size: 13px; color: var(--text2); border-bottom: 2px solid transparent; }
    .admin-tab.active { color: var(--accent); border-bottom-color: var(--accent); }
    .admin-body { flex: 1; overflow-y: auto; padding: 20px; }
    .user-row { display: flex; align-items: center; gap: 10px; padding: 10px 14px; background: var(--bg2); border-radius: 8px; margin-bottom: 8px; }
    .user-row-name { flex: 1; font-size: 14px; font-weight: 500; }
    .user-row-badge { font-size: 11px; padding: 2px 7px; border-radius: 10px; background: var(--bg4); color: var(--text2); }
    .user-row-badge.admin { background: rgba(229,160,13,.15); color: var(--accent); }
    .user-row-badge.disabled { background: rgba(245,85,85,.12); color: #f55; }
    .admin-btn { padding: 5px 10px; background: var(--bg3); border: 1px solid var(--border); border-radius: 5px; font-size: 12px; color: var(--text2); cursor: pointer; }
    .admin-btn:hover { border-color: var(--accent); color: var(--accent); }
    .admin-btn.danger:hover { border-color: #f55; color: #f55; }
    .policy-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 20px; margin-bottom: 16px; }
    .policy-row { display: flex; flex-direction: column; gap: 4px; }
    .policy-row label { font-size: 12px; color: var(--text2); }
    .policy-row select, .policy-row input[type=number] { background: var(--bg3); border: 1px solid var(--border); border-radius: 5px; color: var(--text); padding: 6px 8px; font-size: 13px; outline: none; }
    .policy-toggle { display: flex; align-items: center; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--border); }
    .policy-toggle label { font-size: 13px; }
    .toggle-switch { position: relative; display: inline-block; flex-shrink: 0; width: 36px; height: 20px; }
    .toggle-switch input { opacity: 0; width: 0; height: 0; }
    .toggle-slider { position: absolute; inset: 0; background: var(--bg4); border-radius: 20px; cursor: pointer; transition: background .2s; }
    .toggle-slider::after { content: ''; position: absolute; left: 3px; top: 3px; width: 14px; height: 14px; background: #fff; border-radius: 50%; transition: transform .2s; }
    .toggle-switch input:checked + .toggle-slider { background: var(--accent); }
    .toggle-switch input:checked + .toggle-slider::after { transform: translateX(16px); }


/* READABILITY PASS: library modal and settings */
#library-modal .modal-backdrop { background: rgba(0,0,0,.72); }
#lib-modal-inner {
  width: min(1040px, 94vw) !important;
  height: min(760px, 88vh) !important;
  background: #252525;
  border-color: #3a3a3a;
  box-shadow: 0 24px 80px rgba(0,0,0,.62);
}
#lib-modal-title {
  padding: 26px 32px 0 !important;
  font-size: 21px;
  line-height: 1.25;
  color: #f3f4f5;
}
#lib-modal-inner > div[style*="display:flex"] { margin-top: 20px !important; }
#lib-modal-nav {
  width: 184px !important;
  padding: 6px 12px !important;
  border-right-color: #3a3a3a !important;
}
.lib-modal-nav-item {
  min-height: 38px;
  display: flex;
  align-items: center;
  padding: 0 14px;
  font-size: 15px;
  font-weight: 650;
  color: #cfd6da;
  border-radius: 6px;
}
.lib-modal-nav-item:hover { background: #333; color: #fff; }
.lib-modal-nav-item.active { color: var(--accent); background: rgba(229,160,13,.16); }
#lib-modal-tab-content {
  padding: 6px 32px 24px !important;
  font-size: 15px;
}
#lib-modal-inner .form-group { margin-bottom: 18px; }
#lib-modal-inner .form-group label { font-size: 15px; color: #d7dde0; margin-bottom: 7px; font-weight: 650; }
#lib-modal-inner .form-group input,
#lib-modal-inner .form-group select {
  min-height: 40px;
  padding: 10px 12px;
  font-size: 15px;
  background: #303030;
  border-color: #444;
}
#lib-modal-inner .type-cards { gap: 14px; }
#lib-modal-inner .type-card { padding: 16px 14px; }
#lib-modal-inner .type-card .icon { font-size: 28px; }
#lib-modal-inner .type-card .label { font-size: 14px; color: #d4d9dc; }
#lib-modal-inner .modal-footer {
  padding: 18px 32px !important;
  border-top-color: #3a3a3a !important;
  margin-top: 0;
}
#lib-modal-inner .topbar-btn,
#lib-modal-inner .danger-btn { min-height: 34px; font-size: 14px; padding: 7px 14px; }
#lib-tab-folders .topbar-btn { min-height: 34px; font-size: 14px; padding: 7px 14px; }

/* READABILITY PASS: 친구 편집 모달 (라이브러리 모달과 동일 패턴) */
#friend-modal .modal-backdrop { background: rgba(0,0,0,.72); }
#friend-modal-inner {
  width: min(1040px, 94vw) !important;
  height: min(760px, 88vh) !important;
  background: #252525;
  border-color: #3a3a3a;
  box-shadow: 0 24px 80px rgba(0,0,0,.62);
}
#friend-modal-title { padding: 26px 32px 0 !important; font-size: 21px; line-height: 1.25; color: #f3f4f5; }
#friend-modal-inner > div[style*="display:flex"] { margin-top: 20px !important; }
#friend-modal-nav { width: 184px !important; padding: 6px 12px !important; border-right-color: #3a3a3a !important; }
.friend-modal-nav-item {
  min-height: 38px; display: flex; align-items: center; padding: 0 14px;
  font-size: 15px; font-weight: 650; color: #cfd6da; border-radius: 6px;
}
.friend-modal-nav-item:hover { background: #333; color: #fff; }
.friend-modal-nav-item.active { color: var(--accent); background: rgba(229,160,13,.16); }
#friend-modal-tab-content { padding: 6px 32px 24px !important; font-size: 15px; }
#friend-modal-inner .form-group { margin-bottom: 18px; }
#friend-modal-inner .form-group label { font-size: 15px; color: #d7dde0; margin-bottom: 7px; font-weight: 650; }
#friend-modal-inner .form-group input,
#friend-modal-inner .form-group select {
  min-height: 40px; padding: 10px 12px; font-size: 15px; background: #303030; border-color: #444;
}
#friend-modal-inner .modal-footer { padding: 18px 32px !important; border-top-color: #3a3a3a !important; margin-top: 0; }
#friend-modal-inner .topbar-btn { min-height: 34px; font-size: 14px; padding: 7px 14px; }
.friend-schedule-row { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.friend-schedule-row select, .friend-schedule-row input { background: #303030; border: 1px solid #444; border-radius: 5px; color: var(--text); padding: 6px 8px; font-size: 13px; }
.friend-schedule-row .topbar-btn.danger-btn { min-height: 30px; padding: 4px 10px; font-size: 12px; }
.friend-library-server-block { border-top: 1px solid #1e1e1e; padding: 12px 0; margin-top: 8px; }
.folder-list { gap: 12px; }
.folder-card {
  min-height: 78px;
  padding: 16px 18px;
  gap: 18px;
  background: #2b2b2b;
  border-color: #414141;
}
.folder-path {
  min-width: 0;
  font-size: 14.5px;
  line-height: 1.35;
  color: #f4f5f6;
  overflow-wrap: anywhere;
}
.folder-meta { gap: 20px; font-size: 13px; color: #b8c0c4; }
.folder-meta strong { font-size: 16px; color: #fff; }
.folder-actions { gap: 8px; flex-shrink: 0; }
.folder-actions .topbar-btn,
.folder-actions .danger-btn { min-height: 32px; font-size: 13px; padding: 6px 12px; }

#settings-overlay { background: #181818; }
#settings-nav {
  width: 282px;
  min-width: 282px;
  background: #151515;
  border-right-color: #303030;
}
#settings-nav-header { padding: 22px 22px 16px; border-bottom-color: #303030; }
#settings-back-btn {
  min-height: 38px;
  color: #d7dde0;
  font-size: 15.5px;
  font-weight: 700;
  padding: 8px 10px;
}
#settings-back-btn:hover { background: #242424; color: #fff; }
#settings-nav-title { font-size: 23px; color: #fff; padding: 2px 4px 0; }
.settings-nav-group { padding: 14px 0 6px; }
.settings-nav-label {
  font-size: 12px;
  color: #8f9aa1;
  letter-spacing: .05em;
  padding: 6px 22px 7px;
}
.settings-nav-item {
  min-height: 40px;
  display: flex;
  align-items: center;
  padding: 0 22px;
  font-size: 15.5px;
  font-weight: 600;
  color: #d1d7db;
  border-left-width: 4px;
}
.settings-nav-item:hover { background: #242424; color: #fff; }
.settings-nav-item.active {
  color: #f4b21a;
  background: rgba(229,160,13,.14);
  border-left-color: var(--accent);
}
#settings-content-area { padding: 42px 52px; }
.settings-page-title { font-size: 30px; color: #fff; margin-bottom: 30px; }
.settings-card { background: #232323; border-color: #3a3a3a; border-radius: 8px; }
.settings-card-title {
  font-size: 13px;
  color: #9da7ad;
  padding: 16px 20px;
  border-bottom-color: #3a3a3a;
}
.sfield { min-height: 64px; padding: 16px 20px; border-bottom-color: #323232; }
.sfield-name { font-size: 16px; color: #f2f4f5; font-weight: 650; }
.sfield-desc { font-size: 14px; color: #b7c0c6; line-height: 1.4; }
.s-pill { min-height: 32px; padding: 7px 16px; font-size: 14.5px; color: #d2d8dc; }
.s-input { min-height: 40px; font-size: 15px; background: #303030; border-color: #444; }
.s-btn { min-height: 36px; font-size: 14.5px; color: #d6dde1; }
.s-result { font-size: 13.5px; }
.live-source-row {
  display: grid;
  grid-template-columns: 86px minmax(420px, 1fr) 142px 220px;
  align-items: center;
  gap: 14px;
  padding-right: 42px;
}
.live-source-row > * { min-width: 0; }
.live-source-url, .live-source-option-input { width: 100%; box-sizing: border-box; }
.live-source-option-label { margin-left: 2px; text-align: right; white-space: nowrap; }
.live-status-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(140px, 1fr)) minmax(300px, 1.7fr);
  gap: 10px;
  margin-bottom: 16px;
}

@media (max-width: 640px) {
  #lib-modal-inner { width: 96vw !important; height: 88vh !important; }
  #lib-modal-nav { width: 138px !important; }
  .lib-modal-nav-item { font-size: 13.5px; }
  #friend-modal-inner { width: 96vw !important; height: 88vh !important; }
  #friend-modal-nav { width: 138px !important; }
  .friend-modal-nav-item { font-size: 13.5px; }
  #settings-overlay.open { display: block; }
  #settings-nav { width: 100%; min-width: 0; height: 100%; border-right: 0; }
  #settings-content-panel { display: none; width: 100%; height: 100%; }
  #settings-overlay.mobile-content #settings-nav { display: none; }
  #settings-overlay.mobile-content #settings-content-panel { display: flex; }
  #settings-mobile-nav-back { display: flex; align-items: center; min-height: 48px; padding: 10px 16px; border: 0; border-bottom: 1px solid #303030; background: #181818; color: #e7ebed; font-size: 15px; font-weight: 700; }
  #settings-content-area { padding: 18px 12px 28px; }
  .live-source-row { display: grid; grid-template-columns: 1fr; gap: 7px; padding: 14px 16px 14px 12px; }
  .live-source-option-label { margin: 7px 0 0; text-align: left; }
  .live-status-summary { grid-template-columns: 1fr; }
  .live-status-refresh { overflow-x: auto; }
}


/* PLEX-LIKE VIEW MODES */
body[data-media-view="grid"] .poster-grid { display: flex; flex-wrap: wrap; gap: 16px; }
body[data-media-view="detail"] .poster-grid,
body[data-media-view="table"] .poster-grid { display: flex; flex-direction: column; gap: 0; }
body[data-media-view="detail"] .poster-card {
  width: 100%;
  min-height: 132px;
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr) 92px;
  align-items: center;
  gap: 18px;
  padding: 14px 18px;
  border-bottom: 1px solid #242424;
  background: rgba(255,255,255,.018);
}
body[data-media-view="detail"] .poster-card:nth-child(even) { background: rgba(255,255,255,.035); }
body[data-media-view="detail"] .poster-card:hover { background: #262626; }
body[data-media-view="detail"] .poster-thumb {
  width: 78px;
  height: 112px;
  border-radius: 4px;
  transform: none !important;
}
body[data-media-view="detail"] .poster-card:hover .poster-thumb { box-shadow: none; }
body[data-media-view="detail"] .poster-title { margin-top: 0; font-size: 16px; font-weight: 750; -webkit-line-clamp: 1; }
body[data-media-view="detail"] .poster-sub { grid-column: 3; grid-row: 1; justify-self: end; font-size: 13.5px; color: #c3ccd1; margin-top: 0; }
body[data-media-view="detail"] .poster-summary { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; max-width: 900px; margin-top: 8px; font-size: 13px; line-height: 1.45; color: #aeb7bc; font-weight: 500; }
body[data-media-view="grid"] .poster-summary, body[data-media-view="table"] .poster-summary { display: none; }
body[data-media-view="table"] .poster-grid { border-top: 1px solid #303030; }
body[data-media-view="table"] .poster-card {
  width: 100%;
  min-height: 36px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 120px;
  align-items: center;
  gap: 18px;
  padding: 0 18px;
  border-bottom: 1px solid #242424;
  background: rgba(255,255,255,.018);
}
body[data-media-view="table"] .poster-card:nth-child(even) { background: rgba(255,255,255,.032); }
body[data-media-view="table"] .poster-card:hover { background: #26313a; }
body[data-media-view="table"] .poster-thumb { display: none; }
body[data-media-view="table"] .poster-title { margin: 0; font-size: 14px; font-weight: 700; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
body[data-media-view="table"] .poster-sub { margin: 0; justify-self: end; font-size: 13px; color: #aeb6ba; white-space: nowrap; }
body[data-media-view="table"] .card-menu-btn,
body[data-media-view="table"] .card-edit-btn { display: none !important; }
body[data-media-view="detail"] .card-menu-btn,
body[data-media-view="detail"] .card-edit-btn { display: none !important; }

/* Global search is not a library view-mode surface. Keep its cards in the
   regular poster layout even when the current library saved detail/table mode. */
#content .poster-grid.search-result-grid {
  display: flex;
  flex-flow: row wrap;
  gap: 16px;
  border-top: 0;
}
#content .search-result-grid .poster-card {
  display: block;
  width: var(--card-w);
  min-height: 0;
  padding: 0;
  border: 0;
  background: transparent;
}
#content .search-result-grid .poster-thumb {
  display: block;
  width: var(--card-w);
  height: var(--card-h);
  padding-bottom: 0;
  border-radius: 8px;
}
#content .search-result-grid .poster-title {
  display: -webkit-box;
  margin-top: 7px;
  white-space: normal;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
#content .search-result-grid .poster-sub {
  display: block;
  margin-top: 2px;
}

@media (max-width: 640px) {
  #content .poster-grid.search-result-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px 10px;
  }
  #content .search-result-grid .poster-card {
    width: 100%;
    min-width: 0;
  }
  #content .search-result-grid .poster-thumb {
    width: 100%;
    height: 0;
    padding-bottom: 150%;
  }
  #content .search-result-grid .poster-title {
    margin-top: 5px;
    font-size: 12px;
    line-height: 1.35;
  }
  #content .search-result-grid .poster-sub { font-size: 10px; }
}

@media (max-width: 900px) {
  .browse-list-header { padding-right: 0; }
  #search-wrap { flex-basis: 174px; max-width: 210px; }
}

#main:has(#bulk-select-bar.visible) .browse-list-header,
#main:has(#scan-progress-bar.visible) .browse-list-header { padding-right: 0; }

/* Mobile admin navigation keeps the operational buttons visible. Card zoom
   stays beside the count; alternate list modes remain desktop/tablet-only. */
@media (max-width: 640px) {
  .browse-list-header .show-toolbar > #media-view-controls { display: flex !important; gap: 0; }
  #grid-zoom, #grid-zoom-slider { width: 82px; }
  #view-menu-btn, #view-menu { display: none !important; }

  body[data-media-view] .season-poster-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: start;
  }
  body[data-media-view] .season-poster-grid .season-poster-card {
    display: block;
    flex: 0 0 calc((100% - 32px) / 5);
    width: calc((100% - 32px) / 5);
    max-width: calc((100% - 32px) / 5);
    min-width: 0;
    min-height: 0;
    padding: 0;
    border: 0;
    background: transparent;
  }
  body[data-media-view] .season-poster-grid .season-poster-card:hover {
    background: transparent;
  }
  body[data-media-view] .season-poster-grid .season-poster-card .poster-thumb {
    display: block;
    width: 100%;
    height: 0;
    padding-bottom: 150%;
    border-radius: 7px;
  }
  body[data-media-view] .season-poster-grid .season-poster-card .poster-title {
    display: -webkit-box;
    margin-top: 5px;
    font-size: 12px;
    line-height: 1.35;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }
  body[data-media-view] .season-poster-grid .season-poster-card .poster-sub {
    display: block;
    margin-top: 2px;
    font-size: 10px;
  }
}


/* DETAIL VIEW LAYOUT FIX */
body[data-media-view="detail"] .poster-card { align-items: start; }
body[data-media-view="detail"] .poster-thumb { grid-column: 1; grid-row: 1 / span 2; align-self: center; }
body[data-media-view="detail"] .poster-title { grid-column: 2; grid-row: 1; align-self: end; }
body[data-media-view="detail"] .poster-summary { grid-column: 2; grid-row: 2; align-self: start; }
body[data-media-view="detail"] .poster-sub { grid-column: 3; grid-row: 1 / span 2; align-self: center; }


/* Settings page header actions and secret fields */
.settings-page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 30px; }
.settings-page-head .settings-page-title { margin-bottom: 0; }
.settings-page-actions { display: flex; align-items: center; justify-content: flex-end; gap: 12px; }
.secret-control { display: flex; align-items: center; justify-content: flex-end; gap: 8px; width: 100%; }
.secret-control .s-input { flex: 1; min-width: 0; }
.secret-control-textarea { align-items: flex-start; }
.secret-toggle { min-width: 64px; padding-left: 12px; padding-right: 12px; }
.secret-field.is-masked { -webkit-text-security: disc; }
@media (max-width: 640px) {
  .settings-page-head { align-items: flex-start; flex-direction: column; }
  .settings-page-actions { width: 100%; justify-content: flex-end; }
  .secret-control { align-items: stretch; flex-direction: column; }
  .secret-toggle { width: 100%; }
}

.settings-local-actions { display: flex; align-items: center; justify-content: flex-end; gap: 12px; margin: -4px 0 0; }
@media (max-width: 640px) {
  .settings-local-actions { margin-top: -2px; }
}

/* Logical Library View editor */
.lv-page-desc,.lv-help,.lv-loading { color:var(--text2);font-size:13px;line-height:1.55 }
.lv-back { display:block;border:0;background:none;color:var(--text2);padding:0 0 7px;cursor:pointer;font-size:13px }
.lv-summary-strip { display:flex;gap:22px;padding:12px 16px;margin:-10px 0 16px;background:#202020;border:1px solid var(--border);border-radius:8px;color:var(--text2);font-size:13px }
.lv-card-list { display:flex;flex-direction:column;gap:10px }
.lv-card { display:flex;align-items:center;justify-content:space-between;gap:20px;padding:17px 18px;background:#232323;border:1px solid #3a3a3a;border-radius:9px }
.lv-card-failed { border-color:#8d3d3d }.lv-card-main{display:flex;align-items:center;gap:14px;min-width:0}.lv-card-icon{width:42px;height:42px;display:flex;align-items:center;justify-content:center;border-radius:9px;background:#303030;color:var(--accent);font-size:20px}.lv-card-copy{min-width:0}.lv-card-title{font-size:16px;font-weight:750}.lv-card-meta,.lv-card-sources{margin-top:4px;color:var(--text2);font-size:12.5px}.lv-card-sources b{color:#b9c1c6;font-weight:600}.lv-card-actions{display:flex;gap:8px;align-items:center}.lv-lock,.lv-muted-badge{color:var(--text3);font-size:12px}.lv-muted-badge{padding:2px 7px;background:#333;border-radius:10px}.lv-error{color:#ff8585;font-size:12px;margin-top:5px;max-width:700px}.lv-title-actions{display:flex;align-items:center;justify-content:space-between}.lv-title-actions .s-btn{padding:5px 10px}.lv-help{padding:13px 20px;border-bottom:1px solid var(--border)}
.lv-source-list{width:100%;padding:4px 0}.lv-source-row{display:grid;grid-template-columns:22px minmax(0,1fr) 90px auto;align-items:center;gap:12px;padding:10px 20px;border-bottom:1px solid #303030}.lv-source-row:last-child{border:0}.lv-source-name{font-weight:650;display:flex;align-items:center;min-width:0}.lv-source-type{color:var(--text3);font-size:12px;text-align:right}.lv-source-role{width:130px;min-width:0}.lv-source-ctrls{display:flex;align-items:center;justify-content:flex-end;gap:6px}.lv-source-rank{display:inline-flex;align-items:center;justify-content:center;min-width:18px;height:18px;padding:0 5px;margin-right:8px;border-radius:9px;background:var(--accent);color:#101010;font-size:11px;font-weight:700;flex:none}.lv-source-grouphead{padding:9px 20px 4px;color:var(--text3);font-size:11px;font-weight:700;letter-spacing:.03em}.lv-icon-btn:disabled{opacity:.35;cursor:default}.lv-filter-groups{padding:14px;display:flex;flex-direction:column;gap:12px}.lv-filter-group{border:1px solid #414141;border-radius:8px;background:#1d1d1d;padding:13px}.lv-filter-head{display:flex;align-items:center;gap:10px;margin-bottom:10px}.lv-filter-head span{color:var(--text3);font-size:12px}.lv-filter-head .lv-icon-btn{margin-left:auto}.lv-filter-scope{display:flex;align-items:center;gap:14px;flex-wrap:wrap;padding:8px 10px;margin-bottom:8px;background:#262626;border-radius:6px;color:var(--text2);font-size:12px}.lv-filter-scope>span{font-weight:700;color:#d4d9dc}.lv-condition-list{display:flex;flex-direction:column;gap:7px}.lv-condition-row{display:grid;grid-template-columns:minmax(140px,1fr) minmax(130px,.8fr) minmax(150px,1.2fr) 30px;gap:7px;align-items:center}.lv-icon-btn{width:30px;height:30px;border:0;border-radius:5px;background:#333;color:#ddd;cursor:pointer;font-size:18px}.lv-add-condition{margin-top:9px}.lv-condition-rating{align-items:start}.lv-cond-field-wrap{display:flex;flex-direction:column;gap:6px;min-width:0}.lv-cond-field-wrap .s-select{width:100%;min-width:0}.lv-cond-rating-source{color:var(--accent)}.lv-preview-card{margin-top:16px}.lv-preview-numbers{display:grid;grid-template-columns:repeat(3,1fr);gap:1px;background:var(--border)}.lv-preview-numbers>div{background:#232323;padding:18px;text-align:center}.lv-preview-numbers b{display:block;font-size:24px;color:#fff}.lv-preview-numbers span{color:var(--text2);font-size:12px}.lv-report{padding:12px 18px}.lv-report>div{display:flex;justify-content:space-between;gap:12px;padding:6px 0;border-bottom:1px solid #303030;font-size:13px}.lv-report span{color:var(--text2);text-align:right}.lv-ok{color:#6bd08b}.lv-samples{padding:12px 18px;display:flex;gap:7px;flex-wrap:wrap}.lv-samples b{width:100%;margin-bottom:3px}.lv-samples span{padding:4px 9px;background:#303030;border-radius:12px;color:var(--text2);font-size:12px}
.scheduled-job-card .settings-card-title{padding:10px 16px}.scheduled-job-card .sfield{min-height:42px;padding:8px 16px}.scheduled-job-card .settings-footer-row{padding:9px 16px 10px!important}.scheduled-job-card .sfield-desc{line-height:1.3}
 .lib-metadata-toggles label{display:grid;grid-template-columns:20px minmax(0,1fr);align-items:center;column-gap:10px;cursor:pointer;margin-top:7px;font-size:13px;line-height:1.35}.lib-metadata-toggles label:first-child{margin-top:0}.lib-metadata-toggles input{width:16px;height:16px;justify-self:start}
@media(max-width:700px){.lv-card{align-items:flex-start;flex-direction:column}.lv-card-actions{width:100%;justify-content:flex-end}.lv-summary-strip{gap:8px;flex-direction:column}.lv-source-row{grid-template-columns:22px 1fr}.lv-source-type{display:none}.lv-source-ctrls{grid-column:2;justify-content:flex-start}.lv-source-role{flex:1;width:auto}.lv-condition-row{grid-template-columns:1fr}.lv-condition-row .lv-icon-btn{justify-self:end}.lv-preview-numbers{grid-template-columns:1fr}.lv-report>div{gap:5px;flex-direction:column}}

/* Metadata edit modal enrichment */
#edit-modal { width: min(760px, 95vw); }
.edit-form-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 14px 16px; }
.edit-form-grid .form-group { margin-bottom: 0; }
.edit-tag-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 14px 16px; }
.edit-tag-grid .form-group { margin-bottom: 0; }
.edit-tag-wide { grid-column: 1 / -1; }
.edit-textarea { width: 100%; padding: 9px 11px; background: var(--bg3); border: 1px solid var(--border); border-radius: 6px; color: var(--text); font-size: 14px; line-height: 1.45; resize: vertical; outline: none; }
.edit-textarea:focus { border-color: var(--accent); }
.readonly-input { color: var(--text2) !important; background: #2b2b2b !important; border-color: #3c3c3c !important; cursor: default; }
.edit-chip-box { min-height: 42px; display: flex; align-items: center; flex-wrap: wrap; gap: 8px; padding: 8px 10px; background: var(--bg3); border: 1px solid var(--border); border-radius: 6px; }
.edit-chip { display: inline-flex; align-items: center; min-height: 24px; padding: 3px 9px; border-radius: 5px; background: #3a3a3a; color: var(--text); font-size: 13px; font-weight: 650; }
.edit-empty-chip { color: var(--text3); font-size: 13px; }
@media (max-width: 720px) {
  .edit-form-grid, .edit-tag-grid { grid-template-columns: 1fr; }
  .edit-tag-wide { grid-column: auto; }
}

/* 쇼 테이블: 제목·연도 / 메타코드 / 대표 경로를 한 줄에서 비교한다. */
.table-show-meta { display:none; }
.table-year { display:none; }
body[data-media-view="table"] .poster-grid.show-grid .poster-card { grid-template-columns: minmax(260px, 1.2fr) minmax(420px, 2fr); }
body[data-media-view="table"] .poster-card .table-year { display:inline; color:#aeb6ba; font-weight:500; }
body[data-media-view="table"] .poster-card .poster-sub { display:none; }
body[data-media-view="table"] .poster-card .table-show-meta { display:grid; grid-template-columns:110px minmax(0,1fr); gap:16px; align-items:center; min-width:0; color:#aeb6ba; font-size:12px; }
body[data-media-view="table"] .table-code { color:#d5b36b; font-family:ui-monospace,Consolas,monospace; white-space:nowrap; }
body[data-media-view="table"] .table-path { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; font-family:ui-monospace,Consolas,monospace; color:#9da7ad; }
@media (max-width: 850px) { body[data-media-view="table"] .poster-card { grid-template-columns:minmax(0,1fr); padding:7px 12px; } body[data-media-view="table"] .poster-card .table-show-meta { grid-template-columns:90px minmax(0,1fr); } }

/* 가상 스크롤 그리드 — 컨테이너는 전체 목록 높이를 흉내내는 블록이고(스크롤바 유지),
   카드는 JS가 계산한 행/열 위치에 절대배치된다. flex/grid 레이아웃은 쓰지 않는다. */
.poster-grid.virtualized, .ep-list.virtualized { display: block !important; position: relative; }
/* nth-child 기반 줄무늬는 DOM 윈도우잉과 함께 어긋나므로 항목 인덱스 기반 v-even으로 대체 */
body[data-media-view="detail"] .poster-grid.virtualized .poster-card:nth-child(even),
body[data-media-view="table"] .poster-grid.virtualized .poster-card:nth-child(even) { background: transparent; }
body[data-media-view="detail"] .poster-grid.virtualized .poster-card.v-even { background: rgba(255,255,255,.035); }
body[data-media-view="table"] .poster-grid.virtualized .poster-card.v-even { background: rgba(255,255,255,.032); }
body[data-media-view="detail"] .poster-grid.virtualized .poster-card:hover { background: #262626; }
body[data-media-view="table"] .poster-grid.virtualized .poster-card:hover { background: #26313a; }
/* 공용 드롭다운의 위험 항목 색 — 기존 .show-more-dropdown/.media-row-dropdown 한정 규칙을 일반화 */
.card-dropdown .card-dropdown-item.danger { color: #f87171; }
/* Plex식 2단계 다중 선택 필터 */
.facet-menu { min-width: 236px; width: max-content; max-width: 320px; }
.facet-menu .tb-dropdown-item { min-height: 36px; padding: 8px 12px; }
.facet-menu .facet-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.facet-suffix { margin-left: 18px; color: var(--text3); font-size: 12px; white-space: nowrap; }
.facet-divider { height: 1px; margin: 5px 0; background: var(--border); }
.facet-back { min-height: 44px; padding: 11px 14px; border-bottom: 1px solid var(--border); color: var(--text2); font-size: 13px; font-weight: 650; cursor: pointer; }
.facet-back:hover { background: var(--bg4); color: var(--text); }
.facet-values { max-height: min(52vh, 430px); overflow-y: auto; overscroll-behavior: contain; }
.facet-empty { padding: 16px 14px; color: var(--text3); font-size: 12px; }
.facet-footer { display: flex; justify-content: flex-end; gap: 8px; padding: 9px 10px; border-top: 1px solid var(--border); background: rgba(0,0,0,.15); }
.facet-footer button { min-height: 30px; padding: 5px 12px; border: 1px solid var(--border); border-radius: 5px; color: var(--text2); background: var(--bg4); cursor: pointer; }
.facet-footer button:hover { filter: brightness(1.12); }
.facet-footer .facet-search { border-color: var(--accent); background: var(--accent); color: #17120a; font-weight: 750; }
.music-toolbar { margin-bottom: 14px; }
/* 영화·에피소드·트랙 미디어 작업 및 정보 보기 */
.media-row-menu-btn { flex: 0 0 32px; width: 32px; height: 32px; margin-left: auto; border: 0; border-radius: 50%; background: transparent; color: var(--text2); font-size: 22px; line-height: 1; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; }
.media-row-menu-btn:hover { background: rgba(255,255,255,.10); color: var(--text); }
.media-row-dropdown .card-dropdown-item.danger { color: #f87171; }
.track-play-cell { text-align: right; width: 76px; white-space: nowrap; }
.track-play-cell .media-row-menu-btn { width: 30px; height: 30px; margin-left: 4px; vertical-align: middle; }
.media-info-overlay { position: fixed; inset: 0; z-index: 1200; display: flex; align-items: center; justify-content: center; padding: 24px; background: rgba(0,0,0,.74); }
.media-info-box { width: min(860px, 94vw); max-height: 88vh; display: flex; flex-direction: column; overflow: hidden; border: 1px solid #464646; border-radius: 9px; background: #262626; box-shadow: 0 24px 70px rgba(0,0,0,.65); }
.media-info-header { min-height: 58px; padding: 0 20px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid #3b3b3b; background: #303030; color: #f2f2f2; font-size: 19px; font-weight: 800; }
.media-info-close { width: 34px; height: 34px; border: 0; border-radius: 50%; background: transparent; color: var(--text2); font-size: 27px; cursor: pointer; }
.media-info-close:hover { background: rgba(255,255,255,.09); color: #fff; }
.media-info-body { overflow-y: auto; padding: 18px 20px 24px; }
.media-info-section { margin-bottom: 18px; }
.media-info-section:last-child { margin-bottom: 0; }
.media-info-section h3 { margin: 0 0 11px; font-size: 16px; color: #f2f2f2; }
.media-info-section h4 { margin: 16px 0 8px; font-size: 14px; color: var(--text2); }
.media-info-part { padding: 15px; border: 1px solid #414141; border-radius: 7px; background: #2d2d2d; }
.media-info-path { padding: 11px 12px; margin-bottom: 14px; border-radius: 5px; background: #363636; color: #d6d6d6; font: 12px/1.55 ui-monospace,SFMono-Regular,Consolas,monospace; overflow-wrap: anywhere; }
.media-info-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); column-gap: 28px; row-gap: 0; }
.media-info-row { min-width: 0; display: grid; grid-template-columns: 122px minmax(0,1fr); gap: 10px; padding: 5px 0; border-bottom: 1px solid rgba(255,255,255,.035); }
.media-info-label { color: #999; font-size: 12px; }
.media-info-value { min-width: 0; color: #e1e1e1; font-size: 13px; overflow-wrap: anywhere; }
.media-info-subtitles { display: flex; flex-direction: column; gap: 5px; }
.media-info-subtitle, .media-info-marker { padding: 7px 9px; border-radius: 4px; background: rgba(255,255,255,.04); color: #c8c8c8; font-size: 12px; line-height: 1.5; overflow-wrap: anywhere; }
.media-info-extra { margin-top: 16px; color: var(--text2); }
.media-info-extra summary { cursor: pointer; color: var(--accent); font-size: 13px; }
.media-info-extra pre { max-height: 300px; overflow: auto; padding: 12px; border-radius: 5px; background: #1e1e1e; color: #c9d1d9; font: 12px/1.5 ui-monospace,SFMono-Regular,Consolas,monospace; white-space: pre-wrap; overflow-wrap: anywhere; }
@media (max-width: 720px) { .media-info-overlay { padding: 8px; } .media-info-grid { grid-template-columns: 1fr; } .media-info-row { grid-template-columns: 105px minmax(0,1fr); } .media-info-body { padding: 14px; } }

/* 태블릿·모바일 세로 — 탑바에 들어갈 자리가 없다.
 *
 * 섹션을 옮길 때마다 제목이 바뀌는데 폭이 모자라 제목이 다른 컨트롤을 다 밀어냈고,
 * 우측 끝의 설정 아이콘이 화면 밖으로 나가 관리자가 설정에 못 들어갔다. 세로에서는
 * 제목·탭을 숨긴다 — 제목은 좌측 사이드바가 이미 보여주고 있어 없어도 길을 잃지 않는다.
 * 설정 버튼만은 어떤 폭에서도 줄어들거나 밀리지 않게 고정한다(최소한의 탈출구).
 */
@media (orientation: portrait) and (max-width: 1280px) {
  #library-title, #tabs { display: none; }
  #search-wrap { min-width: 140px; }
  #settings-btn { flex: 0 0 auto; }
}

/* Use the actual content width: a visible library sidebar reduces the tablet
   header enough that the account name is redundant. Keep the avatar as the
   menu target, and restore the name automatically on a wide main pane. */
@container (max-width: 1040px) {
  #user-menu-name { display: none; }
  #user-menu-btn { gap: 0; padding: 4px; }
}
