/* Rubik (SIL OFL 1.1, see fonts/OFL.txt), self-hosted: Hebrew and Latin subsets. */
@font-face {
  font-family: 'Rubik';
  font-style: normal;
  font-display: swap;
  font-weight: 400;
  src: url(../fonts/rubik-hebrew-400.woff2) format('woff2');
  unicode-range: U+0307-0308,U+0590-05FF,U+200C-2010,U+20AA,U+25CC,U+FB1D-FB4F;
}
@font-face {
  font-family: 'Rubik';
  font-style: normal;
  font-display: swap;
  font-weight: 500;
  src: url(../fonts/rubik-hebrew-500.woff2) format('woff2');
  unicode-range: U+0307-0308,U+0590-05FF,U+200C-2010,U+20AA,U+25CC,U+FB1D-FB4F;
}
@font-face {
  font-family: 'Rubik';
  font-style: normal;
  font-display: swap;
  font-weight: 700;
  src: url(../fonts/rubik-hebrew-700.woff2) format('woff2');
  unicode-range: U+0307-0308,U+0590-05FF,U+200C-2010,U+20AA,U+25CC,U+FB1D-FB4F;
}
@font-face {
  font-family: 'Rubik';
  font-style: normal;
  font-display: swap;
  font-weight: 400;
  src: url(../fonts/rubik-latin-400.woff2) format('woff2');
  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: 'Rubik';
  font-style: normal;
  font-display: swap;
  font-weight: 500;
  src: url(../fonts/rubik-latin-500.woff2) format('woff2');
  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: 'Rubik';
  font-style: normal;
  font-display: swap;
  font-weight: 700;
  src: url(../fonts/rubik-latin-700.woff2) format('woff2');
  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;
}

:root {
  --bg: #f4f6fa;
  --surface: #ffffff;
  --surface-2: #f0f3f8;
  --text: #1d2433;
  --muted: #66708a;
  --border: #dde2ec;
  --primary: #3b6fd8;
  --primary-text: #ffffff;
  --primary-soft: #e6eefc;
  --success: #1f9a6f;
  --success-soft: #e1f5ec;
  --warning: #b7791f;
  --warning-soft: #fdf2dc;
  --danger: #c93c3c;
  --danger-soft: #fbe5e5;
  --purple: #7a4fd0;
  --purple-soft: #efe8fc;
  --radius: 12px;
  --shadow: 0 1px 2px rgb(20 30 60 / 6%), 0 2px 8px rgb(20 30 60 / 5%);
  --font: 'Rubik', 'Segoe UI', 'Arial Hebrew', Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --bg: #12161f;
    --surface: #1b212d;
    --surface-2: #232b3a;
    --text: #e6e9f0;
    --muted: #97a1b8;
    --border: #2f3849;
    --primary: #6d97ee;
    --primary-text: #0d1320;
    --primary-soft: #23324f;
    --success: #4cc59a;
    --success-soft: #173a2e;
    --warning: #e2a94b;
    --warning-soft: #3a2f17;
    --danger: #ee7373;
    --danger-soft: #3d1f22;
    --purple: #ab8cf0;
    --purple-soft: #2e2547;
    --shadow: none;
  }
}

:root[data-theme='dark'] {
  --bg: #12161f;
  --surface: #1b212d;
  --surface-2: #232b3a;
  --text: #e6e9f0;
  --muted: #97a1b8;
  --border: #2f3849;
  --primary: #6d97ee;
  --primary-text: #0d1320;
  --primary-soft: #23324f;
  --success: #4cc59a;
  --success-soft: #173a2e;
  --warning: #e2a94b;
  --warning-soft: #3a2f17;
  --danger: #ee7373;
  --danger-soft: #3d1f22;
  --purple: #ab8cf0;
  --purple-soft: #2e2547;
  --shadow: none;
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 { line-height: 1.25; margin: 0 0 .6em; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1rem; margin-top: 1.1em; color: var(--muted); font-weight: 500; }

hr { border: 0; border-top: 1px solid var(--border); margin: 1.5rem 0; }

.muted { color: var(--muted); }
.small { font-size: .875rem; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
[hidden] { display: none !important; } /* a .field (display: flex) must still hide */
.error-text { color: var(--danger); }
.overdue { color: var(--danger); }

/* ------------------------------------------------------------ header */

.app-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}
.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: .6rem 16px;
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}
.brand { font-weight: 700; font-size: 1.15rem; color: var(--text); }
.brand:hover { text-decoration: none; }
#nav { display: flex; gap: .25rem; flex-wrap: wrap; flex: 1; }
#nav a {
  padding: .35rem .75rem;
  border-radius: 999px;
  color: var(--muted);
  font-weight: 500;
  white-space: nowrap;
}
#nav a:hover { background: var(--surface-2); text-decoration: none; }
#nav a.active { background: var(--primary-soft); color: var(--primary); }

