/* ============================================================
   Horse Course — stylesheet
   ============================================================
   Plain CSS, no build step. The old app compiled Tailwind; keeping that would
   have meant running Node on a host that has none, so the same design tokens
   are declared here and used directly.

   Palette sampled from the client's logo:
     shield charcoal #181818 · horse orange #e4903c · jump-bar greys

   The page is RTL Arabic throughout. Use logical properties
   (margin-inline-start, inset-inline-end) rather than left/right, or the
   layout silently mirrors wrong.
   ============================================================ */

:root {
  /* accent — the horse */
  --brand-50:  #fdf4ea;
  --brand-100: #fae3c8;
  --brand-200: #f5c894;
  --brand-300: #efac60;
  --brand-500: #e4903c;
  --brand-600: #c8741f;
  --brand-700: #9c5916;

  /* neutrals — the shield, warmed slightly so it sits with the orange */
  --ink-50:  #f7f7f6;
  --ink-100: #eeeeec;
  --ink-200: #dededa;
  --ink-300: #c2c2bd;
  --ink-400: #91918b;
  --ink-500: #6b6b66;
  --ink-600: #4d4d49;
  --ink-700: #373734;
  --ink-800: #242422;
  --ink-900: #181818;

  --ok:    #2fa36b;
  --warn:  #c78a1f;
  --danger:#b5443f;
  --info:  #2f7fd1;

  --radius-card: 14px;
  --radius-control: 10px;

  --sidebar-w: 16rem;
  --bottombar-h: 4rem;
}

/* ------------------------------------------------------------
   Font
   ------------------------------------------------------------
   Self-hosted, not fetched from Google. The old app had a bug where Cairo was
   downloaded on every page load and never actually applied (fixed in 1d74ad4);
   serving the file ourselves with font-display:swap means it is cached for a
   year and text is readable before it arrives. */
/* Cairo is a VARIABLE font: one file covers 400 through 700, which is why
   there is no separate bold file to load. The three faces below are the same
   typeface cut by script — a page that is entirely Arabic never downloads the
   50 KB of Latin glyphs, and vice versa. */
@font-face {
  font-family: 'Cairo';
  src: url('/assets/fonts/cairo-arabic.woff2') format('woff2');
  font-weight: 400 700;
  font-display: swap;
  unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0897-08E1,
                 U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41,
                 U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC;
}
@font-face {
  font-family: 'Cairo';
  src: url('/assets/fonts/cairo-latin.woff2') format('woff2');
  font-weight: 400 700;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
                 U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122,
                 U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Cairo';
  src: url('/assets/fonts/cairo-latin-ext.woff2') format('woff2');
  font-weight: 400 700;
  font-display: swap;
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF,
                 U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0,
                 U+2113, U+2C60-2C7F, U+A720-A7FF;
}

*, *::before, *::after { box-sizing: border-box; }

/* An author rule beats the browser's `[hidden] { display: none }`, so any
   class that sets a display — .field is display:block, .alert, .row — silently
   un-hid every element the templates marked hidden. The registration form's
   group picker was visible before a level had been chosen, and it was only
   luck that the rules added one at a time had caught the others. */
[hidden] { display: none !important; }

html, body { min-height: 100%; }

body {
  margin: 0;
  font-family: 'Cairo', system-ui, -apple-system, 'Segoe UI', sans-serif;
  background: var(--ink-50);
  color: var(--ink-900);
  /* A wide table must scroll inside its own container, never drag the whole
     page sideways — that is what makes a dashboard feel broken on a phone. */
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
}

h1, h2, h3, p, figure { margin: 0; }
ul { margin: 0; padding: 0; list-style: none; }
a { color: inherit; text-decoration: none; }

/* iOS zooms the page in when a focused input is under 16px. Keeping controls
   at 16px on small screens stops that jump without touching the desktop size. */
