:root {
  color-scheme: light;
  --bg: #f5f5f7;
  --panel: rgba(255, 255, 255, 0.82);
  --panel-soft: rgba(255, 255, 255, 0.68);
  --ink: #111111;
  --muted: #6e6e73;
  --line: rgba(17, 17, 17, 0.08);
  --accent: #111111;
  --accent-soft: rgba(17, 17, 17, 0.06);
  --success: #058061;
  --success-soft: rgba(5, 128, 97, 0.12);
  --warn: #916900;
  --warn-soft: rgba(145, 105, 0, 0.12);
  --neutral-soft: rgba(17, 17, 17, 0.06);
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.06);
  --radius-xl: 28px;
  --radius-lg: 18px;
  --radius-pill: 999px;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  font-family: "SF Pro Display", "PingFang SC", "Helvetica Neue", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top center, rgba(255, 255, 255, 0.9), transparent 32%),
    linear-gradient(180deg, #fbfbfd 0%, var(--bg) 100%);
}

.download-page {
  --ink: #071d37;
  --muted: #587291;
  --line: rgba(17, 90, 157, 0.24);
  --panel: rgba(242, 250, 255, 0.58);
  --panel-soft: rgba(242, 250, 255, 0.48);
  --accent: #0a68b7;
  --accent-soft: rgba(10, 104, 183, 0.12);
  --neutral-soft: rgba(10, 104, 183, 0.1);
  --success: #0c7cbf;
  --success-soft: rgba(12, 124, 191, 0.14);
  --warn: #8b5a00;
  --warn-soft: rgba(139, 90, 0, 0.12);
  --shadow: 0 36px 96px rgba(6, 42, 86, 0.2);
  position: relative;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 12% -16%, rgba(255, 255, 255, 0.94) 0, transparent 40%),
    radial-gradient(circle at 100% 0%, rgba(83, 181, 255, 0.38) 0, transparent 38%),
    linear-gradient(180deg, #f1f8ff 0%, #e5f1fb 44%, #dcebfa 100%);
}

.download-page::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(to right, rgba(18, 95, 164, 0.07) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(18, 95, 164, 0.07) 1px, transparent 1px);
  background-size: 52px 52px;
  mask-image: radial-gradient(circle at 50% 22%, #000 45%, transparent 100%);
  opacity: 0.4;
}

.download-page::after {
  content: "";
  position: fixed;
  top: -180px;
  right: -120px;
  width: 520px;
  height: 520px;
  pointer-events: none;
  border-radius: 999px;
  background: radial-gradient(circle, rgba(45, 173, 255, 0.34) 0, transparent 64%);
  filter: blur(4px);
  animation: download-float-glow 7s ease-in-out infinite;
}

@keyframes download-float-glow {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(22px);
  }
}

.download-page .page {
  position: relative;
  z-index: 1;
  width: min(820px, calc(100% - 28px));
  padding: 24px 0 46px;
}

.download-page .hero,
.download-page .section {
  border: 1px solid rgba(114, 180, 235, 0.52);
  background:
    linear-gradient(155deg, rgba(255, 255, 255, 0.82), rgba(226, 242, 255, 0.52)),
    rgba(250, 253, 255, 0.42);
  box-shadow:
    0 34px 96px rgba(5, 39, 79, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.72);
  backdrop-filter: blur(22px) saturate(160%);
}

.download-page .hero {
  position: relative;
  overflow: hidden;
}

.download-page .hero::before {
  content: "";
  position: absolute;
  inset: -120px -120px auto auto;
  width: 300px;
  height: 300px;
  border-radius: 999px;
  pointer-events: none;
  background: radial-gradient(circle, rgba(59, 189, 255, 0.28) 0, transparent 70%);
}

.download-page h1 {
  color: #061a32;
}

.download-page .eyebrow,
.download-page .section-kicker,
.download-page .meta-label {
  color: #0c5f98;
}

.download-page .summary,
.download-page .section p,
.download-page .steps li,
.download-page .link-copy p {
  color: var(--muted);
}

