:root {
  color-scheme: dark;
  --bg: #07090d;
  --surface: #101720;
  --surface-2: #0d131b;
  --line: #202b39;
  --line-strong: #293646;
  --text: #f7f9fc;
  --muted: #93a2b4;
  --accent: #4b8cff;
  --accent-2: #8db7ff;
  --danger: #e98282;
  --nav-height: 76px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { background: var(--bg); }
body {
  margin: 0;
  overflow-x: hidden;
  min-height: 100dvh;
  background:
    radial-gradient(circle at 90% -10%, rgba(75, 140, 255, .16), transparent 36%),
    linear-gradient(180deg, #0b1017 0%, var(--bg) 48%);
  color: var(--text);
}
button, input { font: inherit; }
button { color: inherit; }

.app-shell { min-height: 100dvh; }
.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: calc(12px + env(safe-area-inset-top)) 18px 12px;
  background: rgba(7, 9, 13, .88);
  backdrop-filter: blur(18px);
  border-bottom: 1px solid rgba(255,255,255,.04);
}
.brand-lockup, .header-actions { display: flex; align-items: center; min-width: 0; }
.header-actions { flex: 0 0 auto; }
.brand-lockup { gap: 10px; flex: 1 1 auto; }
.brand-lockup > div { min-width: 0; }
.brand-icon {
  width: 42px;
  height: 42px;
  border-radius: 13px;
  object-fit: cover;
  box-shadow: 0 9px 30px rgba(0,0,0,.28);
}
.eyebrow {
  margin: 0 0 3px;
  color: var(--accent);
  font-size: 10px;
  line-height: 1.1;
  font-weight: 800;
  letter-spacing: .16em;
}
.app-header h1 { margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 17px; line-height: 1.1; letter-spacing: -.02em; }
.header-actions { gap: 8px; }
.connection-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: rgba(255,255,255,.035);
  font-size: 11px;
  font-weight: 700;
}
.connection-badge i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent-2);
  box-shadow: 0 0 0 4px rgba(75,140,255,.12);
}
.connection-badge.offline i { background: var(--danger); box-shadow: 0 0 0 4px rgba(233,130,130,.1); }
.icon-button {
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255,255,255,.045);
  font-size: 20px;
  cursor: pointer;
}

.app-main {
  width: min(100%, 760px);
  margin: 0 auto;
  padding: 14px 16px calc(var(--nav-height) + 42px + env(safe-area-inset-bottom));
}
.hero-card {
  position: relative;
  overflow: hidden;
  padding: 23px 21px 18px;
  border: 1px solid rgba(75,140,255,.24);
  border-radius: 26px;
  background:
    linear-gradient(135deg, rgba(75,140,255,.16), transparent 50%),
    linear-gradient(160deg, #101720, #0b1017 66%);
  box-shadow: 0 22px 60px rgba(0,0,0,.22);
}
.hero-card::after {
  content: "L";
  position: absolute;
  right: -16px;
  top: -46px;
  color: rgba(255,255,255,.035);
  font-size: 190px;
  line-height: 1;
  font-weight: 900;
  pointer-events: none;
}
.hero-card h2 {
  position: relative;
  z-index: 1;
  margin: 7px 0 9px;
  max-width: 430px;
  font-size: clamp(28px, 8vw, 42px);
  line-height: .98;
  letter-spacing: -.055em;
}
.hero-copy {
  position: relative;
  z-index: 1;
  margin: 0;
  max-width: 520px;
  color: #a8b5c4;
  font-size: 13px;
  line-height: 1.55;
}
.hero-meta {
  position: relative;
  z-index: 1;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 18px;
}
.hero-meta span {
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: #c6d3e2;
  background: rgba(0,0,0,.16);
  font-size: 10px;
  font-weight: 750;
}

.search-box {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 10px;
  margin: 14px 0 20px;
  padding: 0 14px;
  min-height: 52px;
  border: 1px solid var(--line);
  border-radius: 17px;
  background: rgba(255,255,255,.045);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.02);
}
.search-box > span { color: var(--muted); font-size: 20px; }
.search-box input {
  width: 100%;
  border: 0;
  outline: 0;
  color: var(--text);
  background: transparent;
  font-size: 14px;
}
.search-box input::placeholder { color: #65758a; }
.search-box button {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 20px;
  cursor: pointer;
}

.section-block { margin-top: 24px; }
.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  padding: 0 2px 11px;
}
.section-heading h2 { margin: 0; font-size: 20px; letter-spacing: -.025em; }
.section-note { color: var(--muted); font-size: 11px; font-weight: 700; }

