/* Panel chrome: key gate, mode menu, settings, calendar sync, and layout */

/* ---- key gate popup ---- */
.keygate { position: fixed; inset: 0; z-index: 50;
  background: rgba(10,13,18,.82); backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center; }
.keygate.hidden { display: none; }
.keycard { background: var(--panel); border: 1px solid var(--border);
  border-radius: 14px; padding: 26px 28px; width: 350px; text-align: center; }
.keycard h2 { font-size: 16px; margin-bottom: 4px; }
.keycard p { color: var(--dim); font-size: 13px; margin-bottom: 16px; }
.keycard input { width: 100%; background: var(--panel2);
  border: 1px solid var(--border); border-radius: 9px; color: var(--text);
  font: 14px/1.4 ui-monospace, "SF Mono", Menlo, monospace;
  padding: 10px 12px; outline: none; letter-spacing: .5px;
  text-align: center; }
.keycard input:focus { border-color: var(--accent); }
.bugjoke { font-size: 11.5px; color: var(--dim); margin: 0 0 12px; }
.keycard textarea { width: 100%; background: var(--panel2);
  border: 1px solid var(--border); border-radius: 9px;
  color: var(--text); font: 13px/1.5 inherit; padding: 10px 12px;
  outline: none; resize: vertical; min-height: 74px;
  box-sizing: border-box; margin-bottom: 10px; }
.keycard textarea:focus { border-color: var(--accent); }
.bugwa { font-size: 11px; color: var(--dim); line-height: 1.5;
  margin: 0 0 4px; }
.keycard button { margin-top: 12px; width: 100%; background: var(--accent);
  border: none; color: #fff; border-radius: 9px; padding: 10px;
  font-size: 14px; cursor: pointer; }
.keycard button:hover { background: var(--hov); }
.keyerr { color: var(--red); font-size: 12.5px; margin-top: 10px;
  min-height: 16px; }

/* ---- mode menu ---- */
/* no dedicated header row: the menu rides in the week-context row */

/* a sidebar that slides in from the left over the panel */
.menuscrim { position: fixed; inset: 0; z-index: 44;
  background: rgba(10,13,18,.55); opacity: 0; pointer-events: none;
  transition: opacity .2s; }
.menuscrim.show { opacity: 1; pointer-events: auto; }
.modeMenu { position: fixed; top: 0; bottom: 0; left: 0; z-index: 45;
  width: min(350px, 84vw); background: var(--panel);
  border-right: 1px solid var(--border); box-shadow: 8px 0 24px
  rgba(0,0,0,.35); padding: 16px 12px;
  display: flex; flex-direction: column; gap: 8px;
  overflow-y: auto; transform: translateX(-105%);
  transition: transform .2s ease; }
.modeMenu.open { transform: translateX(0); }
/* in the reader the closed menu casts no shadow: on a light page its edge
   would show as a grey strip down the left side */
html.rdblack .modeMenu:not(.open) { box-shadow: none; }
.menulabel { font-size: 10px; font-weight: 700; color: var(--dim);
  text-transform: uppercase; letter-spacing: .8px; margin: 0 4px 4px; }
/* the brand owns the drawer's head, since the schedule column starts at
   the week bar */
.brandhead { display: flex; align-items: center; gap: 7px;
  padding: 6px 8px 14px; margin: 2px 0 4px;
  border-bottom: 1px solid var(--border); font-size: 13.5px; }
.brandhead .pepe { width: 22px; height: 22px; border-radius: 6px;
  filter: drop-shadow(0 0 4px rgba(167,139,250,.22)); }
.brandhead b { filter: drop-shadow(0 0 4px rgba(167,139,250,.22)); }
.brandhead span { font-size: 12px; color: var(--dim); opacity: .4;
  font-weight: 500; margin-left: 2px; }
.brandhead em { font-style: normal; font-size: 9.5px; color: var(--dim);
  opacity: .55; font-weight: 600; letter-spacing: .6px;
  margin-left: auto; }
.menuitem { width: 100%; justify-content: flex-start;
  padding: 11px 12px; font-size: 13.5px; }
