/* Shells: app (signed-in), public (marketing/legal), auth (login/signup) */

.app-root { min-height: 100vh; min-height: 100dvh; }
.container { width: 100%; max-width: var(--content-max); margin-inline: auto; padding-inline: 16px; }
@media (min-width: 768px) { .container { padding-inline: 28px; } }

/* ---- Brand -------------------------------------------------------------- */
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-weight: 800;
  font-size: 1.12rem;
  letter-spacing: -0.03em;
  text-decoration: none;
  min-width: 0;
}
.brand:hover { text-decoration: none; }
.brand-mark { display: block; width: 36px; height: 36px; flex: none; border-radius: 22%; box-shadow: 0 0 0 1px var(--border); }
.brand-name b { font-weight: 500; color: var(--text-muted); }

/* ======================================================================== */
/* App shell                                                                 */
/* ======================================================================== */
.app-shell { display: flex; min-height: 100dvh; }

.sidebar {
  position: fixed;
  z-index: 120;
  top: 0; bottom: 0; left: 0;
  width: min(86vw, 304px);
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-right: 1px solid var(--border);
  transform: translateX(-102%);
  transition: transform .34s var(--ease), width .25s var(--ease);
  padding: calc(14px + var(--safe-top)) 14px calc(14px + var(--safe-bottom));
  overflow-y: auto;
  overscroll-behavior: contain;
}
.sidebar.open { transform: none; box-shadow: var(--shadow-lg); }
.sidebar-head { display: flex; align-items: center; justify-content: space-between; padding: 4px 6px 18px; }
.sidebar-nav { display: flex; flex-direction: column; gap: 18px; flex: 1 1 auto; }
.nav-group { display: flex; flex-direction: column; gap: 3px; }
.nav-heading {
  padding: 0 12px 6px;
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 13px;
  min-height: 46px;
  padding: 0 12px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--text-2);
  font-weight: 600;
  font-size: .94rem;
  text-decoration: none;
  width: 100%;
  text-align: left;
  transition: background-color var(--dur), color var(--dur);
}
.nav-item .icon { width: 21px; height: 21px; color: var(--text-muted); transition: color var(--dur); }
.nav-item:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav-item[aria-current="page"] { background: var(--primary-soft); color: var(--text); }
.nav-item[aria-current="page"] .icon { color: var(--primary-ink); }
.nav-item[aria-current="page"]::before {
  content: "";
  position: absolute;
  left: -14px; top: 10px; bottom: 10px;
  width: 4px;
  border-radius: 0 4px 4px 0;
  background: var(--primary);
}
.nav-item .nav-badge {
  margin-left: auto;
  min-width: 22px; height: 22px;
  padding: 0 6px;
  display: grid; place-items: center;
  border-radius: 99px;
  background: var(--primary);
  color: var(--on-primary);
  font-size: .72rem;
  font-weight: 800;
}
.nav-item.danger:hover { background: var(--danger-soft); color: var(--danger); }
.nav-item.danger:hover .icon { color: var(--danger); }

.sidebar-foot { display: flex; flex-direction: column; gap: 10px; padding-top: 16px; border-top: 1px solid var(--border); margin-top: 16px; }
.side-card {
  padding: 14px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px dashed var(--border-strong);
  font-size: .8rem;
  color: var(--text-2);
}
.side-card strong { display: block; font-size: .86rem; color: var(--text); margin-bottom: 2px; }

.scrim {
  position: fixed; inset: 0;
  z-index: 110;
  background: var(--scrim);
  opacity: 0;
  pointer-events: none;
  transition: opacity .3s;
}
.scrim.show { opacity: 1; pointer-events: auto; }

