:root {
  --background: #f9fafb;
  --surface: #ffffff;
  --surface-muted: #f3f4f6;
  --text: #1f2937;
  --text-muted: #5b6472;
  --border: #e5e7eb;
  --accent: #7c3aed;
  --accent-dark: #6d28d9;
  --focus: #2563eb;
  --shadow: 0 4px 16px rgba(15, 23, 42, 0.08);
  --shadow-hover: 0 18px 36px rgba(15, 23, 42, 0.14);
  --radius: 1rem;
}

* {
  box-sizing: border-box;
}

html {
  color-scheme: light;
  scroll-behavior: smooth;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  background: var(--background);
  color: var(--text);
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.6;
}

a {
  color: inherit;
}

button,
input,
select {
  font: inherit;
}

button,
a,
input,
select {
  -webkit-tap-highlight-color: transparent;
}

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

.skip-link {
  position: fixed;
  top: 0.75rem;
  left: 0.75rem;
  z-index: 1000;
  padding: 0.75rem 1rem;
  transform: translateY(-160%);
  border-radius: 0.5rem;
  background: var(--text);
  color: #fff;
  font-weight: 700;
}

.skip-link:focus {
  transform: translateY(0);
}

.container {
  width: min(100% - 2rem, 72rem);
  margin-inline: auto;
}

.site-header {
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.94);
}

.header-inner {
  min-height: 4.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.back-link,
.portal-link {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  border-radius: 0.7rem;
  font-weight: 700;
  text-decoration: none;
  transition: color 200ms ease, background-color 200ms ease, box-shadow 200ms ease, transform 200ms ease;
}

.back-link {
  padding: 0.5rem 0.75rem;
  color: var(--text-muted);
}

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

.portal-link {
  padding: 0.55rem 1rem;
  background: var(--text);
  color: #fff;
}

.portal-link:hover {
  background: #111827;
  transform: translateY(-1px);
}

.page-main {
  flex: 1;
  padding-block: clamp(3rem, 8vw, 5.5rem);
}

.hero {
  max-width: 46rem;
  margin-bottom: 3.5rem;
}

.eyebrow {
  display: inline-block;
  margin-bottom: 0.65rem;
  color: var(--accent-dark);
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.hero h1 {
  margin: 0;
  color: var(--text);
  font-size: clamp(2.4rem, 7vw, 4.5rem);
  line-height: 1.05;
  letter-spacing: -0.04em;
}

.hero p {
  max-width: 42rem;
  margin: 1.25rem 0 0;
  color: var(--text-muted);
  font-size: clamp(1.05rem, 2vw, 1.2rem);
}

.section-heading {
  margin-bottom: 1.25rem;
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 1rem;
}

.section-heading h2 {
  margin: 0;
  font-size: clamp(1.45rem, 3vw, 2rem);
}

.section-heading p {
  margin: 0.2rem 0 0;
  color: var(--text-muted);
}

.app-controls {
  margin: -0.25rem 0 1.25rem;
  padding: 1rem;
  display: grid;
  grid-template-columns: minmax(16rem, 1.6fr) repeat(2, minmax(10rem, 1fr)) auto;
  align-items: end;
  gap: 0.85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.control-field {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.control-field label {
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.control-field input,
.control-field select {
  width: 100%;
  min-height: 46px;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 0.7rem;
  background: #fff;
  color: var(--text);
}

.control-field input::placeholder {
  color: #9ca3af;
}

.control-field input:hover,
.control-field select:hover,
.control-field input:focus,
.control-field select:focus {
  border-color: #cbd5e1;
}

.clear-filters {
  min-height: 46px;
  padding: 0.65rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: 0.7rem;
  background: var(--surface-muted);
  color: var(--text);
  font-weight: 800;
  cursor: pointer;
  transition: background-color 200ms ease, border-color 200ms ease, transform 200ms ease;
}

.clear-filters:hover:not(:disabled) {
  border-color: #cbd5e1;
  background: #e5e7eb;
  transform: translateY(-1px);
}

.clear-filters:disabled {
  cursor: default;
  opacity: 0.5;
}

.empty-state {
  grid-column: 1 / -1;
  padding: 3rem 1.5rem;
  border: 1px dashed #cbd5e1;
  border-radius: var(--radius);
  color: var(--text-muted);
  text-align: center;
}

.apps-page {
  --accent: #7c3aed;
  --accent-dark: #6d28d9;
}

.apps-page .page-main {
  min-height: 100dvh;
  padding-block: max(2rem, env(safe-area-inset-top)) max(2rem, env(safe-area-inset-bottom));
}

.apps-page .hero {
  margin-bottom: 2.25rem;
}

.apps-hero {
  position: relative;
}

.apps-hero::after {
  content: "";
  width: clamp(8rem, 20vw, 14rem);
  aspect-ratio: 1;
  position: absolute;
  top: -2rem;
  right: min(-12vw, -2rem);
  z-index: -1;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(124, 58, 237, 0.14), rgba(124, 58, 237, 0));
}

.app-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 18.5rem), 1fr));
  align-items: stretch;
  gap: 1.5rem;
}

