/* ==========================================================================
   Member app shell — mirrors the web app's AppLayout
   Sidebar (768px+), sticky top bar, mobile tab bar and menu sheet.
   ========================================================================== */

.pk-icon { width: 18px; height: 18px; flex: none; }

.app { display: flex; min-height: 100vh; background: var(--bg); }

/* ---------- sidebar ---------- */
.app-side {
  position: sticky; top: 0; z-index: 20;
  display: none; flex: none; flex-direction: column;
  width: 256px; height: 100vh;
  border-right: 1px solid var(--border);
  background: linear-gradient(180deg, var(--card), var(--muted));
}
@media (min-width: 768px) { .app-side { display: flex; } }

.app-brand {
  display: flex; align-items: center; gap: .625rem;
  height: 64px; flex: none; padding: 0 1.25rem;
  border-bottom: 1px solid var(--border);
}
.app-brand span { font-weight: 900; letter-spacing: -.01em; }

.app-side-nav { flex: 1; overflow-y: auto; padding: .75rem; }
.app-group { margin-bottom: 1rem; }
.app-group-label {
  margin: 0; padding: 0 .75rem .375rem;
  font-size: .62rem; font-weight: 900; text-transform: uppercase;
  letter-spacing: .16em; color: var(--muted-fg); opacity: .85;
}
.app-link {
  position: relative; display: flex; align-items: center; gap: .75rem;
  padding: .625rem .75rem; border-radius: .75rem;
  font-size: .875rem; font-weight: 800; color: var(--muted-fg);
  transition: background .2s, color .2s, transform .2s;
}
.app-link:hover { background: var(--muted); color: var(--fg); transform: translateX(2px); }
.app-link .pk-icon { transition: transform .2s; }
.app-link:hover .pk-icon { transform: scale(1.1); }
.app-link.is-active { background: hsl(95 98% 40% / .14); color: var(--primary); }
:root[data-theme="dark"] .app-link.is-active { color: hsl(95 90% 74%); }
.app-link.is-active::before {
  content: ""; position: absolute; left: 0; top: 50%;
  width: 4px; height: 24px; border-radius: 0 999px 999px 0;
  background: var(--primary); transform: translateY(-50%);
}

