/* ── App shell ── */
.app-shell {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100dvh;
  position: relative;
  background: var(--sand);
  padding-bottom: calc(var(--nav-height) + env(safe-area-inset-bottom, 0px));
}

/* ── Tab panes ── */
.tab-pane { display: none; flex-direction: column; height: 100%; }
.tab-pane.active { display: flex; }

.tab-scroll {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-4);
  -webkit-overflow-scrolling: touch;
}

.tab-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: white;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
  min-height: 50px;
}

.tab-title {
  font-size: var(--text-lg);
  font-weight: normal;
  flex: 1;
}

/* ─────────────────────────────────────────────────────
   BOTTOM NAV  — base (mobile-first) rules must appear
   BEFORE any media query that overrides them.
   Mobile: position:fixed bottom bar
   Desktop (≥900px): overridden to position:sticky sidebar
───────────────────────────────────────────────────── */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--nav-height);
  background: white;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: stretch;
  padding-bottom: env(safe-area-inset-bottom, 0px);
  z-index: 100;
  box-shadow: 0 -1px 0 var(--border);
}

/* Logo only visible in desktop sidebar */
.nav-brand { display: none; }

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-height: 44px;
  min-width: 44px;
  color: var(--ink-4);
  transition: color var(--dur-fast) var(--ease-smooth);
  position: relative;
}

.nav-item.active { color: var(--accent); }

/* Active pill indicator above icon (mobile) */
.nav-item.active::after {
  content: '';
  position: absolute;
  top: 6px;
  left: 50%;
  transform: translateX(-50%);
  width: 4px;
  height: 4px;
  border-radius: var(--radius-full);
  background: var(--accent);
}

.nav-item:active { opacity: 0.65; }

.nav-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.nav-icon svg {
  width: 20px;
  height: 20px;
  display: block;
}
.nav-label {
  font-family: system-ui, -apple-system, sans-serif;
  font-size: var(--text-xs);
  font-weight: 500;
}

/* ── FAB ── */
.fab {
  position: fixed;
  bottom: calc(var(--nav-height) + env(safe-area-inset-bottom, 0px) + 16px);
  right: 16px;
  width: 52px;
  height: 52px;
  border-radius: var(--radius-full);
  background: var(--accent);
  color: white;
  font-size: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(45, 90, 78, 0.4);
  z-index: 99;
  transition:
    transform    var(--dur-fast) var(--ease-smooth),
    box-shadow   var(--dur-fast) var(--ease-smooth),
    background   var(--dur-fast) var(--ease-smooth);
}
.fab:active {
  transform: scale(0.93);
  box-shadow: 0 2px 8px rgba(45, 90, 78, 0.3);
}
@media (hover: hover) {
  .fab:hover {
    background: var(--accent-hover);
    box-shadow: 0 6px 20px rgba(45, 90, 78, 0.5);
    transform: translateY(-2px);
  }
}

/* ── Sheet overlay ── */
.sheet-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 200;
  opacity: 0;
  transition: opacity var(--dur-base) var(--ease-smooth);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}
.sheet-overlay.visible { opacity: 1; }

/* ── Bottom sheets (mobile base) ── */
.bottom-sheet {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  max-width: 480px;
  margin: 0 auto;
  background: white;
  border-radius: var(--radius) var(--radius) 0 0;
  padding: 12px 20px 20px;
  padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 20px);
  z-index: 201;
  max-height: 92dvh;
  overflow-y: auto;
  transform: translateY(100%);
  transition: transform var(--dur-slow) var(--ease-spring);
  -webkit-overflow-scrolling: touch;
}
.bottom-sheet.open { transform: translateY(0); }

.sheet-handle {
  width: 36px;
  height: 4px;
  background: var(--stone);
  border-radius: 2px;
  margin: 0 auto 16px;
}

.sheet-title {
  font-size: var(--text-xl);
  font-weight: normal;
  margin-bottom: var(--space-5);
}

/* ─────────────────────────────────────────────
   Mid breakpoint (520–899px): centered phone shell
   These must also precede the 900px block.
───────────────────────────────────────────── */
@media (min-width: 520px) {
  body { background: var(--stone); }
  .app-shell { box-shadow: var(--shadow-lg); }
  .bottom-nav {
    max-width: 480px;
    left: 50%;
    transform: translateX(-50%);
    right: auto;
    width: 100%;
  }
  .fab { right: calc(50% - 240px + 16px); }
}

