:root {
  color-scheme: light dark;
  --bg: #0f172a;
  --card: rgba(255, 255, 255, 0.10);
  --card-border: rgba(255, 255, 255, 0.18);
  --text: #f8fafc;
  --muted: #cbd5e1;
  --accent: #2465f3;
  --accent-2: #053eb9;
  --shadow: rgba(2, 6, 23, 0.32);

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-7: 32px;
  --space-8: 40px;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 20px;
  --radius-xl: 24px;
  --radius-full: 999px;

  --shadow-ambient: 0 24px 80px var(--shadow);
  --shadow-soft: 0 8px 20px rgba(2, 6, 23, 0.22);
  --shadow-glow: 0 16px 36px rgba(37, 99, 235, 0.32);
  --shadow-glow-hover: 0 20px 44px rgba(37, 99, 235, 0.42);

  --master-accent: #facc15;
  --master-accent-deep: #b45309;
  --master-highlight: #fde68a;
  --master-highlight-2: #fffbea;
  --master-border: rgba(250, 204, 21, 0.45);
  --master-bg: linear-gradient(135deg, rgba(250, 204, 21, 0.14), rgba(120, 53, 15, 0.2));
  --master-glow: 0 0 0 1px rgba(250, 204, 21, 0.12) inset;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, ui-sans-serif, system-ui, sans-serif;
  background:
    radial-gradient(circle at 20% 10%, rgba(56, 189, 248, 0.24), transparent 32%),
    radial-gradient(circle at 80% 20%, rgba(37, 99, 235, 0.28), transparent 34%),
    linear-gradient(135deg, #020617, var(--bg));
  color: var(--text);
}

.page {
  width: min(980px, calc(100% - 32px));
  margin: 0 auto;
  padding: 64px 0;
}

.card {
  position: relative;
  width: min(640px, 100%);
  margin: 0 auto;
  padding: 40px;
  border: 1px solid var(--card-border);
  border-radius: var(--radius-xl);
  background: var(--card);
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow-ambient);
  text-align: center;
}

/* Platform identity tint — subtle, brand-colored glow behind the install card
   (Apple = neutral silver, Android = green) instead of a flat card for every app. */
.card.platform-ios {
  background:
    radial-gradient(circle at 100% -10%, rgba(148, 163, 184, 0.26), transparent 45%),
    var(--card);
}

.card.platform-android {
  background:
    radial-gradient(circle at 100% -10%, rgba(61, 220, 132, 0.24), transparent 45%),
    var(--card);
}

.app-icon-wrapper {
  margin: 0 auto 24px;
  display: grid;
  place-items: center;
}

.app-icon {
  width: 96px;
  height: 96px;
  border-radius: var(--radius-xl);
  background: rgba(255, 255, 255, 0.2);
}

.app-icon img {
  border-radius: var(--radius-xl);
  width: 96px;
  height: 96px;
}

span[hidden] {
  display: none;
}

/* This stylesheet has no Tailwind, so the "hidden" class used by public.js/index.html/
   detail.html to toggle dynamic UI (other-platform list, chart tooltip) needs its own
   rule here — !important so it always wins regardless of source order vs display utilities. */
.hidden {
  display: none !important;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: calc(100% - 32px);
  padding: 12px 18px;
  border-radius: var(--radius-full);
  background: rgba(251, 191, 36, 0.16);
  backdrop-filter: blur(18px);
  border: 1px solid rgba(251, 191, 36, 0.4);
  box-shadow: var(--shadow-soft);
  color: #fde68a;
  font-size: 0.85rem;
  z-index: 40;
}

.toast-dot {
  flex-shrink: 0;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #fbbf24;
  box-shadow: 0 0 0 rgba(251, 191, 36, 0.6);
  animation: toast-pulse 1.6s ease-out infinite;
}

@keyframes toast-pulse {
  0% { box-shadow: 0 0 0 0 rgba(251, 191, 36, 0.55); }
  70% { box-shadow: 0 0 0 8px rgba(251, 191, 36, 0); }
  100% { box-shadow: 0 0 0 0 rgba(251, 191, 36, 0); }
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(2rem, 3vw, 4rem);
  line-height: 1;
  letter-spacing: -0.06em;
}