.app-user {
  display: flex; align-items: center; gap: .75rem;
  margin: .75rem; padding: .75rem;
  border: 1px solid var(--border); border-radius: 1rem; background: var(--card);
}
.app-user .grow { min-width: 0; }
.app-user-name { margin: 0; font-size: .875rem; font-weight: 900; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.app-user-xp { margin: 0; font-size: .75rem; font-weight: 700; color: var(--muted-fg); }
.app-logout {
  display: flex; align-items: center; justify-content: center; gap: .4rem;
  margin: 0 .75rem .75rem; padding: .55rem .75rem;
  border: 0; border-radius: .75rem; background: var(--muted); color: var(--fg);
  font-family: inherit; font-size: .8rem; font-weight: 900; text-align: center;
}
.app-logout:hover { background: var(--border); }

/* Circular level badge — the web app's LevelRing. */
.level-ring {
  --pct: 0;
  position: relative; flex: none;
  display: grid; place-items: center;
  width: 54px; height: 54px; border-radius: 999px;
  background: conic-gradient(var(--primary) calc(var(--pct) * 1%), var(--border) 0);
}
.level-ring::after {
  content: ""; position: absolute; inset: 5px;
  border-radius: 999px; background: var(--card);
}
.level-ring span { position: relative; z-index: 1; font-size: .8rem; font-weight: 900; }
/* On the green journey banner the ring is white on a translucent track.
   The arc sits on its own masked layer, so the middle stays open like the
   web app's LevelRing instead of filling in as a solid pie. */
.level-ring.is-light { background: none; }
.level-ring.is-light::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: conic-gradient(#fff calc(var(--pct) * 1%), hsl(0 0% 100% / .28) 0);
  -webkit-mask: radial-gradient(circle, transparent 62%, #000 63%);
  mask: radial-gradient(circle, transparent 62%, #000 63%);
}
.level-ring.is-light::after { background: transparent; }
.level-ring.is-light span { color: #fff; }
.hero-ring { width: 96px; height: 96px; }
.hero-ring::after { inset: 7px; }
.hero-ring span { font-size: 1.05rem; }
.hero-row {
  position: relative; z-index: 1;
  display: flex; align-items: center; justify-content: space-between;
  gap: 1.25rem; flex-wrap: wrap;
}
.hero-copy { min-width: 0; }

/* ---------- main column ---------- */
.app-body { display: flex; flex: 1; min-width: 0; flex-direction: column; }

.app-top {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; justify-content: space-between; gap: .75rem;
  height: 64px; padding: 0 1rem;
  border-bottom: 1px solid var(--border);
  background: var(--glass); backdrop-filter: blur(14px);
}
@media (min-width: 768px) { .app-top { padding: 0 1.5rem; } }
.app-top-logo { display: grid; place-items: center; }
.app-top-logo .brand-logo { width: 36px; height: 36px; border-radius: 12px; }
@media (min-width: 768px) { .app-top-logo { display: none; } }

.app-level { display: none; align-items: center; gap: .5rem; }
@media (min-width: 768px) { .app-level { display: flex; } }
.app-level .bar { width: 112px; height: 8px; border-radius: 999px; background: var(--muted); overflow: hidden; }
.app-level .bar > span {
  display: block; height: 100%; border-radius: 999px;
  background-image: linear-gradient(90deg, var(--primary), var(--secondary));
  transition: width .7s cubic-bezier(.2, .8, .2, 1);
}
.app-level .xp-text { font-size: .75rem; font-weight: 800; color: var(--muted-fg); }

.app-actions { display: flex; align-items: center; gap: .5rem; }
.app-actions .res-chip { padding: .25rem .625rem; }
.app-actions .res-chip .pk-icon { fill: currentColor; }
.app-actions .toggle-wrap { display: none; }
@media (min-width: 768px) { .app-actions .toggle-wrap { display: block; } }

.app-avatar {
  display: grid; place-items: center; flex: none;
  width: 36px; height: 36px; border-radius: 999px;
  border: 2px solid var(--border); background: var(--muted);
  font-size: 1.1rem; transition: border-color .2s, transform .2s;
}
.app-avatar:hover { border-color: var(--primary); transform: scale(1.05); }

main.app-main {
  flex: 1;
  padding-block: 1.25rem 6rem;
  animation: pk-rise .5s cubic-bezier(.2, .8, .2, 1) both;
}
@media (min-width: 768px) { main.app-main { padding-block: 2rem 2.5rem; } }

/* ---------- mobile tab bar ---------- */
.app-tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  display: flex; align-items: stretch;
  height: 64px; padding-bottom: env(safe-area-inset-bottom);
  border-top: 1px solid var(--border);
  background: var(--glass-strong); backdrop-filter: blur(14px);
}
@media (min-width: 768px) { .app-tabs { display: none; } }
.app-tab {
  display: flex; flex: 1; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; padding: 0; border: 0; background: transparent;
  font-family: inherit; color: var(--muted-fg); cursor: pointer;
}
.app-tab-icon {
  display: grid; place-items: center;
  width: 48px; height: 32px; border-radius: 999px;
  transition: background .3s, color .3s;
}
.app-tab-icon .pk-icon { width: 20px; height: 20px; }
.app-tab-label { font-size: .65rem; font-weight: 900; }
.app-tab.is-active .app-tab-icon { background: hsl(95 98% 40% / .15); color: var(--primary); }
.app-tab.is-active .app-tab-label { color: var(--primary); }

/* ---------- menu sheet ---------- */
.app-sheet { position: fixed; inset: 0; z-index: 90; display: flex; justify-content: flex-end; }
.app-sheet[hidden] { display: none; }
.app-sheet-backdrop {
  position: absolute; inset: 0; border: 0; padding: 0;
  background: hsl(30 20% 12% / .55); backdrop-filter: blur(3px);
  animation: pk-appear .2s ease both;
}
.app-sheet-panel {
  position: relative; z-index: 1;
  width: min(86%, 24rem); height: 100%; overflow-y: auto;
  padding: 1.25rem;
  border-left: 2px solid var(--border); background: var(--card);
  animation: pk-sheet-in .28s cubic-bezier(.2, .8, .2, 1) both;
}
.app-sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1rem; }
.app-sheet-head h2 { margin: 0; font-size: 1.125rem; }
.app-sheet-close {
  display: grid; place-items: center;
  width: 36px; height: 36px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--muted); color: var(--fg); cursor: pointer;
}
.app-sheet-toggles {
  display: flex; align-items: center; gap: .5rem;
  margin-bottom: 1.25rem; padding: .5rem .75rem;
  border: 1px solid var(--border); border-radius: 1rem; background: var(--muted);
}
.app-sheet-toggles .eyebrow { margin-right: auto; }
.app-sheet .app-link { color: var(--fg); }
.app-sheet .app-link .pk-icon { color: var(--muted-fg); }
.app-sheet .app-group-label { padding-left: .25rem; }
.app-sheet .app-link { padding: .625rem .5rem; }
.app-sheet .app-logout { margin: 1rem 0 0; width: 100%; }

@keyframes pk-sheet-in {
  from { opacity: 0; transform: translateX(24px); }
  to { opacity: 1; transform: none; }
}