/* ==========================================================================
   MKH - Application shell
   Visual language from the Claude Design project.
   Requires tokens.css, base.css and components.css.

   Sidebar states, all driven from <body>:
     (default)                  expanded rail, 252px
     data-sidebar="collapsed"   icon-only rail, 74px  (desktop choice, persisted)
     data-drawer="open"         off-canvas drawer     (below 900px only)
   ========================================================================== */

.app {
  --rail-w: 252px;
  display: grid;
  grid-template-columns: var(--rail-w) minmax(0, 1fr);
  min-height: 100vh;
  min-height: 100svh;
}

body[data-sidebar="collapsed"] .app { --rail-w: 74px; }

/* --------------------------------------------------------------------------
   Rail

   Dark in BOTH themes. It is the one constantly-branded surface in the app,
   so it keeps its own --rail-* tokens rather than following the theme.
   -------------------------------------------------------------------------- */

.sidebar {
  position: sticky;
  top: 0;
  z-index: var(--z-rail);
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100svh;
  overflow: hidden;
  background: var(--rail-bg);
  border-right: 1px solid var(--rail-line);
  color: var(--rail-txt-2);
  transition: transform var(--dur-slow) var(--ease);
}

/* ---- Head ---------------------------------------------------------------- */

.sidebar__head {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 64px;
  padding: 0 14px;
  flex: none;
  border-bottom: 1px solid var(--rail-line-soft);
}

.sidebar__brand { display: flex; align-items: center; gap: 11px; min-width: 0; flex: 1; }
.sidebar__brand:hover { text-decoration: none; }

.sidebar__mark {
  width: 34px;
  height: 34px;
  flex: none;
  border-radius: 9px;
  box-shadow: 0 4px 14px -6px rgba(0, 0, 0, 0.8);
}

