/* The signed in app: the rail runs the full height on the left with the logo at its top, a glass top bar sits over the
   page only, so the page scrolls under it, and one quiet footer line ends the page. */

.app-shell {
  display: grid; grid-template-columns: var(--rail) minmax(0, 1fr); grid-template-rows: auto 1fr; min-height: 100vh;
  transition: grid-template-columns .24s ease;
}
html.rail-collapsed .app-shell { grid-template-columns: var(--rail-collapsed) minmax(0, 1fr); }

/* ---------- Topbar ---------- */
.topbar {
  grid-column: 2; grid-row: 1; position: sticky; top: var(--banner-h, 0px); z-index: 40;
  height: var(--topbar); display: flex; align-items: center; gap: 14px; padding: 0 22px 0 18px;
  background: var(--chrome);
  border-bottom: 1px solid var(--line);
}
/* The logo lives in the rail; the top bar keeps it only on a phone, where the rail is a drawer. */
.topbar-brand { --logo-h: 12px; display: flex; align-items: center; gap: 12px; flex: none; }
.topbar-brand .brand { display: none; min-width: 0; }
.topbar .icon-btn { border-color: var(--line); background: var(--panel); }
.topbar .icon-btn:hover { background: var(--panel-3); }
.topbar .avatar { width: 34px; height: 34px; background: var(--brand-grad-fill); box-shadow: var(--sheen-edge); }

.brand { display: flex; align-items: center; color: var(--ink); flex: none; }

/* The wordmark file carries a lot of empty space above and below the letters; the crop shows only the letters. */
.brandlogo { height: var(--logo-h, 14px); width: auto; max-width: none; aspect-ratio: 12 / 1; object-fit: cover; }

.rail-toggle {
  display: grid; place-items: center; flex: none;
  width: 34px; height: 34px; border-radius: var(--r-m);
  background: none; border: 1px solid var(--line); color: var(--ink-3); cursor: pointer;
  transition: background .15s ease, color .15s ease;
}
.rail-toggle:hover { background: var(--panel-3); color: var(--ink); }
.rail-toggle svg { width: 17px; height: 17px; transition: transform .22s ease; }
html.rail-collapsed .rail-toggle svg { transform: rotate(180deg); }