.download-page .hero-link-card {
  border: 1px solid rgba(119, 186, 236, 0.48);
  background:
    linear-gradient(150deg, rgba(255, 255, 255, 0.8), rgba(223, 240, 255, 0.5)),
    rgba(255, 255, 255, 0.5);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.72),
    0 20px 56px rgba(7, 48, 93, 0.16);
}

.download-page .cta.primary {
  color: #fff;
  background: linear-gradient(135deg, #006cb6 0%, #1f9cf0 100%);
  box-shadow: 0 16px 34px rgba(11, 113, 187, 0.34);
}

.download-page .cta.secondary {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.62);
  border: 1px solid rgba(109, 177, 230, 0.52);
}

.download-page .link-action {
  color: #0c4c7d;
  border: 1px solid rgba(109, 177, 230, 0.58);
  background: rgba(255, 255, 255, 0.64);
}

.download-page .link-action.disabled {
  border-color: rgba(122, 160, 194, 0.45);
  color: #5f7b96;
}

.download-page .section-quiet {
  background:
    linear-gradient(160deg, rgba(255, 255, 255, 0.66), rgba(219, 239, 255, 0.42)),
    rgba(242, 250, 255, 0.5);
}

.download-page .steps li {
  border-top-color: rgba(99, 170, 224, 0.34);
}

.download-page .steps li::before {
  color: #0a67b6;
}

.page {
  width: min(760px, calc(100% - 28px));
  margin: 0 auto;
  padding: 20px 0 40px;
}

.hero,
.section {
  border: 1px solid var(--line);
  background: var(--panel);
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow);
}

.hero,
.section {
  border-radius: var(--radius-xl);
}

.hero {
  padding: 24px;
}

.hero-top,
.hero-actions,
.hero-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.eyebrow,
.section-kicker,
.meta-label {
  display: block;
  margin: 0;
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
}

.hero-body {
  padding: 34px 0 36px;
}

h1,
h2,
p,
h3 {
  margin: 0;
}

h1 {
  font-size: clamp(44px, 11vw, 78px);
  line-height: 0.94;
  letter-spacing: -0.06em;
}

h2 {
  margin-top: 10px;
  font-size: clamp(28px, 6vw, 40px);
  line-height: 1;
  letter-spacing: -0.04em;
}

.summary,
.section p,
.steps li {
  color: var(--muted);
  line-height: 1.75;
}

.summary {
  max-width: 28rem;
  margin-top: 18px;
  font-size: 17px;
}

.hero-downloads {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-top: 6px;
}

.hero-link-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.94);
}

.hero-actions {
  justify-content: flex-start;
  margin-top: 16px;
}

.cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 52px;
  padding: 0 22px;
  border-radius: var(--radius-pill);
  text-decoration: none;
  font-weight: 600;
  transition: transform 140ms ease, opacity 140ms ease;
}

.cta:hover {
  transform: translateY(-1px);
}

.cta.primary {
  color: #fff;
  background: var(--accent);
}

.cta.secondary {
  color: var(--ink);
  background: var(--accent-soft);
}

.hero-meta {
  margin-top: 28px;
  align-items: stretch;
}

.meta-item {
  min-width: 0;
  flex: 1;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.meta-item strong,
.mobile-copy strong {
  display: block;
  margin-top: 8px;
  font-size: 18px;
  line-height: 1.4;
  font-weight: 600;
}

.section {
  margin-top: 18px;
  padding: 24px;
}

.section-quiet {
  background: var(--panel-soft);
}

.steps {
  margin: 14px 0 0;
  padding: 0;
  list-style: none;
  counter-reset: step;
}

.steps li {
  position: relative;
  padding: 16px 0 16px 42px;
  border-top: 1px solid var(--line);
  font-size: 15px;
}

.steps li:first-child {
  border-top: 0;
}

.steps li::before {
  counter-increment: step;
  content: "0" counter(step);
  position: absolute;
  left: 0;
  top: 16px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
}

.link-copy h3 {
  margin-top: 8px;
  font-size: 26px;
  line-height: 1.08;
  letter-spacing: -0.03em;
}

.link-copy p {
  margin-top: 10px;
  color: var(--muted);
  line-height: 1.65;
  word-break: break-all;
}

.link-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 130px;
  min-height: 46px;
  padding: 0 18px;
  border-radius: var(--radius-pill);
  background: var(--accent-soft);
  color: var(--ink);
  text-decoration: none;
  font-weight: 600;
  white-space: nowrap;
}

