@font-face { font-family: Geist; src: url(/fonts/geist.woff2) format("woff2"); font-weight: 100 900; font-display: swap; }
@font-face { font-family: "Geist Mono"; src: url(/fonts/geist-mono.woff2) format("woff2"); font-weight: 100 900; font-display: swap; }

:root {
  --bg: #0a0a0a;
  --bg-2: #111111;
  --surface: #161616;
  --surface-2: #1c1c1c;
  --hover: #222222;
  --line: #262626;
  --line-2: #333333;
  --ink: #ededed;
  --ink-2: #a1a1a1;
  --ink-3: #737373;
  --brand: #ff385c;
  --brand-ink: #ffffff;
  --brand-soft: rgba(255, 56, 92, .14);
  --ok: #22c55e;
  --ok-soft: rgba(34, 197, 94, .14);
  --warn: #f5a524;
  --warn-soft: rgba(245, 165, 36, .14);
  --bad: #f04444;
  --bad-soft: rgba(240, 68, 68, .14);
  --focus: 0 0 0 2px var(--bg), 0 0 0 4px rgba(255, 56, 92, .6);
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .35);
  --radius: 12px;
  --radius-sm: 8px;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #fafafa; --bg-2: #f4f4f4; --surface: #ffffff; --surface-2: #f7f7f7; --hover: #f0f0f0;
    --line: #e8e8e8; --line-2: #d9d9d9; --ink: #171717; --ink-2: #5f5f5f; --ink-3: #8a8a8a;
    --brand: #e31c5f; --brand-soft: rgba(227, 28, 95, .09);
    --ok: #15803d; --ok-soft: rgba(21, 128, 61, .1); --warn: #b45309; --warn-soft: rgba(180, 83, 9, .1);
    --bad: #dc2626; --bad-soft: rgba(220, 38, 38, .09);
    --focus: 0 0 0 2px var(--bg), 0 0 0 4px rgba(227, 28, 95, .45);
    --shadow: 0 1px 2px rgba(0, 0, 0, .05), 0 8px 24px rgba(0, 0, 0, .07);
    color-scheme: light;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100dvh; background: var(--bg); color: var(--ink);
  font: 14px/1.5 Geist, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased; font-feature-settings: "ss01", "cv11";
}
button, input { font: inherit; color: inherit; }
a { color: inherit; }
.mono { font-family: "Geist Mono", ui-monospace, SFMono-Regular, Menlo, monospace; }
.num { font-variant-numeric: tabular-nums; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
svg.i { width: 16px; height: 16px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
:focus-visible { outline: none; box-shadow: var(--focus); }

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 34px; padding: 0 12px;
  border-radius: var(--radius-sm); border: 1px solid var(--line-2); background: var(--surface); color: var(--ink);
  font-weight: 500; cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background .15s, border-color .15s, color .15s, transform .08s;
}
.btn:hover { background: var(--hover); }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .5; cursor: default; transform: none; }
.btn.primary:disabled { background: var(--hover); border-color: var(--line-2); color: var(--ink-3); opacity: 1; filter: none; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn.ghost:hover { background: var(--hover); color: var(--ink); }
.btn.danger { color: var(--bad); }
.btn.danger.solid { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.sm { height: 28px; padding: 0 9px; font-size: 13px; border-radius: 7px; }
.btn.icon { width: 32px; padding: 0; }
.btn.icon.sm { width: 28px; }
.btn.block { width: 100%; height: 40px; }
.spinner { width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Switch ──────────────────────────────────────────────── */
.switch {
  position: relative; width: 38px; height: 22px; border-radius: 999px; border: 0; padding: 0; cursor: pointer; flex: none;
  background: var(--line-2); transition: background .18s;
}
.switch::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, .3); transition: transform .18s;
}
.switch[aria-checked="true"] { background: var(--ok); }
.switch[aria-checked="true"]::after { transform: translateX(16px); }
.switch.lg { width: 46px; height: 26px; }
.switch.lg::after { width: 20px; height: 20px; }
.switch.lg[aria-checked="true"]::after { transform: translateX(20px); }
.switch:disabled { opacity: .5; cursor: default; }

/* ── Inputs ──────────────────────────────────────────────── */
.field { display: grid; gap: 6px; }
.field > span { font-size: 13px; font-weight: 500; color: var(--ink-2); }
.field .hint { font-size: 12px; color: var(--ink-3); }
.input {
  width: 100%; height: 40px; padding: 0 12px; border-radius: var(--radius-sm); border: 1px solid var(--line-2);
  background: var(--bg-2); color: var(--ink); transition: border-color .15s, box-shadow .15s;
}
.input::placeholder { color: var(--ink-3); }
.input:hover { border-color: var(--ink-3); }
.input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.input-wrap { position: relative; }
.input-wrap .input { padding-right: 42px; }
.input-wrap .btn { position: absolute; right: 4px; top: 4px; }

/* ── Login ───────────────────────────────────────────────── */
.login {
  min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px;
  background:
    radial-gradient(50% 40% at 50% 0%, var(--brand-soft), transparent 75%),
    var(--bg);
}
.login-card {
  width: min(380px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 16px;
  padding: 32px 28px 28px; box-shadow: var(--shadow); animation: rise .35s cubic-bezier(.2, .8, .2, 1);
}
.login-card form { display: grid; gap: 16px; }
.login-head { display: grid; justify-items: center; gap: 12px; margin-bottom: 24px; text-align: center; }
.login-head h1 { margin: 0; font-size: 20px; font-weight: 600; letter-spacing: -.02em; }
.login-head p { margin: 0; color: var(--ink-2); }
.logo { width: 44px; height: 44px; border-radius: 12px; background: var(--brand); display: grid; place-items: center; box-shadow: 0 6px 20px rgba(255, 56, 92, .35); }
.logo svg { width: 24px; height: 24px; }
.logo.sm { width: 30px; height: 30px; border-radius: 8px; box-shadow: none; }
.logo.sm svg { width: 18px; height: 18px; }
.form-error {
  display: flex; gap: 8px; align-items: flex-start; padding: 10px 12px; border-radius: var(--radius-sm);
  background: var(--bad-soft); color: var(--bad); font-size: 13px;
}
.login-foot { margin-top: 18px; text-align: center; font-size: 12px; color: var(--ink-3); }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }

/* ── App shell ───────────────────────────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 10; border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 82%, transparent); backdrop-filter: saturate(1.4) blur(12px);
}
.topbar-in { max-width: 1040px; margin: 0 auto; height: 60px; padding: 0 20px; display: flex; align-items: center; gap: 12px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; letter-spacing: -.01em; }
.spacer { flex: 1; }
.main { max-width: 1040px; margin: 0 auto; padding: 24px 20px 80px; }

.hero {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap; padding: 18px 20px; margin-bottom: 16px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
}
.hero h2 { margin: 0; font-size: 16px; font-weight: 600; }
.hero .sub { color: var(--ink-2); font-size: 13px; margin-top: 2px; }
.hero .grow { flex: 1; min-width: 200px; }

.pill {
  display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 10px 0 8px; border-radius: 999px;
  font-size: 12px; font-weight: 500; background: var(--hover); color: var(--ink-2); white-space: nowrap;
}
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; flex: none; }
.pill.ok .dot, .dot.live { animation: pulse 2s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, currentColor 45%, transparent); } 50% { box-shadow: 0 0 0 4px transparent; } }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 28px; }
.stat { padding: 14px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.stat .k { font-size: 12px; color: var(--ink-3); font-weight: 500; }
.stat .v { font-size: 24px; font-weight: 600; letter-spacing: -.02em; margin-top: 2px; }
.stat .v.bad { color: var(--bad); }
.stat .v.good { color: var(--ok); }

.section-head { display: flex; align-items: center; gap: 12px; margin: 0 0 12px; }
.section-head h3 { margin: 0; font-size: 13px; font-weight: 500; color: var(--ink-2); text-transform: uppercase; letter-spacing: .06em; }

/* ── Groups ──────────────────────────────────────────────── */
.group { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 16px; overflow: hidden; animation: rise .3s ease-out; }
.group.off { opacity: .72; }
.group-head { display: flex; align-items: center; gap: 12px; padding: 14px 16px; }
.group-head .grow { flex: 1; min-width: 0; }
.group-head h4 { margin: 0; font-size: 15px; font-weight: 600; letter-spacing: -.01em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.meta { display: flex; flex-wrap: wrap; gap: 6px 12px; margin-top: 3px; color: var(--ink-3); font-size: 12px; }
.meta span { display: inline-flex; align-items: center; gap: 5px; }
.meta svg.i { width: 13px; height: 13px; }
.group-actions { display: flex; align-items: center; gap: 4px; }

.links { border-top: 1px solid var(--line); }
.link { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--line); transition: background .15s; }
.link:hover { background: var(--surface-2); }
.link:last-child { border-bottom: 0; }
.link .state { width: 8px; height: 8px; border-radius: 50%; background: var(--ink-3); }
.link .state.ok { background: var(--ok); }
.link .state.error { background: var(--bad); }
.link .state.stale, .link .state.waiting { background: var(--warn); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 5px; height: 24px; padding: 0 8px; border-radius: 6px; background: var(--hover); color: var(--ink); font-size: 12.5px; white-space: nowrap; }
.chip svg.i { width: 13px; height: 13px; color: var(--ink-3); }
.chip-note { color: var(--ink-3); font-size: 11.5px; }
.chip.zone { background: transparent; border: 1px solid var(--line-2); color: var(--ink-2); }
.chip.zone.top { border-color: color-mix(in srgb, var(--brand) 50%, transparent); background: var(--brand-soft); color: var(--brand); font-weight: 500; }
.link-status { margin-top: 6px; font-size: 12.5px; color: var(--ink-2); display: flex; flex-wrap: wrap; gap: 4px 10px; }
.link-status .err { color: var(--bad); overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.link-status .new { color: var(--brand); font-weight: 500; }
.link-actions { display: flex; align-items: center; gap: 2px; }

.add-link { display: flex; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--line); background: var(--bg-2); }
.add-link .input { height: 34px; }
.add-preview { padding: 0 16px 12px; background: var(--bg-2); }
.add-preview .chips { opacity: .9; }
.add-preview.bad { color: var(--bad); font-size: 12.5px; }

.empty { text-align: center; padding: 56px 20px; border: 1px dashed var(--line-2); border-radius: var(--radius); color: var(--ink-2); }
.empty h4 { margin: 12px 0 4px; font-size: 16px; color: var(--ink); }
.empty p { margin: 0 0 18px; }
.empty .logo { margin: 0 auto; }
.links-empty { padding: 18px 16px; color: var(--ink-3); font-size: 13px; border-top: 1px solid var(--line); }

.skeleton { height: 120px; border-radius: var(--radius); margin-bottom: 16px; background: linear-gradient(90deg, var(--surface) 0%, var(--surface-2) 50%, var(--surface) 100%); background-size: 200% 100%; animation: shimmer 1.2s linear infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ── Helpers ─────────────────────────────────────────────── */
.grow { flex: 1; min-width: 0; }
.dlg-gap { height: 18px; }
.link-main { min-width: 0; }
.link-switch { margin-left: 6px; }
.accent { color: var(--brand); }
.skeleton.short { height: 72px; }

/* ── Avatar ──────────────────────────────────────────────── */
.avatar-btn { display: inline-flex; align-items: center; gap: 8px; height: 34px; padding: 0 10px 0 4px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; font-weight: 500; }
.avatar-btn:hover { background: var(--hover); }
.avatar { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 600; background: linear-gradient(135deg, #ff385c, #bd1e59); color: #fff; }
@media (max-width: 760px) { .avatar-btn { padding: 0 4px; } }

/* ── Menu ────────────────────────────────────────────────── */
.menu-wrap { position: relative; }
.menu {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 20; min-width: 200px; padding: 4px;
  background: var(--surface); border: 1px solid var(--line-2); border-radius: 10px; box-shadow: var(--shadow);
  animation: pop .12s ease-out;
}
.menu button { display: flex; width: 100%; align-items: center; gap: 10px; height: 34px; padding: 0 10px; border: 0; border-radius: 6px; background: none; cursor: pointer; text-align: left; }
.menu button:hover, .menu button:focus-visible { background: var(--hover); box-shadow: none; }
.menu button.danger { color: var(--bad); }
.menu hr { border: 0; border-top: 1px solid var(--line); margin: 4px 0; }
.menu .who { padding: 8px 10px 6px; font-size: 12px; color: var(--ink-3); }
.menu .who b { display: block; color: var(--ink); font-size: 13px; font-weight: 500; }
@keyframes pop { from { opacity: 0; transform: translateY(-4px) scale(.98); } }

/* ── Dialog ──────────────────────────────────────────────── */
dialog {
  border: 1px solid var(--line-2); border-radius: 14px; background: var(--surface); color: var(--ink);
  width: min(460px, calc(100vw - 32px)); padding: 0; box-shadow: var(--shadow);
}
dialog[open] { animation: rise .2s ease-out; }
dialog::backdrop { background: rgba(0, 0, 0, .55); backdrop-filter: blur(2px); }
.dlg-head { display: flex; align-items: flex-start; gap: 12px; padding: 20px 20px 0; }
.dlg-head h2 { margin: 0; font-size: 16px; font-weight: 600; flex: 1; }
.dlg-head p { margin: 4px 0 0; color: var(--ink-2); font-size: 13px; }
.dlg-body { display: grid; gap: 14px; padding: 18px 20px; }
.dlg-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--line); background: var(--bg-2); border-radius: 0 0 14px 14px; }

/* ── Toasts ──────────────────────────────────────────────── */
#toasts { position: fixed; right: 16px; bottom: 16px; z-index: 50; display: grid; gap: 8px; width: min(360px, calc(100vw - 32px)); }
.toast {
  display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; border-radius: 10px;
  background: var(--surface); border: 1px solid var(--line-2); box-shadow: var(--shadow); animation: rise .2s ease-out;
}
.toast svg.i { margin-top: 1px; }
.toast.ok svg.i { color: var(--ok); }
.toast.bad svg.i { color: var(--bad); }
.toast.bad { border-color: color-mix(in srgb, var(--bad) 40%, var(--line-2)); }

/* ── Discord y usuarios ──────────────────────────────────── */
.login-body { display: grid; gap: 14px; }
.btn.discord { background: #5865f2; border-color: #5865f2; color: #fff; gap: 10px; }
.btn.discord:hover { background: #4752c4; border-color: #4752c4; }
.btn.discord.loading { pointer-events: none; opacity: .85; }
.discord-mark { width: 20px; height: 20px; fill: currentColor; flex: none; }
.login-note { margin: -4px 0 0; font-size: 12px; color: var(--ink-3); text-align: center; }
.link-btn { justify-self: center; background: none; border: 0; padding: 4px 6px; color: var(--ink-2); font-size: 13px; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--line-2); border-radius: 6px; }
.link-btn:hover { color: var(--ink); }
.password-form { display: grid; gap: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
.pending-icon { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; background: var(--warn-soft); color: var(--warn); }
.pending-icon svg.i { width: 22px; height: 22px; }
.login-foot a { color: var(--ink-2); }
img.avatar { object-fit: cover; }
.avatar.lg { width: 36px; height: 36px; font-size: 14px; }
.who .role { display: inline-block; margin-top: 4px; font-size: 11px; color: var(--brand); font-weight: 500; }
.pending-btn { border-color: color-mix(in srgb, var(--warn) 45%, var(--line-2)); color: var(--warn); }
dialog.wide { width: min(560px, calc(100vw - 32px)); }
.users-list { display: grid; padding: 8px 12px; max-height: min(60vh, 520px); overflow: auto; }
.user-row { display: flex; align-items: center; gap: 12px; padding: 10px 8px; border-bottom: 1px solid var(--line); }
.user-row:last-child { border-bottom: 0; }
.user-name { font-weight: 500; display: flex; gap: 6px; align-items: baseline; flex-wrap: wrap; }
.user-handle { color: var(--ink-3); font-size: 12px; font-weight: 400; }
.user-meta { color: var(--ink-3); font-size: 12px; }
.row-actions { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.muted-note { color: var(--ink-3); padding: 16px 8px; margin: 0; }
@media (max-width: 760px) { .user-row { flex-wrap: wrap; } .row-actions { width: 100%; justify-content: flex-start; padding-left: 48px; } }

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 760px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .topbar-in, .main { padding-left: 16px; padding-right: 16px; }
  .link { grid-template-columns: auto 1fr; }
  .link-actions { grid-column: 2; justify-content: flex-start; margin-left: -6px; }
  .hide-sm { display: none; }
  .add-link { flex-direction: column; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
