/* Design tokens follow shadcn/ui's zinc theme. */
:root {
  --background: 0 0% 100%;
  --foreground: 240 10% 3.9%;
  --card: 0 0% 100%;
  --popover: 0 0% 100%;
  --muted: 240 4.8% 95.9%;
  --muted-foreground: 240 3.8% 46.1%;
  --accent: 240 4.8% 95.9%;
  --border: 240 5.9% 90%;
  --input: 240 5.9% 90%;
  --primary: 240 5.9% 10%;
  --primary-foreground: 0 0% 98%;
  --secondary: 240 4.8% 95.9%;
  --destructive: 0 72% 51%;
  --destructive-foreground: 0 0% 98%;
  --success: 142 72% 29%;
  --success-bg: 141 79% 95%;
  --warning: 32 95% 35%;
  --warning-bg: 48 100% 95%;
  --brand: 252 89% 63%;
  --ring: 240 5.9% 10%;
  --radius: 0.5rem;
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --background: 240 10% 3.9%;
    --foreground: 0 0% 98%;
    --card: 240 10% 3.9%;
    --popover: 240 10% 3.9%;
    --muted: 240 3.7% 15.9%;
    --muted-foreground: 240 5% 64.9%;
    --accent: 240 3.7% 15.9%;
    --border: 240 3.7% 15.9%;
    --input: 240 3.7% 15.9%;
    --primary: 0 0% 98%;
    --primary-foreground: 240 5.9% 10%;
    --secondary: 240 3.7% 15.9%;
    --destructive: 0 72% 51%;
    --success: 142 69% 58%;
    --success-bg: 144 61% 12%;
    --warning: 45 93% 58%;
    --warning-bg: 35 70% 12%;
    --ring: 240 4.9% 83.9%;
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.5), 0 4px 6px -4px rgb(0 0 0 / 0.5);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --background: 240 10% 3.9%;
  --foreground: 0 0% 98%;
  --card: 240 10% 3.9%;
  --popover: 240 10% 3.9%;
  --muted: 240 3.7% 15.9%;
  --muted-foreground: 240 5% 64.9%;
  --accent: 240 3.7% 15.9%;
  --border: 240 3.7% 15.9%;
  --input: 240 3.7% 15.9%;
  --primary: 0 0% 98%;
  --primary-foreground: 240 5.9% 10%;
  --secondary: 240 3.7% 15.9%;
  --destructive: 0 72% 51%;
  --success: 142 69% 58%;
  --success-bg: 144 61% 12%;
  --warning: 45 93% 58%;
  --warning-bg: 35 70% 12%;
  --ring: 240 4.9% 83.9%;
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.5), 0 4px 6px -4px rgb(0 0 0 / 0.5);
  color-scheme: dark;
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; border: 0 solid hsl(var(--border)); }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  background: hsl(var(--background));
  color: hsl(var(--foreground));
  font-family: "Geist", "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI Variable Text", "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "rlig" 1, "calt" 1;
}
a { color: inherit; }
h1, h2, h3, h4, p { margin: 0; }
img { display: block; }
[hidden] { display: none !important; }
.icon { flex-shrink: 0; width: 16px; height: 16px; }
.mono { font-family: ui-monospace, "Cascadia Code", "SF Mono", Consolas, monospace; font-size: 13px; }
.muted { color: hsl(var(--muted-foreground)); }
.small { font-size: 12px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.link { text-decoration: underline; text-underline-offset: 4px; }
.link:hover { color: hsl(var(--foreground)); }
:focus-visible { outline: none; box-shadow: 0 0 0 2px hsl(var(--background)), 0 0 0 4px hsl(var(--ring)); }

.container { width: 100%; max-width: 1120px; margin: 0 auto; padding: 0 16px; }
@media (min-width: 640px) { .container { padding: 0 24px; } }
main.container { padding-top: 32px; padding-bottom: 64px; }

/* ---------- header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 40;
  border-bottom: 1px solid hsl(var(--border));
  background: hsl(var(--background) / 0.85);
  backdrop-filter: saturate(180%) blur(8px);
  -webkit-backdrop-filter: saturate(180%) blur(8px);
}
.header-inner { display: flex; align-items: center; gap: 24px; height: 56px; }
.brand { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; text-decoration: none; letter-spacing: -0.01em; }
.brand img { width: 24px; height: 24px; }
.main-nav { display: flex; gap: 4px; flex: 1; overflow-x: auto; scrollbar-width: none; }
.main-nav a {
  display: inline-flex; align-items: center; gap: 8px; white-space: nowrap;
  padding: 6px 12px; border-radius: calc(var(--radius) - 2px);
  font-size: 14px; font-weight: 500; text-decoration: none;
  color: hsl(var(--muted-foreground)); transition: color .15s, background-color .15s;
}
.main-nav a:hover { color: hsl(var(--foreground)); }
.main-nav a.active { color: hsl(var(--foreground)); background: hsl(var(--accent)); }
.header-right { display: flex; align-items: center; gap: 8px; margin-left: auto; }
@media (max-width: 640px) {
  .header-inner { gap: 12px; }
  .brand span { display: none; }
  .main-nav a { padding: 6px 8px; }
  .main-nav a .icon { display: none; }
}

.theme-toggle .icon-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .icon-sun { display: block; }
  :root:not([data-theme="light"]) .theme-toggle .icon-moon { display: none; }
}

/* ---------- avatar & dropdown ---------- */
.avatar {
  display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
  width: 32px; height: 32px; border-radius: 999px;
  background: hsl(var(--muted)); color: hsl(var(--foreground));
  font-size: 13px; font-weight: 600; user-select: none;
}
.avatar.lg { width: 48px; height: 48px; font-size: 18px; }
/* A picture covers the initial; if it fails to load it's removed and the initial shows. */
.avatar { position: relative; overflow: hidden; }
.avatar > img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.avatar.sm { width: 26px; height: 26px; font-size: 11px; }
.avatar.xs { width: 20px; height: 20px; font-size: 10px; vertical-align: -5px; margin-right: 2px; }
.dropdown { position: relative; }
.dropdown > summary { list-style: none; cursor: pointer; }
.dropdown > summary::-webkit-details-marker { display: none; }
.dropdown-menu {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 50; min-width: 12rem;
  padding: 4px; border: 1px solid hsl(var(--border)); border-radius: calc(var(--radius) - 2px);
  background: hsl(var(--popover)); box-shadow: var(--shadow-lg);
  animation: pop .12s ease-out;
}
.dropdown-label { padding: 6px 8px; font-size: 14px; font-weight: 600; display: flex; flex-direction: column; }
.dropdown-label .muted { font-weight: 400; font-size: 12px; }
.dropdown-sep { height: 1px; margin: 4px -4px; background: hsl(var(--border)); }
.dropdown-item {
  display: flex; align-items: center; gap: 8px; width: 100%;
  padding: 6px 8px; border-radius: calc(var(--radius) - 4px);
  background: none; color: inherit; font: inherit; font-size: 14px; text-align: left; cursor: pointer; text-decoration: none;
}
.dropdown-item:hover { background: hsl(var(--accent)); }
.dropdown-item.destructive { color: hsl(var(--destructive)); }
.dropdown-menu form { margin: 0; }
@keyframes pop { from { opacity: 0; transform: scale(.96) translateY(-2px); } }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 36px; padding: 0 16px; white-space: nowrap;
  border-radius: calc(var(--radius) - 2px); border: 1px solid transparent;
  font: inherit; font-size: 14px; font-weight: 500; line-height: 1;
  text-decoration: none; cursor: pointer; user-select: none;
  transition: background-color .15s, color .15s, border-color .15s, opacity .15s;
  background: hsl(var(--primary)); color: hsl(var(--primary-foreground));
}
.btn:disabled { opacity: .5; pointer-events: none; }
.btn-primary { background: hsl(var(--primary)); color: hsl(var(--primary-foreground)); box-shadow: var(--shadow-sm); }
.btn-primary:hover { background: hsl(var(--primary) / .9); }
.btn-outline { background: hsl(var(--background)); color: hsl(var(--foreground)); border-color: hsl(var(--input)); box-shadow: var(--shadow-sm); }
.btn-outline:hover, .btn-ghost:hover { background: hsl(var(--accent)); }
.btn-secondary { background: hsl(var(--secondary)); color: hsl(var(--foreground)); }
.btn-secondary:hover { background: hsl(var(--secondary) / .8); }
.btn-ghost { background: transparent; color: hsl(var(--foreground)); }
.btn-destructive { background: hsl(var(--destructive)); color: hsl(var(--destructive-foreground)); box-shadow: var(--shadow-sm); }
.btn-destructive:hover { background: hsl(var(--destructive) / .9); }
.btn-sm { height: 32px; padding: 0 12px; font-size: 13px; }
.btn-icon { width: 36px; padding: 0; }
.btn-sm.btn-icon { width: 32px; }

