/*
 * Cairn layout.
 *
 *   1. App layout       sidebar + topbar + main (web/app.js)
 *   2. Topbar widgets   quick search, credits, notifications, account
 *   3. Auth layout      centered card for login / signup / invite
 *   4. Public layout    navigation + footer around the public pages
 *   5. Page scaffolding .page, .page-narrow, .split, .panel
 *   6. Route progress   thin bar shown while a page module loads
 *   7. Charts           everything drawn by web/lib/charts.js
 *   8. Responsive       drawer below 900px, tighter chrome below 720px
 *
 * The document itself scrolls (the router resets window scroll on navigation):
 * the sidebar and the topbar are sticky, nothing here creates an inner page
 * scroller. Tokens only: no literal colors.
 */

/* ---------------------------------------------------------------------------
 * 1. App layout
 * ------------------------------------------------------------------------- */
.app-layout {
  --sidebar-current: var(--sidebar-width);
  --sidebar-rail: 57px;
  display: grid;
  grid-template-columns: var(--sidebar-current) minmax(0, 1fr);
  min-height: 100vh;
  transition: grid-template-columns var(--duration, 180ms) var(--ease, ease);
}

.app-layout.is-collapsed {
  --sidebar-current: var(--sidebar-rail);
}

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

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

.app-main:focus {
  outline: none;
}

.skip-link {
  position: fixed;
  top: var(--space-2);
  left: var(--space-2);
  z-index: var(--z-toast);
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-md);
  color: var(--text);
  font-weight: 500;
  transform: translateY(-200%);
}

.skip-link:focus {
  transform: none;
}

/* Brand mark (the stacked stones) and name, shared by all three layouts. */
.brand {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-width: 0;
  color: var(--text);
  text-decoration: none;
}

.brand:hover {
  text-decoration: none;
}

.brand-mark {
  flex: none;
  fill: var(--accent);
}

.brand-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.2;
}

.brand-name {
  font-size: var(--text-lg);
  font-weight: 700;
  letter-spacing: -0.01em;
}

.brand-workspace {
  overflow: hidden;
  color: var(--text-muted);
  font-size: var(--text-xs);
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Sidebar */
.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  min-width: 0;
  height: 100vh;
  height: 100dvh;
  border-right: 1px solid var(--border);
  background: var(--surface);
}

.sidebar-head {
  display: flex;
  flex: none;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  height: var(--topbar-height);
  padding: 0 var(--space-3);
  border-bottom: 1px solid var(--border);
}

/* Only the drawer (small screens) has a close button. */
.sidebar-head .sidebar-close {
  display: none;
}

.sidebar-nav {
  flex: 1 1 auto;
  min-height: 0;
  padding: var(--space-2);
  overflow-x: hidden;
  overflow-y: auto;
  /* Reaching the end of the list must not start scrolling the page behind it. */
  overscroll-behavior: contain;
}

.sidebar-foot {
  flex: none;
  padding: var(--space-2);
  border-top: 1px solid var(--border);
}

.nav-group {
  margin-top: var(--space-3);
}

.nav-group-label {
  padding: var(--space-1) var(--space-2);
  overflow: hidden;
  color: var(--text-faint);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.04em;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  min-height: var(--control-height, 32px);
  padding: 0 var(--space-2);
  border-radius: var(--radius);
  color: var(--text-muted);
  font-weight: 500;
  text-align: left;
  text-decoration: none;
  white-space: nowrap;
}

.nav-link + .nav-link {
  margin-top: 2px;
}

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

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

.nav-link:focus-visible {
  outline-offset: -2px;
}

.nav-link.is-active {
  background: var(--accent-soft);
  color: var(--text);
}

.nav-link.is-active .icon {
  color: var(--accent);
}

.nav-label {
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-backdrop {
  display: none;
}

/*
 * Icon rail (wide screens only): labels stay available to screen readers.
 * Written as the exact opposite of the drawer breakpoint below, so a window
 * that is 900.5px wide (browser zoom) gets one of the two and never neither.
 */
@media not all and (max-width: 900px) {
  .is-collapsed .sidebar-head {
    justify-content: center;
    padding: 0;
  }

  .is-collapsed .brand-text,
  .is-collapsed .nav-label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }

  .is-collapsed .nav-link {
    justify-content: center;
    padding: 0;
  }

  .is-collapsed .nav-group {
    margin-top: var(--space-2);
    padding-top: var(--space-2);
    border-top: 1px solid var(--border);
  }

  .is-collapsed .nav-group-label {
    display: none;
  }
}

