/* ==========================================================================
   MMBC Attendance - Application shell and page layout
   --------------------------------------------------------------------------
   Desktop  : persistent sidebar + top bar + content region
   Tablet   : sidebar collapses to icons, content adapts
   Phone    : sidebar becomes an off-canvas panel
   ========================================================================== */

/* ==========================================================================
   Shell
   ========================================================================== */

.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  min-height: 100vh;
  transition: grid-template-columns var(--duration-base) var(--ease-out);
}

.app-shell[data-sidebar="compact"] {
  grid-template-columns: var(--sidebar-width-compact) 1fr;
}

/* ==========================================================================
   Sidebar
   ========================================================================== */

.app-sidebar {
  position: sticky;
  top: 0;
  z-index: var(--z-sidebar);
  display: flex;
  flex-direction: column;
  height: 100vh;
  color: var(--mmbc-100);
  background: var(--mmbc-900);
  border-right: 1px solid var(--mmbc-950);
  overflow: hidden;
}

.app-sidebar__brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  height: var(--topbar-height);
  padding: 0 var(--space-4);
  flex: none;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.app-sidebar__logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  font-size: var(--text-sm);
  font-weight: var(--weight-bold);
  letter-spacing: 0.02em;
  color: var(--mmbc-900);
  background: var(--gray-0);
  border-radius: var(--radius-md);
  flex: none;
}

/*
  The uploaded version of the mark. `object-fit: contain` rather than `cover`,
  because a logo cropped to fit is a logo somebody will complain about; a
  wide one is letterboxed into the square instead. The radius matches the
  lettermark it replaced so the two are interchangeable.
*/
.app-sidebar__logo-img {
  width: 2rem;
  height: 2rem;
  object-fit: contain;
  border-radius: var(--radius-md);
  flex: none;
}

.app-sidebar__wordmark {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.15;
}

.app-sidebar__name {
  font-size: var(--text-base);
  font-weight: var(--weight-semibold);
  color: var(--gray-0);
  white-space: nowrap;
}

.app-sidebar__tagline {
  font-size: var(--text-2xs);
  text-transform: uppercase;
  letter-spacing: var(--tracking-caps);
  color: var(--mmbc-300);
  white-space: nowrap;
}

.app-sidebar__nav {
  flex: 1;
  padding: var(--space-3) var(--space-2);
  overflow-y: auto;
  overflow-x: hidden;
  /* This element owns the sidebar's scrolling, so this is where the chaining
   * has to be stopped. Reaching the end of the menu used to hand the wheel to
   * the document, and the page slid away underneath a pointer that had never
   * left the navigation. `contain` keeps the scroll here and leaves the rest
   * of the page scrolling normally - no wheel handler, no capture, nothing to
   * go stale. */
  overscroll-behavior: contain;
}

.app-sidebar__section + .app-sidebar__section { margin-top: var(--space-4); }

.app-sidebar__section-label {
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-2xs);
  font-weight: var(--weight-semibold);
  text-transform: uppercase;
  letter-spacing: var(--tracking-caps);
  color: var(--mmbc-400);
  white-space: nowrap;
}

.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  padding: var(--space-2) var(--space-3);
  margin-bottom: 2px;
  font-size: var(--text-md);
  font-weight: var(--weight-medium);
  color: var(--mmbc-200);
  border-radius: var(--radius-md);
  white-space: nowrap;
  transition:
    background-color var(--duration-fast) var(--ease-out),
    color var(--duration-fast) var(--ease-out);
}

.nav-item:hover {
  color: var(--gray-0);
  background: rgba(255, 255, 255, 0.07);
  text-decoration: none;
}

.nav-item.is-active {
  color: var(--gray-0);
  background: var(--mmbc-600);
}

/* Active marker: a shape as well as a colour, so the state survives a
   greyscale rendering or a colour-vision difference. */
.nav-item.is-active::before {
  content: "";
  position: absolute;
  left: -0.5rem;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 1.25rem;
  background: var(--gray-0);
  border-radius: 0 var(--radius-full) var(--radius-full) 0;
}

/* The section you are in, when you are not on one of its destinations - a
   day detail, say, which is reachable from all three and belongs to none.
   Deliberately quieter than .is-active: it says "you are in here", not
   "this is the page", and the two must not look alike. */
.nav-group__trigger.is-section {
  color: var(--gray-0);
  background: rgba(255, 255, 255, 0.07);
}

.nav-item .icon { flex: none; }

.nav-item__label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-item--deferred {
  color: var(--mmbc-400);
  cursor: not-allowed;
}
.nav-item--deferred:hover { background: transparent; color: var(--mmbc-400); }