/* mode buttons share one surface; the active one gets an accent wash,
   accent text and an accent icon */
.menuitem { color: var(--text); border-color: var(--border);
  background: none; }
.menuitem:hover { background: var(--panel2); }
.menuitem svg { color: var(--dim); transition: color .15s; }
.menuitem:hover svg { color: var(--text); }
/* the courses under Learn mode: a pick switches and opens Learn */
/* a menu row's news tag (update.js): a gradient outline round the menu's
   own color */
.menuitem .newtag { position: relative; margin: -4px 0 -4px auto;
  display: flex; align-items: center; gap: 6px; padding: 4px 11px 4px 9px;
  border-radius: 999px; color: #e6e0f5;
  font: 600 11px/1.2 Geist, Inter, system-ui, sans-serif; white-space: nowrap; }
.menuitem .newtag i { width: 5px; height: 5px; border-radius: 50%;
  background: #c4b5ff; flex-shrink: 0; }
/* a 1px gradient outline alone, the row showing through inside */
.menuitem .newtag::before { content: ""; position: absolute; inset: 0;
  border-radius: inherit; padding: 1px; opacity: .6;
  background: linear-gradient(90deg, #8b74e8, #d08bd8);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor; mask-composite: exclude; pointer-events: none; }
/* one accent for every mode's active icon, no hue per mode */
.menuitem.active svg { color: var(--accent2); }
.menuitem.active, .menuitem.active:hover {
  background: color-mix(in srgb, var(--hov) 13%, transparent);
  border-color: color-mix(in srgb, var(--hodb) 32%, transparent);
  color: var(--hovt); }
/* foldable header buttons: chevron on the right, rotates when open */
.menuitem .chev { margin-left: auto; font-size: 11px;    transition: transform .18s; }
.menuitem.open .chev { transform: rotate(180deg); }
.examgroup { display: flex; flex-direction: column; gap: 8px; }
.examgroup.collapsed { display: none; }
/* the AI fold: chats are a sub-section indented to the mode buttons' text
   column; "New chat" is a sibling item, threads sit one level in */
#chatgroup { gap: 1px; padding: 2px 0 6px 0; margin-top: 0; }
#chatgroup .chatrow { display: flex; align-items: center; gap: 8px;
  width: 100%; padding: 7px 12px 7px 33px; border: none;
  background: none; border-radius: 9px; font-size: 12.5px;
  color: var(--dim); cursor: pointer; text-align: left;
  font-family: inherit; transition: background .15s, color .15s; }
#chatgroup .chatrow:hover { background: var(--panel2);
  color: var(--text); }
#chatgroup .chatrow:focus-visible { outline: 2px solid
  color-mix(in srgb, var(--accent) 55%, transparent);
  outline-offset: -2px; }
#chatgroup .chatrow.active { color: var(--text);
  background: color-mix(in srgb, var(--hov) 13%, transparent); }
#chatgroup .chatrow .nm { flex: 1; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; }
#chatgroup .chatrow .when { flex-shrink: 0; font-size: 10.5px;
  color: color-mix(in srgb, var(--dim) 55%, transparent);
  font-variant-numeric: tabular-nums; }
/* the new-chat affordance lives inside the AI mode button so it doesn't
   read as a sixth mode button */
.aibtn { position: relative; }
.newplus { position: absolute; right: -1px; top: -1px; bottom: -1px;
  display: inline-flex; align-items: center; gap: 6px;
  padding: 0 12px; color: var(--dim); cursor: pointer;
  font-size: 12.5px; font-weight: 600;
  border-left: 1px solid var(--border);
  border-radius: 0 9px 9px 0;
  transition: color .15s, background .15s; }
.newplus svg { flex-shrink: 0; }
.newplus:hover { color: var(--text); background: var(--panel2); }
.newplus:focus-visible { outline: 2px solid
  color-mix(in srgb, var(--accent) 55%, transparent);
  outline-offset: -2px; }
/* delete ✕ at the row's right end: hover reveals it on desktop, touch
   shows it faintly (no hover). The hit area overhangs the row's right
   padding so a thumb tap can't land on the title */
