:root {
  color-scheme: light dark;
  --bg: #f5f6f9;
  --surface: #ffffff;
  --surface-2: #eef0f5;
  --border: #e1e4ec;
  --text: #14171f;
  --muted: #646c80;
  --accent: #6a4cf5;
  --accent-2: #00a4dc;
  --good: #1a9f5c;
  --warn: #c27a00;
  --warn-bg: #fff5e0;
  --bad: #cc3b3b;
  --shadow: 0 1px 2px rgba(20, 23, 31, .05), 0 8px 24px rgba(20, 23, 31, .06);
  --radius: 16px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d0f14;
    --surface: #161920;
    --surface-2: #1f232d;
    --border: #272c38;
    --text: #eceef4;
    --muted: #8d95a8;
    --accent: #8f78ff;
    --accent-2: #2cc0f2;
    --good: #3ecf8e;
    --warn: #f0b040;
    --warn-bg: #2a2212;
    --bad: #f07070;
    --shadow: none;
  }
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

[hidden] { display: none !important; }

h1, h2, p { margin: 0; }

.muted { color: var(--muted); }

/* Buttons and inputs */

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 18px;
  border: 0;
  border-radius: 12px;
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}

.button.primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
}

.button.quiet {
  min-height: 36px;
  padding: 0 12px;
  background: transparent;
  color: var(--muted);
  font-weight: 500;
  font-size: 14px;
}

.button.quiet:hover { background: var(--surface-2); color: var(--text); }
.button:disabled { opacity: .6; cursor: default; }
.button:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Sign-in */

.login {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px 16px;
}

.login-card {
  width: 100%;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  padding: 32px 24px 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: var(--shadow);
}

.login-logo { border-radius: 16px; margin-bottom: 16px; }
.login-card h1 { font-size: 24px; letter-spacing: -.02em; }
.login-card .muted { margin: 4px 0 20px; font-size: 15px; }
.login-card label { margin: 0 0 6px; font-size: 13px; font-weight: 600; color: var(--muted); }

.login-card input {
  height: 46px;
  margin-bottom: 14px;
  padding: 0 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  font: inherit;
}

.login-card .button { margin-top: 6px; }
.form-error { margin: 0 0 12px; color: var(--bad); font-size: 14px; }

/* Top bar */

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  padding-top: env(safe-area-inset-top);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}

.topbar-inner {
  max-width: 720px;
  margin: 0 auto;
  height: 56px;
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; letter-spacing: -.01em; }
.brand img { border-radius: 8px; }
.topbar-right { display: flex; align-items: center; gap: 6px; }

.live { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; color: var(--muted); }
.live i { width: 8px; height: 8px; border-radius: 50%; background: var(--good); animation: breathe 2.4s ease-in-out infinite; }
.live.offline i { background: var(--warn); animation: none; }

/* Page */

.content {
  max-width: 720px;
  margin: 0 auto;
  padding: 8px 16px calc(40px + env(safe-area-inset-bottom));
}

section { margin-top: 20px; }

h2 {
  margin-bottom: 10px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--muted);
}

.notice {
  margin-top: 16px;
  padding: 10px 14px;
  background: var(--warn-bg);
  color: var(--warn);
  border-radius: 12px;
  font-size: 14px;
}

.cards { display: grid; gap: 12px; }

.card {
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.card-head { display: flex; gap: 14px; align-items: center; min-width: 0; }

.poster {
  flex: none;
  width: 52px;
  height: 78px;
  border-radius: 8px;
  background: linear-gradient(150deg, var(--surface-2), var(--border));
  object-fit: cover;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-weight: 700;
  font-size: 20px;
}

.card-title { min-width: 0; flex: 1; }
.title { font-size: 17px; font-weight: 650; letter-spacing: -.01em; overflow-wrap: anywhere; }
.title .year { color: var(--muted); font-weight: 400; }
.meta { margin-top: 2px; font-size: 13px; color: var(--muted); }

/* Stepper */

.steps {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  margin: 18px 0 14px;
  padding: 0;
  list-style: none;
}

.step { position: relative; display: flex; flex-direction: column; align-items: center; gap: 6px; min-width: 0; }

.step::before {
  content: "";
  position: absolute;
  top: 6px;
  right: 50%;
  width: 100%;
  height: 2px;
  background: var(--border);
}

.step:first-child::before { display: none; }

.step i {
  position: relative;
  z-index: 1;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--surface);
  border: 2px solid var(--border);
}

.step span { font-size: 11px; color: var(--muted); white-space: nowrap; }

.step.done::before, .step.current::before { background: var(--accent); }
.step.done i { background: var(--accent); border-color: var(--accent); }
.step.current i { border-color: var(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 22%, transparent); }
.step.current span { color: var(--text); font-weight: 600; }