.nav-item__soon {
  padding: 0.05rem 0.35rem;
  font-size: var(--text-2xs);
  font-weight: var(--weight-semibold);
  text-transform: uppercase;
  letter-spacing: var(--tracking-caps);
  color: var(--mmbc-300);
  background: rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-full);
}

/* --- Submenu --- */

.nav-group__trigger { cursor: pointer; }

.nav-group__chevron {
  margin-left: auto;
  color: var(--mmbc-400);
  transition: transform var(--duration-base) var(--ease-out);
}

.nav-group__trigger[aria-expanded="true"] .nav-group__chevron { transform: rotate(180deg); }

.nav-group__items {
  overflow: hidden;
  padding-left: var(--space-4);
  transition: height var(--duration-base) var(--ease-out);
}

.nav-group__items[hidden] { display: none; }

/* First paint for a group the user had open.
 *
 * `sidebar.js` restores this from storage, but it is a module and so runs after
 * the browser has painted - the group would open a frame late, which reads as a
 * collapse and a reopen. `boot-shell.js` puts the keys on the root before
 * anything is on the screen and these rules honour them.
 *
 * One rule per key because CSS cannot compare two attribute values, and a
 * static stylesheet rather than one built in JavaScript because `style-src`
 * is `'self'` with no 'unsafe-inline' - an injected <style> is blocked outright.
 * `test_shell_chrome.py` asserts every group the navigation defines has a rule
 * here, so a group added later cannot quietly lose its first paint. */
html[data-nav-open~="attendance"] #nav-group-attendance[hidden],
html[data-nav-open~="administration"] #nav-group-administration[hidden] {
  display: block;
}

html[data-nav-open~="attendance"] [data-nav-group="attendance"] .nav-group__chevron,
html[data-nav-open~="administration"] [data-nav-group="administration"] .nav-group__chevron {
  transform: rotate(180deg);
}

.nav-group__items .nav-item {
  font-size: var(--text-sm);
  font-weight: var(--weight-normal);
}

/* --- Sidebar footer --- */

.app-sidebar__footer {
  flex: none;
  padding: var(--space-3) var(--space-2);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-toggle {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-sm);
  color: var(--mmbc-300);
  border-radius: var(--radius-md);
  white-space: nowrap;
}

.sidebar-toggle:hover { color: var(--gray-0); background: rgba(255, 255, 255, 0.07); }

.sidebar-toggle .icon { transition: transform var(--duration-base) var(--ease-out); }

/* --- Compact (icon-only) mode ---
   Labels are hidden but remain in the accessibility tree via aria-label on the
   link, and reappear as a hover tooltip. */

/* The same mode, read from the root element, for the moment before `app.js`
 * has run. `boot-sidebar.js` sets it in <head> so the very first paint is
 * already correct; without this the shell painted expanded and then animated
 * shut. Only the declarations that decide what that first paint looks like
 * are mirrored - tooltips and hover states can wait for hydration.
 *
 * Scoped above the phone breakpoint on purpose: below it the sidebar is an
 * off-canvas panel and the grid is a single column, which this must not
 * override. */
@media (min-width: 48rem) {
  html[data-sidebar="compact"] .app-shell {
    grid-template-columns: var(--sidebar-width-compact) 1fr;
  }

  html[data-sidebar="compact"] .app-sidebar__wordmark,
  html[data-sidebar="compact"] .app-sidebar__section-label,
  html[data-sidebar="compact"] .nav-item__label,
  html[data-sidebar="compact"] .nav-item__soon,
  html[data-sidebar="compact"] .nav-group__chevron,
  html[data-sidebar="compact"] .sidebar-toggle__label {
    display: none;
  }

  html[data-sidebar="compact"] .app-sidebar__brand,
  html[data-sidebar="compact"] .nav-item,
  html[data-sidebar="compact"] .sidebar-toggle {
    justify-content: center;
    padding-left: var(--space-2);
    padding-right: var(--space-2);
  }
}

.app-shell[data-sidebar="compact"] .app-sidebar__wordmark,
.app-shell[data-sidebar="compact"] .app-sidebar__section-label,
.app-shell[data-sidebar="compact"] .nav-item__label,
.app-shell[data-sidebar="compact"] .nav-item__soon,
.app-shell[data-sidebar="compact"] .nav-group__chevron,
.app-shell[data-sidebar="compact"] .sidebar-toggle__label {
  display: none;
}