.app-card {
  width: 100%;
  overflow: hidden;
  display: grid;
  grid-template-rows: auto 1fr;
  border: 1px solid var(--border);
  border-radius: 1.25rem;
  background: var(--surface);
  color: inherit;
  box-shadow: var(--shadow);
  text-decoration: none;
  transition: box-shadow 250ms ease, transform 250ms ease;
}

.app-card:hover,
.app-card:focus-visible {
  transform: translateY(-4px);
  box-shadow: var(--shadow-hover);
}

.app-card:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 4px;
}

.app-card[hidden] {
  display: none;
}

.app-preview {
  min-height: clamp(11rem, 22vw, 14rem);
  padding: clamp(1rem, 3vw, 1.4rem);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
  background:
    radial-gradient(circle at 75% 20%, rgba(255, 255, 255, 0.38), transparent 30%),
    linear-gradient(145deg, #2563eb, #7c3aed);
  color: #fff;
}

.weather-orb {
  width: clamp(6.25rem, 12vw, 8rem);
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 2rem;
  background: rgba(255, 255, 255, 0.13);
  box-shadow: 0 18px 40px rgba(30, 41, 59, 0.24);
  backdrop-filter: blur(12px);
}

.preview-data {
  display: flex;
  flex-direction: column;
  align-items: center;
  color: rgba(255, 255, 255, 0.82);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.preview-temperature {
  color: #fff;
  font-size: clamp(2.35rem, 7vw, 3.15rem);
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.06em;
}

.app-card-body {
  min-width: 0;
  padding: clamp(1.25rem, 3vw, 1.65rem);
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.app-card-heading {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 1rem;
}

.app-category {
  color: var(--accent-dark);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.app-card h3 {
  margin: 0.2rem 0 0;
  font-size: clamp(1.35rem, 3vw, 1.75rem);
  line-height: 1.12;
}

.app-status {
  flex: 0 0 auto;
  padding: 0.35rem 0.65rem;
  border-radius: 999px;
  background: #dcfce7;
  color: #166534;
  font-size: 0.72rem;
  font-weight: 800;
}

.snake-app-card .app-status {
  background: #dcfce7;
  color: #14532d;
}

.app-card-body > p {
  margin: 1rem 0;
  color: var(--text-muted);
}

.app-features {
  margin: 0 0 1.5rem;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  list-style: none;
}

.app-features li {
  padding: 0.38rem 0.65rem;
  border-radius: 999px;
  background: #f3e8ff;
  color: #6b21a8;
  font-size: 0.8rem;
  font-weight: 700;
}

.app-open-link {
  min-height: 48px;
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.7rem 1rem;
  border-radius: 0.75rem;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
  text-decoration: none;
  transition: background-color 200ms ease, transform 200ms ease;
}

.app-card:hover .app-open-link,
.app-card:focus-visible .app-open-link {
  background: var(--accent-dark);
  transform: translateY(-1px);
}

.snake-preview {
  background:
    radial-gradient(circle at 70% 24%, rgba(34, 197, 94, 0.32), transparent 28%),
    linear-gradient(145deg, #07111f, #14532d);
}

.pdf-master-preview {
  background:
    radial-gradient(circle at 76% 20%, rgba(255, 255, 255, 0.34), transparent 30%),
    linear-gradient(145deg, #4f46e5, #7c3aed);
}

.shortcut-app-preview {
  background:
    radial-gradient(circle at 76% 20%, rgba(255, 255, 255, 0.34), transparent 30%),
    linear-gradient(145deg, #2563eb, #7c3aed);
}

.better-bahn-preview {
  background:
    radial-gradient(circle at 76% 20%, rgba(250, 204, 21, 0.32), transparent 30%),
    linear-gradient(145deg, #171717, #404040);
}

.pdf-master-orb {
  background: rgba(255, 255, 255, 0.13);
}

.shortcut-app-orb {
  background: rgba(255, 255, 255, 0.13);
}

.better-bahn-orb {
  background: rgba(255, 255, 255, 0.14);
}

.better-bahn-app-card .app-features li {
  background: #fef3c7;
  color: #92400e;
}

.better-bahn-app-card .app-open-link {
  background: #171717;
}

.better-bahn-app-card:hover .app-open-link,
.better-bahn-app-card:focus-visible .app-open-link {
  background: #000000;
}

.snake-stage {
  width: min(100%, clamp(8rem, 15vw, 10.5rem));
  aspect-ratio: 1;
  position: relative;
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  grid-template-rows: repeat(7, 1fr);
  gap: 0.35rem;
  padding: 1rem;
  border: 1px solid rgba(134, 239, 172, 0.28);
  border-radius: 1.2rem;
  background:
    linear-gradient(rgba(134, 239, 172, 0.09) 1px, transparent 1px),
    linear-gradient(90deg, rgba(134, 239, 172, 0.09) 1px, transparent 1px),
    rgba(2, 6, 23, 0.62);
  background-size: 28px 28px;
  box-shadow: 0 18px 40px rgba(2, 6, 23, 0.35);
}

.snake-stage span,
.snake-stage i {
  display: block;
  border-radius: 0.45rem;
}

.snake-stage span {
  background: linear-gradient(145deg, #bbf7d0, #22c55e);
  box-shadow: 0 0 18px rgba(34, 197, 94, 0.45);
}

.snake-stage span:nth-child(1) { grid-column: 2; grid-row: 4; }
.snake-stage span:nth-child(2) { grid-column: 3; grid-row: 4; }
.snake-stage span:nth-child(3) { grid-column: 4; grid-row: 4; }
.snake-stage span:nth-child(4) { grid-column: 5; grid-row: 4; }
.snake-stage span:nth-child(5) { grid-column: 5; grid-row: 3; }

.snake-stage i {
  grid-column: 6;
  grid-row: 2;
  background: #facc15;
  box-shadow: 0 0 22px rgba(250, 204, 21, 0.62);
}

.app-empty-state[hidden] {
  display: none;
}

.app-empty-state {
  grid-column: 1 / -1;
}

@media (max-width: 42rem) {
  .header-inner {
    min-height: auto;
    padding-block: 0.8rem;
    flex-direction: column;
    align-items: stretch;
  }

  .back-link,
  .portal-link {
    width: 100%;
  }

  .app-controls { grid-template-columns: 1fr; }
  .app-card { grid-template-rows: auto 1fr; }
  .app-preview { min-height: 14rem; }
  .weather-orb { width: 7.5rem; border-radius: 1.5rem; }
  .weather-orb svg { width: 100px; height: 100px; }
}

@media (min-width: 62rem) {
  .app-controls {
    grid-template-columns: minmax(16rem, 1.4fr) minmax(11rem, 0.8fr) minmax(12rem, 0.8fr) auto;
  }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .app-card:hover,
  .app-card:focus-visible,
  .app-card:hover .app-open-link,
  .app-card:focus-visible .app-open-link,
  .clear-filters:hover:not(:disabled) { transform: none; }

  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
