/* ========================================================================
   AI-Tudor balance pass: every screen centered, every row even.
   Loaded last so it can line up columns the other stylesheets leave lopsided.
   ======================================================================== */

/* 1. One centered 1000px column on every parent screen, with matching
      36px inner padding so titles, headers and content share one edge. */
#shMain > .ipage,
#shMain > .sy,
#shMain > .bk,
#shMain > .shlist,
#shMain > .hw,
#shMain > .wrap {
  width: 100%;
  max-width: 1000px;
  margin-left: auto !important;
  margin-right: auto !important;
  box-sizing: border-box;
}
#shMain > .hw,
#shMain > .wrap { padding-left: 36px; padding-right: 36px; }

/* Page header (title on the left, search on the right) spans the same column. */
#shMain > .shhead {
  padding-left: max(36px, calc((100% - 1000px) / 2 + 36px)) !important;
  padding-right: max(36px, calc((100% - 1000px) / 2 + 36px)) !important;
}
/* Sticky back-bar above a study set matches the column below it. */
#shMain .bar-in {
  max-width: 1000px;
  padding-left: 36px;
  padding-right: 36px;
  box-sizing: border-box;
}

/* 2. Selected chips keep their pressed shading but stay level with the row. */
.chip[aria-pressed="true"] { transform: none !important; }

/* 3. Balanced rows made by balance.js: equal columns, equal heights. */
.bal-row {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 12px;
  align-items: stretch;
  width: 100%;
  margin: 8px 0;
}
.bal-row > .btn,
.bal-row > label.btn {
  width: 100%;
  margin: 0 !important;
  justify-content: center;
  text-align: center;
  vertical-align: top;
}

/* Rows made only of buttons split into equal columns. */
.row.bal-fill {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 12px;
}
.row.bal-fill > .btn { width: 100%; margin: 0; justify-content: center; text-align: center; }

/* Kid home: the three stat chips share the row evenly. */
.kpchips {
  display: grid !important;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.kpchips > * {
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  margin: 0 !important;
}
/* Assignment buttons: one width, so Start, Keep going and Review line up. */
.kpcard > .btn { min-width: 132px; justify-content: center; text-align: center; }

/* 4. Lesson cards: centered label, full-width progress track, full-width action. */
.lxcard > .qtype { text-align: center; }
.lpath { justify-content: space-between; }
.lxcard .row > .btn:only-child { flex: 1 1 auto; width: 100%; justify-content: center; }
.bigpath { margin-left: auto; margin-right: auto; }

/* 5. Song vocal rows: name and note on top, buttons in one even row below. */
.vocrow { flex-wrap: wrap; row-gap: 8px; }
.vocrow > .vocname { flex: 1 1 auto; }
.vocrow > .bal-row { flex: 1 1 100%; margin: 0; }

/* 6. Narrow screens (iPad portrait and phones): every parent page uses the
      same 18px sides, so the header, the title and the list share one edge. */
@media (max-width: 900px) {
  #shMain > .shhead,
  #shMain > .shlist,
  #shMain > .ipage,
  #shMain > .sy,
  #shMain > .bk,
  #shMain > .hw,
  #shMain > .wrap,
  #shMain .bar-in { padding-left: 18px !important; padding-right: 18px !important; }
}
@media (max-width: 560px) {
  .shhead .shs { flex: 1 1 100%; width: 100%; max-width: none; }
  .kpchips { grid-template-columns: 1fr; }
  .bal-row, .row.bal-fill { grid-auto-flow: row; grid-auto-columns: auto; }
}

/* 7. Kid screens: room at the bottom so the last card scrolls clear of the
      floating buddy and the "My assignments" button. */
.kp { padding-bottom: 150px !important; }
body:not(.shelled) .wrap { padding-bottom: 140px; }

/* 8. A lone text link under centered headings sits centered too. */
.wrap > .linkbtn { display: table; margin-left: auto; margin-right: auto; }
.kp > .bal-row, .kpchips { margin: 12px 0 !important; }