.app-shell[data-sidebar="compact"] .app-sidebar__brand,
.app-shell[data-sidebar="compact"] .nav-item,
.app-shell[data-sidebar="compact"] .sidebar-toggle {
  justify-content: center;
  padding-left: var(--space-2);
  padding-right: var(--space-2);
}

.app-shell[data-sidebar="compact"] .nav-group__items { padding-left: 0; }

.app-shell[data-sidebar="compact"] .sidebar-toggle .icon { transform: rotate(180deg); }

/* Tooltip for compact mode. Pure CSS, no JS, no layout cost when unused. */
.app-shell[data-sidebar="compact"] .nav-item[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  left: calc(100% + 0.5rem);
  top: 50%;
  transform: translateY(-50%);
  z-index: var(--z-topbar);
  padding: 0.25rem 0.5rem;
  font-size: var(--text-xs);
  font-weight: var(--weight-normal);
  color: var(--gray-0);
  background: var(--gray-900);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--duration-fast) var(--ease-out);
}

.app-shell[data-sidebar="compact"] .nav-item:hover::after,
.app-shell[data-sidebar="compact"] .nav-item:focus-visible::after { opacity: 1; }

/* ==========================================================================
   Top bar
   ========================================================================== */

.app-topbar {
  position: sticky;
  top: 0;
  z-index: var(--z-topbar);
  display: flex;
  align-items: center;
  gap: var(--space-4);
  height: var(--topbar-height);
  padding: 0 var(--space-5);
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: saturate(1.6) blur(8px);
  border-bottom: 1px solid var(--border-subtle);
}

.app-topbar__mobile-toggle { display: none; }

.app-topbar__context { min-width: 0; flex: 1; }

.app-topbar__title {
  font-size: var(--text-base);
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-tight);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.app-topbar__breadcrumb {
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.app-topbar__actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex: none;
}

/* --- Command palette trigger --- */

.palette-trigger {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-width: 14rem;
  padding: 0.4rem 0.625rem;
  font-size: var(--text-sm);
  color: var(--text-muted);
  background: var(--gray-50);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  transition:
    border-color var(--duration-fast) var(--ease-out),
    background-color var(--duration-fast) var(--ease-out);
}

.palette-trigger:hover {
  background: var(--surface-card);
  border-color: var(--border-default);
}

.palette-trigger__label { flex: 1; text-align: left; }

/* --- MMBC Companion status (Companion identity C3) ---
   A status and a link, not a module. Its colour follows its state and is
   never the only signal: the words always say it too. */

.companion-status {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: 0.4rem 0.625rem;
  font-size: var(--text-sm);
  color: var(--text-muted);
  white-space: nowrap;
  text-decoration: none;
  background: var(--gray-50);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  transition:
    border-color var(--duration-fast) var(--ease-out),
    background-color var(--duration-fast) var(--ease-out);
}

.companion-status:hover {
  background: var(--surface-card);
  border-color: var(--border-default);
}

.companion-status[data-state="connected"] { color: var(--success-700); }
.companion-status[data-state="reserved"],
.companion-status[data-state="pending"] { color: var(--warning-700); }
.companion-status[data-state="unavailable"] { color: var(--danger-700); }

/* --- Notification placeholder ---
   A real indicator arrives with the modules that generate notifications. */

.action-indicator { position: relative; }

.action-indicator__dot {
  position: absolute;
  top: 0.3rem;
  right: 0.3rem;
  width: 0.45rem;
  height: 0.45rem;
  background: var(--danger-600);
  border: 2px solid var(--surface-card);
  border-radius: var(--radius-full);
}

/* --- User menu --- */

.user-menu { position: relative; }

.user-menu__trigger {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 0.25rem 0.5rem 0.25rem 0.25rem;
  border: 1px solid transparent;
  border-radius: var(--radius-full);
  transition: background-color var(--duration-fast) var(--ease-out);
}

.user-menu__trigger:hover { background: var(--surface-hover); }
.user-menu__trigger[aria-expanded="true"] {
  background: var(--surface-hover);
  border-color: var(--border-subtle);
}

.user-menu__name {
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  max-width: 12rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-menu__panel {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: var(--z-sticky);
  width: 15rem;
  padding: var(--space-2);
  background: var(--surface-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  animation: popover-in var(--duration-fast) var(--ease-out);
}

.user-menu__panel[hidden] { display: none; }

.user-menu__header {
  padding: var(--space-2) var(--space-3) var(--space-3);
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: var(--space-2);
}

.user-menu__item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-md);
  color: var(--text-primary);
  text-align: left;
  border-radius: var(--radius-sm);
}

