/* ===== App layout shell ===== */
.app {
  display: grid;
  /* minmax(0, 1fr), not 1fr — a bare 1fr track keeps an `auto` minimum, so wide
     content (tables, long unbroken strings) pushes the track past the viewport
     and the whole page scrolls sideways on mobile. */
  grid-template-columns: var(--rail-w) minmax(0, 1fr);
  min-height: 100vh;
}

/* ===== Left nav rail =====
   Ported from the Eko/Amity app shell: a 76px dark rail of 64px items, each a
   stacked icon + 11px label, the active one filled #424242 with a 4px green
   left border. Icons here stay stroke-outline to match the dashboard's card
   icons rather than Eko's filled sprite. */
.rail {
  background: var(--rail-bg);
  padding-top: 8px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  scrollbar-width: none;
}

.rail::-webkit-scrollbar {
  display: none;
}

.rail-list {
  display: flex;
  flex-direction: column;
}

.rail-item {
  position: relative;
}

.rail-item > a {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: var(--rail-item-h);
  padding: 12px 0;
  color: var(--rail-fg-dim);
  border-left: 4px solid transparent;
  transition: background 0.15s ease, color 0.15s ease;
  cursor: pointer;
}

.rail-item > a:hover {
  color: var(--rail-fg);
}

.rail-item.is-active > a {
  background: var(--rail-item-active);
  border-left-color: var(--rail-accent);
  color: var(--rail-fg);
}

.rail-icon {
  position: relative;
  display: block;
  width: 20px;
  height: 20px;
}

/* Sprite symbols (assets/sprite.js) are Font Awesome, i.e. fill-based */
.rail-icon svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
}

/* Red unread pip, sitting just off the icon's top-right corner */
.rail-icon[data-dot]::after {
  content: "";
  position: absolute;
  top: -4px;
  right: -6px;
  width: 8px;
  height: 8px;
  border-radius: 100%;
  background: var(--rail-dot);
}

.rail-label {
  margin-top: 6px;
  font-size: 11px;
  line-height: 11px;
}

/* ===== Main column ===== */
.main {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* ===== Topbar ===== */
.topbar {
  height: 56px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar__brand {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  font-size: 18px;
  color: var(--text-1);
}

.topbar__brand-logo {
  display: inline-flex;
  align-items: center;
}

.topbar__brand-logo img {
  height: 28px;
  width: auto;
  display: block;
  object-fit: contain;
}

.topbar__right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar__avatar {
  /* The full Savvy figure is portrait and carries its own silhouette, so this
     is a plain box, not the circular photo plate it used to be — no radius, no
     clipping, no fill. The image below is sized directly. */
  display: flex;
  align-items: center;
  flex: none;
}

.topbar__avatar img {
  height: 40px;
  width: auto;
  max-width: none;
  display: block;
}

/* The mark is the full Savvy figure, tight-cropped to its alpha bounds and
   transparent. It is sized by height and centred; nothing clips it. */


.topbar__divider {
  width: 1px;
  height: 24px;
  background: var(--border);
}

.topbar__settings {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  color: var(--text-2);
  transition: background 0.15s ease;
}

.topbar__settings:hover {
  background: var(--bg);
}

.topbar__settings svg {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.6;
}

/* ===== Content area ===== */
.content {
  flex: 1;
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
  padding: 24px 48px 64px;
  min-width: 0;
}

@media (max-width: 1024px) {
  .content {
    padding: 20px 24px 48px;
  }
}

/* ===== Mobile: the rail relocates to a fixed bottom tab bar =====
   Eko hides the rail behind a hamburger at this width; with only two
   destinations a bottom bar is the better trade, so the rail lies down
   instead — the active marker moves from the left border to the bottom. */
@media (max-width: 768px) {
  .app {
    grid-template-columns: minmax(0, 1fr);
  }

  .rail {
    position: fixed;
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    height: calc(var(--bottom-nav-h) + env(safe-area-inset-bottom, 0px));
    padding: 0 8px env(safe-area-inset-bottom, 0px);
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    overflow: visible;
    z-index: 50;
  }

  .rail-list {
    flex-direction: row;
    justify-content: space-around;
    align-items: stretch;
    height: 100%;
  }

  .rail-item {
    flex: 1;
    max-width: 160px;
  }

  .rail-item > a {
    height: 100%;
    padding: 8px 0;
    border-left: 0;
    border-bottom: 3px solid transparent;
  }

  .rail-item.is-active > a {
    border-left-color: transparent;
    border-bottom-color: var(--rail-accent);
  }

  /* Reserve space so page content never hides behind the fixed bar */
  .main {
    padding-bottom: calc(var(--bottom-nav-h) + env(safe-area-inset-bottom, 0px));
  }

  .topbar {
    padding: 0 16px;
  }

  .topbar__brand-logo img {
    height: 24px;
  }
}