.subtitle {
  max-width: 520px;
  margin: 20px auto 0;
  color: var(--muted);
  font-size: 1.08rem;
  line-height: 1.7;
}

.timestamp {
  display: block;
  margin-top: var(--space-5);
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 600;
}

.meta {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin: 32px 0;
}

/* Bundle ID/package name is long and unbreakable — give it its own full-width
   row instead of squeezing it into a column even with Version and Build. */
.meta div:last-child {
  grid-column: 1 / -1;
}

.meta div {
  padding: 16px 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.07);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(8px);
}

.meta span,
.hint {
  color: var(--muted);
}

.meta span {
  display: block;
  margin-bottom: 4px;
  font-size: 0.78rem;
}

.meta strong {
  font-size: 1rem;
  word-break: break-all;
}

.button {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 56px;
  padding: 0 28px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: white;
  font-weight: 800;
  text-decoration: none;
  box-shadow: var(--shadow-glow);
  transition: transform 180ms ease, box-shadow 180ms ease;
}

.button:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-glow-hover);
}

.button svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.button-disabled,
.button-disabled:hover {
  background: rgba(255, 255, 255, 0.12);
  color: var(--muted);
  border: 1px solid var(--card-border);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06), var(--shadow-soft);
  transform: none;
  cursor: not-allowed;
}

/* ---------- Install/download progress ring ---------- */
.button.is-loading {
  cursor: wait;
  pointer-events: none;
}

.button.is-loading .btn-label {
  opacity: 0;
}

.progress-ring {
  display: none;
}

.button.is-loading .progress-ring {
  position: absolute;
  display: block;
}

.progress-ring-track {
  fill: none;
  stroke: rgba(255, 255, 255, 0.3);
  stroke-width: 3;
}

.progress-ring-fill {
  fill: none;
  stroke: #fff;
  stroke-width: 3;
  stroke-linecap: round;
  /* r=15.9155 makes the circle's circumference ~100, so dasharray/offset can
     be plain percentages instead of computed against 2*pi*r. */
  stroke-dasharray: 100 100;
  stroke-dashoffset: 100;
  transform: rotate(-90deg);
  transform-origin: 50% 50%;
  transition: stroke-dashoffset 120ms linear;
}

/* Indeterminate state (no known total, e.g. the iOS OTA install prompt runs
   outside the page) — spin a short arc instead of filling a real percentage. */
.button.is-indeterminate .progress-ring-fill {
  stroke-dasharray: 30 100;
  animation: progress-ring-spin 900ms linear infinite;
  transition: none;
}

@keyframes progress-ring-spin {
  to {
    transform: rotate(270deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  .button.is-indeterminate .progress-ring-fill {
    animation: none;
  }
}

/* ---------- Unavailable app (platform mismatch / download disabled) ---------- */
.card.is-unavailable .app-icon-wrapper,
.card.is-unavailable h1,
.card.is-unavailable .subtitle,
.card.is-unavailable .timestamp,
.card.is-unavailable .meta,
.card.is-unavailable .download-chart-card {
  opacity: 0.45;
  filter: grayscale(0.4);
}

.hint {
  margin: 20px auto 0;
  max-width: 520px;
  font-size: 0.92rem;
  line-height: 1.6;
}

.raw-download-link {
  display: inline-block;
  margin-top: 10px;
  font-size: 0.82rem;
  color: var(--muted);
  text-decoration: underline;
}

.raw-download-link:hover {
  color: var(--text);
}

.info-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-top: 24px;
}

.info-grid article {
  padding: 24px;
  border: 1px solid var(--card-border);
  border-radius: var(--radius-xl);
  background: rgba(255, 255, 255, 0.08);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(8px);
}

.info-grid h2 {
  margin: 0 0 10px;
  font-size: 1rem;
}

.info-grid p {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
  font-size: 0.95rem;
}

.list-header {
  text-align: center;
  margin-bottom: 32px;
}

.brand-logo {
  display: block;
  width: 64px;
  height: 64px;
  margin: 0 auto 16px;
  border-radius: var(--radius-lg);
  object-fit: cover;
}

.access-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 14px;
  padding: 6px 14px;
  border: 1px solid rgba(37, 99, 235, 0.35);
  border-radius: 999px;
  background: rgba(37, 99, 235, 0.15);
  color: #93c5fd;
  font-size: 0.85rem;
  font-weight: 600;
}

