/* Bibliotecas de mídia (home estilo streaming, série, detalhe, admin). */
.nav-label { padding: 8px 24px 0; font-size: 12px; letter-spacing: .02em; }
.lib-nav .nav-item span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.lib-page { max-width: none; padding-right: 16px; }
.lib-title { margin-top: 4px; }
.lib-empty { padding: 24px 0; }

/* Hero */
.lib-hero { position: relative; height: min(30vh, 260px); border-radius: 16px; overflow: hidden; background: var(--md-sys-color-surface-container-high); margin-bottom: 16px; }
.lib-hero-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.lib-hero-shade { position: absolute; inset: 0; background: linear-gradient(90deg, rgba(0,0,0,.82) 0%, rgba(0,0,0,.4) 55%, rgba(0,0,0,0) 100%); }
.lib-hero-body { position: absolute; left: 0; bottom: 0; max-width: min(560px, 90%); padding: 24px 28px; color: #fff; }
.lib-hero-title { margin: 0 0 6px; font-size: 28px; line-height: 34px; font-weight: 500; }
.lib-hero-meta { font-size: 14px; opacity: .9; margin-bottom: 8px; }
.lib-hero-overview { margin: 0 0 16px; font-size: 14px; line-height: 20px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.lib-hero-actions .btn.filled { background: #fff; color: #1f1f1f; }

/* Rows + poster cards */
.lib-rows { display: flex; flex-direction: column; gap: 24px; }
.lib-row-title { margin: 0 0 12px; font-size: 18px; line-height: 24px; font-weight: 500; }
.lib-row-track { display: flex; gap: 14px; overflow-x: auto; padding: 4px 2px 12px; scroll-snap-type: x proximity; }
.lib-card { flex: 0 0 150px; width: 150px; scroll-snap-align: start; background: none; border: 0; padding: 0; text-align: left; color: inherit; font: inherit; cursor: pointer; }
.lib-card:focus-visible, .lib-ep:focus-visible { outline: 2px solid var(--md-sys-color-primary); outline-offset: 2px; border-radius: 10px; }
.lib-card-art { position: relative; aspect-ratio: 2 / 3; border-radius: 10px; overflow: hidden; background: var(--md-sys-color-surface-container-high); box-shadow: var(--elev-1); transition: transform .15s ease, box-shadow .15s ease; }
.lib-card:hover .lib-card-art { transform: translateY(-3px); box-shadow: var(--elev-3); }
.lib-card-art img { width: 100%; height: 100%; object-fit: cover; display: block; }
.lib-card-title { margin-top: 8px; font-size: 14px; line-height: 19px; font-weight: 500; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; word-break: break-word; }
.lib-card-sub { font-size: 12px; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lib-noposter { width: 100%; height: 100%; min-height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; padding: 12px; text-align: center; font-size: 13px; color: var(--md-sys-color-on-surface-variant); box-sizing: border-box; }
.lib-noposter .material-symbols-rounded { font-size: 40px; }
.lib-book-cover { position: relative; width: 100%; height: 100%; min-height: 100%; display: flex; flex-direction: column; justify-content: center; gap: 9px; padding: 20px 13px 34px 17px; box-sizing: border-box; overflow: hidden; text-align: center; color: #fff; border: 1px solid rgba(255,255,255,.24); box-shadow: inset 7px 0 rgba(0,0,0,.24), inset 9px 0 rgba(255,255,255,.12), inset -2px 0 rgba(0,0,0,.16); }
.lib-book-cover-title { display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; font-family: Georgia, 'Times New Roman', serif; font-size: clamp(12px, 1.15vw, 17px); line-height: 1.3; font-weight: 700; text-shadow: 0 1px 2px rgba(0,0,0,.55); }
.lib-book-cover-author { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; font-size: 11px; line-height: 1.35; opacity: .92; text-shadow: 0 1px 2px rgba(0,0,0,.55); }
.lib-book-cover-format { position: absolute; right: 8px; bottom: 8px; margin-top: 0; padding: 3px 8px; border: 0; border-radius: 3px; background: #c62828; color: #fff; font-size: 9px; line-height: 1.2; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; box-shadow: 0 1px 4px rgba(0,0,0,.45); }

.lib-progress { position: absolute; left: 0; right: 0; bottom: 0; height: 4px; background: rgba(0,0,0,.45); }
.lib-progress span { display: block; height: 100%; background: #e50914; }
.lib-ep-still .lib-progress { height: 4px; }

/* Series page */
.lib-back { display: inline-flex; align-items: center; gap: 4px; color: var(--md-sys-color-on-surface-variant); text-decoration: none; margin: 4px 0 8px; font-size: 14px; }
.lib-series-head { display: flex; gap: 24px; margin-bottom: 20px; flex-wrap: wrap; }
.lib-series-art { flex: 0 0 200px; width: 200px; aspect-ratio: 2 / 3; border-radius: 12px; overflow: hidden; background: var(--md-sys-color-surface-container-high); box-shadow: var(--elev-2); }
.lib-series-art img { width: 100%; height: 100%; object-fit: cover; display: block; }
.lib-series-info { flex: 1 1 320px; min-width: 0; }
.lib-series-info .page-title { margin-top: 0; }
.lib-series-overview { font-size: 15px; line-height: 22px; max-width: 70ch; }
.lib-series-info .btn.filled { margin-top: 8px; }
.lib-season-tabs { margin-bottom: 12px; }
.lib-eps { display: flex; flex-direction: column; gap: 8px; max-width: 900px; }
.lib-ep { display: flex; gap: 14px; align-items: center; width: 100%; background: var(--md-sys-color-surface-container-low); border: 0; border-radius: 12px; padding: 8px; text-align: left; color: inherit; font: inherit; cursor: pointer; }
.lib-ep:hover { background: var(--md-sys-color-surface-container-high); }
.lib-ep-still { position: relative; flex: 0 0 168px; aspect-ratio: 16 / 9; border-radius: 8px; overflow: hidden; background: var(--md-sys-color-surface-container-highest); }
.lib-ep-still img { width: 100%; height: 100%; object-fit: cover; display: block; }
.lib-ep-still .lib-noposter { min-height: 0; }
.lib-ep-play { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(0,0,0,.25); color: #fff; opacity: 0; transition: opacity .15s; }
.lib-ep:hover .lib-ep-play, .lib-ep:focus-visible .lib-ep-play { opacity: 1; }
.lib-ep-info { min-width: 0; flex: 1; }
.lib-ep-title { font-size: 15px; font-weight: 500; margin-bottom: 4px; }
.lib-ep-over { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* Detalhe de filme (dialog) */
dialog.dlg.media-detail { width: min(680px, calc(100vw - 32px)); padding: 0; overflow: hidden; }
dialog.dlg.media-detail .dlg-inner { padding: 0; }
.md-hero { position: relative; height: 240px; background: var(--md-sys-color-surface-container-high); }
.md-hero img { width: 100%; height: 100%; object-fit: cover; display: block; }
.md-shade { position: absolute; inset: 0; background: linear-gradient(0deg, var(--md-sys-color-surface-container-lowest) 0%, rgba(0,0,0,0) 70%); }
.md-close { position: absolute; top: 8px; right: 8px; background: rgba(0,0,0,.45); color: #fff; }
.md-body { padding: 0 24px 20px; margin-top: -48px; position: relative; }
.md-title { margin: 0 0 4px; font-size: 24px; line-height: 30px; font-weight: 500; }
.md-meta { font-size: 13px; margin-bottom: 12px; }
.md-overview { font-size: 14px; line-height: 21px; margin: 0 0 16px; max-height: 40vh; overflow-y: auto; }
.md-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* Formulários e admin */
.lib-fix, .lib-create { display: flex; flex-direction: column; gap: 12px; min-width: min(420px, 80vw); }
.lib-folder-pick { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.lib-actions { white-space: nowrap; }
.lib-actions .btn { padding: 0 8px; }
.lib-kvs { display: flex; flex-direction: column; gap: 6px; min-width: min(360px, 80vw); font-size: 14px; }
.lib-kv { display: flex; justify-content: space-between; gap: 16px; }

@media (max-width: 600px) {
  .lib-page { padding-right: 0; padding-left: 16px; }
  .lib-hero { height: 320px; }
  .lib-hero-body { padding: 16px; max-width: 100%; }
  .lib-hero-title { font-size: 22px; line-height: 28px; }
  .lib-card { flex-basis: 128px; width: 128px; }
  .lib-series-art { flex-basis: 150px; width: 150px; }
  .lib-ep-still { flex-basis: 120px; }
  .lib-ep-play { opacity: 1; background: rgba(0,0,0,.2); }
}

/* "Ver todos": cabeçalho da fileira, grade paginada, filtro e paginação */
.lib-row-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.lib-row-more { display: inline-flex; align-items: center; gap: 2px; font-size: 14px; color: var(--md-sys-color-primary); text-decoration: none; white-space: nowrap; }
.lib-row-more:hover { text-decoration: underline; }
.lib-all-count { font-size: 18px; font-weight: 400; }
.lib-all-tools { display: flex; flex-wrap: wrap; gap: 12px; margin: 4px 0 20px; }
.lib-all-search { flex: 1 1 260px; max-width: 420px; }
.lib-all-sort { flex: 0 0 auto; }
.lib-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 20px 14px; }
.lib-grid .lib-card { width: auto; flex: none; }
.lib-pager { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 6px; margin: 28px 0 12px; }
.lib-page-btn { min-width: 40px; height: 40px; padding: 0 10px; display: inline-flex; align-items: center; justify-content: center; border-radius: 20px; border: 1px solid var(--md-sys-color-outline-variant); background: none; color: inherit; font: inherit; cursor: pointer; }
.lib-page-btn:hover:not(:disabled) { background: var(--md-sys-color-surface-container-high); }
.lib-page-btn:disabled { opacity: .4; cursor: default; }
.lib-page-btn.current { opacity: 1; background: var(--md-sys-color-primary); color: var(--md-sys-color-on-primary); border-color: transparent; }
.lib-page-gap { padding: 0 4px; }
@media (max-width: 600px) { .lib-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px 10px; } }
.lib-folder-list { display: flex; flex-direction: column; gap: 6px; margin: 8px 0 12px; }
.lib-folder-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 6px 10px; border-radius: 8px; background: var(--surface-2, rgba(127,127,127,.08)); }

/* Página da biblioteca: abas por tipo, ferramentas (busca, ordem, grade/lista), lista e paginação */
.lib-tabs { margin: 4px 0 16px; }
.lib-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 0 0 16px; }
.lib-search { flex: 1 1 240px; max-width: 420px; min-width: 0; }
.lib-sort { flex: 0 0 auto; width: auto; max-width: 100%; }
.lib-view { display: inline-flex; gap: 4px; margin-left: auto; }
.lib-view-btn { width: 40px; height: 40px; border-radius: 20px; border: 1px solid var(--md-sys-color-outline-variant); background: none; color: inherit; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; }
.lib-view-btn.on { background: var(--md-sys-color-secondary-container); color: var(--md-sys-color-on-secondary-container); border-color: transparent; }
.lib-results { min-height: 200px; }
.lib-list { display: flex; flex-direction: column; gap: 8px; }
.lib-li { display: flex; gap: 14px; align-items: center; width: 100%; background: var(--md-sys-color-surface-container-low); border: 0; border-radius: 12px; padding: 8px; text-align: left; color: inherit; font: inherit; cursor: pointer; }
.lib-li:hover { background: var(--md-sys-color-surface-container-high); }
.lib-li:focus-visible { outline: 2px solid var(--md-sys-color-primary); outline-offset: 2px; }
.lib-li-art { position: relative; flex: 0 0 56px; aspect-ratio: 2 / 3; border-radius: 6px; overflow: hidden; background: var(--md-sys-color-surface-container-high); }
.lib-li-art img { width: 100%; height: 100%; object-fit: cover; display: block; }
.lib-li-art .lib-noposter { font-size: 0; padding: 0; }
.lib-li-art .lib-noposter span { display: none; }
.lib-li-art .lib-noposter .material-symbols-rounded { font-size: 22px; }
.lib-li-art .lib-book-cover { gap: 3px; padding: 4px 3px 14px 5px; border-radius: 6px; box-shadow: inset 3px 0 rgba(0,0,0,.24), inset 4px 0 rgba(255,255,255,.12); }
.lib-li-art .lib-book-cover-title { -webkit-line-clamp: 4; font-size: 7px; line-height: 1.15; }
.lib-li-art .lib-book-cover-author { -webkit-line-clamp: 1; font-size: 6px; }
.lib-li-art .lib-book-cover-format { right: 2px; bottom: 2px; margin-top: 0; padding: 1px 3px; font-size: 5px; }
.lib-li-info { flex: 1 1 auto; min-width: 0; }
.lib-li-title { font-size: 15px; font-weight: 500; line-height: 20px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.lib-li-sub { font-size: 13px; margin-top: 2px; }
.lib-li-over { font-size: 13px; line-height: 18px; margin-top: 4px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.lib-pager { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 6px; margin: 12px 0 16px; }
.lib-pager .lib-pager-info { order: 1; font-size: 13px; text-align: center; }
.lib-pager .lib-pg-step:last-of-type { order: 2; }
.lib-page-btn { font-size: 14px; }
.lib-page-gap { line-height: 40px; }
.lib-season-tabs { margin-bottom: 12px; }
.lib-ep-num { margin-bottom: 2px; }
@media (min-width: 601px) {
  .lib-pager .lib-pager-info { order: 3; margin-left: 12px; }
}
@media (max-width: 600px) {
  .lib-hero { display: none; }
  .lib-tools { gap: 8px; }
  .lib-search { flex: 1 1 100%; max-width: none; }
  .lib-sort { flex: 1 1 auto; }
  .lib-view { margin-left: 0; }
  .lib-pg-num { display: none; }
  .lib-pager .lib-pg-step { min-width: 48px; }
  .lib-li-over { display: none; }
  .lib-li { padding: 6px; gap: 12px; }
  .lib-li-art { flex-basis: 48px; }
  .lib-tabs .tab { padding: 10px 12px; font-size: 14px; }
  .lib-season-tabs .tab { padding: 10px 12px; font-size: 14px; }
  .lib-ep { align-items: flex-start; }
  .lib-ep-title { font-size: 14px; line-height: 19px; }
  .lib-ep-over { -webkit-line-clamp: 3; }
  .lib-series-head { gap: 16px; }
  .lib-series-art { flex-basis: 120px; width: 120px; }
}