/* Topbar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  flex: none;
  align-items: center;
  gap: var(--space-2);
  height: var(--topbar-height);
  padding: 0 var(--space-5) 0 var(--space-3);
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.topbar-actions {
  display: flex;
  flex: none;
  align-items: center;
  gap: var(--space-1);
  margin-left: auto;
}

.topbar-button {
  position: relative;
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: var(--control-height, 32px);
  height: var(--control-height, 32px);
  border-radius: var(--radius);
  color: var(--text-muted);
}

/* Same resting and hover look as the kit's ghost buttons. */
.topbar-button:hover,
.topbar-button[aria-haspopup][aria-expanded="true"] {
  background: var(--surface-3);
  color: var(--text);
}

/* ---------------------------------------------------------------------------
 * 2. Topbar widgets
 * ------------------------------------------------------------------------- */
.topbar-search {
  position: relative;
  flex: 1 1 auto;
  max-width: 420px;
  min-width: 0;
}

.topbar-search .icon {
  position: absolute;
  top: 50%;
  left: 10px;
  color: var(--text-faint);
  pointer-events: none;
  transform: translateY(-50%);
}

.topbar-search input {
  width: 100%;
  padding-left: 32px;
  border-color: transparent;
  background: var(--surface-2);
}

.topbar-search input:hover {
  border-color: var(--border-strong);
}

.topbar-search input:focus {
  border-color: var(--focus);
  background: var(--surface);
}

.credits-pill {
  display: inline-flex;
  flex: none;
  align-items: center;
  gap: 6px;
  height: 28px;
  margin-right: var(--space-1);
  padding: 0 var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  color: var(--text);
  font-size: var(--text-sm);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  text-decoration: none;
  white-space: nowrap;
}

.credits-pill .icon {
  color: var(--accent);
}

.credits-pill:hover {
  border-color: var(--border-strong);
  background: var(--surface-2);
  text-decoration: none;
}

.credits-pill.is-low {
  border-color: var(--warning);
  background: var(--warning-soft);
  color: var(--warning);
}

.credits-pill.is-low .icon {
  color: inherit;
}

.credits-unit {
  color: var(--text-muted);
  font-weight: 500;
}

.credits-pill.is-low .credits-unit {
  color: inherit;
}

/* Notifications: a count on the bell, and a panel shown through the kit's popover. */
.notifications-count {
  position: absolute;
  top: -3px;
  right: -3px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: var(--radius-full);
  background: var(--accent);
  box-shadow: 0 0 0 2px var(--surface);
  color: var(--accent-text);
  font-size: var(--text-xs);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 18px;
  text-align: center;
}

/* Position, surface, border and shadow come from .popover; the list scrolls inside the panel. */
.notifications-panel {
  display: flex;
  flex-direction: column;
  width: 360px;
  max-height: min(480px, calc(100vh - var(--topbar-height) - var(--space-5)));
  overflow: hidden;
}

.notifications-head {
  display: flex;
  flex: none;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  min-height: 44px;
  padding: var(--space-2) var(--space-4);
  border-bottom: 1px solid var(--border);
}

.notifications-title {
  font-size: var(--text-md);
  font-weight: 600;
}

.notifications-list {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
}

.notification {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  width: 100%;
  padding: var(--space-3) var(--space-4);
  color: var(--text);
  text-align: left;
  text-decoration: none;
}

.notification + .notification {
  border-top: 1px solid var(--border);
}

.notification:hover {
  background: var(--surface-2);
  text-decoration: none;
}

.notification:focus-visible {
  outline-offset: -2px;
}

.notification-dot {
  flex: none;
  width: 8px;
  height: 8px;
  margin-top: 6px;
  border-radius: 50%;
}

.notification.is-unread .notification-dot {
  background: var(--accent);
}

