/* Swiftflow — interface moderne */

:root {
  --bg: #09090b;
  --bg-elevated: #111113;
  --surface: #18181b;
  --surface-hover: #1f1f23;
  --border: rgba(255, 255, 255, .07);
  --border-strong: rgba(255, 255, 255, .12);
  --txt: #fafafa;
  --muted: #71717a;
  --muted-light: #a1a1aa;
  --accent: #f43f5e;
  --accent-hover: #fb7185;
  --accent-soft: rgba(244, 63, 94, .1);
  --accent-glow: rgba(244, 63, 94, .25);
  --ember: #fb923c;
  --ok: #4ade80;
  --warn: #fbbf24;
  --err: #f87171;
  --info: #60a5fa;
  --sidebar-w: 240px;
  --radius: 12px;
  --radius-lg: 16px;
  --radius-sm: 8px;
  --shadow: 0 4px 24px rgba(0, 0, 0, .4);
  --font: "Plus Jakarta Sans", system-ui, -apple-system, sans-serif;
  --ease: cubic-bezier(.4, 0, .2, 1);
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--txt);
  font: 14px/1.6 var(--font);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

.hidden { display: none !important; }
.muted { color: var(--muted-light); }
.small { font-size: 12px; }
.mono { font-family: ui-monospace, "Cascadia Code", Menlo, Consolas, monospace; font-size: 12px; }

.i {
  width: 16px; height: 16px; flex-shrink: 0;
  display: inline-block; vertical-align: -3px;
}

/* ── Boutons ── */
button {
  cursor: pointer; border: 0; border-radius: var(--radius-sm);
  padding: 8px 14px; font: 600 13px var(--font); color: var(--txt);
  background: var(--surface); display: inline-flex; align-items: center;
  gap: 6px; justify-content: center;
  transition: background .15s var(--ease), color .15s, border-color .15s, transform .1s;
}
button:active:not(:disabled) { transform: scale(.98); }
button:disabled { opacity: .35; cursor: not-allowed; }

button.primary {
  background: var(--accent); color: #fff;
}
button.primary:hover:not(:disabled) { background: var(--accent-hover); }

button.ghost {
  background: transparent; color: var(--muted-light);
  border: 1px solid var(--border);
}
button.ghost:hover:not(:disabled) {
  color: var(--txt); border-color: var(--border-strong); background: var(--surface);
}
button.ghost.sm { padding: 5px 10px; font-size: 12px; }
button.icon-btn { padding: 7px; }
button.btn-icon {
  padding: 6px; background: transparent; border: 1px solid transparent;
  color: var(--muted-light); border-radius: var(--radius-sm);
}
button.btn-icon:hover:not(:disabled) {
  background: var(--surface); border-color: var(--border); color: var(--txt);
}
button.btn-icon.danger:hover:not(:disabled) { color: var(--err); border-color: rgba(248, 113, 113, .3); }
.wide { width: 100%; }

input {
  background: var(--bg); border: 1px solid var(--border); color: var(--txt);
  border-radius: var(--radius-sm); padding: 10px 14px; font: 14px var(--font);
  width: 100%; transition: border-color .15s, box-shadow .15s;
}
input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input::placeholder { color: var(--muted); }

/* ── Login ── */
.login {
  min-height: 100vh; display: grid; place-items: center;
  padding: 24px; position: relative;
}
.login-bg {
  position: absolute; inset: 0; pointer-events: none;
  background:
    radial-gradient(600px 400px at 50% 0%, rgba(244, 63, 94, .08), transparent 70%),
    radial-gradient(400px 300px at 80% 100%, rgba(244, 63, 94, .04), transparent 60%);
}
.login-card {
  position: relative; width: min(380px, 100%);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 40px 32px;
  display: flex; flex-direction: column; gap: 20px; text-align: center;
  box-shadow: var(--shadow);
  animation: fadeUp .4s var(--ease);
}
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: none; }
}
.logo {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  font-size: 22px; font-weight: 700; letter-spacing: -.3px;
}
.logo em { font-style: normal; color: var(--accent); }
.logo-mark { width: 28px; height: 28px; color: var(--accent); }
.login-sub { margin: -8px 0 0; font-size: 13px; color: var(--muted-light); }
.field { position: relative; }
.field .i { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.field input { padding-left: 38px; text-align: left; }
.error { color: var(--err); font-size: 13px; min-height: 18px; }

/* ── App shell ── */
.app {
  display: flex; min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-w); flex-shrink: 0;
  background: var(--bg-elevated); border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
  padding: 20px 12px;
}

