/* The dashboard's look. Colors are tokens on :root, redefined for dark mode, which
   follows the phone's setting. Sizes are in rem so text follows the phone's font size. */

:root {
  color-scheme: light dark;
  --bg: #f6f5f2;
  --surface: #ffffff;
  --surface-2: #efeee9;
  --line: #e2e0d9;
  --text: #1b1c1e;
  --text-2: #5d6066;
  --muted: #8a8d93;
  --accent: #2d6a4f;
  --accent-ink: #ffffff;
  --accent-soft: #e2efe8;
  --owes: #9a3412;
  --credit: #1d6a46;
  --good-bg: #dcefe3; --good: #1d6a46;
  --warn-bg: #f8ead2; --warn: #8a5300;
  --bad-bg: #f7dfdc; --bad: #a12a1e;
  --info-bg: #e3e9f6; --info: #2c4b8a;
  --tag-bg: #ecebe6; --tag: #55585e;
  --bar-pay: #b9bcc2;
  --bar-profit: #2d6a4f;
  --sk: #e7e5df;
  --shadow: 0 1px 2px rgb(0 0 0 / 6%);
  --tutor-0: #2d6a4f; --tutor-1: #2c5aa0; --tutor-2: #b45309; --tutor-3: #6d3fb0;
  --tutor-4: #0f766e; --tutor-5: #be185d; --tutor-none: #8a8d93;
  --tabs-h: min(4rem, 20vw); /* capped so the tabs fit at the largest text */
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #16181c;
    --surface: #1f2228;
    --surface-2: #272a31;
    --line: #30343c;
    --text: #eceef1;
    --text-2: #a9adb5;
    --muted: #7d828b;
    --accent: #6cc59a;
    --accent-ink: #0f1a14;
    --accent-soft: #1f3a2d;
    --owes: #f2a273;
    --credit: #7fd4a6;
    --good-bg: #1d3b2b; --good: #8fdcb2;
    --warn-bg: #3d3018; --warn: #f0c27a;
    --bad-bg: #44221f; --bad: #f4a59b;
    --info-bg: #222f4a; --info: #a9c1f2;
    --tag-bg: #2c3037; --tag: #b4b8bf;
    --bar-pay: #555a63;
    --bar-profit: #6cc59a;
    --sk: #2a2e35;
    --shadow: none;
    --tutor-0: #6cc59a; --tutor-1: #8fb3f0; --tutor-2: #f0a35e; --tutor-3: #b79af0;
    --tutor-4: #5ccfc2; --tutor-5: #f08bb8; --tutor-none: #7d828b;
  }
}

:root[data-theme="dark"] {
  --bg: #16181c; --surface: #1f2228; --surface-2: #272a31; --line: #30343c;
  --text: #eceef1; --text-2: #a9adb5; --muted: #7d828b;
  --accent: #6cc59a; --accent-ink: #0f1a14; --accent-soft: #1f3a2d;
  --owes: #f2a273; --credit: #7fd4a6;
  --good-bg: #1d3b2b; --good: #8fdcb2; --warn-bg: #3d3018; --warn: #f0c27a;
  --bad-bg: #44221f; --bad: #f4a59b; --info-bg: #222f4a; --info: #a9c1f2;
  --tag-bg: #2c3037; --tag: #b4b8bf; --bar-pay: #555a63; --bar-profit: #6cc59a;
  --sk: #2a2e35; --shadow: none;
  --tutor-0: #6cc59a; --tutor-1: #8fb3f0; --tutor-2: #f0a35e; --tutor-3: #b79af0;
  --tutor-4: #5ccfc2; --tutor-5: #f08bb8; --tutor-none: #7d828b;
}

* { box-sizing: border-box; }

html { font-size: 100%; -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 1rem;
  line-height: 1.4;
  -webkit-tap-highlight-color: transparent;
}

a { color: inherit; text-decoration: none; }

.view {
  max-width: 40rem;
  margin: 0 auto;
  padding: 0 1rem calc(var(--tabs-h) + 1.5rem + env(safe-area-inset-bottom));
}

.screen { padding-top: max(1rem, env(safe-area-inset-top)); }

/* -- headings ------------------------------------------------------------------- */

