:root {
  --bg: #f2f2f7;
  --bg-2: #e8eefc;
  --ink: #1c1c1e;
  --muted: #6e6e73;
  --card: rgba(255, 255, 255, 0.74);
  --fill: rgba(118, 118, 128, 0.12);
  --stroke: rgba(60, 60, 67, 0.12);
  --highlight: rgba(255, 255, 255, 0.62);
  --accent: #3d6bff;
  --accent-2: #2f57e6;
  --accent-text: #ffffff;
  --accent-soft: rgba(61, 107, 255, 0.12);
  --shadow: 0 10px 36px rgba(28, 28, 46, 0.1);
  --shadow-press: 0 4px 16px rgba(61, 107, 255, 0.22);
  --radius: 22px;
  --sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Segoe UI", system-ui, sans-serif;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  color-scheme: light;
}

html[data-theme="dark"] {
  --bg: #000000;
  --bg-2: #12141c;
  --ink: #f5f5f7;
  --muted: #98989d;
  --card: rgba(28, 28, 30, 0.78);
  --fill: rgba(118, 118, 128, 0.24);
  --stroke: rgba(255, 255, 255, 0.08);
  --highlight: rgba(255, 255, 255, 0.08);
  --accent: #6b8cff;
  --accent-2: #4d73ff;
  --accent-text: #ffffff;
  --accent-soft: rgba(107, 140, 255, 0.16);
  --shadow: 0 16px 48px rgba(0, 0, 0, 0.45);
  --shadow-press: 0 8px 24px rgba(77, 115, 255, 0.28);
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden], .is-hidden { display: none !important; }
html {
  min-height: 100%;
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
}
html, body { margin: 0; }
body {
  min-height: 100dvh;
  font-family: var(--sans);
  color: var(--ink);
  background: var(--bg);
  letter-spacing: -0.015em;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  padding-bottom: var(--safe-bottom);
}
img { max-width: 100%; display: block; }
a { color: inherit; }
button, a { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }

.ambient {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(900px 480px at 12% -8%, var(--bg-2), transparent 58%),
    radial-gradient(700px 420px at 110% 8%, var(--accent-soft), transparent 52%);
}

.topbar, .page, .site-footer { position: relative; z-index: 1; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 8;
  width: 100%;
  background: var(--card);
  backdrop-filter: saturate(180%) blur(22px);
  -webkit-backdrop-filter: saturate(180%) blur(22px);
  border-bottom: 1px solid var(--stroke);
  box-shadow: 0 1px 0 var(--highlight);
}
.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  max-width: 980px;
  margin: 0 auto;
  padding: calc(10px + var(--safe-top)) calc(20px + var(--safe-right)) 10px calc(20px + var(--safe-left));
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  font-weight: 650;
  letter-spacing: -0.04em;
  font-size: 19px;
}
.brand img {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  box-shadow: 0 6px 16px rgba(61, 107, 255, 0.28);
}

.icon-btn {
  width: 44px;
  height: 44px;
  border: 1px solid var(--stroke);
  background: var(--fill);
  color: inherit;
  border-radius: 14px;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: transform 0.18s var(--ease), background 0.18s var(--ease);
}
.icon-btn:active { transform: scale(0.94); }
html[data-theme="dark"] .sun { display: none; }
html[data-theme="light"] .moon { display: none; }

.page {
  max-width: 980px;
  margin: 0 auto;
  padding: 22px calc(20px + var(--safe-right)) 72px calc(20px + var(--safe-left));
}
.page-install .page {
  max-width: none;
  padding-top: 28px;
}

