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

:root {
  --bg: #121212;
  --bg-gradient: #1a1a2e;
  --surface: #1e1e2e;
  --surface-border: rgba(103, 80, 164, 0.15);
  --primary: #6750A4;
  --primary-light: #D0BCFF;
  --primary-dim: rgba(103, 80, 164, 0.3);
  --text: #E6E1E5;
  --text-secondary: #CAC4D0;
  --text-muted: #938F99;
  --code-bg: #2d2d3d;
  --max-width: 1100px;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  overflow-x: hidden;
}

a {
  color: var(--primary-light);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* Fade-in animation */
.fade-in {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}

.fade-in.visible {
  opacity: 1;
  transform: translateY(0);
}

/* ---- Hero ---- */
.hero {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 60px 24px;
  background: linear-gradient(180deg, var(--bg) 0%, var(--bg-gradient) 100%);
  position: relative;
}

.hero-inner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 64px;
  max-width: var(--max-width);
  width: 100%;
}

.hero-text {
  flex: 1;
  min-width: 0;
}

.hero-phone {
  flex: 0 0 auto;
}

.hero-mascot {
  width: 220px;
  height: 220px;
}

.hero h1,
.hero-text-centered h1 {
  font-weight: 800;
  background: linear-gradient(135deg, #fff 0%, var(--primary-light) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -1px;
}

.hero h1 {
  font-size: 3.5rem;
  margin-bottom: 8px;
}

.hero .tagline {
  font-size: 1.35rem;
  color: var(--text);
  font-weight: 600;
  margin-bottom: 16px;
}

.hero .sub {
  font-size: 1.05rem;
  color: var(--text-secondary);
  max-width: 520px;
  margin-bottom: 36px;
  line-height: 1.7;
}

.hero-badges {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.hero-badges img {
  width: auto;
  height: 48px;
  transition: transform 0.15s ease;
}

.hero-badges a:hover img {
  transform: scale(1.05);
}

.github-badge {
  margin-top: 16px;
}

.github-badge a:hover {
  text-decoration: none;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 14px 28px;
  border-radius: 12px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.btn:hover {
  transform: translateY(-2px);
  text-decoration: none;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 4px 24px var(--primary-dim);
}

.btn-primary:hover {
  box-shadow: 0 8px 32px var(--primary-dim);
}

.btn-outline {
  background: transparent;
  color: var(--primary-light);
  border: 2px solid var(--primary);
}

/* ---- Sections ---- */
section {
  padding: 100px 24px;
}

.container {
  max-width: var(--max-width);
  margin: 0 auto;
}

.section-title {
  font-size: 2rem;
  font-weight: 700;
  margin-bottom: 12px;
  text-align: center;
}

.section-desc {
  font-size: 1.1rem;
  color: var(--text-secondary);
  text-align: center;
  max-width: 640px;
  margin: 0 auto 48px;
}

/* ---- Phone Carousel ---- */
.phone-carousel {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.phone-carousel .phone-frame {
  width: 280px;
  background: var(--surface);
  border: 3px solid #333;
  border-radius: 28px;
  overflow: hidden;
  box-shadow: 0 20px 60px var(--primary-dim);
  position: relative;
}

.carousel-slides {
  position: relative;
  width: 100%;
}

.carousel-slide {
  display: block;
  width: 100%;
  height: auto;
  position: absolute;
  top: 0;
  left: 0;
  opacity: 0;
  transition: opacity 0.5s ease;
}

.carousel-slide.active {
  position: relative;
  opacity: 1;
}

.carousel-label {
  margin-top: 16px;
  font-size: 1rem;
  color: var(--text-secondary);
  font-weight: 500;
  min-height: 1.6em;
  transition: opacity 0.4s ease;
}

.carousel-dots {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}

.dot {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: none;
  background: var(--text-muted);
  background-clip: content-box;
  padding: 8px;
  cursor: pointer;
  transition: background 0.3s ease, transform 0.2s ease;
}

.dot.active {
  background-color: var(--primary-light);
  transform: scale(1.3);
}

.dot:hover {
  background-color: var(--primary);
}

/* ---- Features Grid ---- */
.features-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}

.feature-card {
  background: var(--surface);
  border: 1px solid var(--surface-border);
  border-radius: 16px;
  padding: 28px;
  transition: transform 0.2s ease, border-color 0.2s ease;
}

.feature-card:hover {
  transform: translateY(-4px);
  border-color: var(--primary);
}

.feature-icon {
  font-size: 1.8rem;
  margin-bottom: 12px;
  display: block;
}

.feature-card h3 {
  font-size: 1.1rem;
  margin-bottom: 8px;
}

.feature-card p {
  font-size: 0.95rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* ---- Download Section ---- */
.download {
  background: linear-gradient(180deg, var(--bg) 0%, var(--bg-gradient) 100%);
}

.badge-row {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 48px;
}

.badge-row a {
  transition: transform 0.15s ease;
}

.badge-row a:hover {
  transform: scale(1.05);
}

.badge-row img {
  width: auto;
  height: 44px;
}

.cli-installs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 32px;
}

.cli-card {
  background: var(--code-bg);
  border-radius: 12px;
  padding: 20px;
}

.cli-card .label {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 8px;
}

.cli-card code {
  font-family: "SF Mono", "Fira Code", "Cascadia Code", monospace;
  font-size: 0.9rem;
  color: var(--primary-light);
  word-break: break-all;
}

.download-footer {
  text-align: center;
  margin-top: 16px;
}

.download-footer a {
  color: var(--text-muted);
  font-size: 0.95rem;
}

.desktop-preview {
  max-width: 700px;
  margin: 0 auto 48px;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.5);
}

.desktop-preview img {
  width: 100%;
  height: auto;
  display: block;
}

/* ---- Footer ---- */
footer {
  border-top: 1px solid var(--surface-border);
  padding: 40px 24px;
  text-align: center;
}

.footer-links {
  display: flex;
  gap: 24px;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.footer-links a {
  color: var(--text-secondary);
  font-size: 0.95rem;
}

.footer-links a:hover {
  color: var(--primary-light);
}

footer .note {
  font-size: 0.85rem;
  color: var(--text-muted);
}

footer .impressum {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 12px;
}

/* ---- Responsive ---- */
@media (max-width: 768px) {
  .hero {
    padding: 40px 16px;
  }

  .hero-inner {
    flex-direction: column;
    text-align: center;
    gap: 40px;
  }

  .hero-text {
    display: flex;
    flex-direction: column;
    align-items: center;
  }

  .hero h1 {
    font-size: 2.5rem;
  }

  .hero .tagline {
    font-size: 1.1rem;
  }

  .hero .sub {
    text-align: center;
  }

  .hero-badges {
    justify-content: center;
  }

  section {
    padding: 64px 16px;
  }

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

  .cli-installs {
    grid-template-columns: 1fr;
  }

  .phone-carousel .phone-frame {
    width: 240px;
  }
}

@media (min-width: 769px) and (max-width: 1024px) {
  .features-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ---- Subpage (run-gemma-locally) ---- */
.page-nav {
  padding: 20px 24px;
  max-width: var(--max-width);
  margin: 0 auto;
}

.page-nav a {
  color: var(--text-muted);
  font-size: 0.95rem;
  font-weight: 500;
}

.page-nav a:hover {
  color: var(--primary-light);
  text-decoration: none;
}

.hero-inner-stacked {
  flex-direction: column;
  text-align: center;
}

.hero-text-centered {
  align-items: center;
  display: flex;
  flex-direction: column;
  max-width: 820px;
}

.hero-text-centered h1 {
  font-size: 3rem;
  margin-bottom: 16px;
  line-height: 1.1;
}

.hero-text-centered .sub {
  max-width: 680px;
  text-align: center;
}

.hero-text-centered .hero-badges {
  justify-content: center;
}

/* Models table */
.models-table-wrapper {
  overflow-x: auto;
  border-radius: 16px;
  border: 1px solid var(--surface-border);
  background: var(--surface);
}

.models-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

.models-table th,
.models-table td {
  padding: 14px 18px;
  text-align: left;
  border-bottom: 1px solid var(--surface-border);
}

.models-table th {
  background: rgba(103, 80, 164, 0.08);
  font-weight: 600;
  color: var(--text);
}

.models-table tbody tr:last-child td {
  border-bottom: none;
}

.models-table td {
  color: var(--text-secondary);
}

.section-note {
  max-width: 760px;
  margin: 24px auto 0;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.95rem;
}

.section-note code {
  background: var(--code-bg);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.85rem;
  color: var(--primary-light);
}

/* How-to steps */
.howto-step {
  max-width: 760px;
  margin: 0 auto 40px;
  background: var(--surface);
  border: 1px solid var(--surface-border);
  border-radius: 16px;
  padding: 28px;
}

.howto-step h3 {
  font-size: 1.25rem;
  margin-bottom: 12px;
  color: var(--text);
}

.howto-step p {
  color: var(--text-secondary);
  margin-bottom: 16px;
}

.howto-step p:last-child {
  margin-bottom: 0;
}

.howto-step img {
  display: block;
  max-width: 320px;
  width: 100%;
  aspect-ratio: 1080 / 2400;
  border-radius: 12px;
  margin-top: 8px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

/* Split (works / doesn't) */
.split-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
}

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

.split-card h3 {
  font-size: 1.15rem;
  margin-bottom: 16px;
}

.split-card ul {
  list-style: none;
  padding: 0;
}

.split-card li {
  color: var(--text-secondary);
  font-size: 0.95rem;
  padding: 6px 0 6px 24px;
  position: relative;
}

.split-card li::before {
  position: absolute;
  left: 0;
  top: 6px;
  color: var(--primary-light);
}

.split-card:first-child li::before {
  content: "\2713";
}

.split-card:last-child li::before {
  content: "\2022";
  color: var(--text-muted);
}

/* FAQ */
.faq-list {
  max-width: 760px;
  margin: 0 auto;
}

.faq-item {
  background: var(--surface);
  border: 1px solid var(--surface-border);
  border-radius: 12px;
  padding: 18px 22px;
  margin-bottom: 12px;
}

.faq-item summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--text);
  list-style: none;
  position: relative;
  padding-right: 28px;
}

.faq-item summary::-webkit-details-marker {
  display: none;
}

.faq-item summary::after {
  content: "+";
  position: absolute;
  right: 0;
  top: 0;
  font-size: 1.4rem;
  color: var(--primary-light);
  line-height: 1;
}

.faq-item[open] summary::after {
  content: "\2212";
}

.faq-item p {
  color: var(--text-secondary);
  margin-top: 12px;
  line-height: 1.6;
}

/* Math gallery (latex-math page) */
.math-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  align-items: start;
  gap: 24px;
  max-width: var(--max-width);
  margin: 0 auto;
}

.math-card {
  background: var(--surface);
  border: 1px solid var(--surface-border);
  border-radius: 16px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  margin: 0;
  transition: transform 0.2s ease, border-color 0.2s ease;
}

.math-card:hover {
  transform: translateY(-4px);
  border-color: var(--primary);
}

.math-card img {
  display: block;
  width: 100%;
  height: auto;
  background: var(--bg-gradient);
}

.math-card figcaption {
  padding: 20px 22px 24px;
}

.math-card figcaption h3 {
  font-size: 1.05rem;
  margin-bottom: 8px;
}

.math-card figcaption p {
  font-size: 0.92rem;
  color: var(--text-secondary);
  line-height: 1.55;
}

.math-card figcaption code {
  background: var(--code-bg);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 0.82rem;
  color: var(--primary-light);
}

/* Feature card as a link */
.feature-card-link {
  color: inherit;
  display: block;
}

.feature-card-link:hover {
  text-decoration: none;
}

.feature-card-link .card-cta {
  color: var(--primary-light);
  font-weight: 600;
  margin-left: 4px;
  white-space: nowrap;
}

@media (max-width: 768px) {
  .hero-text-centered h1 {
    font-size: 2.2rem;
  }

  .howto-step {
    padding: 22px;
  }

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

  .models-table th,
  .models-table td {
    padding: 10px 12px;
    font-size: 0.9rem;
  }
}