.status { font-size: .85rem; padding: .25rem .6rem; border-radius: 999px; border: 0; font: inherit; font-size: .85rem; }
.status.ok { color: var(--success); background: var(--success-soft); }
.status.pending { color: var(--muted); background: var(--surface-2); }
.status.error { color: var(--danger); background: var(--danger-soft); }
button.status { cursor: pointer; }
.link-btn { background: none; border: 0; color: inherit; text-decoration: underline; cursor: pointer; font: inherit; padding: 0; }

/* ------------------------------------------------------------ layout */

.container { max-width: 1200px; margin: 0 auto; padding: 1rem 16px 4rem; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.1rem 1.25rem;
  margin-bottom: 1rem;
  min-width: 0;
}
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: .5rem; }
.card-head h2 { margin: 0; }

.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.grid-2 > .card { margin-bottom: 0; }
.grid-2 + .card, .card + .grid-2 { margin-top: 1rem; }
.student-grid .col > .card { margin-bottom: 1rem; }
@media (max-width: 820px) {
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
}

.welcome { max-width: 620px; margin: 2rem auto; }
.welcome-card { text-align: center; padding: 2rem; }

.count {
  display: inline-block;
  min-width: 1.6em;
  padding: 0 .45em;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: .8rem;
  font-weight: 500;
  text-align: center;
  vertical-align: middle;
}

.empty { padding: 1rem; text-align: center; color: var(--muted); background: var(--surface-2); border-radius: 8px; }
.empty-action { margin-top: .75rem; }

/* ------------------------------------------------------------ forms & buttons */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .35rem;
  padding: .5rem 1rem;
  border-radius: 8px;
  border: 1px solid var(--primary);
  background: var(--primary);
  color: var(--primary-text);
  font: inherit;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover { filter: brightness(1.06); text-decoration: none; }
.btn.secondary { background: var(--surface); color: var(--primary); }
.btn.danger { background: var(--surface); color: var(--danger); border-color: var(--danger); }
.btn.small { padding: .3rem .7rem; font-size: .875rem; }
.file-btn { position: relative; }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--muted);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  padding: .3rem .4rem;
  min-width: 44px; /* a touch target */
  min-height: 44px;
}
.icon-btn:hover:not(:disabled) { background: var(--surface-2); color: var(--text); }
.icon-btn:disabled { opacity: .3; cursor: default; }
.contact-buttons { display: inline-flex; align-items: center; gap: 8px; flex: none; }

input, select, textarea {
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: .45rem .6rem;
  width: 100%;
  min-width: 0;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus, .btn:focus-visible, .icon-btn:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
}
input[type='checkbox'] { width: auto; accent-color: var(--primary); width: 1.05rem; height: 1.05rem; margin: 0; flex: none; }