.screen-head {
  display: flex; align-items: center; gap: .5rem; flex-wrap: wrap;
  margin: .25rem 0 .75rem;
}
.screen-head h1 { font-size: 1.5rem; margin: 0; flex: 1 1 auto; letter-spacing: -.01em; }
.screen-sub { margin: 0; width: 100%; color: var(--text-2); font-size: .9rem; }
/* Home's gear, to Settings: a full-size touch target at the heading's end. */
.gear {
  display: grid; place-items: center; width: 2.75rem; height: 2.75rem; margin-right: -.5rem;
  border-radius: 50%; color: var(--text-2);
}
.gear svg {
  width: 1.5rem; height: 1.5rem; fill: none; stroke: currentColor; stroke-width: 1.8;
  stroke-linecap: round; stroke-linejoin: round;
}
.back { margin: 0 0 .25rem; }
.back a { color: var(--accent); font-weight: 500; display: inline-block; padding: .35rem 0; }

.block { margin-top: 1.5rem; }
.block h2 {
  font-size: .8rem; text-transform: uppercase; letter-spacing: .06em;
  color: var(--text-2); margin: 0 0 .5rem; font-weight: 600;
}

.balance { margin: 0 0 .5rem; font-size: 1.1rem; font-weight: 600; }
.balance.owes { color: var(--owes); }
.balance.credit { color: var(--credit); }
.muted { color: var(--muted); font-weight: 400; }
.hint { color: var(--text-2); font-size: .9rem; margin: 0 0 .75rem; }

/* -- Home ------------------------------------------------------------------------- */

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(6.5rem, 1fr)); gap: .5rem; }
.stat {
  background: var(--surface); border-radius: .9rem; padding: .8rem .75rem;
  box-shadow: var(--shadow); border: 1px solid var(--line); min-width: 0;
}
.stat-label { font-size: .8rem; color: var(--text-2); }
.stat-value {
  font-size: 1.2rem; font-weight: 650; margin-top: .15rem; font-variant-numeric: tabular-nums;
  white-space: nowrap; letter-spacing: -.01em;
}

.links { display: grid; gap: .5rem; margin-top: .75rem; }
.bigrow {
  display: flex; align-items: center; justify-content: space-between; gap: .5rem;
  background: var(--surface); border: 1px solid var(--line); border-radius: .9rem;
  padding: .9rem 1rem; min-height: 3.25rem; box-shadow: var(--shadow);
}
.bigrow strong { font-variant-numeric: tabular-nums; }
.bigrow.attention { background: var(--accent-soft); border-color: transparent; font-weight: 600; }
.chev { color: var(--muted); font-size: 1.4rem; line-height: 1; }

/* -- lists ------------------------------------------------------------------------ */

.list {
  background: var(--surface); border: 1px solid var(--line); border-radius: .9rem;
  overflow: hidden; box-shadow: var(--shadow);
}
.row {
  display: flex; align-items: flex-start; justify-content: space-between; gap: .75rem;
  padding: .7rem 1rem; min-height: 3rem;
}
.row + .row { border-top: 1px solid var(--line); }
.row.tap:active, .bigrow:active { background: var(--surface-2); }
.row-main { min-width: 0; flex: 1 1 auto; }
.row-title { font-weight: 550; overflow-wrap: anywhere; }
.row-sub { color: var(--text-2); font-size: .85rem; margin-top: .1rem; overflow-wrap: anywhere; }
.row-figure {
  text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; font-weight: 550;
  flex: 0 0 auto;
}
.row.owes .row-figure > div:first-child { color: var(--owes); }
.row.credit .row-figure > div:first-child { color: var(--credit); }
.row.voided .row-title, .row.voided .row-figure > div:first-child {
  text-decoration: line-through; color: var(--muted);
}
.row.voided .tag { text-decoration: none; }

.tag {
  display: inline-block; font-size: .72rem; font-weight: 600; line-height: 1.5;
  padding: 0 .45rem; border-radius: 1rem; background: var(--tag-bg); color: var(--tag);
  vertical-align: .1em; margin-right: .2rem; max-width: 100%;
}
/* Tags are written lowercase in the code and shown with a capital: "Voided", "Partly paid". */
.tag::first-letter { text-transform: uppercase; }
.tag.good { background: var(--good-bg); color: var(--good); }
.tag.warn { background: var(--warn-bg); color: var(--warn); }
.tag.bad { background: var(--bad-bg); color: var(--bad); }
.tag.info { background: var(--info-bg); color: var(--info); }