.sidebar-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 4px 10px 24px; font-size: 16px; font-weight: 700;
}
.sidebar-brand em { font-style: normal; color: var(--accent); }
.sidebar-brand .logo-mark { width: 24px; height: 24px; color: var(--accent); }

.sidebar-nav {
  display: flex; flex-direction: column; gap: 4px; flex: 1;
}

.nav-item {
  width: 100%; justify-content: flex-start; gap: 10px;
  padding: 10px 12px; background: transparent; border: 1px solid transparent;
  color: var(--muted-light); font-weight: 500; border-radius: var(--radius-sm);
}
.nav-item .i { width: 18px; height: 18px; opacity: .7; }
.nav-item:hover { background: var(--surface); color: var(--txt); }
.nav-item.active {
  background: var(--accent-soft); color: var(--accent); border-color: rgba(244, 63, 94, .2);
}
.nav-item.active .i { opacity: 1; }

.sidebar-foot {
  margin-top: auto; padding-top: 16px;
  border-top: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 12px;
}

.storage {
  padding: 10px 12px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
}
.st-head {
  display: flex; align-items: center; gap: 8px; margin-bottom: 8px;
}
.st-head .i { color: var(--muted); width: 14px; height: 14px; }
.st-txt { font-size: 11px; color: var(--muted-light); }
.st-bar {
  height: 4px; background: var(--bg); border-radius: 4px; overflow: hidden;
}
.st-fill {
  height: 100%; width: 0; border-radius: 4px;
  background: var(--accent); transition: width .4s var(--ease);
}
.storage.warn .st-fill { background: var(--warn); }
.storage.crit .st-fill { background: var(--err); }

.sidebar-meta {
  display: flex; align-items: center; gap: 8px; padding: 0 4px;
}
.live-label { font-size: 11px; color: var(--muted); flex: 1; }
.dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--err); flex-shrink: 0;
  transition: background .3s, box-shadow .3s;
}
.dot.on {
  background: var(--ok);
  box-shadow: 0 0 8px rgba(74, 222, 128, .5);
  animation: pulse 2s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .6; }
}

/* ── Main area ── */
.app-main {
  flex: 1; min-width: 0; display: flex; flex-direction: column;
}

.global-activity {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 24px; background: var(--accent-soft);
  border-bottom: 1px solid rgba(244, 63, 94, .2);
  color: var(--accent-hover); font-size: 13px; font-weight: 500;
}
.global-activity .i { color: var(--accent); }
.pulse-icon { animation: pulse 2s ease-in-out infinite; }

.content {
  flex: 1; max-width: 880px; width: 100%;
  margin: 0 auto; padding: 32px 28px 64px;
}

.content.content-wide {
  max-width: none;
  margin: 0;
  padding: 24px 32px 48px;
}

.page { animation: fadeUp .25s var(--ease); }

.page-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px; margin-bottom: 28px;
}
.page-head h1 {
  margin: 0; font-size: 24px; font-weight: 700; letter-spacing: -.4px;
}
.page-desc { margin: 4px 0 0; color: var(--muted-light); font-size: 14px; }

.pill {
  display: inline-flex; align-items: center;
  padding: 5px 12px; border-radius: 20px;
  background: var(--surface); border: 1px solid var(--border);
  font-size: 12px; font-weight: 500; white-space: nowrap;
  flex-shrink: 0;
}

.section-head {
  margin: 28px 0 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.section-head h2 {
  margin: 0; font-size: 13px; font-weight: 600;
  color: var(--muted-light); text-transform: uppercase; letter-spacing: .06em;
  display: flex; align-items: center; gap: 8px;
}
.section-head .i { width: 14px; height: 14px; opacity: .6; }

/* ── Cards ── */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 20px;
}
.card-label {
  font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .08em; color: var(--muted); margin-bottom: 14px;
}