.field { display: flex; flex-direction: column; gap: .25rem; margin-bottom: .75rem; flex: 1; min-width: 140px; }
.field > span { font-size: .85rem; color: var(--muted); }
.field.narrow { flex: 0 0 110px; min-width: 110px; }
.field.grow { flex: 3; }
.field.inline { flex-direction: row; align-items: center; gap: .6rem; margin-top: .25rem; }
.field.inline > span { white-space: nowrap; }
.field-row { display: flex; gap: .75rem; flex-wrap: wrap; align-items: flex-end; }
.field-row > .btn, .field-row > .check { margin-bottom: .75rem; }
.field-row .hint { flex: 2; margin: 0 0 .9rem; min-width: 200px; }
fieldset { border: 1px solid var(--border); border-radius: 8px; margin: 0 0 .75rem; padding: .5rem .75rem; }
legend { color: var(--muted); font-size: .85rem; padding: 0 .3rem; }
fieldset .check { margin: .3rem 0; }
.form-actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.toolbar { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.toolbar input[type='search'] { width: 220px; }
.days { display: flex; gap: 1rem; flex-wrap: wrap; }

.check { display: inline-flex; align-items: flex-start; gap: .5rem; cursor: pointer; }
.check > input { margin-top: .2rem; }
.check.grow { flex: 1; min-width: 0; }

details > summary { cursor: pointer; color: var(--primary); margin: .4rem 0; }
details.contact { margin-top: .5rem; }
.contact-body { padding: .5rem 0; display: grid; gap: .35rem; }
.phones { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: .25rem 1.25rem; }
.danger-zone { display: flex; gap: .5rem; flex-wrap: wrap; border-top: 1px dashed var(--border); padding-top: .75rem; }

/* ------------------------------------------------------------ badges */

.badge {
  display: inline-block;
  padding: .05rem .5rem;
  border-radius: 999px;
  font-size: .75rem;
  font-weight: 500;
  background: var(--surface-2);
  color: var(--muted);
  white-space: nowrap;
  vertical-align: middle;
}
.badges { display: inline-flex; gap: .3rem; flex-wrap: wrap; }
.badges.small { margin-top: .2rem; }
.badge.warning { background: var(--warning-soft); color: var(--warning); }
.badge.danger { background: var(--danger-soft); color: var(--danger); }
.badge.kind-scheduled, .badge.owner-teacher, .badge.scope-everyone { background: var(--primary-soft); color: var(--primary); }
.badge.kind-checkup, .badge.owner-student { background: var(--purple-soft); color: var(--purple); }
.badge.kind-suggested { background: var(--surface-2); color: var(--muted); }
.badge.scope-class { background: var(--success-soft); color: var(--success); }
.badge.scope-student { background: var(--warning-soft); color: var(--warning); }
.badge.type-discipline { background: var(--danger-soft); color: var(--danger); }
.badge.type-checkup { background: var(--purple-soft); color: var(--purple); }
.badge.type-academic { background: var(--success-soft); color: var(--success); }

/* ------------------------------------------------------------ dashboard */

.stats-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .75rem; margin-bottom: 1rem; }
.stats-row.compact { grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); }
.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .8rem 1rem;
  display: flex;
  flex-direction: column;
}
.card .stat { background: var(--surface-2); border-color: transparent; }
.stat-value { font-size: 1.6rem; font-weight: 700; }
.stat-label { color: var(--muted); font-size: .85rem; }
.stat.warn .stat-value { color: var(--danger); }

.suggestions, .simple-list, .bar-list, .goal-list, .goal-items, .meetings, .import-list, .goal-matrix { list-style: none; padding: 0; margin: 0; }

.suggestion {
  display: grid;
  grid-template-columns: 110px 1fr auto;
  gap: .75rem;
  align-items: center;
  padding: .65rem 0;
  border-bottom: 1px solid var(--border);
}
.suggestion:last-child { border-bottom: 0; }
.suggestion-date { display: flex; flex-direction: column; line-height: 1.3; }
.suggestion-actions { display: flex; gap: .35rem; }
.pending-actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .4rem; } /* four buttons wrap on a narrow screen instead of overflowing */
.suggestion.missed .suggestion-date strong { color: var(--danger); }
@media (max-width: 520px) {
  .suggestion { grid-template-columns: 1fr; gap: .3rem; }
  .suggestion-date { flex-direction: row; gap: .5rem; flex-wrap: wrap; }
}

.simple-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: .5rem;
  padding: .45rem 0;
  border-bottom: 1px solid var(--border);
}
.simple-list li:last-child { border-bottom: 0; }
.simple-list li.is-done { color: var(--muted); }