/* -- buttons, switches -------------------------------------------------------------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  font: inherit; font-weight: 600; font-size: .95rem; color: var(--text);
  background: var(--surface); border: 1px solid var(--line); border-radius: .7rem;
  padding: .55rem 1rem; min-height: 2.75rem; cursor: pointer;
}
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn:disabled { opacity: .55; cursor: default; }

.switch {
  display: inline-flex; align-items: center; gap: .6rem; margin: 0 0 .75rem;
  color: var(--text-2); font-size: .95rem; min-height: 2.75rem; cursor: pointer;
}
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch-track {
  width: 2.5rem; height: 1.5rem; border-radius: 1rem; background: var(--line);
  position: relative; transition: background .15s; flex: 0 0 auto;
}
.switch-thumb {
  position: absolute; top: .15rem; left: .15rem; width: 1.2rem; height: 1.2rem;
  border-radius: 50%; background: var(--surface); box-shadow: 0 1px 2px rgb(0 0 0 / 25%);
  transition: transform .15s;
}
.switch input:checked + .switch-track { background: var(--accent); }
.switch input:checked + .switch-track .switch-thumb { transform: translateX(1rem); }
.switch input:focus-visible + .switch-track { outline: 2px solid var(--accent); outline-offset: 2px; }

.segmented {
  display: flex; background: var(--surface-2); border-radius: .75rem; padding: .2rem;
  gap: .2rem;
}
.segmented button {
  flex: 1; font: inherit; font-weight: 600; border: 0; border-radius: .6rem;
  padding: .5rem; min-height: 2.5rem; background: transparent; color: var(--text-2);
  cursor: pointer;
}
.segmented button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

/* -- empty, error, loading ---------------------------------------------------------- */

.empty {
  text-align: center; color: var(--text-2); padding: 1.5rem 1rem;
  background: var(--surface); border: 1px dashed var(--line); border-radius: .9rem;
}
.empty p { margin: 0 0 .75rem; }
.empty p:last-child { margin: 0; }

.error {
  background: var(--bad-bg); color: var(--bad); border-radius: .9rem; padding: 1rem;
  margin-top: 1rem;
}
.error p { margin: 0 0 .75rem; font-weight: 550; }

.skeleton { padding-top: .5rem; }
.sk { height: .9rem; border-radius: .4rem; background: var(--sk); animation: pulse 1.2s ease-in-out infinite; }
.sk.title { height: 1.6rem; width: 45%; margin-bottom: 1.25rem; }
.sk.short { width: 30%; margin-top: .5rem; }
.sk-row { padding: .75rem 0; border-bottom: 1px solid var(--line); }
@keyframes pulse { 50% { opacity: .45; } }
@media (prefers-reduced-motion: reduce) { .sk { animation: none; } }

/* -- Reports ---------------------------------------------------------------------- */

.chart {
  background: var(--surface); border: 1px solid var(--line); border-radius: .9rem;
  padding: .75rem; margin-bottom: .75rem; box-shadow: var(--shadow);
}
.legend { display: flex; gap: 1rem; font-size: .8rem; color: var(--text-2); margin-bottom: .5rem; }
.key { display: inline-flex; align-items: center; gap: .35rem; }
.swatch { width: .7rem; height: .7rem; border-radius: .2rem; display: inline-block; }
.swatch.profit, .seg.profit { background: var(--bar-profit); }
.swatch.pay, .seg.pay { background: var(--bar-pay); }
.bars { display: flex; align-items: stretch; gap: .25rem; height: 9rem; }
.bar {
  flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center;
  background: none; border: 0; padding: 0; cursor: pointer; font: inherit; min-width: 0;
  color: var(--text-2); border-radius: .4rem;
}
.bar-stack {
  width: 70%; max-width: 2rem; display: flex; flex-direction: column; gap: 2px;
  min-height: 2px; border-top-left-radius: 4px; border-top-right-radius: 4px; overflow: hidden;
  background: var(--line);
}
.bar-stack:has(.seg) { background: none; }
.seg { display: block; min-height: 2px; }
.bar-label { font-size: .7rem; margin-top: .3rem; white-space: nowrap; }
.bar.on .bar-label { color: var(--text); font-weight: 700; }
.bar.on .bar-stack { outline: 2px solid var(--text); outline-offset: 1px; }
.chart-detail {
  display: flex; flex-wrap: wrap; gap: .25rem .9rem; margin-top: .6rem; font-size: .85rem;
  color: var(--text-2); font-variant-numeric: tabular-nums;
}
.chart-detail strong { color: var(--text); width: 100%; }

