:root {
  --bg:       #0d0d1a;
  --card:     #161627;
  --border:   #2a2a45;
  --accent:   #7c3aed;
  --accent2:  #c026d3;
  --text:     #e2e2f0;
  --muted:    #8888aa;
  --success:  #10b981;
  --error:    #ef4444;
  --radius:   12px;
  --bg2:      rgba(255,255,255,.04);
  --bg-input: rgba(255,255,255,.04);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  max-width: 100%;
  overflow-x: hidden;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
  min-height: 100vh;
  display: flex; flex-direction: column;
  align-items: stretch; justify-content: center;
  padding: .75rem;
}

/* Wrapper screens are flex items of body — must have explicit width so
   percentage widths inside (.card width:100%, flex-wrap containers, etc.)
   resolve against a definite size. Without this, flex-wrap never triggers
   and sort/filter bars expand to max-content, making the card overflow. */
#login-screen,
#upload-screen {
  width: 100%;
  min-width: 0;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem; width: 100%;
  box-shadow: 0 24px 64px rgba(0,0,0,.6);
  min-width: 0; overflow-x: hidden;
}

/* Všechny sekce — zabránit přetékání dynamického obsahu */
[id^="section-"] { min-width: 0; overflow-x: hidden; }

/* Detail body containment */
#lib-detail-body { overflow-x: hidden; min-width: 0; max-width: 100%; }

.header {
  display: flex; align-items: center;
  gap: .85rem; margin-bottom: 1.5rem;
}

.header-icon {
  width: 44px; height: 44px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  border-radius: 11px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.5rem; flex-shrink: 0;
}

h1 { font-size: 1.35rem; font-weight: 700; letter-spacing: -.02em; }
h1 small { display: block; font-size: .8rem; font-weight: 400; color: var(--muted); margin-top: 2px; }

