/* ── ILMI app layer v3 — calm paper workspace ─────────────────────────────
   Loaded after base.css. One paper canvas (no desk), a labeled sidebar with
   the student's subjects, a shared page header, cards with tracked data only,
   and a single mobile top bar. Tokens come from tokens.css. */

:root {
  --sb-w: 236px;
  --page-max: 1160px;
  --line: rgba(26,20,16,0.10);
  --card-radius: 10px;
}

/* ── Canvas ─────────────────────────────────────────────────────────────── */
.app-main { background: var(--bg); }
.today-scroll, .practice-scroll, .mat-scroll, .prof-scroll {
  border: none; background: transparent;
}
.page {
  flex: 1; overflow-y: auto;
  width: 100%; max-width: var(--page-max);
  margin: 0 auto;
  padding: 44px 56px 80px;
}
.studio-wrap.page { overflow-y: auto; }
.prof-scroll.page .prof-inner { max-width: 760px; margin: 0; }
.muted-note { font-size: 15px; color: var(--dim); padding: 12px 0; }

/* ── Page header (every view) ───────────────────────────────────────────── */
.page-head { margin-bottom: 32px; }
.page-head-split { display: flex; align-items: flex-end; justify-content: space-between; gap: 32px; }
.page-eyebrow {
  font-family: var(--mono); font-size: 11px; font-weight: 500;
  letter-spacing: 0.16em; text-transform: uppercase; color: var(--muted);
  margin-bottom: 12px;
}
.page-title {
  font-family: var(--display); font-weight: 600;
  font-size: 40px; line-height: 1.08; letter-spacing: -0.02em;
  color: var(--text); margin: 0;
}
.page-sub {
  font-family: var(--serif); font-size: 18px; color: var(--muted);
  margin: 10px 0 0; line-height: 1.45;
}

/* Section header inside a page */
.block-head {
  display: flex; align-items: baseline; justify-content: space-between;
  margin: 40px 0 16px;
}
.block-title {
  font-family: var(--display); font-weight: 600; font-size: 24px;
  letter-spacing: -0.015em; margin: 0; color: var(--text);
}
.block-meta { font-family: var(--serif); font-size: 15px; color: var(--muted); }

/* ── Buttons ────────────────────────────────────────────────────────────── */
.btn-primary {
  display: inline-flex; align-items: center; gap: 8px; flex-shrink: 0;
  background: var(--accent); color: #fbf6ec;
  border: none; border-radius: 7px;
  padding: 11px 18px;
  font-family: var(--serif); font-size: 16px; font-weight: 600;
  cursor: pointer; transition: background 0.15s;
}
.btn-primary:hover, .btn-primary.active { background: var(--accent-deep); }

/* ── Sidebar ────────────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sb-w); min-width: var(--sb-w);
  align-items: stretch;
  padding: 26px 14px 14px;
  background: var(--bg2);
  border-right: 1px solid var(--line);
}
/* Wordmark — matches the logo: classic serif caps, a long thin rule beneath */
.sb-wordmark {
  display: block; text-align: center; text-decoration: none;
  font-family: var(--serif); font-weight: 700; font-size: 30px; line-height: 1;
  letter-spacing: 0.1em; color: var(--accent);
  padding-left: 0.1em;               /* optically centre the tracked letters */
  margin-bottom: 34px; position: relative;
}
.sb-wordmark::after {
  content: ''; position: absolute; left: 50%; bottom: -11px;
  width: 44px; height: 2px; border-radius: 2px; background: var(--accent); transform: translateX(-50%);
}
.sb-nav { gap: 2px; width: 100%; }
.sb-nav-item {
  width: 100%; height: 40px;
  justify-content: flex-start; gap: 12px;
  padding: 0 12px; border-radius: 7px;
  font-family: var(--serif); font-size: 17px; font-weight: 600;
  color: var(--text);
}
.sb-nav-item span { display: inline; }
.sb-nav-item svg { width: 17px; height: 17px; color: var(--muted); flex-shrink: 0; }
.sb-nav-item::after { content: none; display: none; }
.sb-nav-item:hover { background: rgba(26,20,16,0.045); color: var(--text); }
.sb-nav-item.active { background: var(--accent-soft); color: var(--accent); }
.sb-nav-item.active svg { color: var(--accent); }
.sb-nav-item.active::before { left: -14px; width: 3px; height: 22px; border-radius: 0 2px 2px 0; }