.top-sep { display: none; width: 1px; height: 22px; background: var(--line); flex: none; }
.top-crumbs { display: flex; align-items: center; gap: 7px; min-width: 0; flex: 1; font-size: var(--fs-s); color: var(--ink-3); }
.top-crumbs a { color: var(--ink-3); white-space: nowrap; }
.top-crumbs a:hover { color: var(--ink); }
.top-crumbs .sep { color: var(--ink-5); }
.top-title { font-size: var(--fs-xs); font-weight: 600; letter-spacing: var(--tr-caps); text-transform: uppercase; color: var(--ink-4); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-crumbs > :last-child:not(.sep):not(.btn):not(.top-title) { color: var(--ink); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topright { margin-left: auto; display: flex; align-items: center; gap: 6px; }

/* ---------- Rail ---------- */
.rail {
  grid-column: 1; grid-row: 1 / span 2;
  position: sticky; top: var(--banner-h, 0px); align-self: start;
  height: calc(100vh - var(--banner-h, 0px)); overflow-y: auto;
  display: flex; flex-direction: column; gap: 3px;
  padding: 0 12px 20px;
  background: var(--rail-bg); border-right: 1px solid var(--line);
  transition: padding .24s ease;
}
.rail-brand {
  --logo-h: 13px;
  display: flex; align-items: center; flex: none; height: var(--topbar); margin-bottom: 10px; padding: 0 10px;
  border-bottom: 1px solid var(--line-soft);
}
.rail-brand .rail-mark { display: none; width: 28px; height: 28px; border-radius: var(--r-s); }
/* Collapsed, the wordmark gives way to the mark; on a phone the rail is a drawer and is never collapsed. */
@media (min-width: 861px) {
  html.rail-collapsed .rail-brand { justify-content: center; padding: 0; }
  html.rail-collapsed .rail-brand .brandlogo { display: none; }
  html.rail-collapsed .rail-brand .rail-mark { display: block; }
}
.rail .group {
  margin: 16px 10px 6px; transition: opacity .16s ease .06s;
  font-size: var(--fs-2xs); font-weight: 600; letter-spacing: var(--tr-caps); text-transform: uppercase; color: var(--ink-4);
}
.rail .group:first-child { margin-top: 2px; }
.rail .spacer { flex: 1; }

.rail a.nav {
  display: flex; align-items: center; gap: 11px;
  min-height: 38px; padding: 0 10px; border-radius: var(--r-m);
  color: var(--ink-3); font-size: var(--fs-s); font-weight: 500; line-height: 1.3;
  transition: padding .24s ease, gap .24s ease, background .15s ease, color .15s ease, box-shadow .15s ease;
}
.rail a.nav:hover { background: var(--panel-3); color: var(--ink); }
/* The open page: a soft brand tint with a thin ring, the text in full ink and only the icon in brand blue. */
.rail a.nav.active {
  background: color-mix(in srgb, var(--brand-text) 14%, transparent); color: var(--ink); font-weight: 600;
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--brand-text) 28%, transparent);
}
.rail a.nav .ic { display: grid; place-items: center; width: 18px; flex: none; color: var(--ink-4); transition: color .15s ease; }
.rail a.nav:hover .ic { color: var(--ink-2); }
.rail a.nav.active .ic { color: var(--brand-text); }
.rail a.nav svg { width: 17px; height: 17px; }
.rail a.nav .lbl, .rail a.nav .count {
  display: inline-block; max-width: 170px; overflow: hidden; white-space: nowrap;
  transition: max-width .24s ease, opacity .16s ease .06s;
}
.rail a.nav .count {
  margin-left: auto; padding: 1px 7px; border-radius: var(--r-full);
  background: var(--panel-3); color: var(--ink-3);
  font-size: var(--fs-2xs); font-weight: 600; font-variant-numeric: tabular-nums;
}
.rail a.nav.active .count { background: var(--brand); color: var(--on-brand); }
.rail a.nav .count.alert { background: var(--bad); color: var(--on-bad); }
/* An important announcement: a glowing "!" instead of a count, until it is seen. */
.rail a.nav .count.important, .rail a.nav.active .count.important {
  display: grid; place-items: center; width: 20px; height: 20px; padding: 0; border-radius: 50%;
  background: var(--action-grad); color: var(--on-brand); font-size: var(--fs-xs); font-weight: 800;
  animation: important-glow 2s ease-in-out infinite;
}
@keyframes important-glow {
  0%, 100% { box-shadow: 0 0 0 0 var(--glow-soft); }
  50% { box-shadow: 0 0 0 5px transparent, 0 0 14px 3px var(--glow-soft); }
}
@media (prefers-reduced-motion: reduce) { .rail a.nav .count.important { animation: none; } }

/* A section with pages under it opens and closes in place; the grid row animates the height. */
.rail .nav-group { display: flex; flex-direction: column; }
.rail .nav-lock { margin-left: auto; display: inline-flex; color: var(--ink-4); }
.rail .nav-lock svg { width: 13px; height: 13px; }
.rail .nav-parent .chev { margin-left: auto; display: inline-flex; transition: transform .25s ease; }
.rail .nav-parent .chev svg { width: 14px; height: 14px; }
.rail .nav-group.open .nav-parent .chev { transform: rotate(180deg); }
.rail .nav-sub-wrap { display: grid; grid-template-rows: 0fr; transition: grid-template-rows .28s var(--ease); }
.rail .nav-group.open .nav-sub-wrap { grid-template-rows: 1fr; }
.rail .nav-sub-wrap > .nav-sub { min-height: 0; overflow: hidden; opacity: 0; transition: opacity .2s ease, margin .28s var(--ease); }
.rail .nav-group.open .nav-sub-wrap > .nav-sub { opacity: 1; }
.rail .nav-sub {
  display: flex; flex-direction: column; gap: 1px;
  margin: 0 0 0 18px; padding-left: 10px; border-left: 1px solid var(--line);
}
.rail .nav-group.open .nav-sub { margin-block: 4px 6px; }
.rail .nav-sub a {
  display: flex; align-items: center; gap: 8px; padding: 5px 10px; border-radius: var(--r-s);
  color: var(--ink-3); font-size: var(--fs-s);
  transition: background .15s ease, color .15s ease;
}
.rail .nav-sub a svg { width: 14px; height: 14px; color: var(--ink-4); }
.rail .nav-sub a.on svg { color: var(--brand-text); }
.rail .nav-sub a:hover { background: var(--panel-3); color: var(--ink); }
.rail .nav-sub a.on { color: var(--brand-text); font-weight: 600; }