.table {
  background: var(--surface); border: 1px solid var(--line); border-radius: .9rem;
  overflow: hidden; box-shadow: var(--shadow); font-size: .9rem;
}
.tr {
  display: grid; grid-template-columns: minmax(0, 1.5fr) repeat(3, minmax(0, 1fr));
  gap: .5rem; padding: .6rem .9rem; align-items: start;
}
.tr + .tr { border-top: 1px solid var(--line); }
.tr.th { font-size: .75rem; color: var(--text-2); font-weight: 600; padding: .5rem .9rem; }
.tr.th span:not(:first-child), .num { text-align: right; }
.num { font-variant-numeric: tabular-nums; }
.table.hours .tr { grid-template-columns: minmax(0, 1.6fr) repeat(4, minmax(0, 1fr)); }

/* -- Unanswered questions -------------------------------------------------------------- */

.questions { display: grid; gap: .6rem; }
.question {
  background: var(--surface); border: 1px solid var(--line); border-radius: .9rem;
  padding: .9rem 1rem; box-shadow: var(--shadow);
}
.question-text { margin: 0; font-weight: 550; }
.answers { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .6rem; }
.answers .btn { font-size: .9rem; min-height: 2.5rem; padding: .4rem .8rem; }

/* -- forms and answers (task 22) ------------------------------------------------------ */

[hidden] { display: none !important; }

.form { display: grid; gap: 1rem; }
.field { display: grid; gap: .35rem; min-width: 0; }
.field-label { font-weight: 600; font-size: .95rem; margin: 0; }
.optional { color: var(--muted); font-weight: 400; }
.field-hint { margin: 0; color: var(--text-2); font-size: .85rem; }
.field-error { margin: 0; color: var(--bad); font-size: .85rem; font-weight: 550; }
.subfields {
  display: grid; gap: 1rem; padding: .9rem 1rem; border-radius: .9rem;
  background: var(--surface-2);
}

.input {
  font: inherit; font-size: 1rem; color: var(--text); background: var(--surface);
  border: 1px solid var(--line); border-radius: .7rem; padding: .6rem .75rem;
  min-height: 2.9rem; width: 100%; min-width: 0;
}
.input:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }
select.input { appearance: auto; }
.affix { display: flex; align-items: center; gap: .4rem; }
.affix .input { flex: 1 1 auto; font-variant-numeric: tabular-nums; }
.affix-text { color: var(--text-2); font-weight: 600; }

.subject-rows { display: grid; gap: .5rem; }
.subject-rows:empty { display: none; }
.subject-row {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr) auto; gap: .4rem;
  align-items: center;
}
/* On a phone a subject's notes get their own full-width line under the subject and its ×,
   so "great with reading, rusty on geometry" isn't cut off (2026-10-20). */
@media (max-width: 36rem) {
  .subject-rows { gap: 1rem; }
  .subject-row {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: "subject remove" "notes notes";
  }
  .subject-row > :nth-child(1) { grid-area: subject; }
  .subject-row > :nth-child(2) { grid-area: notes; }
  .subject-row > :nth-child(3) { grid-area: remove; }
}
.btn.icon { min-width: 2.75rem; padding: 0; font-size: 1.3rem; line-height: 1; }
.btn.ghost {
  justify-self: start; background: transparent; border-style: dashed; color: var(--accent);
}

.form-status:empty { display: none; }
.form-error {
  margin: 0; background: var(--bad-bg); color: var(--bad); border-radius: .7rem;
  padding: .7rem .9rem; font-weight: 550;
}
.form-note { margin: 0; color: var(--text-2); }
.choice {
  background: var(--warn-bg); color: var(--text); border-radius: .9rem; padding: .8rem .9rem;
}
.choice-q { margin: 0; font-weight: 600; }
.form-actions { display: grid; }
.btn.save { min-height: 3rem; font-size: 1rem; }