.notification-text {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.notification-title {
  overflow-wrap: anywhere;
}

.notification.is-unread .notification-title {
  font-weight: 600;
}

.notification-body {
  display: -webkit-box;
  overflow: hidden;
  color: var(--text-muted);
  font-size: var(--text-sm);
  overflow-wrap: anywhere;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
}

.notification-time {
  color: var(--text-faint);
  font-size: var(--text-xs);
}

.notifications-note {
  padding: var(--space-6) var(--space-4);
  color: var(--text-muted);
  text-align: center;
}

/* Account menu trigger */
.user-trigger {
  display: inline-flex;
  flex: none;
  align-items: center;
  gap: var(--space-2);
  height: 36px;
  margin-left: var(--space-1);
  padding: 0 var(--space-2) 0 var(--space-1);
  border-radius: var(--radius-full);
  color: var(--text);
}

.user-trigger:hover,
.user-trigger[aria-expanded="true"] {
  background: var(--surface-3);
}

.user-trigger .icon {
  color: var(--text-faint);
}

.user-name {
  max-width: 160px;
  overflow: hidden;
  font-size: var(--text-sm);
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------------------------------------------------------------------------
 * 3. Auth layout
 * ------------------------------------------------------------------------- */
.auth-layout {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-5);
  min-height: 100vh;
  padding: var(--space-7) var(--space-4);
}

.auth-layout .brand-name {
  font-size: var(--text-xl);
}

.auth-card {
  width: 100%;
  max-width: 420px;
  padding: var(--space-7);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-md);
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.auth-intro {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.auth-intro h1 {
  font-size: var(--text-xl);
}

.auth-intro p {
  color: var(--text-muted);
}

/* The alert region is always in the form (so a message is announced); it takes no room while empty. */
.auth-form > [role="alert"]:empty {
  display: none;
}

.auth-alert {
  padding: var(--space-3);
  border-radius: var(--radius);
  background: var(--danger-soft);
  color: var(--danger);
  font-size: var(--text-sm);
  overflow-wrap: anywhere;
}

.auth-note {
  padding: var(--space-3);
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: var(--text-sm);
  overflow-wrap: anywhere;
}

/* The submit button spans the card. */
.auth-actions {
  display: grid;
}

.auth-switch {
  color: var(--text-muted);
  font-size: var(--text-sm);
  text-align: center;
}

.auth-legal {
  color: var(--text-faint);
  font-size: var(--text-xs);
  text-align: center;
}

/* "Forgot your password?" right under the password field. */
.auth-forgot {
  margin-top: calc(var(--space-2) * -1);
  font-size: var(--text-sm);
  text-align: right;
}

/* The emailed code: spaced digits, easy to compare with the email. */
.auth-code .input {
  font-family: var(--font-mono);
  font-size: var(--text-lg);
  letter-spacing: 0.3em;
}

/* Under a code field: ask for another code, or go back and change the address. */
.auth-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--space-2) var(--space-4);
}

/* ---------------------------------------------------------------------------
 * 4. Public layout
 * ------------------------------------------------------------------------- */
.public-layout {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.public-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  flex: none;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.public-nav-inner,
.public-footer-inner {
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 var(--space-5);
}

.public-nav-inner {
  display: flex;
  align-items: center;
  gap: var(--space-5);
  height: var(--topbar-height);
}

.public-links {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  margin-left: auto;
}

.public-link {
  color: var(--text-muted);
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
}

.public-link:hover {
  color: var(--text);
  text-decoration: none;
}

.public-main {
  flex: 1 1 auto;
  min-width: 0;
}

.public-footer {
  flex: none;
  border-top: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  font-size: var(--text-sm);
}

.public-footer-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3) var(--space-5);
  padding-top: var(--space-5);
  padding-bottom: var(--space-5);
}

.public-footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-5);
}

/* ---------------------------------------------------------------------------
 * 5. Page scaffolding
 * ------------------------------------------------------------------------- */
.page,
.page-narrow {
  width: 100%;
  margin: 0 auto;
  padding: var(--space-6);
}

.page {
  max-width: 1440px;
}

.page-narrow {
  max-width: 800px;
}

/*
 * Default rhythm between the direct children of a page, so sections placed
 * straight into .page never touch. Zero specificity: any component or page
 * rule that sets its own margin wins, and adjoining margins collapse instead
 * of adding up. The kit's tighter pairs keep their own spacing: whatever
 * follows a .toolbar, and a .pagination under its table. An Async wrapper has
 * no box of its own (display: contents), so its first child takes the margin.
 */