/* ---------- forms ---------- */
.field { display: flex; flex-direction: column; gap: 8px; }
.label { font-size: 14px; font-weight: 500; line-height: 1; }
.hint { font-size: 13px; color: hsl(var(--muted-foreground)); }
.input {
  display: flex; width: 100%; height: 36px; padding: 4px 12px;
  border: 1px solid hsl(var(--input)); border-radius: calc(var(--radius) - 2px);
  background: transparent; color: inherit; font: inherit; font-size: 14px;
  box-shadow: var(--shadow-sm); transition: box-shadow .15s;
}
.input::placeholder { color: hsl(var(--muted-foreground)); }
.input:focus-visible { box-shadow: 0 0 0 1px hsl(var(--ring)); }
select.input {
  appearance: none; -webkit-appearance: none; padding-right: 32px; cursor: pointer;
  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='%2371717a' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center;
}
select.input option { background: hsl(var(--popover)); color: hsl(var(--foreground)); }
.input[readonly] { background: hsl(var(--muted) / .5); }
.input-group { display: flex; gap: 8px; }
.input-group .input { flex: 1; min-width: 0; }
.form { display: flex; flex-direction: column; gap: 16px; }
.form-grid { display: grid; gap: 16px; grid-template-columns: 1fr; }
@media (min-width: 640px) { .form-grid.cols-2 { grid-template-columns: 1fr 1fr; } .form-grid .span-2 { grid-column: span 2; } }

/* switch */
.switch {
  appearance: none; -webkit-appearance: none; flex-shrink: 0; margin: 0; cursor: pointer;
  position: relative; width: 36px; height: 20px; border-radius: 999px;
  background: hsl(var(--input)); transition: background-color .15s; box-shadow: var(--shadow-sm);
}
.switch::before {
  content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 999px;
  background: hsl(var(--background)); box-shadow: 0 1px 3px rgb(0 0 0 / .25); transition: transform .15s;
}
.switch:checked { background: hsl(var(--primary)); }
.switch:checked::before { transform: translateX(16px); }
.switch-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; cursor: pointer; }
.switch-row .switch { margin-top: 2px; }
.switch-row > span { display: flex; flex-direction: column; gap: 4px; }
.switch-card { padding: 12px 16px; border: 1px solid hsl(var(--border)); border-radius: var(--radius); }

/* toggle chips (checkbox pills) */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { position: relative; cursor: pointer; }
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip span {
  display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px;
  border: 1px dashed hsl(var(--input)); border-radius: 999px;
  font-size: 13px; font-weight: 500; color: hsl(var(--muted-foreground));
  transition: all .15s;
}
.chip span .icon { width: 14px; height: 14px; display: none; }
.chip:hover span { background: hsl(var(--accent)); }
.chip input:checked + span { border-style: solid; border-color: hsl(var(--primary)); color: hsl(var(--foreground)); background: hsl(var(--accent)); }
.chip input:checked + span .icon { display: block; }
.chip input:focus-visible + span { box-shadow: 0 0 0 2px hsl(var(--background)), 0 0 0 4px hsl(var(--ring)); }

/* ---------- layout bits ---------- */
.page-header { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 24px; }
.page-header h1 { font-size: 28px; font-weight: 700; letter-spacing: -0.025em; line-height: 1.2; }
.page-header p { margin-top: 4px; color: hsl(var(--muted-foreground)); max-width: 60ch; }
.page-title { display: flex; align-items: center; gap: 16px; }
.back-link { display: inline-flex; align-items: center; gap: 4px; margin-bottom: 12px; font-size: 14px; color: hsl(var(--muted-foreground)); text-decoration: none; }
.back-link:hover { color: hsl(var(--foreground)); }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.row-between { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 16px; }
.stack { display: flex; flex-direction: column; gap: 24px; }
.split { display: grid; gap: 24px; grid-template-columns: 1fr; align-items: start; }
@media (min-width: 960px) { .split { grid-template-columns: minmax(0, 1fr) 340px; } }
.mt-4 { margin-top: 16px; }
.separator { height: 1px; background: hsl(var(--border)); margin: 16px 0; }

/* ---------- card ---------- */
.card {
  background: hsl(var(--card)); color: hsl(var(--foreground));
  border: 1px solid hsl(var(--border)); border-radius: calc(var(--radius) + 4px);
  box-shadow: var(--shadow-sm);
}
.card-header { display: flex; flex-direction: column; gap: 6px; padding: 24px; }
.card-header.row-between { flex-direction: row; }
.card-title { font-size: 16px; font-weight: 600; line-height: 1.2; letter-spacing: -0.01em; }
.card-description { font-size: 14px; color: hsl(var(--muted-foreground)); }
.card-content { padding: 0 24px 24px; }
.card-footer { display: flex; align-items: center; gap: 8px; padding: 16px 24px; border-top: 1px solid hsl(var(--border)); }
.card.danger { border-color: hsl(var(--destructive) / .4); }
.card.narrow { max-width: 480px; }

/* ---------- badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 8px; white-space: nowrap;
  border: 1px solid transparent; border-radius: calc(var(--radius) - 2px);
  font-size: 12px; font-weight: 600; line-height: 1;
  background: hsl(var(--primary)); color: hsl(var(--primary-foreground));
}
.badge .icon { width: 12px; height: 12px; }
.badge-secondary { background: hsl(var(--secondary)); color: hsl(var(--foreground)); }
.badge-outline { background: transparent; color: hsl(var(--foreground)); border-color: hsl(var(--border)); font-weight: 500; }
.badge-success { background: hsl(var(--success-bg)); color: hsl(var(--success)); }
.badge-destructive { background: hsl(var(--destructive) / .12); color: hsl(var(--destructive)); }
.badges { display: flex; flex-wrap: wrap; gap: 6px; }

/* ---------- alert ---------- */
.alert {
  display: flex; gap: 12px; padding: 16px; margin-bottom: 24px;
  border: 1px solid hsl(var(--border)); border-radius: var(--radius); background: hsl(var(--card));
}
.alert .icon { margin-top: 2px; }
.alert-title { font-weight: 500; line-height: 1.2; margin-bottom: 4px; }
.alert-desc { font-size: 14px; color: hsl(var(--muted-foreground)); }
.alert-warning { border-color: hsl(var(--warning) / .4); background: hsl(var(--warning-bg)); }
.alert-warning .icon, .alert-warning .alert-title { color: hsl(var(--warning)); }
.alert-warning .alert-desc { color: hsl(var(--foreground)); }
.alert-destructive { border-color: hsl(var(--destructive) / .5); color: hsl(var(--destructive)); }
.alert-destructive .alert-desc { color: hsl(var(--destructive)); }
.alert.compact { margin: 0; padding: 12px; }

/* ---------- table ---------- */
.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { height: 40px; padding: 0 16px; text-align: left; font-weight: 500; color: hsl(var(--muted-foreground)); border-bottom: 1px solid hsl(var(--border)); }
td { padding: 12px 16px; border-bottom: 1px solid hsl(var(--border)); vertical-align: middle; }
tbody tr { transition: background-color .15s; }
tbody tr:hover { background: hsl(var(--muted) / .5); }
tbody tr:last-child td { border-bottom: 0; }
td.actions { text-align: right; width: 1%; white-space: nowrap; }
.user-cell { display: flex; align-items: center; gap: 12px; font-weight: 500; }
.row-link { text-decoration: none; }
.row-link:hover { text-decoration: underline; text-underline-offset: 4px; }
@media (max-width: 640px) {
  .responsive thead { display: none; }
  .responsive tr { display: grid; grid-template-columns: 1fr auto; gap: 8px; padding: 12px 16px; border-bottom: 1px solid hsl(var(--border)); }
  .responsive td { padding: 0; border: 0; }
  .responsive td.actions { grid-row: 1; grid-column: 2; }
  .responsive td.hide-sm { display: none; }
}

/* ---------- empty state ---------- */
.empty-state {
  display: flex; flex-direction: column; align-items: center; text-align: center; gap: 8px;
  padding: 40px 24px; border: 1px dashed hsl(var(--border)); border-radius: var(--radius);
}
.empty-state > .icon { width: 40px; height: 40px; padding: 10px; border-radius: 999px; background: hsl(var(--muted)); color: hsl(var(--muted-foreground)); }
.empty-state h4 { font-size: 16px; font-weight: 600; margin-top: 4px; }
.empty-state p { color: hsl(var(--muted-foreground)); max-width: 42ch; }
.empty-state .row { margin-top: 8px; justify-content: center; }