.toast {
  position: fixed; left: 1rem; right: 1rem; z-index: 20;
  bottom: calc(var(--tabs-h) + .75rem + env(safe-area-inset-bottom));
  max-width: 38rem; margin: 0 auto; padding: .75rem 1rem; border-radius: .8rem;
  background: var(--text); color: var(--bg); font-weight: 550; overflow-wrap: anywhere;
  box-shadow: 0 4px 16px rgb(0 0 0 / 20%);
}

.question .form-status { margin-top: .6rem; }
.question.answered { background: var(--surface-2); box-shadow: none; }
.question.answered .question-text { color: var(--text-2); }
.answered-note { margin: .6rem 0 0; font-weight: 600; color: var(--good); }
.typed-answer { display: flex; gap: .4rem; margin-top: .6rem; }
.typed-answer .input { flex: 1 1 auto; }

/* -- the bottom tabs ---------------------------------------------------------------- */

.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: grid; grid-template-columns: repeat(6, 1fr); /* Calendar added 2026-11-12 */
  background: var(--surface); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabs a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .15rem;
  min-height: var(--tabs-h); color: var(--muted); font-size: min(.75rem, 2.9vw); font-weight: 600;
  min-width: 0;
}
.tabs svg {
  width: min(1.5rem, 7vw); height: min(1.5rem, 7vw); fill: none; stroke: currentColor; stroke-width: 1.8;
  stroke-linecap: round; stroke-linejoin: round;
}
.tabs a[aria-current="page"] { color: var(--accent); }
.tabs a[aria-current="page"] svg { stroke-width: 2.2; }

a:focus-visible, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* -- installable app, offline, pull to refresh (task 23) ------------------------------ */

/* Only the app's own pull to refresh (js/pull-refresh.js), not Chrome's page reload. */
html, body { overscroll-behavior-y: none; }

.netbar, .installbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; flex-wrap: wrap; align-items: center; justify-content: center;
  gap: .15rem .75rem; padding: .5rem 1rem; padding-top: max(.5rem, env(safe-area-inset-top));
  font-size: .9rem; font-weight: 600; text-align: center;
}
.netbar { background: var(--warn-bg); color: var(--warn); }
.netbar-wait { width: 100%; font-weight: 500; }
.installbar {
  background: var(--accent-soft); color: var(--text); flex-wrap: nowrap; text-align: left;
}
.installbar span { flex: 1 1 auto; }
.installbar .btn { min-height: 2.5rem; padding: .35rem 1rem; }
.netbar[hidden], .installbar[hidden] { display: none; }

[data-offline-locked="inert"] { opacity: .55; }

.ptr {
  position: fixed; top: 0; left: 50%; z-index: 30; margin-top: -2.75rem;
  width: 2.5rem; height: 2.5rem; border-radius: 50%; display: grid; place-items: center;
  background: var(--surface); color: var(--accent); box-shadow: 0 1px 4px rgb(0 0 0 / 25%);
  transform: translate(-50%, 0); opacity: 0; pointer-events: none;
}
.ptr svg {
  width: 1.4rem; height: 1.4rem; fill: none; stroke: currentColor; stroke-width: 2.2;
  stroke-linecap: round; stroke-linejoin: round;
}
.ptr.ready { background: var(--accent); color: var(--accent-ink); }
.ptr.spinning { opacity: 1; transition: transform .15s; }
.ptr.spinning svg { animation: spin .8s linear infinite; }
@keyframes spin { to { rotate: 360deg; } }
@media (prefers-reduced-motion: reduce) { .ptr.spinning svg { animation: none; } }

/* At the largest text sizes a row's figure moves under its name instead of squeezing
   the name to a letter per line; at normal sizes the row stays on one line. */
.row { flex-wrap: wrap; row-gap: .15rem; }
.row-main { flex-basis: 9rem; }
.row-figure { margin-left: auto; }

/* Report tables scroll sideways at the largest text sizes rather than run their
   figures together; at normal sizes they fit as before. */
