:root {
  --blue: #1C8FFF;
  --green: #5FE223;
  --pink: #FE007A;
  --bg: #0B1220;
  --panel: #131b2e;
  --panel-2: #1a2439;
  --border: #232f47;
  --text: #F4F7FC;
  --text-muted: #93a1bd;
  --radius: 18px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { overflow-x: hidden; }
body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  min-height: 100dvh;
}

/* Compact, transient auth-check state — intentionally NOT full-height.
   Unmounted (gate.remove()) the instant auth resolves, so it never leaves
   behind spacing; the fade is purely cosmetic, not something callers wait on. */
.gate {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px;
  padding: 28px 16px;
  min-height: 0;
  color: var(--text-muted);
  opacity: 1;
  transition: opacity 180ms ease-out;
}
.gate.gate--leaving { opacity: 0; }
.gate p { margin: 0; font-size: 12.5px; }
.gate__mark span, .mark span {
  display: block; height: 6px; border-radius: 999px; margin: 3px 0;
}
.gate__mark { width: 52px; }
.gate__mark span:nth-child(1) { background: var(--blue); }
.gate__mark span:nth-child(2) { background: var(--green); }
.gate__mark span:nth-child(3) { background: var(--pink); }
.gate__spinner {
  width: 18px; height: 18px;
  border-radius: 999px;
  border: 2px solid var(--border);
  border-top-color: var(--blue);
  animation: gate-spin 700ms linear infinite;
}
@keyframes gate-spin { to { transform: rotate(360deg); } }

.app { padding-bottom: 48px; }

.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
  padding: max(16px, env(safe-area-inset-top)) 16px 12px;
  background: rgba(11,18,32,0.92);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--border);
}
.topbar__brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.mark { width: 28px; flex: 0 0 auto; }
.mark span { height: 5px; margin: 3px 0; }
.mark span:nth-child(1) { background: var(--blue); }
.mark span:nth-child(2) { background: var(--green); }
.mark span:nth-child(3) { background: var(--pink); }
.topbar__title { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.topbar__title strong { font-size: 15px; letter-spacing: 0.02em; }
.topbar__title small { font-size: 11.5px; color: var(--text-muted); }
.topbar__back {
  font-size: 12.5px; color: var(--text-muted); text-decoration: none;
  padding: 8px 10px; border-radius: 10px; border: 1px solid var(--border);
  white-space: nowrap;
}
.topbar__back:active { background: var(--panel-2); }

.searchbar { padding: 12px 16px 4px; }
.searchbar input {
  width: 100%;
  font-size: 16px; /* avoid iOS zoom-on-focus */
  padding: 13px 16px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
}
.searchbar input::placeholder { color: var(--text-muted); }
.searchbar input:focus { outline: 2px solid var(--blue); outline-offset: 1px; }

.main { padding: 4px 16px 24px; }

.group { margin-top: 22px; }
.group__title {
  font-size: 12px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--text-muted); padding: 0 2px 10px;
  display: flex; align-items: center; gap: 8px;
}
.group__title .dot { width: 7px; height: 7px; border-radius: 999px; background: var(--blue); }
.group[data-group="favorites"] .dot { background: var(--pink); }
.group[data-group="recent"] .dot { background: var(--green); }

.cards { display: flex; flex-direction: column; gap: 10px; }

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  display: flex;
  gap: 12px;
  align-items: flex-start;
}
.card__icon {
  width: 44px; height: 44px; flex: 0 0 auto;
  border-radius: 13px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  background: var(--panel-2);
  border: 1px solid var(--border);
}
.card__body { flex: 1; min-width: 0; }
.card__head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.card__name { font-size: 15px; font-weight: 700; margin: 0; }
.card__subtitle { margin: 2px 0 0; font-size: 12.5px; color: var(--text-muted); line-height: 1.4; }

.star {
  border: none; background: none; color: var(--text-muted);
  font-size: 20px; line-height: 1; padding: 6px; margin: -6px -6px 0 0;
  cursor: pointer;
}
.star[data-fav="true"] { color: #FFC94A; }

.account {
  margin-top: 8px; display: flex; align-items: center; gap: 8px;
  font-size: 12px; color: var(--text-muted);
  background: var(--panel-2); border-radius: 10px; padding: 7px 10px;
}
.account__email { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
.account button {
  border: none; background: transparent; color: var(--blue);
  font-size: 12px; font-weight: 600; padding: 3px 4px; cursor: pointer;
}

.card__actions { display: flex; gap: 8px; margin-top: 12px; }
.btn {
  flex: 1;
  text-align: center;
  padding: 12px 10px;
  border-radius: 12px;
  font-size: 14px; font-weight: 700;
  text-decoration: none;
  border: 1px solid transparent;
  min-height: 44px;
  display: flex; align-items: center; justify-content: center;
}
.btn--open { background: var(--blue); color: #05121f; }
.btn--admin { background: transparent; border-color: var(--border); color: var(--text); }
.btn:active { transform: scale(0.98); }

.empty { text-align: center; color: var(--text-muted); padding: 40px 20px; font-size: 14px; }

.footnote {
  text-align: center; color: var(--text-muted); font-size: 11px;
  padding: 8px 24px 0; opacity: 0.8;
}
.footnote code { color: var(--text); }

.toast {
  position: fixed; left: 50%; bottom: max(20px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: #F4F7FC; color: #0B1220;
  font-size: 13px; font-weight: 600;
  padding: 10px 16px; border-radius: 999px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.35);
  z-index: 50;
}

@media (min-width: 640px) {
  .cards { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .main { max-width: 760px; margin: 0 auto; }
  .topbar { max-width: 760px; margin: 0 auto; }
  .searchbar { max-width: 760px; margin: 0 auto; }
}
