:root {
  color-scheme: light;
  --bg: #f6f8fb;
  --surface: #ffffff;
  --surface-strong: #eef4ff;
  --ink: #111827;
  --muted: #5c6675;
  --line: #d8e0ec;
  --blue: #2563eb;
  --blue-dark: #1746a2;
  --green: #169b72;
  --amber: #b7791f;
  --violet: #7c3aed;
  --sky: #0284c7;
  --shadow: 0 18px 42px rgba(17, 24, 39, 0.1);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  min-height: 100%;
  margin: 0;
  background:
    linear-gradient(180deg, rgba(37, 99, 235, 0.1), rgba(37, 99, 235, 0) 21rem),
    radial-gradient(circle at top right, rgba(22, 155, 114, 0.12), rgba(22, 155, 114, 0) 18rem),
    var(--bg);
  color: var(--ink);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
}

body.standalone {
  background-color: var(--bg);
}

body.app-wrapper-body {
  height: 100dvh;
  overflow: hidden;
  background: var(--surface);
}

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

.shell {
  width: min(100%, 72rem);
  min-height: 100dvh;
  margin: 0 auto;
  padding:
    calc(1rem + env(safe-area-inset-top))
    max(1rem, env(safe-area-inset-right))
    calc(1.25rem + env(safe-area-inset-bottom))
    max(1rem, env(safe-area-inset-left));
}

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

.brand {
  display: flex;
  align-items: center;
  gap: 1rem;
  min-width: 0;
}

.brand-logo {
  display: block;
  flex: 0 0 auto;
  width: clamp(4rem, 18vw, 5.5rem);
  height: clamp(4rem, 18vw, 5.5rem);
  border-radius: 0;
  filter: drop-shadow(0 10px 16px rgba(15, 23, 42, 0.14));
}

.eyebrow {
  margin: 0;
  color: var(--blue-dark);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  color: var(--ink);
  font-size: clamp(1.7rem, 9vw, 2.7rem);
  font-weight: 900;
  line-height: 1;
  letter-spacing: 0;
}

.install-button {
  min-height: 2.75rem;
  padding: 0 1rem;
  border: 1px solid rgba(37, 99, 235, 0.32);
  border-radius: 8px;
  background: var(--surface);
  color: var(--blue-dark);
  font: inherit;
  font-size: 0.95rem;
  font-weight: 800;
  box-shadow: 0 8px 20px rgba(17, 24, 39, 0.08);
  cursor: pointer;
}

.install-button:active {
  transform: translateY(1px);
}

.app-nav {
  display: flex;
  gap: 0.65rem;
  margin-top: 0.4rem;
}

.nav-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.6rem;
  padding: 0 0.9rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 0.92rem;
  font-weight: 850;
  text-decoration: none;
  box-shadow: 0 8px 20px rgba(17, 24, 39, 0.06);
  cursor: pointer;
}

.nav-button-primary {
  border-color: rgba(37, 99, 235, 0.26);
  background: var(--blue);
  color: #ffffff;
}

.nav-button:active {
  transform: translateY(1px);
}

.app-wrapper {
  display: grid;
  grid-template-rows: auto 1fr;
  height: 100dvh;
  min-height: 100dvh;
  background: var(--surface);
}

.app-frame-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-height: calc(3.5rem + env(safe-area-inset-top));
  padding:
    calc(0.48rem + env(safe-area-inset-top))
    max(0.75rem, env(safe-area-inset-right))
    0.48rem
    max(0.75rem, env(safe-area-inset-left));
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 6px 18px rgba(17, 24, 39, 0.08);
  z-index: 1;
}

.app-back-link {
  position: relative;
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  width: 2.5rem;
  height: 2.5rem;
  border: 1px solid rgba(37, 99, 235, 0.22);
  border-radius: 999px;
  background: rgba(37, 99, 235, 0.08);
  color: var(--blue-dark);
  text-decoration: none;
  box-shadow: 0 8px 18px rgba(37, 99, 235, 0.12);
}

.app-back-icon {
  width: 0.72rem;
  height: 0.72rem;
  border-bottom: 2.5px solid currentColor;
  border-left: 2.5px solid currentColor;
  transform: translateX(0.12rem) rotate(45deg);
}

.app-back-link:active {
  transform: translateY(1px);
}

.app-frame-title {
  min-width: 0;
  overflow: hidden;
  color: var(--ink);
  font-size: 1rem;
  font-weight: 900;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.app-frame {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 0;
  border: 0;
  background: var(--surface);
}

.intro {
  margin-top: 0.8rem;
  padding: 1.1rem;
  border: 1px solid rgba(37, 99, 235, 0.15);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.78);
  box-shadow: 0 10px 30px rgba(37, 99, 235, 0.08);
  backdrop-filter: blur(14px);
}