.table { overflow-x: auto; }
.table .tr {
  grid-template-columns: minmax(5.5rem, 1.5fr) repeat(3, minmax(max-content, 1fr));
}
.table.hours .tr {
  grid-template-columns: minmax(5.5rem, 1.6fr) repeat(4, minmax(max-content, 1fr));
}
.bar-label { font-size: min(.7rem, 3vw); } /* chart labels, eight across */
.screen-head h1 { min-width: 0; overflow-wrap: break-word; hyphens: auto; } /* "Unanswered" */

/* -- editing (task 29) ------------------------------------------------------------------ */

.btn.danger { background: var(--bad-bg); color: var(--bad); border-color: transparent; }
.form-actions.pair { grid-template-columns: 1fr 1fr; gap: .5rem; }
.confirm-wrap > .btn { width: 100%; }
.confirm { background: var(--surface-2); border-radius: .9rem; padding: .9rem 1rem; }
.radio { display: flex; align-items: center; gap: .4rem; min-height: 2.5rem; }
.radio input { width: 1.2rem; height: 1.2rem; accent-color: var(--accent); }
.preview:empty { display: none; }
.preview { display: grid; gap: .35rem; }
.preview-count { margin: 0; font-weight: 600; }
.preview-report {
  margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; font: inherit; font-size: .9rem;
  background: var(--surface-2); border-radius: .7rem; padding: .7rem .9rem;
}
.toast { white-space: pre-line; }

/* -- adding sessions and payments, and Undo (2026-10-19) ------------------------------------ */

.add-actions { display: flex; flex-wrap: wrap; gap: .5rem; margin: 0 0 1rem; }
.add-actions .btn { flex: 1 1 8rem; text-decoration: none; }
textarea.input { min-height: 5rem; resize: vertical; line-height: 1.4; }
.void-reason { margin: 0 0 .75rem; font-weight: 600; color: var(--bad); overflow-wrap: anywhere; }
.calendar-hint { margin: 0; }
.toast { display: flex; align-items: center; gap: .75rem; }
.toast-text { flex: 1 1 auto; min-width: 0; }
.toast .toast-undo {
  flex: none; min-height: 2.75rem; color: var(--bg); background: transparent;
  border-color: var(--bg); text-decoration: underline;
}
/* A long report (a rate fix repricing a semester) never covers the screen (2026-10-20): the
   notice stops at about a third of it and its text scrolls, while Undo stays at the top right. */
.toast { max-height: 30vh; max-height: 30dvh; }
.toast-text {
  overflow-y: auto; overscroll-behavior: contain;
  max-height: calc(30vh - 1.5rem); max-height: calc(30dvh - 1.5rem);
}
.toast .toast-undo { align-self: flex-start; }

/* -- people's details and edit forms (2026-10-19) ------------------------------------------ */

.details { display: grid; gap: .6rem; margin: 0 0 .75rem; }
.detail { display: grid; gap: .15rem; min-width: 0; }
.detail-label { color: var(--text-2); font-size: .85rem; font-weight: 600; }
.detail-value { margin: 0; overflow-wrap: anywhere; }
.detail-value a { color: var(--accent); font-weight: 500; }
/* Call, Text, and email as 44px tap targets with room between them (2026-10-20). */
.contact-links { display: flex; flex-wrap: wrap; gap: .5rem; }
.detail-value a.contact-link {
  display: inline-flex; align-items: center; min-height: 2.75rem; min-width: 2.75rem;
  max-width: 100%; padding: .35rem .9rem; border: 1px solid var(--line); border-radius: .7rem;
  background: var(--surface); overflow-wrap: anywhere;
}
.family-link a {
  display: inline-flex; align-items: center; min-height: 2.75rem; color: var(--accent);
  font-weight: 500;
}
.notes-text { white-space: pre-wrap; }
.chips { display: flex; flex-wrap: wrap; gap: .4rem; }
.chips:empty { display: none; }
.chip {
  display: inline-flex; align-items: center; gap: .2rem; max-width: 100%;
  background: var(--accent-soft); color: var(--text); border-radius: 1rem;
  padding: .3rem .75rem; font-size: .9rem; overflow-wrap: anywhere;
}
.chip-x {
  font: inherit; font-size: 1.15rem; line-height: 1; color: var(--text-2);
  background: transparent; border: 0; min-width: 2.25rem; min-height: 2.25rem;
  margin: -.3rem -.6rem -.3rem 0; cursor: pointer;
}
.chip-input { display: grid; gap: .5rem; }
.chip-add { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .4rem; }

