/* VGB — install system styles (v14.10). Self-contained: works with or without the bettor.html design tokens. */
/* Essential: .sidebar-item, .btn and #installAppBtn set their own display and would otherwise ignore [hidden]. */
[data-pwa-install][hidden], [data-pwa-install-card][hidden] { display: none !important; }

/* ── Install card (login / register / landing) ─────────────────────────────────────────────────────────────── */
.pwa-card { position: relative; display: flex; align-items: center; gap: 12px; margin-top: 16px; padding: 12px 12px 12px 12px;
  background: linear-gradient(135deg, rgba(59,157,255,.10), rgba(255,60,60,.07)), var(--surface2, #0f1d38);
  border: 1px solid var(--border, rgba(120,160,255,.2)); border-radius: 14px; overflow: hidden; text-align: left;
  animation: pwaIn .35s ease both; }
.pwa-card::before { content: ""; position: absolute; inset: 0; pointer-events: none; border-radius: inherit;
  background: radial-gradient(240px 80px at 0% 0%, rgba(255,255,255,.07), transparent 70%); }
.pwa-card img { border-radius: 11px; flex-shrink: 0; box-shadow: 0 4px 14px rgba(0,0,0,.4); }
.pwa-card-text { display: flex; flex-direction: column; font-size: 12px; color: var(--muted, #8397c0); line-height: 1.4; flex: 1; min-width: 0; }
.pwa-card-text strong { color: var(--text, #e6edf9); font-size: 13.5px; margin-bottom: 1px; }
.pwa-card .btn, .pwa-card .pwa-btn { flex-shrink: 0; width: auto; }
@keyframes pwaIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ── Buttons ───────────────────────────────────────────────────────────────────────────────────────────────── */
.pwa-btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 11px 16px; border-radius: 12px;
  border: 1px solid var(--border, rgba(120,160,255,.25)); background: rgba(255,255,255,.05); color: var(--text, #e6edf9);
  font: 700 14px/1 inherit; font-family: inherit; cursor: pointer; text-decoration: none; transition: transform .1s, background .15s; }
.pwa-btn:hover { background: rgba(255,255,255,.09); }
.pwa-btn:active { transform: scale(.98); }
.pwa-btn.primary { background: linear-gradient(135deg, #3b9dff, #2563eb); border-color: transparent; color: #fff; box-shadow: 0 8px 22px rgba(37,99,235,.35); }
.pwa-btn.block { display: flex; width: 100%; margin-top: 16px; }
.pwa-btn:focus-visible, .pwa-x:focus-visible { outline: 2px solid #3b9dff; outline-offset: 2px; }

/* ── Guide sheet ───────────────────────────────────────────────────────────────────────────────────────────── */
.sheet-ov.pwa-ov, .pwa-ov { position: fixed; inset: 0; z-index: 3000; display: flex; align-items: center; justify-content: center; padding: 16px;
  background: rgba(2,6,16,.72); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); animation: pwaFade .2s ease; }
.sheet-box.pwa-box, .pwa-box { width: 100%; max-width: 420px; max-height: 92dvh; overflow-y: auto; padding: 14px 18px calc(20px + env(safe-area-inset-bottom, 0px));
  background: linear-gradient(180deg, #0f1f3f, #0a1428); border: 1px solid rgba(120,160,255,.22); border-radius: 22px;
  color: var(--text, #e6edf9); box-shadow: 0 30px 80px rgba(0,0,0,.6); animation: pwaUp .26s cubic-bezier(.2,.8,.2,1); }
.pwa-grab { display: none; width: 38px; height: 4px; border-radius: 4px; background: rgba(255,255,255,.2); margin: 0 auto 12px; }
.pwa-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.pwa-head img { border-radius: 12px; box-shadow: 0 6px 18px rgba(255,40,40,.25); }
.pwa-head > div { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.pwa-head b { font-size: 17px; letter-spacing: .1px; }
.pwa-head span { font-size: 12.5px; color: var(--muted, #8397c0); margin-top: 2px; }
.pwa-x { width: 34px; height: 34px; border-radius: 50%; border: 1px solid rgba(255,255,255,.12); background: rgba(255,255,255,.06);
  color: var(--muted, #8397c0); font-size: 13px; cursor: pointer; flex-shrink: 0; }
.pwa-steps { list-style: none; display: flex; flex-direction: column; gap: 10px; margin: 4px 0 6px; padding: 0; counter-reset: none; }
.pwa-steps li { display: flex; align-items: flex-start; gap: 12px; padding: 12px; border-radius: 14px; background: rgba(255,255,255,.04); border: 1px solid rgba(255,255,255,.07); }
.pwa-n { flex-shrink: 0; width: 26px; height: 26px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  font: 800 13px/1 inherit; color: #fff; background: linear-gradient(135deg, #3b9dff, #2563eb); box-shadow: 0 4px 10px rgba(37,99,235,.4); }
.pwa-t { font-size: 14px; line-height: 1.5; color: var(--text, #e6edf9); }
.pwa-t b { color: #fff; }
.pwa-ico { display: inline-block; vertical-align: -4px; margin: 0 2px; color: #6fb6ff; }
.pwa-note { margin-top: 10px; font-size: 12.5px; line-height: 1.55; color: var(--muted, #8397c0); }
.pwa-note.lead { font-size: 14px; color: var(--text, #e6edf9); margin: 0 0 14px; }
.pwa-note b { color: var(--text, #e6edf9); }
.pwa-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.pwa-actions .pwa-btn { flex: 1; min-width: 130px; }
.pwa-link { margin-top: 12px; padding: 10px 12px; border-radius: 10px; font: 12px/1.4 ui-monospace, Menlo, monospace; word-break: break-all;
  color: #9fc4ff; background: rgba(0,0,0,.3); border: 1px dashed rgba(120,160,255,.3); user-select: all; }
.pwa-point { margin: 12px 0 2px; text-align: center; font-size: 12px; color: #6fb6ff; font-weight: 700; display: flex; align-items: center; justify-content: center; gap: 8px; }
.pwa-point.down { flex-direction: column; animation: pwaBob 1.3s ease-in-out infinite; font-size: 22px; line-height: 1; }
.pwa-point.up { justify-content: flex-end; animation: pwaBob 1.3s ease-in-out infinite; font-size: 22px; }
.pwa-point span { font-size: 12px; }
@keyframes pwaBob { 50% { transform: translateY(5px); } }
@keyframes pwaFade { from { opacity: 0; } to { opacity: 1; } }
@keyframes pwaUp { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
@media (max-width: 640px) {
  .sheet-ov.pwa-ov, .pwa-ov { align-items: flex-end; padding: 0; }
  .sheet-box.pwa-box, .pwa-box { max-width: none; border-radius: 22px 22px 0 0; border-bottom: 0; }
  .pwa-grab { display: block; }
}

/* ── Fallback toast (used where the page has no toast()) ───────────────────────────────────────────────────── */
.pwa-toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); z-index: 3100;
  max-width: calc(100vw - 32px); padding: 12px 18px; border-radius: 14px; font: 600 14px/1.4 -apple-system, "Segoe UI", sans-serif;
  color: #fff; background: rgba(15,31,63,.96); border: 1px solid rgba(120,160,255,.3); box-shadow: 0 12px 40px rgba(0,0,0,.5); animation: pwaUp .25s ease; transition: opacity .4s; }
.pwa-toast.out { opacity: 0; }
@media (prefers-reduced-motion: reduce) { .pwa-card, .pwa-box, .pwa-ov, .pwa-point, .pwa-toast { animation: none !important; } }

/* ══ Phase 2 (v14.11) ══════════════════════════════════════════════════════════════════════════════════════════ */
/* Offline bar */
.offline-bar { position: fixed; left: 50%; top: calc(8px + env(safe-area-inset-top, 0px)); transform: translateX(-50%); z-index: 2900; max-width: calc(100vw - 24px);
  display: flex; align-items: center; gap: 9px; padding: 8px 14px; border-radius: 99px; font: 700 12.5px/1.3 -apple-system, "Segoe UI", sans-serif; color: #ffe9b8;
  background: rgba(60,38,6,.94); border: 1px solid rgba(245,165,36,.55); box-shadow: 0 10px 30px rgba(0,0,0,.45); backdrop-filter: blur(6px); }
.offline-bar[hidden] { display: none; }
.offline-bar .ob-dot { width: 8px; height: 8px; border-radius: 50%; background: #f5a524; flex-shrink: 0; animation: pwaPulse 1.4s infinite; }
.offline-bar.warn { background: rgba(70,20,16,.94); border-color: rgba(239,68,68,.6); color: #ffd2cd; } .offline-bar.warn .ob-dot { background: #ef4444; }
.offline-bar.ok { background: rgba(8,50,28,.94); border-color: rgba(34,197,94,.55); color: #c8f7da; } .offline-bar.ok .ob-dot { background: #22c55e; animation: none; }
@keyframes pwaPulse { 50% { opacity: .35; } }

/* Update snackbar */
.pwa-snack { position: fixed; left: 50%; bottom: calc(76px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); z-index: 2950; width: min(440px, calc(100vw - 24px));
  display: flex; align-items: center; gap: 12px; padding: 11px 12px 11px 14px; border-radius: 16px; color: var(--text, #e6edf9);
  background: linear-gradient(180deg, #112447, #0b1830); border: 1px solid rgba(80,150,255,.45); box-shadow: 0 18px 50px rgba(0,0,0,.55); animation: pwaUp .26s ease; }
.pwa-snack-dot { width: 10px; height: 10px; border-radius: 50%; background: #3b9dff; box-shadow: 0 0 0 4px rgba(59,157,255,.25); flex-shrink: 0; }
.pwa-snack-t { display: flex; flex-direction: column; flex: 1; min-width: 0; font-size: 13.5px; } .pwa-snack-t small { color: var(--muted, #8397c0); font-size: 12px; margin-top: 1px; }
.pwa-snack .pwa-btn { padding: 9px 14px; }
@media (min-width: 769px) { .pwa-snack { bottom: 24px; } }

/* Update-required gate */
.pwa-gate { position: fixed; inset: 0; z-index: 6000; display: flex; align-items: center; justify-content: center; padding: 20px; background: radial-gradient(900px 500px at 50% -10%, #10234a, #050b18 65%); }
.pwa-gate-card { width: 100%; max-width: 380px; text-align: center; padding: 30px 24px; border-radius: 22px; color: var(--text, #e6edf9); background: rgba(14,29,58,.75); border: 1px solid rgba(120,160,255,.25); box-shadow: 0 24px 70px rgba(0,0,0,.55); }
.pwa-gate-card img { border-radius: 16px; margin-bottom: 14px; } .pwa-gate-card h2 { font-size: 22px; margin-bottom: 8px; }
.pwa-gate-card p { font-size: 14px; line-height: 1.55; color: var(--muted, #8397c0); } .pwa-gate-note { margin-top: 10px; font-size: 12px; color: var(--muted, #8397c0); min-height: 16px; }

/* Soft install banner */
.pwa-banner { position: fixed; z-index: 2800; left: 12px; right: 12px; bottom: calc(72px + env(safe-area-inset-bottom, 0px)); display: flex; align-items: center; gap: 12px; padding: 11px 10px 11px 12px;
  border-radius: 16px; color: var(--text, #e6edf9); background: linear-gradient(135deg, rgba(59,157,255,.16), rgba(255,60,60,.10)), #0d1b36; border: 1px solid rgba(120,160,255,.35);
  box-shadow: 0 16px 44px rgba(0,0,0,.5); animation: pwaUp .3s ease; }
.pwa-banner img { border-radius: 11px; flex-shrink: 0; } .pwa-banner-t { display: flex; flex-direction: column; flex: 1; min-width: 0; font-size: 12px; color: var(--muted, #8397c0); line-height: 1.35; }
.pwa-banner-t b { color: var(--text, #e6edf9); font-size: 13.5px; } .pwa-banner .pwa-btn { padding: 9px 14px; }
@media (min-width: 769px) { .pwa-banner { left: auto; right: 24px; bottom: 24px; width: 400px; } }

/* Share target + welcome sheets */
.pwa-share-prev { margin: 4px 0 12px; padding: 10px 12px; border-radius: 12px; font-size: 13px; line-height: 1.5; white-space: pre-wrap; word-break: break-word; max-height: 120px; overflow: auto;
  color: var(--text, #e6edf9); background: rgba(255,255,255,.05); border: 1px dashed rgba(120,160,255,.3); }
.pwa-share-list, #pwaShareChans { display: flex; flex-direction: column; gap: 6px; }
.pwa-row { text-align: left; padding: 12px 13px; border-radius: 12px; border: 1px solid rgba(255,255,255,.08); background: rgba(255,255,255,.04); color: var(--text, #e6edf9); font: 600 14px inherit; font-family: inherit; cursor: pointer; }
.pwa-row:hover { background: rgba(59,157,255,.14); }
.pwa-ok { color: #6ff0a0; font-style: normal; font-weight: 700; } .pwa-mu { color: var(--muted, #8397c0); font-style: normal; }

/* Profile "Invite friends" card, About version */
.pwa-share-card { display: flex; align-items: center; gap: 12px; margin: 0 0 12px; padding: 12px 14px; border-radius: 14px; border: 1px solid var(--border, #173058);
  background: linear-gradient(135deg, rgba(59,157,255,.12), rgba(34,197,94,.08)), var(--surface2, #0e1c36); }
.pwa-share-t { display: flex; flex-direction: column; flex: 1; min-width: 0; font-size: 12px; color: var(--muted, #8397c0); line-height: 1.4; } .pwa-share-t b { color: var(--text, #e6edf9); font-size: 14px; }
.about-ver { margin-top: 4px; font-size: 12px; color: var(--muted, #8397c0); letter-spacing: .03em; }

/* Window Controls Overlay (desktop installed app): draw the top bar under the title bar, keep it draggable */
@media (display-mode: window-controls-overlay) {
  .topbar { padding-left: calc(env(titlebar-area-x, 0px) + 12px); padding-right: calc(100vw - env(titlebar-area-x, 0px) - env(titlebar-area-width, 100vw) + 12px);
    min-height: env(titlebar-area-height, 40px); -webkit-app-region: drag; app-region: drag; }
  .topbar button, .topbar input, .topbar a, .topbar .tb-search, .topbar .user-info, .topbar .avatar { -webkit-app-region: no-drag; app-region: no-drag; }
}