.sidebar__wordmark { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.sidebar__name {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 0.07em;
  line-height: 1;
  color: var(--rail-txt);
}
.sidebar__name em { font-style: normal; color: var(--sky-300); }
.sidebar__sub {
  font-size: 8.5px;
  font-weight: var(--fw-bold);
  letter-spacing: 0.17em;
  text-transform: uppercase;
  color: var(--rail-txt-3);
  white-space: nowrap;
}

.sidebar__collapse {
  margin-left: auto;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  flex: none;
  border-radius: var(--r-xs);
  color: var(--rail-txt-3);
  transition: background-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.sidebar__collapse:hover { background: var(--rail-hover); color: var(--rail-txt); }
.sidebar__collapse svg { width: 16px; height: 16px; transition: transform var(--dur-base) var(--ease); }
body[data-sidebar="collapsed"] .sidebar__collapse svg { transform: rotate(180deg); }

/* ---- Nav ----------------------------------------------------------------- */

.sidebar__nav {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 12px 10px 16px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

/* With a mouse the scrollbar takes the place of the right padding, kept for
   it whether or not it is drawn. A long section opened would otherwise bring
   the bar in and take 10px off every label, which cut "Sales Order &
   Reservation" short. Overlay scrollbars (a finger) take no room, so there
   the padding stays. */
@media (pointer: fine) {
  .sidebar__nav { padding-right: 0; scrollbar-gutter: stable; }
}

.nav__section { display: flex; flex-direction: column; }

/* The dashboard, a section of one entry drawn as that entry, stands a little
   apart from the headings under it. */
.nav__section--single { margin-bottom: 6px; }

/* ---- Section headings: an accordion ---------------------------------------
   Each heading is a button that opens its section's items; one section is
   open at a time. The server opens the page's own section with every page
   (data-open, see NavRail.razor) and layout.js answers a click on a heading,
   so the first paint is already right and nothing waits on a script. */

.nav__heading {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  height: 38px;
  padding: 0 10px;
  border-radius: var(--r-sm);
  font-size: var(--fs-base);
  font-weight: var(--fw-semibold);
  color: var(--rail-txt-2);
  text-align: left;
  white-space: nowrap;
  transition: background-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.nav__heading:hover { background: var(--rail-hover); color: var(--rail-txt); }
.nav__heading svg { width: 18px; height: 18px; flex: none; }
.nav__heading .nav__chevron {
  width: 14px;
  height: 14px;
  color: var(--rail-txt-3);
  transition: transform var(--dur-base) var(--ease);
}

/* Open, and the page's own section even when folded, read in the brighter
   ink: where you are is never only in the item that may be out of sight. */
.nav__section[data-open] > .nav__heading,
.nav__section:has(.nav__item[aria-current="page"]) > .nav__heading { color: var(--rail-txt); }
.nav__section[data-open] > .nav__heading .nav__chevron { transform: rotate(90deg); }

/* Folded by its row shrinking to nothing, which animates where a height of
   auto cannot. Hidden as well once folded, so a folded link is neither
   tabbed to nor read out; visibility waits for the fold to finish going and
   arrives at once when it opens. */
.nav__group {
  display: grid;
  grid-template-rows: 0fr;
  visibility: hidden;
  transition: grid-template-rows var(--dur-base) var(--ease), visibility 0s linear var(--dur-base);
}
.nav__section[data-open] > .nav__group {
  grid-template-rows: 1fr;
  visibility: visible;
  transition: grid-template-rows var(--dur-base) var(--ease), visibility 0s linear 0s;
}

/* The items hang off a faint line under the heading's icon, so which heading
   they belong to is seen and not inferred. No vertical padding here: padding
   would survive the fold as a sliver, so the room is a margin on the links. */
.nav__group-inner {
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-left: 16px;
  border-left: 1px solid var(--rail-line);
}
/* The indent costs the label room, which the right padding gives back: the
   longest, "Sales Order & Reservation", fits whole at the rail's 252px. */
.nav__group-inner > .nav__item { padding-right: 6px; }
.nav__group-inner > .nav__item:first-of-type { margin-top: 2px; }
.nav__group-inner > .nav__item:last-child { margin-bottom: 6px; }

/* ---- Folders inside a section: the same accordion one level down ----------
   Transactions holds Sales and Purchase. A folder's heading is drawn as one
   of the section's rows with a chevron, and its items hang off a second faint
   line under its icon. One folder open at a time; the server opens the
   page's own (data-open) and layout.js answers a click, in the expanded rail,
   the drawer and the folded rail's flyout alike. */

.nav__folder { display: flex; flex-direction: column; }
.nav__flyout-title + .nav__folder { margin-top: 2px; }
.nav__group-inner > .nav__folder:last-child { margin-bottom: 6px; }

.nav__subheading {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  height: 38px;
  padding: 0 6px 0 10px;
  border-radius: var(--r-sm);
  font-size: var(--fs-base);
  font-weight: var(--fw-medium);
  color: var(--rail-txt-2);
  text-align: left;
  white-space: nowrap;
  transition: background-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.nav__subheading:hover { background: var(--rail-hover); color: var(--rail-txt); }
.nav__subheading svg { width: 18px; height: 18px; flex: none; }
.nav__subheading .nav__chevron {
  width: 14px;
  height: 14px;
  color: var(--rail-txt-3);
  transition: transform var(--dur-base) var(--ease);
}
.nav__folder[data-open] > .nav__subheading,
.nav__folder:has(.nav__item[aria-current="page"]) > .nav__subheading { color: var(--rail-txt); }
.nav__folder[data-open] > .nav__subheading .nav__chevron { transform: rotate(90deg); }

.nav__subgroup {
  display: grid;
  grid-template-rows: 0fr;
  visibility: hidden;
  transition: grid-template-rows var(--dur-base) var(--ease), visibility 0s linear var(--dur-base);
}
.nav__folder[data-open] > .nav__subgroup {
  grid-template-rows: 1fr;
  visibility: visible;
  transition: grid-template-rows var(--dur-base) var(--ease), visibility 0s linear 0s;
}
.nav__subgroup-inner {
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-left: 10px;
  border-left: 1px solid var(--rail-line);
}
/* The second indent costs the label room the first did not: tighter padding
   gives it back, so "Sales Order & Reservation" fits whole at the rail's
   252px, and a label that still does not fit (another font, a larger text
   setting) wraps onto a second line rather than being cut off. */
.nav__subgroup-inner > .nav__item {
  height: auto;
  min-height: 38px;
  padding: 4px 2px 4px 6px;
  gap: 8px;
}
.nav__subgroup-inner > .nav__item .nav__text { white-space: normal; line-height: 1.25; }
.nav__subgroup-inner > .nav__item:first-child { margin-top: 2px; }
.nav__subgroup-inner > .nav__item:last-child { margin-bottom: 4px; }

.nav__item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 11px;
  height: 38px;
  padding: 0 10px;
  border-radius: var(--r-sm);
  font-size: var(--fs-base);
  font-weight: var(--fw-medium);
  color: var(--rail-txt-2);
  white-space: nowrap;
  transition: background-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.nav__item:hover { background: var(--rail-hover); color: var(--rail-txt); text-decoration: none; }
.nav__item svg { width: 18px; height: 18px; }

/* The active item is a soft green wash plus a green edge marker, rather than
   a solid indigo pill - it sits better against the rail's own gradient. */
.nav__item[aria-current="page"] {
  background: var(--rail-active);
  color: var(--rail-txt);
  font-weight: var(--fw-semibold);
}
.nav__item[aria-current="page"]::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  width: 2px;
  height: 20px;
  margin-top: -10px;
  border-radius: 0 2px 2px 0;
  background: var(--green-400);
}

.nav__text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }

/* The app's focus ring is the indigo of the light pages, which barely shows
   on this dark rail. Drawn inside the box, because a folding group clips
   anything outside it. */
.sidebar :focus-visible { outline-color: var(--sky-300); outline-offset: -2px; }

/* Under a finger every row of the rail is 42px, like every other box. */
@media (pointer: coarse) {
  .nav__item, .nav__heading, .nav__subheading { height: 42px; }
  .nav__subgroup-inner > .nav__item { min-height: 42px; }
}

@media (prefers-reduced-motion: reduce) {
  .nav__group,
  .nav__section[data-open] > .nav__group,
  .nav__subgroup,
  .nav__folder[data-open] > .nav__subgroup { transition: none; }
}

.nav__count {
  flex: none;
  padding: 1px 7px;
  border-radius: var(--r-full);
  background: rgba(147, 152, 214, 0.16);
  font-family: var(--font-mono);
  font-size: var(--fs-2xs);
  font-weight: var(--fw-semibold);
}

/* ---- Foot ---------------------------------------------------------------- */

.sidebar__foot { flex: none; padding: 12px 14px 16px; border-top: 1px solid var(--rail-line-soft); }
.sidebar__org { display: flex; align-items: center; gap: 10px; }
.sidebar__org-text { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.sidebar__org-name {
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
  color: var(--rail-txt);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar__org-meta { font-size: 10.5px; color: var(--rail-txt-3); white-space: nowrap; }

/* ---- Collapsed rail ------------------------------------------------------ */

body[data-sidebar="collapsed"] .sidebar__wordmark,
body[data-sidebar="collapsed"] .nav__text,
body[data-sidebar="collapsed"] .nav__count,
body[data-sidebar="collapsed"] .sidebar__org-text { display: none; }

body[data-sidebar="collapsed"] .sidebar__head { justify-content: center; padding: 0 var(--sp-2); }
body[data-sidebar="collapsed"] .sidebar__brand { flex: none; }
body[data-sidebar="collapsed"] .nav__item { justify-content: center; padding-left: 0; padding-right: 0; }
body[data-sidebar="collapsed"] .sidebar__org { justify-content: center; }

/* With no room left in the rail, the control becomes a handle straddling the
   edge. Circular and raised so it reads as a grip, not a clipped button.

   Fixed rather than absolute, and placed from the left: the rail clips its own
   content, so an absolutely positioned handle is sliced down the middle by that
   clip - the one thing this is not supposed to look like. Half the handle sits
   past the rail, which the rail's z-index keeps above the topbar. */
body[data-sidebar="collapsed"] .sidebar__collapse {
  position: fixed;
  left: calc(var(--rail-w) - 14px);
  top: 17px;
  z-index: 1;
  border-radius: var(--r-full);
  background: var(--indigo-800);
  border: 1px solid var(--rail-line);
  box-shadow: var(--sh-md);
}
body[data-sidebar="collapsed"] .sidebar__collapse:hover { background: var(--indigo-700); }

/* ---- Folded rail: section icons, each with a flyout -----------------------
   Folded to its icons, the rail shows one icon per section rather than every
   item of every section: forty-odd unlabelled icons is a column to scroll and
   guess at. A click (or Enter or Space) on a section's icon opens its items
   beside the rail, labelled, and layout.js closes it again on a pick, a click
   elsewhere, Escape or focus moving away. The page's own section carries the
   green marker the current item does.

   The accordion's data-open means nothing here: it is the server's mark for
   the page's section, and the flyout is data-flyout, set only by a click.

   Fixed, like the collapse handle, because the rail clips what it holds and
   a flyout inside it would be cut off at its edge. layout.js puts its top
   level with the heading and keeps it on the screen.

   Written twice, as the folded rail itself is: chosen, and the default under
   1200px. Never in the drawer, which is always the full rail. */

@keyframes nav-flyout-in { from { opacity: 0; transform: translateX(-6px); } to { opacity: 1; transform: none; } }

/* Only the flyout has a title of its own; the expanded rail has the heading. */
.nav__flyout-title {
  display: none;
  padding: 6px 10px 6px;
  font-size: 9.5px;
  font-weight: var(--fw-bold);
  letter-spacing: 0.17em;
  text-transform: uppercase;
  color: var(--rail-txt-3);
  white-space: nowrap;
}

@media (width > 900px) {
  body[data-sidebar="collapsed"] .nav__heading { position: relative; justify-content: center; padding: 0; }
  body[data-sidebar="collapsed"] .nav__heading .nav__chevron { display: none; }
  body[data-sidebar="collapsed"] .nav__group { display: none; }
  body[data-sidebar="collapsed"] .nav__section:has(.nav__item[aria-current="page"]) > .nav__heading { background: var(--rail-active); }
  body[data-sidebar="collapsed"] .nav__section:has(.nav__item[aria-current="page"]) > .nav__heading::before {
    content: "";
    position: absolute;
    left: 0;
    top: 50%;
    width: 2px;
    height: 20px;
    margin-top: -10px;
    border-radius: 0 2px 2px 0;
    background: var(--green-400);
  }
  body[data-sidebar="collapsed"] .nav__section[data-flyout] > .nav__heading { background: var(--rail-hover); color: var(--rail-txt); }
  body[data-sidebar="collapsed"] .nav__section[data-flyout] > .nav__group {
    display: block;
    visibility: visible;
    position: fixed;
    left: calc(var(--rail-w) + 8px);
    top: var(--flyout-top, 72px);
    width: 240px;
    max-height: calc(100vh - 16px);
    max-height: calc(100svh - 16px);
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 6px;
    background: var(--rail-bg);
    border: 1px solid var(--rail-line);
    border-radius: var(--r-md);
    box-shadow: var(--sh-lg);
    animation: nav-flyout-in var(--dur-fast) var(--ease-out);
  }
  body[data-sidebar="collapsed"] .nav__section[data-flyout] .nav__group-inner { margin-left: 0; border-left: 0; overflow: visible; }
  body[data-sidebar="collapsed"] .nav__section[data-flyout] .nav__group-inner > .nav__item { margin: 0; }
  body[data-sidebar="collapsed"] .nav__section[data-flyout] .nav__flyout-title { display: block; }
  body[data-sidebar="collapsed"] .nav__section[data-flyout] .nav__item { justify-content: flex-start; padding: 0 10px; }
  body[data-sidebar="collapsed"] .nav__section[data-flyout] .nav__group .nav__text { display: block; }
}

@media (width > 900px) and (max-width: 1200px) {
  body:not([data-sidebar="expanded"]) .nav__heading { position: relative; justify-content: center; padding: 0; }
  body:not([data-sidebar="expanded"]) .nav__heading .nav__chevron { display: none; }
  body:not([data-sidebar="expanded"]) .nav__group { display: none; }
  body:not([data-sidebar="expanded"]) .nav__section:has(.nav__item[aria-current="page"]) > .nav__heading { background: var(--rail-active); }
  body:not([data-sidebar="expanded"]) .nav__section:has(.nav__item[aria-current="page"]) > .nav__heading::before {
    content: "";
    position: absolute;
    left: 0;
    top: 50%;
    width: 2px;
    height: 20px;
    margin-top: -10px;
    border-radius: 0 2px 2px 0;
    background: var(--green-400);
  }
  body:not([data-sidebar="expanded"]) .nav__section[data-flyout] > .nav__heading { background: var(--rail-hover); color: var(--rail-txt); }
  body:not([data-sidebar="expanded"]) .nav__section[data-flyout] > .nav__group {
    display: block;
    visibility: visible;
    position: fixed;
    left: calc(var(--rail-w) + 8px);
    top: var(--flyout-top, 72px);
    width: 240px;
    max-height: calc(100vh - 16px);
    max-height: calc(100svh - 16px);
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 6px;
    background: var(--rail-bg);
    border: 1px solid var(--rail-line);
    border-radius: var(--r-md);
    box-shadow: var(--sh-lg);
    animation: nav-flyout-in var(--dur-fast) var(--ease-out);
  }
  body:not([data-sidebar="expanded"]) .nav__section[data-flyout] .nav__group-inner { margin-left: 0; border-left: 0; overflow: visible; }
  body:not([data-sidebar="expanded"]) .nav__section[data-flyout] .nav__group-inner > .nav__item { margin: 0; }
  body:not([data-sidebar="expanded"]) .nav__section[data-flyout] .nav__flyout-title { display: block; }
  body:not([data-sidebar="expanded"]) .nav__section[data-flyout] .nav__item { justify-content: flex-start; padding: 0 10px; }
  body:not([data-sidebar="expanded"]) .nav__section[data-flyout] .nav__group .nav__text { display: block; }
}

/* --------------------------------------------------------------------------
   Main column
   -------------------------------------------------------------------------- */

.app__main { min-width: 0; display: flex; flex-direction: column; }

/* ---- Topbar -------------------------------------------------------------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: var(--z-topbar);
  display: flex;
  align-items: center;
  gap: 10px;
  height: 64px;
  flex: none;
  padding: 0 clamp(14px, 2.5vw, 26px);
  /* Frosted rather than opaque, so content scrolling under it stays hinted. */
  background: var(--surface-glass);
  backdrop-filter: blur(14px) saturate(1.4);
  -webkit-backdrop-filter: blur(14px) saturate(1.4);
  border-bottom: 1px solid var(--line);
}

.topbar__menu { display: none; }

.topbar__search { position: relative; display: flex; align-items: center; flex: 1; max-width: 420px; }
.topbar__search .field__icon { left: 11px; }
.topbar__search .input {
  height: 38px;
  padding-left: 36px;
  padding-right: 38px;
  font-size: var(--fs-md);
  border-radius: var(--r-full);
}

.topbar__kbd {
  position: absolute;
  right: 10px;
  display: grid;
  place-items: center;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--surface-3);
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--txt-3);
  pointer-events: none;
}

.topbar__actions { margin-left: auto; display: flex; align-items: center; gap: var(--sp-2); }

/* The topbar's New button is .btn--sm, which the shared touch rule holds at
   38px; under a finger it is 42px like every other box. The bar is 64px and
   centres its items, so nothing beside it moves. */
@media (pointer: coarse) {
  .topbar__actions > .btn--sm { height: 42px; }
}
.topbar__sep { width: 1px; height: 22px; background: var(--line); }

.usermenu { position: relative; }
.usermenu__trigger {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  height: 34px;
  padding: 0 8px 0 4px;
  border: 1px solid var(--line);
  border-radius: var(--r-full);
  background: var(--surface-2);
  color: var(--txt-2);
  transition: border-color var(--dur-fast) var(--ease);
}
.usermenu__trigger:hover { border-color: var(--line-strong); }

/* Under a finger the trigger is 42px like every other box; the avatar inside
   keeps its size and stays centred. */
@media (pointer: coarse) {
  .usermenu__trigger { height: 42px; padding: 0 10px 0 7px; }
}
.usermenu__trigger .avatar { width: 26px; height: 26px; border-radius: var(--r-full); font-size: 10.5px; }
.usermenu__name { font-size: var(--fs-md); font-weight: var(--fw-semibold); white-space: nowrap; }
.usermenu__trigger svg { width: 14px; height: 14px; color: var(--txt-3); }

/* ---- Content ------------------------------------------------------------- */

.content {
  flex: 1;
  min-width: 0;
  padding: clamp(18px, 2.6vw, 30px) clamp(14px, 2.5vw, 30px) 64px;

  /* Page grids size themselves against this box, not the viewport - the rail
     is 178px wide when expanded, more than enough to change how many columns
     actually fit. */
  container-type: inline-size;
  container-name: content;
}

/* A measure cap: on a very wide monitor a full-bleed table is unreadable. */
.content__inner {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: clamp(16px, 2vw, 22px);
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  flex-wrap: wrap;
}
.page-head__text { min-width: 0; display: flex; flex-direction: column; gap: 7px; }
.page-head__title {
  font-family: var(--font-display);
  font-size: clamp(24px, 2.7vw, 32px);
  font-weight: var(--fw-bold);
  letter-spacing: -0.025em;
  line-height: 1.1;
}
.page-head__sub { font-size: var(--fs-base); color: var(--txt-2); max-width: 74ch; }
.page-head__actions { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }

/* Under a finger the heading's buttons (Add, Export, Import, Print, Back) are
   42px like every other box. They are .btn--sm, which the shared touch rule
   holds at 38px for the small buttons inside cards and rows, so they are named
   here. Only the direct children: the import panel rendered inside this row
   keeps its own sizes. With a mouse they stay 32px. */
@media (pointer: coarse) {
  .page-head__actions > .btn--sm { height: 42px; }
}

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: var(--fs-sm);
  color: var(--txt-3);
}
.breadcrumb a { color: var(--txt-3); font-weight: var(--fw-medium); }
.breadcrumb a:hover { color: var(--primary); text-decoration: none; }
.breadcrumb svg { width: 12px; height: 12px; color: var(--line-strong); }

/* --------------------------------------------------------------------------
   Drawer scrim - only rendered below 900px
   -------------------------------------------------------------------------- */

.scrim {
  display: none;
  position: fixed;
  inset: 0;
  z-index: var(--z-scrim);
  background: rgba(9, 10, 26, 0.55);
  backdrop-filter: blur(2px);
  animation: mkh-fade 0.2s var(--ease);
}

/* --------------------------------------------------------------------------
   Responsive
   -------------------------------------------------------------------------- */

/* Narrow desktops start from the collapsed rail unless the user chose otherwise. */
@media (max-width: 1200px) {
  body:not([data-sidebar="expanded"]) .app { --rail-w: 74px; }
  body:not([data-sidebar="expanded"]) .sidebar__wordmark,
  body:not([data-sidebar="expanded"]) .nav__text,
  body:not([data-sidebar="expanded"]) .nav__count,
  body:not([data-sidebar="expanded"]) .sidebar__org-text { display: none; }
  body:not([data-sidebar="expanded"]) .sidebar__head { justify-content: center; padding: 0 var(--sp-2); }
  body:not([data-sidebar="expanded"]) .nav__item { justify-content: center; padding-left: 0; padding-right: 0; }
  body:not([data-sidebar="expanded"]) .sidebar__org { justify-content: center; }

  /* The same handle, for the same reason. See the collapsed rule above. */
  body:not([data-sidebar="expanded"]) .sidebar__collapse {
    position: fixed;
    left: calc(var(--rail-w) - 14px);
    top: 17px;
    z-index: 1;
    border-radius: var(--r-full);
    background: var(--indigo-800);
    border: 1px solid var(--rail-line);
    box-shadow: var(--sh-md);
  }
  body:not([data-sidebar="expanded"]) .sidebar__collapse:hover { background: var(--indigo-700); }
}

/* Tablet and phone - the rail leaves the flow and becomes a drawer. */
@media (max-width: 900px) {
  .app { grid-template-columns: minmax(0, 1fr); }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 272px;
    transform: translateX(-100%);
    box-shadow: var(--sh-lg);
  }
  body[data-drawer="open"] .sidebar { transform: translateX(0); }
  body[data-drawer="open"] .scrim { display: block; }
  body[data-drawer="open"] { overflow: hidden; }

  /* The drawer is always the full rail, whatever the desktop collapse state. */
  .sidebar__wordmark, .nav__text, .nav__count, .sidebar__org-text { display: flex !important; }
  .sidebar__head { justify-content: flex-start !important; padding: 0 14px !important; }
  .nav__item { justify-content: flex-start !important; padding-left: 10px !important; padding-right: 10px !important; }
  .sidebar__org { justify-content: flex-start !important; }
  .sidebar__collapse { display: none; }

  .topbar__menu { display: grid; }
  .topbar__search { max-width: none; }
  .usermenu__name { display: none; }
}

