/* ==========================================================================
   Lazy Nerds TV — Content Studio
   Design system + application shell
   ========================================================================== */

/* --------------------------------------------------------------- tokens -- */
/* Light is the default theme; [data-theme="dark"] overrides the palette. */
:root {
  color-scheme: light;

  /* surfaces */
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-2: #f8fafd;
  --surface-3: #eef2f9;
  --surface-4: #e2e8f4;

  /* lines */
  --line: #d9e0ee;
  --line-soft: #e7ebf5;

  /* type */
  --text: #101828;
  --text-2: #46506a;
  --text-3: #6b7692;

  /* accent — navy */
  --navy-deep: #102048;
  --navy: #1e3a7a;
  --navy-hi: #2f57ab;
  --navy-ink: #2a4a94;
  /* legacy aliases so every component keeps one source of truth */
  --iris: var(--navy-ink);
  --iris-2: var(--navy);
  --violet: var(--navy-hi);
  --cyan: #0e7490;
  --ok: #047857;
  --warn: #a16207;
  --err: #be123c;

  /* theme-aware chrome */
  --ambient:
    radial-gradient(760px 420px at 14% -8%, rgba(47, 87, 171, .1), transparent 70%),
    radial-gradient(680px 380px at 92% 4%, rgba(47, 87, 171, .06), transparent 72%);
  --selection-bg: rgba(47, 87, 171, .18);
  --scroll-thumb: #c6cfdf;
  --scroll-thumb-hover: #a9b5cc;
  --sidebar-bg: linear-gradient(180deg, #ffffff 0%, #f7f9fe 100%);
  --topbar-bg: rgba(255, 255, 255, .82);
  --nav-active-bg: linear-gradient(100deg, rgba(47, 87, 171, .14), rgba(30, 58, 122, .05));
  --nav-active-fg: #14224a;
  --nav-active-ring: inset 0 0 0 1px rgba(47, 87, 171, .2);
  --badge-bg: rgba(16, 24, 40, .06);
  --badge-active-bg: rgba(47, 87, 171, .18);
  --seg-active-bg: #ffffff;
  --seg-active-fg: #14224a;
  --stat-glow: radial-gradient(closest-side, rgba(47, 87, 171, .16), transparent);
  --hero-border: rgba(47, 87, 171, .24);
  --hero-bg:
    radial-gradient(620px 200px at 8% 120%, rgba(47, 87, 171, .12), transparent 70%),
    linear-gradient(120deg, #eef3ff 0%, #f6f8ff 55%, #ffffff 100%);
  --backdrop: rgba(17, 24, 44, .42);
  --sheet-foot-bg: rgba(244, 246, 251, .72);
  --log-bg: #fbfcff;
  --log-fg: #33405c;
  --log-border: #e3e8f4;
  --logo-bg: #ffffff;
  --logo-ring: inset 0 0 0 1px rgba(16, 32, 72, .1);
  --select-arrow: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236b7692' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");

  /* geometry */
  --r-xs: 6px;
  --r-sm: 9px;
  --r: 13px;
  --r-lg: 18px;
  --r-xl: 26px;

  /* elevation */
  --sh-1: 0 1px 2px rgba(16, 24, 40, .05);
  --sh-2: 0 10px 30px -18px rgba(16, 24, 40, .28);
  --sh-3: 0 30px 70px -26px rgba(16, 24, 40, .3);

  --ring: 0 0 0 3px rgba(47, 87, 171, .2);
  --ease: cubic-bezier(.22, .68, .32, 1);

  --sidebar-w: 258px;
  --topbar-h: 68px;
}

[data-theme="dark"] {
  color-scheme: dark;

  --bg: #070910;
  --surface: #0d1018;
  --surface-2: #131725;
  --surface-3: #1a1f30;
  --surface-4: #222840;

  --line: #242b3f;
  --line-soft: #1a2032;

  --text: #eef1f9;
  --text-2: #a5aec6;
  --text-3: #7b85a1;

  --navy-ink: #93b4f7;
  --iris: var(--navy-ink);
  --cyan: #4fd1e0;
  --ok: #3ddc97;
  --warn: #f5b544;
  --err: #ff6b82;

  --ambient:
    radial-gradient(760px 420px at 14% -8%, rgba(30, 58, 122, .34), transparent 70%),
    radial-gradient(680px 380px at 92% 4%, rgba(47, 87, 171, .1), transparent 72%);
  --selection-bg: rgba(47, 87, 171, .5);
  --scroll-thumb: #2b3247;
  --scroll-thumb-hover: #3b4460;
  --sidebar-bg: linear-gradient(180deg, #0d1018 0%, #0a0d15 100%);
  --topbar-bg: rgba(13, 16, 24, .72);
  --nav-active-bg: linear-gradient(100deg, rgba(47, 87, 171, .34), rgba(30, 58, 122, .18));
  --nav-active-fg: #ffffff;
  --nav-active-ring: inset 0 0 0 1px rgba(147, 180, 247, .26);
  --badge-bg: rgba(255, 255, 255, .16);
  --badge-active-bg: rgba(255, 255, 255, .18);
  --seg-active-bg: #222840;
  --seg-active-fg: #ffffff;
  --stat-glow: radial-gradient(closest-side, rgba(47, 87, 171, .28), transparent);
  --hero-border: rgba(47, 87, 171, .4);
  --hero-bg:
    radial-gradient(620px 200px at 8% 120%, rgba(47, 87, 171, .3), transparent 70%),
    linear-gradient(120deg, #141a2c 0%, #101423 60%, #0d1018 100%);
  --backdrop: rgba(4, 6, 12, .68);
  --sheet-foot-bg: rgba(7, 9, 16, .5);
  --log-bg: #05070c;
  --log-fg: #a9b4cc;
  --log-border: #1a2032;
  --logo-bg: #ffffff;
  --logo-ring: inset 0 0 0 1px rgba(147, 180, 247, .18);
  --select-arrow: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%237b85a1' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");

  --sh-1: 0 1px 2px rgba(0, 0, 0, .5);
  --sh-2: 0 10px 30px -16px rgba(0, 0, 0, .85);
  --sh-3: 0 30px 70px -24px rgba(0, 0, 0, .9);
  --ring: 0 0 0 3px rgba(47, 87, 171, .38);
}

@keyframes fade-up { from { opacity: 0; transform: translateY(6px); } }
@keyframes pop-in { from { opacity: 0; transform: translateY(14px) scale(.985); } }
@keyframes slide-in { from { opacity: 0; transform: translateX(18px); } }
@keyframes pulse { 50% { opacity: .35; } }
@keyframes sweep { from { transform: translateX(-100%); } to { transform: translateX(100%); } }
@keyframes spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}

/* ---------------------------------------------------------------- reset -- */
* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
}

body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.55 "Segoe UI Variable Text", "Segoe UI", Inter, system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: var(--ambient);
}

h1, h2, h3, h4, p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
button { font-family: inherit; }
a { color: var(--iris); }
::selection { background: var(--selection-bg); }

svg.ico {
  width: 17px;
  height: 17px;
  flex: none;
  stroke: currentColor;
  stroke-width: 1.7;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

::-webkit-scrollbar { width: 11px; height: 11px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--scroll-thumb);
  border: 3px solid transparent;
  border-radius: 20px;
  background-clip: content-box;
}
::-webkit-scrollbar-thumb:hover { background: var(--scroll-thumb-hover); background-clip: content-box; }

/* ------------------------------------------------------------ app shell -- */
.app {
  position: relative;
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  height: 100vh;
}

/* -------------------------------------------------------------- sidebar -- */
.sidebar {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--line-soft);
  padding: 16px 12px 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 6px 8px 20px;
}

