/* ==========================================================================
   App shell: rail (sidebar) + chrome header + content column
   ========================================================================== */
.shell { display: flex; min-height: 100dvh; }

/* ---- Rail ------------------------------------------------------------- */
.rail {
  position: sticky; top: 0; height: 100dvh; width: var(--sidebar-width); flex-shrink: 0;
  display: flex; flex-direction: column; background: var(--rail); color: var(--rail-ink);
  border-right: 1px solid var(--rail-line); z-index: 40;
}
.rail-brand { display: flex; align-items: center; gap: 10px; padding: 20px 20px 18px; }
.brand-mark { width: 30px; height: 30px; object-fit: contain; }
.brand-name { font-size: 15px; font-weight: 600; letter-spacing: .14em; line-height: 1; }
.brand-tag { margin-top: 4px; font-size: 11.5px; font-weight: 500; letter-spacing: .02em; line-height: 1; color: var(--rail-muted); }
.rail .rail-close { display: none; margin-left: auto; }

.rail-nav { flex: 1; min-height: 0; overflow-y: auto; padding: 0 12px 8px; display: flex; flex-direction: column; }
.rail-nav > * { flex-shrink: 0; }
.nav-bottom { margin-top: auto; }
.nav-bottom .nav-section { margin-top: 24px; }
.nav-item {
  position: relative; display: flex; align-items: center; gap: 12px; height: 40px; padding: 0 12px;
  border-radius: var(--r-md); color: var(--rail-muted); font-size: 14.5px; font-weight: 500;
  transition: background-color var(--t-base) ease, color var(--t-base) ease;
}
.nav-item + .nav-item, .nav-sub + .nav-item { margin-top: 2px; }
.nav-item:hover { background: #ffffff0d; color: var(--rail-ink); }
.nav-item .i { color: currentColor; }
.nav-item .i-fill { display: none; }
.nav-item[aria-current="page"] { background: var(--rail-active); color: var(--rail-ink); }
.nav-item[aria-current="page"] .i-line { display: none; }
.nav-item[aria-current="page"] .i-fill { display: inline-block; color: var(--olive); }
.nav-item.is-drop { background: var(--rail-active); box-shadow: inset 0 0 0 1.5px var(--olive); color: var(--rail-ink); }
.nav-badge { margin-left: auto; font-size: 11.5px; font-weight: 600; color: var(--rail-muted); }

.nav-group { position: relative; margin-top: 2px; }
.nav-group .nav-item { padding-right: 40px; }
.nav-caret { position: absolute; right: 6px; top: 6px; display: grid; place-items: center; width: 28px; height: 28px; border-radius: var(--r-sm);
  color: var(--rail-muted); }
.nav-caret:hover { background: #ffffff14; color: var(--rail-ink); }
.nav-caret .i { transition: transform var(--t-base) var(--ease); }
.nav-caret[aria-expanded="false"] .i { transform: rotate(-90deg); }
.nav-sub { margin: 2px 0 6px 22px; padding-left: 9px; border-left: 1px solid #ffffff1a; }
.nav-sub a {
  display: flex; align-items: center; height: 34px; padding: 0 10px; border-radius: var(--r-sm); font-size: 13.5px;
  color: var(--rail-muted); transition: background-color var(--t-base) ease, color var(--t-base) ease;
}
.nav-sub a + a { margin-top: 0; }
.nav-sub a:hover { color: var(--rail-ink); background: #ffffff0d; }
.nav-sub a[aria-current="page"] { background: var(--rail-active); color: var(--rail-ink); font-weight: 500; }
.nav-sub a.is-drop { background: var(--rail-active); box-shadow: inset 0 0 0 1.5px var(--olive); }
.nav-sub span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.nav-section { margin: 28px 0 6px; padding: 0 12px; font-size: 11.5px; font-weight: 600; letter-spacing: .04em;
  color: color-mix(in oklab, var(--rail-muted) 80%, transparent); }

.rail-foot { padding: 12px 12px 16px; display: grid; gap: 12px; }
.storage-card { border-radius: 12px; background: #ffffff0a; padding: 12px; box-shadow: inset 0 0 0 1px #ffffff0d; }
.storage-card .row-between { display: flex; align-items: baseline; justify-content: space-between; font-size: 12px; }
.storage-card .label { font-weight: 500; color: var(--rail-ink); }
.storage-card .value { color: var(--rail-muted); }
.bar { margin-top: 8px; height: 6px; border-radius: 999px; background: #ffffff14; overflow: hidden; }
.bar > span { display: block; height: 100%; width: 0; border-radius: inherit; background: var(--olive);
  transition: width var(--t-slow) var(--ease); min-width: 3px; }
.bar.is-warn > span { background: #d9a23a; }
.bar.is-full > span { background: var(--danger); }

.me-button {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px; border-radius: 12px; text-align: left;
  color: var(--rail-ink);
}
.me-button:hover, .me-button[aria-expanded="true"] { background: #ffffff12; }
.me-name { display: block; font-size: 13.5px; font-weight: 600; color: var(--rail-ink); }
.me-role { display: block; font-size: 12px; color: var(--rail-muted); }
.me-button .i { color: var(--rail-muted); margin-left: auto; }

/* ---- Main column ------------------------------------------------------ */
.main-col { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 30; height: var(--header-height);
  background: var(--chrome); -webkit-backdrop-filter: blur(20px) saturate(170%); backdrop-filter: blur(20px) saturate(170%);
  border-bottom: 1px solid var(--line);
}
.topbar-inner { margin: 0 auto; max-width: var(--content-max); height: 100%; display: flex; align-items: center; gap: 12px; padding: 0 32px; }
.topbar-mobile { display: none; }

.search-trigger {
  display: flex; align-items: center; gap: 8px; flex: 1; max-width: 440px; height: 40px; padding: 0 12px;
  border-radius: var(--r-md); border: 1px solid var(--line); background: var(--surface); box-shadow: var(--e-1);
  color: var(--faint); font-size: 14px; text-align: left; cursor: text;
}
.search-trigger:hover { border-color: var(--line-strong); }
.search-trigger .i { color: var(--muted); }
.kbd {
  margin-left: auto; border-radius: var(--r-xs); border: 1px solid var(--line); background: var(--surface-2);
  padding: 2px 6px; font-family: var(--font); font-size: 11.5px; font-weight: 500; color: var(--muted); line-height: 1.3;
}
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }

.content { width: 100%; max-width: var(--content-max); margin: 0 auto; padding: 32px 32px 64px; flex: 1; }
.content.is-narrow { max-width: calc(760px + 64px); }

/* Page header */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }
.page-head .t-display { margin-top: 2px; }
.page-sub { margin-top: 6px; font-size: 14px; color: var(--muted); }
.page-eyebrow { font-size: 14px; font-weight: 500; color: var(--muted); }
.page-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.section-title { margin: 40px 0 14px; display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.section-title:first-child { margin-top: 0; }
.section-title a { font-size: 13.5px; font-weight: 500; color: var(--muted); }
.section-title a:hover { color: var(--olive-ink); }

/* ---- Mobile tab bar ---------------------------------------------------- */
.tabbar { display: none; }

/* ---- Responsive -------------------------------------------------------- */
@media (max-width: 1023.98px) {
  .rail {
    position: fixed; inset: 0 auto 0 0; width: min(300px, 86vw); transform: translateX(-102%);
    transition: transform var(--t-slow) var(--ease-out); box-shadow: var(--e-3);
  }
  .rail.is-open { transform: none; }
  .rail .rail-close { display: inline-grid; }
  .rail-scrim { position: fixed; inset: 0; background: var(--scrim); z-index: 39; opacity: 0; pointer-events: none; transition: opacity var(--t-slow) ease; }
  .rail-scrim.is-open { opacity: 1; pointer-events: auto; }
  .topbar-inner { padding: 0 24px; }
  .topbar-desktop { display: none; }
  .topbar-mobile { display: flex; align-items: center; gap: 8px; width: 100%; }
  .topbar-mobile .brand-mark { width: 32px; height: 32px; }
  .content { padding: 24px 24px 120px; }
  .tabbar {
    display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; position: fixed; inset: auto 0 0 0; z-index: 35;
    height: calc(var(--tabbar-height) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
    background: color-mix(in oklab, var(--surface) 94%, transparent); -webkit-backdrop-filter: blur(20px) saturate(170%); backdrop-filter: blur(20px) saturate(170%);
    border-top: 1px solid var(--line); box-shadow: 0 -4px 16px rgb(0 0 0 / .06);
  }
  .tab { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 11.5px;
    font-weight: 500; color: var(--muted); }
  .tab .i-fill { display: none; }
  .tab[aria-current="page"] { color: var(--ink); }
  .tab[aria-current="page"] .i-line { display: none; }
  .tab[aria-current="page"] .i-fill { display: inline-block; color: var(--olive-ink); }
}
@media (max-width: 639.98px) {
  .topbar-inner { padding: 0 16px; }
  .content { padding: 20px 16px 120px; }
  .page-head { margin-bottom: 20px; }
}
