* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.page {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 420px 390px;
  gap: 26px;
  align-items: start;
  justify-content: center;
  padding: 24px;
}

/* Phone frame */
.phone {
  width: 390px;
  height: 820px;
  max-height: calc(100vh - 48px);
  background: var(--phone);
  border-radius: 38px;
  padding: 14px;
  box-shadow: 0 24px 70px rgba(16, 24, 40, .25);
  position: sticky;
  top: 24px;
}

.screen {
  height: 100%;
  background: var(--screen);
  border-radius: 28px;
  overflow: hidden;
  position: relative;
  color: var(--text);
}

.screen-scroll {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  bottom: 78px;
  overflow-y: auto;
  padding: 18px;
}

.screen-scroll.baby-budget-mode {
  padding: 0;
  overflow: hidden;
  bottom: 0; /* nav is hidden in this mode — fill to edge */
}

.screen-scroll.lesson-mode {
  padding: 0;
  overflow: hidden;
  bottom: 0; /* extend past tab bar — nav is hidden when lesson is active */
}

.screen-scroll.streak-mode {
  padding: 0;
  overflow: hidden;
  bottom: 0; /* full-bleed branded splash — nav is hidden on the streak screen */
}

.screen-scroll.chat-mode {
  padding: 0;
  overflow: hidden;
  bottom: 0; /* nav is hidden on chat — the input bar sits on the bottom edge */
  /* The chat shell owns its own scrolling: the thread scrolls, the chips and
     input bar stay pinned. See .chat-shell in components.css. */
}

/* Bottom nav */
.bottom-tabs {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 78px;
  padding: 10px 10px 14px;
  background: rgba(248, 250, 252, .98);
  border-top: 1px solid var(--line);
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
}

.dark-mode .bottom-tabs {
  background: rgba(30, 33, 40, .98);
}

.tab {
  border: 0;
  background: transparent;
  color: var(--muted);
  border-radius: 14px;
  font-size: 11px;
  font-weight: 850;
  cursor: pointer;
}

.tab.active {
  background: var(--accent-soft);
  color: var(--accent);
}

/* Admin panel */
.admin {
  height: 820px;
  max-height: calc(100vh - 48px);
  background: rgba(255, 255, 255, .82);
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: 0 12px 40px rgba(16, 24, 40, .08);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 24px;
}

.admin-header {
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--card);
  color: var(--text);
}

.admin-title {
  margin: 0;
  font-size: 16px;
  font-weight: 850;
}

.admin-subtitle {
  margin: 5px 0 0;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.35;
}

.admin-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}

/* Admin collapse */
.page.admin-collapsed {
  grid-template-columns: 420px;
}
.page.admin-collapsed .admin {
  display: none;
}

.admin-collapse-btn {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
  flex-shrink: 0;
}
.admin-collapse-btn:hover {
  color: var(--text);
}

.admin-expand-tab {
  display: none; /* shown via JS when collapsed */
  position: fixed;
  right: 16px;
  top: 24px;
  width: 28px;
  height: 48px;
  background: rgba(255, 255, 255, .92);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(16, 24, 40, .1);
  font-size: 16px;
  font-weight: 700;
  color: var(--muted);
  cursor: pointer;
  align-items: center;
  justify-content: center;
}
.admin-expand-tab:hover {
  color: var(--text);
}

/* Responsive */
@media (max-width: 900px) {
  .page {
    grid-template-columns: 1fr;
    justify-items: center;
  }
  .admin {
    width: 390px;
    max-width: 100%;
    position: relative;
    top: auto;
  }
  .phone {
    position: relative;
    top: auto;
  }
}

@media (max-width: 768px) {
  .admin {
    display: none !important;
  }
  #adminExpandTab {
    display: none !important;
  }
}

/* ─── Responsive grid utility ────────────────────────────────────────────────
   .summary-grid: 3-col by default, collapses to 2-col on very narrow screens */
.summary-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
}

@media (max-width: 400px) {
  .summary-grid {
    grid-template-columns: 1fr 1fr;
  }
}

/* ─── Scroll indicators ───────────────────────────────────────────────────────
   Mobile-app-style overlay look: thin rounded thumb, no track, no arrow
   buttons. Applies to every scrollable container (phone screen, chat thread,
   admin panel). Chromium/WebKit takes the pseudo-element rules; Firefox
   (no ::-webkit-scrollbar support) gets the standard thin-scrollbar props
   via @supports so the two rule sets never fight in one engine. */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-corner { background: transparent; }
::-webkit-scrollbar-button { display: none; width: 0; height: 0; }
::-webkit-scrollbar-thumb {
  background: var(--scroll-thumb);
  border-radius: 99px;
}

@supports not selector(::-webkit-scrollbar) {
  * {
    scrollbar-width: thin;
    scrollbar-color: var(--scroll-thumb) transparent;
  }
}