html.rail-collapsed .rail { padding: 0 10px 20px; }
/* Collapsed, every item is the same centred square, and a group label becomes a thin divider instead of empty space. */
html.rail-collapsed .rail a.nav { justify-content: center; width: 44px; height: 40px; margin-inline: auto; padding: 0; gap: 0; }
html.rail-collapsed .rail a.nav .lbl,
html.rail-collapsed .rail a.nav .count { max-width: 0; opacity: 0; transition: max-width .24s ease, opacity .1s ease; }
html.rail-collapsed .rail a.nav .count { margin: 0; padding: 0; }
html.rail-collapsed .rail .group { height: 1px; margin: 10px 12px; overflow: hidden; font-size: 0; background: var(--line); }
html.rail-collapsed .rail .nav-lock,
html.rail-collapsed .rail .nav-parent .chev,
html.rail-collapsed .rail .nav-sub-wrap { display: none; }

.nav-scrim { display: none; }

/* ---------- Page ---------- */
.main {
  grid-column: 2; grid-row: 2;
  min-width: 0; display: flex; flex-direction: column;
  background-color: var(--bg);
}

.crumbs { display: flex; gap: 6px; align-items: center; margin-bottom: 8px; font-size: var(--fs-xs); color: var(--ink-4); }
.crumbs a { color: var(--ink-3); }
.crumbs .sep { color: var(--ink-5); }

/* ---------- Grids ---------- */
.grid { display: grid; gap: 16px; }
.split-2-1 { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.stack { display: flex; flex-direction: column; gap: 16px; }

/* ---------- Footer ---------- */
.appfoot {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  margin-top: auto; padding: 12px 96px 12px 28px;
  border-top: 1px solid var(--canvas-line);
  font-size: var(--fs-xs); color: var(--ink-4);
}
.appfoot .links { display: flex; gap: 16px; margin-left: auto; flex-wrap: wrap; }
.appfoot a { color: var(--ink-3); }
.appfoot a:hover { color: var(--ink); }

@media (max-width: 1080px) {
  .split-2-1 { grid-template-columns: 1fr; }
}

@media (max-width: 860px) {
  .app-shell, html.rail-collapsed .app-shell { grid-template-columns: minmax(0, 1fr); }
  .topbar, .main { grid-column: 1; }
  .topbar { padding-left: 12px; gap: 10px; }
  .topbar-brand .brand { display: flex; }
  .top-sep { display: block; }

  .rail {
    position: fixed; top: var(--banner-h, 0px); bottom: 0; left: 0; z-index: 90;
    width: min(280px, 84vw); height: calc(100vh - var(--banner-h, 0px)); padding: 0 12px 24px;
    transform: translateX(-105%); transition: transform .2s ease; box-shadow: var(--sh-float);
    border-right: 0;
  }
  html.rail-collapsed .rail a.nav { justify-content: flex-start; width: auto; height: auto; min-height: 38px; margin-inline: 0; padding: 0 10px; gap: 11px; }
  html.rail-collapsed .rail a.nav .lbl,
  html.rail-collapsed .rail a.nav .count { max-width: 170px; opacity: 1; }
  html.rail-collapsed .rail a.nav .count { margin-left: auto; padding: 1px 7px; }
  html.rail-collapsed .rail .group { height: auto; margin: 16px 10px 6px; overflow: visible; font-size: var(--fs-2xs); background: none; }
  body.nav-open .rail { transform: none; }
  body.nav-open .nav-scrim { display: block; position: fixed; inset: 0; z-index: 80; background: var(--scrim); }

  .appfoot { padding: 12px 80px 12px 16px; }
}

@media (max-width: 480px) {
  .topbar { gap: 6px; padding-right: 10px; }
  .topbar-brand .brand, .top-sep { display: none; }
  .top-crumbs { flex: 1; min-width: 0; overflow: hidden; }
  .top-crumbs > a:not(.btn), .top-crumbs > .sep { display: none; }

  .topright { flex: none; gap: 2px; }
}

/* Back is always blue and top right, in the top bar of every detail page. */

.top-crumbs .pill { flex: none; }

.top-crumbs > .crumb-current { color: var(--ink); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

