/* The frame every page sits in: sidebar, top bar, page header, the split
   and stack layouts. */

/* ---------- Shell ---------- */

.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100dvh;
}

.app[data-rail="on"] {
  grid-template-columns: var(--sidebar-w-collapsed) 1fr;
}

.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100dvh;
  overflow: hidden;
}

.brand {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: var(--s3);
  padding: 0 var(--s4);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.brand-mark {
  width: 26px;
  height: 26px;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: var(--accent-fg);
  display: grid;
  place-items: center;
  font-size: var(--fs-meta);
  font-weight: 600;
  flex-shrink: 0;
}

.brand-name {
  font-weight: 600;
  font-size: var(--fs-title);
  white-space: nowrap;
}

.nav {
  padding: var(--s3) var(--s2);
  overflow-y: auto;
  flex: 1;
}

.nav-group {
  padding: var(--s4) var(--s3) var(--s2);
  font-size: var(--fs-micro);
  color: var(--text-faint);
  font-weight: 600;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: var(--s3);
  padding: var(--s2) var(--s3);
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: var(--fs-cell);
  white-space: nowrap;
  transition: background var(--t-fast) var(--ease-out),
    color var(--t-fast) var(--ease-out);
}

.nav-link i {
  font-size: 17px;
  flex-shrink: 0;
}

.nav-link:hover {
  background: var(--surface-3);
  color: var(--text);
}

.nav-link[aria-current="page"] {
  background: var(--accent);
  color: var(--accent-fg);
  font-weight: 500;
}

.nav-count {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: var(--fs-micro);
  color: inherit;
  opacity: 0.7;
}

.app[data-rail="on"] .brand-name,
.app[data-rail="on"] .nav-group,
.app[data-rail="on"] .nav-link span,
.app[data-rail="on"] .nav-count {
  display: none;
}

.app[data-rail="on"] .nav-link {
  justify-content: center;
  padding: var(--s2);
}

/* ---------- Topbar ---------- */

.main {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: var(--s3);
  padding: 0 var(--s5);
  position: sticky;
  top: 0;
  z-index: 20;
}

.search {
  flex: 1;
  max-width: 420px;
  position: relative;
}

.search i {
  position: absolute;
  left: var(--s3);
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-faint);
  font-size: 16px;
}

.search input {
  width: 100%;
  height: 34px;
  padding: 0 var(--s3) 0 34px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: var(--fs-cell);
}

.search input::placeholder {
  color: var(--text-faint);
}

.topbar-spacer {
  flex: 1;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: var(--s2);
  padding: var(--s1) var(--s2) var(--s1) var(--s1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  cursor: pointer;
  font-size: var(--fs-cell);
}

.avatar {
  width: 24px;
  height: 24px;
  border-radius: var(--radius-sm);
  background: var(--surface-3);
  color: var(--text-muted);
  display: grid;
  place-items: center;
  font-size: var(--fs-micro);
  font-weight: 600;
  flex-shrink: 0;
}

/* ---------- Page ---------- */

.view {
  padding: var(--s6);
  flex: 1;
}

.page-head {
  display: flex;
  align-items: flex-start;
  gap: var(--s4);
  margin-bottom: var(--s5);
  flex-wrap: wrap;
}

.page-title {
  font-size: var(--fs-page);
  font-weight: 600;
  letter-spacing: -0.01em;
}

.page-sub {
  font-size: var(--fs-meta);
  color: var(--text-muted);
  margin-top: 2px;
}

.page-actions {
  margin-left: auto;
  display: flex;
  gap: var(--s2);
  flex-wrap: wrap;
}

.crumb {
  font-size: var(--fs-meta);
  color: var(--text-muted);
  margin-bottom: var(--s2);
  display: flex;
  align-items: center;
  gap: var(--s2);
}

.crumb a:hover {
  color: var(--text);
  text-decoration: underline;
}

.section-title {
  font-size: var(--fs-title);
  font-weight: 600;
  margin-bottom: var(--s3);
}

.grid {
  display: grid;
  gap: var(--s4);
}

.cols-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.cols-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.cols-4 {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: var(--s5);
  align-items: start;
}

.stack {
  display: grid;
  gap: var(--s4);
}

/* Sign in replaces the whole shell. */

body[data-view="auth"] .app,
body[data-view="app"] #auth {
  display: none;
}