.brand .logo {
  width: 42px;
  height: 42px;
  flex: none;
  border-radius: 12px;
  overflow: hidden;
  background: var(--logo-bg);
  box-shadow: 0 6px 16px -10px rgba(16, 32, 72, .55), var(--logo-ring);
}
.brand .logo img { display: block; width: 100%; height: 100%; }

.brand b { display: block; font-size: 14.5px; font-weight: 650; letter-spacing: -.1px; }
.brand span { display: block; font-size: 11px; color: var(--text-3); letter-spacing: .05em; text-transform: uppercase; }

.nav { display: flex; flex-direction: column; gap: 2px; overflow-y: auto; min-height: 0; flex: 1; }

.nav-label {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--text-3);
  padding: 16px 10px 6px;
}
.nav-label:first-child { padding-top: 2px; }

.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  padding: 9px 11px;
  border: 0;
  border-radius: var(--r-sm);
  background: none;
  color: var(--text-2);
  text-align: left;
  cursor: pointer;
  transition: background .16s var(--ease), color .16s var(--ease);
}
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active {
  background: var(--nav-active-bg);
  color: var(--nav-active-fg);
  font-weight: 600;
  box-shadow: var(--nav-active-ring);
}
.nav-item.active::before {
  content: "";
  position: absolute;
  left: -12px;
  top: 50%;
  width: 3px;
  height: 20px;
  border-radius: 0 4px 4px 0;
  background: linear-gradient(180deg, var(--navy-ink), var(--navy-hi));
  transform: translateY(-50%);
}
.nav-item .badge {
  margin-left: auto;
  min-width: 22px;
  text-align: center;
  padding: 1px 7px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  background: var(--badge-bg);
  color: var(--text-2);
}
.nav-item.active .badge { background: var(--badge-active-bg); color: var(--nav-active-fg); }