#chatgroup .cdel { display: inline-flex; align-items: center;
  justify-content: center; width: 22px; height: 22px;
  margin: -4px -6px -4px 0; padding: 4px 6px; box-sizing:
  content-box; border-radius: 8px; color: var(--dim); opacity: 0;
  cursor: pointer; flex-shrink: 0; transition: opacity .15s,
  color .15s, background .15s; }
#chatgroup .chatrow:hover .cdel,
#chatgroup .chatrow.active .cdel { opacity: .55; }
#chatgroup .cdel:hover { opacity: 1; color: var(--red);
  background: color-mix(in srgb, var(--red) 13%, transparent); }
#chatgroup .chatrow.arm { color: var(--red);
  background: color-mix(in srgb, var(--red) 9%, transparent); }
/* armed (waiting for the second tap): a red "delete" pill replaces the ✕ */
#chatgroup .chatrow.arm .cdel { opacity: 1; color: var(--red);
  background: color-mix(in srgb, var(--red) 16%, transparent);
  width: auto; padding-inline: 9px; border-radius: 999px; }
#chatgroup .chatrow.arm .cdel svg { display: none; }
#chatgroup .cdel .ctxt { display: none; font-size: 10.5px;
  font-weight: 600; letter-spacing: .3px; }
#chatgroup .chatrow.arm .cdel .ctxt { display: inline; }
@media (hover: none) {
  #chatgroup .cdel { opacity: .45; }
}
#chatgroup .chatrow.chatmore { padding: 6px 12px 6px 33px;
  font-size: 11.5px; color: color-mix(in srgb, var(--dim) 60%,
  transparent); background: none; }
#chatgroup .chatrow.chatmore:hover { color: var(--dim);
  background: none; }
#chatgroup .chatempty { font-size: 11.5px;
  color: color-mix(in srgb, var(--dim) 65%, transparent);
  padding: 4px 12px 6px 33px; }
#aibtn.open { color: var(--accent); }
.scopenote { font-size: 11px; color: var(--dim); padding: 2px 11px; }
.setbtn { color: var(--text); }
.setbtn:hover { background: var(--panel2); }
/* bug report + settings pin to the drawer's bottom so an expanded chat
   list scrolls under them; margin-top:auto anchors them on short lists */
#bugmenubtn, #setmenubtn { position: sticky; bottom: 0;
  background: var(--panel); z-index: 2;
  box-shadow: 0 14px 0 var(--panel); }
#bugmenubtn { margin-top: auto; }
/* utility entries sit a size below the mode buttons, with space above */
.menuitem.small { padding: 8px 10px; font-size: 12.5px;
  border-radius: 8px; }
.menuitem.small svg { width: 13px; height: 13px; }
.menuitem .mini { margin-left: auto; flex-shrink: 1;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-size: 9px; font-weight: 600; letter-spacing: .3px;
  color: var(--dim); opacity: .6; }
/* the report button: label and joke share a baseline, icon stays centered */
.bugbtn { margin-top: auto; align-items: baseline; }
.bugbtn svg { align-self: center; }
.menulabel.modehead { margin-top: 12px; }
/* the chat view gets the same boxless hamburger as the schedule */
.chathead .menubtn { width: 50px; height: 46px; padding: 0;
  justify-content: center; color: var(--text);
  background: none; border: none; border-radius: 10px; }
.chathead .menubtn:hover { color: #fff;
  background: rgba(255,255,255,.06); }
.chathead .menubtn:active { transform: scale(.92); }

/* ---- settings modal ---- */
.setlabel { color: var(--dim); font-size: 11.5px; text-transform: uppercase;
  letter-spacing: .4px; margin: 14px 0 5px; text-align: left; }
.instaltut { margin-top: 10px; padding: 10px 12px; background: var(--panel2);
  border: 1px solid var(--border); border-radius: 8px; font-size: 12.5px;
  color: var(--dim2); line-height: 1.5; text-align: left; }