.sb-section-label {
  display: block;
  font-family: var(--mono); font-size: 10px; font-weight: 500;
  letter-spacing: 0.16em; text-transform: uppercase; color: var(--muted);
  margin: 30px 12px 8px;
}
.sb-subjects {
  display: flex; flex-direction: column; gap: 1px;
  flex: 1; min-height: 0; overflow-y: auto;
  margin: 0 -4px; padding: 0 4px;
}
.sb-subject-row {
  display: flex; align-items: center; gap: 10px;
  width: 100%; text-align: left;
  padding: 6px 12px; border-radius: 6px;
  background: none; border: none; cursor: pointer;
  font-family: var(--serif); font-size: 15.5px; color: var(--text);
}
.sb-subject-name { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-subject-row:hover { background: rgba(26,20,16,0.045); }
.sb-subject-row.active { color: var(--accent); font-weight: 600; }
.sb-subject-dot { width: 5px; height: 5px; border-radius: 50%; background: var(--border2); flex-shrink: 0; }
.sb-subject-row.active .sb-subject-dot { background: var(--accent); }

.sb-user { margin-top: 12px; width: 100%; padding-top: 12px; border-top: 1px solid var(--line); }
.sb-user-card {
  width: 100%; height: auto; border-radius: 8px;
  background: transparent; color: var(--text);
  display: flex; align-items: center; justify-content: flex-start; gap: 10px;
  padding: 8px 10px;
}
.sb-user-card:hover { background: rgba(26,20,16,0.045); }
.sb-user-card:empty { display: none; }
.sb-avatar {
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--accent); color: #fbf6ec;
  font-family: var(--serif); font-size: 16px; font-weight: 700;
}
.sb-user-info { display: flex; flex-direction: column; min-width: 0; }
.sb-user-name {
  display: block; font-family: var(--serif); font-size: 16px; font-weight: 600; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sb-user-sub {
  display: block; font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.04em;
  color: var(--muted); margin-top: 1px;
}

/* ── Mobile top bar (hidden on desktop) ─────────────────────────────────── */
.mobile-bar { display: none; }
.mobile-menu-btn, .hamburger-btn { display: none !important; }

/* ── Shared tiles ───────────────────────────────────────────────────────── */
.tile-icon {
  width: 38px; height: 38px; border-radius: 9px; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--accent-soft); color: var(--accent);
  border: 1px solid var(--accent-border);
}
.tile-icon svg { width: 18px; height: 18px; }
.tile-icon-sm { width: 32px; height: 32px; border-radius: 8px; }
.tile-icon-sm svg { width: 15px; height: 15px; }
.tile-arrow { width: 18px; height: 18px; color: var(--muted); transition: transform 0.15s, color 0.15s; }

.bar { flex: 1; height: 4px; border-radius: 4px; background: rgba(26,20,16,0.08); overflow: hidden; }
.bar-fill { height: 100%; background: var(--accent); border-radius: 4px; }