.bar-list li { padding: .45rem 0; }
.bar-head { display: flex; justify-content: space-between; gap: .5rem; align-items: baseline; }
.progress { height: 8px; background: var(--surface-2); border-radius: 999px; overflow: hidden; margin-top: .3rem; }
.card .progress { background: var(--border); }
.progress-fill { height: 100%; border-radius: 999px; transition: width .3s; }
.progress-fill.good { background: var(--success); }
.progress-fill.mid { background: var(--warning); }
.progress-fill.low { background: var(--danger); }
/* Bar widths in steps of 5% (the CSP forbids inline style=). */
.pct-0 { width: 0%; }
.pct-5 { width: 5%; }
.pct-10 { width: 10%; }
.pct-15 { width: 15%; }
.pct-20 { width: 20%; }
.pct-25 { width: 25%; }
.pct-30 { width: 30%; }
.pct-35 { width: 35%; }
.pct-40 { width: 40%; }
.pct-45 { width: 45%; }
.pct-50 { width: 50%; }
.pct-55 { width: 55%; }
.pct-60 { width: 60%; }
.pct-65 { width: 65%; }
.pct-70 { width: 70%; }
.pct-75 { width: 75%; }
.pct-80 { width: 80%; }
.pct-85 { width: 85%; }
.pct-90 { width: 90%; }
.pct-95 { width: 95%; }
.pct-100 { width: 100%; }

/* ------------------------------------------------------------ tables */

.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: start; padding: .55rem .5rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table th { color: var(--muted); font-weight: 500; font-size: .85rem; }
.table tr.inactive { opacity: .6; }
.student-link { font-weight: 500; }
@media (max-width: 640px) {
  .table thead { display: none; }
  .table tr { display: block; padding: .5rem 0; border-bottom: 1px solid var(--border); }
  .table td { display: flex; justify-content: space-between; border: 0; padding: .15rem 0; }
  .table td[data-label]::before { content: attr(data-label); color: var(--muted); font-size: .85rem; }
}

/* ------------------------------------------------------------ student page */

.student-title { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap; }
.student-title h1 { margin-bottom: .2rem; }
.meeting-form { border-color: var(--primary); }
.next-meeting { background: var(--surface-2); border-radius: 8px; padding: .6rem .8rem; margin-bottom: .75rem; }

.topics { list-style: none; padding: 0; margin: .25rem 0 0; counter-reset: topic; }
.topic {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .45rem .4rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: .4rem;
  background: var(--surface);
}
.topic.editing { display: block; }
.topic.editing .field-row { align-items: center; }
.topic.editing .field-row > * { margin: 0; }
.topic.editing input { flex: 1; }
.topic.dragging { opacity: .4; }
.topic.drop-target { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary-soft); }
.drag-handle { cursor: grab; color: var(--muted); user-select: none; letter-spacing: -2px; padding: 0 .2rem; }
.row-actions { display: inline-flex; gap: .1rem; flex: none; }

.goal-check {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .25rem .75rem;
  padding: .5rem 0;
  border-bottom: 1px solid var(--border);
}
.goal-check:last-child { border-bottom: 0; }
.goal-check.is-done .goal-title { color: var(--muted); text-decoration: line-through; }
.goal-check.is-done.recurring .goal-title { text-decoration: none; }
.goal-status { font-size: .8rem; color: var(--muted); }
.goal-status.overdue { color: var(--danger); }
.goal-desc { flex-basis: 100%; font-size: .85rem; color: var(--muted); padding-inline-start: 1.6rem; }
.add-goal { margin-top: .75rem; }
.add-goal form { margin-top: .5rem; }