.side-foot { padding-top: 12px; }
.status-card {
  border: 1px solid var(--line-soft);
  background: var(--surface-2);
  border-radius: var(--r);
  padding: 11px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.status-line {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-3);
  min-width: 0;
}
.status-line .truncate { min-width: 0; }

/* --------------------------------------------------------------- topbar -- */
.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }

.topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  height: var(--topbar-h);
  flex: none;
  padding: 0 24px;
  border-bottom: 1px solid var(--line-soft);
  background: var(--topbar-bg);
  backdrop-filter: blur(14px);
  z-index: 20;
}
.tb-title h1 { font-size: 17px; font-weight: 650; letter-spacing: -.2px; line-height: 1.2; }
.tb-title .tb-sub { font-size: 12px; color: var(--text-3); margin-top: 1px; }
.spacer { flex: 1; }

.tb-activity {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 12px 5px 10px;
  border-radius: 20px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  font-size: 12px;
  color: var(--text-2);
  white-space: nowrap;
}
.tb-activity .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text-3); }
.tb-activity .dot.live { background: var(--navy-ink); box-shadow: 0 0 0 4px rgba(147, 180, 247, .2); animation: pulse 1.6s infinite; }
.tb-activity .dot.ok { background: var(--ok); box-shadow: 0 0 0 4px rgba(61, 220, 151, .14); }
.tb-activity .dot.err { background: var(--err); box-shadow: 0 0 0 4px rgba(255, 107, 130, .14); }

.version {
  font-size: 11.5px;
  color: var(--text-3);
  padding: 3px 8px;
  border-radius: 20px;
  background: var(--surface-2);
  border: 1px solid var(--line-soft);
}
.version:empty { display: none; }

/* --------------------------------------------------------------- views --- */
.view {
  display: none;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 24px;
}
.view.active { display: block; }
.view > * { animation: fade-up .3s var(--ease) backwards; }
.view > *:nth-child(2) { animation-delay: .04s; }
.view > *:nth-child(3) { animation-delay: .08s; }
.view > *:nth-child(4) { animation-delay: .12s; }

/* ---------------------------------------------------------------- cards -- */
.card {
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-lg);
  padding: 18px;
  margin-bottom: 16px;
  box-shadow: var(--sh-1);
}
.card-head {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.card-head .ct h2 { font-size: 14.5px; font-weight: 650; letter-spacing: -.1px; }
.card-head .ct p { font-size: 12.5px; color: var(--text-3); margin-top: 2px; }
.card-head .ct { min-width: 0; }
.card > p.hint { font-size: 12.5px; color: var(--text-3); margin: 3px 0 14px; }
.card + .card { margin-top: 0; }

.section-title {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--text-3);
  margin: 26px 2px 12px;
}
.section-title:first-child { margin-top: 0; }
.section-title::after { content: ""; flex: 1; height: 1px; background: var(--line-soft); }

/* -------------------------------------------------------------- buttons -- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface-2);
  color: var(--text);
  font-size: 13px;
  font-weight: 550;
  white-space: nowrap;
  cursor: pointer;
  transition: background .15s var(--ease), border-color .15s var(--ease), transform .1s var(--ease);
}
.btn:hover { background: var(--surface-3); border-color: var(--surface-4); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: none; box-shadow: var(--ring); }

.btn.primary {
  background: linear-gradient(120deg, var(--navy-hi) 0%, var(--navy) 55%, var(--navy-deep) 130%);
  border-color: transparent;
  color: #fff;
  font-weight: 620;
  box-shadow: 0 10px 24px -14px rgba(16, 32, 72, .95);
}
.btn.primary:hover { filter: brightness(1.08); }

.btn.ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--surface-2); color: var(--text); }

.btn.danger { color: var(--err); border-color: rgba(255, 107, 130, .28); background: rgba(255, 107, 130, .07); }
.btn.danger:hover { background: rgba(255, 107, 130, .14); border-color: rgba(255, 107, 130, .5); }

.btn.sm { padding: 5px 10px; font-size: 12.5px; border-radius: var(--r-xs); gap: 5px; }
.btn.sm .ico { width: 14px; height: 14px; }
.btn.icon { padding: 8px; }
.btn.icon.sm { padding: 6px; }

.btn:disabled, .btn[aria-disabled="true"] { opacity: .4; cursor: not-allowed; transform: none; }
.btn.loading .ico { animation: spin .9s linear infinite; }

.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.row.tight { gap: 6px; }

/* --------------------------------------------------------------- inputs -- */
.field { display: block; min-width: 0; }
.field > span {
  display: block;
  font-size: 12px;
  font-weight: 550;
  color: var(--text-2);
  margin-bottom: 6px;
}
.field > small { display: block; font-size: 11.5px; color: var(--text-3); margin-top: 5px; }
.field .row { gap: 8px; flex-wrap: nowrap; }

