/* One compact subject selector; class statistics belong below the chart. */
#trainingWorkspace #trainingLocationStatus { display:none!important; }
#gradeWorkspace #gradeSubjectFilters { display:block; flex:0 1 auto; width:auto; min-width:0; margin:0; padding:0; overflow:visible; }
#gradeWorkspace .grade-subject-select-label { display:block; margin:0; }
#gradeWorkspace [data-grade-subject-select] { width:auto; max-width:100%; min-width:125px; height:40px; min-height:40px; margin:0; padding:6px 30px 6px 10px; border:1.5px solid var(--control-outline); border-radius:9px; color:var(--ink); background:var(--surface); font:inherit; font-size:14px; cursor:pointer; }
#gradeWorkspace .grade-student-selector-panel { grid-template-rows:minmax(0,1fr); }
#gradeWorkspace .grade-class-overview { display:grid; grid-template-columns:auto minmax(0,1fr); gap:12px; align-items:center; margin-top:10px; padding:12px; border:1px solid var(--line); border-radius:10px; background:var(--surface); }
#gradeWorkspace .grade-class-overview .grade-average-summary { display:flex; align-items:baseline; justify-content:flex-start; width:auto; margin:0; padding:0 12px 0 0; gap:5px; border:0; border-right:1px solid var(--line); border-radius:0; background:transparent; font-size:14px; }
#gradeWorkspace .grade-class-overview .grade-average-summary strong { color:var(--ink); font-size:22px; font-variant-numeric:tabular-nums; }
#gradeWorkspace .grade-class-counts { display:grid; grid-template-columns:repeat(5,minmax(0,1fr)); gap:8px; }
#gradeWorkspace .grade-class-count { display:flex; flex-direction:column; gap:3px; color:var(--muted); font-size:12px; }
#gradeWorkspace .grade-class-count strong { color:var(--ink); font-size:18px; font-weight:650; font-variant-numeric:tabular-nums; }
#gradeWorkspace .grade-class-counts-note { grid-column:1/-1; font-size:11px; color:var(--muted); margin:0; }
@media(max-width:760px) {
 #gradeWorkspace .grade-compact-toolbar .grade-context-actions { width:auto; margin-left:auto; }
 #gradeWorkspace .grade-compact-toolbar .grade-dataset-title { flex:1 1 130px; }
 #gradeWorkspace [data-grade-subject-select] { height:38px; min-height:38px; min-width:110px; font-size:13px; }
 #gradeWorkspace .grade-student-analysis-layout { display:grid; grid-template-columns:minmax(0,1fr); gap:8px; }
 #gradeWorkspace .grade-student-selector-panel { position:static; top:auto; width:100%; height:auto; min-height:0; max-height:none; display:block; box-shadow:none; }
 #gradeWorkspace .grade-student-list { display:flex; flex-wrap:nowrap; align-items:stretch; gap:6px; width:100%; max-width:100%; padding:7px; overflow-x:auto; overflow-y:hidden; overscroll-behavior-x:contain; scrollbar-gutter:auto; -webkit-overflow-scrolling:touch; }
 #gradeWorkspace .grade-student-list-item { display:flex; flex:0 0 auto; align-items:center; justify-content:center; width:auto; min-width:82px; min-height:40px; padding:7px 10px; gap:7px; border:1px solid var(--line); border-radius:8px; white-space:nowrap; }
 #gradeWorkspace .grade-student-name { white-space:nowrap; font-size:13px; }
 #gradeWorkspace .grade-student-list-item.is-active { border-color:var(--accent); }
 #gradeWorkspace .grade-student-list-item strong { font-size:13px; }
 #gradeWorkspace .grade-student-trend-panel { min-height:0; padding:8px 4px; }
 #gradeWorkspace .grade-student-trend-chart { min-width:0; width:100%; }
 #gradeWorkspace .grade-student-trend-svg { height:290px; }
 #gradeWorkspace .grade-class-overview { grid-template-columns:minmax(0,1fr); gap:10px; padding:10px; }
 #gradeWorkspace .grade-class-overview .grade-average-summary { padding:0 0 8px; border-right:0; border-bottom:1px solid var(--line); }
 #gradeWorkspace .grade-class-counts { grid-template-columns:repeat(3,minmax(0,1fr)); gap:12px 8px; }
}