.user-menu__item:hover { background: var(--surface-hover); text-decoration: none; }
.user-menu__item .icon { color: var(--text-muted); }
.user-menu__item--danger { color: var(--danger-600); }
.user-menu__item--danger .icon { color: var(--danger-600); }

/* ==========================================================================
   Impersonation banner
   ========================================================================== */

.impersonation-banner {
  position: sticky;
  top: 0;
  z-index: calc(var(--z-topbar) + 1);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-5);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--gray-0);
  background: var(--warning-700);
  /* Diagonal hazard stripes: unmistakable, and legible without colour. */
  background-image: repeating-linear-gradient(
    45deg,
    rgba(255, 255, 255, 0.08) 0 10px,
    transparent 10px 20px
  );
}

.impersonation-banner .icon { flex: none; }
.impersonation-banner__text { flex: 1; min-width: 0; }
.impersonation-banner__mode {
  padding: 0.05rem 0.4rem;
  font-size: var(--text-2xs);
  text-transform: uppercase;
  letter-spacing: var(--tracking-caps);
  background: rgba(0, 0, 0, 0.25);
  border-radius: var(--radius-full);
}

.impersonation-banner .btn {
  color: var(--warning-700);
  background: var(--gray-0);
}
.impersonation-banner .btn:hover { background: var(--warning-50); }

/* ==========================================================================
   Content region
   ========================================================================== */

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

.app-main {
  flex: 1;
  width: 100%;
  max-width: var(--content-max-width);
  margin: 0 auto;
  padding: var(--space-6) var(--space-5) var(--space-12);
}

.page-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-6);
}

.page-header__heading { min-width: 0; }

.page-header__title {
  font-size: var(--text-2xl);
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-tight);
}

.page-header__description {
  margin-top: var(--space-1);
  font-size: var(--text-md);
  color: var(--text-secondary);
  max-width: 70ch;
}

.page-header__actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.section + .section { margin-top: var(--space-8); }

.section__title {
  margin-bottom: var(--space-3);
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
}

/* ==========================================================================
   Authentication layout
   ========================================================================== */

.auth-layout {
  display: grid;
  grid-template-columns: 1fr;
  min-height: 100vh;
  background: var(--surface-page);
}

.auth-layout__aside {
  display: none;
  position: relative;
  flex-direction: column;
  justify-content: space-between;
  padding: var(--space-12);
  color: var(--mmbc-100);
  background:
    radial-gradient(circle at 15% 15%, var(--mmbc-700), transparent 55%),
    radial-gradient(circle at 85% 80%, var(--mmbc-600), transparent 50%),
    var(--mmbc-900);
  overflow: hidden;
}

.auth-layout__aside::after {
  /* Subtle geometric texture, drawn in CSS - no image asset required. */
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.04) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(circle at 50% 40%, #000 20%, transparent 75%);
  pointer-events: none;
}

.auth-layout__aside > * { position: relative; z-index: 1; }

.auth-layout__headline {
  font-size: var(--text-3xl);
  font-weight: var(--weight-semibold);
  line-height: var(--leading-tight);
  letter-spacing: var(--tracking-tight);
  color: var(--gray-0);
  max-width: 18ch;
}

.auth-layout__lede {
  margin-top: var(--space-4);
  font-size: var(--text-base);
  color: var(--mmbc-200);
  max-width: 44ch;
}

.auth-layout__points {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  margin-top: var(--space-8);
}

.auth-layout__point {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  font-size: var(--text-md);
  color: var(--mmbc-200);
}

.auth-layout__point .icon { color: var(--mmbc-300); }

.auth-layout__main {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-6) var(--space-4);
}

.auth-card {
  width: min(26rem, 100%);
}

.auth-card__brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-6);
}

.auth-card__logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  font-size: var(--text-md);
  font-weight: var(--weight-bold);
  color: var(--gray-0);
  background: var(--mmbc-600);
  border-radius: var(--radius-md);
}

.auth-card__logo-img {
  width: 2.75rem;
  height: 2.75rem;
  object-fit: contain;
  border-radius: var(--radius-md);
  flex: none;
}

.auth-card__title {
  font-size: var(--text-2xl);
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-tight);
}

.auth-card__subtitle {
  margin-top: var(--space-1);
  font-size: var(--text-md);
  color: var(--text-secondary);
}

.auth-card__panel {
  margin-top: var(--space-6);
  padding: var(--space-6);
  background: var(--surface-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.auth-card__footer {
  margin-top: var(--space-5);
  font-size: var(--text-sm);
  color: var(--text-muted);
  text-align: center;
}

/* ==========================================================================
   Error pages
   ========================================================================== */

.error-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-4);
  min-height: 60vh;
  padding: var(--space-8) var(--space-4);
  text-align: center;
}