.meeting { padding: .75rem 0; border-bottom: 1px solid var(--border); }
.meeting:last-child { border-bottom: 0; }
.meeting-head { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.meeting-head .row-actions { margin-inline-start: auto; }
.meeting-summary { white-space: pre-wrap; margin-top: .35rem; overflow-wrap: anywhere; }
.meeting-extras { margin-top: .35rem; display: grid; gap: .15rem; }
.notes { min-height: 120px; }

/* ------------------------------------------------------------ goals page */

.goal-item { padding: .75rem 0; border-bottom: 1px solid var(--border); }
.goal-item:last-child { border-bottom: 0; }
.goal-item.archived { opacity: .6; }
.goal-item-head { display: flex; justify-content: space-between; gap: .5rem; align-items: flex-start; }
.goal-item .goal-list { margin-top: .25rem; }
.goal-matrix { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: .35rem 1rem; padding: .25rem 0; }
.goal-matrix li.is-overdue { color: var(--danger); }
.goal-edit { background: var(--surface-2); padding: .75rem; border-radius: 8px; }
.goal-item-head > div:first-child { min-width: 0; overflow-wrap: anywhere; }
.goal-item .badges { display: flex; flex-wrap: wrap; gap: .3rem; margin: .2rem 0; }
.goal-check { display: flex; flex-wrap: wrap; align-items: center; gap: .25rem .75rem; }
.goal-check .check, .goal-matrix .check, .days .check { min-height: 44px; align-items: center; } /* touch targets */
.show-archived { min-height: 44px; align-items: center; }
.per-student > summary { min-height: 44px; display: flex; align-items: center; cursor: pointer; }
.student-heading a { display: inline-flex; align-items: center; min-height: 44px; }
.card form input:not([type="checkbox"]):not([type="radio"]), .card form select { min-height: 44px; }
.goal-check .check > input, .goal-matrix .check > input, .days .check > input { margin-top: 0; }
.goal-status.overdue { color: var(--danger); }
.goal-adherence { flex-basis: 100%; }
.goal-edit .form-actions { margin-top: .5rem; }
@media (max-width: 480px) {
  .goal-matrix { grid-template-columns: minmax(0, 1fr); }
  .recurrence .field.narrow { flex: 1 1 110px; }
}

.import-list { max-height: 420px; overflow: auto; margin: .75rem 0; border: 1px solid var(--border); border-radius: 8px; }
.import-list li { padding: .4rem .75rem; border-bottom: 1px solid var(--border); }
.import-list li:last-child { border-bottom: 0; }
.import-list .check > span { display: flex; flex-wrap: wrap; gap: .25rem .6rem; align-items: center; }

/* ------------------------------------------------------------ toast */

.toast {
  position: fixed;
  bottom: calc(1.25rem + env(safe-area-inset-bottom, 0px)); /* clear of the iPhone home indicator (viewport-fit=cover) */
  left: 50%;
  transform: translate(-50%, 150%);
  background: var(--text);
  color: var(--bg);
  padding: .6rem 1.1rem;
  border-radius: 8px;
  box-shadow: 0 4px 16px rgb(0 0 0 / 20%);
  transition: transform .25s;
  z-index: 100;
  max-width: calc(100% - 32px);
}
.toast.show { transform: translate(-50%, 0); }
.toast.error { background: var(--danger); color: #fff; }

@media (max-width: 640px) {
  .header-inner { gap: .5rem; }
  #nav { order: 3; flex-basis: 100%; overflow-x: auto; flex-wrap: nowrap; }
  #save-status { margin-inline-start: auto; }
  .card { padding: 1rem; }
  .toolbar input[type='search'] { width: 100%; }
}

/* ------------------------------------------------------------ sign-in */

.google-btn { background: var(--surface); color: var(--text); border-color: var(--border); font-weight: 500; padding: .6rem 1.2rem; }
.google-btn:hover { background: var(--surface-2); }
.g-icon { width: 18px; height: 18px; flex: none; }
.welcome form .google-btn { margin-bottom: .5rem; }
.footer-links { margin-top: 1.5rem; }
article.welcome ul { padding-inline-start: 1.25rem; }

/* ------------------------------------------------------------ safe areas (viewport-fit=cover) */

body { padding-left: env(safe-area-inset-left, 0px); padding-right: env(safe-area-inset-right, 0px); }
.app-header { padding-top: env(safe-area-inset-top, 0px); }
.container { padding-bottom: calc(4rem + env(safe-area-inset-bottom, 0px)); }

/* ------------------------------------------------------------ sheet (bottom sheet; a centred dialog from 768px) */

html.sheet-open { overflow: hidden; }

.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: var(--backdrop, rgb(10 14 24 / 45%));
  animation: sheet-fade .2s ease-out;
}

/* --kb: how much of the layout viewport the on-screen keyboard covers (set from visualViewport; 0 where the browser resizes the content);
   --vv-h: the visible height; --sheet-drag: the swipe offset, both on <html>. */
.sheet {
  position: fixed;
  z-index: 91;
  inset-inline: 0;
  bottom: var(--kb, 0px);
  display: flex;
  flex-direction: column;
  max-height: calc(var(--vv-h, 100dvh) - env(safe-area-inset-top, 0px) - .75rem);
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-bottom: 0;
  border-radius: 16px 16px 0 0;
  box-shadow: 0 -4px 24px rgb(0 0 0 / 22%);
  transform: translateY(var(--sheet-drag, 0px));
  animation: sheet-up .25s ease-out;
}
.sheet:focus-visible, .sheet-header h2:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

.sheet-grip {
  flex: none;
  width: 40px;
  height: 5px;
  margin: .5rem auto .25rem;
  border-radius: 999px;
  background: var(--border);
  touch-action: none;
  cursor: grab;
}

.sheet-header {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  padding: 0 1rem .25rem;
  touch-action: none;
}
.sheet-header h2 { margin: 0; outline: none; }

.sheet-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: .5rem 1rem 1rem;
}

