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

:root {
  --color-bg: #f5f5f5;
  --color-surface: #ffffff;
  --color-primary: #1a237e;
  --color-primary-light: #3949ab;
  --color-text: #212121;
  --color-text-muted: #757575;
  --color-border: #e0e0e0;
  --radius: 12px;
  --shadow: 0 2px 8px rgba(0,0,0,0.10);
}

@media (prefers-color-scheme: dark) {
  :root {
    --color-bg: #121212;
    --color-surface: #1e1e1e;
    --color-primary: #7986cb;
    --color-primary-light: #9fa8da;
    --color-text: #e0e0e0;
    --color-text-muted: #9e9e9e;
    --color-border: #333333;
    --shadow: 0 2px 8px rgba(0,0,0,0.4);
  }
}

body {
  font-family: system-ui, -apple-system, sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Header ── */
header {
  background: var(--color-primary);
  color: #fff;
  padding: 2rem 1.5rem 1.5rem;
  text-align: center;
}

header h1 {
  font-size: clamp(1.6rem, 5vw, 2.4rem);
  font-weight: 700;
  letter-spacing: -0.5px;
}

.subtitle {
  margin-top: 0.4rem;
  opacity: 0.85;
  font-size: 1rem;
}

/* ── Main ── */
main {
  flex: 1;
  max-width: 900px;
  width: 100%;
  margin: 0 auto;
  padding: 1.5rem 1rem;
}

.intro {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1.2rem 1.4rem;
  margin-bottom: 2rem;
  font-size: 0.97rem;
  color: var(--color-text-muted);
}

/* ── App grid ── */
.app-grid {
  display: grid;
  gap: 1.25rem;
}

.app-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  padding: 1rem;
  transition: box-shadow 0.2s;
}

.app-card:hover {
  box-shadow: 0 4px 16px rgba(0,0,0,0.15);
}

.app-info {
  flex: 1;
}

.app-title {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--color-primary);
  margin-bottom: 0.35rem;
}

.app-desc {
  color: var(--color-text-muted);
  font-size: 0.93rem;
  margin-bottom: 1rem;
}

.app-link {
  display: inline-block;
  background: var(--color-primary);
  color: #fff;
  text-decoration: none;
  padding: 0.45rem 1rem;
  border-radius: 6px;
  font-size: 0.9rem;
  font-weight: 500;
  transition: background 0.15s;
}

.app-link:hover {
  background: var(--color-primary-light);
}

/* ── QR code ── */
.app-qr {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  flex-shrink: 0;
}

.app-qr canvas,
.app-qr img {
  width: 100px;
  height: 100px;
  border-radius: 6px;
  border: 1px solid var(--color-border);
}

.app-qr img {
  cursor: zoom-in;
}

.qr-label {
  font-size: 0.72rem;
  color: var(--color-text-muted);
  text-align: center;
}

/* ── QR lightbox ── */
#qr-lightbox {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  cursor: zoom-out;
}
#qr-lightbox.open {
  display: flex;
}
#qr-lightbox img {
  width: min(90vw, 90vh);
  height: min(90vw, 90vh);
  border-radius: 12px;
  image-rendering: pixelated;
}

/* ── Empty state ── */
.empty-state {
  text-align: center;
  color: var(--color-text-muted);
  padding: 3rem 1rem;
  font-size: 1rem;
}

/* ── Footer ── */
footer {
  text-align: center;
  padding: 1.25rem;
  font-size: 0.85rem;
  color: var(--color-text-muted);
  border-top: 1px solid var(--color-border);
}

footer a {
  color: var(--color-primary);
}

/* ── Responsive: stack QR below on narrow screens ── */
@media (max-width: 480px) {
  .app-card {
    flex-direction: column;
  }
  .app-qr {
    width: 100%;
    flex-direction: row;
    justify-content: flex-start;
    align-items: center;
  }
  .app-qr img,
  .app-qr canvas {
    width: 80px;
    height: 80px;
  }
}