.tabs {
  display: inline-flex; gap: 2px; padding: 3px;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius-sm); margin-bottom: 16px;
}
.tab {
  padding: 7px 14px; background: transparent; border: none;
  color: var(--muted-light); font-size: 13px; font-weight: 500;
  border-radius: 6px;
}
.tab:hover { color: var(--txt); }
.tab.active { background: var(--surface-hover); color: var(--txt); box-shadow: 0 1px 3px rgba(0,0,0,.2); }

/* ── Drop zone ── */
.drop {
  border: 1.5px dashed var(--border-strong); border-radius: var(--radius);
  padding: 36px 24px; text-align: center; cursor: pointer;
  transition: border-color .2s, background .2s;
  background: var(--bg);
}
.drop:hover, .drop.hover {
  border-color: var(--accent); background: var(--accent-soft);
}
.drop-icon {
  width: 32px; height: 32px; color: var(--accent); margin-bottom: 12px;
}
.drop-title { margin: 0 0 4px; font-size: 15px; font-weight: 600; }
.drop-hint { margin: 0; font-size: 13px; color: var(--muted); }

.or {
  display: flex; align-items: center; gap: 12px;
  margin: 16px 0; color: var(--muted); font-size: 11px;
  text-transform: uppercase; letter-spacing: .1em;
}
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: var(--border); }

.row-inline { display: flex; gap: 10px; }
.row-inline button { flex-shrink: 0; }

.alert {
  display: flex; align-items: center; gap: 8px;
  margin-top: 14px; padding: 10px 14px; border-radius: var(--radius-sm);
  font-size: 13px;
}
.alert.warn {
  color: var(--warn); background: rgba(251, 191, 36, .08);
  border: 1px solid rgba(251, 191, 36, .15);
}
.alert.info {
  color: var(--info); background: rgba(96, 165, 250, .08);
  border: 1px solid rgba(96, 165, 250, .15);
  margin-bottom: 16px;
}
.alert .i { flex-shrink: 0; }

.upbar {
  margin-top: 14px; height: 28px; background: var(--bg);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  position: relative; overflow: hidden;
}
.upbar-fill {
  height: 100%; width: 0; background: var(--accent);
  transition: width .2s var(--ease); border-radius: var(--radius-sm);
}
.upbar span {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-size: 11px; font-weight: 600;
}

/* ── Jobs ── */
.job-list { display: flex; flex-direction: column; gap: 10px; }

.job {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px 18px;
  animation: fadeUp .3s var(--ease);
  transition: border-color .2s;
}
.job:hover { border-color: var(--border-strong); }

.job-head {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 12px; flex-wrap: wrap;
}
.job-info {
  display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1;
}
.title-text {
  font-weight: 600; font-size: 14px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.job-actions {
  display: flex; align-items: center; gap: 6px; flex-shrink: 0;
}
.job-step { font-size: 13px; margin: 8px 0 10px; color: var(--muted-light); }

.badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 10px; font-weight: 700; padding: 3px 8px; border-radius: 6px;
  text-transform: uppercase; letter-spacing: .04em;
  background: var(--bg); color: var(--muted-light); flex-shrink: 0;
}
.badge .i { width: 11px; height: 11px; }
.badge.status.downloading, .badge.status.resolving { background: var(--accent-soft); color: var(--accent); }
.badge.status.encoding { background: rgba(251, 146, 60, .12); color: var(--ember); }
.badge.status.uploading, .badge.status.queued { background: rgba(244, 63, 94, .08); color: var(--accent-hover); }
.badge.status.done { background: rgba(74, 222, 128, .1); color: var(--ok); }
.badge.status.error { background: rgba(248, 113, 113, .1); color: var(--err); }
.badge.status.canceled { background: var(--bg); color: var(--muted); }

.bar {
  height: 6px; background: var(--bg); border-radius: 6px; overflow: hidden;
}
.bar-fill {
  height: 100%; width: 0; border-radius: 6px;
  background: linear-gradient(90deg, var(--accent), var(--accent-hover));
  transition: width .35s var(--ease);
}
.job.done .bar-fill { background: var(--ok); }
.job.error .bar-fill { background: var(--err); }
.job.canceled .bar-fill { background: var(--muted); }