@media (max-width: 767px) {
  input, select, textarea { font-size: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
}

/* Visible focus for keyboard users, invisible for mouse users. */
:focus-visible {
  outline: 2px solid var(--brand-500);
  outline-offset: 2px;
}

.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ============================================================
   Layout shell
   ============================================================ */

.shell { min-height: 100vh; }

@media (min-width: 768px) {
  .shell { display: flex; }
}

/* ---- mobile top bar: identity + sign-out only ---------------
   Navigation lives in the bottom bar, where a thumb can reach it. */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: .75rem;
  background: var(--ink-900); color: #fff;
  padding: .75rem 1rem;
  padding-top: max(.75rem, env(safe-area-inset-top));
}
.topbar__logo { width: 2rem; height: auto; flex-shrink: 0; }
.topbar__text { min-width: 0; flex: 1; }
.topbar__title { font-weight: 700; font-size: .875rem; line-height: 1.2; }
.topbar__sub { font-size: .6875rem; color: rgba(255,255,255,.5); }
.topbar__title, .topbar__sub { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

@media (min-width: 768px) { .topbar { display: none; } }

/* ---- desktop sidebar ---------------------------------------- */
.sidebar { display: none; }

@media (min-width: 768px) {
  .sidebar {
    display: flex; flex-direction: column;
    width: var(--sidebar-w); flex-shrink: 0;
    background: var(--ink-900); color: #fff;
    min-height: 100vh; position: sticky; top: 0;
  }
}
.sidebar__brand {
  display: flex; align-items: center; gap: .75rem;
  padding: 1.5rem 1.25rem;
}
.sidebar__brand img { width: 2.5rem; height: auto; flex-shrink: 0; }
.sidebar__name { font-weight: 700; line-height: 1.2; }
.sidebar__sub { font-size: .75rem; color: rgba(255,255,255,.5); margin-top: .125rem; }

.sidebar__nav {
  display: flex; flex-direction: column; gap: .25rem;
  padding: 0 .75rem 1.25rem; flex: 1;
}
.navlink {
  display: flex; align-items: center; gap: .625rem;
  padding: .625rem .75rem;
  border-radius: var(--radius-control);
  color: rgba(255,255,255,.7);
  font-size: .875rem;
  transition: background .15s, color .15s;
}
.navlink:hover { background: rgba(255,255,255,.07); color: #fff; }
.navlink[aria-current='page'] {
  background: var(--brand-500); color: #fff; font-weight: 700;
}
.navlink__icon { font-size: 1.05rem; line-height: 1; }
.navlink__badge {
  margin-inline-start: auto;
  background: var(--brand-500); color: #fff;
  font-size: .6875rem; font-weight: 700;
  min-width: 1.25rem; height: 1.25rem;
  border-radius: 999px;
  display: grid; place-items: center; padding: 0 .375rem;
}
.navlink[aria-current='page'] .navlink__badge { background: rgba(0,0,0,.25); }

.sidebar__foot { padding: 0 .75rem 1.25rem; }

/* ---- mobile bottom bar -------------------------------------- */
.bottombar {
  position: fixed; inset-inline: 0; bottom: 0; z-index: 30;
  display: flex; background: #fff;
  border-top: 1px solid var(--ink-200);
  padding-bottom: env(safe-area-inset-bottom);
}

@media (min-width: 768px) { .bottombar { display: none; } }

/* Five equal tabs that always fit, rather than ten that never did. */
.bottombar .navlink {
  flex-direction: column; gap: .125rem;
  flex: 1 1 0; min-width: 0;
  padding: .5rem .25rem;
  color: var(--ink-500);
  font-size: .6875rem;
  border-radius: 0;
  position: relative;
  background: none; border: 0; font-family: inherit; cursor: pointer;
  text-align: center;
}
.bottombar .navlink > span:last-child {
  max-width: 100%; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap;
}
.bottombar .navlink[aria-current='page'] {
  background: none; color: var(--brand-600);
}
.bottombar .navlink[aria-current='page']::before {
  content: ''; position: absolute; top: 0; inset-inline: .75rem;
  height: 2px; background: var(--brand-500);
}
.bottombar .navlink__icon { font-size: 1.25rem; }
.bottombar .navlink__badge {
  position: absolute; top: .25rem; inset-inline-end: 50%;
  transform: translateX(50%) translateX(1rem);
  margin: 0;
}

/* ---- main column -------------------------------------------- */
.main {
  flex: 1; min-width: 0;
  padding: 1.25rem 1rem calc(var(--bottombar-h) + 1.5rem);
}
@media (min-width: 768px) {
  .main { padding: 2rem; }
}

.page-head { margin-bottom: 1.25rem; }
.page-head h1 { font-size: 1.375rem; font-weight: 700; }
.page-head p { color: var(--ink-500); font-size: .875rem; margin-top: .25rem; }

/* ============================================================
   Cards, tables, forms
   ============================================================ */

.card {
  background: #fff;
  border: 1px solid var(--ink-200);
  border-radius: var(--radius-card);
  padding: 1.25rem;
}
.card + .card { margin-top: 1rem; }
.card__title {
  font-weight: 700; font-size: 1rem; margin-bottom: .875rem;
  display: flex; align-items: center; gap: .5rem;
}

/* auto-fit rather than fixed breakpoints.
   The sidebar eats 16rem, so a 1000px laptop leaves ~700px of content — under
   the old 1024px breakpoint, which meant four stat tiles stacked into a
   column of four on the most common screen the academy actually uses. */
.grid { display: grid; gap: 1rem; }
.grid--2 { grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr)); }
.grid--3 { grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr)); }
.grid--4 { grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr)); }