/* -- rate history, subjects, and settings (2026-10-19) ---------------------------------------- */

.rate-list {
  background: var(--surface); border: 1px solid var(--line); border-radius: .9rem;
  box-shadow: var(--shadow);
}
.rate-row { display: grid; gap: .6rem; padding: .75rem 1rem; }
.rate-row + .rate-row { border-top: 1px solid var(--line); }
.rate-row.muted .row-title { color: var(--muted); }
.rate-actions { display: grid; gap: .5rem; }
.rate-actions:empty { display: none; }
.rate-actions > .btn { width: 100%; }
.fix-form, .pay-form {
  background: var(--surface-2); border-radius: .9rem; padding: .9rem 1rem;
}
.subject .chips { margin: .6rem 0; }
.subject .row-sub { margin: 0; }
.subject-add { margin-top: .6rem; }
.subject-add > .btn { width: 100%; }
.nickname-form { gap: .5rem; }
.ignored-row { display: grid; gap: .5rem; padding: .7rem 1rem; }
.ignored-row + .ignored-row { border-top: 1px solid var(--line); }
.other-answer { margin-top: .4rem; }
.other-answer > .btn { font-size: .9rem; min-height: 2.5rem; padding: .4rem .8rem; }

/* -- chat (2026-11-12) ------------------------------------------------------------------- */

.screen.chat { padding-bottom: 5.5rem; } /* until chat.js sizes it to the message box */
.chat-log { display: grid; gap: .35rem; }
.chat-day {
  margin: .9rem 0 .2rem; text-align: center; color: var(--muted); font-size: .8rem; font-weight: 600;
}
.chat-item { display: grid; justify-items: start; gap: .25rem; max-width: 85%; }
.chat-item.mine { justify-self: end; justify-items: end; }
.chat-item.pending { opacity: .6; }
.chat-msg {
  padding: .55rem .8rem; border-radius: 1rem; min-width: 0; max-width: 100%;
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow);
}
.chat-msg.theirs { border-bottom-left-radius: .3rem; }
.chat-msg.mine {
  background: var(--accent); color: var(--accent-ink); border-color: transparent;
  border-bottom-right-radius: .3rem;
}
.chat-msg.alert { background: var(--warn-bg); border-color: transparent; }
.chat-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.chat-quote {
  margin-bottom: .3rem; padding-left: .5rem; border-left: 3px solid currentColor;
  font-size: .85rem; opacity: .75; overflow-wrap: anywhere;
}
.chat-meta { margin-top: .15rem; font-size: .75rem; opacity: .7; text-align: right; }
.chat-buttons { display: flex; flex-wrap: wrap; gap: .35rem; }
.chat-buttons .btn { min-height: 2.5rem; padding: .3rem .9rem; }
.chat-reply {
  background: none; border: 0; padding: .1rem .3rem; color: var(--accent); font: inherit;
  font-size: .8rem; font-weight: 600; cursor: pointer;
}
.chat-note { margin: .1rem 0; text-align: center; color: var(--muted); font-size: .85rem; }
.chat-working { display: flex; gap: .3rem; padding: .7rem .9rem; }
.chat-working[hidden] { display: none; }
.chat-working span {
  width: .45rem; height: .45rem; border-radius: 50%; background: var(--muted);
  animation: chat-dot 1.2s infinite ease-in-out;
}
.chat-working span:nth-child(2) { animation-delay: .15s; }
.chat-working span:nth-child(3) { animation-delay: .3s; }
@keyframes chat-dot { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .chat-working span { animation: none; opacity: .6; } }