.app-main {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  padding-bottom: calc(var(--bottom-nav-h) + var(--safe-bottom));
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 60;
  height: calc(var(--topbar-h) + var(--safe-top));
  padding: var(--safe-top) 12px 0;
  display: flex;
  align-items: center;
  gap: 10px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(1.4) blur(14px);
  -webkit-backdrop-filter: saturate(1.4) blur(14px);
  border-bottom: 1px solid var(--border);
}
.topbar .topbar-brand { display: inline-flex; min-width: 0; }
.topbar .topbar-brand .brand { font-size: 1.02rem; }
.topbar .topbar-brand .brand-mark { width: 34px; height: 34px; }
.topbar-title { display: none; font-weight: 700; font-size: 1.02rem; letter-spacing: -0.02em; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 4px; flex: none; }
@media (max-width: 380px) { .topbar .topbar-brand .brand-name { display: none; } }
.topbar .icon-btn {
  position: relative;
  width: 44px; height: 44px;
  display: grid; place-items: center;
  border-radius: 12px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-2);
  text-decoration: none;
}
.topbar .icon-btn:hover { background: var(--surface); border-color: var(--border); text-decoration: none; }
.topbar .icon-btn .dot {
  position: absolute;
  top: 7px; right: 6px;
  min-width: 18px; height: 18px;
  padding: 0 4px;
  display: grid; place-items: center;
  border-radius: 99px;
  background: var(--danger);
  color: #fff;
  font-size: .66rem;
  font-weight: 800;
  border: 2px solid var(--bg);
  line-height: 1;
}
.user-btn {
  display: flex; align-items: center; gap: 10px;
  height: 46px;
  padding: 3px 4px 3px 3px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  background: var(--surface);
}
.user-btn:hover { border-color: var(--border-strong); }
.user-btn .u-name { display: none; font-weight: 650; font-size: .88rem; max-width: 120px; }
.user-btn .icon { display: none; }
.view { flex: 1 1 auto; width: 100%; max-width: var(--content-max); margin-inline: auto; padding: 18px 16px 32px; outline: none; }
.view.enter > * { animation: fade-up .45s var(--ease) both; }
.view.enter > *:nth-child(2) { animation-delay: .04s; }
.view.enter > *:nth-child(3) { animation-delay: .08s; }
.view.enter > *:nth-child(4) { animation-delay: .12s; }
.view.enter > *:nth-child(5) { animation-delay: .16s; }

.app-footer {
  padding: 18px 16px 28px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  justify-content: center;
  font-size: .8rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  margin-top: 8px;
}
.app-footer a { color: var(--text-muted); font-weight: 600; }
.app-footer a:hover { color: var(--text); }

.bottom-nav {
  position: fixed;
  z-index: 70;
  left: 0; right: 0; bottom: 0;
  height: calc(var(--bottom-nav-h) + var(--safe-bottom));
  padding: 6px 6px var(--safe-bottom);
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--border);
}
.bn-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  border: 0;
  background: transparent;
  border-radius: 14px;
  color: var(--text-muted);
  font-size: .7rem;
  font-weight: 650;
  text-decoration: none;
  min-width: 0;
  transition: color var(--dur);
}
.bn-item:hover { text-decoration: none; color: var(--text); }
.bn-item .icon { width: 23px; height: 23px; transition: transform var(--dur) var(--ease); }
.bn-item[aria-current="page"] { color: var(--primary-ink); }
.bn-item[aria-current="page"] .icon { transform: translateY(-1px) scale(1.08); }
.bn-item .bn-pill {
  display: grid; place-items: center;
  width: 54px; height: 30px;
  border-radius: 99px;
  transition: background-color var(--dur);
}
.bn-item[aria-current="page"] .bn-pill { background: var(--primary-soft); }

/* Tablet: icon rail */
@media (min-width: 768px) {
  .sidebar {
    transform: none;
    width: var(--rail-w);
    padding-inline: 12px;
    box-shadow: none;
  }
  .sidebar.open { box-shadow: none; }
  .sidebar .brand-name,
  .sidebar .nav-label,
  .sidebar .nav-heading,
  .sidebar .side-card,
  .sidebar .sidebar-close { display: none; }
  .sidebar-head { justify-content: center; padding-inline: 0; }
  .nav-item { justify-content: center; padding: 0; min-height: 48px; }
  .nav-item[aria-current="page"]::before { left: -12px; }
  .nav-item .nav-badge {
    position: absolute; top: 4px; right: 6px;
    min-width: 18px; height: 18px; font-size: .64rem; padding: 0 4px;
  }
  .nav-group + .nav-group { padding-top: 10px; border-top: 1px solid var(--border); }
  .scrim { display: none; }
  .app-main { margin-left: var(--rail-w); padding-bottom: 0; }
  .bottom-nav { display: none; }
  .menu-btn, .topbar .topbar-brand { display: none !important; }
  .topbar { padding-inline: 20px; }
  .topbar-title { display: block; }
  .view { padding: 28px 28px 40px; }
  .user-btn .u-name { display: block; }
  .user-btn { padding-right: 12px; }
  .user-btn .icon { display: block; width: 16px; height: 16px; color: var(--text-muted); }
}

/* Short desktop windows: keep "Sign out" in view. */
@media (min-width: 1100px) and (max-height: 960px) {
  .sidebar { padding-block: 10px; }
  .sidebar-head { padding-bottom: 8px; }
  .sidebar-nav { gap: 10px; }
  .nav-item { min-height: 40px; }
  .nav-heading { padding-bottom: 3px; }
  .side-card { display: none !important; }
  .sidebar-foot { margin-top: 8px; padding-top: 8px; }
}