body.page-install {
  height: 100dvh;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
body.page-install .ambient { display: none; }
body.page-install .page {
  max-width: none;
  height: 100dvh;
  margin: 0;
  padding: 0;
}
.ipa-screen {
  height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: calc(24px + var(--safe-top)) 24px calc(20px + var(--safe-bottom));
}
.ipa-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}
.ipa-icon {
  width: 120px;
  height: 120px;
  border-radius: 26px;
  object-fit: cover;
  aspect-ratio: 1 / 1;
  pointer-events: none;
  -webkit-user-drag: none;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.28);
}
.ipa-name {
  margin: 0;
  font-size: 28px;
  line-height: 1.15;
  font-weight: 700;
  letter-spacing: -0.04em;
  text-align: center;
}
.ipa-get {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 128px;
  height: 34px;
  margin-top: 4px;
  border-radius: 17px;
  background: var(--accent);
  color: var(--accent-text);
  text-decoration: none;
  font-weight: 700;
  font-size: 15px;
  letter-spacing: -0.02em;
  box-shadow: none;
  overflow: hidden;
  transition:
    width 0.34s var(--ease),
    height 0.34s var(--ease),
    border-radius 0.34s var(--ease),
    background 0.22s var(--ease),
    box-shadow 0.22s var(--ease);
}
.ipa-get:active { transform: scale(0.96); }
.ipa-get-label {
  position: relative;
  z-index: 1;
  transition: opacity 0.16s linear;
}
.ipa-get-ring {
  position: absolute;
  inset: 0;
  width: 34px;
  height: 34px;
  margin: auto;
  opacity: 0;
  pointer-events: none;
  transform: rotate(-90deg);
  transition: opacity 0.16s linear;
}
.ipa-get-track,
.ipa-get-bar {
  fill: none;
  stroke-width: 3.1;
}
.ipa-get-track { stroke: rgba(118, 118, 128, 0.28); }
.ipa-get-bar {
  stroke: var(--accent);
  stroke-linecap: round;
  stroke-dasharray: 100;
  stroke-dashoffset: 100;
}
.ipa-get.is-busy {
  width: 34px;
  height: 34px;
  border-radius: 17px;
  background: transparent;
  box-shadow: none;
  pointer-events: none;
}
.ipa-get.is-busy .ipa-get-label { opacity: 0; }
.ipa-get.is-busy .ipa-get-ring { opacity: 1; }
.ipa-get[data-state="spin"] .ipa-get-track { opacity: 0; }
.ipa-get[data-state="spin"] .ipa-get-ring {
  animation: ipa-orbit 0.82s linear infinite;
}
.ipa-get[data-state="spin"] .ipa-get-bar {
  stroke-dasharray: 28 72;
  stroke-dashoffset: 0;
}
.ipa-get[data-state="progress"] .ipa-get-ring {
  animation: none;
  transform: rotate(-90deg);
}
.ipa-get[data-state="progress"] .ipa-get-bar { stroke-dasharray: 100; }
.ipa-get[data-state="done"] {
  width: 128px;
  background: #30d158;
  color: #fff;
}
.ipa-get[data-state="done"] .ipa-get-label { opacity: 1; }
.ipa-get[data-state="done"] .ipa-get-ring { opacity: 0; }
@keyframes ipa-orbit {
  to { transform: rotate(270deg); }
}

.landing {
  text-align: center;
  padding: 48px 8px 24px;
  animation: rise 0.5s var(--ease) both;
}
.landing-mark {
  width: 64px;
  height: 64px;
  margin: 0 auto 18px;
  border-radius: 16px;
  box-shadow: 0 16px 36px rgba(61, 107, 255, 0.32);
}
.landing h1 {
  margin: 0 0 10px;
  font-size: 34px;
  letter-spacing: -0.045em;
}
.landing .lead,
.lead {
  margin: 0 auto;
  max-width: 28rem;
  color: var(--muted);
  font-size: 17px;
  line-height: 1.5;
}