.intro h2 {
  max-width: 44rem;
  color: var(--ink);
  font-size: clamp(1.4rem, 7vw, 3.15rem);
  font-weight: 900;
  line-height: 1.04;
  letter-spacing: 0;
}

.intro p {
  max-width: 42rem;
  margin-top: 0.75rem;
  color: var(--muted);
  font-size: clamp(0.98rem, 3.2vw, 1.16rem);
  font-weight: 650;
}

.app-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.85rem;
  margin-top: 1rem;
}

.app-card {
  position: relative;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.95rem;
  min-height: 11.25rem;
  padding: 1rem;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: inherit;
  text-decoration: none;
  box-shadow: 0 12px 32px rgba(17, 24, 39, 0.07);
  transition: transform 160ms ease, box-shadow 160ms ease, border-color 160ms ease;
}

.app-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 0.28rem;
  background: var(--accent, var(--blue));
}

.app-card:active {
  transform: translateY(1px);
}

.app-card:focus-visible,
.install-button:focus-visible,
.nav-button:focus-visible,
.app-back-link:focus-visible {
  outline: 3px solid rgba(37, 99, 235, 0.3);
  outline-offset: 3px;
}

@media (hover: hover) {
  .app-card:hover {
    transform: translateY(-2px);
    border-color: color-mix(in srgb, var(--accent, var(--blue)) 42%, var(--line));
    box-shadow: var(--shadow);
  }
}

.phrasal {
  --accent: var(--violet);
}

.sielpa {
  --accent: var(--amber);
}

.read-aloud {
  --accent: var(--sky);
}

.linespeak {
  --accent: var(--green);
}

.icon-wrap {
  display: grid;
  place-items: center;
  width: 4.8rem;
  height: 4.8rem;
  border: 1px solid rgba(17, 24, 39, 0.08);
  border-radius: 8px;
  background: var(--surface-strong);
}

.icon-wrap img {
  display: block;
  width: 3.85rem;
  height: 3.85rem;
  border-radius: 8px;
  object-fit: cover;
}

.read-aloud .icon-wrap img {
  object-fit: contain;
}

.app-content,
.app-title-row {
  display: flex;
  min-width: 0;
}

.app-content {
  flex-direction: column;
  gap: 0.42rem;
  padding-top: 0.15rem;
}

.app-title-row {
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.app-title {
  display: block;
  color: var(--ink);
  font-size: clamp(1.25rem, 5.4vw, 1.55rem);
  font-weight: 900;
  line-height: 1.1;
}

.app-copy {
  display: block;
  color: var(--muted);
  font-size: 0.96rem;
  font-weight: 600;
  line-height: 1.45;
}

.origin-badge {
  display: inline-flex;
  align-items: center;
  min-height: 1.55rem;
  padding: 0 0.45rem;
  border: 1px solid rgba(22, 155, 114, 0.24);
  border-radius: 999px;
  background: rgba(22, 155, 114, 0.08);
  color: #0f7558;
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
}

.launch-row {
  grid-column: 1 / -1;
  align-self: end;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 2.75rem;
  padding: 0.72rem 0.85rem;
  border-radius: 8px;
  background: color-mix(in srgb, var(--accent, var(--blue)) 10%, #ffffff);
  color: color-mix(in srgb, var(--accent, var(--blue)) 82%, #111827);
  font-size: 0.98rem;
  font-weight: 900;
}

.arrow {
  width: 0.66rem;
  height: 0.66rem;
  border-top: 2px solid currentColor;
  border-right: 2px solid currentColor;
  transform: rotate(45deg);
}

@supports not (color: color-mix(in srgb, #000 50%, #fff)) {
  .app-card:hover {
    border-color: var(--accent, var(--blue));
  }

  .launch-row {
    background: #f3f7ff;
    color: var(--blue-dark);
  }
}

@media (min-width: 44rem) {
  .shell {
    padding-top: calc(1.4rem + env(safe-area-inset-top));
  }

  .intro {
    padding: 1.35rem;
  }

  .app-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
    margin-top: 1.2rem;
  }

  .app-card {
    min-height: 14.75rem;
    padding: 1.15rem;
  }
}

@media (min-width: 64rem) {
  .shell {
    display: grid;
    align-content: center;
    padding-top: calc(2rem + env(safe-area-inset-top));
    padding-bottom: calc(2rem + env(safe-area-inset-bottom));
  }

  .topbar {
    min-height: 5rem;
  }

  .app-frame-bar {
    min-height: calc(3.65rem + env(safe-area-inset-top));
    padding-right: max(1rem, env(safe-area-inset-right));
    padding-left: max(1rem, env(safe-area-inset-left));
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