.link-action.disabled {
  opacity: 0.72;
}

.status-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 0 14px;
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.status-chip.neutral {
  color: var(--ink);
  background: var(--neutral-soft);
}

.status-chip.ready {
  color: var(--success);
  background: var(--success-soft);
}

.status-chip.pending {
  color: var(--warn);
  background: var(--warn-soft);
}

.text-input,
.json-editor {
  width: 100%;
  margin-top: 8px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.96);
  color: var(--ink);
}

.text-input {
  padding: 14px 16px;
  font: inherit;
}

.json-editor {
  min-height: 420px;
  padding: 18px;
  resize: vertical;
  font: 13px/1.7 "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

.status-line {
  margin-top: 14px;
  color: var(--muted);
}

.status-line[data-error="true"] {
  color: #b42318;
}

.shell {
  width: min(980px, calc(100% - 28px));
  margin: 0 auto;
  padding: 20px 0 40px;
}

.auth-shell {
  width: min(460px, calc(100% - 28px));
  margin: 0 auto;
  padding: 32px 0 40px;
}

.shell h1 {
  font-size: clamp(34px, 7vw, 52px);
}

.auth-panel {
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  background: var(--panel);
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow);
}

.auth-panel h1 {
  margin-top: 8px;
  font-size: clamp(34px, 9vw, 46px);
  letter-spacing: -0.04em;
}

.auth-summary {
  max-width: none;
}

.auth-form {
  margin-top: 18px;
}

.auth-form .label {
  margin-top: 12px;
}

.auth-submit {
  width: 100%;
  margin-top: 16px;
}

.captcha-row {
  margin-top: 8px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.captcha-prompt {
  display: inline-flex;
  align-items: center;
  min-height: 42px;
  min-width: 160px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.94);
  font: 600 16px/1 "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  letter-spacing: 0.04em;
}

.captcha-refresh {
  min-width: 80px;
}

.panel {
  margin-top: 18px;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  background: var(--panel);
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow);
}

.label {
  display: block;
  margin: 0;
  font-size: 12px;
  color: var(--muted);
}

.actions {
  margin-top: 12px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.actions.compact {
  margin-top: 10px;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 16px;
  border-radius: 12px;
  border: 1px solid transparent;
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.button.primary {
  color: #fff;
  background: var(--accent);
}

.button.secondary {
  color: var(--ink);
  background: rgba(17, 17, 17, 0.04);
  border-color: var(--line);
}

.button:disabled {
  opacity: 0.62;
  cursor: not-allowed;
}

.text-input.slim {
  width: auto;
  min-width: 120px;
  margin-top: 0;
  min-height: 42px;
  padding: 0 12px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.stat-card {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.92);
  padding: 14px;
}

.stat-card span {
  display: block;
  font-size: 12px;
  color: var(--muted);
}

.stat-card strong {
  display: block;
  margin-top: 8px;
  font-size: 24px;
  line-height: 1.1;
}

.table-wrap {
  overflow-x: auto;
}

.metrics-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 620px;
}

.metrics-table th,
.metrics-table td {
  padding: 10px 8px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}

.metrics-table th {
  color: var(--muted);
  font-weight: 600;
}

.metric-columns {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.metric-columns h3 {
  font-size: 18px;
}

.metric-list {
  list-style: none;
  margin: 10px 0 0;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
}

.metric-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid var(--line);
  font-size: 13px;
}

.metric-list li:first-child {
  border-top: 0;
}

.metric-list li strong {
  font-size: 13px;
}

.events-log {
  margin-top: 10px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.94);
  padding: 12px;
  min-height: 220px;
  max-height: 420px;
  overflow: auto;
  font: 12px/1.65 "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  color: var(--ink);
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.panel-head h2 {
  margin-top: 8px;
}

.form-grid {
  display: grid;
  gap: 14px;
  margin-top: 14px;
}

.form-grid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.full-span {
  grid-column: 1 / -1;
}

.textarea-input {
  min-height: 108px;
  padding: 14px 16px;
  resize: vertical;
  font: inherit;
  line-height: 1.6;
}

.upload-block {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.upload-block.compact {
  margin-top: 14px;
  padding-top: 14px;
}

.upload-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 8px;
}

.upload-row .text-input {
  margin-top: 0;
}

.upload-note,
.card-subtitle,
.empty-state,
.list-title,
.stat-card p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.admin-card-list {
  display: grid;
  gap: 14px;
  margin-top: 14px;
}

.admin-card {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.94);
  padding: 18px;
}