.job-meta {
  display: flex; gap: 16px; font-size: 12px; color: var(--muted);
  margin-top: 8px; flex-wrap: wrap;
}
.job-meta span { display: inline-flex; align-items: center; gap: 4px; }
.job-meta .i { width: 12px; height: 12px; }
.job-meta .pct { color: var(--txt); font-weight: 600; }

.active-files { margin-top: 10px; display: flex; flex-direction: column; gap: 6px; }
.active-files:empty { display: none; }
.afile {
  display: flex; align-items: center; gap: 8px; font-size: 12px;
  padding: 8px 10px; background: var(--bg); border-radius: var(--radius-sm);
}
.afile .afi { width: 13px; height: 13px; flex-shrink: 0; }
.afile.download .afi { color: var(--accent); }
.afile.encode .afi { color: var(--ember); }
.afname {
  flex: 0 1 auto; min-width: 50px; max-width: 35%;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.afbar { flex: 1; height: 4px; background: var(--surface-hover); border-radius: 4px; overflow: hidden; min-width: 40px; }
.affill { display: block; height: 100%; border-radius: 4px; transition: width .3s; }
.afile.download .affill { background: var(--accent); }
.afile.encode .affill { background: var(--ember); }
.afpct { font-weight: 600; width: 32px; text-align: right; font-size: 11px; }
.afmeta { color: var(--muted); font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.outputs { margin-top: 10px; display: flex; flex-direction: column; gap: 4px; }
.outputs:empty { display: none; }
.outputs .out {
  display: flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--ok);
}
.outputs .out .i { width: 13px; height: 13px; }

.logs {
  margin-top: 12px; background: #050506; border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 12px; max-height: 220px;
  overflow: auto; font: 11px/1.5 ui-monospace, Menlo, Consolas, monospace;
  white-space: pre-wrap; color: #a1a1aa;
}
.logs.sys-logs {
  max-height: 60vh; min-height: 280px; font-size: 12px;
}
.upload-hint {
  margin: 0 0 12px; padding: 10px 14px; border-radius: var(--radius-sm);
  background: var(--accent-soft); color: var(--muted-light); font-size: 12px;
}
.upload-hint strong { color: var(--accent); }

.empty-state {
  text-align: center; padding: 48px 24px;
  border: 1px dashed var(--border); border-radius: var(--radius);
  background: var(--surface);
}
.empty-state.compact { padding: 32px; border: none; background: transparent; }
.empty-icon { width: 32px; height: 32px; color: var(--muted); margin-bottom: 12px; opacity: .5; }
.empty-state p { margin: 0 0 4px; font-weight: 500; }
.empty-state span { font-size: 13px; }

/* ── Bibliothèque ── */
.lib-card { padding: 0; overflow: hidden; }

.breadcrumb {
  display: flex; flex-wrap: wrap; gap: 4px; align-items: center;
  padding: 14px 18px; border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.breadcrumb a {
  display: inline-flex; align-items: center; gap: 5px;
  color: var(--muted-light); cursor: pointer; padding: 4px 8px;
  border-radius: 6px; transition: background .15s, color .15s;
}
.breadcrumb a:hover { color: var(--accent); background: var(--accent-soft); }
.breadcrumb a:last-child { color: var(--txt); pointer-events: none; }
.breadcrumb .sep { color: var(--muted); opacity: .4; padding: 0 2px; }
.breadcrumb .i { width: 14px; height: 14px; }

.lib-list { display: flex; flex-direction: column; }
.lib-row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 18px; border-bottom: 1px solid var(--border);
  transition: background .12s;
}
.lib-row:last-child { border-bottom: none; }
.lib-row:hover { background: var(--surface-hover); }
.lib-row .ic { width: 18px; height: 18px; color: var(--muted); flex-shrink: 0; }
.lib-row.dir { cursor: pointer; }
.lib-row.dir:hover .ic, .lib-row.dir:hover .chev { color: var(--accent); }
.lib-row.file .ic { color: var(--accent); opacity: .8; }
.lib-name {
  flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-weight: 500; font-size: 14px;
}
.lib-name.renameable { cursor: text; border-radius: 4px; padding: 2px 6px; margin: -2px -6px; }
.lib-name.renameable:hover { background: var(--accent-soft); }
.lib-rename-input {
  flex: 1; min-width: 0; padding: 4px 8px; border-radius: 6px;
  border: 1px solid var(--accent); background: var(--bg); color: var(--txt);
  font: inherit; font-weight: 500;
}
.lib-size { color: var(--muted); font-size: 12px; white-space: nowrap; min-width: 56px; text-align: right; }
.lib-size.hidden { display: none; }
.lib-ftp-status {
  display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; max-width: 280px;
}
.lib-ftp-badge {
  font-size: 10px; font-weight: 700; letter-spacing: .04em;
  padding: 2px 6px; border-radius: 4px;
  background: var(--accent-soft); color: var(--accent); white-space: nowrap;
}
.lib-ftp-badge.active { background: var(--err); color: #fff; }
.lib-ftp-bar {
  flex: 1; height: 6px; border-radius: 3px;
  background: var(--border); overflow: hidden; min-width: 48px;
}
.lib-ftp-fill {
  height: 100%; width: 0; border-radius: 3px;
  background: var(--accent); transition: width .35s ease;
}
.lib-row-ftp-active .lib-ftp-fill { background: var(--err); }
.lib-ftp-pct { font-size: 12px; font-weight: 600; color: var(--txt); min-width: 36px; text-align: right; }
.lib-ftp-speed { font-size: 11px; color: var(--muted); white-space: nowrap; }
.lib-ftp-speed.hidden { display: none; }
.lib-row-ftp-active { background: rgba(220, 53, 69, .06); }
.lib-row-ftp-active .lib-name { color: var(--err); }
.lib-row-ftp-wait { opacity: .75; }
.chev { width: 16px; height: 16px; color: var(--muted); margin-left: auto; }
.lib-row .actions {
  display: flex; gap: 4px; opacity: .7; transition: opacity .15s;
}
.lib-row:hover .actions { opacity: 1; }
.lib-row a.dl { text-decoration: none; }

/* ── Catalogue Senpai / Manquants ── */
.nav-count {
  margin-left: auto;
  min-width: 20px;
  padding: 2px 7px;
  border-radius: 99px;
  background: var(--err);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  text-align: center;
}

.nav-count-amber {
  background: var(--warn);
  color: #422006;
}

.cat-summary { margin-bottom: 20px; }

.cat-hero {
  padding: 20px 22px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

.cat-hero-red { border-left: 3px solid var(--err); }
.cat-hero-red .cat-hero-num { color: var(--err); }

.cat-hero-amber { border-left: 3px solid var(--warn); }
.cat-hero-amber .cat-hero-num { color: var(--warn); }

.cat-hero-main {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 12px;
}

.cat-hero-num {
  font-size: 36px;
  font-weight: 700;
  line-height: 1;
}

.cat-hero-txt { color: var(--muted-light); font-size: 14px; }

.cat-hero-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}

.cat-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.cat-toolbar {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 16px;
}

.cat-toolbar-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
}

.cat-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip {
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted-light);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
}

