/* 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; }
.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; }
.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 .icon { width: 18px; height: 18px; }
.status-ready .dl-icon { background: hsl(var(--success-bg)); color: hsl(var(--success)); }
.status-downloading .dl-icon, .status-queued .dl-icon { background: hsl(var(--brand) / .12); color: hsl(var(--brand)); }
.status-error .dl-icon { background: hsl(var(--destructive) / .1); color: hsl(var(--destructive)); }
.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(--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; }
}