/* ─────────────────────────────────────────────
   Desktop (≥ 900px): CSS Grid macro-layout
   NOW placed last so it correctly overrides all
   base rules above (cascade order wins).
   grid-template-columns: 220px sidebar | 1fr content
   Nav: position:sticky in-flow sidebar
───────────────────────────────────────────── */
@media (min-width: 900px) {
  body { background: var(--stone); }

  /* Grid container */
  #main-app {
    display: grid;
    grid-template-columns: 220px 1fr;
    grid-template-rows: auto 1fr;
    min-height: 100dvh;
  }

  /* Offline banner spans both columns */
  #offline-banner {
    grid-column: 1 / -1;
    grid-row: 1;
  }

  /* ── Sidebar nav: override fixed → sticky ── */
  .bottom-nav {
    grid-column: 1;
    grid-row: 2;
    /* KEY: override mobile position:fixed */
    position: sticky;
    top: 0;
    bottom: auto;
    left: auto;
    right: auto;
    /* Override 520px centering */
    transform: none;
    max-width: none;
    /* Size */
    height: 100dvh;
    width: 220px;
    /* Layout */
    flex-direction: column;
    align-items: stretch;
    overflow-y: auto;
    overflow-x: hidden;
    /* Visuals */
    background: white;
    border-top: none;
    border-right: 1px solid var(--border);
    border-bottom: none;
    box-shadow: none;
    padding: 0;
    padding-bottom: 0;
    z-index: 10;
  }

  /* Brand logo at sidebar top */
  .nav-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 18px;
    height: 56px;      /* will be overridden to 64px by desktop.css at 1024px */
    border-bottom: 1px solid var(--border);
    margin-bottom: 0;  /* no extra gap — nav-items start immediately below */
    flex-shrink: 0;
  }
  .nav-logo {
    width: 26px;
    height: 26px;
    display: block;
    flex-shrink: 0;
  }

  .nav-item {
    flex: 0 0 auto;
    flex-direction: row;
    justify-content: flex-start;
    gap: 12px;
    margin: 2px 8px;
    padding: 11px 14px;
    min-height: 46px;
    border-radius: var(--radius-sm);
    position: relative;
    transition:
      background var(--dur-fast) var(--ease-smooth),
      color      var(--dur-fast) var(--ease-smooth);
  }

  /* Remove mobile dot indicator */
  .nav-item::after { display: none; }

  /* Active: tinted pill + left-edge bar */
  .nav-item.active {
    background: var(--accent-light);
    color: var(--accent);
  }
  .nav-item.active::before {
    content: '';
    position: absolute;
    left: -8px;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 22px;
    background: var(--accent);
    border-radius: 0 2px 2px 0;
  }

  @media (hover: hover) {
    .nav-item:not(.active):hover {
      background: var(--sand);
      color: var(--ink-2);
    }
  }

  .nav-icon svg { width: 18px; height: 18px; }
  .nav-label { font-size: 14px; font-weight: 500; font-family: system-ui, -apple-system, sans-serif; }

  /* ── Content area ── */
  .app-shell {
    grid-column: 2;
    grid-row: 2;
    max-width: 100%;
    margin: 0;
    padding-bottom: 0;
    box-shadow: none;
    border-radius: 0;
    min-height: 100dvh;
    /* stretch to fill grid row height so tab-pane height:100% resolves */
    display: flex;
    flex-direction: column;
  }

  /* Tab pane fills the panel */
  .tab-pane { flex: 1; min-height: 0; }

  /* Content fills the full panel width — no more narrow centered column */
  .tab-scroll {
    /* max-width: none — content stretches edge to edge */
    padding: clamp(24px, 3vw, 40px) clamp(32px, 4vw, 56px);
  }

  /* Spacious desktop page header */
  .tab-header {
    padding: 0 clamp(32px, 4vw, 56px);
    min-height: 64px;
  }
  .tab-title { font-size: 20px; }

  /* FAB: stays fixed in viewport */
  .fab {
    right: 32px;
    bottom: 32px;
  }

  /* ── Bottom sheets → centered modals ── */
  .bottom-sheet {
    left: 220px;
    right: 0;
    margin: 0 auto;
    width: min(600px, calc(100vw - 220px - 48px));
    max-width: none;
    top: 50%;
    bottom: auto;
    border-radius: var(--radius);
    transform: translateY(calc(-50% + 28px));
    opacity: 0;
    transition:
      transform var(--dur-slow) var(--ease-spring),
      opacity   var(--dur-base) var(--ease-smooth);
  }
  .bottom-sheet.open {
    transform: translateY(-50%);
    opacity: 1;
  }

  .sheet-handle { display: none; }
  .sheet-title  { font-size: clamp(18px, 2.5vw, 22px); }
}

/* ── Auth screen ── */
.auth-screen {
  position: fixed;
  inset: 0;
  background: var(--sand);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
  padding: var(--space-6);
}

.auth-card {
  max-width: 380px;
  width: 100%;
  background: white;
  border-radius: var(--radius);
  padding: clamp(32px, 6vw, 48px) clamp(24px, 6vw, 40px);
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.auth-logo {
  display: flex;
  justify-content: center;
  margin-bottom: clamp(20px, 4vw, 32px);
}

.auth-logo img {
  height: 40px;
  width: auto;
  display: block;
}

.auth-subtitle {
  color: var(--ink-3);
  margin-bottom: var(--space-6);
  font-size: var(--text-body);
  font-family: system-ui, -apple-system, sans-serif;
}

/* auth-title removed — logo carries the brand name */
.auth-sent-msg { font-size: clamp(17px, 3vw, 20px); margin-bottom: var(--space-2); }
.auth-sent-sub {
  color: var(--ink-3);
  margin-bottom: var(--space-4);
  font-family: system-ui, -apple-system, sans-serif;
}

/* ── Offline banner ── */
.offline-banner {
  background: var(--accent-2);
  color: white;
  text-align: center;
  padding: 8px 16px;
  font-family: system-ui, -apple-system, sans-serif;
  font-size: var(--text-sm);
  position: sticky;
  top: 0;
  z-index: 50;
}

/* ── Toasts ── */
#toast-container {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
  max-width: 340px;
  width: calc(100% - 32px);
}
.toast {
  background: var(--ink);
  color: white;
  padding: 12px 18px;
  border-radius: var(--radius);
  font-family: system-ui, -apple-system, sans-serif;
  font-size: var(--text-base);
  animation: toast-in var(--dur-base) var(--ease-spring);
  pointer-events: auto;
  text-align: center;
  box-shadow: var(--shadow-md);
}
.toast.toast-success { background: var(--accent); }
.toast.toast-error   { background: var(--danger); }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(-12px) scale(0.95); }
  to   { opacity: 1; transform: translateY(0)     scale(1);    }
}

/* ── Share header ── */
.share-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: white;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand { font-size: var(--text-body); }
.share-badge {
  font-family: system-ui, -apple-system, sans-serif;
  font-size: var(--text-xs);
  background: var(--stone);
  padding: 4px 10px;
  border-radius: var(--radius-full);
  color: var(--ink-3);
}