.chip:hover { color: var(--txt); border-color: var(--border-strong); }

.chip.active {
  background: var(--accent-soft);
  border-color: rgba(244, 63, 94, 0.35);
  color: var(--accent-hover);
}

.chip-red.active { background: rgba(248, 113, 113, 0.12); border-color: rgba(248, 113, 113, 0.35); color: var(--err); }
.chip-green.active { background: rgba(74, 222, 128, 0.12); border-color: rgba(74, 222, 128, 0.35); color: var(--ok); }
.chip-amber.active { background: rgba(251, 191, 36, 0.12); border-color: rgba(251, 191, 36, 0.35); color: var(--warn); }

.pill.chip-red { color: var(--err); }
.pill.chip-green { color: var(--ok); }
.pill.chip-amber { color: var(--warn); }

.cat-hidden-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--muted-light);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

.cat-hidden-toggle input { accent-color: var(--warn); }

.cat-dismiss-btn {
  position: absolute;
  top: 6px;
  right: 6px;
  z-index: 2;
  width: 26px;
  height: 26px;
  padding: 0;
  border: none;
  border-radius: 6px;
  background: rgba(0, 0, 0, .75);
  color: #fff;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  transition: opacity .15s var(--ease), background .15s var(--ease);
}

.media-card:hover .cat-dismiss-btn,
.media-card.is-hidden .cat-dismiss-btn { opacity: 1; }