.chat-composer {
  position: fixed; left: 0; right: 0; z-index: 9;
  bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom));
  padding: .5rem max(1rem, calc((100% - 38rem) / 2));
  background: var(--bg); border-top: 1px solid var(--line);
}
.chat-row { display: flex; gap: .4rem; align-items: flex-end; }
.chat-composer .chat-input {
  flex: 1 1 auto; resize: none; min-height: 2.75rem; max-height: 10rem; line-height: 1.35;
}
.chat-send { min-width: 2.75rem; min-height: 2.75rem; padding: 0; display: grid; place-items: center; }
.chat-send svg {
  width: 1.3rem; height: 1.3rem; fill: none; stroke: currentColor; stroke-width: 2;
  stroke-linecap: round; stroke-linejoin: round;
}
.chat-replying {
  display: flex; align-items: center; gap: .4rem; margin-bottom: .4rem;
  padding: .3rem .3rem .3rem .6rem; border-left: 3px solid var(--accent); background: var(--surface);
  border-radius: .4rem; font-size: .85rem;
}
.chat-replying[hidden] { display: none; }
.chat-replying-text { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; }
.chat-cancel { min-height: 2.25rem; min-width: 2.25rem; }
.chat-status { margin: 0 0 .4rem; }
.chat-status[hidden] { display: none; }
/* While the phone's keyboard is up, the tabs hide and the message box sits on it. */
body.keyboard-up .tabs { display: none; }

/* -- sessions grouped under their payments (2026-11-12) ------------------------------ */

.timeline .pay-group + .pay-group { border-top: 2px solid var(--line); }
.group-head {
  display: flex; justify-content: space-between; gap: .75rem; padding: .6rem 1rem;
  background: var(--surface-2); font-weight: 650; font-size: .9rem;
}
.group-head.owes { color: var(--owes); }
.group-figure { font-variant-numeric: tabular-nums; }
.row.group-pay { background: var(--surface-2); }
.pay-sessions > .row { border-top: 1px solid var(--line); padding-left: 1.75rem; }

/* -- the Calendar tab (2026-11-12) ---------------------------------------------------- */

.tutor-0 { --who: var(--tutor-0); } .tutor-1 { --who: var(--tutor-1); }
.tutor-2 { --who: var(--tutor-2); } .tutor-3 { --who: var(--tutor-3); }
.tutor-4 { --who: var(--tutor-4); } .tutor-5 { --who: var(--tutor-5); }
.tutor-none { --who: var(--tutor-none); }

.cal-nav { display: flex; align-items: center; gap: .5rem; margin: .25rem 0 .75rem; }
.cal-nav .btn { min-width: 2.75rem; }
.cal-week { flex: 1 1 auto; font-weight: 650; font-size: 1.05rem; }

.week-strip {
  display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: .25rem;
  background: var(--surface); border: 1px solid var(--line); border-radius: .9rem;
  padding: .35rem; box-shadow: var(--shadow);
}
.week-day {
  display: grid; justify-items: center; gap: .1rem; padding: .35rem 0; min-height: 3.6rem;
  border: 0; border-radius: .6rem; background: none; color: var(--text); font: inherit;
}
.week-day.today { background: var(--accent-soft); }
.week-letter { font-size: .7rem; color: var(--text-2); font-weight: 600; }
.week-num { font-weight: 650; font-variant-numeric: tabular-nums; }
.week-dots { display: flex; gap: 2px; min-height: 6px; }
.dot {
  width: 6px; height: 6px; border-radius: 50%; background: var(--who, var(--muted));
  display: inline-block; flex: 0 0 auto;
}

.cal-chips { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .75rem; }
.chip-btn {
  display: inline-flex; align-items: center; gap: .35rem; min-height: 2.5rem;
  padding: .3rem .8rem; border-radius: 1.25rem; border: 1px solid var(--line);
  background: var(--surface); color: var(--text); font: inherit; font-size: .9rem;
}
.chip-btn.on { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.chip-btn.on .dot { background: var(--accent-ink); }

.cal-day { margin-top: 1.25rem; scroll-margin-top: 1rem; }
.cal-day h2 { font-size: 1rem; margin: 0 0 .5rem; }
.cal-none { margin: 0; color: var(--muted); font-size: .9rem; }
.cal-item { border-left: 4px solid var(--who); }
.cal-time {
  flex: 0 0 4.5rem; font-variant-numeric: tabular-nums; font-weight: 600; font-size: .9rem;
  color: var(--text-2); padding-top: .05rem;
}
.cal-item.calendar .row-title, .cal-item.missed .row-title { font-weight: 500; }
.cal-item.missed { border-left-style: dashed; }
.cal-actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .6rem; }
.cal-actions .confirm-wrap { flex: 1 1 100%; }
.cal-actions .confirm-wrap:has(> .btn) { flex: 0 0 auto; }