input[type=text], input[type=number], input[type=password], select, textarea {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 9px 11px;
  outline: none;
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease), background .15s var(--ease);
}
input::placeholder, textarea::placeholder { color: var(--text-3); }
input:focus, select:focus, textarea:focus {
  border-color: var(--iris);
  box-shadow: var(--ring);
  background: var(--surface-3);
}
input[type=checkbox] { width: auto; }
textarea { resize: vertical; min-height: 84px; }
select { appearance: none; padding-right: 32px; background-image: var(--select-arrow); background-repeat: no-repeat; background-position: right 10px center; background-size: 15px; }

.grid { display: grid; gap: 14px; }
.grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.grid.cols-6 { grid-template-columns: repeat(auto-fit, minmax(158px, 1fr)); }

/* ---------------------------------------------------------------- chips -- */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 650;
  letter-spacing: .04em;
  text-transform: uppercase;
  background: var(--surface-3);
  color: var(--text-2);
  border: 1px solid var(--line);
  white-space: nowrap;
}
.chip::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; opacity: .85; }
.chip.plain::before { display: none; }
.chip.ok { color: var(--ok); border-color: rgba(61, 220, 151, .3); background: rgba(61, 220, 151, .1); }
.chip.warn { color: var(--warn); border-color: rgba(245, 181, 68, .3); background: rgba(245, 181, 68, .1); }
.chip.err { color: var(--err); border-color: rgba(255, 107, 130, .3); background: rgba(255, 107, 130, .1); }
.chip.info { color: var(--navy-ink); border-color: rgba(147, 180, 247, .32); background: rgba(47, 87, 171, .18); }
.chip.mono {
  font-family: "Cascadia Mono", Consolas, monospace;
  text-transform: none;
  letter-spacing: 0;
  font-weight: 500;
  font-size: 11px;
}
.chip.lg { padding: 5px 12px; font-size: 11.5px; }

.tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: var(--r-xs);
  background: var(--surface-3);
  border: 1px solid var(--line-soft);
  font-size: 11.5px;
  color: var(--text-2);
}

/* --------------------------------------------------------------- stats --- */
.stat {
  position: relative;
  overflow: hidden;
  background: linear-gradient(160deg, var(--surface-2) 0%, var(--surface) 100%);
  border: 1px solid var(--line-soft);
  border-radius: var(--r);
  padding: 15px 16px;
}
.stat::after {
  content: "";
  position: absolute;
  inset: 0 0 auto auto;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: var(--stat-glow);
  transform: translate(34%, -46%);
}
.stat .s-ico {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  background: var(--surface-4);
  color: var(--text-2);
  margin-bottom: 12px;
}
.stat b {
  display: block;
  font-size: 27px;
  font-weight: 700;
  letter-spacing: -.6px;
  line-height: 1.05;
  font-variant-numeric: tabular-nums;
}
.stat span { display: block; font-size: 12px; color: var(--text-3); margin-top: 3px; }
.stat.tone-ok .s-ico { color: var(--ok); background: rgba(61, 220, 151, .12); }
.stat.tone-info .s-ico { color: var(--navy-ink); background: rgba(47, 87, 171, .22); }
.stat.tone-warn .s-ico { color: var(--warn); background: rgba(245, 181, 68, .12); }
.stat.tone-err .s-ico { color: var(--err); background: rgba(255, 107, 130, .12); }
.stat.hot { border-color: rgba(255, 107, 130, .4); }

/* --------------------------------------------------------- hero / intro -- */
.hero {
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  gap: 22px;
  flex-wrap: wrap;
  padding: 22px 24px;
  border-radius: var(--r-lg);
  border: 1px solid var(--hero-border);
  background: var(--hero-bg);
  box-shadow: var(--sh-2);
  margin-bottom: 18px;
}
.hero h2 { font-size: 19px; font-weight: 680; letter-spacing: -.3px; }
.hero p { font-size: 13px; color: var(--text-2); margin-top: 5px; max-width: 62ch; }
.hero .hero-actions { margin-left: auto; display: flex; gap: 10px; flex-wrap: wrap; }

/* ------------------------------------------------------- tool / list rows - */
.stack { display: flex; flex-direction: column; gap: 8px; }

.tool-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--r);
  border: 1px solid var(--line-soft);
  background: var(--surface-2);
}
.tool-row .t-ico { width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; background: var(--surface-4); color: var(--text-2); flex: none; }
.tool-row .t-name { font-size: 13px; font-weight: 600; }
.tool-row .t-meta { font-size: 11.5px; color: var(--text-3); }
.tool-row.missing { border-color: rgba(255, 107, 130, .3); background: rgba(255, 107, 130, .05); }
.tool-row.missing .t-ico { color: var(--err); background: rgba(255, 107, 130, .12); }

