:root {
  color-scheme: light dark;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --radius: 14px;
  --ease: 0.15s ease;

  --bg: #f1f5f9;
  --surface: #ffffff;
  --surface-hover: #f8fafc;
  --border: rgba(15, 23, 42, 0.1);
  --text: #0f172a;
  --muted: #64748b;
  --accent-fallback: #0284c7;
  --success: #059669;
  --success-soft: rgba(5, 150, 105, 0.12);
  --danger: #dc2626;
  --danger-soft: rgba(220, 38, 38, 0.1);
  --warn: #d97706;
  --warn-soft: rgba(217, 119, 6, 0.12);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 8px 24px rgba(0, 0, 0, 0.04);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #070b14;
    --surface: #111827;
    --surface-hover: #152033;
    --border: rgba(148, 163, 184, 0.14);
    --text: #e2e8f0;
    --muted: #94a3b8;
    --accent-fallback: #38bdf8;
    --success: #34d399;
    --success-soft: rgba(52, 211, 153, 0.14);
    --danger: #f87171;
    --danger-soft: rgba(248, 113, 113, 0.14);
    --warn: #fbbf24;
    --warn-soft: rgba(251, 191, 36, 0.14);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.25), 0 10px 28px rgba(0, 0, 0, 0.22);
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-family: var(--font);
  line-height: 1.4;
  color: var(--text);
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
}

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
}

a {
  color: inherit;
  text-decoration: none;
}

.page {
  width: min(100%, 40rem);
  margin: 0 auto;
  padding: max(1.25rem, var(--safe-top)) 1.1rem calc(1.5rem + var(--safe-bottom));
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.header {
  margin-bottom: 1.35rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.7rem;
}

.brand-mark {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 0.65rem;
  background: linear-gradient(135deg, #0ea5e9, #8b5cf6);
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 0.72rem;
  color: #fff;
  letter-spacing: -0.03em;
  flex-shrink: 0;
}

.brand strong {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.03em;
}

/* Square adaptive app tiles */
.apps {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 7.5rem), 1fr));
  gap: clamp(0.65rem, 2.5vw, 1rem);
  flex: 1;
  align-content: start;
}

.app {
  aspect-ratio: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  gap: 0.35rem;
  padding: clamp(0.7rem, 2.5vw, 1rem) clamp(0.55rem, 2vw, 0.85rem) clamp(0.65rem, 2vw, 0.85rem);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transition: background var(--ease), border-color var(--ease), transform var(--ease);
  -webkit-tap-highlight-color: transparent;
  position: relative;
  min-width: 0;
}

.app:hover {
  background: var(--surface-hover);
  border-color: color-mix(in srgb, var(--accent) 30%, var(--border));
}

.app:active {
  transform: scale(0.98);
}

.app:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.app-status {
  position: absolute;
  top: clamp(0.45rem, 1.5vw, 0.65rem);
  right: clamp(0.45rem, 1.5vw, 0.65rem);
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  flex-shrink: 0;
}

.app-status.live {
  background: var(--success);
  box-shadow: 0 0 0 3px var(--success-soft);
  animation: pulse 2s ease-in-out infinite;
}

.app-status.down {
  background: var(--danger);
  box-shadow: 0 0 0 3px var(--danger-soft);
}

.app-status.beta {
  background: var(--warn);
  box-shadow: 0 0 0 3px var(--warn-soft);
}

.app-icon {
  flex: 1;
  width: 100%;
  display: grid;
  place-items: center;
  min-height: 0;
}

.app-icon-box {
  width: clamp(2.6rem, 12vw, 3.4rem);
  height: clamp(2.6rem, 12vw, 3.4rem);
  border-radius: 0.85rem;
  display: grid;
  place-items: center;
  background: color-mix(in srgb, var(--accent) 16%, transparent);
  color: var(--accent);
}

.app-icon-box svg {
  width: 52%;
  height: 52%;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.85;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.app-name {
  font-size: clamp(0.82rem, 2.8vw, 0.95rem);
  font-weight: 650;
  letter-spacing: -0.02em;
  text-align: center;
  line-height: 1.2;
  width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.site-footer {
  margin-top: 1.75rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: center;
}

.footer-link {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
  transition: color var(--ease);
}

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

/* Credits page */
.credits-page {
  max-width: 36rem;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 1.25rem;
}

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

.credits-head {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  margin-bottom: 0.5rem;
}

.credits-head h1 {
  margin: 0;
  font-size: 1.4rem;
  font-weight: 750;
  letter-spacing: -0.03em;
}

.credits-head .sub {
  margin: 0.15rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.credits-section {
  padding: 1.35rem 0;
  border-top: 1px solid var(--border);
}

.credits-section h2 {
  margin: 0 0 0.7rem;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.credits-section p {
  margin: 0 0 0.7rem;
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.65;
}

.credits-section p:last-child {
  margin-bottom: 0;
}

.credits-section a {
  color: var(--accent-fallback);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.credits-section strong {
  color: var(--text);
  font-weight: 650;
}

@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.45;
  }
}

@media (prefers-reduced-motion: reduce) {
  .app-status.live {
    animation: none;
  }

  .app {
    transition: none;
  }
}

@media (min-width: 520px) {
  .apps {
    grid-template-columns: repeat(3, 1fr);
  }
}
