/* ==========================================================================
   app.css — element defaults, links, and the page's own furniture

   Layers: `base` (document typography, links, scrollbars) and `layout` (the
   topbar band, the page header, the section rhythm).

   What is NOT here any more: the `.app` grid and everything that hung off it
   — `.app__sidebar/__main/__content/__scrim`, `.nav-group*`, `.nav-item*`,
   `.thread-item*`, and the `.page/.page--wide/.page--flush` content column.
   That was the shell before the shell was remade. base.html mounts `.shell`
   and every surface mounts `.surface`; shell.css and surfaces.css own those,
   and nothing in the tree had written the old names for a long time. The
   `.prose` document recipe went with them: an answer is `.msg__prose`, which
   chat.css states in writing does not carry this class.

   Breakpoints — four, fixed, and the only ones in the system (plus 767px,
   which belongs to the row-card collapse in surfaces.css and nowhere else).
   Media queries cannot read custom properties, so these numbers are literal
   by necessity; every other length in this file is a token. This file now
   only has something to say at the last of them.

     1440px   comfortable — content column reaches --content-max
     1200px   dense       — page gutters tighten
      900px   overlay     — sidebar leaves the grid and becomes a drawer
      640px   handheld    — page furniture stacks, toolbars compress
   ========================================================================== */

@layer base {
  html {
    font-family: var(--font-sans);
    scrollbar-width: thin;
    scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
  }

  body {
    background-color: var(--bg-canvas);
    color: var(--fg-primary);
    font-family: var(--font-sans);
    font-size: var(--text-base);
    line-height: var(--lh-base);
    font-weight: var(--weight-regular);
    /* The page itself is never allowed a horizontal scrollbar. Anything wider
       than its column scrolls inside its own container — see .table-wrap and
       the .scroll-x utility. */
    overflow-x: hidden;
  }

  ::-webkit-scrollbar {
    inline-size: var(--scrollbar-size);
    block-size: var(--scrollbar-size);
  }

  ::-webkit-scrollbar-track {
    background: var(--scrollbar-track);
  }

  ::-webkit-scrollbar-thumb {
    background-color: var(--scrollbar-thumb);
    border: 2px solid transparent;
    background-clip: padding-box;
    border-radius: var(--radius-pill);
  }

  ::-webkit-scrollbar-thumb:hover {
    background-color: var(--scrollbar-thumb-hover);
  }

  ::-webkit-scrollbar-corner {
    background: transparent;
  }

  .link {
    color: var(--link);
    text-decoration: underline;
    text-decoration-color: color-mix(in srgb, var(--link) 35%, transparent);
    text-underline-offset: 0.18em;
    text-decoration-thickness: 1px;
    border-radius: var(--radius-control);
    transition: color var(--dur-fast) var(--ease-out),
                text-decoration-color var(--dur-fast) var(--ease-out);
  }

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

  .link:active {
    color: var(--link-hover);
  }

  .skip-link {
    position: fixed;
    inset-block-start: var(--space-2);
    inset-inline-start: var(--space-2);
    z-index: var(--z-toast);
    padding: var(--space-2) var(--space-3);
    background-color: var(--bg-raised);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-control);
    box-shadow: var(--shadow-md);
    font-weight: var(--weight-medium);
  }
}

@layer layout {
  /* ---- Topbar --------------------------------------------------------- */
  .topbar {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    block-size: var(--topbar-h);
    padding-inline: var(--space-4);
    background-color: var(--bg-surface);
    border-block-end: 1px solid var(--border-subtle);
    min-inline-size: 0;
  }

  .topbar__lead {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    min-inline-size: 0;
    flex: 1 1 auto;
  }

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

  .topbar__toggle {
    display: none;
  }

  /* ---- Page furniture -------------------------------------------------- */
  .page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--space-4);
    margin-block-end: var(--space-5);
    min-inline-size: 0;
  }

  .page-header__text {
    min-inline-size: 0;
  }

  .page-header__title {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    font-size: var(--text-xl);
    line-height: var(--lh-xl);
    font-weight: var(--weight-semibold);
    letter-spacing: -0.01em;
    color: var(--fg-primary);
  }

  .page-header__subtitle {
    margin-block-start: var(--space-1);
    color: var(--fg-muted);
    font-size: var(--text-base);
    line-height: var(--lh-base);
    max-inline-size: var(--measure);
  }

  .page-header__actions {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    flex: 0 0 auto;
  }

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

  .section__header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: var(--space-3);
    margin-block-end: var(--space-3);
  }

  .section__title {
    font-size: var(--text-md);
    line-height: var(--lh-md);
    font-weight: var(--weight-semibold);
  }

  .section__hint {
    color: var(--fg-muted);
    font-size: var(--text-sm);
    line-height: var(--lh-sm);
  }

  /* ---- Empty states ----------------------------------------------------
     One shape everywhere — a quiet mark, a sentence that says what would be
     here, and the action that would put it here. The recipe lives in
     components.css beside its sibling `.error-state`, so the pair cannot
     drift; this layer holds nothing. */

  /* ---- Responsive ------------------------------------------------------ */
  @media (max-width: 640px) {
    .page-header {
      flex-direction: column;
      align-items: stretch;
      gap: var(--space-3);
    }

    .page-header__actions {
      flex-wrap: wrap;
    }
  }
}