.access-chip-master {
  border-color: var(--master-border);
  background: var(--master-bg);
  box-shadow: var(--master-glow);
}

.chip-shimmer-text {
  background-image: linear-gradient(
    100deg,
    var(--master-accent-deep) 20%,
    var(--master-highlight) 40%,
    var(--master-highlight-2) 50%,
    var(--master-highlight) 60%,
    var(--master-accent-deep) 80%
  );
  background-size: 220% 100%;
  background-clip: text;
  -webkit-background-clip: text;
  color: transparent;
  font-weight: 800;
  animation: chip-shimmer 3s linear infinite;
}

@keyframes chip-shimmer {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .chip-shimmer-text {
    animation: none;
  }
}

.forbidden-card {
  width: min(560px, 100%);
}

.forbidden-card h2 {
  margin: 4px 0 0;
  font-size: 1.8rem;
}

.back-nav {
  margin-bottom: 20px;
}

.back-nav a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 8px 4px;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.92rem;
  transition: color 150ms ease;
}

.back-nav svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.back-nav a:hover {
  color: var(--text);
}

.app-list {
  display: grid;
  gap: 14px;
}

.app-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 18px 20px;
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  background: var(--card);
  backdrop-filter: blur(18px);
  color: var(--text);
  text-decoration: none;
  transition: transform 180ms ease, background 180ms ease, box-shadow 180ms ease;
}

a.app-item:hover {
  transform: translateY(-2px);
  background: rgba(255, 255, 255, 0.16);
  box-shadow: var(--shadow-soft);
}

.app-item img {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-md);
  object-fit: cover;
  background: rgba(255, 255, 255, 0.08);
  flex-shrink: 0;
}

.app-item-info {
  flex: 1;
  min-width: 0;
}

.app-item-info strong {
  display: block;
  font-size: 1.05rem;
}

.app-item-info span {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.85rem;
  word-break: break-all;
}

.item-icon-wrap{
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.app-item-info span.platform-icon, .app-item-info span.platform-icon + span {
  display: inline-block;
}

.app-item-info p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.5;
}

.app-item-meta {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.78rem;
}

.app-item-chart {
  display: none;
}

@media (min-width: 560px) {
  .app-item-chart {
    width: 220px;
    display: block;
  }
}

.app-item-chart .sparkline {
  display: block;
  width: 100%;
  height: 40px;
  opacity: 0.9;
}

.platform-badge {
  margin-bottom: 12px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
  padding: 3px 9px;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.08);
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.platform-badge svg {
  width: 16px;
  height: 16px;
}

.platform-icon {
  display: inline-flex;
  vertical-align: -2px;
  margin-left: 0px;
  color: var(--muted);
}

.platform-icon svg {
  width: 22px;
  height: 22px;
}

/* Mirrors admin's .badge.badge-warning (assets/css/admin.css) so the "build in
   progress" chip reads identically for admins and testers. */
.app-item-info .build-in-progress-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  margin: 0px 4px;
  border-radius: var(--radius-full);
  background: rgba(251, 191, 36, 0.1);
  color: #fbbf24;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.01em;
}

/* Corner badge for production apps — icon only, tucked into the card's corner
   instead of cluttering the title text with a label. */
.production-badge {
  position: absolute;
  top: -8px;
  right: -8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #f87171;
  color: #fff;
  box-shadow: 0 2px 8px rgba(248, 113, 113, 0.5);
}

.production-badge svg {
  width: 14px;
  height: 14px;
}

.app-item.is-building,
.card.is-building {
  position: relative;
  overflow: hidden;
  border-color: rgba(245, 158, 11, 0.16);
}