.card.active .step.current i { animation: pulse 2s ease-in-out infinite; }
.card.problem .step.current i { border-color: var(--warn); box-shadow: 0 0 0 4px color-mix(in srgb, var(--warn) 22%, transparent); }
.card.problem .step.current span { color: var(--warn); }

/* Status line and bar */

.status { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; font-size: 15px; }
.status-label { font-weight: 600; }
.card.problem .status-label { color: var(--warn); }
.status-side { color: var(--muted); font-size: 14px; font-variant-numeric: tabular-nums; white-space: nowrap; }

.bar { height: 8px; margin-top: 8px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }

.bar i {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width .8s ease;
}

.card.problem .bar i { background: var(--warn); }

.bar.busy i {
  width: 35% !important;
  transition: none;
  animation: slide 1.6s ease-in-out infinite;
}

.detail { margin-top: 8px; font-size: 13px; color: var(--muted); }

.downloads { margin: 12px 0 0; padding: 12px 0 0; border-top: 1px solid var(--border); list-style: none; display: grid; gap: 8px; }
.download { min-width: 0; }

.release {
  font: 12px/1.4 ui-monospace, "Cascadia Mono", Consolas, Menlo, monospace;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.download-note { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.download.problem .download-note { color: var(--warn); }

/* Recently finished */

.rows { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.row { display: flex; align-items: center; gap: 12px; padding: 12px 16px; }
.row + .row { border-top: 1px solid var(--border); }
.row .title { font-size: 15px; }
.row-main { flex: 1; min-width: 0; }

.badge {
  flex: none;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: color-mix(in srgb, var(--good) 16%, transparent);
  color: var(--good);
  font-size: 13px;
  font-weight: 700;
}

.row.declined .badge { background: color-mix(in srgb, var(--bad) 14%, transparent); color: var(--bad); }

.badge.warn { background: color-mix(in srgb, var(--warn) 18%, transparent); color: var(--warn); }
.badge.bad { background: color-mix(in srgb, var(--bad) 14%, transparent); color: var(--bad); }

/* Server summary */

.server {
  margin-top: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.server summary {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 56px;
  padding: 0 16px;
  cursor: pointer;
  list-style: none;
  border-radius: var(--radius);
  -webkit-tap-highlight-color: transparent;
}

.server summary::-webkit-details-marker { display: none; }
.server summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.server-headline { flex: 1; min-width: 0; font-weight: 600; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.meters { flex: none; display: flex; align-items: center; gap: 12px; }
.meter { display: flex; align-items: center; gap: 6px; }
.meter-label { font-size: 12px; font-weight: 600; color: var(--muted); }
.meter .bar { display: block; width: 40px; height: 6px; margin: 0; }

.server .bar i { transition: none; }
.warn > .bar i { background: var(--warn); }
.bad > .bar i { background: var(--bad); }

.chevron {
  flex: none;
  width: 8px;
  height: 8px;
  margin: 0 2px 4px;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(45deg);
  transition: transform .2s ease;
}

.server[open] .chevron { transform: rotate(225deg); margin-bottom: -4px; }

.server-body { border-top: 1px solid var(--border); padding: 4px 16px 16px; }
.server-group { padding-top: 14px; }
.server-group + .server-group { margin-top: 14px; border-top: 1px solid var(--border); }

.server-group h3 {
  margin: 0 0 4px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--muted);
}

.fact { display: flex; align-items: center; gap: 10px; min-height: 32px; font-size: 15px; }
.dot { flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--good); }
.fact.warn .dot { background: var(--warn); }
.fact.bad .dot { background: var(--bad); }
.fact-name { flex: 1; min-width: 0; font-weight: 500; }
.fact-value { flex: none; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; text-align: right; }
.fact.warn .fact-value { color: var(--warn); }
.fact.bad .fact-value { color: var(--bad); }

.drive + .drive { margin-top: 8px; }
.drive .bar { display: block; height: 6px; margin: 2px 0 4px 18px; }
/* Empty state */

.empty { padding: 48px 16px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.empty-ring { width: 56px; height: 56px; margin-bottom: 10px; border-radius: 50%; border: 5px solid var(--surface-2); border-top-color: var(--accent); border-right-color: var(--accent-2); }
.empty-title { font-size: 18px; font-weight: 650; }
.empty .button { margin-top: 14px; }

@keyframes pulse {
  50% { box-shadow: 0 0 0 7px color-mix(in srgb, var(--accent) 10%, transparent); }
}

@keyframes breathe {
  50% { opacity: .35; }
}

@keyframes slide {
  0% { transform: translateX(-110%); }
  100% { transform: translateX(300%); }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
  .bar.busy i { width: 100% !important; opacity: .35; }
}

@media (max-width: 380px) {
  .step span { font-size: 10px; }
  .card { padding: 14px; }
}