/* ---------- addon list ---------- */
.addon-list { list-style: none; margin: 0; padding: 0; border: 1px solid hsl(var(--border)); border-radius: var(--radius); }
.addon-item + .addon-item { border-top: 1px solid hsl(var(--border)); }
.addon-row { display: flex; align-items: center; gap: 12px; padding: 12px 16px; }
.addon-item.is-off .addon-logo, .addon-item.is-off .addon-main { opacity: .5; }
.addon-logo {
  position: relative; display: flex; align-items: center; justify-content: center; flex-shrink: 0;
  width: 40px; height: 40px; border-radius: var(--radius); overflow: hidden;
  background: hsl(var(--muted)); border: 1px solid hsl(var(--border));
  font-weight: 600; color: hsl(var(--muted-foreground));
}
.addon-logo img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; background: hsl(var(--muted)); }
.addon-main { flex: 1; min-width: 0; }
.addon-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.addon-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 4px; font-size: 13px; }
.addon-actions { display: flex; align-items: center; gap: 4px; }
.addon-actions form { margin: 0; display: flex; }
.addon-actions .switch { margin-right: 8px; }
.addon-error {
  display: flex; gap: 8px; margin: -4px 16px 12px 68px; padding: 8px 12px;
  border-radius: calc(var(--radius) - 2px); background: hsl(var(--destructive) / .1);
  color: hsl(var(--destructive)); font-size: 13px;
}
.addon-error .icon { margin-top: 2px; }

/* hosts (mirrors) with live health */
.hosts { margin: 0; padding: 0; border: 0; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.hosts-legend { padding: 0; margin-bottom: 4px; font-size: 12px; font-weight: 500; }
.host-option, .host-row {
  display: flex; align-items: center; gap: 8px; min-width: 0;
  padding: 6px 8px; border: 1px solid hsl(var(--border)); border-radius: calc(var(--radius) - 2px);
  font-size: 12px;
}
.host-option { cursor: pointer; display: grid; grid-template-columns: auto minmax(0, 1fr); column-gap: 8px; row-gap: 2px; }
.host-option .host-status { grid-column: 2; }
.host-option:has(input:checked) { border-color: hsl(var(--ring) / .6); background: hsl(var(--accent) / .6); }
.host-option input { margin: 0; accent-color: hsl(var(--primary)); }
.host-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: ui-monospace, "Cascadia Code", Consolas, monospace; }
.host-status { display: inline-flex; align-items: center; gap: 6px; flex-shrink: 0; color: hsl(var(--muted-foreground)); white-space: nowrap; }
.host-status .dot { width: 8px; height: 8px; border-radius: 999px; background: hsl(var(--muted-foreground) / .5); }
.host-status:not([data-state]) .dot { animation: pulse 1.2s ease-in-out infinite; }
.host-status[data-state="ok"] { color: hsl(var(--success)); }
.host-status[data-state="ok"] .dot { background: hsl(var(--success)); }
.host-status[data-state="config"], .host-status[data-state="online"], .host-status[data-state="notorrents"] { color: hsl(var(--warning)); }
.host-status[data-state="config"] .dot, .host-status[data-state="online"] .dot, .host-status[data-state="notorrents"] .dot { background: hsl(var(--warning)); }
.host-status[data-state="blocked"], .host-status[data-state="down"], .host-status[data-state="error"] { color: hsl(var(--destructive)); }
.host-status[data-state="blocked"] .dot, .host-status[data-state="down"] .dot, .host-status[data-state="error"] .dot { background: hsl(var(--destructive)); }
@keyframes pulse { 50% { opacity: .3; } }
.hosts-panel { display: flex; flex-direction: column; gap: 10px; padding-bottom: 16px; margin-bottom: 16px; border-bottom: 1px dashed hsl(var(--border)); }
.hosts-list { display: flex; flex-direction: column; gap: 6px; }
.host-row { background: hsl(var(--background)); }
.host-row form { margin: 0; }
.host-row .btn-sm { height: 26px; padding: 0 10px; font-size: 12px; }
.link-button { background: none; border: 0; padding: 0; font: inherit; color: inherit; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
@media (max-width: 640px) { .addon-error { margin-left: 16px; } }
.addon-edit { padding: 16px; border-top: 1px dashed hsl(var(--border)); background: hsl(var(--muted) / .35); }

/* ---------- browse ---------- */
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 24px; }
.search { position: relative; flex: 1 1 260px; }
.search .icon { position: absolute; left: 12px; top: 10px; color: hsl(var(--muted-foreground)); }
.search .input { padding-left: 36px; }
.toolbar select.input { width: auto; flex: 0 0 auto; }
.toolbar .check { display: inline-flex; align-items: center; gap: 8px; padding: 0 8px; font-size: 14px; cursor: pointer; }
.addon-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.addon-card { display: flex; flex-direction: column; padding: 20px; gap: 12px; transition: border-color .15s, box-shadow .15s; }
.addon-card:hover { border-color: hsl(var(--ring) / .35); }
.addon-card-head { display: flex; align-items: flex-start; gap: 12px; }
.addon-card-head .addon-main { padding-top: 1px; }
.addon-card-head .addon-meta { margin-top: 2px; color: hsl(var(--muted-foreground)); font-size: 12px; }
.addon-card-head .addon-meta .icon { width: 12px; height: 12px; }
.addon-desc {
  font-size: 13px; color: hsl(var(--muted-foreground));
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; word-break: break-word;
}
.addon-card .badges { max-height: 50px; overflow: hidden; }
.addon-card-foot { margin-top: auto; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding-top: 12px; border-top: 1px solid hsl(var(--border)); }
.addon-card-foot form { margin: 0; }
.pagination { display: flex; align-items: center; justify-content: center; gap: 12px; margin-top: 32px; }
.attribution { margin-top: 32px; text-align: center; font-size: 13px; color: hsl(var(--muted-foreground)); }
.steps { margin: 0; padding: 0; list-style: none; counter-reset: step; display: flex; flex-direction: column; gap: 16px; }
.steps > li { position: relative; padding-left: 36px; counter-increment: step; }
.steps > li::before {
  content: counter(step); position: absolute; left: 0; top: -2px;
  display: flex; align-items: center; justify-content: center; width: 24px; height: 24px; border-radius: 999px;
  background: hsl(var(--muted)); font-size: 12px; font-weight: 600;
}
.steps .label { display: block; margin-bottom: 8px; line-height: 1.4; }

