/* Feature layouts consume portal.css tokens; no second visual system. */
.student-academic { margin-top: var(--space-3); border-top: 1px solid var(--line); }
.student-academic summary { display: flex; align-items: center; gap: 8px; min-height: 42px; padding: 10px 0; font-size: 13px; font-weight: 600; cursor: pointer; list-style: none; }
.student-academic summary::-webkit-details-marker { display: none; }
.student-academic summary:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }
.academic-record-count { margin-left: auto; font-size: 11px; font-weight: 400; color: var(--muted); font-variant-numeric: tabular-nums; }
.student-academic[open] > summary .disclosure-chevron { transform: rotate(90deg); }
.academic-records-empty { padding: 8px 0 12px; font-size: 12px; color: var(--muted); }
.academic-history-session { padding-bottom: 10px; }
.academic-history-session > header { display: flex; align-items: baseline; gap: 8px; padding: 9px 0 4px; }
.academic-history-session > header strong { font-size: 14px; font-weight: 600; }
.academic-history-session time { margin-left: auto; color: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.academic-history { padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 11px; line-height: 1.5; }
.academic-history-class { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.academic-history-class strong { font-size: 12px; font-weight: 550; }
.academic-history-class small { flex-shrink: 0; font-size: 10px; color: var(--muted); }
.academic-history-status { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 5px; }
.academic-history-note { margin: 5px 0 0; color: var(--muted); font-size: 12px; overflow-wrap: anywhere; white-space: pre-wrap; }
.academic-history-note > span { margin-right: 8px; font-size: 11px; }

.academic-panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-panel); overflow: hidden; }
.academic-head { display: flex; align-items: center; gap: 8px; padding: 10px; border-bottom: 1px solid var(--line); }
.academic-head button { min-width: 40px; min-height: 40px; padding: 6px 8px; font-size: 13px; background: #f0f3f8; color: #486b98; }
.academic-head h2 { min-width: 0; font-size: 17px; font-weight: 600; overflow-wrap: anywhere; }
.academic-school-label { flex: 0 0 auto; margin-left: auto; color: var(--muted); font-size: 11px; white-space: nowrap; }
.academic-add-row { display: flex; align-items: center; justify-content: center; gap: 7px; width: 100%; min-height: 48px; padding: 10px; border: 0; border-top: 1px solid var(--line); border-radius: 0; background: var(--surface-subtle); color: var(--blue); font-size: 13px; font-weight: 550; }
.academic-add-row svg { flex-shrink: 0; pointer-events: none; }
.academic-add-row:focus-visible { outline-offset: -3px; }
.academic-add-row:active:not(:disabled) { background: var(--blue-soft); }
.session-pills { display: flex; gap: 6px; padding: 10px; overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: none; }
.session-pills::-webkit-scrollbar { display: none; }
.session-pills button { flex: 0 0 auto; min-height: 44px; min-width: 78px; padding: 6px 9px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface-subtle); font-size: 12px; line-height: 1.4; white-space: nowrap; }
.session-pills button.active { background: var(--blue-soft); border-color: #bdd6ff; color: #0667c8; font-weight: 600; }
.session-pills small { display: block; margin-top: 2px; font-size: 10px; font-weight: 400; font-variant-numeric: tabular-nums; }
.session-pills .academic-exam-pill { border-style: dashed; }
.session-pills .academic-exam-pill.active { border-style: solid; }
.academic-exam-caption { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 5px 12px; padding: 0 10px 10px; }
.academic-exam-caption strong { min-width: 0; font-size: 13px; overflow-wrap: anywhere; }
.academic-exam-caption span { color: var(--muted); font-size: 11px; }
.academic-exam-panel .academic-exam-column-head,
.academic-exam-panel .academic-exam-row { grid-template-columns: 36px minmax(120px, 1fr) minmax(110px, 160px); }
.academic-score-cell { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; column-gap: 6px; min-width: 0; padding: 2px 6px; }
.academic-score-input { grid-column: 1 / -1; width: 100%; min-width: 0; min-height: 42px; padding: 7px 10px; font-size: var(--font-input); text-align: center; font-variant-numeric: tabular-nums; }
.academic-score-input[readonly] { background: var(--surface-subtle); }
.academic-score-input[aria-busy="true"] { color: inherit; opacity: 1; }
.academic-score-input[aria-invalid="true"] { border-color: var(--bad); }
.academic-score-status { min-height: 17px; margin-top: 4px; color: var(--muted); font-size: 10px; line-height: 1.5; overflow-wrap: anywhere; }
.academic-score-status.is-error { color: var(--bad); }
.academic-score-check { min-height: 30px; padding: 3px 7px; border-radius: var(--radius-control); font-size: 11px; color: var(--blue); }
.academic-exam-history { flex: 0 0 auto; margin-top: 8px; border: 1px solid var(--line); border-radius: var(--radius-control); background: var(--surface); }
.academic-exam-history summary { display: flex; justify-content: space-between; gap: 10px; padding: 11px 12px; font-size: 13px; font-weight: 550; cursor: pointer; }
.academic-exam-history summary span { color: var(--muted); font-size: 11px; font-weight: 400; }
.academic-exam-history-list { max-height: 34vh; max-height: 34dvh; overflow: auto; overscroll-behavior: contain; }
.academic-exam-history-list button { display: flex; align-items: center; justify-content: space-between; gap: 10px; width: 100%; padding: 10px 12px; border: 0; border-top: 1px solid var(--line); border-radius: 0; background: transparent; text-align: left; }
.academic-exam-history-list strong { display: block; font-size: 13px; }
.academic-exam-history-list small, .academic-exam-history-list button > span:last-child { color: var(--muted); font-size: 11px; }
.academic-exam-history-error { margin: 8px 0; color: var(--muted); font-size: 11px; }
.academic-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; padding: 9px 6px; margin: 0 10px 10px; border-radius: 9px; background: #f4f7fb; color: #748091; font-size: 12px; text-align: center; }
.academic-stats b { font-size: 16px; font-weight: 650; color: #233447; font-variant-numeric: tabular-nums; }
.academic-future-note { margin: -2px 10px 8px; font-size: 11px; color: var(--muted); text-align: center; }
.academic-column-head { display: grid; grid-template-columns: 24px repeat(5, minmax(0, 1fr)); gap: 3px; padding: 8px 10px; background: var(--surface-subtle); color: var(--muted); font-size: 11px; text-align: center; }
.academic-row { display: grid; grid-template-columns: 24px repeat(5, minmax(0, 1fr)); align-items: center; column-gap: 3px; row-gap: 4px; min-height: 68px; padding: 10px; border-top: 1px solid var(--line); }
.academic-student-sequence { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; text-align: center; }
.academic-student-name { display: flex; flex-direction: column; align-items: center; justify-content: center; min-width: 0; min-height: 44px; padding: 0; border: 0; border-radius: 5px; background: transparent; text-align: center; }
.academic-student-prefix { color: var(--muted); font-size: 11px; line-height: 1.25; }
.academic-student-name strong { display: block; font-size: 15px; font-weight: 600; line-height: 1.4; overflow-wrap: anywhere; }
.academic-controls { display: contents; }
.academic-control-cell { display: flex; align-items: center; justify-content: center; min-width: 0; min-height: 44px; text-align: center; }
.academic-control-cell > .muted { display: block; color: #98a1af; }
.academic-row-notes { grid-column: 1 / -1; display: grid; gap: 4px; min-width: 0; padding: 8px 0; border-top: 1px solid var(--line); }
.academic-row-note { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: baseline; gap: 8px; font-size: 12px; line-height: 1.6; }
.academic-row-note-label { color: var(--muted); font-size: 11px; white-space: nowrap; }
.academic-row-note-text { min-width: 0; overflow-wrap: anywhere; white-space: pre-wrap; }
.mark-group { display: flex; align-items: center; justify-content: center; width: 100%; gap: 2px; }
.mark-group .mark { display: flex; align-items: center; justify-content: center; flex: 1 1 0; min-width: 0; min-height: 44px; padding: 5px 2px; border: 0; border-radius: 8px; background: #f0f3f7; font-size: 17px; line-height: 1; }
.mark-group .mark.good { background: #dcf5e9; color: var(--good); }
.mark-group .mark.bad { background: #ffe9ee; color: var(--bad); }
.academic-situation-select { position: relative; width: 100%; min-width: 0; }
.academic-situation-chevron { position: absolute; right: 5px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.late-choice { width: 100%; min-height: 44px; padding: 3px 14px 3px 1px; border-radius: 8px; font-size: var(--font-input); line-height: 1.25; text-align: center; appearance: none; -webkit-appearance: none; }
.late-choice.good { background-color: #eaf8f1; border-color: #cbe9db; color: var(--good); }
.late-choice.bad { background-color: #fff1f3; border-color: #f1d3d9; color: var(--bad); }
.late-choice.excused { background-color: #fff8eb; border-color: #ecd9b4; color: var(--excused); }
.academic-controls.is-upcoming .mark-group .mark, .academic-controls.is-upcoming .late-choice { background-color: #ebedf2; border-color: #e0e4ec; color: #7c8795; -webkit-text-fill-color: #7c8795; opacity: .62; cursor: not-allowed; }
.academic-controls.is-upcoming .mark-group .mark[aria-pressed="true"] { background: #dee3eb; }
.academic-controls.is-past .mark-group .mark:disabled, .academic-controls.is-past .late-choice:disabled { opacity: .7; cursor: default; }
.academic-note-slot { height: 44px; width: 100%; display: flex; align-items: center; justify-content: center; }
.academic-note-link { min-width: 0; min-height: 44px; width: 100%; padding: 2px; border: 0; background: transparent; color: var(--muted); font-size: 10px; line-height: 1.2; }
.academic-note-link.has-note { color: var(--blue); font-weight: 550; }
.academic-note-icon { display: flex; align-items: center; justify-content: center; width: 100%; min-height: 44px; border-radius: 8px; }
.academic-note-icon.has-note { background: var(--blue-soft); }
.academic-note-icon svg { pointer-events: none; }
.academic-controls.is-upcoming .academic-note-link:not(.has-note) { opacity: .5; }
#attendance-note-form label { display: block; margin: var(--space-1) 0 var(--space-2); color: var(--muted); font-size: 12px; }
#attendance-note-form textarea { display: block; width: 100%; min-height: 120px; resize: vertical; padding: 10px; }
#attendance-note-form p { font-size: 12px; line-height: 1.6; margin: 10px 0; }
.note-save { display: block; margin-left: auto; color: #fff; background: var(--blue); }
.note-save[hidden] { display: none; }
/* Saving is guarded, not an unavailable/grey state. Keep its confirmed color
   while the single pending request is in flight instead of flashing the row. */
.academic-panel .mark[aria-busy="true"] { opacity: 1; }
.late-choice.good[aria-busy="true"] { color: var(--good); -webkit-text-fill-color: var(--good); }
.late-choice.bad[aria-busy="true"] { color: var(--bad); -webkit-text-fill-color: var(--bad); }
.late-choice.excused[aria-busy="true"] { color: var(--excused); -webkit-text-fill-color: var(--excused); }
.academic-history-toggle { display: flex; align-items: center; gap: 8px; width: 100%; min-height: 44px; padding: 10px; border: 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); border-radius: 0; background: var(--surface-subtle); color: var(--muted); text-align: left; font-size: 12px; font-weight: 600; }
.academic-history-toggle:focus-visible { outline-offset: -2px; }
.disclosure-chevron { flex-shrink: 0; font-size: 20px; line-height: 1; transition: transform .12s ease; }
.academic-history-toggle[aria-expanded="true"] .disclosure-chevron { transform: rotate(90deg); }
.history-count { padding: 2px 5px; border-radius: 5px; background: #e9edf3; font-size: 11px; font-weight: 400; white-space: nowrap; }
.history-action { margin-left: auto; font-size: 11px; font-weight: 400; }

/* The phone academic workspace never scrolls its navigation or date controls.
   Only the timetable or ledger list owns the remaining viewport. Dialogs are
   outside #app and retain their own native scrolling and keyboard behavior. */
html:has(#app[data-fixed-academic="true"]),
body:has(#app[data-fixed-academic="true"]) { height: 100%; overflow: hidden; overscroll-behavior-y: none; }
#app[data-fixed-academic="true"] { position: fixed; inset: 0; height: 100vh; height: 100dvh; overflow: hidden; touch-action: pan-x pan-y; }
#app[data-fixed-academic="true"] .shell { display: flex; flex-direction: column; height: 100%; min-height: 0; padding-bottom: 0; }
#app[data-fixed-academic="true"] .shell > header { flex: 0 0 auto; }
#app[data-fixed-academic="true"] #main { display: flex; flex-direction: column; flex: 1 1 0%; min-height: 0; overflow: hidden; padding: 6px var(--space-3) max(6px, env(safe-area-inset-bottom)); }
#app[data-fixed-academic="true"] .academic-panel { display: flex; flex-direction: column; flex: 1 1 0%; min-height: 0; }
#app[data-fixed-academic="true"] .academic-panel > :not(.academic-rows) { flex: 0 0 auto; }
#app[data-fixed-academic="true"] .academic-rows { flex: 1 1 0%; min-height: 0; overflow: auto; overscroll-behavior: contain; padding-bottom: max(18px, env(safe-area-inset-bottom)); -webkit-overflow-scrolling: touch; }
#app[data-fixed-academic="true"] .academic-head { padding: 8px 10px; }
#app[data-fixed-academic="true"] .session-pills { padding: 8px 10px; }
#app[data-fixed-academic="true"] .academic-stats { margin-bottom: 6px; padding-block: 6px; }

/* Existing phone student-management forms share the same control scale. */
.management-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.management-fields label, .management-date { display: grid; gap: 5px; min-width: 0; font-size: 12px; color: var(--muted); }
.management-fields input, .management-fields select, .management-date select, #manage-search { width: 100%; min-height: 42px; padding: 8px 10px; font-size: var(--font-input); }
.management-fields .wide { grid-column: 1 / -1; }
.management-hint { color: var(--muted); font-size: 12px; line-height: 1.55; margin: 10px 0; overflow-wrap: anywhere; }
.management-modes { display: flex; gap: 3px; padding: 3px; margin: 10px 0; border-radius: 10px; background: #e9edf3; }
.management-modes button { flex: 1; min-height: 38px; padding: 7px 8px; border-radius: 7px; background: transparent; font-size: 13px; }
.management-modes button[aria-pressed="true"] { color: var(--blue); background: #fff; font-weight: 600; }
.management-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; margin-top: 14px; }
.management-actions button { min-height: 42px; font-size: 13px; }
.management-results { max-height: 45svh; overflow: auto; overscroll-behavior: contain; margin-top: 8px; }
.management-search-row { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); width: 100%; min-height: 54px; padding: var(--space-list-y) var(--space-2); border: 0; border-bottom: 1px solid var(--line); border-radius: 0; background: var(--surface); text-align: left; }
.management-search-row > span { min-width: 0; overflow-wrap: anywhere; }
.management-search-row strong { font-size: 13px; font-weight: 600; line-height: 1.4; }
.management-search-row small { display: block; margin-top: var(--space-meta); font-size: 11px; line-height: 1.45; }
.management-search-row > small { flex-shrink: 0; color: var(--blue); }
.management-student-courses { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.management-course-heading { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 8px; }
.management-course-heading h3 { font-size: 13px; font-weight: 600; }
.management-course-heading button { min-height: 40px; padding: 6px 8px; color: var(--blue); background: transparent; font-size: 12px; }
.management-course-row + .management-course-row { margin-top: 8px; }
.management-course-actions { display: flex; align-items: center; gap: 4px; margin-top: 2px; font-size: 12px; }
.management-course-actions span { margin-right: auto; padding-left: 9px; color: var(--muted); font-variant-numeric: tabular-nums; }
.management-course-actions button { min-height: 42px; padding: 7px 10px; color: var(--blue); background: transparent; font-size: 12px; }
.management-course-actions .management-danger { color: var(--bad); }
.management-course-list { max-height: 55svh; overflow: auto; overscroll-behavior: contain; }
.management-course-list h3 { color: var(--muted); font-size: 12px; font-weight: 600; margin: 12px 0 5px; }
.management-course-option { display: flex; align-items: center; gap: 8px; min-height: 48px; padding: 8px 2px; border-bottom: 1px solid var(--line); }
.management-course-option input { width: 20px; height: 20px; min-height: 0; margin: 0; flex-shrink: 0; accent-color: var(--blue); }
.management-course-option span { display: flex; justify-content: space-between; flex: 1; gap: 8px; min-width: 0; font-size: 13px; }
.management-course-option strong { min-width: 0; font-weight: 550; overflow-wrap: anywhere; }
.management-course-option small { flex-shrink: 0; font-size: 11px; white-space: nowrap; }
.management-course-option.cross-grade { color: var(--muted); }

@media (max-width: 340px) {
  .academic-row, .academic-column-head { padding-inline: 5px; column-gap: 2px; }
  .academic-head h2 { font-size: 16px; }
}
@media (hover: hover) {
  .academic-add-row:not(:disabled):hover { background: var(--blue-soft); }
  .academic-student-name:not(:disabled):hover { color: var(--blue); background: transparent; }
  .mark-group .mark.good:not(:disabled):hover { background: #cceedd; }
  .mark-group .mark.bad:not(:disabled):hover { background: #ffdae3; }
  .academic-note-link:not(:disabled):hover { color: var(--blue); background: var(--blue-soft); }
  .management-course-actions button:not(:disabled):hover, .management-course-heading button:not(:disabled):hover { background: var(--blue-soft); }
}