.sheet-footer {
  flex: none;
  display: flex;
  gap: .5rem;
  padding: .75rem 1rem calc(.75rem + env(safe-area-inset-bottom, 0px));
  background: var(--surface);
  border-top: 1px solid var(--border);
}
.sheet-footer .btn { flex: 1; justify-content: center; min-height: 44px; }

@keyframes sheet-up { from { opacity: 0; translate: 0 24px; } to { opacity: 1; translate: 0 0; } }
@keyframes sheet-fade { from { opacity: 0; } to { opacity: 1; } }

@media (min-width: 768px) {
  .sheet {
    inset-inline: 0;
    inset-block: 0 var(--kb, 0px);
    margin: auto;
    width: calc(100% - 2rem);
    max-width: 560px;
    height: fit-content;
    max-height: min(calc(100dvh - 4rem), 760px);
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: 0 12px 48px rgb(0 0 0 / 30%);
  }
  .sheet-grip { display: none; }
  .sheet-header { padding-top: 1rem; }
  .sheet-footer { padding-bottom: .75rem; }
}

@media (prefers-reduced-motion: reduce) {
  .sheet, .sheet-backdrop, .toast { animation: none; transition: none; }
}

/* ------------------------------------------------------------ undo toast */

.toast.action { display: flex; align-items: center; gap: .75rem; }
.toast-action {
  background: none;
  border: 0;
  border-radius: 6px;
  color: inherit;
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  text-decoration: underline;
  padding: .5rem .25rem;
  min-height: 44px;
}

/* ------------------------------------------------------------ dashboard rows (S7) */

/* The name opens the quick report; it looks like text, not like a form button. */
.name-btn {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 .25rem;
  background: none;
  border: 0;
  border-radius: 6px;
  color: var(--text);
  cursor: pointer;
  font: inherit;
  font-weight: 600;
  text-align: start;
}
.name-btn:hover { color: var(--primary); }
.name-btn:focus-visible, .row-open:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

/* The chevron to the student page (it points to the inline end: left in RTL). */
.row-open {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
  flex: none;
  border-radius: 6px;
  color: var(--muted);
  font-size: 1.5rem;
  line-height: 1;
}
.row-open:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }

.today-strip { border-inline-start: 4px solid var(--primary); }
.today-strip .simple-list li { justify-content: flex-start; flex-wrap: wrap; }
.cal-mark { margin-inline-start: .25rem; }

.dot {
  display: inline-block;
  width: .65rem;
  height: .65rem;
  margin-inline-end: .35rem;
  border-radius: 50%;
  flex: none;
}
.due-late { background: var(--danger); }
.due-today { background: var(--warning); }

.simple-list li .contact-buttons, .simple-list li .row-open { margin-inline-start: auto; }
.simple-list li .contact-buttons + .row-open { margin-inline-start: 0; }
.suggestion-actions { align-items: center; justify-content: flex-end; flex-wrap: wrap; }
@media (max-width: 520px) {
  .suggestion-actions { justify-content: flex-start; }
  .simple-list li { flex-wrap: wrap; }
}

/* ------------------------------------------------------------ students list (S8) */

.list-tools { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; margin-bottom: .75rem; }
.list-tools .search { flex: 1 1 180px; min-width: 0; min-height: 44px; padding: .4rem .75rem; }
.list-tools select { flex: 0 1 auto; min-height: 44px; padding: .4rem .5rem; }