/* ---- stat tile ---------------------------------------------- */
.stat {
  background: #fff; border: 1px solid var(--ink-200);
  border-radius: var(--radius-card); padding: 1rem 1.125rem;
}
.stat__label { font-size: .8125rem; color: var(--ink-500); }
.stat__value { font-size: 1.75rem; font-weight: 700; line-height: 1.15; margin-top: .25rem; }
.stat__hint  { font-size: .75rem; color: var(--ink-400); margin-top: .25rem; }

/* ---- table --------------------------------------------------
   Always inside .table-wrap: a wide table scrolls in its own box rather than
   pushing the page sideways. */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--ink-200);
  border-radius: var(--radius-card);
  background: #fff;
}
table { width: 100%; border-collapse: collapse; font-size: .875rem; }
thead th {
  background: var(--ink-100);
  text-align: start; font-weight: 700; font-size: .8125rem;
  color: var(--ink-600);
  padding: .625rem .75rem;
  white-space: nowrap;
  position: sticky; top: 0; z-index: 1;
}
tbody td { padding: .625rem .75rem; border-top: 1px solid var(--ink-100); }
tbody tr:hover { background: var(--ink-50); }
td.num, th.num { text-align: center; font-variant-numeric: tabular-nums; }

/* ---- forms --------------------------------------------------- */
.field { display: block; margin-bottom: .875rem; }
.field__label {
  display: block; font-size: .8125rem; font-weight: 700;
  color: var(--ink-700); margin-bottom: .375rem;
}
.field__hint { font-size: .75rem; color: var(--ink-400); margin-top: .25rem; }

/* Every text-ish input is listed by type rather than styled as a bare
   `input`, so that checkboxes and radios keep the browser's own look. The
   cost is that a type missing from this list renders as an unstyled 130px
   box — which is exactly what `url` did on the settings page until it was
   added here. Adding a new input type means adding it here too. */
input[type='text'], input[type='tel'], input[type='password'],
input[type='number'], input[type='date'], input[type='datetime-local'],
input[type='search'], input[type='url'], input[type='email'],
select, textarea {
  width: 100%;
  padding: .5625rem .75rem;
  border: 1px solid var(--ink-300);
  border-radius: var(--radius-control);
  background: #fff;
  color: inherit;
  font: inherit;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--brand-500);
  box-shadow: 0 0 0 3px var(--brand-100);
}
input:disabled, select:disabled, textarea:disabled {
  background: var(--ink-100); color: var(--ink-400); cursor: not-allowed;
}
textarea { min-height: 7rem; resize: vertical; line-height: 1.7; }

.row { display: flex; flex-wrap: wrap; gap: .75rem; align-items: flex-end; }

/* min-width:0 is not optional here.
   A flex item refuses to shrink below its content's min-content width, and
   <input type="datetime-local"> reports a very wide one — so a row holding a
   date field wrapped onto two lines even when the two fields fit side by side
   with room to spare. Every .row in the app was affected. */