/* Desktop: full sidebar */
@media (min-width: 1100px) {
  .sidebar { width: var(--sidebar-w); padding-inline: 14px; }
  .sidebar .brand-name,
  .sidebar .nav-label,
  .sidebar .nav-heading,
  .sidebar .side-card { display: revert; }
  .sidebar .brand-name { display: inline; }
  .sidebar-head { justify-content: flex-start; padding-inline: 6px; }
  .nav-item { justify-content: flex-start; padding: 0 12px; min-height: 46px; }
  .nav-item[aria-current="page"]::before { left: -14px; }
  .nav-item .nav-badge { position: static; min-width: 22px; height: 22px; font-size: .72rem; padding: 0 6px; }
  .nav-group + .nav-group { padding-top: 0; border-top: 0; }
  .app-main { margin-left: var(--sidebar-w); }
  .topbar { padding-inline: 32px; }
  .view { padding: 32px 32px 48px; }
}

/* ======================================================================== */
/* Public shell                                                              */
/* ======================================================================== */
.pub-shell { min-height: 100dvh; display: flex; flex-direction: column; }
.pub-header {
  position: sticky;
  top: 0;
  z-index: 60;
  padding-top: var(--safe-top);
  background: color-mix(in srgb, var(--bg) 84%, transparent);
  backdrop-filter: saturate(1.4) blur(14px);
  -webkit-backdrop-filter: saturate(1.4) blur(14px);
  border-bottom: 1px solid var(--border);
}
.pub-header-inner { display: flex; align-items: center; gap: 10px; height: var(--topbar-h); }
.pub-nav { display: none; gap: 4px; margin-left: 24px; }
.pub-nav a {
  padding: 8px 14px;
  border-radius: var(--radius-pill);
  color: var(--text-2);
  font-weight: 600;
  font-size: .92rem;
}
.pub-nav a:hover { background: var(--surface); text-decoration: none; color: var(--text); }
.pub-nav a[aria-current="page"] { background: var(--primary-soft); color: var(--text); }
.pub-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.pub-actions .btn-login, .pub-actions .btn-signup { display: none; }
.pub-menu {
  padding: 8px 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  border-top: 1px solid var(--border);
  background: var(--bg);
  animation: fade-in .2s;
}
.pub-menu[hidden] { display: none; }
.pub-menu a.menu-link {
  display: flex; align-items: center; min-height: 48px; padding: 0 12px;
  border-radius: var(--radius-sm); font-weight: 650; color: var(--text);
}
.pub-menu a.menu-link:hover { background: var(--surface); text-decoration: none; }
.pub-menu .menu-cta { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 10px; }

.view-public { max-width: none; padding: 0; }
.view-public > section, .view-public > .container { animation: none; }
.page-narrow { max-width: 820px; margin-inline: auto; padding: 28px 16px 56px; }

@media (min-width: 900px) {
  .pub-nav { display: flex; }
  .pub-actions .btn-login, .pub-actions .btn-signup { display: inline-flex; }
  .pub-toggle { display: none !important; }
  .pub-menu { display: none !important; }
}

.pub-footer { background: var(--surface); border-top: 1px solid var(--border); margin-top: auto; }
.pub-footer-grid {
  display: grid;
  gap: 28px;
  grid-template-columns: 1fr 1fr;
  padding-block: 40px 28px;
}
.pub-footer-grid .f-brand { grid-column: 1 / -1; }
.pub-footer h4 { font-size: .8rem; text-transform: uppercase; letter-spacing: .08em; color: var(--text-muted); margin-bottom: 12px; }
.pub-footer li + li { margin-top: 8px; }
.pub-footer li a { color: var(--text-2); font-weight: 550; font-size: .92rem; }
.pub-footer .f-note { color: var(--text-muted); font-size: .86rem; max-width: 42ch; margin-top: 12px; }
.pub-footer-base {
  display: flex; flex-wrap: wrap; gap: 8px 20px; justify-content: space-between;
  padding-block: 18px 28px;
  border-top: 1px solid var(--border);
  font-size: .8rem;
  color: var(--text-muted);
}
@media (min-width: 768px) {
  .pub-footer-grid { grid-template-columns: 1.6fr 1fr 1fr 1fr; }
  .pub-footer-grid .f-brand { grid-column: auto; }
}