.cat-dismiss-btn:hover { background: rgba(220, 38, 38, .9); }

.media-card.is-hidden {
  opacity: .55;
  border-style: dashed;
}

.cat-restore-btn {
  margin-top: 6px;
  width: 100%;
  font-size: 11px;
}

.cat-search {
  flex: 1;
  min-width: 160px;
  max-width: 360px;
}

.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 14px;
  width: 100%;
}

.media-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color .15s var(--ease);
}

.media-card:hover { border-color: var(--border-strong); }

.media-poster {
  position: relative;
  aspect-ratio: 2 / 3;
  background: var(--bg);
}

.media-poster img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.no-poster {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  color: var(--muted);
  opacity: .4;
}

.no-poster .i { width: 28px; height: 28px; }

.status-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  padding: 3px 8px;
  border-radius: 99px;
  font-size: 10px;
  font-weight: 600;
  background: rgba(0, 0, 0, .72);
  color: #fff;
}

.status-badge.present { background: rgba(74, 222, 128, .85); color: #052e16; }
.status-badge.absent { background: rgba(248, 113, 113, .9); color: #450a0a; }
.status-badge.extra { background: rgba(251, 191, 36, .9); color: #422006; }

.type-badge {
  position: absolute;
  bottom: 8px;
  right: 8px;
  padding: 2px 8px;
  border-radius: 99px;
  font-size: 10px;
  background: rgba(0, 0, 0, .65);
  color: #fff;
}

.match-tag {
  position: absolute;
  bottom: 8px;
  left: 8px;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 9px;
  background: rgba(244, 63, 94, .85);
  color: #fff;
}

.media-body { padding: 10px 12px 12px; }

.media-title {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.media-meta {
  margin: 4px 0 0;
  font-size: 11px;
  color: var(--muted);
}

.media-links {
  margin-top: 6px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.media-links a {
  font-size: 11px;
  color: var(--accent-hover);
  text-decoration: none;
}

.media-links a.link-senpai {
  color: var(--warn);
  font-weight: 600;
}

.media-links a:hover { text-decoration: underline; }

.cat-empty-grid {
  grid-column: 1 / -1;
  text-align: center;
  padding: 40px 16px;
}

.global-activity .ga-body { flex: 1; min-width: 0; }
.global-activity .progress-bar {
  height: 8px;
  background: rgba(255, 255, 255, .12);
  border-radius: 99px;
  overflow: hidden;
  margin: 6px 0 4px;
}
.global-activity .progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #fb7185);
  width: 0;
  transition: width .25s var(--ease);
}
.global-activity #progressText {
  margin: 0;
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
}

/* ── Import MP4 ── */
.mp4-hero-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
}

.mp4-hero-stats {
  display: flex;
  gap: 10px;
}

.mp4-hero-stat {
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 12px;
  color: var(--muted-light);
}

.mp4-hero-stat strong {
  display: block;
  font-size: 18px;
  font-weight: 700;
  color: var(--txt);
  line-height: 1.2;
}

.mp4-dropzone {
  margin-bottom: 24px;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--border);
  background:
    radial-gradient(ellipse 80% 60% at 50% -20%, rgba(244, 63, 94, .12), transparent 60%),
    var(--surface);
  box-shadow: var(--shadow);
}

.mp4-dropzone-inner {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 20px 22px 0;
}

.mp4-dropzone-icon {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--accent-soft), rgba(251, 146, 60, .08));
  border: 1px solid rgba(244, 63, 94, .2);
  color: var(--accent-hover);
  flex-shrink: 0;
}