.app-item.is-building::before,
.card.is-building::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 1.5px;
  background: linear-gradient(
    90deg,
    transparent 0%,
    transparent 8%,
    rgba(245, 158, 11, 0.16) 12%,
    rgba(245, 158, 11, 0.55) 17%,
    #fbbf24 21%,
    #fff 24%,
    #fbbf24 27%,
    rgba(245, 158, 11, 0.35) 31%,
    transparent 36%,
    transparent 100%
  );
  background-size: 320% 100%;
  animation: borderSweep 3.2s linear infinite;
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
  filter: drop-shadow(0 0 7px rgba(251, 191, 36, 0.42));
}

.app-item.is-building::after,
.card.is-building::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.025), 0 0 26px rgba(245, 158, 11, 0.025);
  pointer-events: none;
}

@keyframes borderSweep {
  0% { background-position: 110% 0; }
  100% { background-position: -210% 0; }
}

.app-item.is-other {
  opacity: 0.55;
  filter: grayscale(0.4);
}

.app-item.is-other:hover {
  opacity: 0.8;
}

.other-platform-toggle {
  display: block;
  width: 100%;
  margin-top: 18px;
  padding: 12px;
  border: 1px dashed var(--card-border);
  border-radius: var(--radius-lg);
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 150ms ease, color 150ms ease;
}

.other-platform-toggle:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
}

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

.download-chart-card {
  margin-top: 24px;
  padding: 20px;
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.05);
  text-align: left;
}

.download-chart-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 12px;
}

.download-chart-head span {
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 600;
}

.download-chart-head strong {
  font-size: 1.3rem;
}

.chart-wrap {
  position: relative;
}

#downloadChart {
  display: block;
  width: 100%;
}

.chart-tip {
  position: absolute;
  transform: translateX(-50%);
  padding: 5px 9px;
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  background: rgba(15, 23, 42, 0.96);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(6px);
  color: var(--text);
  font-size: 0.72rem;
  white-space: nowrap;
  pointer-events: none;
}

code {
  background: rgba(255, 255, 255, 0.1);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  font-size: 0.85em;
}

/* ---------- Empty state ---------- */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 56px 24px;
  border: 1px dashed var(--card-border);
  border-radius: var(--radius-xl);
  background: rgba(255, 255, 255, 0.04);
  box-shadow: var(--shadow-soft);
  text-align: center;
}

.empty-state svg {
  width: 176px;
  height: auto;
  margin-bottom: 20px;
}

.empty-state h2 {
  margin: 0;
  font-size: 1.1rem;
}

.empty-state p {
  margin: 8px 0 0;
  /* max-width: 380px; */
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.6;
}

/* ---------- Redirect-to-store confirmation modal ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(2, 6, 23, 0.7);
  backdrop-filter: blur(4px);
  opacity: 0;
  transition: opacity 150ms ease;
}

.modal-overlay.visible {
  opacity: 1;
}

.modal-panel {
  width: min(420px, 100%);
  padding: 24px;
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  background: #0f172a;
  box-shadow: 0 30px 60px rgba(2, 6, 23, 0.5);
  transform: scale(0.96);
  opacity: 0;
  text-align: left;
  transition: transform 150ms ease, opacity 150ms ease;
}

.modal-overlay.visible .modal-panel {
  transform: scale(1);
  opacity: 1;
}

.modal-panel h3 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: normal;
}

.modal-message {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.6;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 22px;
}

.modal-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 40px;
  padding: 0 18px;
  border: none;
  border-radius: var(--radius-full);
  font: inherit;
  font-size: 0.86rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 120ms ease, box-shadow 150ms ease, background 150ms ease;
}

.modal-btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  box-shadow: var(--shadow-glow);
}

.modal-btn-primary:hover {
  box-shadow: var(--shadow-glow-hover);
}

.modal-btn-ghost {
  border: 1px solid var(--card-border);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
}

.modal-btn-ghost:hover {
  background: rgba(255, 255, 255, 0.12);
}

@media (max-width: 720px) {
  .page {
    padding: 32px 0;
  }

  .card {
    padding: 28px 20px;
  }

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

  .button {
    width: 100%;
  }
}