/* Exam and subject together, actions grouped at the right; score summary first. */
#gradeWorkspace .grade-compact-toolbar { display:grid; grid-template-columns:auto minmax(120px,1fr) minmax(110px,auto) auto; gap:8px; }
#gradeWorkspace .grade-compact-toolbar .grade-dataset-title { width:100%; max-width:none; min-width:0; }
#gradeWorkspace .grade-exam-picker { height:40px; min-height:40px; margin:0; border:var(--control-stroke) solid var(--control-outline); }
#gradeWorkspace .grade-context-actions { justify-content:flex-end; }
#gradeWorkspace #gradeScoreSettingsBtn { display:inline-flex; align-items:center; justify-content:center; width:40px; height:40px; min-height:40px; padding:0; border-radius:50%; border:var(--control-stroke) solid var(--control-outline); }
#gradeWorkspace .grade-class-overview { grid-template-columns:minmax(0,1fr); }
#gradeWorkspace .grade-class-overview .grade-average-summary { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); padding:0 0 12px; border-right:0; border-bottom:1px solid var(--line); gap:8px; }
#gradeWorkspace .grade-average-summary > div { display:flex; flex-direction:column; align-items:center; gap:4px; color:var(--muted); font-size:12px; }
#gradeWorkspace .grade-average-summary > div + div { border-left:1px solid var(--line); }
.grade-score-config-context { display:flex; align-items:center; justify-content:space-between; flex-wrap:wrap; gap:8px; margin:12px 0 6px; }
.grade-score-config-context strong { font-size:13px; }
.grade-score-config-context button { min-height:34px; padding:5px 10px; font-size:12px; }
.grade-score-reference-note { font-size:12px; line-height:1.6; color:var(--muted); margin:0 0 12px; }
.grade-score-mode-choice { display:flex; align-items:center; justify-content:space-between; gap:12px; margin:0 0 12px; font-size:13px; }
.grade-score-mode-choice select { width:auto; min-width:150px; height:38px; margin:0; padding:5px 26px 5px 8px; color:var(--ink); background:var(--surface); border:1.5px solid var(--control-outline); border-radius:8px; }
#gradeScoreSettingsPanel .grade-score-settings-dialog { max-height:calc(100dvh - 32px); overflow-y:auto; }
#gradeScoreSettingsPanel .grade-score-settings-footer { position:sticky; bottom:0; background:var(--surface); padding:10px 0 0; }
@media(max-width:760px) {
 #gradeWorkspace .grade-compact-toolbar { grid-template-columns:minmax(0,1fr) minmax(110px,auto); }
 #gradeWorkspace .grade-compact-toolbar > .workspace-page-title { grid-column:1; grid-row:1; }
 #gradeWorkspace .grade-compact-toolbar > .grade-context-actions { grid-column:2; grid-row:1; }
 #gradeWorkspace .grade-compact-toolbar > .grade-dataset-title { grid-column:1; grid-row:2; }
 #gradeWorkspace .grade-compact-toolbar > #gradeSubjectFilters { grid-column:2; grid-row:2; }
 #gradeWorkspace .grade-exam-picker { height:38px; min-height:38px; padding:5px 8px; }
 #gradeWorkspace #gradeScoreSettingsBtn { width:38px; height:38px; min-height:38px; }
 #gradeWorkspace .grade-class-overview .grade-average-summary strong { font-size:20px; }
 #gradeScoreSettingsPanel .grade-score-settings-table-head,#gradeScoreSettingsPanel .grade-score-setting-row { grid-template-columns:minmax(60px,1fr) repeat(2,minmax(68px,1fr)); gap:6px; padding-inline:8px; }
 #gradeScoreSettingsPanel .grade-score-setting-subject > span { display:none; }
 #gradeScoreSettingsPanel .grade-score-setting-row input { min-height:38px; font-size:14px; }
}

.grade-score-config-context button { width:auto; flex:0 0 auto; }