/* -------------------------------------------------------------- toolbar -- */
.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 12px 14px;
  border: 1px solid var(--line-soft);
  border-radius: var(--r-lg);
  background: var(--surface);
  margin-bottom: 14px;
}
.seg {
  display: inline-flex;
  padding: 3px;
  gap: 3px;
  border-radius: var(--r-sm);
  background: var(--surface-2);
  border: 1px solid var(--line-soft);
}
.seg button {
  border: 0;
  background: none;
  color: var(--text-3);
  padding: 6px 12px;
  border-radius: 7px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background .15s var(--ease), color .15s var(--ease);
}
.seg button:hover { color: var(--text); }
.seg button.active { background: var(--seg-active-bg); color: var(--seg-active-fg); box-shadow: var(--sh-1); }
.seg button .n { font-size: 11px; opacity: .7; font-variant-numeric: tabular-nums; }

.search { position: relative; display: flex; align-items: center; min-width: 210px; }
.search .ico { position: absolute; left: 11px; color: var(--text-3); pointer-events: none; }
.search input { padding-left: 34px; }

/* ------------------------------------------------------- progress / bars - */
.bar {
  position: relative;
  height: 6px;
  border-radius: 20px;
  background: var(--surface-4);
  overflow: hidden;
}
.bar > i {
  display: block;
  height: 100%;
  border-radius: 20px;
  background: linear-gradient(90deg, var(--navy-hi), var(--navy-ink));
  transition: width .3s var(--ease);
}
.bar.active > i { position: relative; }
.bar.active > i::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .45), transparent);
  animation: sweep 1.6s infinite;
}
.bar.done > i { background: var(--ok); }
.bar.fail > i { background: var(--err); }
.bar.lg { height: 8px; }

/* ----------------------------------------------------------- job cards --- */
.job {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  padding: 14px;
  border: 1px solid var(--line-soft);
  border-radius: var(--r);
  background: var(--surface);
  transition: border-color .16s var(--ease), background .16s var(--ease);
}
.job + .job { margin-top: 9px; }
.job:hover { border-color: var(--line); background: var(--surface-2); }
.job .j-ico {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: var(--surface-3);
  color: var(--text-2);
}
.job.kind-DOWNLOAD .j-ico { color: var(--navy-ink); background: rgba(47, 87, 171, .22); }
.job.kind-UPLOAD .j-ico { color: var(--cyan); background: rgba(79, 209, 224, .12); }
.job.kind-TRANSLATE .j-ico { color: var(--warn); background: rgba(245, 181, 68, .12); }
.job .j-top { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.job .j-title { font-size: 13.5px; font-weight: 620; }
.job .j-sub { font-size: 11.5px; color: var(--text-3); margin-top: 2px; }
.job .j-meta { font-size: 11.5px; color: var(--text-2); margin-top: 7px; display: flex; gap: 12px; flex-wrap: wrap; font-variant-numeric: tabular-nums; }
.job .j-meta span { display: inline-flex; align-items: center; gap: 5px; }
.job .j-actions { display: flex; gap: 6px; align-items: center; }
.job.failed { border-color: rgba(255, 107, 130, .28); }
.job.done { border-color: rgba(61, 220, 151, .22); }

/* ------------------------------------------------------------ library ---- */
.lib-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }

.series-card {
  display: flex;
  gap: 14px;
  padding: 15px;
  border: 1px solid var(--line-soft);
  border-radius: var(--r);
  background: var(--surface);
  transition: border-color .16s var(--ease), transform .16s var(--ease), box-shadow .16s var(--ease);
}
.series-card:hover { border-color: var(--line); transform: translateY(-2px); box-shadow: var(--sh-2); }
.series-card .cover {
  width: 62px;
  height: 88px;
  flex: none;
  position: relative;
  overflow: hidden;
  border-radius: 10px;
  display: grid;
  place-items: center;
  font-size: 22px;
  font-weight: 750;
  color: #fff;
  background: linear-gradient(150deg, var(--navy-hi), var(--navy-deep));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .2);
}
.series-card .cover-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.series-card .sc-body { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 6px; }
.series-card .sc-title { font-size: 14px; font-weight: 650; letter-spacing: -.1px; }
.series-card .sc-sub { font-size: 11.5px; color: var(--text-3); }
.series-card .sc-meta { display: flex; gap: 7px; flex-wrap: wrap; }
.series-card .sc-actions { margin-top: auto; display: flex; gap: 6px; padding-top: 4px; }