/* ── Sysinfo panel ──────────────────────────────────────────────────────────── */
.sysinfo {
  margin-left: auto;
  display: flex; flex-direction: column; gap: 4px;
  align-items: flex-end;
  flex-shrink: 1; min-width: 0;
}
.sysinfo-disks {
  display: flex; gap: 5px; flex-wrap: wrap; justify-content: flex-end;
}
.sysinfo-row2 {
  display: flex; gap: 5px; align-items: center; flex-wrap: wrap; justify-content: flex-end;
}
.si-chip {
  font-size: .68rem; font-weight: 600;
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.09);
  border-radius: 6px;
  padding: 2px 7px;
  color: var(--muted);
  white-space: nowrap;
}
.si-disk {
  font-size: .68rem; font-weight: 600;
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.09);
  border-radius: 6px;
  padding: 2px 7px;
  color: var(--muted);
  white-space: nowrap;
}
.si-disk.si-warn {
  color: #fca5a5;
  border-color: rgba(239,68,68,.4);
  background: rgba(239,68,68,.1);
}
.si-disk.si-err {
  color: var(--muted); opacity: .5;
}
.si-zenbook {
  font-size: .68rem; font-weight: 600;
  padding: 2px 7px 2px 5px;
  border-radius: 6px;
  border: 1px solid rgba(255,255,255,.09);
  background: rgba(255,255,255,.06);
  color: var(--muted);
  white-space: nowrap;
  display: flex; align-items: center; gap: 4px;
}
.si-zenbook::before {
  content: '';
  display: inline-block;
  width: 7px; height: 7px;
  border-radius: 50%;
  background: #6b7280;
  flex-shrink: 0;
}
.si-zenbook.online::before { background: #22c55e; }
.si-zenbook.online { color: #86efac; border-color: rgba(34,197,94,.3); background: rgba(34,197,94,.07); }
.si-cleanup-btn {
  font-size: .8rem; padding: 2px 5px; line-height: 1;
  background: none; border: 1px solid rgba(255,255,255,.12);
  border-radius: 5px; color: inherit; cursor: pointer;
  opacity: .6; transition: opacity .15s;
}
.si-cleanup-btn:hover:not(:disabled) { opacity: 1; }
.si-cleanup-btn:disabled { cursor: default; }
.si-tc {
  font-size: .72rem;
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid rgba(99,179,237,.4);
  background: rgba(99,179,237,.08);
  color: #93c5fd;
  width: 300px; max-width: 100%;
  display: flex; flex-direction: column; gap: 5px;
}
.si-tc-top {
  display: flex; align-items: baseline; gap: 6px;
}
.si-tc-phase {
  font-weight: 700; white-space: nowrap; flex-shrink: 0;
  opacity: .9;
}
.si-tc-name {
  flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-weight: 600;
}
.si-tc-pct {
  font-weight: 700; white-space: nowrap; flex-shrink: 0;
  color: #bfdbfe;
}
.si-tc-bar-wrap {
  height: 4px; background: rgba(99,179,237,.2); border-radius: 2px; overflow: hidden;
}
.si-tc-bar {
  height: 100%; background: #60a5fa; border-radius: 2px; transition: width .8s linear;
}
.si-tc-stats {
  display: flex; gap: 8px; flex-wrap: wrap; opacity: .8; font-size: .68rem;
}
@media (max-width: 560px) {
  .header-icon { display: none; }
  h1 { display: none; }
  .header { margin-bottom: .75rem; }
  .sysinfo { margin-left: 0; align-items: flex-start; width: 100%; }
  .sysinfo-disks { justify-content: flex-start; }
  .sysinfo-row2 { justify-content: flex-start; }
}

label {
  display: block; font-size: .75rem; font-weight: 600;
  color: var(--muted); text-transform: uppercase;
  letter-spacing: .06em; margin-bottom: .5rem;
}

select, input[type=password], input[type=text] {
  width: 100%;
  background: rgba(255,255,255,.04);
  border: 1px solid var(--border); border-radius: 8px;
  color: var(--text); padding: .75rem 1rem; font-size: 1rem;
  outline: none; transition: border-color .2s, box-shadow .2s;
  -webkit-appearance: none; appearance: none;
}
select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238888aa' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right .9rem center;
  padding-right: 2.5rem; cursor: pointer;
}
select option { background: #1e1e35; }
select:focus, input[type=password]:focus, input[type=text]:focus {
  border-color: var(--accent); box-shadow: 0 0 0 3px rgba(124,58,237,.15);
}

.form-group { margin-bottom: 1.5rem; }

/* ── Tab bar ─────────────────────────────────────────────────────────── */
.tab-bar {
  display: flex; gap: .35rem; margin-bottom: 1.75rem;
  background: rgba(255,255,255,.04);
  border: 1px solid var(--border); border-radius: 8px; padding: .25rem;
}
.tab-btn {
  flex: 1; padding: .5rem; border: none; border-radius: 6px;
  background: transparent; color: var(--muted);
  font-size: .88rem; font-weight: 500; cursor: pointer;
  transition: background .15s, color .15s;
}
.tab-btn.active {
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #fff;
}

/* Mode toggle */
.mode-toggle {
  display: flex; gap: .5rem; margin-bottom: 1.25rem;
  background: rgba(255,255,255,.04);
  border: 1px solid var(--border); border-radius: 8px; padding: .3rem;
}
.mode-btn {
  flex: 1; padding: .5rem; border: none; border-radius: 6px;
  background: transparent; color: var(--muted);
  font-size: .88rem; font-weight: 500; cursor: pointer;
  transition: background .15s, color .15s;
}
.mode-btn.active { background: linear-gradient(135deg, var(--accent), var(--accent2)); color: #fff; }

/* Drop zone */
.drop-zone {
  border: 2px dashed var(--border); border-radius: var(--radius);
  padding: 2.2rem 1rem; text-align: center; cursor: pointer;
  transition: border-color .2s, background .2s;
  margin-bottom: .75rem; position: relative; user-select: none;
}
.drop-zone:hover, .drop-zone.drag-over {
  border-color: var(--accent); background: rgba(124,58,237,.06);
}
.drop-zone input[type=file] {
  position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%;
}
.drop-icon { font-size: 2rem; margin-bottom: .5rem; }
.drop-text { font-size: .95rem; font-weight: 500; margin-bottom: .3rem; }
.drop-hint { font-size: .82rem; color: var(--muted); }

/* Folder toolbar */
.folder-toolbar {
  display: none; gap: .5rem; margin-bottom: .75rem;
}
.folder-toolbar.show { display: flex; }

.btn-sm {
  padding: .45rem .9rem; border: 1px solid var(--border);
  border-radius: 7px; background: rgba(255,255,255,.04);
  color: var(--text); font-size: .82rem; font-weight: 500;
  cursor: pointer; transition: border-color .15s, background .15s;
  white-space: nowrap;
}
.btn-sm:hover:not(:disabled) { border-color: var(--accent); background: rgba(124,58,237,.08); }
.btn-sm.danger:hover { border-color: var(--error); background: rgba(239,68,68,.08); color: #fca5a5; }
.btn-sm:disabled { opacity: .35; cursor: not-allowed; }

.queue-summary {
  display: none; font-size: .8rem; color: var(--muted);
  padding: .3rem .5rem; margin-bottom: .5rem;
}
.queue-summary.show { display: block; }

/* File queue */
.file-queue {
  display: none; flex-direction: column; gap: .35rem;
  margin-bottom: 1rem; max-height: 280px; overflow-y: auto;
}
.file-queue.show { display: flex; }
.file-queue::-webkit-scrollbar { width: 4px; }
.file-queue::-webkit-scrollbar-track { background: transparent; }
.file-queue::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* Folder group label */
.folder-group-label {
  font-size: .73rem; color: var(--muted); font-weight: 600;
  text-transform: uppercase; letter-spacing: .05em;
  padding: .15rem .5rem; margin-top: .25rem;
}
.folder-group-label:first-child { margin-top: 0; }

.file-row {
  display: flex; align-items: center; gap: .55rem;
  padding: .45rem .7rem; border-radius: 7px;
  background: rgba(255,255,255,.03); border: 1px solid var(--border);
  font-size: .82rem; min-width: 0;
}
.file-row.uploading { border-color: rgba(124,58,237,.4); background: rgba(124,58,237,.07); }
.file-row.done      { border-color: rgba(16,185,129,.35); background: rgba(16,185,129,.06); }
.file-row.error     { border-color: rgba(239,68,68,.35);  background: rgba(239,68,68,.06); }

.file-row-icon { flex-shrink: 0; font-size: .9rem; width: 1.1rem; text-align: center; }
.file-row-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-row-sub  { font-size: .74rem; color: var(--muted); white-space: nowrap; flex-shrink: 0; }
.file-row-mini-bar { width: 50px; height: 4px; background: rgba(255,255,255,.07); border-radius: 2px; flex-shrink: 0; overflow: hidden; }
.file-row-mini-fill { height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent2)); width: 0%; transition: width .3s; }

/* Single file */
.file-info {
  background: rgba(124,58,237,.1); border: 1px solid rgba(124,58,237,.3);
  border-radius: 8px; padding: .7rem 1rem;
  display: none; align-items: center; gap: .75rem; margin-bottom: 1rem;
}
.file-info.show { display: flex; }
.file-name { flex: 1; font-weight: 500; font-size: .9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-size { color: var(--muted); font-size: .82rem; flex-shrink: 0; }

/* Main button */
.btn {
  width: 100%; padding: .85rem;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  border: none; border-radius: 8px; color: #fff;
  font-size: 1rem; font-weight: 600; cursor: pointer;
  transition: opacity .2s, transform .1s; letter-spacing: -.01em;
}
.btn:hover:not(:disabled) { opacity: .9; }
.btn:active:not(:disabled) { transform: scale(.98); }
.btn:disabled { opacity: .35; cursor: not-allowed; }

/* Progress */
.progress-section { margin-top: 1.25rem; display: none; }
.progress-section.show { display: block; }
.progress-header { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: .5rem; }
.progress-label { font-size: .85rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; margin-right: .5rem; }
.progress-pct   { font-size: 1.1rem; font-weight: 700; flex-shrink: 0; }
.progress-bar-wrap { background: rgba(255,255,255,.07); border-radius: 999px; height: 8px; overflow: hidden; margin-bottom: .6rem; }
.progress-bar { height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent2)); border-radius: 999px; width: 0%; transition: width .4s ease; }
.progress-stats { display: flex; justify-content: space-between; font-size: .8rem; color: var(--muted); }

/* Status */
.status { display: none; border-radius: 8px; padding: .9rem 1rem; margin-top: 1.25rem; font-size: .88rem; line-height: 1.6; }
.status.show    { display: block; }
.status.success { background: rgba(16,185,129,.1); border: 1px solid rgba(16,185,129,.3); color: #6ee7b7; }
.status.error   { background: rgba(239,68,68,.1);  border: 1px solid rgba(239,68,68,.3);  color: #fca5a5; }
.status.info    { background: rgba(124,58,237,.1); border: 1px solid rgba(124,58,237,.25); color: var(--muted); }

/* ── TMM queue ───────────────────────────────────────────────────────── */
.tmm-queue {
  display: none; flex-direction: column; gap: .4rem;
  width: 100%; margin-bottom: .75rem; max-height: 320px; overflow-y: auto; overflow-x: hidden;
}
.tmm-queue.show { display: flex; }
.tmm-queue::-webkit-scrollbar { width: 4px; }
.tmm-queue::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.tmm-item {
  display: flex; align-items: center; gap: .65rem; flex-wrap: wrap;
  padding: .55rem .75rem; border-radius: 8px;
  background: rgba(255,255,255,.03); border: 1px solid var(--border);
  cursor: pointer; transition: border-color .15s; min-width: 0;
  position: relative;
}
.tmm-item:hover  { border-color: rgba(124,58,237,.5); }
.tmm-item.active { border-color: var(--accent); background: rgba(124,58,237,.07); }
.tmm-del-btn {
  position: absolute; top: 4px; right: 5px;
  background: none; border: none; cursor: pointer;
  color: var(--muted); font-size: .7rem; padding: 1px 4px;
  border-radius: 4px; opacity: 0; transition: opacity .12s, color .12s, background .12s;
  line-height: 1.4;
}
.tmm-item:hover .tmm-del-btn { opacity: 1; }
.tmm-del-btn:hover { color: #fca5a5; background: rgba(239,68,68,.18); }

.tmm-poster {
  width: 62px; height: 92px; border-radius: 5px; overflow: hidden;
  background: rgba(255,255,255,.06); flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem; color: var(--muted);
}
.tmm-poster img { width: 100%; height: 100%; object-fit: cover; }

.tmm-meta { flex: 1; min-width: 0; }
.tmm-fn   { font-size: .76rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-bottom: .15rem; }
.tmm-ttl  { font-size: .95rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tmm-ot   { font-size: .78rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.tmm-badge { flex-shrink: 0; padding: .2rem .5rem; border-radius: 5px; font-size: .7rem; font-weight: 700; letter-spacing: .03em; }
.b-uploading   { background: rgba(255,255,255,.07); color: var(--muted); }
.b-downloading { background: rgba(14,165,233,.18); color: #7dd3fc; }
.b-analyzing   { background: rgba(124,58,237,.18); color: #c4b5fd; }
.b-ready     { background: rgba(16,185,129,.15); color: #6ee7b7; }
.b-review    { background: rgba(245,158,11,.15); color: #fcd34d; }
.b-confirmed  { background: rgba(124,58,237,.25); color: #e9d5ff; }
.b-processing { background: rgba(124,58,237,.18); color: #c4b5fd; }
.b-processed  { background: rgba(16,185,129,.20); color: #6ee7b7; }
.b-moving     { background: rgba(245,158,11,.15); color: #fcd34d; }
.b-moved      { background: rgba(16,185,129,.30); color: #a7f3d0; }
.b-error      { background: rgba(239,68,68,.15); color: #fca5a5; }

/* ── TMM transcoding row ─────────────────────────────────────────────── */
.tmm-tc-row {
  flex-basis: 100%; width: 100%;
  padding: .25rem .25rem .25rem 70px; min-width: 0;
  box-sizing: border-box;
}
.tmm-tc-btns { display: flex; gap: .4rem; flex-wrap: wrap; }
.tmm-tc-btn {
  font-size: .72rem; padding: .2rem .5rem;
  border: 1px solid var(--border); background: var(--bg2);
  border-radius: 5px; cursor: pointer; color: var(--text);
}
.tmm-tc-btn:hover { background: rgba(255,255,255,.08); }
.tmm-tc-btn-go { background: rgba(124,58,237,.2); border-color: var(--accent); }
.tmm-tc-btn-cancel { color: #fca5a5; }
.tmm-tc-form, .tmm-tc-progress, .tmm-tc-state {
  display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; font-size: .75rem;
}
.tmm-tc-inp {
  width: 70px; padding: .2rem .35rem;
  background: var(--bg-input); border: 1px solid var(--border);
  border-radius: 4px; color: var(--text); font-size: .75rem;
}
.tmm-tc-lbl { color: var(--muted); font-size: .73rem; }
.tmm-tc-bar {
  flex: 1; min-width: 60px; height: 5px;
  background: var(--border); border-radius: 3px; overflow: hidden;
}
.tmm-tc-bar > div { height: 100%; background: var(--accent); transition: width .5s; border-radius: 3px; }
.tmm-tc-pct { font-size: .7rem; color: var(--muted); min-width: 28px; }
.tmm-tc-done { font-size: .72rem; color: var(--success); font-weight: 600; }
.tmm-tc-err  { font-size: .72rem; color: var(--error); }

/* ── TMM review panel ────────────────────────────────────────────────── */
.tmm-review {
  background: rgba(255,255,255,.02);
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1rem; margin-bottom: .75rem;
  width: 100%; min-width: 0; overflow-x: hidden; box-sizing: border-box;
}
.tmm-rev-hdr { font-size: .7rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; margin-bottom: .4rem; }
.tmm-rev-fn  { font-size: .85rem; font-weight: 500; margin-bottom: .8rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.tmm-cands { display: flex; flex-direction: column; gap: .35rem; margin-bottom: .75rem; }
.tmm-cand {
  display: flex; align-items: center; gap: .6rem;
  padding: .5rem .65rem; border-radius: 7px;
  border: 1px solid var(--border); background: rgba(255,255,255,.02);
  cursor: pointer; transition: border-color .15s, background .15s;
}
.tmm-cand:hover { border-color: rgba(124,58,237,.5); background: rgba(124,58,237,.06); }
.tmm-cand.sel   { border-color: var(--success); background: rgba(16,185,129,.07); }

.tmm-cand-art {
  width: 54px; height: 80px; border-radius: 4px; overflow: hidden;
  background: rgba(255,255,255,.05); flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-size: .85rem;
}
.tmm-cand-art img { width: 100%; height: 100%; object-fit: cover; }
.tmm-cand { align-items: flex-start; }
.tmm-cand-info { flex: 1; min-width: 0; }
.tmm-cand-t  { font-size: .86rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tmm-cand-ot { font-size: .74rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-bottom: .15rem; }
.tmm-cand-genres { display: flex; flex-wrap: wrap; gap: .2rem; margin-top: .25rem; margin-bottom: .2rem; }
.tmm-cand-genre  { font-size: .66rem; font-weight: 600; padding: .1rem .35rem; border-radius: 3px;
                   background: rgba(124,58,237,.18); color: #c4b5fd; letter-spacing: .02em; }
.tmm-cand-ov { font-size: .73rem; color: var(--muted); line-height: 1.4;
               display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.tmm-cand-pct { flex-shrink: 0; font-size: .78rem; font-weight: 700; min-width: 2.5rem; text-align: right; padding-top: .1rem; }

/* ── TMM detail hero ─────────────────────────────────────────────────── */
.tmm-hero { position: relative; border-radius: 8px; overflow: hidden; margin-bottom: .75rem; min-height: 80px; }
.tmm-hero-bd { width: 100%; height: clamp(200px, 28vw, 340px); object-fit: cover; display: block; filter: brightness(.5); }
.tmm-hero-overlay { position: absolute; inset: 0; padding: 1rem 1.2rem; display: flex; flex-direction: column; justify-content: flex-end; }
.tmm-hero-logo { max-height: 72px; max-width: 300px; object-fit: contain; margin-bottom: .6rem; filter: drop-shadow(0 2px 8px rgba(0,0,0,.8)); }
.tmm-hero-title { font-size: 1.2rem; font-weight: 700; line-height: 1.2; text-shadow: 0 1px 4px rgba(0,0,0,.9); overflow-wrap: break-word; }
.tmm-hero-sub   { font-size: .82rem; color: rgba(255,255,255,.7); margin-top: .25rem; overflow-wrap: break-word; }
.tmm-detail { background: rgba(255,255,255,.02); border: 1px solid var(--border); border-radius: 8px;
              padding: .75rem .9rem; margin-bottom: .75rem;
              overflow-x: hidden; overflow-y: visible; max-width: 100%; width: 100%; box-sizing: border-box; }
.tmm-detail-row  { display: flex; flex-wrap: wrap; gap: .3rem .9rem; margin-bottom: .55rem; }
.tmm-detail-item { font-size: .78rem; color: var(--muted); overflow-wrap: break-word; min-width: 0; }
.tmm-detail-item strong { color: var(--text); font-weight: 600; }
.tmm-detail-genres { display: flex; flex-wrap: wrap; gap: .25rem; margin-bottom: .55rem; }
.tmm-detail-genre  { font-size: .72rem; font-weight: 600; padding: .15rem .45rem; border-radius: 4px;
                     background: rgba(124,58,237,.2); color: #c4b5fd; }
.tmm-detail-ov { font-size: .81rem; line-height: 1.55; color: rgba(255,255,255,.75); margin-bottom: .5rem; overflow-wrap: break-word; }
.tmm-detail-rating { display: inline-flex; align-items: center; gap: .3rem; font-size: .78rem;
                     background: rgba(255,255,255,.06); border-radius: 5px; padding: .2rem .5rem; }
.tmm-detail-tagline { font-size: .82rem; font-style: italic; color: rgba(255,255,255,.65);
                      border-left: 2px solid rgba(124,58,237,.6); padding-left: .6rem;
                      margin-bottom: .5rem; line-height: 1.4; overflow-wrap: break-word; }
.tmm-detail-kws { display: flex; flex-wrap: wrap; gap: .2rem; margin-top: .4rem; }
.tmm-detail-kw  { font-size: .65rem; padding: .1rem .3rem; border-radius: 3px;
                  background: rgba(255,255,255,.06); color: var(--muted); }

/* ── Cast ────────────────────────────────────────────────────────────── */
.tmm-cast-strip { display: flex; gap: .5rem; overflow-x: auto; min-width: 0;
                  -webkit-overflow-scrolling: touch; padding-bottom: .35rem; }
.tmm-cast-strip::-webkit-scrollbar { height: 3px; }
.tmm-cast-strip::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
.tmm-cast-item  { flex-shrink: 0; width: 68px; }
.tmm-cast-photo { width: 68px; height: 102px; border-radius: 5px; overflow: hidden;
                  background: rgba(255,255,255,.06); display: flex; align-items: center;
                  justify-content: center; margin-bottom: .3rem; }
.tmm-cast-photo img { width: 100%; height: 100%; object-fit: cover; }
.tmm-cast-ph-icon { font-size: 1.8rem; color: var(--muted); }
.tmm-cast-name { font-size: .69rem; font-weight: 600; line-height: 1.25;
                 overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tmm-cast-char { font-size: .63rem; color: var(--muted); line-height: 1.25;
                 overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── Image picker ────────────────────────────────────────────────────── */
.tmm-img-section { margin-top: .65rem; min-width: 0; }
.tmm-img-section + .tmm-img-section { margin-top: .6rem; }
.tmm-img-ph  { font-size: .67rem; font-weight: 700; color: var(--muted);
               text-transform: uppercase; letter-spacing: .06em; margin-bottom: .35rem; }
.tmm-img-strip { display: flex; gap: .45rem; overflow-x: auto; min-width: 0;
                 -webkit-overflow-scrolling: touch;
                 padding-bottom: .35rem; padding-top: .05rem; }
.tmm-img-strip::-webkit-scrollbar { height: 3px; }
.tmm-img-strip::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.tmm-img-thumb { position: relative; border-radius: 5px; overflow: hidden;
                 cursor: pointer; flex-shrink: 0;
                 border: 2px solid rgba(255,255,255,.1); transition: border-color .12s; }
.tmm-img-thumb:hover { border-color: rgba(124,58,237,.6); }
.tmm-img-thumb.sel  { border-color: #22c55e; border-width: 4px; box-shadow: 0 0 0 4px #22c55e80; }
.tmm-img-thumb img  { display: block; width: 100%; height: 100%; object-fit: cover; }

/* Type-specific sizes — poster 2:3, backdrop 16:9, logo wide */
.tmm-thumb-poster   { width: 110px; height: 165px; }
.tmm-thumb-backdrop { width: 200px; height: 113px; }
.tmm-thumb-logo     { width: 200px; height: 70px; background: rgba(0,0,0,.25); }
.tmm-thumb-logo img { object-fit: contain; }

.tmm-img-lang  { position: absolute; bottom: 3px; left: 3px; font-size: .56rem; font-weight: 800;
                 background: rgba(0,0,0,.82); color: #fff; padding: 1px 4px; border-radius: 2px;
                 letter-spacing: .04em; pointer-events: none; }
.tmm-img-score { position: absolute; bottom: 3px; right: 3px; font-size: .56rem;
                 background: rgba(0,0,0,.82); color: #fcd34d; padding: 1px 4px; border-radius: 2px;
                 pointer-events: none; }

.tmm-search { display: flex; gap: .5rem; min-width: 0; }
.tmm-search input { flex: 1; min-width: 0; padding: .6rem .9rem; font-size: .88rem; }
.tmm-empty { text-align: center; color: var(--muted); font-size: .84rem; padding: .75rem; }

.tmm-act { display: flex; align-items: center; gap: .6rem; margin-top: .5rem; flex-wrap: wrap; width: 100%; overflow-x: hidden; }
.tmm-date-row  { width:100%; display:flex; align-items:center; gap:.5rem; margin-top:.2rem; flex-wrap:wrap; }
.tmm-date-lbl  { font-size:.77rem; color:var(--muted); white-space:nowrap; }
.tmm-date-input { flex:1; min-width:90px; padding:.35rem .7rem; font-size:.83rem;
                  background:rgba(255,255,255,.04); border:1px solid var(--border);
                  border-radius:7px; color:var(--text); outline:none; }
.tmm-date-hint { font-size:.72rem; color:var(--muted); white-space:nowrap; }

/* ── Download tab ────────────────────────────────────────────────────── */
.dl-url-wrap { display: flex; gap: .5rem; margin-bottom: 1.25rem; }
.dl-url-wrap input { flex: 1; font-size: .92rem; }
.dl-queue { display: flex; flex-direction: column; gap: .4rem; margin-top: .5rem; }
.dl-item {
  display: flex; align-items: center; gap: .65rem;
  padding: .65rem .85rem; border-radius: 8px;
  background: rgba(14,165,233,.06); border: 1px solid rgba(14,165,233,.22);
  min-width: 0;
}
.dl-item.error { background: rgba(239,68,68,.06); border-color: rgba(239,68,68,.25); }
.dl-item-meta { flex: 1; min-width: 0; }
.dl-item-name { font-size: .88rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dl-item-bar-wrap { height: 4px; background: rgba(255,255,255,.07); border-radius: 2px; margin-top: .3rem; overflow: hidden; }
.dl-item-bar { height: 100%; background: linear-gradient(90deg,#0ea5e9,#38bdf8); border-radius: 2px; transition: width .5s; }
.dl-item-sub { font-size: .74rem; color: var(--muted); margin-top: .2rem; }
.dl-done-hint { font-size: .82rem; color: var(--muted); text-align: center; padding: .75rem 0; display: none; }
.dl-done-hint.show { display: block; }

/* ── Library tab ─────────────────────────────────────────────────────── */
.lib-filter-bar { display: none; gap: .28rem; margin-bottom: .6rem; flex-wrap: wrap; }
.lib-filter-bar.show { display: flex; }
.lib-fpill {
  padding: .3rem .65rem; border: 1px solid var(--border); border-radius: 99px;
  background: transparent; color: var(--muted); font-size: .75rem; font-weight: 500;
  cursor: pointer; transition: border-color .15s, color .15s, background .15s; white-space: nowrap;
}
.lib-fpill.active { background: rgba(124,58,237,.15); border-color: var(--accent); color: #c4b5fd; }

.lib-search-wrap { display: none; margin-bottom: .4rem; }
.lib-search-wrap.show { display: block; }
.lib-search-input { width: 100%; box-sizing: border-box; padding: .38rem .65rem;
  background: var(--bg2); border: 1px solid var(--border); border-radius: 6px;
  color: var(--text); font-size: .82rem; }
.lib-search-input:focus { border-color: var(--accent); outline: none; }
.lib-count { font-size: .76rem; color: var(--muted); margin-bottom: .45rem; display: none; }
.lib-count.show { display: block; }

/* ── Two-column Library layout ─────────────────────────────────────────── */
#lib-columns { display: block; }
#lib-left-col { min-width: 0; }

@media (min-width: 900px) {
  #lib-columns.has-detail {
    display: flex;
    flex-direction: row;
    gap: 1.2rem;
    align-items: start;
  }
  #lib-columns.has-detail #lib-left-col {
    flex: 0 0 360px;
    min-width: 0;
  }
  #lib-columns.has-detail .lib-detail {
    flex: 1;
    min-width: 0;
    margin-bottom: 0;
    max-height: calc(100vh - 140px);
    overflow-y: auto;
  }
  #lib-columns.has-detail .lib-list {
    max-height: calc(100vh - 240px);
  }
}

.lib-list {
  display: none; flex-direction: column; gap: .3rem;
  width: 100%; max-height: 480px; overflow-y: auto; overflow-x: hidden; margin-bottom: .5rem;
}
.lib-list.show { display: flex; }
.lib-list::-webkit-scrollbar { width: 4px; }
.lib-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* ── Library item (same feel as .tmm-item) ─────────────────────────── */
.lib-item {
  display: flex; align-items: center; gap: .65rem;
  padding: .55rem .75rem; border-radius: 8px;
  background: rgba(255,255,255,.03); border: 1px solid var(--border);
  cursor: pointer; transition: border-color .15s; min-width: 0;
}
.lib-item:hover   { border-color: rgba(124,58,237,.5); }
.lib-item.active  { border-color: var(--accent); background: rgba(124,58,237,.07); }
.lib-item.incomplete { border-color: rgba(239,68,68,.22); }
.lib-item.incomplete:hover { border-color: rgba(239,68,68,.55); }

.lib-meta  { flex: 1; min-width: 0; }
.lib-title { font-size: .87rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lib-year  { color: var(--muted); font-weight: 400; font-size: .82rem; }
.lib-info  { font-size: .72rem; color: var(--muted); margin-top: .1rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* ── Collection widget ──────────────────────────────────────────────── */
.lib-coll-section { margin-bottom: .35rem; }
.lib-coll-view    { display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; }
.lib-coll-lbl     { font-size: .8rem; color: var(--fg); white-space: nowrap; }
.lib-coll-pill    { font-size: .78rem; background: rgba(99,102,241,.15); color: #a5b4fc;
                    padding: .1rem .45rem; border-radius: 20px; }
.lib-coll-none    { font-size: .78rem; color: var(--muted); }
.lib-coll-edit-btn{ background: none; border: none; cursor: pointer; font-size: .78rem;
                    opacity: .45; padding: 0 .1rem; transition: opacity .12s; }
.lib-coll-edit-btn:hover { opacity: 1; }
.lib-coll-edit    { display: flex; align-items: center; gap: .35rem; flex-wrap: wrap; margin-top: .25rem; }
.lib-coll-inp     { flex: 1; min-width: 140px; background: var(--surface2); border: 1px solid var(--border);
                    color: var(--fg); border-radius: 5px; padding: .25rem .5rem; font-size: .78rem; }
.lib-coll-inp:focus  { outline: none; border-color: var(--accent); }
.lib-coll-save-btn   { background: rgba(16,185,129,.15); border-color: rgba(16,185,129,.4); color: #6ee7b7; }
.lib-coll-clear-btn  { background: rgba(239,68,68,.12); border-color: rgba(239,68,68,.35); color: #fca5a5; }

.lib-badges { display: flex; gap: .18rem; margin-top: .22rem; flex-wrap: wrap; }
.lib-badge { font-size: .62rem; font-weight: 700; padding: .08rem .25rem; border-radius: 3px; letter-spacing: .03em; }
.lib-badge.ok   { background: rgba(16,185,129,.15); color: #6ee7b7; }
.lib-badge.miss { background: rgba(239,68,68,.14);  color: #fca5a5; }

.lib-icons { display: flex; flex-direction: column; gap: .25rem; flex-shrink: 0; align-items: center; }
.lib-icon-btn {
  background: none; border: none; cursor: pointer; font-size: .95rem;
  padding: .05rem; line-height: 1; opacity: .3; transition: opacity .15s, transform .1s;
}
.lib-icon-btn:hover { opacity: .85; }
.lib-icon-btn.on    { opacity: 1; }
.lib-icon-btn:active { transform: scale(1.3); }

/* ── Library detail panel ───────────────────────────────────────────── */
.lib-detail {
  background: rgba(255,255,255,.02); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1rem; margin-bottom: .6rem;
  width: 100%; min-width: 0; overflow-x: hidden; box-sizing: border-box;
}
.lib-detail-hdr {
  display: flex; justify-content: space-between; align-items: center;
  font-size: .7rem; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: .06em; margin-bottom: 0;
}
/* Section tabs in detail panel */
.lib-detail-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  margin: .45rem -1rem 0;
  padding: 0 .75rem;
  overflow-x: auto;
  scrollbar-width: none;
}
.lib-detail-tabs::-webkit-scrollbar { display: none; }
.lib-dtab {
  padding: .52rem .9rem;
  font-size: .8rem;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
  transition: color .15s, border-color .15s;
  flex-shrink: 0;
}
.lib-dtab:hover { color: var(--text); }
.lib-dtab.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
/* Tab content padding */
#lib-tab-detail, #lib-tab-remux, #lib-tab-tc { padding-top: .75rem; }
.lib-detail-close {
  background: none; border: none; color: var(--muted);
  cursor: pointer; font-size: .85rem; padding: 0 .1rem; line-height: 1;
}
.lib-detail-close:hover { color: var(--text); }
.lib-us-section { margin-top: .7rem; border-top: 1px solid var(--border); padding-top: .7rem; }
.lib-us-row { display: flex; align-items: center; gap: .75rem; margin-bottom: .45rem; }
.lib-us-label { font-size: .78rem; color: var(--muted); flex: 1; }
.lib-toggle {
  display: flex; align-items: center; gap: .35rem;
  background: rgba(255,255,255,.04); border: 1px solid var(--border);
  border-radius: 6px; padding: .28rem .6rem; cursor: pointer;
  font-size: .78rem; color: var(--muted); transition: border-color .15s, color .15s, background .15s;
  flex-shrink: 0; user-select: none;
}
.lib-toggle.on { border-color: var(--success); color: #6ee7b7; background: rgba(16,185,129,.08); }
input[type=date].lib-date {
  background: rgba(255,255,255,.04); border: 1px solid var(--border); border-radius: 6px;
  color: var(--text); padding: .28rem .6rem; font-size: .78rem; outline: none;
  flex-shrink: 0; color-scheme: dark;
}
input[type=date].lib-date:focus { border-color: var(--accent); }
.lib-del-zone { display: flex; justify-content: flex-end; margin-top: .7rem; padding-top: .65rem; border-top: 1px solid var(--border); }

/* ── Library sort bar ───────────────────────────────────────────────────── */
.lib-sort-bar { display: none; gap: .22rem; margin-bottom: .45rem; flex-wrap: wrap; align-items: center; }
.lib-sort-bar.show { display: flex; }
.lib-sort-btn {
  padding: .24rem .55rem; border: 1px solid var(--border); border-radius: 99px;
  background: transparent; color: var(--muted); font-size: .7rem; font-weight: 500;
  cursor: pointer; transition: border-color .15s, color .15s, background .15s; white-space: nowrap;
}
.lib-sort-btn.active { background: rgba(124,58,237,.12); border-color: rgba(124,58,237,.45); color: #c4b5fd; }
.lib-sort-btn:hover:not(.active) { border-color: rgba(124,58,237,.3); color: var(--text); }

/* ── Library edit panel ─────────────────────────────────────────────────── */
.lib-edit-panel {
  display: none; margin-top: .6rem; padding-top: .6rem;
  border-top: 1px solid var(--border);
}

#login-screen  { display: block; }
#upload-screen { display: none; }

/* ── Transcoder ──────────────────────────────────────────────────────────── */
.tc-agent-bar {
  display: flex; align-items: center; gap: .5rem;
  padding: .45rem .75rem; background: rgba(255,255,255,.03);
  border: 1px solid var(--border); border-radius: 8px;
  margin-bottom: .75rem; font-size: .8rem;
}
.tc-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.tc-dot.online  { background: var(--success); box-shadow: 0 0 5px var(--success); }
.tc-dot.offline { background: var(--muted); }
.tc-form { display: flex; flex-direction: column; gap: .5rem; }
.tc-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; }
.tc-jobs { display: flex; flex-direction: column; gap: .5rem; margin-top: .75rem; }
.tc-job {
  background: rgba(255,255,255,.03); border: 1px solid var(--border);
  border-radius: 8px; padding: .7rem .75rem; position: relative;
}
.tc-job-hdr { display: flex; align-items: flex-start; gap: .5rem; }
.tc-job-info { flex: 1; min-width: 0; }
.tc-job-dir  { font-size: .8rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tc-job-meta { font-size: .71rem; color: var(--muted); margin-top: 2px; }
.tc-badge {
  font-size: .65rem; font-weight: 700; padding: 2px 8px; border-radius: 4px;
  text-transform: uppercase; white-space: nowrap; flex-shrink: 0;
}
.tc-badge.pending   { background: rgba(136,136,170,.12); color: var(--muted); }
.tc-badge.running   { background: rgba(124,58,237,.15);  color: #a78bfa; }
.tc-badge.completed { background: rgba(16,185,129,.15);  color: var(--success); }
.tc-badge.failed    { background: rgba(239,68,68,.15);   color: var(--error); }
.tc-badge.cancelled { background: rgba(136,136,170,.1);  color: var(--muted); }
.tc-progress { margin-top: .4rem; }
.tc-fname-row { display: flex; align-items: center; gap: 6px; margin-bottom: .25rem; min-width: 0; }
.tc-fname { font-size: .73rem; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; }
.tc-phase-badge {
  font-size: .63rem; font-weight: 700; padding: 1px 5px; border-radius: 4px;
  white-space: nowrap; flex-shrink: 0;
}
.tc-phase-dl { background: rgba(59,130,246,.25); color: #93c5fd; border: 1px solid rgba(59,130,246,.35); }
.tc-phase-tc { background: rgba(168,85,247,.25); color: #d8b4fe; border: 1px solid rgba(168,85,247,.35); }
.tc-phase-up { background: rgba(34,197,94,.2);   color: #86efac; border: 1px solid rgba(34,197,94,.3); }
.tc-bar-wrap { background: rgba(255,255,255,.07); border-radius: 3px; height: 5px; overflow: hidden; margin-bottom: .25rem; }
.tc-bar { background: var(--accent); height: 100%; border-radius: 3px; transition: width .5s; }
.tc-stats { display: flex; gap: .6rem; font-size: .68rem; color: var(--muted); flex-wrap: wrap; align-items: center; }
.tc-result { font-size: .72rem; margin-top: .3rem; }
.tc-del { position: absolute; top: .55rem; right: .55rem; background: none; border: none; color: var(--muted); cursor: pointer; font-size: .85rem; padding: 2px 5px; border-radius: 4px; line-height: 1; }
.tc-del:hover { color: var(--error); background: rgba(239,68,68,.1); }

@media (max-width: 680px) {
  body  { padding: .4rem; }
  .card { padding: 1rem; border-radius: 8px; }
  .progress-stats { flex-direction: column; gap: .2rem; }
  .tmm-poster   { width: 48px; height: 71px; }
  .tmm-cand-art { width: 40px; height: 59px; }
  .tab-btn { font-size: .78rem; padding: .45rem .2rem; }
  .tmm-hero-bd { height: clamp(140px, 45vw, 200px); }
  .tmm-hero-logo { max-height: 44px; max-width: 160px; }
  .tmm-thumb-poster   { width: 72px;  height: 108px; }
  .tmm-thumb-backdrop { width: 140px; height: 79px;  }
  .tmm-thumb-logo     { width: 140px; height: 50px;  }
  .lib-list { max-height: none; }
  .tmm-date-hint { display: none; }
  .tmm-date-lbl  { font-size: .73rem; }
  .tmm-date-input { min-width: 70px; }
  .tmm-queue { max-height: none; }
  .tmm-cands { overflow-x: hidden; }
  .tmm-detail { padding: .6rem .7rem; }
}

/* ── Cookies panel ───────────────────────────────────────────────────────────── */
.dl-cookies { border:1px solid var(--border); border-radius:8px; margin-top:.75rem; overflow:hidden; }
.dl-cookies-hdr {
  display:flex; align-items:center; gap:.5rem;
  padding:.5rem .75rem; cursor:pointer;
  font-size:.8rem; font-weight:600; color:var(--muted);
  background:rgba(255,255,255,.025); user-select:none;
}
.dl-cookies-hdr:hover { background:rgba(255,255,255,.055); }
#dl-cookies-badge { margin-left:auto; font-size:.72rem; }
.dl-cookies-chevron { font-size:.68rem; }
.dl-cookies-body { padding:.6rem .75rem; border-top:1px solid var(--border); }
.dl-cookies-body textarea {
  width:100%; box-sizing:border-box; min-height:96px;
  font-size:.72rem; font-family:monospace; resize:vertical;
  background:rgba(0,0,0,.25); border:1px solid var(--border); border-radius:6px;
  color:var(--text); padding:.45rem .55rem; line-height:1.45;
}
.dl-cookies-body textarea:focus { outline:none; border-color:var(--accent); }
.dl-cookies-actions { display:flex; gap:.5rem; margin-top:.45rem; }

/* ── Track inspector & remux ─────────────────────────────────────────────── */
.lib-tracks-section {
  margin-top: .65rem;
  padding-top: .65rem;
  border-top: 1px solid var(--border);
}
.lib-tracks-lbl {
  font-size: .7rem; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: .06em; margin-bottom: .4rem;
}
.lib-tracks-group-lbl {
  font-size: .68rem; color: var(--muted); font-weight: 600;
  text-transform: uppercase; letter-spacing: .05em; margin-bottom: .2rem;
}
.lib-track-row {
  display: flex; align-items: center; gap: .4rem;
  padding: .22rem 0; cursor: pointer;
}
.lib-track-row:hover { opacity: .85; }
.lib-track-row input[type=checkbox] {
  accent-color: var(--accent);
  width: .95rem; height: .95rem; flex-shrink: 0; cursor: pointer;
}
.lib-track-lang {
  font-size: .63rem; font-weight: 700; padding: .09rem .3rem;
  border-radius: 3px; min-width: 2.6rem; text-align: center; flex-shrink: 0;
}
.lib-track-codec { font-size: .73rem; color: var(--muted); }
.lib-track-title { font-size: .76rem; color: var(--text); }

/* ── Library Transcoder (Fáze 8) ──────────────────────────────────────────── */
.lib-tc-warn {
  font-size: .78rem; color: var(--warning); padding: .4rem .5rem;
  background: color-mix(in srgb, var(--warning) 12%, transparent);
  border-radius: 5px; border: 1px solid color-mix(in srgb, var(--warning) 30%, transparent);
  margin-bottom: .3rem;
}
.lib-tc-btn {
  font-size: .76rem; padding: .25rem .65rem;
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: 5px; color: var(--text); cursor: pointer; white-space: nowrap;
}
.lib-tc-btn:hover { background: var(--border); }
.lib-tc-form {
  display: flex; flex-wrap: wrap; gap: .35rem; align-items: center; margin-top: .35rem;
}
.lib-tc-form label { font-size: .72rem; color: var(--muted); }
.lib-tc-form input[type=text] {
  width: 5rem; background: var(--bg-input); border: 1px solid var(--border);
  border-radius: 4px; color: var(--text); font-size: .8rem; padding: .2rem .4rem;
}
.lib-tc-btn-go {
  font-size: .76rem; padding: .25rem .7rem;
  background: var(--accent); border: none; border-radius: 5px;
  color: #fff; cursor: pointer;
}
.lib-tc-btn-go:hover { opacity: .85; }
.lib-tc-btn-cancel {
  font-size: .76rem; padding: .25rem .6rem;
  background: transparent; border: 1px solid var(--error);
  border-radius: 5px; color: var(--error); cursor: pointer;
}
.lib-tc-progress {
  margin-top: .4rem;
}
.lib-tc-bar-wrap {
  height: 6px; background: var(--bg2); border-radius: 3px;
  overflow: hidden; margin: .25rem 0;
}
.lib-tc-bar-fill {
  height: 100%; background: var(--accent); border-radius: 3px;
  transition: width .5s;
}
.lib-tc-done { font-size: .78rem; color: var(--success); margin-top: .3rem; }
.lib-tc-err  { font-size: .78rem; color: var(--error);   margin-top: .3rem; }

/* ── Toast notifications ─────────────────────────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column-reverse;
  align-items: center;
  gap: .5rem;
  z-index: 9999;
  pointer-events: none;
  width: min(420px, 92vw);
}
.toast {
  pointer-events: all;
  width: 100%;
  padding: .75rem 1.1rem;
  border-radius: 10px;
  font-size: .88rem;
  line-height: 1.5;
  cursor: pointer;
  display: flex;
  align-items: flex-start;
  gap: .6rem;
  box-shadow: 0 4px 24px rgba(0,0,0,.45);
  animation: toast-in .22s cubic-bezier(.4,0,.2,1) both;
}
.toast-success { background: #064e3b; border: 1px solid #059669; color: #a7f3d0; }
.toast-error   { background: #450a0a; border: 1px solid #dc2626; color: #fca5a5; }
.toast-info    { background: #1e1b4b; border: 1px solid #6366f1; color: #c7d2fe; }
.toast-icon    { font-size: 1rem; flex-shrink: 0; margin-top: .05rem; }
.toast-body    { flex: 1; }
.toast-out     { animation: toast-out .3s cubic-bezier(.4,0,.2,1) both; }
@keyframes toast-in  { from { opacity:0; transform:translateY(12px) scale(.97); } to { opacity:1; transform:none; } }
@keyframes toast-out { from { opacity:1; transform:none; } to { opacity:0; transform:translateY(8px) scale(.97); } }

/* ── Remux Manager Modal ─────────────────────────────────────────── */
#remux-modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.82);
  z-index: 500;
  overflow-y: auto;
  padding: 1.5vh 1vw;
}
#remux-modal {
  margin: 0 auto;
  width: 98vw;
  max-width: 1440px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  min-height: 92vh;
}
#remux-modal-header {
  display: flex;
  align-items: center;
  gap: .7rem;
  padding: .7rem 1rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
#remux-modal-title { font-size: .95rem; font-weight: 700; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#remux-modal-body  { display: flex; flex: 1; min-height: 0; }
#remux-modal-left  {
  width: 290px;
  flex-shrink: 0;
  padding: .8rem;
  border-right: 1px solid var(--border);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: .5rem;
}
#remux-modal-right {
  flex: 1;
  padding: .8rem;
  display: flex;
  flex-direction: column;
  gap: .55rem;
  overflow-y: auto;
  min-width: 0;
}
#remux-modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: .5rem;
  padding: .6rem 1rem;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
#rm-video-player {
  width: 100%;
  max-height: 55vh;
  background: #0a0a0a;
  border-radius: 6px;
  display: block;
}
.rm-section-label {
  font-size: .72rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .04em;
  margin-bottom: .25rem;
}
.rm-probe-row {
  font-size: .73rem;
  padding: .28rem .4rem;
  background: rgba(0,0,0,.2);
  border-radius: 4px;
  line-height: 1.5;
}
.rm-probe-label { color: var(--muted); font-size: .68rem; }
.rm-seek-row {
  display: flex;
  align-items: center;
  gap: .5rem;
  flex-wrap: wrap;
}
.rm-offset-row {
  display: flex;
  align-items: center;
  gap: .45rem;
  flex-wrap: wrap;
}
#rm-seek-slider, #rm-offset-slider {
  flex: 1;
  min-width: 80px;
  accent-color: var(--accent);
  cursor: pointer;
}
#rm-offset-slider { accent-color: #fcd34d; }
.rm-time-inp {
  width: 7rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: .2rem .4rem;
  font-size: .73rem;
  color: var(--text);
}
.rm-btn-step {
  font-size: .63rem;
  padding: .1rem .3rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
}
.rm-btn-step:hover { background: rgba(255,255,255,.08); }
.rm-generate-btn {
  background: rgba(16,185,129,.12);
  border: 1px solid rgba(16,185,129,.4);
  color: #6ee7b7;
  font-weight: 600;
  padding: .35rem .8rem;
  font-size: .8rem;
  border-radius: 5px;
  cursor: pointer;
  white-space: nowrap;
}
.rm-generate-btn:disabled { opacity: .5; cursor: default; }
.rm-section-toggle {
  display: flex;
  align-items: center;
  gap: .4rem;
  font-size: .72rem;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
  padding: .3rem 0;
  border-top: 1px solid var(--border);
  margin-top: .3rem;
}
.rm-section-toggle:hover { color: var(--text); }
.rm-collapsible { overflow: hidden; }
@media (max-width: 700px) {
  #remux-modal-body { flex-direction: column; }
  #remux-modal-left { width: 100%; border-right: none; border-bottom: 1px solid var(--border); max-height: 45vh; overflow-y: auto; }
  #rm-video-player  { max-height: 35vh; }
}

/* ── Stremio ──────────────────────────────────────────────────────────────── */
.str-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: .7rem .85rem;
  margin-bottom: .5rem;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.str-card:hover { border-color: var(--accent); background: rgba(124,58,237,.05); }
.str-card.str-best { border-color: rgba(16,185,129,.4); background: rgba(16,185,129,.04); }
.str-card.str-selected { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(124,58,237,.2); }
.str-card-top { display:flex; align-items:center; gap:.5rem; margin-bottom:.3rem; }
.str-best-badge { font-size:.68rem; padding:.1rem .45rem; background:rgba(16,185,129,.18); color:#6ee7b7; border-radius:4px; font-weight:600; }
.str-addon { font-size:.72rem; color:var(--muted); flex:1; }
.str-score { font-size:.72rem; padding:.1rem .4rem; background:rgba(124,58,237,.15); color:#c4b5fd; border-radius:4px; font-weight:600; }
.str-name { font-size:.82rem; color:var(--text); font-weight:500; margin-bottom:.2rem; }
.str-desc { font-size:.74rem; color:var(--muted); margin-bottom:.35rem; white-space:pre-wrap; word-break:break-word; }
.str-badges { display:flex; flex-wrap:wrap; gap:.3rem; margin-bottom:.35rem; }
.str-badge { font-size:.67rem; padding:.1rem .4rem; border-radius:3px; font-weight:600; background:rgba(255,255,255,.08); color:var(--text); }
.str-badge-res  { background:rgba(59,130,246,.18); color:#93c5fd; }
.str-badge-lang { background:rgba(16,185,129,.18); color:#6ee7b7; }
.str-badge-codec{ background:rgba(245,158,11,.14); color:#fcd34d; }
.str-badge-audio{ background:rgba(139,92,246,.18); color:#c4b5fd; }
.str-badge-src  { background:rgba(255,255,255,.06); color:var(--muted); }
.str-badge-rd      { background:rgba(251,191,36,.18); color:#fbbf24; }
.str-badge-bitrate { background:rgba(99,102,241,.18); color:#a5b4fc; }
.str-badge-size    { background:rgba(255,255,255,.06); color:var(--muted); }
.str-badge-ch      { background:rgba(139,92,246,.12); color:#c4b5fd; }
.str-meta { font-size:.72rem; color:var(--muted); margin-bottom:.45rem; }
.str-filter-btn { font-size:.72rem; padding:.2rem .6rem; border-radius:4px; border:1px solid var(--border); background:none; color:var(--muted); cursor:pointer; transition:all .15s; }
.str-filter-btn:hover { border-color:var(--accent); color:var(--text); }
.str-filter-active { background:rgba(124,58,237,.18); border-color:var(--accent); color:#c4b5fd; }
.str-src { color:#93c5fd; }
.str-actions { display:flex; gap:.5rem; flex-wrap:wrap; }
.str-btn-tmm { background:rgba(16,185,129,.12); border-color:rgba(16,185,129,.4); color:#6ee7b7; }
.str-btn-tmm:hover:not(:disabled) { background:rgba(16,185,129,.22); border-color:rgba(16,185,129,.7); }