.install-card {
  position: relative;
  overflow: hidden;
  padding: 32px 22px 22px;
  border-radius: 32px;
  background: var(--card);
  border: 1px solid var(--stroke);
  box-shadow: var(--shadow), inset 0 1px 0 var(--highlight);
  backdrop-filter: saturate(180%) blur(22px);
  -webkit-backdrop-filter: saturate(180%) blur(22px);
  text-align: center;
  animation: rise 0.5s var(--ease) both;
}
.icon-glow {
  position: absolute;
  left: 50%;
  top: -40px;
  width: 240px;
  height: 180px;
  transform: translateX(-50%);
  background: radial-gradient(circle, var(--accent-soft), transparent 70%);
  pointer-events: none;
}
.icon-frame-hero {
  width: 120px;
  height: 120px;
  margin: 0 auto 16px;
  position: relative;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.35);
}
.install-card .app-name {
  font-size: 30px;
  margin: 4px 0 6px;
}
.install-card .app-version { margin: 0 0 8px; }
.install-card .cta-stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 20px 0 10px;
}
.install-card .cta-stack .btn,
.btn-block { width: 100%; min-width: 0; }
.install-card .hint { margin: 4px 0 18px; }
.install-card .app-lede {
  text-align: left;
  margin: 0 0 16px;
  font-size: 15px;
  line-height: 1.5;
}
.install-card .spec-list {
  text-align: left;
  background: var(--fill);
  border-radius: 18px;
  padding: 4px 14px;
  margin: 0 0 12px;
}
.sheet-lite {
  text-align: left;
  margin: 12px 0;
}
.sheet-lite h2 {
  margin: 0 0 8px;
  font-size: 12px;
  font-weight: 650;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.eyebrow {
  margin: 0 0 6px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent);
}
.catalog-head h1,
.empty-state h1,
.empty-state h2,
.app-name {
  margin: 0;
  font-size: 34px;
  line-height: 1.08;
  letter-spacing: -0.045em;
  font-weight: 700;
}

.search-field {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 18px 0 22px;
  padding: 11px 14px;
  min-height: 48px;
  border-radius: 14px;
  background: var(--fill);
  border: 1px solid transparent;
  box-shadow: inset 0 1px 0 var(--highlight);
  color: var(--muted);
  transition: background 0.2s var(--ease), border-color 0.2s var(--ease), box-shadow 0.2s var(--ease), transform 0.2s var(--ease);
}
.search-field:focus-within {
  background: var(--card);
  border-color: rgba(61, 107, 255, 0.35);
  box-shadow: 0 0 0 4px var(--accent-soft), var(--shadow);
  color: var(--ink);
  transform: translateY(-1px);
}
.search-field input {
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 16px;
  outline: none;
}
.search-field input::placeholder { color: var(--muted); }

.app-grid {
  display: grid;
  gap: 12px;
}

