/* RageQuit admin and download pages. Dark first, light supported. */

:root {
  --bg: #f5f4f8;
  --glow-1: rgb(236 47 140 / 14%);
  --glow-2: rgb(124 58 237 / 12%);
  --surface: rgb(255 255 255 / 78%);
  --surface-solid: #ffffff;
  --surface-2: rgb(20 16 40 / 5%);
  --border: rgb(20 16 40 / 9%);
  --border-strong: rgb(20 16 40 / 16%);
  --text: #16131f;
  --muted: #6b6680;
  --accent: #e3197e;
  --gradient: linear-gradient(135deg, #ff2e93 0%, #c026d3 55%, #7c3aed 100%);
  --ok: #138a52;
  --ok-bg: rgb(19 138 82 / 11%);
  --warn: #a35a00;
  --warn-bg: rgb(245 158 11 / 14%);
  --bad: #c0262d;
  --bad-bg: rgb(220 38 38 / 10%);
  --idle: #6b6680;
  --idle-bg: rgb(20 16 40 / 6%);
  --radius: 18px;
  --shadow: 0 1px 2px rgb(20 16 40 / 4%), 0 8px 28px rgb(20 16 40 / 7%);
  --ring: 0 0 0 3px rgb(236 47 140 / 28%);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b0a10;
    --glow-1: rgb(236 47 140 / 20%);
    --glow-2: rgb(124 58 237 / 20%);
    --surface: rgb(23 21 32 / 72%);
    --surface-solid: #17151f;
    --surface-2: rgb(255 255 255 / 5%);
    --border: rgb(255 255 255 / 8%);
    --border-strong: rgb(255 255 255 / 15%);
    --text: #f1eff7;
    --muted: #9d97b3;
    --accent: #ff3d9a;
    --ok: #4ade80;
    --ok-bg: rgb(74 222 128 / 12%);
    --warn: #fbbf24;
    --warn-bg: rgb(251 191 36 / 12%);
    --bad: #fb7185;
    --bad-bg: rgb(251 113 133 / 12%);
    --idle: #a7a1bd;
    --idle-bg: rgb(255 255 255 / 7%);
    --shadow: 0 1px 0 rgb(255 255 255 / 4%) inset, 0 12px 40px rgb(0 0 0 / 35%);
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(900px 600px at -10% -10%, var(--glow-1), transparent 60%),
    radial-gradient(900px 700px at 110% 110%, var(--glow-2), transparent 60%),
    var(--bg);
  background-attachment: fixed;
  font: 15px/1.5 "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

[hidden] { display: none !important; }

h1, h2 { margin: 0; font-weight: 650; letter-spacing: -0.01em; }
h2 { font-size: 1.2rem; }
code { font-family: "Cascadia Code", "Cascadia Mono", Consolas, ui-monospace, monospace; }
strong { font-weight: 600; }

.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.center { text-align: center; }
.error { margin: 0; padding: 10px 12px; border-radius: 10px; background: var(--bad-bg); color: var(--bad); font-size: 0.9rem; }
.notice { margin: 0; padding: 10px 12px; border-radius: 10px; background: var(--warn-bg); color: var(--warn); font-size: 0.9rem; }
.notice.ok { background: var(--ok-bg); color: var(--ok); }

button, input { font: inherit; color: inherit; }

input {
  width: 100%;
  min-height: 48px;
  padding: 12px 14px;
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  background: var(--surface-2);
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}
input::placeholder { color: var(--muted); opacity: 0.8; }
input:focus { outline: none; border-color: var(--accent); box-shadow: var(--ring); background: var(--surface-solid); }

button {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 40px;
  padding: 9px 16px;
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  background: var(--surface-2);
  font-weight: 550;
  cursor: pointer;
  white-space: nowrap;
  transition: transform 0.12s, background 0.15s, border-color 0.15s, box-shadow 0.15s, filter 0.15s;
}
button:hover { background: var(--border); }
button:active { transform: translateY(1px) scale(0.99); }
button:focus-visible { outline: none; box-shadow: var(--ring); }
button:disabled { opacity: 0.55; cursor: default; transform: none; }
button.primary {
  border: 0;
  background: var(--gradient);
  color: #fff;
  font-weight: 650;
  box-shadow: 0 6px 20px rgb(236 47 140 / 30%);
}
button.primary:hover { filter: brightness(1.08) saturate(1.05); box-shadow: 0 8px 26px rgb(236 47 140 / 40%); }
button.ghost { background: transparent; }
button.ghost:hover { background: var(--surface-2); }
button.danger { color: var(--bad); }
button.danger:hover { background: var(--bad-bg); border-color: transparent; }

/* Glass cards */
.login-card, .stat, .key, .releases {
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  -webkit-backdrop-filter: blur(18px) saturate(1.3);
  backdrop-filter: blur(18px) saturate(1.3);
}

@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- Login / download ---------- */

.login { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; }
.login-card {
  width: 100%; max-width: 410px;
  border-radius: 24px;
  padding: 32px 28px 26px;
  display: flex; flex-direction: column; gap: 12px;
  animation: rise 0.35s ease-out;
}
.login-logo {
  width: 72px; height: 72px; align-self: center; border-radius: 20px; padding: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  box-shadow: 0 0 0 6px rgb(236 47 140 / 7%), 0 10px 40px rgb(236 47 140 / 30%);
  margin-bottom: 4px;
}
.login-card h1 {
  font-size: 1.95rem; text-align: center; font-weight: 750; letter-spacing: -0.02em;
  background: var(--gradient); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.login-card .subtitle { text-align: center; margin: -8px 0 10px; color: var(--muted); }
.login-card label { font-weight: 600; font-size: 0.88rem; margin-bottom: -4px; }
.login-card button[type="submit"] { min-height: 50px; margin-top: 4px; font-size: 1rem; }

.key-input { font-family: "Cascadia Code", "Cascadia Mono", Consolas, ui-monospace, monospace; letter-spacing: 0.04em; text-transform: uppercase; text-align: center; }
.key-input::placeholder { text-transform: none; letter-spacing: 0.02em; }

.steps { list-style: none; margin: 6px 0 0; padding: 16px 0 0; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 10px; counter-reset: step; }
.steps li { display: flex; gap: 12px; align-items: flex-start; font-size: 0.9rem; color: var(--muted); counter-increment: step; }
.steps li::before {
  content: counter(step);
  flex: none; display: grid; place-items: center;
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--gradient); color: #fff; font-size: 0.78rem; font-weight: 700;
}
.steps strong { color: var(--text); }

/* ---------- Top bar ---------- */

.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px max(16px, calc((100vw - 1000px) / 2 + 16px));
  padding-top: max(12px, env(safe-area-inset-top));
  background: color-mix(in srgb, var(--bg) 70%, transparent);
  -webkit-backdrop-filter: blur(16px) saturate(1.4);
  backdrop-filter: blur(16px) saturate(1.4);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.08rem; letter-spacing: -0.01em; }
.brand img { width: 34px; height: 34px; border-radius: 10px; padding: 4px; background: var(--surface-2); border: 1px solid var(--border); }
.brand .muted { font-weight: 500; }

.content { max-width: 1000px; margin: 0 auto; padding: 26px 16px 64px; animation: rise 0.3s ease-out; }

.page-title { margin-bottom: 18px; }
.page-title h1 { font-size: 1.7rem; font-weight: 750; letter-spacing: -0.02em; }
.page-title p { margin: 2px 0 0; }

/* ---------- Stats ---------- */

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 20px; }
.stat {
  position: relative; overflow: hidden;
  border-radius: var(--radius); padding: 16px 18px 14px;
  display: flex; flex-direction: column; gap: 2px;
}
.stat::before { content: ""; position: absolute; inset: 0 0 auto; height: 3px; background: var(--stat-color, var(--accent)); }
.stat.s-active { --stat-color: var(--ok); }
.stat.s-idle { --stat-color: var(--idle); }
.stat.s-revoked { --stat-color: var(--bad); }
.stat.warn { --stat-color: var(--warn); }
.stat-value { font-size: 2rem; font-weight: 750; line-height: 1.15; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.stat-label { color: var(--muted); font-size: 0.82rem; }
.stat.warn.has .stat-value { color: var(--warn); }

/* ---------- Toolbar ---------- */

.toolbar { display: flex; gap: 10px; margin-bottom: 16px; }
.search { position: relative; flex: 1; }
.search svg { position: absolute; left: 15px; top: 50%; width: 18px; height: 18px; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.search input { padding-left: 44px; }
.toolbar button { min-height: 48px; padding: 0 20px; }

/* ---------- Key cards ---------- */

.keys { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.key {
  position: relative; overflow: hidden;
  border-radius: var(--radius);
  padding: 16px 18px 14px 22px;
  display: flex; flex-direction: column; gap: 12px;
  transition: transform 0.15s, border-color 0.15s;
  animation: rise 0.25s ease-out both;
}
.key::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 4px; background: var(--key-color, var(--idle)); }
.key.active { --key-color: var(--ok); }
.key.idle { --key-color: var(--idle); }
.key.revoked { --key-color: var(--bad); }
.key:hover { border-color: var(--border-strong); transform: translateY(-1px); }
.key.revoked .key-name, .key.revoked .key-details { opacity: 0.6; }

.key-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; min-width: 0; }
.avatar {
  flex: none; display: grid; place-items: center;
  width: 36px; height: 36px; border-radius: 11px;
  background: var(--gradient); color: #fff; font-weight: 700; font-size: 0.95rem;
  box-shadow: 0 4px 14px rgb(236 47 140 / 25%);
}
.key.revoked .avatar { background: var(--idle-bg); color: var(--muted); box-shadow: none; }
.key-name { font-weight: 650; font-size: 1.05rem; overflow-wrap: anywhere; }
.key-id { color: var(--muted); font-size: 0.82rem; font-variant-numeric: tabular-nums; }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 0.76rem; font-weight: 650; padding: 3px 10px; border-radius: 999px;
}
.chip::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.chip.ok { background: var(--ok-bg); color: var(--ok); }
.chip.idle { background: var(--idle-bg); color: var(--idle); }
.chip.bad { background: var(--bad-bg); color: var(--bad); }
.chip.warn { background: var(--warn-bg); color: var(--warn); }

