/* The panels every shell is built from: a card, and the bento grid that
   lays cards out.

   These lived in the admin's own stylesheet, which the Inbox does not
   load - so the Settings screen had the markup for a bento of cards and
   none of the rules, and came out as a plain stacked list. Charlie: "your
   settings page is not a bento grid, just a list." Their own file now,
   linked by the admin shell and the Inbox shell, so there is one copy and
   neither can be given the markup without the rules again.

   Linked BEFORE each shell's own stylesheet on purpose: this is the base
   each of them may override, not a late sheet that overrides them.

   Charlie's rule for a bento, 2026-09-03, all three products: "the most
   information in the minimum space ... it is not okay to just expand a
   box that doesn't need very long fields to fill a space ... without any
   space wasted." Every card is a regular width, keeps its own height, is
   never stretched; bento-pack.js measures each one and sets how many of
   the small rows it covers, and dense flow slots a short card under a
   short one so no hole is left. */

.card {
  /* Each shell names its own panel colours - the admin's are --sm-*, the
     Inbox's are --aw-*. Asking for the Inbox's first and falling back to
     the admin's is what lets one card rule serve both, and it is why the
     Settings cards had no edges at all when this moved out of the admin's
     stylesheet: the rules arrived, the colour names did not. */
  background: var(--aw-panel, var(--sm-panel));
  border: 1px solid var(--aw-panel-border, var(--sm-panel-border));
  border-radius: var(--shape-radius, min(10px, 25%));
  box-shadow: var(--aw-shadow-panel, var(--sm-shadow-panel));
  padding: 1.25rem;
  /* Panels never touch. There was no margin here at all, so anywhere cards
     were simply stacked one after another they ran together into a single
     block with hairlines through it. The grids that lay cards out
     themselves (.card-grid, .bento-grid) set their own gap and override
     this. 1.25rem matches that gap, so stacked and gridded cards are spaced
     the same. */
  margin-bottom: 1.25rem;
}


.card {
  /* Owns the rhythm between its own children, instead of each element
     bringing its own margins and colliding with the next. */
  display: flex;
  flex-direction: column;
  gap: 0.875rem;
  padding: 1.5rem;
}
.card > * { margin-top: 0; margin-bottom: 0; }

/* h1 as well as h2: a card's heading is the same size whichever tag it
   carries. Settings was written with an <h1> per card and had no rule, so
   every title took the page-title clamp and came out at 2-3rem - eight
   enormous words down a bento of small print (Charlie, 12 September 2026).
   The template says h2 now; this rule is so the next one cannot do it. */
.card h1,
.card h2 {
  font-size: 1.0625rem;
  font-weight: 600;
  line-height: 1.3;
}
.card h3 {
  font-size: 0.9375rem;
  font-weight: 600;
  margin-top: 0.5rem;
}

/* Body copy inside a card. ~68 characters is the readable measure - past
   that the eye loses its place returning to the next line, which is what
   made these panels feel like a wall of long lines. */
.card > p,
.card .section-note,
.card > ul {
  max-width: 68ch;
  line-height: 1.6;
}

/* A row of buttons is a block in its own right, so it needs air above it
   rather than inheriting whatever margin the previous element had. */
.card .button-row {
  flex-wrap: wrap;
  align-items: center;
  margin-top: 0.25rem;
}


.bento-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1.25rem;
}
.bento-grid--six { grid-template-columns: repeat(6, 1fr); }
.bento-grid > .bento-span-2 { grid-column: span 2; }
.bento-grid > .bento-span-3 { grid-column: span 3; }
.bento-grid > .bento-span-4 { grid-column: span 4; }
.bento-grid > .bento-span-6 { grid-column: span 6; }

/* Between the two: six narrow columns squeeze a table down to a
   scrollbar, so pair the tiles up rather than stacking them all. */
@media (max-width: 1100px) {
  .bento-grid--six { grid-template-columns: repeat(2, 1fr); }
  .bento-grid--six > .card { grid-column: span 1; }
}
@media (max-width: 700px) {
  /* minmax(0, 1fr) and not a bare 1fr: a bare 1fr floors the column at the
     content's min-content width, so on the System screen a card whose
     content would not shrink held the column at 306px inside a 254px page
     and hung off the right edge with no scrollbar (13 September 2026). */
  .bento-grid { grid-template-columns: minmax(0, 1fr); }
  .bento-grid > .card { grid-column: span 1 !important; }
}

.bento-grid .card { margin-bottom: 0; }

/* A grid of cards sitting straight in the page has the next panel right
   under it; the cards inside carry no margin of their own. Nothing touches. */
.content > .card-grid,
.content > .bento-grid { margin-bottom: 1.25rem; }
.content > .card-grid:last-child,
.content > .bento-grid:last-child { margin-bottom: 0; }

/* A dense bento: Charlie's rule, 2026-09-03 - "the most information in
   the minimum space". Every card is a regular width (a third of the row),
   keeps its own height, and is never stretched (align-items: start). The
   rows are small units so bento-pack.js can say how many each card covers,
   and dense flow then slots each card into the first gap it fits - a short
   card sits under a short one, and nothing is left empty. Without the
   script the cards still lay out in order; they just do not fill gaps. */
.bento-grid--dense { grid-auto-rows: 8px; grid-auto-flow: dense; align-items: start; }

/* The house bento, as the style skill defines it: repeat(auto-fit,
   minmax(240px, 1fr)). Columns are found from the width available rather
   than fixed at four, so a wide screen gets more of them and a laptop
   fewer, and no card is ever squeezed below 240px to keep a column count
   nobody asked for.
   
   Paired with --dense it satisfies the other half of the rule as well: the
   packer measures each card and the dense flow drops it into the first gap
   it fits, so a short card never gets stretched to fill a tall row. */
.bento-grid--fit { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.bento-grid--fit > .card { grid-column: auto; }
@media (max-width: 900px) { .bento-grid--dense { grid-auto-rows: auto; } }

/* A bento whose cards keep their own height. The System page's cards are
   all about the same size and stretching them to the row looks tidy; the
   Settings cards are not - Email is long, the API key is four lines - and
   stretching left the short one three-quarters empty. */
.bento-grid--loose { align-items: start; }