.app-tile {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  border-radius: var(--radius);
  background: var(--card);
  border: 1px solid var(--stroke);
  box-shadow: var(--shadow), inset 0 1px 0 var(--highlight);
  backdrop-filter: saturate(160%) blur(18px);
  -webkit-backdrop-filter: saturate(160%) blur(18px);
  animation: rise 0.48s var(--ease) both;
  animation-delay: calc(var(--i, 0) * 45ms);
}
.app-tile-main {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
  flex: 1;
  text-decoration: none;
}
.app-tile-copy { min-width: 0; }
.app-tile-copy h2 {
  margin: 0;
  font-size: 17px;
  font-weight: 650;
  letter-spacing: -0.03em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.app-tile-desc,
.app-tile-meta,
.app-version,
.app-lede,
.hint,
.sheet p,
.empty-state p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}
.app-tile-desc {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.app-tile-meta { font-size: 12px; }

.icon-frame {
  flex: none;
  width: 72px;
  height: 72px;
  border-radius: 22%;
  background: var(--fill);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.16), inset 0 1px 0 rgba(255, 255, 255, 0.28);
}
.icon-frame-lg {
  width: 112px;
  height: 112px;
}
.app-icon {
  width: 100%;
  height: 100%;
  object-fit: cover;
  aspect-ratio: 1 / 1;
  border-radius: 22%;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0 20px;
  border-radius: 999px;
  text-decoration: none;
  font-weight: 650;
  font-size: 16px;
  letter-spacing: -0.02em;
  border: 1px solid transparent;
  transition: transform 0.16s var(--ease), background 0.16s var(--ease), box-shadow 0.16s var(--ease), opacity 0.16s var(--ease);
  user-select: none;
}
.btn:active { transform: scale(0.97); }
.btn-primary {
  background: linear-gradient(180deg, var(--accent) 0%, var(--accent-2) 100%);
  color: var(--accent-text);
  box-shadow: var(--shadow-press), inset 0 1px 0 rgba(255, 255, 255, 0.28);
}
.btn-primary:hover { filter: brightness(1.04); }
.btn-compact {
  min-height: 36px;
  min-width: 108px;
  padding: 0 14px;
  font-size: 14px;
  flex: none;
}
.btn-secondary,
.btn-ghost {
  background: var(--fill);
  color: var(--ink);
  border-color: var(--stroke);
}
.btn-ghost { background: transparent; }
.btn[data-state="preparing"],
.btn[data-state="installing"] { opacity: 0.78; pointer-events: none; }
.btn[data-state="done"] { background: linear-gradient(180deg, #34c759, #28a745); }
.btn[data-state="error"] { background: linear-gradient(180deg, #ff6b6b, #e5484d); }

.cta-stack {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}
.cta-stack .btn { min-width: 148px; }

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 18px;
  color: var(--accent);
  text-decoration: none;
  font-size: 16px;
  font-weight: 550;
}
.back-link::before { content: "‹"; font-size: 22px; line-height: 1; }

.app-page { animation: rise 0.46s var(--ease) both; }
.app-hero {
  display: flex;
  gap: 18px;
  align-items: flex-start;
  margin-bottom: 22px;
}
.app-hero-copy { min-width: 0; flex: 1; }
.app-lede { font-size: 15px; line-height: 1.45; max-width: 42rem; }

.sheet {
  margin: 12px 0;
  padding: 18px;
  border-radius: var(--radius);
  background: var(--card);
  border: 1px solid var(--stroke);
  box-shadow: var(--shadow), inset 0 1px 0 var(--highlight);
  backdrop-filter: saturate(160%) blur(18px);
  -webkit-backdrop-filter: saturate(160%) blur(18px);
}
.sheet h2 {
  margin: 0 0 10px;
  font-size: 13px;
  font-weight: 650;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}
.sheet p { font-size: 16px; line-height: 1.55; color: var(--ink); margin: 0; }
.changelog { white-space: pre-line; }

.spec-list { margin: 0; }
.spec-list > div {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 0;
  border-bottom: 1px solid var(--stroke);
}
.spec-list > div:last-child { border-bottom: 0; }
.spec-list dt { color: var(--muted); font-size: 14px; }
.spec-list dd { margin: 0; font-size: 14px; font-weight: 550; text-align: right; }
.spec-list code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  font-weight: 500;
}

.shots {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 4px;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
}
.shots img {
  height: 280px;
  width: auto;
  border-radius: 18px;
  scroll-snap-align: start;
  background: var(--fill);
}

.app-secondary {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 8px;
}
.hint { text-align: center; margin-top: 16px; }

.empty-state {
  text-align: center;
  padding: 42px 12px;
  color: var(--muted);
}
.empty-state h1,
.empty-state h2 {
  color: var(--ink);
  font-size: 28px;
  margin-bottom: 8px;
}
.empty-state-page { padding-top: 36px; }
.empty-state .btn { margin-top: 18px; }

.site-footer {
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  padding: 0 16px calc(18px + var(--safe-bottom));
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + var(--safe-bottom));
  transform: translateX(-50%);
  background: rgba(28, 28, 30, 0.92);
  color: #fff;
  padding: 12px 16px;
  border-radius: 14px;
  z-index: 30;
  max-width: min(90vw, 360px);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: var(--shadow);
}
html[data-theme="light"] .toast {
  background: rgba(28, 28, 30, 0.94);
}

@keyframes rise {
  from { opacity: 0; transform: translateY(10px) scale(0.985); }
  to { opacity: 1; transform: none; }
}

@media (min-width: 820px) {
  .app-grid { grid-template-columns: 1fr 1fr; }
  .catalog-head h1 { font-size: 40px; }
}

@media (max-width: 640px) {
  .app-hero { flex-direction: column; }
  .cta-stack .btn { width: 100%; }
  .app-name { font-size: 30px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
}