/* ── Today: study path + stats ──────────────────────────────────────────── */
.today-top { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.today-top .path-card[style*="none"] + .stats-box { grid-column: 1 / -1; }

.path-card {
  margin: 0; padding: 26px 28px;
  background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--card-radius);
  box-shadow: var(--shadow-md);
  display: flex; flex-direction: column; justify-content: center;
}
.path-top { margin-bottom: 10px; }
.path-plan-label {
  font-family: var(--mono); font-size: 10.5px; font-weight: 500;
  letter-spacing: 0.16em; text-transform: uppercase; color: var(--accent);
}
.path-day-row { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.path-day-num { font-family: var(--display); font-size: 26px; font-weight: 600; }
.path-dot { color: var(--dim); }
.path-subject-name { font-family: var(--serif); font-size: 21px; font-weight: 600; color: var(--text); }
.path-focus-topic { font-family: var(--serif); font-size: 16px; color: var(--muted); margin-top: 4px; }
.path-prog-wrap { display: flex; align-items: center; gap: 14px; margin: 18px 0 20px; }
.path-prog-bar { flex: 1; height: 5px; border-radius: 5px; background: rgba(26,20,16,0.08); overflow: hidden; }
.path-prog-fill { height: 100%; background: var(--accent); border-radius: 5px; }
.path-prog-pct { font-family: var(--mono); font-size: 12px; color: var(--muted); }
.path-start-btn {
  align-self: flex-start;
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--accent); color: #fbf6ec;
  border: none; border-radius: 7px; padding: 11px 18px;
  font-family: var(--serif); font-size: 16px; font-weight: 600; cursor: pointer;
}
.path-start-btn:hover { background: var(--accent-deep); }
.path-card-continue .path-continue-note { display: none; }
.path-card-continue .path-subject-name { font-family: var(--display); font-size: 26px; }
.path-card-continue .path-start-btn { margin-top: 18px; }

.stats-box {
  display: grid; grid-template-columns: repeat(3, 1fr);
  background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--card-radius);
  box-shadow: var(--shadow-md);
}
.stats-box:empty { display: none; }
.stat {
  padding: 24px 18px; display: flex; flex-direction: column; justify-content: center;
  border-left: 1px solid var(--line); min-width: 0;
}
.stat:first-child { border-left: none; }
.stat-num {
  font-family: var(--display); font-weight: 600; font-size: 34px; line-height: 1;
  color: var(--text); letter-spacing: -0.02em;
}
.stat-num small { font-family: var(--serif); font-size: 17px; font-weight: 500; color: var(--muted); margin-left: 2px; }
.stat-label {
  font-family: var(--mono); font-size: 9.5px; font-weight: 500;
  letter-spacing: 0.13em; text-transform: uppercase; color: var(--muted);
  margin-top: 10px; line-height: 1.5;
}
.stats-box-sm { min-width: 380px; }
.stats-box-sm .stat { padding: 16px 18px; align-items: center; text-align: center; }
.stats-box-sm .stat-num { font-size: 26px; }