.error-page--standalone { min-height: 100vh; }

.error-page__code {
  font-size: var(--text-3xl);
  font-weight: var(--weight-bold);
  letter-spacing: var(--tracking-caps);
  color: var(--mmbc-600);
}

.error-page__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 4rem;
  height: 4rem;
  color: var(--mmbc-700);
  background: var(--mmbc-50);
  border-radius: var(--radius-full);
}

.error-page__title { font-size: var(--text-2xl); }
.error-page__message { max-width: 48ch; color: var(--text-secondary); }

.error-page__correlation {
  padding: var(--space-2) var(--space-3);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--text-muted);
  background: var(--surface-sunken);
  border-radius: var(--radius-md);
  user-select: all;
}

/* ==========================================================================
   Responsive
   ========================================================================== */

/* --- Large desktop: reveal the marketing aside on auth screens --- */
@media (min-width: 62rem) {
  .auth-layout { grid-template-columns: 1.1fr 1fr; }
  .auth-layout__aside { display: flex; }
}

/* --- Tablet: sidebar defaults to icon-only --- */
@media (max-width: 74rem) and (min-width: 48rem) {
  .app-shell { grid-template-columns: var(--sidebar-width-compact) 1fr; }
  .app-shell[data-sidebar="expanded"] { grid-template-columns: var(--sidebar-width) 1fr; }
}

/* --- Phone: sidebar becomes an off-canvas panel --- */
@media (max-width: 47.99rem) {
  .app-shell,
  .app-shell[data-sidebar="compact"] { grid-template-columns: 1fr; }

  .app-sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    width: min(var(--sidebar-width), 82vw);
    transform: translateX(-100%);
    transition: transform var(--duration-slow) var(--ease-out);
    box-shadow: var(--shadow-xl);
  }

  .app-shell.is-nav-open .app-sidebar { transform: translateX(0); }

  /* Compact mode is meaningless on a phone: always show labels here. */
  .app-shell[data-sidebar="compact"] .app-sidebar__wordmark,
  .app-shell[data-sidebar="compact"] .app-sidebar__section-label,
  .app-shell[data-sidebar="compact"] .nav-item__label,
  .app-shell[data-sidebar="compact"] .nav-item__soon,
  .app-shell[data-sidebar="compact"] .nav-group__chevron,
  .app-shell[data-sidebar="compact"] .sidebar-toggle__label { display: revert; }

  .app-shell[data-sidebar="compact"] .app-sidebar__brand,
  .app-shell[data-sidebar="compact"] .nav-item,
  .app-shell[data-sidebar="compact"] .sidebar-toggle { justify-content: flex-start; }

  .app-sidebar__footer { display: none; }

  .nav-scrim {
    position: fixed;
    inset: 0;
    z-index: calc(var(--z-sidebar) - 1);
    background: rgba(25, 25, 48, 0.45);
    animation: fade-in var(--duration-fast) var(--ease-out);
  }
  .nav-scrim[hidden] { display: none; }

  .app-topbar { padding: 0 var(--space-4); }
  .app-topbar__mobile-toggle { display: inline-flex; }

  .palette-trigger { min-width: auto; }
  .palette-trigger__label,
  .palette-trigger kbd { display: none; }

  .companion-status__label { display: none; }

  .user-menu__name { display: none; }

  .app-main { padding: var(--space-5) var(--space-4) var(--space-10); }

  .page-header__title { font-size: var(--text-xl); }

  .form-grid { grid-template-columns: 1fr; }

  .modal { padding: 0; align-items: flex-end; }
  .modal__panel {
    width: 100%;
    max-height: 88vh;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    animation-name: sheet-in;
  }
  .modal__footer { border-radius: 0; }

  .drawer__panel { width: 100%; }

  .palette { padding: var(--space-3); align-items: flex-start; }
  .palette__panel { max-height: 75vh; }

  .toast-region {
    top: auto;
    bottom: var(--space-4);
    left: var(--space-4);
    right: var(--space-4);
    width: auto;
  }

  .pagination { justify-content: center; }
}

@keyframes sheet-in {
  from { opacity: 0; transform: translateY(100%); }
  to   { opacity: 1; transform: translateY(0); }
}

/* --- Small phone --- */
@media (max-width: 26rem) {
  .app-topbar__title { font-size: var(--text-sm); }
  .btn { padding: 0.5rem 0.75rem; }
  .card__body,
  .auth-card__panel { padding: var(--space-4); }
}