/* Reading order: tools, subject, exam; long exam names wrap onto their own row. */
#gradeWorkspace .grade-compact-toolbar { display:flex; flex-wrap:wrap; align-items:center; gap:8px; }
#gradeWorkspace .grade-compact-toolbar > .workspace-page-title { margin-right:auto; }
#gradeWorkspace .grade-compact-toolbar > .grade-context-actions { width:auto; margin:0; flex:0 0 auto; }
#gradeWorkspace .grade-compact-toolbar > #gradeSubjectFilters { flex:0 0 auto; }
#gradeWorkspace .grade-compact-toolbar [data-grade-subject-select] { min-width:84px; }
#gradeWorkspace .grade-compact-toolbar > .grade-dataset-title { width:auto; flex:0 1 auto; max-width:min(420px,100%); min-width:0; margin:0; }
#gradeWorkspace .grade-exam-picker { height:auto; min-height:40px; }
#gradeWorkspace .grade-exam-picker strong { white-space:normal; overflow-wrap:anywhere; text-align:left; line-height:1.4; }
#gradeWorkspace .grade-compact-toolbar .grade-context-actions :is(button,.grade-file-button) { border:var(--control-stroke) solid var(--control-outline)!important; }
#gradeWorkspace .grade-compact-toolbar .grade-context-actions :is(button,.grade-file-button):hover { border-color:var(--control-outline-hover)!important; }
@media(max-width:760px) {
 #gradeWorkspace .grade-compact-toolbar { gap:6px; }
 #gradeWorkspace .grade-compact-toolbar > .grade-dataset-title { flex:1 0 100%; max-width:100%; }
 #gradeWorkspace .grade-compact-toolbar > .grade-context-actions { gap:4px; }
 #gradeWorkspace .grade-compact-toolbar [data-grade-subject-select] { min-width:76px; padding-left:8px; padding-right:22px; }
 #gradeWorkspace .grade-exam-picker { min-height:38px; }
}