.row > * { flex: 1 1 12rem; min-width: 0; }
.row > .row__fit { flex: 0 0 auto; }

/* ---- buttons -------------------------------------------------
   min-height 44px everywhere: below that a control is genuinely hard to hit
   on a phone, and this dashboard is used on phones. */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: .5rem;
  min-height: 2.75rem; padding: .5rem 1.125rem;
  border: 1px solid transparent;
  border-radius: var(--radius-control);
  font: inherit; font-weight: 700; font-size: .875rem;
  cursor: pointer;
  transition: background .15s, border-color .15s, opacity .15s;
}
.btn:disabled { opacity: .55; cursor: not-allowed; }

.btn--primary { background: var(--brand-500); color: #fff; }
.btn--primary:hover:not(:disabled) { background: var(--brand-600); }

.btn--ghost { background: #fff; border-color: var(--ink-300); color: var(--ink-700); }
.btn--ghost:hover:not(:disabled) { background: var(--ink-100); }

.btn--danger { background: var(--danger); color: #fff; }
.btn--danger:hover:not(:disabled) { filter: brightness(.92); }

.btn--dark { background: var(--ink-900); color: #fff; }
.btn--dark:hover:not(:disabled) { background: var(--ink-700); }

.btn--sm { min-height: 2.25rem; padding: .3125rem .75rem; font-size: .8125rem; }
.btn--block { width: 100%; }

/* ---- badges --------------------------------------------------- */
.badge {
  display: inline-flex; align-items: center; gap: .25rem;
  padding: .1875rem .5rem;
  border-radius: 999px;
  font-size: .75rem; font-weight: 700;
  white-space: nowrap;
}
.badge--pending   { background: var(--ink-100);  color: var(--ink-600); }
.badge--submitted { background: #e7f0fa;         color: var(--info); }
.badge--grading   { background: #fdf4ea;         color: var(--brand-700); }
.badge--graded    { background: #e6f4ed;         color: var(--ok); }
.badge--missed    { background: #f9e9e8;         color: var(--danger); }

/* ---- alerts ---------------------------------------------------- */
.alert {
  border-radius: var(--radius-control);
  padding: .75rem 1rem;
  font-size: .875rem;
  margin-bottom: 1rem;
  border: 1px solid transparent;
}
.alert--error   { background: #f9e9e8; border-color: #f0cfcd; color: #8c2f2b; }
.alert--ok      { background: #e6f4ed; border-color: #c6e6d5; color: #1d6b45; }
.alert--info    { background: #e7f0fa; border-color: #cadff5; color: #1f5b98; }
.alert--warn    { background: #fdf4ea; border-color: #f5dcbd; color: var(--brand-700); }

/* ---- empty state ------------------------------------------------ */
.empty {
  text-align: center; padding: 3rem 1rem; color: var(--ink-400);
}
.empty__icon { font-size: 2.5rem; display: block; margin-bottom: .5rem; opacity: .55; }

/* ============================================================
   Auth pages
   ============================================================
   The academy's own look: the page ground, the logo standing above the card
   rather than boxed inside it. A dark gradient here belonged to a different
   product — every other screen of this app is light. */
.auth {
  min-height: 100vh;
  display: grid; place-items: center;
  padding: 2.5rem 1rem;
  background: var(--ink-50);
}
.auth__inner { width: 100%; max-width: 26rem; }

.auth__brand { text-align: center; margin-bottom: 2rem; }
.auth__brand img { width: 6rem; height: auto; margin: 0 auto 1rem; display: block; }
.auth__brand h1 { font-size: 1.5rem; font-weight: 700; }
.auth__brand p { color: var(--ink-500); margin-top: .25rem; }

.auth__card {
  background: #fff;
  border: 1px solid var(--ink-200);
  border-radius: var(--radius-card);
  padding: 1.5rem;
}
.auth__foot {
  text-align: center; font-size: .875rem;
  color: var(--ink-500); margin-top: 1.25rem;
}
.auth__foot a { color: var(--brand-600); font-weight: 700; }
.auth__foot a:hover { text-decoration: underline; }

/* The phone number and a sub-teacher's username are both Latin, so the box
   reads left-to-right even though the page does not. */
.auth input[dir='ltr'] { text-align: left; }

/* ============================================================
   Homework cards (student)
   ============================================================ */
.hw {
  background: #fff; border: 1px solid var(--ink-200);
  border-radius: var(--radius-card); padding: 1.125rem;
}
.hw + .hw { margin-top: .875rem; }
.hw--done { border-inline-start: 4px solid var(--ok); }
.hw--late { border-inline-start: 4px solid var(--danger); }
.hw--open { border-inline-start: 4px solid var(--brand-500); }

.hw__head { display: flex; align-items: flex-start; gap: .75rem; flex-wrap: wrap; }
.hw__title { font-weight: 700; flex: 1; min-width: 0; }
.hw__meta  { font-size: .8125rem; color: var(--ink-500); margin-top: .25rem; }
.hw__part {
  border: 1px solid var(--ink-200); border-radius: var(--radius-control);
  padding: .875rem; margin-top: .75rem;
}
.hw__part-no {
  font-size: .75rem; font-weight: 700; color: var(--brand-600);
  margin-bottom: .375rem;
}
.hw__prompt { font-size: .875rem; line-height: 1.7; margin-bottom: .625rem; white-space: pre-wrap; }

/* ---- feedback block ------------------------------------------- */
.feedback {
  background: var(--brand-50); border: 1px solid var(--brand-100);
  border-radius: var(--radius-control);
  padding: .75rem .875rem; margin-top: .75rem;
  font-size: .875rem; line-height: 1.7;
}
.feedback__title { font-weight: 700; color: var(--brand-700); margin-bottom: .25rem; }

.words { display: flex; flex-wrap: wrap; gap: .25rem; margin-top: .5rem; }
.words__chip {
  font-size: .75rem; padding: .125rem .5rem; border-radius: 999px;
  background: #fff; border: 1px solid var(--ink-200);
}
.words__chip--miss { background: #f9e9e8; border-color: #f0cfcd; color: #8c2f2b; }
.words__chip--hit  { background: #e6f4ed; border-color: #c6e6d5; color: #1d6b45; }

/* ============================================================
   Audio recorder
   ============================================================ */
.rec { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; }
.rec__btn {
  width: 3rem; height: 3rem; border-radius: 999px;
  border: none; cursor: pointer;
  background: var(--danger); color: #fff;
  font-size: 1.125rem;
  display: grid; place-items: center;
}
.rec__btn--stop { background: var(--ink-900); }
.rec__btn:disabled { opacity: .5; cursor: not-allowed; }
.rec__time {
  font-variant-numeric: tabular-nums; font-weight: 700;
  min-width: 3.5rem;
}
.rec__dot {
  width: .625rem; height: .625rem; border-radius: 999px;
  background: var(--danger);
  animation: pulse 1.2s ease-in-out infinite;
}
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .25; } }
.rec audio { flex: 1 1 12rem; min-width: 0; height: 2.5rem; }

/* ============================================================
   Progress table — the one screen that stays interactive
   ============================================================ */
.progress-table th:first-child,
.progress-table td:first-child {
  position: sticky; inset-inline-start: 0; z-index: 2;
  background: #fff;
  border-inline-end: 1px solid var(--ink-200);
  min-width: 9rem;
}
.progress-table thead th:first-child { background: var(--ink-100); z-index: 3; }
.progress-table tbody tr:hover td:first-child { background: var(--ink-50); }

/* input.cell-input, not .cell-input.
   The base rule is `input[type='number'], …` — a type+attribute selector,
   which outranks a lone class. Every cell input was silently keeping the
   full-size control styling: 96px wide and 46px tall inside a table cell
   meant to hold two digits. */
input.cell-input, select.cell-input {
  width: 3.5rem; min-width: 0; padding: .25rem .375rem;
  text-align: center; font-size: .8125rem;
  border: 1px solid var(--ink-200); background: #fff;
  border-radius: 6px;
}
select.cell-input { width: auto; text-align: start; }
input.cell-input:hover, select.cell-input:hover { border-color: var(--ink-300); }
input.cell-input:focus, select.cell-input:focus {
  border-color: var(--brand-500);
  box-shadow: 0 0 0 3px var(--brand-100);
}
/* Chrome's number spinners are wider than the field they sit in. */
input.cell-input::-webkit-outer-spin-button,
input.cell-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
input.cell-input[type='number'] { -moz-appearance: textfield; appearance: textfield; }

/* Save bar that appears once something is edited. */
.savebar {
  position: sticky; bottom: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem;
  background: var(--ink-900); color: #fff;
  padding: .75rem 1rem;
  border-radius: var(--radius-control);
  margin-top: 1rem;
}

/* ---- toast ---------------------------------------------------- */
.toast {
  position: fixed; z-index: 60;
  bottom: calc(var(--bottombar-h) + 1rem);
  inset-inline: 1rem;
  background: var(--ink-900); color: #fff;
  padding: .75rem 1rem; border-radius: var(--radius-control);
  font-size: .875rem; text-align: center;
  box-shadow: 0 10px 30px -10px rgba(0,0,0,.5);
}
@media (min-width: 768px) {
  .toast { inset-inline: auto 2rem; bottom: 2rem; max-width: 22rem; }
}
.toast--error { background: var(--danger); }
.toast--ok    { background: var(--ok); }

/* ---- utility -------------------------------------------------- */
.muted   { color: var(--ink-500); }
.small   { font-size: .8125rem; }
.strong  { font-weight: 700; }
.nowrap  { white-space: nowrap; }
.mt-1 { margin-top: .5rem; }  .mt-2 { margin-top: 1rem; }
.mb-1 { margin-bottom: .5rem; } .mb-2 { margin-bottom: 1rem; }
.flex { display: flex; gap: .5rem; align-items: center; }
.flex--between { justify-content: space-between; }
.flex--wrap { flex-wrap: wrap; }
.spacer { flex: 1; }

/* ---- a homework the teacher has not opened yet -------------------
   Visible on purpose: the student can read the term ahead. Muted, not
   disabled-looking, because there is nothing wrong with it. */
.hw--locked { border-inline-start: 4px solid var(--ink-300); }
.hw--locked .hw__title { color: var(--ink-600); }
.hw__part--locked { background: var(--ink-50); border-style: dashed; }
.hw__part--locked .hw__prompt { color: var(--ink-600); }

.hw__session {
  display: inline-block;
  font-size: .6875rem; font-weight: 700;
  background: var(--ink-100); color: var(--ink-600);
  padding: .125rem .5rem; border-radius: 999px;
  margin-inline-end: .375rem;
  vertical-align: middle;
}

/* ---- teacher's term planner ---------------------------------- */
.plan__row {
  border: 1px solid var(--ink-200);
  border-radius: var(--radius-card);
  background: #fff;
  margin-bottom: .75rem;
  overflow: hidden;
}
.plan__head {
  display: flex; align-items: center; gap: .75rem; flex-wrap: wrap;
  padding: .875rem 1rem;
  cursor: pointer;
  background: var(--ink-50);
}
.plan__head:hover { background: var(--ink-100); }
.plan__no {
  width: 2rem; height: 2rem; flex-shrink: 0;
  display: grid; place-items: center;
  border-radius: 999px;
  background: var(--ink-900); color: #fff;
  font-weight: 700; font-size: .8125rem;
}
.plan__row--open .plan__no { background: var(--brand-500); }
.plan__row--empty .plan__no { background: var(--ink-300); color: var(--ink-600); }
.plan__title { flex: 1; min-width: 0; font-weight: 700; }
.plan__title span { font-weight: 400; color: var(--ink-400); }
.plan__body { padding: 1rem; border-top: 1px solid var(--ink-200); }

/* the open/close switch */
.switch { display: inline-flex; align-items: center; gap: .5rem; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch__track {
  width: 2.75rem; height: 1.5rem; border-radius: 999px;
  background: var(--ink-300); position: relative;
  transition: background .15s;
}
.switch__track::after {
  content: ''; position: absolute; top: 3px; inset-inline-start: 3px;
  width: 1.125rem; height: 1.125rem; border-radius: 999px; background: #fff;
  transition: transform .15s;
}
.switch input:checked + .switch__track { background: var(--ok); }
.switch input:checked + .switch__track::after { transform: translateX(-1.25rem); }
.switch input:disabled + .switch__track { opacity: .5; }
.switch__label { font-size: .8125rem; font-weight: 700; }

/* audio settings inside a part */
.audio-opts {
  display: flex; flex-wrap: wrap; gap: .5rem; align-items: flex-end;
  margin-top: .625rem; padding-top: .625rem;
  border-top: 1px dashed var(--ink-200);
}
.audio-opts label { margin: 0; }
.audio-opts select, .audio-opts input { min-width: 7rem; }


/* ============================================================
   The "more" sheet — the pages that do not fit the phone bar
   ============================================================ */
.sheet {
  position: fixed; inset: 0; z-index: 40;
  display: flex; align-items: flex-end;
}

.sheet__backdrop {
  position: absolute; inset: 0;
  background: rgba(0, 0, 0, .45);
  animation: sheet-fade .15s ease-out;
}
.sheet__panel {
  position: relative; width: 100%;
  background: #fff;
  border-radius: var(--radius-card) var(--radius-card) 0 0;
  padding: .5rem .75rem calc(.75rem + env(safe-area-inset-bottom));
  max-height: 80vh; overflow-y: auto;
  animation: sheet-up .18s ease-out;
}
.sheet__grip {
  width: 2.5rem; height: .25rem; border-radius: 999px;
  background: var(--ink-300);
  margin: .375rem auto .625rem;
}
.navlink--sheet { color: var(--ink-700); font-size: .9375rem; }
.sheet .navlink { color: var(--ink-700); }
.sheet .navlink:hover { background: var(--ink-100); color: var(--ink-900); }
.sheet .navlink[aria-current='page'] { background: var(--brand-500); color: #fff; }
.sheet .navlink__badge { background: var(--brand-500); }
.sheet form button { color: var(--ink-700) !important; }

@keyframes sheet-up   { from { transform: translateY(100%); } }
@keyframes sheet-fade { from { opacity: 0; } }

@media (min-width: 768px) { .sheet { display: none !important; } }

/* ============================================================
   Small corrections found reviewing the pages
   ============================================================ */

/* A field with a hint under it is taller than one without, and flex-end
   aligned their BOTTOMS — so in a row of two, one input sat 30px lower than
   the other. Aligning the tops lines the inputs up; a hint simply hangs
   below its own field. */
.row { align-items: flex-start; }
.row > .btn { margin-top: 1.6rem; }   /* clears the label line beside it */

/* A wide table scrolls inside its box, but on a mouse there was nothing to
   say so. A shadow on the scrolling edge, drawn only while there is more to
   reach. */
.table-wrap {
  background:
    linear-gradient(to left, #fff 30%, rgba(255,255,255,0)) left center / 2.5rem 100% no-repeat,
    linear-gradient(to left, rgba(0,0,0,.10), rgba(0,0,0,0)) left center / .75rem 100% no-repeat,
    #fff;
  background-attachment: local, scroll, local;
}

/* Colour swatches for a teacher's colour, instead of a dropdown of hex codes
   that RTL rendered back to front ("e4903c#"). */
.swatches { display: flex; flex-wrap: wrap; gap: .5rem; }
.swatch { position: relative; cursor: pointer; }
.swatch input { position: absolute; opacity: 0; width: 0; height: 0; }
.swatch span {
  display: block; width: 2rem; height: 2rem;
  border-radius: 999px;
  border: 2px solid transparent;
  box-shadow: inset 0 0 0 2px #fff;
}
.swatch input:checked + span { border-color: var(--ink-900); }
.swatch input:focus-visible + span { outline: 2px solid var(--brand-500); outline-offset: 2px; }

/* A score badge with no score is not a success — it is an absence. */
.badge--none { background: var(--ink-100); color: var(--ink-400); }

/* The planner's header wrapped mid-phrase on a phone. */
.plan__title { line-height: 1.5; }
.plan__title span { display: block; font-size: .8125rem; }
.plan__head [aria-hidden] { font-size: 1rem; color: var(--ink-400); }