/* ── Subject cards (Today + Study Room picker) ──────────────────────────── */
.subject-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.subj-card {
  display: flex; flex-direction: column; text-align: left;
  min-height: 150px; padding: 20px 20px 18px;
  background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--card-radius);
  cursor: pointer; transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
}
.subj-card:hover { border-color: var(--accent-border); box-shadow: var(--shadow-md); transform: translateY(-1px); }
.subj-card:hover .tile-arrow { color: var(--accent); transform: translateX(2px); }
.subj-card-top { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 16px; }
.subj-name { font-family: var(--serif); font-size: 20px; font-weight: 600; line-height: 1.25; color: var(--text); }
.subj-exam {
  align-self: flex-start; margin-top: 6px;
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--accent); background: var(--accent-soft); border-radius: 4px; padding: 3px 7px;
}
.subj-exam.urgent { color: #fbf6ec; background: var(--accent); }
.subj-progress { display: flex; align-items: center; gap: 12px; margin-top: auto; padding-top: 16px; }
.subj-meta { font-family: var(--mono); font-size: 11px; color: var(--text); white-space: nowrap; }
.subj-meta.muted { color: var(--muted); }

/* ── Recent sessions ────────────────────────────────────────────────────── */
.recent-list { border: 1px solid var(--border); border-radius: var(--card-radius); background: var(--surface); overflow: hidden; }
.recent-row {
  display: flex; align-items: center; gap: 14px; width: 100%;
  padding: 14px 18px; text-align: left;
  background: none; border: none; border-top: 1px solid var(--line); cursor: pointer;
}
.recent-row:first-child { border-top: none; }
.recent-row:hover { background: rgba(26,20,16,0.03); }
.recent-body { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.recent-subject { font-family: var(--serif); font-size: 17px; font-weight: 600; color: var(--text); }
.recent-summary { font-family: var(--serif); font-size: 15px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.recent-date { font-family: var(--mono); font-size: 11px; color: var(--muted); flex-shrink: 0; }

/* ── Study Room ─────────────────────────────────────────────────────────── */
.studio-wrap.page { max-width: var(--page-max); }
.chat-panel { order: 1; }
.lesson-panel {
  order: 2;
  flex: 0 0 380px; width: 380px;
  border-left: 1px solid var(--line);
  background: var(--bg2);
  box-shadow: none;
}
.chat-topbar {
  height: 68px; padding: 0 28px;
  background: transparent;
  border-bottom: 1px solid var(--line);
}
.chat-frame-label {
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.16em; color: var(--muted);
}
.chat-subject-name { font-family: var(--display); font-size: 22px; font-weight: 600; }
.chat-topbar-right { gap: 8px; }
.chat-subject-select.ilmi-select { width: 210px; flex-shrink: 0; }
.chat-subject-block { min-width: 0; }
.chat-subject-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-subject-select .ilmi-select-btn { height: 36px; font-size: 15px; border-radius: 7px; }
.chat-subject-select .ilmi-select-list { width: max-content; min-width: 100%; max-width: 340px; right: 0; left: auto; }
.mode-pill { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 3px; }
.mode-seg { border-radius: 6px; }
.icon-btn { border-radius: 8px; width: 36px; height: 36px; background: var(--surface); }
.icon-btn.active { color: var(--accent); border-color: var(--accent-border); background: var(--accent-soft); }

.messages { padding: 36px 32px 24px; gap: 26px; }
.message-row.user .bubble {
  background: var(--accent); color: #fbf6ec;
  border-radius: 14px 14px 4px 14px;
  font-size: 16px; padding: 11px 18px;
}
.message-row.user .bubble code { background: rgba(255,255,255,0.18); color: #fbf6ec; }
.message-row.user .avatar {
  background: var(--surface); color: var(--text); border: 1px solid var(--border);
  font-family: var(--serif); font-weight: 700;
}
.message-row.ilmi .avatar { border-radius: 50%; }
.message-row.ilmi .bubble { font-size: 17px; line-height: 1.7; }
.input-area { padding: 12px 32px 22px; }
.input-wrap {
  border-radius: 12px; border-color: var(--border);
  background: var(--surface); padding: 8px 8px 8px 10px;
  box-shadow: var(--shadow-md);
}
.input-wrap textarea { font-size: 16px; }
.send-btn { width: 38px; height: 38px; }
.input-footer { font-family: var(--serif); font-size: 13px; }

/* Notes panel — a quiet paper sheet on the right */
.lp-header-slim { padding: 18px 22px 14px; border-bottom: 1px solid var(--line); }
.lp-eyebrow { font-family: var(--mono); font-size: 10px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--muted); }
.lp-header-slim .lp-subject { font-family: var(--display); font-size: 19px; font-weight: 600; }
.lp-notes-empty {
  font-family: var(--serif); font-size: 16px; color: var(--muted); line-height: 1.5;
  padding: 18px; border: 1px dashed var(--border2); border-radius: 8px; background: var(--surface);
}

/* ── Practice ───────────────────────────────────────────────────────────── */
.pmode-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; border: none; }
.pmode-card {
  display: flex; flex-direction: column; text-align: left;
  padding: 22px 22px 20px; min-height: 160px;
  background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--card-radius);
  cursor: pointer; transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
}
.pmode-card:hover { border-color: var(--accent-border); box-shadow: var(--shadow-md); transform: translateY(-1px); }
.pmode-card:hover .tile-arrow { color: var(--accent); transform: translateX(2px); }
.pmode-card-top { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 18px; }
.pmode-title { font-family: var(--serif); font-size: 21px; font-weight: 600; color: var(--text); }
.pmode-desc { font-family: var(--serif); font-size: 16px; color: var(--muted); margin-top: 4px; line-height: 1.45; }
.pmode-footer { margin-top: auto; padding-top: 12px; font-family: var(--mono); font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); border: none; }
.pmode-footer:empty, .pmode-footer span:empty { display: none; }
.pmode-badge {
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--muted); background: rgba(26,20,16,0.05); border: none; border-radius: 4px; padding: 3px 7px;
}
.pmode-badge:empty { display: none; }
.pmode-badge.live { color: var(--accent); background: var(--accent-soft); }