/* anime search: poster grid */
.ani-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(148px, 1fr)); gap: 14px; }
.ani-card {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--line-soft);
  border-radius: var(--r);
  background: var(--surface);
  transition: border-color .16s var(--ease), transform .16s var(--ease), box-shadow .16s var(--ease);
}
.ani-card:hover { border-color: var(--line); transform: translateY(-2px); box-shadow: var(--sh-2); }
.ani-card .poster {
  position: relative;
  aspect-ratio: 2 / 3;
  display: grid;
  place-items: center;
  overflow: hidden;
  font-size: 24px;
  font-weight: 750;
  color: #fff;
  background: linear-gradient(150deg, var(--navy-hi), var(--navy-deep));
}
.ani-card .poster img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.ani-card .body { display: flex; flex-direction: column; gap: 7px; padding: 10px 11px 12px; }
.ani-card .name {
  font-size: 12.5px;
  font-weight: 650;
  line-height: 1.3;
  height: 2.6em;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.ani-card .meta { display: flex; gap: 6px; flex-wrap: wrap; min-height: 18px; }

.ep-row {
  display: grid;
  grid-template-columns: 132px minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line-soft);
  border-radius: var(--r);
  background: var(--surface);
  transition: border-color .16s var(--ease), background .16s var(--ease);
}
.ep-row + .ep-row { margin-top: 9px; }
.ep-row:hover { border-color: var(--line); background: var(--surface-2); }
.ep-thumb {
  position: relative;
  width: 132px;
  aspect-ratio: 16 / 9;
  border-radius: 10px;
  overflow: hidden;
  background: linear-gradient(150deg, var(--surface-3), var(--surface-4));
  display: grid;
  place-items: center;
  color: var(--text-3);
  border: 1px solid var(--line-soft);
}
.ep-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ep-thumb .dur {
  position: absolute;
  right: 6px;
  bottom: 6px;
  padding: 1px 6px;
  border-radius: 5px;
  font-size: 10.5px;
  font-weight: 650;
  color: #fff;
  background: rgba(4, 6, 12, .82);
  font-variant-numeric: tabular-nums;
}
.ep-thumb .tagl {
  position: absolute;
  left: 6px;
  top: 6px;
  padding: 1px 7px;
  border-radius: 5px;
  font-size: 10.5px;
  font-weight: 700;
  color: #fff;
  background: rgba(4, 6, 12, .78);
  font-family: "Cascadia Mono", Consolas, monospace;
}
.ep-body { min-width: 0; }
.ep-body h3 { font-size: 14px; font-weight: 630; letter-spacing: -.1px; }
.ep-body .ep-sub { font-size: 11.5px; color: var(--text-3); margin-top: 3px; }
.ep-body .ep-files { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 9px; }
.ep-actions { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }

/* --------------------------------------------------------------- tables -- */
table { width: 100%; border-collapse: collapse; }
th {
  text-align: left;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--text-3);
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  background: var(--surface);
}
td { padding: 10px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
tbody tr { transition: background .14s var(--ease); }
tbody tr:hover { background: var(--surface-2); }
tr:last-child td { border-bottom: 0; }
td .actions { display: flex; gap: 6px; justify-content: flex-end; }

/* ---------------------------------------------------- youtube cards ------ */
.yt-card {
  display: flex;
  gap: 14px;
  padding: 12px;
  border: 1px solid var(--line-soft);
  border-radius: var(--r);
  background: var(--surface);
}
.yt-card .yt-thumb {
  width: 168px;
  aspect-ratio: 16 / 9;
  flex: none;
  border-radius: 10px;
  overflow: hidden;
  background: var(--surface-3);
  border: 1px solid var(--line-soft);
  display: grid;
  place-items: center;
  color: var(--text-3);
}
.yt-card .yt-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.yt-card .yt-body { min-width: 0; flex: 1; }
.yt-card .yt-title { font-size: 14.5px; font-weight: 640; letter-spacing: -.1px; margin-bottom: 4px; }
.yt-card .yt-meta { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 9px; }

.pl-item {
  display: grid;
  grid-template-columns: 34px 92px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 8px;
  border: 1px solid var(--line-soft);
  border-radius: var(--r-sm);
  background: var(--surface);
}
.pl-item:hover { border-color: var(--line); background: var(--surface-2); }
.pl-item .idx {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: var(--surface-3);
  color: var(--text-2);
  font-size: 12px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}
.pl-item .pl-thumb { width: 92px; aspect-ratio: 16 / 9; border-radius: 7px; overflow: hidden; background: var(--surface-3); }
.pl-item .pl-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pl-item .pl-title { font-size: 13px; font-weight: 550; }
.pl-item .pl-sub { font-size: 11px; color: var(--text-3); margin-top: 2px; }

/* --------------------------------------------------------- steps/stepper - */
.steps-nav { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.step-pill {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-3);
}
.step-pill .n {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--surface-3);
  border: 1px solid var(--line);
  font-size: 12px;
}
.step-pill.on { color: var(--text); }
.step-pill.on .n { background: linear-gradient(140deg, var(--navy-hi), var(--navy)); border-color: transparent; color: #fff; }
.step-pill.ok .n { background: rgba(61, 220, 151, .16); border-color: rgba(61, 220, 151, .4); color: var(--ok); }
.step-sep { width: 26px; height: 1px; background: var(--line); }

.newlayout { display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 16px; align-items: start; }
.newlayout .side-col { position: sticky; top: 0; }

/* ----------------------------------------------------------------- misc -- */
.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 44px 20px;
  text-align: center;
  color: var(--text-3);
  font-size: 13px;
}
.empty .e-ico {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: var(--surface-2);
  border: 1px solid var(--line-soft);
  color: var(--text-3);
}
.empty .e-ico .ico { width: 22px; height: 22px; }