.quick-grid { display: grid; gap: 10px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.quick-card {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 18px;
  text-align: left;
  background: var(--surface);
  cursor: pointer;
}
.quick-card:disabled { opacity: .48; cursor: default; }
.quick-glyph, .app-glyph {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border: 1px solid rgba(75,140,255,.28);
  color: var(--accent-2);
  background: linear-gradient(145deg, rgba(75,140,255,.14), rgba(255,255,255,.025));
  font-weight: 850;
  letter-spacing: -.04em;
}
.quick-glyph { width: 38px; height: 38px; border-radius: 12px; font-size: 14px; }
.quick-copy { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.quick-copy strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
.quick-copy small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: 9px; }
.quick-arrow { color: var(--muted); }

.registry-grid { display: grid; grid-template-columns: 1fr; gap: 11px; }
.app-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: linear-gradient(145deg, rgba(255,255,255,.045), rgba(255,255,255,.02));
}
.app-card[data-status="route-needed"] { border-style: dashed; }
.app-card-button {
  width: 100%;
  min-height: 188px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 18px;
  padding: 16px;
  border: 0;
  text-align: left;
  background: transparent;
  cursor: pointer;
}
.app-card-button:disabled { cursor: default; }
.app-card-top, .app-card-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.app-glyph { width: 46px; height: 46px; border-radius: 15px; font-size: 16px; }
.status-pill {
  padding: 6px 8px;
  border-radius: 999px;
  background: rgba(75,140,255,.10);
  color: #8db7ff;
  font-size: 9px;
  font-weight: 850;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.app-card[data-status="demo"] .status-pill { background: rgba(141,183,255,.12); color: #bcd3ff; }
.app-card[data-status="route-needed"] .status-pill { background: rgba(255,255,255,.06); color: #8f9b95; }
.app-card-copy { flex: 1; }
.card-eyebrow { margin: 0 0 5px; color: var(--muted); font-size: 9px; font-weight: 800; letter-spacing: .12em; }
.app-card h3 { margin: 0 0 7px; font-size: 19px; letter-spacing: -.025em; }
.card-description { margin: 0; color: #a8b5c4; font-size: 12px; line-height: 1.48; }
.tag-list { display: flex; gap: 5px; flex-wrap: wrap; }
.tag-list span {
  padding: 5px 7px;
  border-radius: 7px;
  background: rgba(255,255,255,.045);
  color: #8291a4;
  font-size: 8px;
  font-weight: 750;
}
.launch-arrow { color: var(--accent); font-size: 19px; }
.app-card[data-status="route-needed"] .launch-arrow { color: #66736d; }

.empty-state { padding: 48px 18px; text-align: center; color: var(--muted); }
.empty-state > span { display: block; font-size: 36px; margin-bottom: 12px; }
.empty-state h3 { margin: 0 0 5px; color: var(--text); }
.empty-state p { margin: 0; font-size: 12px; }

.bottom-nav {
  position: fixed;
  z-index: 30;
  left: 0;
  right: 0;
  bottom: 0;
  height: calc(var(--nav-height) + env(safe-area-inset-bottom));
  padding: 8px 10px calc(7px + env(safe-area-inset-bottom));
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
  background: rgba(7,9,13,.96);
  backdrop-filter: blur(22px);
  border-top: 1px solid var(--line);
}
.nav-item {
  min-width: 0;
  border: 0;
  border-radius: 14px;
  background: transparent;
  color: #65758a;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  cursor: pointer;
}
.nav-item span { font-size: 18px; line-height: 1; }
.nav-item strong { font-size: 9px; font-weight: 750; }
.nav-item.active { color: var(--accent-2); background: rgba(75,140,255,.10); }

.install-banner {
  position: fixed;
  z-index: 50;
  left: 12px;
  right: 12px;
  bottom: calc(var(--nav-height) + 10px + env(safe-area-inset-bottom));
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border: 1px solid rgba(75,140,255,.28);
  border-radius: 19px;
  background: #101720;
  box-shadow: 0 22px 60px rgba(0,0,0,.45);
}
.install-banner img { width: 42px; height: 42px; border-radius: 13px; }
.install-banner div { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.install-banner strong { font-size: 12px; }
.install-banner span { color: var(--muted); font-size: 9px; }
.install-banner button:not(.dismiss-button) {
  border: 0;
  border-radius: 11px;
  padding: 9px 12px;
  background: var(--accent);
  color: #ffffff;
  font-weight: 850;
  font-size: 11px;
}
.dismiss-button { border: 0; background: transparent; color: var(--muted); font-size: 18px; }

@media (min-width: 560px) {
  .app-main { padding-left: 22px; padding-right: 22px; }
  .registry-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .quick-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .bottom-nav { left: 50%; right: auto; width: min(100%, 760px); transform: translateX(-50%); border: 1px solid var(--line); border-bottom: 0; border-radius: 20px 20px 0 0; }
  .install-banner { left: 50%; right: auto; width: min(calc(100% - 24px), 720px); transform: translateX(-50%); }
}

@media (display-mode: standalone) {
  .app-header { padding-top: calc(9px + env(safe-area-inset-top)); }
}

@media (prefers-reduced-motion: no-preference) {
  .app-card, .quick-card, .nav-item, .icon-button { transition: transform .16s ease, border-color .16s ease, background .16s ease; }
  .app-card:has(.app-card-button:not(:disabled):active), .quick-card:not(:disabled):active { transform: scale(.985); }
}

@media (max-width: 430px) {
  .app-header { gap: 8px; padding-left: 14px; padding-right: 14px; }
  .connection-badge { width: 32px; padding: 0; justify-content: center; }
  .connection-badge span { display: none; }
  .app-main { padding-left: 12px; padding-right: 12px; }
  .hero-card { padding-left: 18px; padding-right: 18px; }
  .hero-card h2 { font-size: clamp(27px, 8vw, 36px); }
  .quick-card { padding: 10px; gap: 8px; }
  .quick-glyph { width: 34px; height: 34px; }
  .install-banner { grid-template-columns: auto minmax(0,1fr) auto; }
  .install-banner .dismiss-button { display: none; }
}