/* Quiet analysis surface: compact roster, an open plot, and aligned summaries. */
#gradeWorkspace { --analysis-focus:#426b86; --analysis-focus-soft:color-mix(in srgb,var(--analysis-focus) 9%,var(--surface)); }
:root.theme-dark #gradeWorkspace { --analysis-focus:#91bad4; }
#gradeWorkspace .grade-compact-toolbar { padding-bottom:10px; margin-bottom:12px; }
#gradeWorkspace .grade-student-analysis-layout { grid-template-columns:208px minmax(0,1fr); gap:12px; }
#gradeWorkspace :is(.grade-student-selector-panel,.grade-student-trend-panel,.grade-class-overview) { background:var(--surface); border:1px solid var(--line); border-radius:12px; box-shadow:none; }
#gradeWorkspace .grade-student-list { padding:6px; gap:4px; }
#gradeWorkspace .grade-student-list-item { min-height:42px; padding:6px 9px; border:1px solid transparent; border-radius:8px; gap:8px; box-shadow:none; }
#gradeWorkspace .grade-student-list-item::before { display:none; }
#gradeWorkspace .grade-student-list-item:hover { transform:none; background:var(--surface-soft); }
#gradeWorkspace .grade-student-list-item.is-active { border-color:color-mix(in srgb,var(--analysis-focus) 65%,var(--line)); background:var(--analysis-focus-soft); box-shadow:none; }
#gradeWorkspace .grade-student-name { color:var(--ink); font-size:13px; font-weight:600; }
#gradeWorkspace .grade-student-seat { display:grid; place-items:center; min-width:22px; height:22px; padding:0 3px; border-radius:6px; background:var(--surface-soft); color:var(--muted); font-size:11px; font-weight:600; font-variant-numeric:tabular-nums; }
#gradeWorkspace .grade-student-list-item > strong { font-size:14px; font-weight:700; }
#gradeWorkspace .grade-student-list-item:focus-visible { outline:2px solid var(--analysis-focus); outline-offset:-2px; }
#gradeWorkspace .grade-student-trend-panel { padding:14px 14px 8px; min-height:0; }
#gradeWorkspace .grade-student-trend-chart:not(.is-total-trend) { min-height:320px; }
#gradeWorkspace .grade-student-trend-chart:not(.is-total-trend) .grade-student-trend-svg { height:320px; }
#gradeWorkspace .grade-student-trend-line { stroke:var(--analysis-focus); stroke-width:2.5; }
#gradeWorkspace .grade-student-trend-grid { opacity:.65; }
#gradeWorkspace .grade-class-overview { padding:14px 12px 10px; margin-top:10px; gap:12px; }
#gradeWorkspace .grade-class-overview .grade-average-summary { margin:0; padding:0 0 12px; }
#gradeWorkspace .grade-average-summary > div { gap:6px; font-size:12px; }
#gradeWorkspace .grade-average-summary strong { font-size:24px; font-weight:700; line-height:1.15; font-variant-numeric:tabular-nums; }
#gradeWorkspace .grade-average-summary > div:first-child strong { color:var(--analysis-focus); }
#gradeWorkspace .grade-class-counts { gap:8px; }
#gradeWorkspace .grade-class-count { align-items:center; text-align:center; padding:8px 3px; gap:6px; border-radius:7px; background:var(--surface-soft); }
#gradeWorkspace .grade-class-count strong { font-size:18px; line-height:1.1; font-variant-numeric:tabular-nums; }
#gradeWorkspace .grade-class-count small { font-size:11px; font-weight:400; color:var(--muted); }
#gradeWorkspace .grade-class-counts-note { line-height:1.6; padding-top:2px; }
@media(max-width:760px) {
 #gradeWorkspace .grade-compact-toolbar { margin-bottom:8px; padding-bottom:8px; }
 #gradeWorkspace .grade-student-analysis-layout { grid-template-columns:minmax(0,1fr); gap:8px; }
 #gradeWorkspace .grade-student-selector-panel { border:0; background:transparent; border-radius:0; }
 #gradeWorkspace .grade-student-list { padding:2px 1px 6px; gap:6px; scroll-padding-inline:4px; }
 #gradeWorkspace .grade-student-list-item { flex:0 0 auto; min-width:0; min-height:38px; padding:6px 9px; gap:6px; border-color:var(--line); background:var(--surface); }
 #gradeWorkspace .grade-student-seat { min-width:20px; height:20px; }
 #gradeWorkspace .grade-student-list-item > strong { font-size:13px; }
 #gradeWorkspace .grade-student-trend-panel { padding:10px 4px 4px; }
 #gradeWorkspace .grade-student-trend-chart:not(.is-total-trend) { min-height:260px; }
 #gradeWorkspace .grade-student-trend-chart:not(.is-total-trend) .grade-student-trend-svg { height:260px; }
 #gradeWorkspace .grade-class-overview { padding:12px 8px 8px; gap:10px; }
 #gradeWorkspace .grade-average-summary strong { font-size:21px; }
 #gradeWorkspace .grade-class-counts { grid-template-columns:repeat(5,minmax(0,1fr)); gap:4px; }
 #gradeWorkspace .grade-class-count { padding:8px 1px; font-size:10px; }
 #gradeWorkspace .grade-class-count strong { font-size:16px; }
}
@media(max-width:359px) { #gradeWorkspace .grade-class-counts { grid-template-columns:repeat(3,minmax(0,1fr)); } }

#gradeWorkspace .grade-average-summary > div { width:100%; box-sizing:border-box; }
#gradeWorkspace .grade-class-overview .grade-average-summary { justify-items:stretch; }

/* The toolbar and analysis share the same panel, like the other workspaces. */
#gradeWorkspace .grade-workbench { min-width:0; border:1px solid var(--line); border-radius:12px; background:var(--surface); box-shadow:0 2px 8px rgb(20 35 55 / 3%); }
#gradeWorkspace .grade-workbench > .grade-compact-toolbar { margin:0; padding:8px 12px; border-bottom:1px solid var(--line); border-radius:12px 12px 0 0; background:linear-gradient(110deg,var(--surface),var(--surface-soft)); }
#gradeWorkspace .grade-workbench > .grade-dashboard { padding:12px; border:0; background:transparent; }
#gradeWorkspace :is([data-grade-subject-select],.grade-exam-picker) { border-radius:10px; background:var(--surface); box-shadow:0 1px 2px rgb(20 35 55 / 4%); font-size:13px; font-weight:600; transition:border-color .15s,background .15s; }
#gradeWorkspace :is([data-grade-subject-select],.grade-exam-picker):hover { border-color:var(--control-outline-hover); background:var(--surface-soft); }
#gradeWorkspace :is([data-grade-subject-select],.grade-exam-picker):focus-visible { outline:2px solid var(--analysis-focus); outline-offset:2px; }
#gradeWorkspace .grade-student-list-item { grid-template-columns:22px minmax(0,1fr) auto; align-items:center; justify-content:stretch; }
#gradeWorkspace .grade-student-list-item > .grade-student-score { display:block; white-space:nowrap; text-align:right; line-height:1.3; font-variant-numeric:tabular-nums; color:var(--muted); }
#gradeWorkspace .grade-student-list-item.is-elite > .grade-student-score { color:#7852ae; }
#gradeWorkspace .grade-student-list-item.is-excellent > .grade-student-score { color:#cf294b; }
#gradeWorkspace .grade-student-list-item.is-pass > .grade-student-score { color:#2563b9; }
#gradeWorkspace .grade-student-list-item.is-fail > .grade-student-score { color:var(--ink); }
#gradeWorkspace .grade-student-list-item.is-low > .grade-student-score { color:#a65b0a; }
:root.theme-dark #gradeWorkspace .grade-student-list-item.is-elite > .grade-student-score { color:#c3a1f1; }
:root.theme-dark #gradeWorkspace .grade-student-list-item.is-excellent > .grade-student-score { color:#ff8a9f; }
:root.theme-dark #gradeWorkspace .grade-student-list-item.is-pass > .grade-student-score { color:#8cbaff; }
:root.theme-dark #gradeWorkspace .grade-student-list-item.is-low > .grade-student-score { color:#f1be79; }
#gradeWorkspace .grade-student-analysis-detail { min-width:0; }
#gradeWorkspace .grade-student-trend-panel { overflow:hidden; }
#gradeWorkspace .grade-student-trend-chart { display:block; min-width:0; max-width:100%; overflow-x:auto; overflow-y:hidden; overscroll-behavior-x:contain; scrollbar-width:thin; scrollbar-color:var(--control-outline) transparent; }
#gradeWorkspace .grade-student-trend-chart svg { display:block; max-width:none; }
@media(max-width:760px) {
 #gradeWorkspace .grade-workbench > .grade-compact-toolbar { padding:7px 8px; }
 #gradeWorkspace .grade-workbench > .grade-dashboard { padding:8px; }
 #gradeWorkspace .grade-compact-toolbar > #gradeSubjectFilters { margin-left:auto; }
 #gradeWorkspace .grade-student-list-item { display:flex; justify-content:center; }
 #gradeWorkspace .grade-student-list-item > .grade-student-score { flex:none; }
}

#gradeWorkspace .grade-student-trend-exam { font-size:13px; }
#gradeWorkspace .grade-student-trend-axis { font-size:12px; }
@media(max-width:760px) {
 #gradeWorkspace .grade-student-trend-chart:not(.is-total-trend) { min-height:300px; }
 #gradeWorkspace .grade-student-trend-chart:not(.is-total-trend) .grade-student-trend-svg { height:300px; }
}

:root.theme-dark #gradeWorkspace .grade-student-trend-score.is-elite { fill:#c3a1f1; }
:root.theme-dark #gradeWorkspace .grade-student-trend-score.is-excellent { fill:#ff8a9f; }
:root.theme-dark #gradeWorkspace .grade-student-trend-score.is-pass { fill:#8cbaff; }
:root.theme-dark #gradeWorkspace .grade-student-trend-score.is-low { fill:#f1be79; }
:root.theme-dark #gradeWorkspace .grade-student-trend-point.is-elite { stroke:#c3a1f1; }
:root.theme-dark #gradeWorkspace .grade-student-trend-point.is-excellent { stroke:#ff8a9f; }
:root.theme-dark #gradeWorkspace .grade-student-trend-point.is-pass { stroke:#8cbaff; }
:root.theme-dark #gradeWorkspace .grade-student-trend-point.is-low { stroke:#f1be79; }

/* Refine the existing analysis hierarchy without changing its layout. */
#gradeWorkspace { --analysis-purple:#7852ae; --analysis-red:#bc3756; --analysis-blue:#3266a8; --analysis-amber:#98631f; }
:root.theme-dark #gradeWorkspace { --analysis-purple:#c3a1f1; --analysis-red:#ff9caf; --analysis-blue:#99c3ff; --analysis-amber:#f1c486; }
#gradeWorkspace .grade-workbench > .grade-compact-toolbar { background:var(--surface); }
#gradeWorkspace .grade-compact-toolbar :is([data-grade-subject-select],.grade-exam-picker) { box-shadow:inset 0 1px 0 color-mix(in srgb,var(--surface) 70%,transparent); background:color-mix(in srgb,var(--analysis-focus) 3%,var(--surface)); }
#gradeWorkspace .grade-exam-picker { gap:9px; padding-inline:12px; }
#gradeWorkspace .grade-exam-picker strong { font-weight:600; }
#gradeWorkspace .grade-student-selector-panel { background:color-mix(in srgb,var(--analysis-focus) 2%,var(--surface)); }
#gradeWorkspace .grade-student-list { scrollbar-width:thin; scrollbar-color:var(--control-outline) transparent; }
#gradeWorkspace .grade-student-list-item { transition:background .15s,border-color .15s; }
#gradeWorkspace .grade-student-list-item.is-active { background:color-mix(in srgb,var(--analysis-focus) 11%,var(--surface)); border-color:color-mix(in srgb,var(--analysis-focus) 60%,var(--line)); }
#gradeWorkspace .grade-student-list-item.is-active .grade-student-name { font-weight:700; }
#gradeWorkspace .grade-student-list-item > .grade-student-score { min-width:44px; padding:3px 6px; border-radius:6px; text-align:center; background:color-mix(in srgb,currentColor 7%,transparent); }
#gradeWorkspace .grade-student-seat { background:transparent; color:var(--muted); font-weight:500; }
#gradeWorkspace .grade-student-trend-line { stroke-linecap:round; stroke-linejoin:round; }
#gradeWorkspace .grade-student-trend-area { opacity:.42; }
#gradeWorkspace .grade-student-trend-band rect { opacity:.7; }
#gradeWorkspace .grade-student-trend-column { opacity:.45; }
#gradeWorkspace .grade-student-trend-grid { opacity:.55; }
#gradeWorkspace .grade-student-trend-score-bg { stroke:color-mix(in srgb,var(--control-outline) 40%,transparent); stroke-width:.7; }
#gradeWorkspace .grade-student-trend-exam { fill:var(--ink); opacity:.8; }
#gradeWorkspace .grade-class-overview { padding-top:16px; }
#gradeWorkspace .grade-average-summary > div > span { font-size:12px; color:var(--muted); }
#gradeWorkspace .grade-average-summary strong { letter-spacing:-.4px; }
#gradeWorkspace .grade-class-count { --stat-color:var(--muted); padding:10px 4px; gap:7px; background:color-mix(in srgb,var(--stat-color) 5%,var(--surface)); border:1px solid color-mix(in srgb,var(--stat-color) 12%,var(--line)); border-radius:8px; }
#gradeWorkspace .grade-class-count:nth-child(1) { --stat-color:var(--analysis-purple); }
#gradeWorkspace .grade-class-count:nth-child(2) { --stat-color:var(--analysis-red); }
#gradeWorkspace .grade-class-count:nth-child(3) { --stat-color:var(--analysis-blue); }
#gradeWorkspace .grade-class-count:nth-child(5) { --stat-color:var(--analysis-amber); }
#gradeWorkspace .grade-class-count strong { color:var(--stat-color); font-size:19px; }
#gradeWorkspace .grade-class-count > span { color:var(--ink); font-size:12px; }
#gradeWorkspace .grade-class-counts-note { padding-top:3px; font-size:11px; line-height:1.7; }
@media(max-width:760px) {
 #gradeWorkspace .grade-student-selector-panel { background:transparent; }
 #gradeWorkspace .grade-student-list-item { padding:5px 8px; gap:7px; }
 #gradeWorkspace .grade-student-list-item > .grade-student-score { min-width:32px; padding:2px 4px; }
 #gradeWorkspace .grade-class-overview { padding:12px 8px 9px; }
 #gradeWorkspace .grade-class-count { padding:9px 1px; gap:6px; }
 #gradeWorkspace .grade-class-count strong { font-size:17px; }
 #gradeWorkspace .grade-class-count > span { font-size:11px; }
 #gradeWorkspace .grade-class-count small { font-size:10px; }
}
@media(prefers-reduced-motion:reduce) { #gradeWorkspace .grade-student-list-item { transition:none; } }