.weak-topics-list .empty-state, .empty-card {
  display: flex; flex-direction: column; align-items: flex-start; gap: 4px;
  padding: 22px 24px;
  background: var(--surface); border: 1px dashed var(--border2); border-radius: var(--card-radius);
}
.weak-topics-list .empty-state { flex-direction: row; align-items: center; gap: 14px; }
.empty-state-text, .empty-text { font-family: var(--serif); font-size: 16px; color: var(--muted); }
.empty-title { font-family: var(--serif); font-size: 18px; font-weight: 600; color: var(--text); }
.weak-topic-row {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 18px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--card-radius); margin-bottom: 8px;
}
.weak-topic-name { font-family: var(--serif); font-size: 17px; font-weight: 600; }
.weak-topic-subject { font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.06em; color: var(--muted); text-transform: uppercase; }
.weak-topic-cta {
  font-family: var(--serif); font-size: 15px; font-weight: 600; color: var(--accent);
  background: transparent; border: 1px solid var(--accent-border); border-radius: 7px; padding: 6px 14px; cursor: pointer;
}
.weak-topic-cta:hover { background: var(--accent-soft); }

/* ── Course Materials ───────────────────────────────────────────────────── */
.mat-upload-card {
  margin-bottom: 24px; padding: 22px 24px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--card-radius);
}
.mat-upload-note { font-family: var(--serif); font-size: 16px; color: var(--muted); margin: 0 0 16px; }
.mat-filters { display: flex; gap: 12px; margin-bottom: 16px; }
.mat-filter {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  padding: 0 12px; height: 42px;
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted);
}
.mat-filter select, .mat-filter input {
  border: none; background: transparent; outline: none;
  font-family: var(--serif); font-size: 16px; color: var(--text); letter-spacing: 0; text-transform: none;
  height: 100%; min-width: 0;
}
.mat-filter select { cursor: pointer; padding-right: 4px; }
.mat-filter-search { flex: 1; max-width: 360px; margin-left: auto; }
.mat-filter-search input { flex: 1; }
.mat-filter-search svg { color: var(--muted); flex-shrink: 0; }