/* ======================================================================== */
/* Auth shell                                                                */
/* ======================================================================== */
.auth-shell { min-height: 100dvh; display: grid; grid-template-columns: 1fr; background: var(--bg); }
.auth-showcase { display: none; }
.auth-panel {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  padding: calc(16px + var(--safe-top)) 20px calc(18px + var(--safe-bottom));
  background: var(--surface);
}
.auth-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.auth-view { flex: 1 1 auto; display: flex; flex-direction: column; justify-content: center; width: 100%; max-width: 440px; margin-inline: auto; padding-block: 28px; }
.auth-foot { text-align: center; font-size: .78rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em; }

@media (min-width: 640px) {
  .auth-panel { padding-inline: 40px; }
}
@media (min-width: 960px) {
  .auth-shell { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .auth-showcase {
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100dvh;
    padding: 36px 48px;
    background:
      radial-gradient(900px 500px at 10% 0%, var(--primary-soft), transparent 60%),
      var(--bg);
    border-right: 1px solid var(--border);
    overflow: hidden;
  }
  .auth-top .brand { visibility: hidden; }
  .auth-panel { padding-inline: 56px; }
}

.showcase-stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 260px;
  display: grid;
  place-items: center;
}
.mock { position: relative; width: min(100%, 420px); height: 340px; }
.mock-card {
  position: absolute;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: var(--shadow);
  padding: 16px;
}
.mock-balance { left: 0; top: 10px; width: 190px; animation: float 7s ease-in-out infinite; }
.mock-balance .mb-icon { width: 38px; height: 38px; border-radius: 12px; background: var(--primary-soft); color: var(--primary-ink); display: grid; place-items: center; margin-bottom: 14px; }
.mock-balance .mb-label { font-size: .68rem; letter-spacing: .06em; text-transform: uppercase; color: var(--text-muted); font-weight: 700; }
.mock-balance .mb-value { font-size: 1.55rem; font-weight: 800; letter-spacing: -0.03em; margin-top: 2px; }
.mock-balance .mb-value span { color: var(--primary-ink); }
.mock-donut { right: 0; top: 70px; width: 170px; text-align: center; animation: float 8s ease-in-out -2s infinite; }
.mock-donut .md-ring {
  --p: 34;
  width: 112px; height: 112px;
  margin: 2px auto 8px;
  border-radius: 50%;
  background: conic-gradient(var(--primary) calc(var(--p) * 1%), var(--c1) 0 62%, var(--c4) 0 82%, var(--surface-3) 0);
  display: grid; place-items: center;
  -webkit-mask: radial-gradient(circle, transparent 0 36px, #000 37px);
  mask: radial-gradient(circle, transparent 0 36px, #000 37px);
}
.mock-donut .md-text { position: absolute; left: 0; right: 0; top: 58px; font-weight: 800; font-size: 1.1rem; }
.mock-donut .md-sub { font-size: .75rem; color: var(--text-muted); font-weight: 600; }
.mock-new {
  left: 18px; bottom: 0; width: 200px;
  text-align: center;
  border-style: dashed;
  border-color: var(--border-strong);
  animation: float 9s ease-in-out -4s infinite;
}
.mock-new .mn-plus { width: 40px; height: 40px; margin: 0 auto 8px; border-radius: 50%; background: var(--primary); color: var(--on-primary); display: grid; place-items: center; }
.mock-new strong { display: block; font-size: .88rem; }
.mock-new span { font-size: .74rem; color: var(--text-muted); }
@keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }

.showcase-copy { min-height: 150px; }
.showcase-slide { display: none; }
.showcase-slide.active { display: block; animation: fade-up .5s var(--ease); }
.showcase-slide h2 { font-size: clamp(1.7rem, 1.2rem + 1.4vw, 2.3rem); letter-spacing: -0.035em; }
.showcase-slide p { margin-top: 10px; color: var(--text-muted); font-size: 1.05rem; max-width: 44ch; }
.showcase-ctrl { display: flex; align-items: center; justify-content: center; gap: 14px; margin-top: 22px; }
.showcase-ctrl button.arrow {
  width: 38px; height: 38px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  display: grid; place-items: center;
  color: var(--text-2);
}
.showcase-ctrl button.arrow:hover { border-color: var(--border-strong); color: var(--text); }
.dots { display: flex; gap: 8px; align-items: center; }
.dots button { width: 8px; height: 8px; padding: 0; border: 0; border-radius: 99px; background: var(--border-strong); transition: all var(--dur) var(--ease); }
.dots button[aria-current="true"] { width: 24px; background: var(--primary); }
