/* ============================================================
   Homework page (/homework and /homework/<id>).
   The list: new homework, from the to-do, past homework, mistakes,
   what Zenith has noticed. The workspace: the questions Zenith read
   off the sheet (left) and the conversation (right).
   ============================================================ */

.hw-page { --hw-paper: #fbfbfd; --hw-ink: #1d1d1f; --hw-read: 16px; }

/* ---------- the list ---------- */
.hw-library { display: flex; flex-direction: column; gap: 14px; }
.hw-new { padding: 22px; display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 18px; }
.hw-drop {
  position: relative; border: 1.5px dashed var(--border-hi); border-radius: var(--r-md); min-height: 210px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; text-align: center;
  padding: 22px; cursor: pointer; transition: border-color .2s, background-color .2s; background: var(--card-2);
}
.hw-drop:hover, .hw-drop.over { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 7%, var(--card-2)); }
.hw-drop .big { font-size: 19px; font-weight: 650; letter-spacing: -0.015em; }
.hw-drop .small { font-size: 13.5px; color: var(--muted); max-width: 42ch; line-height: 1.45; }
.hw-drop svg { color: var(--muted); }
.hw-pages { display: flex; gap: 10px; flex-wrap: wrap; width: 100%; justify-content: center; }
.hw-pages:empty { display: none; }
.hw-thumb { position: relative; width: 86px; height: 112px; border-radius: 10px; overflow: hidden; background: #fff; border: 1px solid var(--border-hi); flex-shrink: 0; }
.hw-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.hw-thumb.pdf { background: var(--card-hi); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; font-size: 11px; color: var(--muted); padding: 6px; text-align: center; overflow-wrap: anywhere; }
.hw-thumb.pdf b { color: #ff6961; font-size: 13px; letter-spacing: .04em; }
.hw-thumb button { position: absolute; top: 4px; right: 4px; width: 22px; height: 22px; border-radius: 50%; border: 0; background: rgba(0,0,0,.65); color: #fff; font-size: 14px; line-height: 22px; padding: 0; cursor: pointer; }
.hw-form { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.hw-form h2 { margin: 0; font-size: 20px; font-weight: 650; letter-spacing: -0.02em; }
.hw-form .hint { font-size: 13.5px; color: var(--muted); line-height: 1.45; margin-top: -4px; }
.hw-input, .hw-form textarea {
  width: 100%; background: var(--card-2); color: var(--text); border: 1px solid var(--border-hi); border-radius: 12px;
  padding: 10px 13px; font: 15px/1.45 'Geist', system-ui, sans-serif; outline: none; transition: border-color .2s;
}
.hw-input:focus, .hw-form textarea:focus { border-color: var(--accent); }
.hw-form textarea { min-height: 92px; resize: vertical; }
.hw-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.hw-row .hw-input { flex: 1 1 160px; width: auto; }
.hw-row input[type="date"] { flex: 0 0 170px; color-scheme: dark; }
.hw-subjects { display: flex; gap: 6px; flex-wrap: wrap; }
.hw-subjects .chip { padding: 6px 12px; font-size: 13px; display: inline-flex; align-items: center; gap: 7px; }
.hw-subjects .chip .dot { width: 7px; height: 7px; }
.hw-start { align-self: flex-start; padding: 11px 18px; font-size: 14px; }
.hw-start:disabled { opacity: .4; cursor: default; transform: none; }
.hw-form .err { color: var(--bad); font-size: 13.5px; }
.hw-task-note { font-size: 13.5px; color: var(--accent-hover); background: var(--accent-soft); border-radius: 10px; padding: 8px 11px; display: flex; justify-content: space-between; gap: 10px; align-items: center; }
.hw-task-note button { background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 16px; }

.hw-todo .rows { display: flex; flex-direction: column; gap: 2px; }
.hw-todo-row { display: grid; grid-template-columns: 10px minmax(0, 1fr) auto auto; gap: 12px; align-items: center; padding: 9px 8px; border-radius: 10px; }
.hw-todo-row:hover { background: var(--card-hi); }
.hw-todo-row .desc { font-size: 15px; overflow-wrap: anywhere; }
.hw-todo-row .when { font-size: 13px; color: var(--dim); white-space: nowrap; }

.hw-list-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 6px; }
.hw-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
a.hw-card { padding: 18px 18px 16px; display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-rows: auto auto 1fr auto; gap: 6px 14px; min-height: 150px; }
.hw-card .k { grid-column: 1; display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.hw-card .t { grid-column: 1; font-size: 18px; font-weight: 650; letter-spacing: -0.015em; line-height: 1.25; overflow-wrap: anywhere; }
.hw-card .s { grid-column: 1; font-size: 13.5px; color: var(--muted); line-height: 1.45; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.hw-card .thumb { grid-column: 2; grid-row: 1 / span 3; width: 64px; height: 84px; border-radius: 8px; overflow: hidden; background: #fff; border: 1px solid var(--border-hi); align-self: start; }
.hw-card .thumb img { width: 100%; height: 100%; object-fit: cover; object-position: top; display: block; }
.hw-card .foot { grid-column: 1 / -1; display: flex; align-items: center; gap: 12px; margin-top: auto; padding-top: 8px; font-size: 12.5px; color: var(--dim); flex-wrap: wrap; }
.hw-card .bar { flex: 1 1 80px; height: 5px; border-radius: 99px; background: var(--line); overflow: hidden; min-width: 60px; }
.hw-card .bar span { display: block; height: 100%; background: var(--ok); border-radius: 99px; }
.hw-card .mk { color: #ffb36b; }
.hw-card.busy .k::after { content: 'Zenith is on it'; margin-left: auto; color: var(--accent-hover); }
.hw-card.archived { opacity: .55; }
.hw-empty { padding: 26px; color: var(--muted); font-size: 15px; line-height: 1.5; }

.hw-mrow { display: grid; grid-template-columns: 84px minmax(0, 1fr); gap: 12px; padding: 10px 6px; border-radius: 10px; color: inherit; }
a.hw-mrow:hover { background: var(--card-hi); color: inherit; }
.hw-mrow .when { font-size: 12.5px; color: var(--dim); display: flex; flex-direction: column; gap: 6px; }
.hw-mrow .what { font-size: 14.5px; line-height: 1.45; }
.hw-mrow .what .fix { color: var(--ok); }
.hw-mrow .src { font-size: 12.5px; color: var(--dim); margin-top: 3px; }
.hw-type { display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; font-weight: 650; text-transform: uppercase; letter-spacing: .05em; }
.hw-type::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--tc, #8e8e93); }
.hw-insight { display: flex; gap: 10px; align-items: flex-start; padding: 8px 4px; font-size: 14.5px; line-height: 1.45; }
.hw-insight .dot { margin-top: 7px; }
.hw-insight .x { margin-left: auto; background: none; border: 0; color: var(--dim); cursor: pointer; font-size: 17px; line-height: 1; padding: 2px 4px; }
.hw-insight .x:hover { color: var(--text); }
.hw-insight .from { display: block; font-size: 12px; color: var(--dim); margin-top: 2px; }

/* ---------- the workspace ---------- */
body.hw-in-session .kz-bar, body.hw-in-session .kz-panel { display: none !important; }
body.hw-in-session .page { padding-bottom: 0; max-width: 1560px; }
.hw-session { display: flex; flex-direction: column; gap: 12px; min-height: 0; flex: 1 1 auto; }
.hw-top { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; min-height: 40px; }
.hw-top .back { font-size: 15px; white-space: nowrap; }
.hw-top .subj { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; color: var(--muted); }
.hw-top .subj select { background: transparent; color: var(--muted); border: 0; font: inherit; cursor: pointer; padding: 2px; }
.hw-top h1 { margin: 0; font-size: 22px; font-weight: 700; letter-spacing: -0.025em; padding: 0; cursor: text; border-radius: 8px; min-width: 2em; overflow-wrap: anywhere; }
.hw-top h1:hover { background: var(--card-hi); }
.hw-top h1 input { font: inherit; letter-spacing: inherit; color: var(--text); background: var(--card-2); border: 1px solid var(--accent); border-radius: 8px; padding: 0 6px; width: min(60vw, 560px); }
.hw-top .due { font-size: 13.5px; color: var(--dim); white-space: nowrap; }
.hw-top .acts { margin-left: auto; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.hw-filed { font-size: 12.5px; color: var(--dim); display: inline-flex; align-items: center; gap: 7px; }
.hw-filed.waiting { color: #ffb36b; }
.hw-filed.ok { color: var(--ok); }
.hw-mobile-only { display: none !important; }

.hw-ws { display: grid; grid-template-columns: minmax(340px, 430px) minmax(0, 1fr); gap: 16px; align-items: start; flex: 1 1 auto; }
.hw-side { position: sticky; top: 12px; max-height: calc(100dvh - 24px); overflow-y: auto; display: flex; flex-direction: column; gap: 12px; padding-bottom: 12px; scrollbar-width: thin; }
.hw-side-head { display: flex; justify-content: space-between; align-items: baseline; padding: 0 4px; }
.hw-side-head h2 { margin: 0; font-size: 15px; font-weight: 650; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.hw-side-head .aside { font-size: 12.5px; color: var(--dim); }
.hw-summary { font-size: 14px; color: var(--muted); line-height: 1.5; padding: 0 4px; }

.hw-q { padding: 14px 16px 12px; cursor: pointer; position: relative; transition: border-color .25s, background-color .25s, box-shadow .25s; scroll-margin-top: 14px; }
.hw-q:hover { border-color: var(--border-hi); }
.hw-q.active { border-color: color-mix(in srgb, var(--accent) 70%, transparent); box-shadow: 0 0 0 3px var(--accent-soft); background: var(--card-hi); }
.hw-q.flash { animation: hw-flash 1.6s var(--ease); }
@keyframes hw-flash { 0%, 40% { box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 55%, transparent); } 100% { box-shadow: 0 0 0 3px var(--accent-soft); } }
.hw-q-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.hw-q-head .lbl { font-weight: 700; font-size: 15px; letter-spacing: -0.01em; }
.hw-q-head .marks { font-family: 'Geist Mono', monospace; font-size: 12px; color: var(--dim); }
.hw-q-head .topic { font-size: 12px; color: var(--dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; flex: 1 1 auto; }
.hw-st { font-size: 11.5px; font-weight: 650; padding: 3px 8px; border-radius: 99px; background: var(--line); color: var(--muted); white-space: nowrap; margin-left: auto; }
.hw-st.working { background: color-mix(in srgb, var(--accent) 18%, transparent); color: var(--accent-hover); }
.hw-st.done { background: color-mix(in srgb, var(--ok) 18%, transparent); color: var(--ok); }
.hw-st.stuck { background: color-mix(in srgb, var(--warn) 20%, transparent); color: #ffb36b; }
.hw-q-body { font-size: 14.5px; line-height: 1.55; color: var(--soft); overflow-wrap: anywhere; }
.hw-q:not(.active) .hw-q-body.clip { max-height: 260px; overflow: hidden; -webkit-mask-image: linear-gradient(#000 70%, transparent); mask-image: linear-gradient(#000 70%, transparent); }
.hw-q-foot { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; align-items: center; }
.hw-q-foot .btn { padding: 5px 10px; font-size: 12px; }
.hw-q-foot .n-mk { font-size: 12px; color: #ffb36b; margin-left: auto; }
.hw-orig { margin-top: 8px; }

.hw-panel { padding: 14px 16px; display: flex; flex-direction: column; gap: 6px; }
.hw-panel h3 { margin: 0 0 4px; font-size: 14px; font-weight: 650; display: flex; justify-content: space-between; align-items: baseline; }
.hw-panel h3 .aside { font-size: 12px; color: var(--dim); font-weight: 500; }
.hw-mk { padding: 9px 8px; border-radius: 10px; display: flex; flex-direction: column; gap: 4px; scroll-margin-top: 14px; transition: background-color .3s; }
.hw-mk:hover { background: var(--card-hi); }
.hw-mk.flash { animation: hw-flash-bg 1.8s var(--ease); }
@keyframes hw-flash-bg { 0%, 40% { background: color-mix(in srgb, var(--accent) 22%, transparent); } 100% { background: transparent; } }
.hw-mk .top { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--dim); }
.hw-mk .top .q { color: var(--muted); font-weight: 600; }
.hw-mk .wrong { font-size: 14px; line-height: 1.45; }
.hw-mk .fix { font-size: 14px; line-height: 1.45; color: var(--ok); }
.hw-mk .fix::before { content: '→ '; }
.hw-mk .acts { display: flex; gap: 4px; }
.hw-mk .acts button { background: none; border: 0; color: var(--dim); font: 12px 'Geist', system-ui, sans-serif; cursor: pointer; padding: 2px 4px; border-radius: 6px; }
.hw-mk .acts button:hover { color: var(--text); background: var(--line); }
.hw-mk.dismissed .wrong, .hw-mk.dismissed .fix { text-decoration: line-through; opacity: .5; }
.hw-none { font-size: 13.5px; color: var(--dim); line-height: 1.45; }

/* the conversation */
.hw-chat { display: flex; flex-direction: column; min-width: 0; min-height: calc(100dvh - 90px); }
.hw-focus-card { display: none; }
.hw-thread { display: flex; flex-direction: column; gap: 22px; padding: 6px 0 24px; flex: 1 1 auto; }
.hw-msg { max-width: 780px; width: 100%; scroll-margin-top: 16px; }
.hw-msg.me { align-self: flex-end; width: auto; max-width: min(620px, 86%); background: var(--card-hi); border: 1px solid var(--border); border-radius: 18px 18px 6px 18px; padding: 10px 14px; font-size: 15.5px; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; }
.hw-msg.me .on { display: block; font-size: 11.5px; color: var(--dim); margin-bottom: 3px; white-space: normal; }
.hw-msg.me img { display: block; max-width: 260px; max-height: 220px; border-radius: 10px; margin-top: 8px; cursor: zoom-in; background: #fff; }
.hw-msg.zenith { display: grid; grid-template-columns: 26px minmax(0, 1fr); gap: 12px; align-self: flex-start; }
.hw-msg.zenith .av { width: 26px; height: 26px; border-radius: 8px; background: var(--text); color: var(--bg); font-weight: 800; font-size: 13px; display: flex; align-items: center; justify-content: center; margin-top: 1px; }
.hw-msg.zenith.flash .body { animation: hw-flash-bg 1.8s var(--ease); border-radius: 10px; }
.hw-msg .body { font-size: var(--hw-read); line-height: 1.62; color: var(--text); min-width: 0; overflow-wrap: anywhere; }
.hw-msg .meta { font-size: 12px; color: var(--dim); margin-top: 6px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.hw-msg .meta button { background: none; border: 0; color: var(--accent); font: 12.5px 'Geist', system-ui, sans-serif; cursor: pointer; padding: 0; }

/* rich text inside replies and question cards */
.hw-rich > :first-child, .hw-msg .body > :first-child { margin-top: 0; }
.hw-rich > :last-child, .hw-msg .body > :last-child { margin-bottom: 0; }
.hw-msg .body p, .hw-q-body p { margin: 0 0 .75em; }
.hw-msg .body h3, .hw-msg .body h4, .hw-msg .body h5, .hw-q-body h3, .hw-q-body h4 { margin: 1.1em 0 .45em; font-size: 1.05em; font-weight: 700; letter-spacing: -0.01em; }
.hw-msg .body h4, .hw-msg .body h5 { font-size: 1em; color: var(--soft); }
.hw-msg .body ul, .hw-msg .body ol, .hw-q-body ul, .hw-q-body ol { margin: 0 0 .8em; padding-left: 1.4em; }
.hw-msg .body li, .hw-q-body li { margin: .25em 0; }
.hw-msg .body li > p, .hw-q-body li > p { margin: 0 0 .3em; }
.hw-msg .body blockquote, .hw-q-body blockquote { margin: 0 0 .8em; padding: 8px 14px; border-left: 3px solid var(--border-hi); color: var(--muted); background: var(--card-2); border-radius: 0 10px 10px 0; }
.hw-msg .body code, .hw-q-body code { font-family: 'Geist Mono', monospace; font-size: .88em; background: var(--card-hi); padding: 1px 5px; border-radius: 5px; }
.hw-msg .body pre, .hw-q-body pre { background: var(--card-2); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; overflow-x: auto; font-size: 13px; margin: 0 0 .8em; }
.hw-msg .body pre code { background: none; padding: 0; }
.hw-msg .body hr { border: 0; border-top: 1px solid var(--border); margin: 1em 0; }
.hw-msg .body strong, .hw-q-body strong { color: #fff; font-weight: 650; }
html.night .hw-msg .body strong, html.night .hw-q-body strong { color: var(--text); }
.hw-table { overflow-x: auto; margin: 0 0 .9em; }
.hw-table table { border-collapse: collapse; font-size: .92em; min-width: 50%; }
.hw-table th, .hw-table td { border: 1px solid var(--border-hi); padding: 6px 10px; text-align: left; vertical-align: top; }
.hw-table th { background: var(--card-hi); font-weight: 650; }
.hw-qref { color: var(--accent-hover); background: var(--accent-soft); border-radius: 6px; padding: 0 4px; cursor: pointer; font-weight: 600; white-space: nowrap; }
.hw-qref:hover { color: #fff; }

/* maths, drawn by the browser from MathML */
math { font-family: 'STIX Two Math', 'Cambria Math', 'Latin Modern Math', 'Noto Sans Math', math; font-size: 1.1em; }
.hw-mblock { display: block; overflow-x: auto; overflow-y: hidden; margin: .35em 0 .8em; padding: 2px 0; }
.hw-mblock math { font-size: 1.16em; }
.tx-err { color: var(--bad); font-family: 'Geist Mono', monospace; font-size: .8em; }
.tx-raw { color: var(--muted); }
.tx-box { border: 1.5px solid currentColor; padding: 2px 5px; border-radius: 3px; }
.tx-over { border-top: 1px solid currentColor; padding-top: 2px; }
.tx-under { border-bottom: 1px solid currentColor; padding-bottom: 1px; }
.tx-cancel { background: linear-gradient(to top right, transparent calc(50% - .6px), currentColor calc(50% - .6px), currentColor calc(50% + .6px), transparent calc(50% + .6px)); }
.tx-bold { font-weight: 700; }
.tx-italic { font-style: italic; }

/* figures */
.hw-fig { margin: .4em 0 1em; padding: 12px; border-radius: 14px; background: var(--card-2); border: 1px solid var(--border); max-width: 640px; }
.hw-fig-svg, .hw-fig-crop { background: var(--hw-paper); border-color: #d2d2d7; }
.hw-fig svg.hw-svg { display: block; width: 100%; height: auto; max-height: 520px; }
.hw-fig-svg svg.hw-svg { color: var(--hw-ink); }
.hw-fig-svg svg.hw-svg text:not([fill]) { fill: var(--hw-ink); }
.hw-fig figcaption { font-size: 12.5px; color: var(--dim); margin-top: 8px; text-align: center; }
.hw-fig-svg figcaption, .hw-fig-crop figcaption { color: #6e6e73; }
.hw-fig.drawing { min-height: 120px; display: flex; align-items: center; justify-content: center; background: linear-gradient(100deg, var(--card-2) 30%, var(--card-hi) 50%, var(--card-2) 70%); background-size: 300% 100%; animation: hw-shimmer 1.6s linear infinite; }
@keyframes hw-shimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } }
.hw-fig.err { background: var(--card-2); border-style: dashed; }
.hw-fig-msg { font-size: 13px; color: var(--dim); text-align: center; }
.hw-fig details { margin-top: 8px; font-size: 12px; color: var(--dim); }
.hw-fig details pre { white-space: pre-wrap; max-height: 200px; overflow: auto; font-size: 11.5px; }
.hw-fig-why { color: var(--bad); margin-top: 4px; }
.hw-crop { line-height: 0; }
.hw-crop .hw-fig-msg { line-height: 1.4; color: #6e6e73; padding: 20px; }
.hw-crop-c { width: 100%; height: auto; display: block; border-radius: 6px; }
.hw-q-body .hw-fig { max-width: 100%; padding: 8px; margin: .5em 0 .7em; }

/* what Zenith logged, inside its replies */
.hw-log { display: flex; gap: 10px; align-items: flex-start; margin: .2em 0 .9em; padding: 9px 12px; border-radius: 12px; font-size: 13.5px; line-height: 1.45; background: var(--card); border: 1px solid var(--border); border-left: 3px solid var(--tc, var(--border-hi)); cursor: default; }
.hw-log.mistake { cursor: pointer; }
.hw-log.mistake:hover { border-color: var(--border-hi); border-left-color: var(--tc); }
.hw-log .l { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--tc, var(--dim)); white-space: nowrap; padding-top: 2px; }
.hw-log .w { color: var(--soft); }
.hw-log .f { color: var(--ok); display: block; }
.hw-log .f::before { content: '→ '; }
.hw-log.dismissed .w, .hw-log.dismissed .f { text-decoration: line-through; opacity: .5; }
.hw-log.progress { --tc: var(--ok); padding: 6px 12px; font-size: 13px; color: var(--muted); }
.hw-log.progress.working { --tc: var(--accent); }
.hw-log.progress.stuck { --tc: var(--warn); }
.hw-log.insight { --tc: #bf5af2; color: var(--muted); font-style: italic; }
.hw-pending { font-size: 13px; color: var(--dim); }

.hw-thinking { display: inline-flex; gap: 5px; align-items: center; color: var(--dim); font-size: 13.5px; padding: 4px 0; }
.hw-thinking i { width: 6px; height: 6px; border-radius: 50%; background: currentColor; animation: kzdot 1.2s infinite ease-in-out; }
.hw-thinking i:nth-child(2) { animation-delay: .15s; }
.hw-thinking i:nth-child(3) { animation-delay: .3s; }
.hw-thinking span { margin-left: 6px; }

/* the composer */
.hw-compose { position: sticky; bottom: 0; padding: 8px 0 14px; background: linear-gradient(transparent, var(--bg) 26%); z-index: 20; display: flex; flex-direction: column; gap: 8px; }
.hw-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.hw-chips:empty { display: none; }
.hw-chips button { border: 1px solid var(--border-hi); background: var(--card); color: var(--muted); border-radius: 99px; padding: 6px 12px; font: 13px 'Geist', system-ui, sans-serif; cursor: pointer; transition: color .2s, border-color .2s, background-color .2s; }
.hw-chips button:hover { color: var(--text); border-color: var(--faint); background: var(--card-hi); }
.hw-bar { display: flex; align-items: flex-end; gap: 4px; padding: 6px; background: var(--card); border: 1px solid var(--border-hi); border-radius: 24px; box-shadow: 0 10px 30px rgba(0,0,0,.35); }
.hw-bar:focus-within { border-color: color-mix(in srgb, var(--accent) 60%, var(--border-hi)); }
.hw-bar textarea { flex: 1 1 auto; min-width: 0; background: transparent; border: 0; outline: none; color: var(--text); font: 16px/22px 'Geist', system-ui, sans-serif; padding: 10px 8px 10px 10px; resize: none; max-height: 200px; overflow-y: auto; }
.hw-bar textarea::placeholder { color: var(--dim); }
.hw-ctx { display: flex; align-items: center; gap: 10px; font-size: 12.5px; color: var(--dim); padding: 0 6px; flex-wrap: wrap; }
.hw-ctx .on { display: inline-flex; align-items: center; gap: 6px; }
.hw-ctx .on b { color: var(--accent-hover); font-weight: 650; }
.hw-ctx button { background: none; border: 0; color: var(--dim); font: inherit; cursor: pointer; padding: 2px 4px; border-radius: 6px; }
.hw-ctx button:hover { color: var(--text); background: var(--line); }
.hw-depth { margin-left: auto; display: inline-flex; background: var(--card); border: 1px solid var(--border); border-radius: 99px; padding: 2px; }
.hw-depth button { border-radius: 99px; padding: 3px 10px; }
.hw-depth button.on { background: var(--card-hi); color: var(--text); }
.hw-att { position: relative; flex-shrink: 0; margin: 0 4px 6px; }
.hw-att img { width: 38px; height: 38px; object-fit: cover; border-radius: 8px; border: 1px solid var(--border-hi); display: block; background: #fff; }
.hw-att button { position: absolute; top: -6px; right: -6px; width: 18px; height: 18px; border-radius: 50%; border: 0; background: var(--faint); color: #fff; font-size: 12px; line-height: 18px; padding: 0; cursor: pointer; }

/* reading the homework */
.hw-reading { padding: 30px; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); gap: 28px; align-items: center; }
.hw-reading h2 { margin: 0 0 10px; font-size: 26px; letter-spacing: -0.03em; }
.hw-reading p { color: var(--muted); font-size: 15px; line-height: 1.55; margin: 0 0 10px; }
.hw-reading .prog { font-family: 'Geist Mono', monospace; font-size: 13px; color: var(--accent-hover); margin-top: 14px; display: flex; align-items: center; gap: 10px; }
.hw-reading .pages { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; }
.hw-reading .pages img { width: 150px; height: 200px; object-fit: cover; object-position: top; border-radius: 10px; background: #fff; border: 1px solid var(--border-hi); }
.hw-reading .pasted { white-space: pre-wrap; font-size: 13px; color: var(--muted); background: var(--card-2); border-radius: 12px; padding: 14px; max-height: 260px; overflow: auto; }
.hw-scan { position: relative; overflow: hidden; border-radius: 10px; }
.hw-scan::after { content: ''; position: absolute; left: 0; right: 0; height: 30%; top: -30%; background: linear-gradient(transparent, color-mix(in srgb, var(--accent) 35%, transparent), transparent); animation: hw-scan 2.4s ease-in-out infinite; }
@keyframes hw-scan { to { top: 100%; } }

/* sheets and the picture viewer */
.hw-veil { position: fixed; inset: 0; z-index: 60; background: rgba(0,0,0,.72); display: flex; align-items: flex-start; justify-content: center; overflow-y: auto; padding: 28px 16px; }
.hw-veil .inner { display: flex; flex-direction: column; gap: 14px; align-items: center; max-width: 980px; width: 100%; }
.hw-veil img { max-width: 100%; border-radius: 10px; background: #fff; }
.hw-veil .close { position: fixed; top: 14px; right: 16px; width: 40px; height: 40px; border-radius: 50%; border: 0; background: var(--card-hi); color: var(--text); font-size: 20px; cursor: pointer; z-index: 61; }
.hw-menu { position: relative; }
.hw-menu .list { position: absolute; right: 0; top: calc(100% + 6px); z-index: 50; min-width: 210px; background: var(--card-2); border: 1px solid var(--border-hi); border-radius: 14px; padding: 6px; box-shadow: 0 18px 40px rgba(0,0,0,.5); display: flex; flex-direction: column; }
.hw-menu .list button { text-align: left; background: none; border: 0; color: var(--soft); font: 14px 'Geist', system-ui, sans-serif; padding: 9px 11px; border-radius: 9px; cursor: pointer; }
.hw-menu .list button:hover { background: var(--card-hi); color: var(--text); }
.hw-ask-subject { padding: 14px 16px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; font-size: 14px; color: var(--muted); }
.hw-mail { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.hw-mail input { flex: 1 1 220px; }

/* ---------- small screens ---------- */
@media (max-width: 1000px) {
  .hw-new { grid-template-columns: 1fr; }
  .hw-reading { grid-template-columns: 1fr; padding: 22px; }
}
@media (max-width: 900px) {
  body.hw-in-session .page { padding: 12px 12px 0; }
  .hw-mobile-only { display: inline-flex !important; }
  .hw-ws { grid-template-columns: minmax(0, 1fr); }
  .hw-side { position: fixed; inset: 0; z-index: 55; max-height: none; background: var(--bg); padding: 16px 14px 30px; transform: translateY(100%); transition: transform .35s var(--ease); top: auto; height: 100dvh; }
  .hw-side.open { transform: none; }
  .hw-side .hw-sheet-close { display: flex !important; }
  .hw-focus-card { display: block; position: sticky; top: 0; z-index: 15; margin: 0 -2px 6px; padding-top: 4px; background: var(--bg); }
  .hw-focus-card .card { padding: 10px 14px; background: var(--card-hi); box-shadow: 0 10px 24px rgba(0,0,0,.45); }
  .hw-focus-card.shut .hw-q-head { margin-bottom: 0; }
  .hw-focus-card .hw-q-body { max-height: 30dvh; overflow: auto; }
  .hw-focus-card.shut .hw-q-body, .hw-focus-card.shut .hw-q-foot { display: none; }
  .hw-top h1 { font-size: 19px; }
  .hw-top .acts { margin-left: 0; width: 100%; }
  .hw-msg.me { max-width: 92%; }
  .hw-msg.zenith { grid-template-columns: minmax(0, 1fr); }
  .hw-msg.zenith .av { display: none; }
  .hw-page { --hw-read: 15.5px; }
}
.hw-sheet-close { display: none !important; align-self: flex-end; }
@media (max-width: 520px) {
  .hw-new { padding: 16px; }
  .hw-drop { min-height: 170px; }
  .hw-row input[type="date"] { flex: 1 1 150px; }
  .hw-grid { grid-template-columns: 1fr; }
  .hw-mrow { grid-template-columns: 1fr; gap: 4px; }
  .hw-mrow .when { flex-direction: row; }
  .hw-depth { margin-left: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .hw-fig.drawing, .hw-scan::after, .hw-thinking i, .hw-q.flash, .hw-mk.flash, .hw-msg.flash .body { animation: none !important; }
  .hw-side { transition: none; }
}
.hw-nobr { white-space: nowrap; }

/* ---------- Tutor lessons (/tutor/<id>: this workspace in lesson mode) ---------- */
.hw-st.understood { background: color-mix(in srgb, var(--lv-getting) 26%, transparent); color: #8cc0ff; }
.hw-st.nailed { background: color-mix(in srgb, var(--lv-nailed) 22%, transparent); color: var(--lv-nailed); }
.tu-l .hw-q-head .tu-title { font-size: 14px; color: var(--text); font-weight: 560; white-space: normal; line-height: 1.3; }
.tu-l .hw-q-head { align-items: flex-start; }
.tu-l .hw-q-head .lbl { min-width: 2.2em; color: var(--muted); }
.tu-l:not(.active) { padding-bottom: 10px; }
.tu-l.off { opacity: .6; }
.tu-l .tu-off { font-size: 12.5px; color: var(--dim); margin: 0 0 4px; }
.tu-start { display: flex; flex-direction: column; }
.tu-start[hidden] { display: none; }
.tu-start-card { padding: 22px 24px; display: flex; flex-direction: column; gap: 12px; max-width: 820px; }
.tu-start-card h2 { margin: 0; font-size: 21px; letter-spacing: -0.02em; }
.tu-start-card .tu-lede { margin: 0; color: var(--muted); font-size: 14.5px; line-height: 1.55; }
.tu-method { margin: 4px 0 6px; padding: 0; list-style: none; counter-reset: tu; display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; }
.tu-method li { counter-increment: tu; background: var(--card-2); border: 1px solid var(--border); border-radius: 14px; padding: 12px 13px; display: flex; flex-direction: column; gap: 5px; font-size: 13px; line-height: 1.45; color: var(--muted); }
.tu-method li b { color: var(--text); font-size: 14px; }
.tu-method li b::before { content: counter(tu) '  '; color: var(--accent-hover); font-family: 'Geist Mono', monospace; font-size: 12px; }
.tu-start-card .hw-row .btn { white-space: normal; text-align: left; }

/* ---------- visual teaching tools in replies (hw-render.js) ---------- */
/* a diagram that changes: steps (frames) and sliders (vars) */
.hw-fig-live { max-width: 720px; }
.hw-live { display: flex; flex-direction: column; gap: 10px; }
.hw-live-stage svg.hw-svg { animation: hw-live-in .32s var(--ease); }
@keyframes hw-live-in { from { opacity: .35; } to { opacity: 1; } }
.hw-live-cap { font-size: 14.5px; line-height: 1.5; color: var(--text); background: var(--card-hi); border: 1px solid var(--border); border-radius: 10px; padding: 9px 12px; min-height: 1.5em; }
.hw-live-cap:empty { display: none; }
.hw-live-ctrls { display: flex; flex-direction: column; gap: 8px; }
.hw-live-steps { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.hw-live-n { font-family: 'Geist Mono', monospace; font-size: 12.5px; color: var(--dim); min-width: 4.5em; text-align: center; }
.hw-live-b { font: 600 13px 'Geist', system-ui, sans-serif; color: var(--text); background: var(--card-hi); border: 1px solid var(--border-hi); border-radius: 9px; padding: 6px 12px; cursor: pointer; transition: background-color .2s, border-color .2s; }
.hw-live-b:hover:not(:disabled) { border-color: var(--faint); background: var(--card); }
.hw-live-b:disabled { opacity: .4; cursor: default; }
.hw-live-b.primary { background: var(--text); color: var(--bg); border-color: var(--text); }
.hw-live-var { display: grid; grid-template-columns: minmax(70px, auto) minmax(0, 1fr) auto auto; align-items: center; gap: 10px; font-size: 13.5px; color: var(--muted); }
.hw-live-var input[type="range"] { width: 100%; accent-color: var(--accent); }
.hw-live-name { white-space: nowrap; }
.hw-live-out { font-family: 'Geist Mono', monospace; font-size: 13px; color: var(--text); min-width: 4.5em; text-align: right; }
/* a figure from his Learn page */
.hw-fig-learn { max-width: 780px; padding: 8px; }
.hw-figframe { display: block; width: 100%; border: 0; border-radius: 10px; background: transparent; color-scheme: dark; transition: height .2s; }
.hw-figfoot { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; font-size: 12.5px; color: var(--dim); margin-top: 6px; padding: 0 4px; }
.hw-figfoot a { color: var(--accent-hover); margin-left: auto; }
/* tap an answer */
.hw-choose { margin: .5em 0 1em; padding: 12px 14px; border-radius: 14px; background: var(--card-2); border: 1px solid var(--border); max-width: 640px; }
.hw-choose-q { margin: 0 0 10px !important; font-weight: 600; }
.hw-choose-opts { display: flex; flex-direction: column; gap: 6px; }
.hw-choose-o { display: flex; align-items: flex-start; gap: 10px; text-align: left; font: 15px/1.45 'Geist', system-ui, sans-serif; color: var(--text); background: var(--card-hi); border: 1px solid var(--border-hi); border-radius: 11px; padding: 9px 12px; cursor: pointer; transition: border-color .2s, background-color .2s; }
.hw-choose-o:hover:not(:disabled) { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, var(--card-hi)); }
.hw-choose-o:disabled { cursor: default; opacity: .55; }
.hw-choose-o.on { opacity: 1; border-color: var(--accent); background: var(--accent-soft); }
.hw-choose-o .k { font-family: 'Geist Mono', monospace; font-weight: 600; color: var(--accent-hover); min-width: 1.2em; }
.hw-choose-hint { font-size: 12px; color: var(--dim); margin-top: 8px; }
.hw-choose-hint:empty { display: none; }
/* working hidden until he taps */
.hw-reveal { margin: .5em 0 1em; border-radius: 12px; border: 1px dashed var(--border-hi); padding: 6px 10px; max-width: 720px; }
.hw-reveal-b { background: none; border: 0; color: var(--accent-hover); font: 600 14px 'Geist', system-ui, sans-serif; cursor: pointer; padding: 6px 2px; }
.hw-reveal-body { padding: 4px 4px 8px; }
/* a cause-and-effect or process chain */
.hw-chain { margin: .5em 0 1em; max-width: 720px; }
.hw-chain-label { font-size: 12px; font-weight: 650; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: 6px; }
.hw-chain-steps { list-style: none; margin: 0 !important; padding: 0 !important; display: flex; flex-direction: column; gap: 0; counter-reset: chn; }
.hw-chain-steps li { counter-increment: chn; position: relative; background: var(--card-hi); border: 1px solid var(--border); border-radius: 11px; padding: 8px 12px 8px 40px; margin: 0 0 22px !important; line-height: 1.45; }
.hw-chain-steps li::before { content: counter(chn); position: absolute; left: 12px; top: 8px; font: 600 12.5px 'Geist Mono', monospace; color: var(--accent-hover); }
.hw-chain-steps li:not(:last-child)::after { content: '↓'; position: absolute; left: 50%; bottom: -21px; transform: translateX(-50%); color: var(--accent-hover); font-size: 15px; line-height: 20px; }
.hw-chain-steps li:last-child { margin-bottom: 0 !important; border-color: color-mix(in srgb, var(--accent) 40%, var(--border)); }

/* Past papers on the list page: his school's own trial papers (papers.py) */
.hw-papers-how { font-size: 13.5px; color: var(--muted); line-height: 1.5; margin: -2px 0 14px; max-width: 86ch; }
.hw-papers-group + .hw-papers-group { margin-top: 16px; }
.hw-papers-subj { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--dim); text-transform: uppercase; letter-spacing: .06em; font-weight: 650; margin: 2px 0 8px; }
.hw-papers-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr)); gap: 8px; }
.hw-paper { display: flex; align-items: center; gap: 12px; padding: 12px 12px 12px 14px; border-radius: 12px; background: var(--card-2); border: 1px solid var(--line); min-width: 0; }
.hw-paper:hover { background: var(--card-hi); }
.hw-paper.here { border-color: color-mix(in srgb, var(--accent) 70%, transparent); box-shadow: 0 0 0 3px var(--accent-soft); }
.hw-paper .info { flex: 1 1 auto; min-width: 0; }
.hw-paper .t { font-size: 15.5px; font-weight: 650; letter-spacing: -0.01em; }
.hw-paper .m { font-size: 12.5px; color: var(--dim); margin-top: 2px; }
.hw-paper .mix { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; }
.hw-paper .mix span { font-size: 11.5px; color: var(--muted); background: var(--line); border-radius: 99px; padding: 2px 8px; white-space: nowrap; }
.hw-paper .go { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; flex: 0 0 auto; }
.hw-paper .sc { font-size: 13px; font-weight: 650; color: var(--ok); white-space: nowrap; }
.hw-st.scored { background: color-mix(in srgb, var(--ok) 18%, transparent); color: var(--ok); }
.hw-top .hw-paper-score { color: var(--ok); }
.hw-papers-note { font-size: 13px; color: var(--muted); line-height: 1.45; margin: -2px 0 10px; max-width: 92ch; }