.mp4-textarea {
  width: calc(100% - 44px);
  min-height: 88px;
  margin: 16px 22px 0;
  padding: 14px 16px;
  font-family: ui-monospace, "Cascadia Code", Menlo, Consolas, monospace;
  font-size: 12px;
  line-height: 1.5;
  resize: vertical;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--txt);
  transition: border-color .2s, box-shadow .2s;
}

.mp4-textarea:focus {
  outline: none;
  border-color: rgba(244, 63, 94, .45);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.mp4-parse-row {
  display: flex;
  justify-content: flex-end;
  padding: 14px 22px 20px;
}

.mp4-parse-btn {
  padding: 10px 20px;
  font-size: 13px;
  box-shadow: 0 4px 20px var(--accent-glow);
}

.mp4-queue {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.mp4-empty {
  text-align: center;
  padding: 48px 24px;
  border-radius: var(--radius-lg);
  border: 1px dashed var(--border-strong);
  background: var(--bg-elevated);
}

.mp4-empty-icon {
  width: 56px;
  height: 56px;
  margin: 0 auto 16px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--surface);
  color: var(--muted);
  border: 1px solid var(--border);
}

/* Carte import */
.mp4-card {
  position: relative;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  transition: border-color .25s, box-shadow .25s;
}

.mp4-card::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 1px;
  background: linear-gradient(135deg, rgba(244, 63, 94, .35), transparent 40%, rgba(96, 165, 250, .15));
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
  opacity: 0;
  transition: opacity .3s;
}

.mp4-card--downloading::before { opacity: 1; }

.mp4-card--downloading {
  box-shadow: 0 8px 40px rgba(244, 63, 94, .08);
}

.mp4-card--ready {
  border-color: rgba(74, 222, 128, .25);
}

.mp4-card--error {
  border-color: rgba(248, 113, 113, .35);
}

.mp4-card-body { padding: 20px 22px; }

.mp4-card-head {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 16px;
}

.mp4-card-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  font-size: 18px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
}

.mp4-card--downloading .mp4-card-icon {
  background: linear-gradient(135deg, var(--accent-soft), rgba(251, 146, 60, .1));
  border-color: rgba(244, 63, 94, .25);
  animation: mp4-pulse 2s ease-in-out infinite;
}

@keyframes mp4-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(244, 63, 94, .25); }
  50% { box-shadow: 0 0 0 8px rgba(244, 63, 94, 0); }
}

.mp4-card-title { flex: 1; min-width: 0; }

.mp4-card-title h3 {
  margin: 6px 0 0;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mp4-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  background: var(--accent-soft);
  color: var(--accent-hover);
  border: 1px solid rgba(244, 63, 94, .2);
}

.mp4-badge.serie {
  background: rgba(251, 191, 36, .1);
  color: var(--warn);
  border-color: rgba(251, 191, 36, .25);
}

.mp4-state {
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  flex-shrink: 0;
}

.mp4-state--pending { background: var(--bg-elevated); color: var(--muted-light); }
.mp4-state--downloading { background: rgba(244, 63, 94, .15); color: var(--accent-hover); }
.mp4-state--ready { background: rgba(74, 222, 128, .12); color: var(--ok); }
.mp4-state--error { background: rgba(248, 113, 113, .12); color: var(--err); }

/* Panneau téléchargement */
.mp4-dl-panel {
  margin-bottom: 18px;
  padding: 16px 18px;
  border-radius: var(--radius);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
}

.mp4-dl-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 14px;
}

@media (max-width: 720px) {
  .mp4-dl-stats { grid-template-columns: repeat(2, 1fr); }
}

.mp4-stat label {
  display: block;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  margin-bottom: 4px;
}

.mp4-stat strong {
  font-size: 15px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--txt);
}

.mp4-stat strong.accent { color: var(--accent-hover); }

.mp4-dl-bar-wrap {
  position: relative;
  height: 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .06);
  overflow: hidden;
}

.mp4-dl-bar-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--ember));
  transition: width .4s var(--ease);
  box-shadow: 0 0 12px var(--accent-glow);
}