:where(.page, .page-narrow) > :where(:not(.toolbar) + :not(.pagination)),
:where(.page, .page-narrow) > :where(:not(.toolbar) + .async) > :where(:first-child) {
  margin-top: var(--space-4);
}

/* Filter rail + results. The rail stays in view and scrolls on its own when it is taller than the window. */
.split {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  align-items: start;
  gap: var(--space-5);
}

.split-aside {
  position: sticky;
  top: calc(var(--topbar-height) + var(--space-4));
  min-width: 0;
  max-height: calc(100vh - var(--topbar-height) - var(--space-7));
  overflow-y: auto;
}

.split-main {
  min-width: 0;
}

/* A plain surface box: the flat sibling of the kit's Card. */
.panel {
  min-width: 0;
  padding: var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

/* ---------------------------------------------------------------------------
 * 6. Route progress
 * ------------------------------------------------------------------------- */
.route-progress {
  position: fixed;
  top: 0;
  right: 0;
  left: 0;
  z-index: var(--z-toast);
  height: 2px;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms ease;
}

/* The short delay keeps the bar away from navigations that finish instantly. */
.route-progress.is-active {
  opacity: 1;
  transition-delay: 120ms;
}

.route-progress::before {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 40%;
  border-radius: var(--radius-full);
  background: var(--accent);
  content: "";
  animation: route-progress 1.1s ease-in-out infinite paused;
}

.route-progress.is-active::before {
  animation-play-state: running;
}

@keyframes route-progress {
  from {
    transform: translateX(-100%);
  }

  to {
    transform: translateX(250%);
  }
}

@media (prefers-reduced-motion: reduce) {
  .route-progress::before {
    width: 100%;
    animation: none;
  }
}

/* ---------------------------------------------------------------------------
 * 7. Charts (web/lib/charts.js)
 *
 * Marks take their series color inline (var(--chart-n)); everything else
 * (axes, grid, text, tooltip) is styled here from the neutral tokens. Text
 * never wears a series color. Set --chart-surface on a parent when a chart
 * sits on something other than --surface.
 * ------------------------------------------------------------------------- */
.chart {
  --chart-surface: var(--surface);
  position: relative;
  min-width: 0;
}

.chart-svg {
  height: auto;
  overflow: visible;
  font-size: var(--text-xs);
}

.chart-svg:focus-visible {
  border-radius: var(--radius-sm);
  outline-offset: 4px;
}

.chart-grid,
.chart-axis,
.chart-crosshair {
  stroke: var(--border);
  stroke-width: 1;
  shape-rendering: crispEdges;
}

.chart-axis,
.chart-crosshair {
  stroke: var(--border-strong);
}

.chart-tick,
.chart-label {
  fill: var(--text-muted);
}

.chart-tick {
  font-variant-numeric: tabular-nums;
}

.chart-value {
  fill: var(--text);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.chart-note {
  fill: var(--text-muted);
  font-weight: 400;
}

.chart-line {
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.chart-area {
  fill-opacity: 0.1;
}

/* A ring in the surface color keeps dots legible where they cross a line. */
.chart-dot {
  stroke: var(--chart-surface);
  stroke-width: 2;
}

.chart-mark {
  transition: opacity var(--duration-fast, 120ms) ease;
}

/*
 * Hit targets double as the hover wash over the active bar or row. On touch
 * screens a horizontal drag scrubs through the values; a vertical one still
 * scrolls the page.
 */
.chart-hit {
  fill: var(--text);
  fill-opacity: 0;
  pointer-events: all;
  touch-action: pan-y;
}

.chart-hit.is-active {
  fill-opacity: 0.06;
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1) var(--space-4);
  margin-bottom: var(--space-3);
  color: var(--text-muted);
  font-size: var(--text-sm);
}

.chart.is-empty .chart-legend {
  display: none;
}

.chart-legend-item {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
}

.chart-key {
  flex: none;
  width: 10px;
  height: 10px;
  border-radius: 3px;
}

.chart-key-line {
  width: 14px;
  height: 2px;
  border-radius: 1px;
}

.chart-empty {
  display: grid;
  place-items: center;
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: var(--text-sm);
}

.chart-tooltip {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 2;
  min-width: 96px;
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-md);
  color: var(--text);
  font-size: var(--text-xs);
  line-height: 1.5;
  opacity: 0;
  pointer-events: none;
  transition: opacity 80ms ease;
  visibility: hidden;
  white-space: nowrap;
}

.chart-tooltip.is-visible {
  opacity: 1;
  visibility: visible;
}

.chart-tooltip-title {
  margin-bottom: 2px;
  color: var(--text-muted);
}

.chart-tooltip-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.chart-tooltip-label {
  max-width: 180px;
  overflow: hidden;
  color: var(--text-muted);
  text-overflow: ellipsis;
}

.chart-tooltip-value {
  margin-left: auto;
  padding-left: var(--space-3);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* Screen-reader twin of each chart: present for assistive technology, never painted. */
.chart-data {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* Donut: ring on the left, legend with values on the right (below when narrow). */
.chart-donut {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-4) var(--space-6);
}

.chart-donut .chart-svg {
  flex: none;
}

.chart-donut .chart-empty {
  flex: 1 1 auto;
}

.chart-donut.has-active .chart-mark:not(.is-active) {
  opacity: 0.4;
}

.chart-donut-total {
  fill: var(--text);
  font-weight: 600;
}

.chart-donut-legend {
  display: flex;
  flex: 1 1 180px;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  font-size: var(--text-sm);
}

.chart-donut-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 26px;
  margin: 0 calc(var(--space-2) * -1);
  padding: 0 var(--space-2);
  border-radius: var(--radius-sm);
}

.chart-donut-item.is-active {
  background: var(--surface-2);
}

.chart-donut-label {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  color: var(--text-muted);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chart-donut-value {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.chart-donut-share {
  min-width: 36px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  text-align: right;
}

/* Sparkline: a quiet line, the latest point in the first series color. */
.chart-spark {
  display: inline-flex;
  flex: none;
  vertical-align: middle;
}

.chart-spark-line {
  fill: none;
  stroke: var(--text-faint);
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.chart-spark-dot {
  fill: var(--chart-1);
}

/* ---------------------------------------------------------------------------
 * 8. Responsive
 * ------------------------------------------------------------------------- */

/* Below 900px the sidebar leaves the grid and becomes an off-canvas drawer. */
@media (max-width: 900px) {
  .app-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: var(--z-drawer);
    width: min(280px, 86vw);
    box-shadow: var(--shadow-lg);
    transform: translateX(-102%);
    transition:
      transform var(--duration, 180ms) var(--ease, ease),
      visibility 0s linear var(--duration, 180ms);
    visibility: hidden;
  }

  .is-drawer-open .sidebar {
    transform: none;
    transition-delay: 0s;
    visibility: visible;
  }

  .sidebar-head .sidebar-close {
    display: inline-flex;
  }

  .sidebar-backdrop {
    position: fixed;
    inset: 0;
    z-index: calc(var(--z-drawer) - 1);
    display: block;
    background: var(--overlay);
    touch-action: none;
    opacity: 0;
    transition:
      opacity var(--duration, 180ms) ease,
      visibility 0s linear var(--duration, 180ms);
    visibility: hidden;
  }

  .is-drawer-open .sidebar-backdrop {
    opacity: 1;
    transition-delay: 0s;
    visibility: visible;
  }

  .topbar {
    padding-right: var(--space-3);
  }

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

  .split-aside {
    position: static;
    max-height: none;
    overflow-y: visible;
  }
}

@media (max-width: 720px) {
  .page,
  .page-narrow {
    padding: var(--space-4);
  }

  .user-name,
  .credits-unit {
    display: none;
  }

  .user-trigger {
    padding-right: var(--space-1);
  }

  .user-trigger .icon {
    display: none;
  }

  .auth-card {
    padding: var(--space-5);
  }

  .public-nav-inner {
    gap: var(--space-3);
    padding: 0 var(--space-3);
  }

  .public-links {
    gap: var(--space-3);
  }
}

/* A page's heading takes the focus after a page change (app.js) so screen
 * readers announce the new page; it is not a control, so it draws no ring. */
.app-main h1[tabindex="-1"]:focus,
.public-main h1[tabindex="-1"]:focus,
.auth-card h1[tabindex="-1"]:focus,
.public-main:focus,
.auth-card:focus {
  outline: none;
}