.mat-table { border: 1px solid var(--border); border-radius: var(--card-radius); background: var(--surface); overflow: hidden; }
.mat-tr {
  display: grid; grid-template-columns: minmax(0, 2.4fr) minmax(0, 1.3fr) 80px 120px;
  align-items: center; gap: 16px;
  padding: 13px 20px; border-top: 1px solid var(--line);
}
.mat-tr:first-child { border-top: none; }
.mat-th {
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted);
  background: rgba(26,20,16,0.025); padding-top: 11px; padding-bottom: 11px;
}
.mat-name { display: flex; align-items: center; gap: 12px; min-width: 0; }
.mat-filename { font-family: var(--serif); font-size: 16px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mat-ext {
  flex-shrink: 0; width: 42px; text-align: center;
  font-family: var(--mono); font-size: 9.5px; font-weight: 700; letter-spacing: 0.04em;
  padding: 4px 0; border-radius: 4px; color: #fbf6ec; background: var(--muted);
}
.mat-ext.pdf  { background: var(--accent); }
.mat-ext.docx { background: #4b5a73; }
.mat-ext.pptx { background: var(--orange); }
.mat-ext.img  { background: #6b7a5a; }
.mat-pending {
  flex-shrink: 0; font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--orange); background: var(--orange-light); border-radius: 4px; padding: 3px 6px;
}
.mat-subj { font-family: var(--serif); font-size: 15.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mat-type, .mat-date { font-family: var(--mono); font-size: 11px; color: var(--muted); }
.mat-count { margin-top: 12px; }

/* ── Profile ────────────────────────────────────────────────────────────── */
.prof-hero, .prof-card, .prof-plan-card, .prof-danger-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--card-radius);
  box-shadow: none;
}
.prof-avatar { background: var(--accent); color: #fbf6ec; }
.prof-hero-chip {
  padding: 3px 9px; border-radius: 100px;
  font-family: var(--mono); font-size: 10px; font-weight: 500;
  letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--muted); border: 1px solid var(--border);
}

/* ── Sign in / sign up / onboarding ─────────────────────────────────────── */
.auth-overlay { background: var(--bg); backdrop-filter: none; }
.auth-card, .profile-ob-card {
  border-radius: 12px; padding: 40px 40px 34px;
  box-shadow: 0 1px 0 rgba(26,20,16,0.04), 0 30px 60px -40px rgba(26,20,16,0.35);
}
.auth-logo { margin-bottom: 30px; }
.auth-logo svg { display: none; }
.auth-logo-text {
  font-family: var(--serif); font-size: 28px; font-weight: 700; line-height: 1;
  letter-spacing: 0.1em; color: var(--accent);
  position: relative; padding-bottom: 10px;
}
.auth-logo-text::after {
  content: ''; position: absolute; left: 0; bottom: 0;
  width: 40px; height: 2px; border-radius: 2px; background: var(--accent);
}
.auth-card h2 { font-family: var(--display); font-size: 32px; font-weight: 600; letter-spacing: -0.02em; }
.auth-card p { font-family: var(--serif); font-size: 17px; }
.auth-field input, .ob-field input, .ob-field select {
  font-family: var(--serif); font-size: 16px; border-radius: 8px;
}
.auth-btn, .btn-continue {
  background: var(--accent); color: #fbf6ec; border-radius: 8px; padding: 13px;
  font-family: var(--serif); font-size: 17px; font-weight: 600;
  text-transform: none; letter-spacing: 0;
}
.auth-btn:hover, .btn-continue:hover { background: var(--accent-deep); }
.auth-switch { font-family: var(--serif); font-size: 15px; }

/* ── ILMI dropdown (static/js/select.js) ────────────────────────────────── */
.ilmi-select { position: relative; width: 100%; }
.ilmi-select-native {
  position: absolute !important; inset: 0; width: 1px !important; height: 1px !important;
  opacity: 0; pointer-events: none; border: 0 !important; padding: 0 !important;
}
.ilmi-select-btn {
  width: 100%; height: 44px; padding: 0 12px 0 14px;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  font-family: var(--serif); font-size: 16px; color: var(--text); text-align: left;
  cursor: pointer; transition: border-color 0.15s, box-shadow 0.15s;
}
.ilmi-select-btn:hover { border-color: var(--border2); }
.ilmi-select-btn:focus-visible, .ilmi-select.open .ilmi-select-btn {
  outline: none; border-color: var(--accent-border); box-shadow: 0 0 0 3px var(--accent-soft);
}
.ilmi-select-btn:disabled { opacity: 0.55; cursor: default; }
.ilmi-select-label { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ilmi-select-btn svg { width: 14px; height: 14px; flex-shrink: 0; color: var(--muted); transition: transform 0.15s; }
.ilmi-select.open .ilmi-select-btn svg { transform: rotate(180deg); }
.ilmi-select-list {
  position: absolute; top: calc(100% + 6px); left: 0; z-index: 400;
  min-width: 100%; max-height: 300px; overflow-y: auto;
  padding: 6px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 10px;
  box-shadow: 0 18px 40px -18px rgba(26,20,16,0.35);
}
.ilmi-select-opt {
  padding: 9px 12px; border-radius: 6px; cursor: pointer;
  font-family: var(--serif); font-size: 16px; color: var(--text); white-space: nowrap;
}
.ilmi-select-opt:hover, .ilmi-select-opt.active { background: rgba(26,20,16,0.05); }
.ilmi-select-opt.selected { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

/* Inside the bordered Materials filter, the dropdown blends into the field */
.mat-filter .ilmi-select { flex: 1; width: auto; min-width: 160px; height: 100%; }
.mat-filter .ilmi-select-btn { height: 100%; border: none; background: transparent; padding: 0 2px 0 0; box-shadow: none; }
.mat-filter .ilmi-select-btn, .mat-filter .ilmi-select-list { text-transform: none; letter-spacing: 0; }
.mat-filter .ilmi-select-list { top: calc(100% + 1px); left: -12px; }

/* ── Popups: upload, edit profile ───────────────────────────────────────── */
.upload-modal { border-radius: 12px; padding: 32px 34px; }
.upload-modal-header h3, .profile-ob-card h2, .profile-ob-card h3 {
  font-family: var(--display); font-size: 26px; font-weight: 600; letter-spacing: -0.02em;
}
.upload-modal-header p { font-family: var(--serif); font-size: 16px; line-height: 1.45; }
.upload-field select, .mat-upload-field select, .ob-field select {
  width: 100%; height: 44px; padding: 0 36px 0 12px;
  font-family: var(--serif); font-size: 16px; color: var(--text);
  background-color: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  appearance: none; -webkit-appearance: none; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238a7e6c' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
}
.upload-drop, .mat-drop-zone { border-radius: 10px; border-color: var(--border2); background: var(--bg); }
.upload-meta { display: flex; gap: 6px; flex-wrap: wrap; }
.upload-meta-chip {
  padding: 3px 9px; border-radius: 100px; border: 1px solid var(--border);
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted);
}
.upload-submit, .mat-submit-btn, .mat-browse-btn {
  background: var(--accent); color: #fbf6ec; border: none; border-radius: 8px;
  font-family: var(--serif); font-size: 17px; font-weight: 600; text-transform: none; letter-spacing: 0;
}
.upload-submit:hover, .mat-submit-btn:hover, .mat-browse-btn:hover { background: var(--accent-deep); }

/* Practice — quiz options: letter badge + answer text on one row */
.mcq-option { display: flex; align-items: center; gap: 14px; border-radius: 10px; padding: 14px 18px; }
.mcq-option:hover { border-color: var(--accent-border); background: var(--bg); }
.mcq-option-letter {
  flex-shrink: 0; width: 30px; height: 30px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--mono); font-size: 12px; font-weight: 600;
  border: 1px solid var(--border2); color: var(--muted);
}
.mcq-option-text { flex: 1; font-family: var(--serif); font-size: 17px; line-height: 1.45; }
.mcq-option.correct .mcq-option-letter { border-color: var(--green); color: var(--green); }
.mcq-option.wrong .mcq-option-letter { border-color: var(--accent); color: var(--accent); }
.mcq-question { font-family: var(--serif); font-weight: 600; }
.mcq-next-btn, .flash-next {
  background: var(--accent); color: #fbf6ec; border: none; border-radius: 8px;
  font-family: var(--serif); font-size: 16px; font-weight: 600; text-transform: none; letter-spacing: 0;
}
.mcq-next-btn:hover, .flash-next:hover { background: var(--accent-deep); }

/* Practice — subject picker step */
.practice-session .psession-body .subject-grid { width: 100%; max-width: var(--page-max); margin: 0 auto; }

/* ── Tablet ─────────────────────────────────────────────────────────────── */
@media (max-width: 1180px) {
  .page { padding: 36px 36px 72px; }
  .subject-grid, .pmode-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .lesson-panel { flex-basis: 320px; width: 320px; }
  .mode-seg span { display: none; }
}
@media (max-width: 1020px) {
  .today-top { grid-template-columns: 1fr; }
  .page-head-split { flex-direction: column; align-items: flex-start; }
  .stats-box-sm { min-width: 0; width: 100%; }
  .chat-subject-select { display: none; }
}

/* ── Mobile: sidebar becomes a drawer, one top bar ──────────────────────── */
@media (max-width: 900px) {
  .app-shell { flex-direction: column; }
  .mobile-bar {
    display: flex; align-items: center; gap: 12px;
    height: 54px; padding: 0 14px; flex-shrink: 0;
    background: var(--bg2); border-bottom: 1px solid var(--line);
  }
  .mobile-bar-btn {
    width: 38px; height: 38px; border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    background: transparent; border: 1px solid var(--border); color: var(--text); cursor: pointer;
  }
  .mobile-bar-mark {
    font-family: var(--serif); font-weight: 700; font-size: 22px;
    letter-spacing: 0.1em; color: var(--accent);
  }
  .mobile-bar-spacer { width: 38px; margin-left: auto; }

  .sidebar, .sidebar.open {
    position: fixed; top: 0; bottom: 0; left: 0;
    width: 272px; min-width: 272px;
    transform: translateX(-100%); transition: transform 0.25s cubic-bezier(0.16,1,0.3,1);
    align-items: stretch; padding: 26px 14px 14px;
    box-shadow: var(--shadow-lg); z-index: 60;
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar.open .sb-nav { padding: 0; }
  .sidebar.open .sb-nav-item { height: 44px; padding: 0 12px; }
  .sidebar.open .sb-nav-item span { font-size: 17px; font-weight: 600; }
  .sidebar.open .sb-user { padding: 12px 0 0; }
  .sidebar.open .sb-user-card { height: auto; padding: 8px 10px; }
  .sidebar.open .sb-avatar { width: 34px; height: 34px; background: var(--accent); color: #fbf6ec; font-size: 16px; }
  .sidebar.open .sb-user-name { color: var(--text); font-size: 16px; }
  .sidebar.open .sb-user-sub { color: var(--muted); font-size: 10.5px; }
  /* .app-shell is its own stacking context, so the backdrop must start where the drawer ends */
  .sb-overlay.visible { display: block; left: 272px; z-index: 55; }

  .page, .studio-wrap.page { padding: 26px 18px 64px; }
  .page-title { font-size: 31px; }
  .page-sub { font-size: 16.5px; }
  .page-head { margin-bottom: 24px; }
  .block-head { margin: 32px 0 12px; }
  .block-title { font-size: 21px; }

  .path-card { padding: 22px 20px; }
  .stat { padding: 16px 12px; }
  .stat-num { font-size: 26px; }
  .stat-label { font-size: 8.5px; letter-spacing: 0.1em; }

  .subject-grid, .pmode-grid { grid-template-columns: 1fr; gap: 10px; }
  .subj-card { min-height: 0; padding: 16px 16px 14px; }
  .subj-card-top { margin-bottom: 10px; }
  .pmode-card { min-height: 0; }

  .mat-filters { flex-direction: column; }
  .mat-filter { flex: none; min-height: 44px; }
  .mat-filter-search { max-width: none; margin-left: 0; }
  .mat-tr { grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; padding: 12px 14px; }
  .mat-th { display: none; }
  .mat-subj { grid-column: 1; grid-row: 2; font-size: 14px; padding-left: 54px; }
  .mat-type { display: none; }
  .mat-date { grid-column: 2; grid-row: 1 / span 2; }

  .notes-toggle { display: none; }   /* the Chat / Notes tabs do this job on mobile */
  .mobile-tabs { padding: 8px 14px; gap: 6px; background: var(--bg); border-bottom: 1px solid var(--line); }
  .mt-btn {
    border-radius: 7px; border: 1px solid var(--border); background: var(--surface);
    font-family: var(--serif); font-size: 15px; font-weight: 600; color: var(--muted); padding: 8px;
  }
  .mt-btn.active { background: var(--accent-soft); border-color: var(--accent-border); color: var(--accent); }
  .chat-topbar { height: 58px; padding: 0 14px; }
  .chat-subject-name { font-size: 18px; }
  /* One panel at a time: Chat tab = chat, Notes tab = tabs bar + full-width notes */
  .chat-view { flex-direction: column !important; }
  .lesson-panel { flex: 1 1 auto; width: 100%; border-left: none; }
  .chat-view.tab-notes .chat-panel { flex: 0 0 auto; }
  .messages { padding: 22px 16px 16px; }
  .input-area { padding: 10px 14px 16px; }
}