.mp4-dl-pct {
  position: absolute;
  right: 0;
  top: -22px;
  font-size: 13px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--accent-hover);
}

.mp4-url {
  word-break: break-all;
  margin: 0 0 14px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--bg);
  border: 1px solid var(--border);
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 11px;
  line-height: 1.45;
  color: var(--muted-light);
}

.mp4-modal-form .mp4-fields { margin: 14px 0 10px; }
.mp4-modal-preview { margin: 0 0 4px; font-size: 13px; }

.mp4-name-input-wrap {
  display: flex;
  align-items: center;
  gap: 4px;
  width: 100%;
}

.mp4-name-input-wrap input { flex: 1; min-width: 0; }

.mp4-ext-suffix {
  color: var(--muted);
  font-size: 13px;
  flex-shrink: 0;
}

.mp4-path-line {
  margin: 0 0 10px;
  font-size: 12px;
  word-break: break-all;
}

.mp4-fields {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.mp4-fields label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 11px;
  color: var(--muted-light);
  font-weight: 600;
}

.mp4-fields input {
  padding: 10px 12px;
  font-size: 13px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--txt);
}

.mp4-fields input:focus {
  outline: none;
  border-color: rgba(244, 63, 94, .4);
}

.mp4-grow { grid-column: span 2; }
@media (max-width: 600px) { .mp4-grow { grid-column: span 1; } }

.mp4-preview {
  grid-column: 1 / -1;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  background: rgba(96, 165, 250, .06);
  border: 1px solid rgba(96, 165, 250, .15);
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 12px;
  color: var(--info);
}

.mp4-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding-top: 4px;
}

.mp4-actions .primary {
  min-width: 130px;
}

/* legacy aliases */
.mp4-row { padding: 0; border: none; background: transparent; }
.mp4-progress, .mp4-progress-fill { display: none; }

button.danger { color: var(--err); }
button.danger:hover { border-color: rgba(248, 113, 113, 0.4); }

.field {
  margin-bottom: 12px;
  text-align: left;
}

.field label {
  display: block;
  font-size: 12px;
  color: var(--muted-light);
  margin-bottom: 4px;
}

.field input { width: 100%; }

/* ── Modale ── */
.modal {
  position: fixed; inset: 0; z-index: 100;
  display: grid; place-items: center; padding: 20px;
}
.modal-backdrop {
  position: absolute; inset: 0; background: rgba(0, 0, 0, .75);
  backdrop-filter: blur(6px); animation: fadeIn .2s;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal-card {
  position: relative; width: min(860px, 96vw); max-height: 90vh; overflow: auto;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow);
  animation: fadeUp .25s var(--ease);
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
  position: sticky; top: 0; background: var(--surface); z-index: 1;
}
.modal-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.modal-body { padding: 20px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; flex-wrap: wrap; }

.player { width: 100%; max-height: 70vh; border-radius: var(--radius-sm); background: #000; display: block; }
.player-note { margin-top: 10px; }
.conflict-list {
  margin: 10px 0; padding: 12px 14px 12px 28px; max-height: 200px; overflow: auto;
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-size: 13px;
}

/* ── Responsive ── */
@media (max-width: 768px) {
  .app { flex-direction: column; }
  .sidebar {
    width: 100%; height: auto; position: relative;
    flex-direction: row; flex-wrap: wrap; padding: 12px;
    border-right: none; border-bottom: 1px solid var(--border);
  }
  .sidebar-brand { padding: 0 8px 0 0; }
  .sidebar-nav {
    flex-direction: row; flex: 1; justify-content: center;
  }
  .nav-item span { display: none; }
  .nav-item { padding: 10px; }
  .sidebar-foot {
    flex-direction: row; align-items: center; border-top: none;
    margin-top: 0; padding-top: 0; gap: 8px;
  }
  .storage { display: none; }
  .content { padding: 20px 16px 48px; }
  .page-head { flex-direction: column; }
  .row-inline { flex-direction: column; }
  .job-actions { width: 100%; justify-content: flex-end; }
}

@media (max-width: 480px) {
  .lib-row .actions { opacity: 1; }
  .lib-size { display: none; }
}