.card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.card-actions {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.card-header h3 {
  font-size: 20px;
  line-height: 1.1;
}

.firmware-summary {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.firmware-summary span {
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(17, 17, 17, 0.04);
  color: var(--ink);
  font-size: 12px;
  font-weight: 600;
}

.toggle-row {
  margin-top: 14px;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-weight: 500;
}

.toggle-row input {
  width: 18px;
  height: 18px;
}

.admin-stats-grid {
  margin-top: 14px;
}

.admin-list {
  display: grid;
  gap: 14px;
  margin-top: 14px;
}

.list-block {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.92);
  padding: 14px;
}

.list-title {
  margin-top: 0;
  font-weight: 600;
  color: var(--ink);
}

.list-row {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 0.6fr) minmax(0, 1fr);
  gap: 10px;
  padding: 12px 0;
  border-top: 1px solid var(--line);
  font-size: 13px;
  color: var(--muted);
}

.list-row:first-of-type {
  border-top: 0;
}

.list-row strong {
  color: var(--ink);
}

.site-footer {
  position: relative;
  z-index: 1;
  text-align: center;
  padding: 20px 0;
  font-size: 14px;
  color: #666;
}

.site-footer a {
  color: #666;
  text-decoration: none;
}

.site-footer a:hover {
  text-decoration: underline;
}

@media (max-width: 640px) {
  .page {
    width: min(100% - 16px, 760px);
    padding: 12px 0 28px;
  }

  .download-page .page {
    width: min(100% - 16px, 820px);
  }

  .shell {
    width: min(100% - 16px, 980px);
    padding: 12px 0 28px;
  }

  .auth-shell {
    width: min(100% - 16px, 460px);
    padding: 12px 0 28px;
  }

  .hero,
  .section,
  .panel,
  .auth-panel {
    padding: 18px;
    border-radius: 28px;
  }

  .hero-top,
  .hero-actions,
  .hero-meta {
    flex-direction: column;
    align-items: stretch;
  }

  .hero-body {
    padding: 26px 0 28px;
  }

  h1 {
    font-size: clamp(36px, 13vw, 56px);
  }

  .summary {
    font-size: 15px;
  }

  .cta {
    width: 100%;
  }

  .meta-item {
    padding-top: 14px;
  }

  .hero-downloads {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .download-page .hero-downloads {
    grid-template-columns: 1fr;
  }

  .actions {
    flex-direction: column;
    align-items: stretch;
  }

  .panel-head,
  .card-header,
  .upload-row {
    flex-direction: column;
    align-items: stretch;
  }

  .form-grid.two,
  .list-row {
    grid-template-columns: 1fr;
  }

  .captcha-row {
    flex-direction: column;
    align-items: stretch;
  }

  .captcha-prompt {
    width: 100%;
    justify-content: center;
  }

  .button,
  .text-input.slim {
    width: 100%;
  }

  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .metric-columns {
    grid-template-columns: 1fr;
  }
}