/* ---------- services ---------- */
.service-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.service-tag {
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
  width: 40px; height: 40px; border-radius: var(--radius);
  background: hsl(var(--primary)); color: hsl(var(--primary-foreground));
  font-size: 13px; font-weight: 700; letter-spacing: .02em;
}
.service-card.is-off .service-tag { background: hsl(var(--muted)); color: hsl(var(--muted-foreground)); }
.service-head { display: flex; align-items: center; gap: 12px; padding: 20px 20px 0; }
.service-head .addon-main { flex: 1; }
.service-body { padding: 16px 20px; }
.kv { display: flex; justify-content: space-between; gap: 12px; font-size: 13px; }
.kv + .kv { margin-top: 6px; }
.kv > span:last-child { min-width: 0; text-align: right; }
.kv .icon { width: 13px; height: 13px; vertical-align: -2px; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge-warning { background: hsl(var(--warning-bg)); color: hsl(var(--warning)); }
.service-body { display: flex; flex-direction: column; gap: 14px; }
.service-alert { display: flex; gap: 8px; align-items: flex-start; font-size: 13px; color: hsl(var(--destructive)); }
.service-alert .icon { flex-shrink: 0; margin-top: 2px; }
.service-alert.is-warning { color: hsl(var(--warning)); }
.service-expiry { display: flex; gap: 10px; align-items: center; padding: 10px 12px; border-radius: 10px; background: hsl(var(--muted) / .6); }
.service-expiry > .icon { width: 18px; height: 18px; color: hsl(var(--muted-foreground)); flex-shrink: 0; }
.service-expiry-main { font-size: 14px; font-weight: 600; }
.service-expiry.is-soon { background: hsl(var(--warning-bg)); }
.service-expiry.is-soon > .icon, .service-expiry.is-soon .service-expiry-main { color: hsl(var(--warning)); }
.service-usage { display: grid; grid-template-columns: repeat(3, 1fr); border: 1px solid hsl(var(--border)); border-radius: 10px; }
.service-usage > div { display: flex; flex-direction: column; gap: 2px; padding: 8px 12px; min-width: 0; }
.service-usage > div + div { border-left: 1px solid hsl(var(--border)); }
.learned-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.learned-tag { display: inline-flex; align-items: center; gap: 2px; padding: 2px 4px 2px 8px; border-radius: 999px; font-size: 12px; background: hsl(var(--warning-bg)); color: hsl(var(--warning)); }
.learned-x { display: flex; padding: 2px; border: 0; border-radius: 999px; background: none; color: inherit; cursor: pointer; }
.learned-x:hover { background: hsl(var(--warning) / .15); }
.learned-x .icon { width: 12px; height: 12px; }
.refused-list summary { cursor: pointer; }
.refused-list ul { margin: 6px 0; padding-left: 18px; max-height: 160px; overflow: auto; }
.refused-list li { overflow-wrap: anywhere; }
.service-usage b { font-size: 14px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.service-card .card-footer { padding: 12px 20px; justify-content: space-between; }

/* ---------- dialog ---------- */
.dialog {
  width: calc(100% - 32px); max-width: 512px; max-height: calc(100vh - 32px); padding: 0;
  border: 1px solid hsl(var(--border)); border-radius: calc(var(--radius) + 4px);
  background: hsl(var(--background)); color: hsl(var(--foreground)); box-shadow: var(--shadow-lg);
}
.dialog[open] { animation: dialog-in .16s ease-out; }
.dialog::backdrop { background: rgb(0 0 0 / .6); backdrop-filter: blur(2px); animation: fade .16s ease-out; }
.dialog > form, .dialog > .dialog-body { display: flex; flex-direction: column; gap: 20px; padding: 24px; margin: 0; }
.dialog-header { display: flex; flex-direction: column; gap: 6px; padding-right: 24px; }
.dialog-header h2 { font-size: 18px; font-weight: 600; letter-spacing: -0.01em; line-height: 1.2; }
.dialog-header p { font-size: 14px; color: hsl(var(--muted-foreground)); }
.dialog-footer { display: flex; flex-wrap: wrap-reverse; justify-content: flex-end; gap: 8px; }
.dialog-close { position: absolute; top: 14px; right: 14px; opacity: .7; }
.dialog-close:hover { opacity: 1; }
@keyframes dialog-in { from { opacity: 0; transform: translateY(4px) scale(.97); } }
@keyframes fade { from { opacity: 0; } }

/* ---------- toast ---------- */
.toaster { position: fixed; z-index: 100; right: 16px; bottom: 16px; left: 16px; display: flex; flex-direction: column; align-items: flex-end; gap: 8px; pointer-events: none; }
.toast {
  pointer-events: auto; display: flex; align-items: flex-start; gap: 10px; width: 100%; max-width: 380px;
  padding: 14px 16px; border: 1px solid hsl(var(--border)); border-radius: var(--radius);
  background: hsl(var(--popover)); color: hsl(var(--foreground)); box-shadow: var(--shadow-lg);
  font-size: 14px; animation: toast-in .25s cubic-bezier(.21,1.02,.73,1);
  transition: opacity .2s, transform .2s;
}
.toast > .icon { margin-top: 2px; color: hsl(var(--success)); }
.toast-error > .icon { color: hsl(var(--destructive)); }
.toast span { flex: 1; word-break: break-word; }
.toast-close { background: none; border: 0; padding: 2px; margin: -2px -4px 0 0; color: hsl(var(--muted-foreground)); cursor: pointer; border-radius: 4px; }
.toast-close:hover { color: hsl(var(--foreground)); }
.toast.leaving { opacity: 0; transform: translateY(8px); }
@keyframes toast-in { from { opacity: 0; transform: translateY(16px); } }

/* ---------- auth pages ---------- */
.auth-wrap { min-height: calc(100vh - 96px); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 24px; }
.auth-brand { display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center; }
.auth-brand img { width: 44px; height: 44px; }
.auth-brand h1 { font-size: 24px; font-weight: 700; letter-spacing: -0.025em; }
.auth-brand p { color: hsl(var(--muted-foreground)); max-width: 36ch; }
.auth-wrap .card { width: 100%; max-width: 380px; }
.auth-wrap .card-content { padding-top: 24px; }
.auth-wrap .btn { width: 100%; }
.auth-wrap .alert { margin: 0; width: 100%; max-width: 380px; }
.auth-actions { position: fixed; top: 16px; right: 16px; }

/* ---------- downloads (get) ---------- */
.input-sm { height: 32px; font-size: 13px; padding: 2px 10px; }
select.input-sm { width: auto; max-width: 200px; }
.composer-bar > .row { flex-wrap: nowrap; }
.composer-bar > .row:first-child { flex-wrap: wrap; min-width: 0; }
.downloads-head > .row { flex-wrap: nowrap; }
select.input-sm { padding-right: 30px; background-position: right 8px center; }
.hide-xs { }
@media (max-width: 520px) { .hide-xs { display: none; } }

.get-hero { text-align: center; max-width: 640px; margin: 8px auto 28px; }
.get-eyebrow {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; margin-bottom: 14px;
  border: 1px solid hsl(var(--border)); border-radius: 999px; background: hsl(var(--muted) / .5);
  font-size: 12px; font-weight: 500; color: hsl(var(--muted-foreground));
}
.get-eyebrow .icon { width: 13px; height: 13px; color: hsl(var(--brand)); }
.get-hero h1 {
  font-size: clamp(32px, 6vw, 48px); font-weight: 800; letter-spacing: -0.04em; line-height: 1.05;
  background: linear-gradient(180deg, hsl(var(--foreground)) 30%, hsl(var(--foreground) / .6));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.get-hero p { margin-top: 14px; color: hsl(var(--muted-foreground)); font-size: 15px; }
.get-hero code, .composer-hint code { font-size: 12px; padding: 1px 5px; border-radius: 4px; background: hsl(var(--muted)); color: hsl(var(--foreground)); }

.composer {
  position: relative; max-width: 760px; margin: 0 auto;
  border: 1px solid hsl(var(--border)); border-radius: 16px; background: hsl(var(--card));
  box-shadow: 0 1px 2px rgb(0 0 0 / .04), 0 12px 40px -12px hsl(var(--brand) / .25);
  transition: border-color .2s, box-shadow .2s;
}
.composer:focus-within, .composer.dragging {
  border-color: hsl(var(--brand) / .6);
  box-shadow: 0 0 0 3px hsl(var(--brand) / .15), 0 16px 48px -12px hsl(var(--brand) / .4);
}
.composer-body { position: relative; padding: 16px 18px 8px; }
.composer-input {
  display: block; width: 100%; min-height: 72px; max-height: 320px; resize: none; padding: 0; border: 0; outline: none;
  background: transparent; color: inherit; font: 14px/1.6 ui-monospace, "Cascadia Code", "SF Mono", Consolas, monospace;
}
.composer-input::placeholder { color: hsl(var(--muted-foreground)); font-family: inherit; }
.composer-input:focus-visible { box-shadow: none; }
.composer-files { display: flex; flex-wrap: wrap; gap: 6px; padding-top: 10px; }
.file-chip {
  display: inline-flex; align-items: center; gap: 6px; max-width: 100%; height: 28px; padding: 0 6px 0 10px;
  border: 1px solid hsl(var(--border)); border-radius: 999px; background: hsl(var(--muted) / .6); font-size: 12px;
}
.file-chip .icon { width: 13px; height: 13px; color: hsl(var(--brand)); }
.file-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 260px; }
.file-chip button { display: flex; padding: 2px; border: 0; border-radius: 999px; background: none; color: hsl(var(--muted-foreground)); cursor: pointer; }
.file-chip button:hover { background: hsl(var(--accent)); color: hsl(var(--foreground)); }
.drop-overlay {
  position: absolute; inset: 6px; display: none; align-items: center; justify-content: center; gap: 10px;
  border: 2px dashed hsl(var(--brand) / .7); border-radius: 12px; background: hsl(var(--card) / .92);
  color: hsl(var(--brand)); font-weight: 600;
}
.composer.dragging .drop-overlay { display: flex; }
.composer-bar {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px;
  padding: 8px 10px 10px 12px; border-top: 1px solid hsl(var(--border) / .7);
}
.composer-attach { cursor: pointer; color: hsl(var(--muted-foreground)); }
.composer-attach:hover { color: hsl(var(--foreground)); }
.composer-detect { display: inline-flex; flex-wrap: wrap; gap: 6px; font-size: 12px; color: hsl(var(--muted-foreground)); }
.composer-detect .badge { font-weight: 500; }
.composer .btn-primary { min-width: 92px; }
.composer .when-busy, .composer.busy .when-idle { display: none; }
.composer.busy .when-busy { display: inline-flex; align-items: center; gap: 8px; }
.composer .when-idle { display: inline-flex; align-items: center; gap: 8px; }
.composer.busy .when-busy .icon { animation: spin 1s linear infinite; }
.composer-hint { max-width: 760px; margin: 10px auto 0; text-align: center; font-size: 12px; color: hsl(var(--muted-foreground)); }
@keyframes spin { to { transform: rotate(360deg); } }

.downloads { max-width: 960px; margin: 48px auto 0; }
.downloads-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.downloads-head h2 { display: flex; align-items: center; gap: 8px; font-size: 18px; font-weight: 600; letter-spacing: -0.01em; }
.count { display: inline-flex; align-items: center; justify-content: center; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 999px; background: hsl(var(--muted)); font-size: 12px; font-weight: 600; color: hsl(var(--muted-foreground)); }
.seg { display: inline-flex; padding: 3px; gap: 2px; border-radius: calc(var(--radius) + 1px); background: hsl(var(--muted)); }
.seg button {
  display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 10px; border: 0; border-radius: calc(var(--radius) - 2px);
  background: none; color: hsl(var(--muted-foreground)); font: inherit; font-size: 13px; font-weight: 500; cursor: pointer;
}
.seg button span { font-size: 11px; opacity: .8; }
.seg button.active { background: hsl(var(--background)); color: hsl(var(--foreground)); box-shadow: var(--shadow-sm); }
.search-sm { flex: 0 1 200px; width: 200px; }
.search-sm .icon { top: 8px; left: 10px; width: 15px; height: 15px; }
.search-sm .input { padding-left: 32px; }

.dl-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.dl-item {
  border: 1px solid hsl(var(--border)); border-radius: 12px; background: hsl(var(--card));
  transition: border-color .15s, box-shadow .15s;
}
.dl-item:hover { border-color: hsl(var(--ring) / .25); box-shadow: var(--shadow-sm); }
.dl-row { display: flex; align-items: center; gap: 14px; padding: 12px 14px; }
.dl-icon {
  display: flex; align-items: center; justify-content: center; flex-shrink: 0; width: 40px; height: 40px;
  border-radius: 10px; background: hsl(var(--muted)); color: hsl(var(--muted-foreground));
}
.dl-icon { position: relative; background: hsl(var(--k, var(--muted-foreground)) / .13); color: hsl(var(--k, var(--muted-foreground))); }
.dl-icon > .icon { width: 19px; height: 19px; }
/* What the download is, by colour. The status is the pill on the right. */
.kind-video { --k: 262 70% 60%; }
.kind-series { --k: 222 80% 58%; }
.kind-audio { --k: 330 72% 56%; }
.kind-archive { --k: 32 88% 50%; }
.kind-disc { --k: 190 75% 42%; }
.kind-book { --k: 152 55% 40%; }
.kind-image { --k: 12 80% 56%; }
.kind-subtitle { --k: 48 85% 44%; }
.kind-app { --k: 205 15% 45%; }
.kind-text, .kind-file { --k: var(--muted-foreground); }
.status-error .dl-icon { filter: grayscale(.85); opacity: .75; }
.dl-source {
  position: absolute; right: -4px; bottom: -4px; display: flex; align-items: center; justify-content: center;
  width: 20px; height: 20px; border-radius: 999px; background: hsl(var(--card)); color: hsl(var(--foreground) / .75);
  box-shadow: 0 0 0 1px hsl(var(--border));
}
.dl-source .icon { width: 11px; height: 11px; }
.dl-main { flex: 1; min-width: 0; }
.dl-name { font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dl-meta { display: flex; flex-wrap: wrap; gap: 4px 0; margin-top: 3px; font-size: 12px; color: hsl(var(--muted-foreground)); }
.dl-meta span + span::before { content: "·"; margin: 0 7px; opacity: .6; }
.progress { height: 4px; margin-top: 8px; border-radius: 999px; background: hsl(var(--muted)); overflow: hidden; }
.progress-bar {
  height: 100%; min-width: 4%; border-radius: inherit; transition: width .6s ease;
  background: linear-gradient(90deg, hsl(var(--brand)), hsl(var(--brand) / .6), hsl(var(--brand)));
  background-size: 200% 100%; animation: shimmer 1.6s linear infinite;
}
.status-queued .progress-bar { width: 30% !important; opacity: .5; animation: indeterminate 1.4s ease-in-out infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }
@keyframes indeterminate { 0% { transform: translateX(-100%); } 100% { transform: translateX(340%); } }
.dl-error { display: flex; gap: 6px; margin-top: 6px; font-size: 12px; color: hsl(var(--destructive)); }
.dl-error .icon { width: 13px; height: 13px; margin-top: 2px; }
.dl-status { flex-shrink: 0; }
.pill {
  display: inline-flex; align-items: center; gap: 5px; height: 24px; padding: 0 9px; border-radius: 999px;
  font-size: 12px; font-weight: 600; white-space: nowrap;
}
.pill .icon { width: 13px; height: 13px; }
.pill-ready { background: hsl(var(--success-bg)); color: hsl(var(--success)); }
.pill-active { background: hsl(var(--brand) / .12); color: hsl(var(--brand)); font-variant-numeric: tabular-nums; }
.pill-active .icon { animation: spin 1s linear infinite; }
.pill-queued { background: hsl(var(--muted)); color: hsl(var(--muted-foreground)); }
.pill-error { background: hsl(var(--destructive) / .1); color: hsl(var(--destructive)); }
.dl-actions { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }
.dl-actions form { margin: 0; display: flex; }
.dl-files { margin: 0 14px 12px 68px; border: 1px solid hsl(var(--border)); border-radius: 10px; overflow: hidden; }
.dl-file { display: flex; align-items: center; gap: 10px; padding: 6px 6px 6px 12px; font-size: 13px; }
.dl-file + .dl-file { border-top: 1px solid hsl(var(--border)); }
.dl-file:hover { background: hsl(var(--muted) / .4); }
.dl-file-icon { display: flex; color: hsl(var(--k, var(--muted-foreground))); }
.dl-file-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dl-file-size { flex-shrink: 0; font-size: 12px; color: hsl(var(--muted-foreground)); font-variant-numeric: tabular-nums; }
@media (max-width: 640px) {
  .dl-row { flex-wrap: wrap; gap: 10px 12px; }
  .dl-main { flex-basis: calc(100% - 52px); }
  .dl-status { margin-left: 52px; }
  .dl-actions { margin-left: auto; }
  .dl-files { margin-left: 14px; }
  .downloads-head > .row { width: 100%; flex-wrap: wrap; }
  .search-sm { flex: 1 1 140px; width: auto; }
}

/* ---------- downloads: paste / search ---------- */
.mode-switch { display: flex; justify-content: center; margin: 0 auto 16px; }
.seg-lg { padding: 4px; border-radius: 12px; }
.seg-lg button { height: 34px; padding: 0 16px; border-radius: 9px; font-size: 14px; }
.seg-lg button .icon { width: 15px; height: 15px; }

.finder {
  max-width: 760px; margin: 0 auto; overflow: hidden;
  border: 1px solid hsl(var(--border)); border-radius: 16px; background: hsl(var(--card));
  box-shadow: 0 1px 2px rgb(0 0 0 / .04), 0 12px 40px -12px hsl(var(--brand) / .25);
  transition: border-color .2s, box-shadow .2s;
}
.finder:focus-within { border-color: hsl(var(--brand) / .6); box-shadow: 0 0 0 3px hsl(var(--brand) / .15), 0 16px 48px -12px hsl(var(--brand) / .4); }
.finder-bar { display: flex; align-items: center; gap: 10px; padding: 10px 12px 10px 18px; border-bottom: 1px solid hsl(var(--border) / .7); }
.finder-query { position: relative; flex: 1; display: flex; align-items: center; gap: 12px; min-width: 0; }
.finder-query > .icon { flex-shrink: 0; width: 18px; height: 18px; color: hsl(var(--muted-foreground)); }
.finder-input { flex: 1; min-width: 0; height: 40px; border: 0; outline: none; background: transparent; color: inherit; font: inherit; font-size: 16px; }
.finder-input::placeholder { color: hsl(var(--muted-foreground)); }
.finder-input:focus-visible { outline: none; box-shadow: none; }
.finder-input::-webkit-search-cancel-button { cursor: pointer; }
.finder-spin { display: flex; color: hsl(var(--brand)); }
.finder-spin .icon, .finder-loading p .icon, .btn.is-busy .icon { animation: spin 1s linear infinite; }
.finder-body { padding: 16px; min-height: 120px; }
.finder-hint { padding: 22px 8px; text-align: center; font-size: 13px; color: hsl(var(--muted-foreground)); }
.finder-hint strong { color: hsl(var(--foreground)); font-weight: 500; }
.finder-note { padding: 18px 4px 4px; text-align: center; font-size: 13px; color: hsl(var(--muted-foreground)); }
.finder-empty { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 28px 12px; text-align: center; }
.finder-empty > .icon { width: 40px; height: 40px; padding: 10px; border-radius: 999px; background: hsl(var(--muted)); color: hsl(var(--muted-foreground)); }
.finder-empty h4 { font-size: 15px; font-weight: 600; margin-top: 4px; }
.finder-empty p { font-size: 13px; color: hsl(var(--muted-foreground)); max-width: 46ch; }
.finder > .finder-empty { padding: 36px 16px; }

.title-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 14px; }
.title-card {
  display: flex; flex-direction: column; gap: 4px; padding: 0; border: 0; background: none; color: inherit;
  font: inherit; text-align: left; cursor: pointer; min-width: 0;
}
.title-poster {
  position: relative; display: flex; align-items: center; justify-content: center; aspect-ratio: 2 / 3; margin-bottom: 4px;
  border-radius: 10px; overflow: hidden; background: hsl(var(--muted)); color: hsl(var(--muted-foreground));
  box-shadow: 0 0 0 1px hsl(var(--border)); transition: transform .15s, box-shadow .15s;
}
.title-poster img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.title-card:hover .title-poster, .title-card:focus-visible .title-poster { transform: translateY(-2px); box-shadow: 0 0 0 2px hsl(var(--brand) / .7), 0 10px 24px -8px rgb(0 0 0 / .35); }
.title-card:focus-visible { outline: none; }
.title-name { font-size: 13px; font-weight: 600; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.title-sub { display: flex; align-items: center; gap: 6px; font-size: 12px; color: hsl(var(--muted-foreground)); }
.title-sub .badge { padding: 0 6px; font-size: 10px; line-height: 16px; }

.pick-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.pick-poster { width: 40px; height: 60px; flex-shrink: 0; border-radius: 6px; object-fit: cover; box-shadow: 0 0 0 1px hsl(var(--border)); }
.pick-title { min-width: 0; }
.pick-title h3 { font-size: 17px; font-weight: 700; letter-spacing: -0.015em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pick-title span { font-size: 12px; color: hsl(var(--muted-foreground)); }

.fchips { display: flex; flex-wrap: wrap; gap: 6px; }
.fchip {
  display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 11px; border: 1px solid hsl(var(--border));
  border-radius: 999px; background: hsl(var(--background)); color: hsl(var(--muted-foreground));
  font: inherit; font-size: 12px; font-weight: 500; white-space: nowrap; cursor: pointer; transition: background .15s, color .15s, border-color .15s;
}
.fchip:hover { color: hsl(var(--foreground)); border-color: hsl(var(--ring) / .35); }
.fchip span { font-size: 11px; opacity: .7; font-variant-numeric: tabular-nums; }
.fchip.active { background: hsl(var(--foreground)); border-color: hsl(var(--foreground)); color: hsl(var(--background)); }
.season-tabs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 10px; scrollbar-width: thin; }
.episode-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px; max-height: 196px; overflow-y: auto; padding: 2px; scrollbar-width: thin; }
.episode {
  display: flex; align-items: center; gap: 8px; min-width: 0; height: 36px; padding: 0 10px; border: 1px solid hsl(var(--border));
  border-radius: 8px; background: hsl(var(--background)); color: inherit; font: inherit; font-size: 12px; text-align: left; cursor: pointer;
}
.episode:hover { border-color: hsl(var(--ring) / .35); background: hsl(var(--muted) / .5); }
.episode.active { border-color: hsl(var(--brand)); background: hsl(var(--brand) / .1); box-shadow: 0 0 0 1px hsl(var(--brand)); }
.episode.future { opacity: .5; }
.episode-season { border-style: dashed; font-weight: 600; }
.episode-season .icon { flex-shrink: 0; width: 15px; height: 15px; color: hsl(var(--brand)); }
.episode-season.active { border-style: solid; }
.pack-tag { display: inline-flex; align-items: center; gap: 4px; color: hsl(var(--brand)); font-weight: 600; }
.pack-tag .icon { width: 12px; height: 12px; }
.ep-num { flex-shrink: 0; font-weight: 700; font-variant-numeric: tabular-nums; color: hsl(var(--muted-foreground)); }
.episode.active .ep-num { color: hsl(var(--brand)); }
.ep-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
[data-torrents] { margin-top: 4px; }
.episode-grid + [data-torrents] { margin-top: 16px; padding-top: 14px; border-top: 1px solid hsl(var(--border) / .7); }
.episode-grid + [data-torrents]:has(.finder-note) { border-top: 0; padding-top: 0; margin-top: 0; }

.finder-loading p { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; font-size: 13px; color: hsl(var(--muted-foreground)); }
.finder-loading p .icon { width: 14px; height: 14px; color: hsl(var(--brand)); }
.skel-row { display: flex; flex-direction: column; gap: 7px; padding: 12px; border: 1px solid hsl(var(--border) / .7); border-radius: 10px; }
.skel-row + .skel-row { margin-top: 6px; }
.skel-row span { height: 10px; border-radius: 6px; background: linear-gradient(90deg, hsl(var(--muted)), hsl(var(--muted) / .4), hsl(var(--muted))); background-size: 200% 100%; animation: shimmer 1.4s linear infinite; }
.skel-row span:first-child { width: 70%; height: 12px; }
.skel-row span:last-child { width: 40%; }

.sources { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-bottom: 12px; font-size: 12px; color: hsl(var(--muted-foreground)); }
.source { display: inline-flex; align-items: center; gap: 5px; cursor: default; }
.source .icon { width: 13px; height: 13px; }
.source.ok .icon { color: hsl(var(--success)); }
.source.bad { opacity: .75; }
.source.bad .icon { color: hsl(var(--destructive)); }
.source b { color: hsl(var(--foreground)); font-weight: 600; font-variant-numeric: tabular-nums; }
.torrent-tools { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.torrent-tools .fchips { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
.torrent-tools select { flex-shrink: 0; }
.torrent-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; max-height: 520px; overflow-y: auto; scrollbar-width: thin; }
.torrent {
  display: flex; align-items: center; gap: 12px; padding: 10px 10px 10px 12px;
  border: 1px solid hsl(var(--border)); border-radius: 10px; transition: border-color .15s, background .15s;
}
.torrent:hover { border-color: hsl(var(--ring) / .25); background: hsl(var(--muted) / .3); }
.torrent-main { flex: 1; min-width: 0; }
.torrent-title { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.torrent .dl-meta { flex-wrap: nowrap; overflow: hidden; }
.torrent .dl-meta span { white-space: nowrap; }
.torrent-file { overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.seeders { display: inline-flex; align-items: center; gap: 3px; }
.seeders .icon { width: 12px; height: 12px; }
.torrent .btn, .torrent .pill { flex-shrink: 0; }
.q-badge {
  flex-shrink: 0; width: 50px; padding: 4px 0; border-radius: 6px; text-align: center;
  font-size: 11px; font-weight: 700; letter-spacing: .02em; background: hsl(var(--muted)); color: hsl(var(--muted-foreground));
}
.q-2160p { background: linear-gradient(135deg, hsl(var(--brand)), hsl(var(--brand) / .7)); color: #fff; }
.q-1440p, .q-1080p { background: hsl(var(--brand) / .14); color: hsl(var(--brand)); }
.q-720p { background: hsl(var(--success-bg)); color: hsl(var(--success)); }
@media (max-width: 640px) {
  .finder-bar { padding-left: 14px; flex-wrap: wrap; }
  .finder-bar select { flex: 1 1 100%; max-width: none; }
  .finder-body { padding: 12px; }
  .title-grid { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px; }
  .torrent { flex-wrap: wrap; }
  .torrent-main { flex-basis: calc(100% - 62px); }
  .torrent .btn, .torrent .pill { margin-left: auto; }
  .torrent-tools { flex-wrap: wrap; }
}

/* ---------- stream rules ---------- */
#rules { scroll-margin-top: 80px; }
.rules { display: flex; flex-direction: column; gap: 0; }
.rules-section { display: grid; grid-template-columns: 180px 1fr; gap: 12px 24px; padding: 18px 0; border-top: 1px solid hsl(var(--border)); }
.rules-section:first-of-type { border-top: 0; padding-top: 0; }
.rules-section > :not(.rules-label) { grid-column: 2; min-width: 0; }
.rules-label { display: flex; flex-direction: column; gap: 6px; grid-row: span 3; }
.label-sm { font-size: 12px; font-weight: 500; color: hsl(var(--muted-foreground)); }

.sort-steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.sort-step { display: grid; grid-template-columns: 40px minmax(0, 240px) 1fr; align-items: center; gap: 10px; transition: opacity .15s; }
.sort-step.is-off { opacity: .45; }
.sort-num {
  display: inline-flex; align-items: center; justify-content: center; height: 24px; border-radius: 999px;
  background: hsl(var(--muted)); font-size: 11px; font-weight: 600; color: hsl(var(--muted-foreground));
}
.sort-step:first-child .sort-num { background: hsl(var(--brand) / .14); color: hsl(var(--brand)); }
.sort-step select { height: 36px; }
.sort-hint { font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.toggle-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.toggle-chip { position: relative; cursor: pointer; }
.toggle-chip input { position: absolute; opacity: 0; pointer-events: none; }
.toggle-chip > span {
  display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 12px; border: 1px dashed hsl(var(--border));
  border-radius: 999px; font-size: 13px; font-weight: 500; color: hsl(var(--muted-foreground)); text-decoration: line-through;
  transition: background .15s, color .15s, border-color .15s;
}
.toggle-chip > span .icon { width: 13px; height: 13px; display: none; }
.toggle-chip input:checked + span { border-style: solid; border-color: hsl(var(--brand) / .5); background: hsl(var(--brand) / .1); color: hsl(var(--foreground)); text-decoration: none; }
.toggle-chip input:checked + span .icon { display: block; color: hsl(var(--brand)); }
.toggle-chip input:focus-visible + span { box-shadow: 0 0 0 2px hsl(var(--ring)); }
.toggle-chip:hover > span { border-color: hsl(var(--ring) / .5); }
.rules-section .switch-row { max-width: 560px; }

.limits { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 12px; max-width: 720px; }
.limits .field { gap: 6px; }
.input-unit { position: relative; display: flex; }
.input-unit .input { padding-right: 38px; }
.input-unit > span { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); font-size: 12px; color: hsl(var(--muted-foreground)); pointer-events: none; }

.rules-preview { margin-top: 4px; padding: 16px; border: 1px solid hsl(var(--border)); border-radius: 12px; background: hsl(var(--muted) / .35); }
.rules-preview-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.rules-preview-head > div:first-child { display: flex; flex-direction: column; gap: 4px; }
.rules-title { position: relative; flex: 0 1 280px; width: 280px; }
.rules-suggest {
  position: absolute; z-index: 20; top: calc(100% + 6px); left: 0; right: 0; max-height: 340px; overflow-y: auto; padding: 4px;
  border: 1px solid hsl(var(--border)); border-radius: 10px; background: hsl(var(--popover, var(--card))); box-shadow: var(--shadow-lg, 0 10px 30px rgb(0 0 0 / .25));
}
.rules-suggest button {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 6px; border: 0; border-radius: 6px; background: none;
  color: inherit; font: inherit; text-align: left; cursor: pointer;
}
.rules-suggest button:hover, .rules-suggest button:focus-visible { background: hsl(var(--accent)); outline: none; }
.rules-suggest img, .rules-suggest .ph { width: 28px; height: 42px; flex-shrink: 0; border-radius: 4px; object-fit: cover; background: hsl(var(--muted)); }
.rules-suggest b { display: block; font-size: 13px; font-weight: 600; }
.rules-suggest small { font-size: 12px; color: hsl(var(--muted-foreground)); }
.rules-suggest .hint { padding: 8px; }
.rules-preview-body { transition: opacity .15s; }
.rules-preview-body.is-loading { opacity: .5; }
.pv-stats { margin-bottom: 10px; font-size: 13px; }
.pv-stats .hint { font-size: 12px; margin-top: 2px; }
.pv-list { list-style: none; margin: 0; padding: 0; counter-reset: pv; display: flex; flex-direction: column; gap: 4px; max-height: 420px; overflow-y: auto; scrollbar-width: thin; }
.pv-list li { counter-increment: pv; display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 8px; background: hsl(var(--card)); border: 1px solid hsl(var(--border) / .7); }
.pv-list li::before { content: counter(pv); width: 18px; flex-shrink: 0; text-align: right; font-size: 11px; font-weight: 600; color: hsl(var(--muted-foreground)); font-variant-numeric: tabular-nums; }
.pv-list .q-badge { width: 44px; padding: 3px 0; font-size: 10px; }
.pv-main { min-width: 0; flex: 1; }
.pv-title { font-size: 13px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pv-more { margin-top: 8px; text-align: center; }
.rules-actions { display: flex; justify-content: flex-end; gap: 8px; padding-top: 18px; }
@media (max-width: 720px) {
  .rules-section { grid-template-columns: 1fr; }
  .rules-section > :not(.rules-label) { grid-column: 1; }
  .rules-label { grid-row: auto; }
  .sort-step { grid-template-columns: 40px 1fr; }
  .sort-hint { grid-column: 2; white-space: normal; }
  .rules-title { flex: 1 1 100%; width: auto; }
}

/* search: stream rules */
.rules-note { display: flex; align-items: center; gap: 6px; margin: -2px 0 10px; font-size: 12px; color: hsl(var(--muted-foreground)); }
.rules-note .icon { width: 13px; height: 13px; color: hsl(var(--success)); flex-shrink: 0; }
.hidden-note {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; margin-top: 10px; padding: 8px 8px 8px 12px;
  border: 1px dashed hsl(var(--border)); border-radius: 10px; font-size: 13px;
}
.hidden-note > span { display: inline-flex; align-items: center; gap: 6px; }
.hidden-note .icon { width: 14px; height: 14px; color: hsl(var(--muted-foreground)); }
.hidden-note .hint { font-size: 12px; }
.torrent.is-hidden { opacity: .55; border-style: dashed; }
.hidden-why { display: inline-flex; align-items: center; gap: 4px; color: hsl(var(--destructive)); font-weight: 500; }
.hidden-why .icon { width: 12px; height: 12px; }

/* stream names: Stremio-like rows */
.name-options { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 10px; }
.name-option { position: relative; cursor: pointer; min-width: 0; }
.name-option input { position: absolute; opacity: 0; pointer-events: none; }
.name-option-body {
  display: flex; flex-direction: column; gap: 10px; height: 100%; padding: 12px; border: 1px solid hsl(var(--border)); border-radius: 12px;
  transition: border-color .15s, box-shadow .15s;
}
.name-option:hover .name-option-body { border-color: hsl(var(--ring) / .4); }
.name-option input:checked + .name-option-body { border-color: hsl(var(--brand)); box-shadow: 0 0 0 1px hsl(var(--brand)); }
.name-option input:focus-visible + .name-option-body { box-shadow: 0 0 0 3px hsl(var(--ring) / .4); }
.name-option-head { display: flex; flex-direction: column; gap: 2px; font-size: 14px; }
.name-option-head .hint { font-size: 12px; }
/* Stremio's own stream list is dark whatever the site theme. */
.stremio-row {
  display: flex; gap: 12px; align-items: flex-start; min-width: 0; padding: 10px 12px; border-radius: 10px;
  background: #19172b; color: #fff; font-size: 12px; line-height: 1.45;
}
.stremio-name { flex: 0 0 92px; white-space: pre-line; font-weight: 700; font-size: 12px; color: #fff; }
.stremio-desc { flex: 1; min-width: 0; white-space: pre-line; color: rgb(255 255 255 / .72); overflow-wrap: anywhere; }
.pv-list li { padding: 0; border: 0; background: none; align-items: flex-start; }
.pv-list li::before { padding-top: 12px; }
.pv-list .stremio-row { flex: 1; }

/* rules: unsaved changes */
.rules-actions { align-items: center; flex-wrap: wrap; }
.rules-dirty { display: inline-flex; align-items: center; gap: 6px; margin-right: auto; font-size: 13px; font-weight: 500; color: hsl(var(--warning, 38 92% 50%)); }
.rules-dirty[hidden] { display: none; }
.rules-dirty .icon { width: 14px; height: 14px; flex-shrink: 0; }
.rules.is-dirty .rules-actions .btn-primary { box-shadow: 0 0 0 3px hsl(var(--brand) / .35); }
.rules-actions { position: sticky; bottom: 0; z-index: 5; margin: 0 -24px -24px; padding: 14px 24px; border-radius: 0 0 var(--radius) var(--radius); background: hsl(var(--card) / .92); backdrop-filter: blur(6px); }
.rules.is-dirty .rules-actions { border-top: 1px solid hsl(var(--border)); }

/* ---------- debrid service logos ---------- */
/* Logos are drawn on a white tile so dark marks stay visible in dark mode. */
.svc-logo { width: 14px; height: 14px; flex-shrink: 0; border-radius: 3px; background: #fff; object-fit: contain; }
.badge .svc-logo { margin-left: -1px; }
.service-tag:has(img) { padding: 4px; background: #fff; box-shadow: inset 0 0 0 1px hsl(var(--border)); }
.service-tag img { width: 100%; height: 100%; object-fit: contain; border-radius: calc(var(--radius) - 3px); }
.service-card.is-off .service-tag img { filter: grayscale(1); opacity: .6; }
.kind-picker { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.kind-option { position: relative; cursor: pointer; }
.kind-option input { position: absolute; opacity: 0; pointer-events: none; }
.kind-option > span {
  display: flex; align-items: center; gap: 10px; height: 44px; padding: 0 12px; border: 1px solid hsl(var(--border)); border-radius: var(--radius);
  font-size: 14px; font-weight: 500; transition: border-color .15s, box-shadow .15s, background .15s;
}
.kind-option img { width: 26px; height: 26px; padding: 2px; border-radius: 6px; background: #fff; box-shadow: 0 0 0 1px hsl(var(--border)); object-fit: contain; }
.kind-option:hover > span { border-color: hsl(var(--ring) / .4); }
.kind-option input:checked + span { border-color: hsl(var(--brand)); background: hsl(var(--brand) / .08); box-shadow: 0 0 0 1px hsl(var(--brand)); }
.kind-option input:focus-visible + span { box-shadow: 0 0 0 3px hsl(var(--ring) / .4); }

/* ---------- Discord sign-in ---------- */
.btn-discord { background: #5865f2; color: #fff; border-color: #5865f2; }
.btn-discord:hover { background: #4752c4; border-color: #4752c4; color: #fff; }
.btn-discord .icon { width: 18px; height: 18px; }
.auth-wrap .btn-discord { width: 100%; height: 40px; }
.auth-or { display: flex; align-items: center; gap: 12px; margin: 18px 0; font-size: 12px; color: hsl(var(--muted-foreground)); }
.auth-or::before, .auth-or::after { content: ""; flex: 1; height: 1px; background: hsl(var(--border)); }
.discord-mark { display: inline-flex; align-items: center; justify-content: center; width: 26px; height: 26px; border-radius: 7px; background: #5865f2; color: #fff; flex-shrink: 0; }
.discord-mark .icon { width: 16px; height: 16px; }
.discord-mark.sm { width: 18px; height: 18px; border-radius: 5px; margin-left: 6px; }
.discord-mark.sm .icon { width: 11px; height: 11px; }
.discord-linked { display: flex; align-items: center; gap: 10px; padding: 8px 8px 8px 10px; border: 1px solid hsl(var(--border)); border-radius: var(--radius); font-size: 14px; }
.discord-linked > span:nth-child(2) { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.settings { max-width: 760px; }
.card-header.row-between { flex-wrap: nowrap; }
.card-header.row-between > div:first-child { flex: 1; min-width: 0; }
.setup-steps { list-style: none; margin: 0; padding: 0; counter-reset: step; display: flex; flex-direction: column; gap: 22px; }
.setup-steps > li { counter-increment: step; position: relative; padding-left: 40px; display: flex; flex-direction: column; gap: 10px; }
.setup-steps > li::before {
  content: counter(step); position: absolute; left: 0; top: -3px; display: flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; border-radius: 999px; background: hsl(var(--muted)); font-size: 12px; font-weight: 700; color: hsl(var(--muted-foreground));
}
.setup-steps .hint b { color: hsl(var(--foreground)); font-weight: 600; }
.copy-field { display: flex; gap: 8px; }
.copy-field .input { flex: 1; min-width: 0; font-size: 13px; }
.settings-save { align-items: center; padding-top: 18px; border-top: 1px solid hsl(var(--border)); }
@media (max-width: 520px) { .setup-steps > li { padding-left: 0; } .setup-steps > li::before { position: static; margin-bottom: 2px; } }

/* ---------- activity ---------- */
.seg-link { display: inline-flex; align-items: center; height: 28px; padding: 0 12px; border-radius: calc(var(--radius) - 2px); font-size: 13px; font-weight: 500; color: hsl(var(--muted-foreground)); text-decoration: none; }
.seg-link:hover { color: hsl(var(--foreground)); }
.seg-link.active { background: hsl(var(--background)); color: hsl(var(--foreground)); box-shadow: var(--shadow-sm); }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat { display: flex; flex-direction: column; gap: 6px; padding: 18px 20px; }
.stat-label { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 500; color: hsl(var(--muted-foreground)); }
.stat-label .icon { width: 15px; height: 15px; }
.stat-value { font-size: 28px; font-weight: 700; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.stat-sub { font-size: 12px; color: hsl(var(--muted-foreground)); }
.text-danger { color: hsl(var(--destructive)); }
@media (min-width: 960px) { .split.split-even { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); } }
.activity { display: flex; flex-direction: column; gap: 24px; }
.activity .stat-grid { margin-bottom: 0; }
th.num, td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
@media (max-width: 640px) { th.hide-sm, td.hide-sm { display: none; } }

.bars { display: flex; align-items: flex-end; gap: 4px; height: 160px; padding-top: 8px; }
.bars.dense { gap: 1px; }
.bar { position: relative; flex: 1; height: 100%; display: flex; align-items: flex-end; border-radius: 4px 4px 0 0; cursor: default; }
.bar:hover { background: hsl(var(--muted) / .6); }
.bar-fill { width: 100%; min-height: 2px; border-radius: 4px 4px 0 0; background: linear-gradient(180deg, hsl(var(--brand)), hsl(var(--brand) / .55)); transition: height .4s ease; }
.bars-axis { display: flex; justify-content: space-between; margin-top: 8px; font-size: 12px; color: hsl(var(--muted-foreground)); }

.live-dot { width: 9px; height: 9px; border-radius: 999px; background: hsl(var(--muted-foreground)); }
[data-live].is-live .live-dot { background: #22c55e; box-shadow: 0 0 0 0 rgb(34 197 94 / .6); animation: pulse 1.6s infinite; }
@keyframes pulse { 70% { box-shadow: 0 0 0 8px rgb(34 197 94 / 0); } 100% { box-shadow: 0 0 0 0 rgb(34 197 94 / 0); } }
.live-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.live-list li { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 1px solid hsl(var(--border)); border-radius: 10px; }
.live-main { flex: 1; min-width: 0; }
.live-file { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.live-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; margin-top: 2px; font-size: 12px; color: hsl(var(--muted-foreground)); }
.live-meta > span { display: inline-flex; align-items: center; }
.live-meta img { display: inline-block; width: 13px; height: 13px; border-radius: 3px; background: #fff; margin-right: 5px; }
.live-rate { flex-shrink: 0; text-align: right; font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; }
.live-rate small { display: block; font-weight: 400; font-size: 11px; color: hsl(var(--muted-foreground)); }
.live-list li { align-items: flex-start; }
.live-list li > .avatar { margin-top: 2px; }
.live-list li.is-idle { opacity: .65; }
.live-filename { display: block; font-size: 11px; font-weight: 400; color: hsl(var(--muted-foreground)); overflow: hidden; text-overflow: ellipsis; }
.live-paused { color: hsl(var(--warning, 38 92% 45%)); font-weight: 500; }
.live-progress { height: 4px; margin-top: 8px; border-radius: 999px; background: hsl(var(--muted)); overflow: hidden; }
.live-progress > div { height: 100%; border-radius: inherit; background: hsl(var(--brand)); }
.live-sub { display: flex; flex-wrap: wrap; gap: 2px 10px; margin-top: 4px; font-size: 11px; color: hsl(var(--muted-foreground)); font-variant-numeric: tabular-nums; }
.live-totals { display: flex; gap: 16px; flex-wrap: wrap; }
.live-total { display: flex; flex-direction: column; align-items: flex-end; font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; }
.live-total small { font-size: 11px; font-weight: 500; color: hsl(var(--muted-foreground)); }
@media (max-width: 640px) { .live-total { align-items: flex-start; } }

.share-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 14px; }
.share-head { display: flex; justify-content: space-between; align-items: center; font-size: 14px; font-weight: 500; margin-bottom: 6px; }
.share-bar { height: 6px; border-radius: 999px; background: hsl(var(--muted)); overflow: hidden; }
.share-bar > div { height: 100%; border-radius: inherit; background: hsl(var(--brand)); }

.event-list { list-style: none; margin: 0; padding: 0; }
.event { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid hsl(var(--border) / .7); font-size: 13px; }
.event:last-child { border-bottom: 0; }
.ev-icon { display: flex; align-items: center; justify-content: center; width: 26px; height: 26px; flex-shrink: 0; border-radius: 7px; background: hsl(var(--muted)); color: hsl(var(--muted-foreground)); }
.ev-icon .icon { width: 14px; height: 14px; }
.ev-play .ev-icon { background: hsl(var(--brand) / .12); color: hsl(var(--brand)); }
.ev-download .ev-icon { background: hsl(var(--success-bg)); color: hsl(var(--success)); }
.ev-error .ev-icon { background: hsl(var(--destructive) / .1); color: hsl(var(--destructive)); }
.ev-uncached .ev-icon { background: hsl(38 92% 50% / .14); color: hsl(38 92% 45%); }
.ev-main { flex: 1; min-width: 0; }
.ev-line { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: hsl(var(--muted-foreground)); }
.ev-line b, .ev-detail { color: hsl(var(--foreground)); font-weight: 500; }
.ev-line b { font-weight: 600; }
.ev-extra { font-size: 12px; color: hsl(var(--muted-foreground)); }
.ev-time { flex-shrink: 0; font-size: 12px; color: hsl(var(--muted-foreground)); }
.card-header .fchips { flex-wrap: wrap; justify-content: flex-end; }
a.fchip { text-decoration: none; }

/* admin / user mode switch in the account menu */
.mode-switch-form { margin: 0; }
.mode-toggle { width: 100%; }
.mode-toggle > span:first-of-type { flex: 1; text-align: left; }
.toggle-pill { position: relative; width: 30px; height: 17px; flex-shrink: 0; border-radius: 999px; background: hsl(var(--input)); transition: background .15s; }
.toggle-pill::after { content: ""; position: absolute; top: 2px; left: 2px; width: 13px; height: 13px; border-radius: 999px; background: hsl(var(--background)); box-shadow: 0 1px 2px rgb(0 0 0 / .25); transition: transform .15s; }
.toggle-pill.on { background: hsl(var(--brand)); }
.toggle-pill.on::after { transform: translateX(13px); }