.key-details {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px 18px;
  margin: 0; padding: 12px 14px; border-radius: 12px; background: var(--surface-2);
  font-size: 0.88rem;
}
.key-details div { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.key-details dt { color: var(--muted); font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600; }
.key-details dd { margin: 0; overflow-wrap: anywhere; }

.key-alert { background: var(--warn-bg); color: var(--warn); border-radius: 12px; padding: 10px 12px; font-size: 0.88rem; }

.key-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.key-actions button { min-height: 34px; padding: 5px 12px; font-size: 0.85rem; border-radius: 10px; }

/* ---------- Releases ---------- */

.releases { margin-top: 28px; border-radius: var(--radius); padding: 14px 18px; }
.releases summary { cursor: pointer; font-weight: 650; list-style: none; display: flex; align-items: center; gap: 10px; }
.releases summary::-webkit-details-marker { display: none; }
.releases summary::before { content: "›"; font-size: 1.3rem; line-height: 1; transition: transform 0.15s; color: var(--muted); }
.releases[open] summary::before { transform: rotate(90deg); }
.releases ul { list-style: none; margin: 12px 0 2px; padding: 0; display: flex; flex-direction: column; gap: 8px; font-size: 0.9rem; }
.releases li { padding: 10px 12px; border-radius: 10px; background: var(--surface-2); }

/* ---------- Dialogs ---------- */

dialog {
  border: 1px solid var(--border); border-radius: 22px; padding: 0; width: min(460px, calc(100vw - 32px));
  background: var(--surface-solid); color: var(--text);
  box-shadow: 0 24px 80px rgb(0 0 0 / 40%);
}
dialog[open] { animation: rise 0.2s ease-out; }
dialog::backdrop { background: rgb(8 6 14 / 55%); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); }
dialog form, .dialog-body { padding: 24px; display: flex; flex-direction: column; gap: 12px; }
dialog label { font-weight: 600; font-size: 0.88rem; margin-bottom: -4px; }
dialog p { margin: 0; }
.actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.actions.wrap { flex-wrap: wrap; }
.key-box {
  padding: 18px 14px; border-radius: 14px; text-align: center;
  background: var(--surface-2);
  border: 1px dashed var(--border-strong);
  font-size: 1.08rem; letter-spacing: 0.03em; user-select: all; overflow-wrap: anywhere;
}
.key-box code { background: var(--gradient); -webkit-background-clip: text; background-clip: text; color: transparent; font-weight: 700; }

/* ---------- Toast ---------- */

.toast {
  position: fixed; left: 50%; bottom: max(24px, env(safe-area-inset-bottom)); transform: translateX(-50%);
  padding: 11px 18px; border-radius: 999px; z-index: 20; max-width: calc(100vw - 32px);
  background: var(--surface-solid); color: var(--text); border: 1px solid var(--border-strong);
  box-shadow: 0 12px 40px rgb(0 0 0 / 30%); font-size: 0.9rem; font-weight: 550;
}

/* ---------- Phone ---------- */

@media (max-width: 680px) {
  .stats { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .stat-value { font-size: 1.7rem; }
  .toolbar { flex-direction: column; }
  .key { padding: 14px 14px 12px 18px; }
  .key-details { grid-template-columns: 1fr 1fr; gap: 8px 12px; }
  .key-actions button { flex: 1 1 auto; }
  .actions { flex-direction: column-reverse; }
  .actions button { width: 100%; }
  .login-card { padding: 28px 20px 22px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before { animation: none !important; transition: none !important; }
}

.release-notes { margin-top: 6px; color: var(--muted); font-size: 0.86rem; white-space: pre-line; }
