.app-shell {
  display: grid;
  grid-template-rows: auto 1fr;
  min-height: 100svh;
}

/* Grid and flex children default to min-width:auto, which would let a wide
   scroll container push the page past the viewport. */
.app-shell > *,
.app-shell__layout > * {
  min-width: 0;
}

.app-shell__header {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem var(--shell-padding);
  background: var(--color-surface);
  border-block-end: 1px solid var(--color-border);
}

.app-shell__identity {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.app-shell__product {
  font-weight: 700;
}

.app-shell__descriptor,
.app-shell__funnel {
  color: var(--color-muted);
  font-size: 0.875rem;
  overflow-wrap: anywhere;
}

.app-shell__funnel {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 0.75rem;
  align-items: baseline;
}

.app-shell__funnel-zone::before {
  content: "· ";
}

.app-shell__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.app-shell__menu-toggle {
  min-width: 44px;
  min-height: 44px;
}

.app-shell__layout {
  display: grid;
  grid-template-columns: 1fr;
  min-height: 0;
}

.app-shell__side-nav {
  display: none;
  padding: 1rem;
  background: var(--color-surface);
  border-inline-end: 1px solid var(--color-border);
}

.app-shell__nav-list {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 0;
  margin: 0;
  list-style: none;
}

.app-shell__nav-item {
  display: flex;
}

.app-shell__nav-link {
  display: flex;
  flex: 1 1 auto;
  gap: 0.5rem;
  align-items: center;
  min-width: 44px;
  min-height: 44px;
  padding: 0.6rem 0.9rem;
  color: var(--color-text);
  text-decoration: none;
  border: 1px solid transparent;
  border-radius: var(--radius-control);
  overflow-wrap: anywhere;
}

.app-shell__nav-link:hover {
  background: var(--color-elevated);
}

.app-shell__nav-link[aria-current="page"] {
  color: var(--color-primary-text);
  font-weight: 700;
  background: var(--color-primary);
  border-color: var(--color-primary);
}

.app-shell__nav-link[aria-current="page"]::before {
  content: "▍";
  color: var(--color-primary-text);
}

.app-shell__drawer {
  position: fixed;
  z-index: 20;
  inset: 0;
  padding: var(--shell-padding);
  overflow-y: auto;
  background: var(--color-surface);
}

.app-shell__main {
  min-width: 0;
  padding: var(--shell-padding);
}

/* Layout hook for the read-only route bodies. The body and everything it hosts
   must be allowed to shrink, or a wide scroll container would push the page
   past the viewport. */
.app-shell__main > *,
[data-shell-body],
[data-shell-body] > * {
  min-width: 0;
  max-width: 100%;
}

.app-shell__panel {
  max-width: 60rem;
  padding: var(--card-padding);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-panel);
  box-shadow: var(--shadow-panel);
}

.app-shell__panel--placeholder {
  border-style: dashed;
}

.app-shell__route-name {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  color: var(--color-muted);
  font-size: 0.875rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-control);
}

.app-shell__quick-nav {
  display: none;
  padding: 0.35rem;
  background: var(--color-surface);
  border-block-start: 1px solid var(--color-border);
}

.app-shell__quick-nav .app-shell__nav-list {
  flex-direction: row;
  max-width: 100%;
  overflow-x: auto;
  overscroll-behavior-x: contain;
}

.app-shell__quick-nav .app-shell__nav-link {
  justify-content: center;
  white-space: nowrap;
}

@media (min-width: 1024px) {
  .app-shell__layout {
    grid-template-columns: minmax(13rem, 17rem) 1fr;
  }

  .app-shell__side-nav {
    display: block;
  }

  .app-shell__menu-toggle,
  .app-shell__drawer {
    display: none;
  }
}

@media (max-width: 1023px) {
  .app-shell__side-nav {
    display: none;
  }
}

@media (max-width: 767px) {
  .app-shell {
    grid-template-rows: auto 1fr auto;
  }

  .app-shell__main {
    padding-inline: 1rem;
  }

  .app-shell__quick-nav {
    display: block;
    position: sticky;
    inset-block-end: 0;
  }

  .app-shell__panel {
    padding: 1rem;
  }
}

@media (prefers-reduced-motion: no-preference) {
  .app-shell__nav-link {
    transition: background 120ms ease, color 120ms ease;
  }
}