.chip {
  display: inline-block;
  padding: .1rem .6rem;
  border-radius: 999px;
  background: var(--warning-soft);
  color: var(--warning);
  font-size: .8rem;
  font-weight: 500;
  white-space: nowrap;
}

.table td:first-child { display: flex; align-items: center; flex-wrap: wrap; gap: .25rem; }
.table td:first-child .contact-buttons { margin-inline-start: auto; }
.student-link { display: inline-flex; align-items: center; min-height: 44px; font-weight: 600; }
@media (min-width: 641px) {
  .table td:first-child { display: table-cell; }
  .table td:first-child .contact-buttons { margin-inline-start: .5rem; vertical-align: middle; }
}

/* ------------------------------------------------------------ student page (S9, S9a) */

.action-row { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; margin-top: .75rem; }
.action-row .btn { min-height: 44px; }
.action-row .contact-buttons { margin-inline-start: auto; }

.contact-list { list-style: none; padding: 0; margin: 0 0 .75rem; }
.contact-list li { display: flex; align-items: center; gap: .75rem; min-height: 44px; border-bottom: 1px solid var(--border); }
.contact-list li:last-child { border-bottom: 0; }
.contact-label { flex: 1; }
.contact-list .contact-buttons { margin-inline-start: auto; }

.presets { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: .75rem; }
.preset-btn { min-height: 44px; }
.preset-btn[aria-pressed="true"] { background: var(--primary); color: var(--primary-text); border-color: var(--primary); }
.cadence-preview { background: var(--surface-2); border-radius: 8px; padding: .6rem .8rem; margin: 0 0 .75rem; display: grid; gap: .15rem; }
.field.inline input[type="number"] { min-height: 44px; width: 6rem; }
.pause-line { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; margin: 0; }
.student-grid .col > .card .meeting-head .chip { white-space: nowrap; }

/* ------------------------------------------------------------ quick-report sheet form (S10) */

.tap { min-height: 44px; align-items: center; }
.sheet input:not([type="checkbox"]):not([type="radio"]), .sheet select { min-height: 44px; }
.sheet fieldset { min-width: 0; }
.sheet .check.tap { display: flex; }
.sheet .check.tap > input { margin-top: 0; width: 1.25rem; height: 1.25rem; flex: none; }
.sheet details { margin: 0 0 .75rem; }
.sheet details > summary { min-height: 44px; display: flex; align-items: center; }

/* Touch targets: on narrow screens and touch devices every button is at least 44 px high (wide screens with a mouse keep the dense look). */
@media (max-width: 640px), (pointer: coarse) {
  .btn { min-height: 44px; }
  .btn.small { min-height: 44px; }
}

/* The in-progress conversation bar (S10a): a wrapping row in the page flow between the header and <main>; it never floats over content. */
.live-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .5rem;
  padding: .5rem 1rem;
  background: var(--surface-2);
  color: var(--text);
  border-bottom: 1px solid var(--border);
}
.live-bar .live-text { flex: 1 1 12rem; min-width: 0; overflow-wrap: anywhere; font-weight: 500; }
.live-bar .btn { min-height: 44px; justify-content: center; }

/* The conversation briefing of the sheet (S10a). */
.briefing { background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: .5rem 1rem 1rem; margin: .75rem 0; }
.briefing h3 { margin-top: .25rem; }
.briefing h4 { margin: .75rem 0 .25rem; font-size: .9rem; color: var(--muted); font-weight: 500; }
.briefing p { margin: .25rem 0; overflow-wrap: anywhere; }
.briefing li { overflow-wrap: anywhere; }
.briefing .btn { margin-top: .75rem; min-height: 44px; }

/* Docs on the student page (S13) */
.notes-card .btn, .doc-notices .btn { min-height: 44px; }
.meeting .open-summary { min-height: 44px; }
.notes-text { white-space: pre-wrap; overflow-wrap: anywhere; margin: .35rem 0; }
.notes-text[data-collapsed="true"] { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 8; line-clamp: 8; overflow: hidden; }
.doc-notice + .doc-notice { margin-top: .75rem; }