.error-text { color: var(--err); font-size: 12.5px; white-space: pre-wrap; word-break: break-word; }
.ok-text { color: var(--ok); font-size: 12.5px; }
.warn-text { color: var(--warn); font-size: 12.5px; }
.dim { color: var(--text-3); }
.muted { color: var(--text-2); }
.mono { font-family: "Cascadia Mono", Consolas, ui-monospace, monospace; font-size: 12px; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.grow { flex: 1; min-width: 0; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.note {
  display: flex;
  gap: 10px;
  padding: 11px 13px;
  border-radius: var(--r-sm);
  border: 1px solid var(--line-soft);
  background: var(--surface-2);
  font-size: 12.5px;
  color: var(--text-2);
}
.note .ico { color: var(--iris); margin-top: 1px; }
.note.warn { border-color: rgba(245, 181, 68, .3); background: rgba(245, 181, 68, .07); }
.note.warn .ico { color: var(--warn); }
.note.err { border-color: rgba(255, 107, 130, .3); background: rgba(255, 107, 130, .07); }
.note.err .ico { color: var(--err); }

.check-list { display: flex; flex-direction: column; gap: 7px; }
.check-item { display: flex; align-items: center; gap: 10px; font-size: 12.5px; color: var(--text-2); }
.check-item .ck {
  width: 19px;
  height: 19px;
  flex: none;
  border-radius: 6px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: transparent;
}
.check-item .ck .ico { width: 12px; height: 12px; stroke-width: 2.6; }
.check-item.done { color: var(--text-3); }
.check-item.done .ck { background: rgba(61, 220, 151, .16); border-color: rgba(61, 220, 151, .4); color: var(--ok); }

/* -------------------------------------------------------------- toasts --- */
#toasts {
  position: fixed;
  right: 18px;
  bottom: 18px;
  display: flex;
  flex-direction: column;
  gap: 9px;
  z-index: 90;
  width: min(430px, calc(100vw - 36px));
}
.toast {
  display: flex;
  gap: 11px;
  align-items: flex-start;
  padding: 12px 13px;
  border-radius: var(--r);
  border: 1px solid var(--line);
  background: linear-gradient(150deg, var(--surface-3), var(--surface-2));
  box-shadow: var(--sh-3);
  animation: slide-in .22s var(--ease);
  font-size: 13px;
}
.toast .t-ico { width: 30px; height: 30px; flex: none; border-radius: 9px; display: grid; place-items: center; background: rgba(47, 87, 171, .24); color: var(--navy-ink); }
.toast.ok .t-ico { background: rgba(61, 220, 151, .14); color: var(--ok); }
.toast.err .t-ico { background: rgba(255, 107, 130, .14); color: var(--err); }
.toast b { display: block; font-weight: 620; font-size: 13px; }
.toast .t-detail { display: block; color: var(--text-3); font-size: 11.5px; margin-top: 3px; word-break: break-word; }
.toast .t-x { margin-left: auto; background: none; border: 0; color: var(--text-3); cursor: pointer; padding: 2px; border-radius: 6px; }
.toast .t-x:hover { color: var(--text); background: var(--surface-4); }

/* --------------------------------------------------------------- modal --- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--backdrop);
  backdrop-filter: blur(6px);
  animation: fade-up .16s var(--ease);
}
.modal.hidden { display: none; }
.sheet {
  width: min(720px, 94vw);
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  box-shadow: var(--sh-3);
  overflow: hidden;
  animation: pop-in .2s var(--ease);
}
.sheet header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 22px;
  border-bottom: 1px solid var(--line-soft);
  flex: none;
}
.sheet header h3 { font-size: 15.5px; font-weight: 660; letter-spacing: -.15px; }
.sheet .body { padding: 20px 22px; overflow-y: auto; }
/* The question a confirmation popup asks, in place of a form. */
.sheet .confirm-body {
  margin: 0;
  font-size: 13.5px;
  line-height: 1.6;
  color: var(--text-2);
}
.sheet .confirm-body b { color: var(--text); font-weight: 600; }
.sheet .confirm-body .mono { color: var(--text-3); }
.sheet footer {
  display: flex;
  gap: 9px;
  justify-content: flex-end;
  padding: 15px 22px;
  border-top: 1px solid var(--line-soft);
  background: var(--sheet-foot-bg);
  flex: none;
}

/* ---------------------------------------------------------------- logs --- */
pre.logs {
  margin: 0;
  padding: 14px 16px;
  max-height: calc(100vh - 300px);
  min-height: 260px;
  overflow: auto;
  border: 1px solid var(--log-border);
  border-radius: var(--r);
  background: var(--log-bg);
  font-family: "Cascadia Mono", Consolas, ui-monospace, monospace;
  font-size: 11.5px;
  line-height: 1.65;
  color: var(--log-fg);
  white-space: pre;
  tab-size: 2;
}
pre.logs.wrap { white-space: pre-wrap; word-break: break-word; }
pre.logs .lv-ERROR, pre.logs .lv-error { color: var(--err); }

/* --------------------------------------------------------- settings tabs - */
.set-layout { display: grid; grid-template-columns: 208px minmax(0, 1fr); gap: 18px; align-items: start; }
.set-nav { display: flex; flex-direction: column; gap: 3px; position: sticky; top: 0; }
.set-nav button {
  text-align: left;
  border: 0;
  background: none;
  color: var(--text-2);
  padding: 9px 12px;
  border-radius: var(--r-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
}
.set-nav button:hover { background: var(--surface-2); color: var(--text); }
.set-nav button.active {
  background: var(--nav-active-bg);
  color: var(--nav-active-fg);
  font-weight: 600;
  box-shadow: var(--nav-active-ring);
}
.set-panel { display: none; }
.set-panel.active { display: block; }

/* --------------------------------------------------------------- footer -- */
.save-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding-top: 16px;
  margin-top: 4px;
  border-top: 1px solid var(--line-soft);
}

/* --------------------------------------------------------- tool setup ---- */
.setup-row {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid var(--line-soft);
  border-radius: var(--r);
  background: var(--surface-2);
}
.setup-row + .setup-row { margin-top: 8px; }
.setup-row .s-ico {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  background: var(--surface-4);
  color: var(--navy-ink);
}
.setup-row.done .s-ico { color: var(--ok); background: rgba(61, 220, 151, .13); }
.setup-row.failed .s-ico { color: var(--err); background: rgba(255, 107, 130, .13); }
.setup-row .s-note { font-size: 11.5px; color: var(--text-3); margin-top: 3px; }
.setup-row .bar { margin-top: 8px; }
.setup-row .pct { font-size: 11.5px; color: var(--text-3); font-variant-numeric: tabular-nums; white-space: nowrap; }

textarea.mono {
  font-family: "Cascadia Mono", Consolas, ui-monospace, monospace;
  font-size: 11.5px;
  line-height: 1.6;
  min-height: 220px;
  white-space: pre;
  overflow: auto;
}

/* ------------------------------------------------------------ responsive - */
@media (max-width: 1180px) {
  .newlayout { grid-template-columns: minmax(0, 1fr); }
  .newlayout .side-col { position: static; }
  .set-layout { grid-template-columns: minmax(0, 1fr); }
  .set-nav { flex-direction: row; flex-wrap: wrap; position: static; }
}
@media (max-width: 940px) {
  :root { --sidebar-w: 74px; }
  .brand-text, .nav-item span.nl, .nav-label, .side-foot { display: none; }
  .nav-item { justify-content: center; padding: 11px; }
  .nav-item .badge { position: absolute; top: 4px; right: 6px; margin: 0; }
  .app { grid-template-columns: var(--sidebar-w) 1fr; }
  .ep-row { grid-template-columns: 108px minmax(0, 1fr); }
  .ep-thumb { width: 108px; }
  .ep-actions { grid-column: 1 / -1; justify-content: flex-start; }
  .job { grid-template-columns: 38px minmax(0, 1fr); }
  .job .j-actions { grid-column: 1 / -1; justify-content: flex-start; }
}

/* ------------------------------------------------------- web sign-in ----- */
.web-login {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--backdrop);
  backdrop-filter: blur(6px);
}
.web-login.hidden { display: none; }
.web-login .wl-card {
  width: min(380px, 92vw);
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 26px;
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
  box-shadow: var(--sh-2);
}
.web-login .wl-logo { width: 44px; height: 44px; object-fit: contain; }
.web-login h2 { font-size: 17px; font-weight: 700; letter-spacing: -.2px; }
.web-login p { font-size: 12.5px; color: var(--text-2); line-height: 1.5; }
.web-login input { width: 100%; }
.web-login .btn { width: 100%; justify-content: center; }

/* The browser build hides desktop-only surfaces. */
html.web-mode [data-view="new"],
html.web-mode #view-new,
html.web-mode #btn-hero-new,
html.web-mode [data-pick],
html.web-mode #btn-open-logs,
html.web-mode [data-act="open-ep"],
html.web-mode [data-set="cookies"],
html.web-mode [data-set="gemini"],
html.web-mode #set-cookies,
html.web-mode #set-gemini { display: none !important; }

.hidden { display: none !important; }
