/* =====================================================================
   LAYOUT FIX — the app shell must never clip its own scroll containers.

   The shell is a 3-row grid (header / main / status bar) at viewport height.
   Every view inside <main> owns its scrolling. That only works if the grid
   row and <main> are allowed to shrink below content size (min-height: 0),
   which is the classic CSS grid gotcha: grid items default to min-height:auto,
   so the row grows past the viewport, body overflow:hidden clips it, and
   nothing scrolls.
   ===================================================================== */

html,
body {
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}

#app {
  height: 100vh;
  height: 100dvh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  min-height: 0;
}

/* the grid item that hosts every view */
#main {
  min-height: 0;
  overflow: hidden;
}

/* monitor: rails and feed each scroll independently */
.monitor {
  height: 100%;
  min-height: 0;
  overflow: hidden;
}
.monitor .rail,
.monitor .feed {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
}

/* full-page views inside main */
.briefs-view,
.archive-view,
.sources-view,
.settings-view {
  height: 100%;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
}

/* brief editor: both panes scroll independently */
.editor {
  height: 100%;
  min-height: 0;
  overflow: hidden;
}
.editor-main,
.editor-side {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
}

/* modal content must scroll too */
.modal {
  overflow-y: auto;
  overscroll-behavior: contain;
}

/* small screens: header can wrap; give the shell a sane minimum */
@media (max-width: 900px) {
  #app {
    grid-template-rows: auto minmax(0, 1fr) auto;
  }
  .topbar {
    flex-wrap: wrap;
    height: auto;
    min-height: 58px;
    padding: 8px 14px;
  }
  .tools {
    width: 100%;
    margin-left: 0;
  }
  .searchwrap {
    flex: 1;
  }
  #q {
    width: 100%;
  }
  .monitor .rail.left,
  .monitor .rail.right {
    display: none;
  }
}

/* the monitor toolbar can wrap instead of clipping on narrow panes */
.feed-toolbar {
  flex-wrap: wrap;
  row-gap: 6px;
}

/* keyboard users need to see where focus is inside custom widgets */
.facet-row:focus-visible,
.pulse-row:focus-visible,
.related-item:focus-visible,
.chip:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 1px;
}