@media (max-width: 620px) {
  .topbar { gap: var(--sp-2); padding: 0 14px; }
  .topbar__kbd { display: none; }
  .topbar__sep { display: none; }
}

/* Below this the search field crowds everything else out - move it to its own
   row under the topbar rather than shrinking it into uselessness. */
@media (max-width: 480px) {
  .topbar { flex-wrap: wrap; height: auto; padding-top: 10px; padding-bottom: 10px; }
  .topbar__search { order: 3; flex: 1 0 100%; }
  .topbar__actions { margin-left: auto; }
}

/* A section whose every item is hidden by the signed-in role would otherwise
   leave its heading floating over nothing. */
.nav__section:not(:has(.nav__item)) { display: none; }

/* The server already leaves such a section or folder out (NavRail.Blocks);
   this is the stylesheet's own word on it should anything ever slip by. */
.nav__folder:not(:has(.nav__item)) { display: none; }

/* ---- Navigation progress --------------------------------------------------
   The thin bar layout.js shows when a page has not arrived 300 ms after a
   click (see "Navigation progress and recovery" there). A dark bar on a pale
   track in the light theme and a light one on a dark track in the dark theme,
   so it reads by lightness alone and survives a greyscale screen. Above the
   drawer and its scrim, and never in the way of a click. */
.nav-progress {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  z-index: calc(var(--z-drawer) + 10);
  overflow: hidden;
  pointer-events: none;
  background: var(--line-strong);
  opacity: 0;
  transition: opacity var(--dur-base) var(--ease);
}

.nav-progress[data-on] { opacity: 1; }

.nav-progress__bar {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 40%;
  background: var(--txt);
  animation: nav-progress-slide 1.1s var(--ease) infinite;
}

@keyframes nav-progress-slide {
  from { transform: translateX(-100%); }
  to { transform: translateX(250%); }
}

/* No movement for those who asked for none: a still, full-width bar says
   "loading" just as well. */
@media (prefers-reduced-motion: reduce) {
  .nav-progress { transition: none; }
  .nav-progress__bar { animation: none; width: 100%; }
}

@media print {
  .nav-progress { display: none; }
}