.instaltut.hidden { display: none; }
.instaltut ol { margin: 6px 0 0; padding-left: 18px; display: flex;
  flex-direction: column; gap: 4px; }
.instaltut strong { color: var(--text); }
.setkeycode { display: block; font: 13px/1.6 ui-monospace, Menlo, monospace;
  background: var(--panel2); border: 1px solid var(--border);
  border-radius: 8px; padding: 8px 10px; margin-top: 6px;
  letter-spacing: .5px; word-break: break-all; text-align: left; }
.setbtns { display: flex; gap: 8px; margin-top: 8px; }
.setbtns button { background: var(--panel2); color: var(--text);
  margin-top: 0; width: auto; flex: 1; }
.setbtns button:hover { border-color: var(--hodb); background: var(--panel2); }

/* ---- calendar sync (unsynced card + popup + settings section) ---- */
/* amber, like the exam accents: a warning, but in the panel's palette */
/* the unsynced course renders as a plain day card; only an amber outline
   and a short warning set it apart */
.unsyncday { border-color: rgba(255,201,122,.55); }
/* the warning reads as a quiet link; the why lives on its tooltip */
.unsynccta { margin-left: auto; flex-shrink: 0; background: none;
  border: none; color: #ffcf8a; font-size: 12px; font-weight: 600;
  cursor: pointer; text-decoration: underline; text-underline-offset: 2px;
  text-decoration-color: rgba(255,201,122,.5); }
.unsynccta:hover { color: #ffe2b0; text-decoration-color: #ffe2b0; }
/* the head's course link: the lecture-row course-name look, in the course color */
.unsyncday .coursename { font-weight: 700;
  color: var(--course, var(--text)); }
.unsyncday .coursename.bspace:hover .cname {
  text-decoration: underline; text-underline-offset: 2px; }
.synccard { position: relative; width: 560px;
  max-width: calc(100vw - 40px); text-align: left; }
.synccard h2 { text-align: center; }
.syncintro { color: var(--dim); font-size: 13px; margin: 6px 0 12px; }
.syncintro b { color: var(--text); }
/* explicit .keycard overrides: the base rules force full-width accent
   styling on every button and input in a card */
.keycard button.modalx { position: absolute; top: 10px; right: 12px;
  width: auto; margin: 0; padding: 4px 9px; background: none;
  border: none; border-radius: 8px; color: var(--dim); font-size: 15px;
  font-weight: 400; line-height: 1; letter-spacing: 0; cursor: pointer;
  transition: color .15s, background .15s; }
.keycard button.modalx:hover { color: var(--text); background: var(--panel2); }
/* the university timetable link to open */
.roosterlink { display: flex; align-items: center; justify-content: center;
  gap: 6px; margin: 0 0 12px; padding: 8px 10px; border-radius: 9px;
  border: 1px solid rgba(123,108,230,.45); background: rgba(123,108,230,.12);
  color: var(--accent2); font-size: 12.5px; font-weight: 600;
  text-decoration: none; transition: border-color .15s, background .15s; }
.roosterlink:hover { border-color: var(--hodb); background: rgba(123,108,230,.2); }
/* the how-to: three tiny drawn screens of the university app. The screens
   are faded; rings, badges, and arrow sit at full strength on top so the
   eye goes straight to what to tap */
.syncguide { display: flex; gap: 10px; margin: 2px 0 14px;
  animation: swapin .3s ease .05s backwards; }
.syncshot { flex: 1; min-width: 0; text-align: center; }
.sscreen { position: relative; height: 104px; border-radius: 10px;
  background: #10141c; border: 1px solid var(--border);
  overflow: hidden; text-align: left; }
.sshead { display: flex; align-items: center; gap: 6px; height: 20px;
  padding: 0 8px; background: #1b2653; color: rgba(232,234,246,.75);
  font-size: 8.5px; font-weight: 600; white-space: nowrap; }
.sshead.sscenter { justify-content: center; }
/* header labels shrink with an ellipsis instead of clipping */
.sshead .sst { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.ssburger { position: relative; width: 10px; height: 7px; flex-shrink: 0;
  border-top: 1.5px solid rgba(232,234,246,.75);
  border-bottom: 1.5px solid rgba(232,234,246,.75); }
.ssburger::after { content: ""; position: absolute; left: 0; right: 0;
  top: 1.75px; height: 1.5px; background: rgba(232,234,246,.75); }
.ssrow { padding: 7px 8px 0; }
.ssrow i { display: block; height: 5px; border-radius: 2px;
  background: rgba(232,234,246,.38); margin-bottom: 5px; }
.ssrow i.d { background: rgba(232,234,246,.15); }
.syncshot:hover .ssrow i { background: rgba(232,234,246,.5); }
.syncshot:hover .ssrow i.d { background: rgba(232,234,246,.2); }
.sslist { display: grid; gap: 3px; padding: 5px 6px; }
.ssitem { position: relative; font-size: 7.5px; line-height: 1.25;
  color: rgba(232,234,246,.55); background: rgba(232,234,246,.06);
  border: 1px solid rgba(232,234,246,.14); border-radius: 3px;
  padding: 4px 6px; padding-right: 20px; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; }
.ssitem.hl { color: #fff; border-color: var(--accent);
  background: rgba(123,108,230,.28);
  box-shadow: 0 0 0 1px rgba(123,108,230,.35); }
.ssurl { position: relative; display: flex; align-items: center;
  gap: 5px; margin: 9px 7px 0; padding: 5px 7px;
  background: rgba(232,234,246,.08);
  border: 1px solid rgba(232,234,246,.22); border-radius: 4px;
  font-size: 7.5px; color: rgba(232,234,246,.6); white-space: nowrap;
  overflow: hidden; }
/* the copy button, drawn: two stacked squares */
.sscpy { position: relative; width: 7px; height: 8px; flex-shrink: 0;
  border: 1px solid rgba(232,234,246,.8); border-radius: 1px;
  box-shadow: 0 0 0 1.5px var(--accent), 0 0 0 4px rgba(123,108,230,.25); }
.sscpy::after { content: ""; position: absolute; left: 2.5px; top: -3.5px;
  width: 7px; height: 8px; border: 1px solid rgba(232,234,246,.8);
  border-radius: 1px; background: #10141c; }
/* ring drawn onto the element it circles, softly breathing */
@keyframes ssblink {
  0%, 100% { box-shadow: 0 0 0 1.5px var(--accent),
    0 0 0 4px rgba(123,108,230,.25); }
  50% { box-shadow: 0 0 0 1.5px var(--accent),
    0 0 0 8px rgba(123,108,230,.05); }
}
.ssburger { animation: ssblink 2.4s ease-in-out infinite; }
.sscpy { animation: ssblink 2.4s ease-in-out .5s infinite; }
@keyframes ssblink2 {
  0%, 100% { box-shadow: 0 0 0 1px rgba(123,108,230,.35); }
  50% { box-shadow: 0 0 0 4px rgba(123,108,230,.08); }
}
.ssitem.hl { animation: ssblink2 2.4s ease-in-out 1s infinite; }
/* numbered step badges */
.ssbadge { position: absolute; z-index: 2; width: 13px; height: 13px;
  border-radius: 50%; background: var(--accent); color: #fff;
  font-size: 8.5px; font-weight: 700; display: flex; align-items: center;
  justify-content: center; box-shadow: 0 1px 4px rgba(0,0,0,.4); }
/* screen 1's badge sits in the header's free right side, clear of the label */
.ssbadge.b1 { right: 6px; top: 3.5px; }
/* sequence chevrons between the three screens */
.sssep { align-self: center; flex-shrink: 0; color: var(--dim);
  opacity: .65; font-size: 15px; line-height: 1; padding: 0 0; }
.ssitem .ssbadge { right: 3px; top: 50%; transform: translateY(-50%); }
.ssurl .ssbadge { right: -5px; top: -16px; }
/* the copied link flows down out of the mini screen into the paste box below */
.ssarrow { position: absolute; right: 18px; bottom: 1px; }
.sscap { margin-top: 6px; font-size: 11px; color: var(--dim); }
.syncnote { margin-top: 10px; text-align: center; font-size: 11.5px;
  color: var(--dim); }
.syncsecondary { background: none !important; border: 1px solid var(--border);
  color: var(--dim) !important; }
.syncsecondary:hover { color: var(--text) !important;
  background: var(--panel2) !important; border-color: var(--hodb); }
.setbtns button.primary { background: var(--accent); border: none;
  color: #fff; }
.setbtns button.primary:hover { background: var(--hov); }
.setbtns button:disabled { opacity: .45; cursor: default; }
/* paste-an-iCal-link row (popup + settings) */
.urlrow { display: flex; gap: 8px; margin-top: 8px; }
.urlrow input { flex: 1; min-width: 0; background: var(--panel2);
  border: 1px solid var(--border); border-radius: 9px;
  color: var(--text); font: 12.5px/1.4 Geist, Inter, sans-serif;
  padding: 9px 10px; outline: none; }
.urlrow input:focus { border-color: var(--accent); }
.urlrow input::placeholder { color: var(--dim); }
.urlrow button { flex-shrink: 0; margin-top: 0; background: var(--accent);
  border: none; color: #fff; border-radius: 9px; padding: 9px 14px;
  font-size: 13px; cursor: pointer; }
.urlrow button:hover { background: var(--hov); }
.urlrow button:disabled { opacity: .45; cursor: default; }
/* stacked like the sync modal (the shared .keycard rules would crush it) */
#settings .urlrow { flex-direction: column; gap: 8px; margin-top: 10px; }
#settings .urlrow input { width: 100%; text-align: left;
  font: 13px/1.4 Geist, Inter, sans-serif; letter-spacing: 0; padding: 11px 12px; }
#settings .urlrow button { width: 100%; padding: 10px; font-size: 13.5px; }
/* calendar status: a dot (gray = not synced, green = synced), with Remove
   on the right when there is something to remove */
.calrow { display: flex; align-items: center; gap: 10px; margin: 2px 0 2px; }
.calstat { flex: 1; min-width: 0; font-size: 13px; color: var(--dim);
  display: flex; align-items: center; gap: 7px; }
.calstat::before { content: ""; width: 7px; height: 7px; flex-shrink: 0;
  border-radius: 50%; background: var(--dim); opacity: .5; }
.calstat.synced { color: var(--text); }
.calstat.synced::before { background: var(--green); opacity: 1; }
.calremove { flex-shrink: 0; background: none;
  border: 1px solid var(--border); border-radius: 8px; color: var(--dim);
  font-size: 12px; cursor: pointer; padding: 5px 11px;
  transition: color .15s, border-color .15s, background .15s; }
.calremove:hover { color: var(--red); border-color: var(--red); }
.calremove.armed { color: #fff; background: var(--red);
  border-color: var(--red); }
/* one wide input with Sync full-width below (the shared .keycard rules
   would crush the input inside the flex row) */
#syncmodal .urlrow { flex-direction: column; gap: 8px; margin-top: 4px; }
#syncmodal .urlrow input { width: 100%; text-align: left;
  font: 13px/1.4 Geist, Inter, sans-serif; letter-spacing: 0; padding: 11px 12px; }
#syncmodal .urlrow button { width: 100%; padding: 10px; font-size: 13.5px; }

/* each mode fades in as its own page (own URL, back gesture works) */
@keyframes viewin { from { opacity: .35; } to { opacity: 1; } }
body.taskmode .tasks, body.chatmode .chatcol, body.exammode .examcol,
body.readermode #readercol { animation: viewin .16s ease-out; }

/* ---- views: tasks (default) vs chat (AI mode) ---- */
body.taskmode .chatcol,
body.taskmode .railbtn { display: none !important; }
body.taskmode .tasks { position: static; width: 100%; height: 100vh;
  border-left: none; box-shadow: none; padding: 0 18px 40px; }
body.taskmode .tasks > * { max-width: 1200px; width: 100%;
  margin-left: auto; margin-right: auto; }
/* title and button row span the full page so the menu and collapse
   buttons sit at the outer edges and the title stays centered */
body.taskmode .tasks > .weekbar { max-width: none; }
body.taskmode #collapseTasks { display: none; }
body.taskmode .tasks::after { width: 100%; }
/* AI mode is a full-width conversation; its chats live under the AI menu item */
body.chatmode .tasks, body.chatmode #openTasks {
  display: none !important; }
body.chatmode .chatcol { width: 100%; box-shadow: none; }
button { touch-action: manipulation;
  -webkit-tap-highlight-color: transparent; }
/* pills are divs, not buttons: without this, a tap flashes a gray square
   over the rounded chip on mobile */
.pill { touch-action: manipulation;
  -webkit-tap-highlight-color: transparent; }

@media (max-width: 900px) {
  body { overflow: auto; }
  .app { height: auto; min-height: 100vh; }
  /* pin the chat column to the viewport so the input bar stays in reach */
  .chatcol { position: fixed; inset: 0; }
  .tasks { box-shadow: none; }
  .chathead { padding: 10px 12px; }
  /* the empty chat keeps the thread at natural height so the week carousel
     and material tree sit above the pinned input bar without scrolling */
  .thread { min-height: 0; }
  .chips { padding: 0 16px 10px; }
  .chatweek { padding: 0 16px 6px; }
  /* the box clears the home indicator (safe-area) and rides above the open
     keyboard (--kb) */
  .inputwrap { padding: 6px 16px
    calc(10px + env(safe-area-inset-bottom, 0px) + var(--kb, 0px)); }
  .msg.user { max-width: 85%; }
  /* phones: panels hug the screen edge, but task mode is the whole page and
     must keep filling it */
  .tasks { width: min(470px, 100vw); }
  body.taskmode .tasks { width: 100vw; padding: 0 6px 40px; }
  /* tighter edge room goes through the same variables, so the pill pull
     recomputes and stays flush */
  .day { padding: 8px 8px 12px; --tb-x: 9px; }
  .thread { padding: 16px 16px 8px; }
  /* the disclaimer: tiny, one line, leaving the thread the spare height */
  .disclaimer { padding: 0 16px 4px; font-size: 9.5px; }
  /* pills run nearly to the edge; the checkbox stays inset so a thumb can't
     overshoot it */
  .taskblock { margin-right: 6px; }
  .pill { padding-right: 10px; }
  .pill .box { margin-right: 12px; }
  /* shorten the link so the checkbox keeps clear space (the full name stays
     in the title attribute) */
   .pill .pname a { max-width: 60vw; }
  .weekbar .arrow { width: 42px; height: 44px; }
  .wkmenu { width: 40px; height: 40px; border-radius: 10px; }
  .wkhid { width: 36px; height: 36px; }
  .weekchip { min-width: 66px; padding: 8px 8px 7px; }
  .card { min-height: 48px; }
  .pill { min-height: 45px; }
  .iconbtn { padding: 6px 11px; }
}
@media (max-width: 640px) {
  /* phones drop the locator hints and parenthetical suffixes first */
  #checklist .pill .phint,
  #checklist .pill .pname .suf { display: none; }
  /* a wider drawer puts the mode buttons closer to mid-screen, within reach */
  .modeMenu { width: min(320px, 94vw); }
  /* outlined rows: on glass a tap target needs a visible edge */
  .modeMenu .menuitem { padding: 13px 14px; font-size: 14px;
    border: 1px solid var(--border); background:
    color-mix(in srgb, var(--panel2) 45%, transparent); }
  .modeMenu .menuitem.active { border-color:
    color-mix(in srgb, var(--accent) 35%, var(--border)); }
  /* the utility entries stay compact even when the mode buttons grow */
  .modeMenu .menuitem.small { padding: 8px 10px; font-size: 12.5px; }
  /* the chat sub-section and the New chat zone grow with the mode buttons */
  #chatgroup .chatrow { padding: 9px 12px 9px 33px; font-size: 13.5px; }
  #chatgroup .cdel { width: 26px; height: 26px; }
  #chatgroup .chatrow.chatmore { padding-top: 8px; padding-bottom: 8px; }
  .newplus { padding: 0 14px; font-size: 13.5px; }
  /* compact stacked week header: tighter title row, dash row hugs the edge */
  .wktitle { font-size: 13px; }
  .weekstrip-box { padding: 0 4px 2px; }
  .wk-context { gap: 6px; padding: 7px 0 8px; }
  .wk-left { gap: 6px; }
  /* the actions take their own line under the title — no overlap */
  .wk-right { gap: 5px; }
  .markchip { padding: 4px 8px; font-size: 11.5px; gap: 6px; }
  .infobtn { font-size: 11px; }
}

/* ---- one header for every mode, learn mode's ----
   A 42px strip over a 2px hairline, a boxless 40px hamburger with a 26px
   glyph in --dim2, the title in Inter 600 15px, and quiet text actions.
   The learn header (trainers.css) is the reference and stays as it is. */
.chathead, .readerhead, .examhead { height: 44px; padding: 0 6px 0 4px;
  gap: 2px; border-bottom: 2px solid rgba(255,255,255,.06); }
.chathead .menubtn, .readerhead .readermenu, .examhead .exammenu,
.wk-top .wkmenu { width: 40px; height: 40px; padding: 0; border: 0;
  background: none; color: var(--dim2); border-radius: 10px;
  display: grid; place-items: center; position: static; top: auto;
  flex-shrink: 0; transition: color .15s, background .15s; }
.chathead .menubtn:hover, .readerhead .readermenu:hover,
.examhead .exammenu:hover, .wk-top .wkmenu:hover { color: var(--text);
  background: rgba(255,255,255,.05); }
.chathead .menubtn svg, .readerhead .readermenu svg,
.examhead .exammenu svg, .wk-top .wkmenu svg { width: 26px; height: 26px;
  stroke-width: 2.4; }
/* titles: one face and size everywhere */
.chathead .title { padding: 0 8px; color: var(--text);
  font: 600 15px/1.2 Geist, Inter, system-ui, sans-serif; }
.readerhead > div { display: flex; align-items: baseline; gap: 10px;
  min-width: 0; padding: 0 8px; }
.readerhead h2, .examhead .examtitle h2 {
  font: 600 15px/1.2 Geist, Inter, system-ui, sans-serif; color: var(--text);
  white-space: nowrap; }
.readerhead .crumb { font-size: 12.5px; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; }
.examhead .examtitle { min-width: 0; padding: 0 8px; }
.examhead .examtitle .crumb { font-size: 11.5px; margin-top: 1px; }
.wk-top .wktitle { font: 600 15px/1.2 Geist, Inter, system-ui, sans-serif; }
/* exam's Stats reads like learn's Progress: text and a glyph, no box */
#examcol .examheadbtns .stattxt { height: 40px; padding: 0 12px; border: 0;
  background: none; color: var(--dim); border-radius: 10px;
  font: 600 14px/1 Geist, Inter, system-ui, sans-serif; gap: 7px; }
#examcol .examheadbtns .stattxt:hover { color: var(--text); }
#examcol .examheadbtns .stattxt svg { color: currentColor; }
#examcol .examheadbtns .stattxt.back { color: var(--accent2); padding: 0 12px; }
@media (max-width: 640px) {
  /* the reader's tagline is a desktop nicety; phones keep the title */
  .readerhead .crumb { display: none; }
  /* learn's phone title slot */
  .chathead .title, .readerhead > div, .examhead .examtitle { padding: 0 6px; }
  /* the schedule's header sits in a padded panel: pull its hamburger onto
     the same spot as every other mode's */
  .wk-top .wkmenu { margin-left: -6px; }
  .wk-top { margin-top: -6px; }
  .wk-top .wktitle { margin-left: -2px; }
  #examcol .examheadbtns .stattxt { padding: 0 10px 0 8px; gap: 6px; }
}
/* the narrowest phones: the disclaimer still fits on one line */
@media (max-width: 380px) { .disclaimer { font-size: 9px; } }
