/* ExamGuard Lite 2.3 — teacher dashboard, isolated from student exam flow. */
:root {
  --eg-red: #c40d02;
  --eg-orange: #f59814;
  --eg-ink: #20283b;
  --eg-muted: #718098;
  --eg-line: #e8ecf3;
}

main:has(> #teacher:not(.hidden)) {
  max-width: 1450px;
  padding: 22px 24px 140px;
}

#teacher, #teacher * { min-width: 0; }
#teacher { color: var(--eg-ink); }
#teacher button { font-size: 13px; font-weight: 750; }
#teacher button.primary {
  color: #fff;
  background: linear-gradient(115deg, #d51a0e 0%, #bc0c03 100%);
  border: 1px solid #bc160c;
  box-shadow: 0 8px 19px rgba(194, 25, 13, .17);
}
#teacher button.primary:hover:not(:disabled) {
  background: linear-gradient(115deg, #b91209 0%, #970c04 100%);
}
#teacher button.outline { color: #3e4b62; border-color: #dce3ed; }
#teacher button:disabled { opacity: .43; box-shadow: none; }
#teacher input, #teacher textarea, #teacher select {
  width: 100%; max-width: 100%;
  background: #fff; border: 1px solid #dce3ee;
  padding: 13px 14px; border-radius: 10px;
  font-size: 14px; color: #263449;
}
#teacher label { display: grid; gap: 8px; color: #47556a; font-size: 12px; font-weight: 750; }
#teacher input:focus, #teacher textarea:focus, #teacher select:focus {
  outline: 3px solid rgba(196, 13, 2, .12); border-color: #dd7a6d;
}

.workspace-shell {
  display: grid;
  grid-template-columns: 234px minmax(0, 1fr);
  align-items: start;
  gap: 0;
  min-height: 750px;
  border-radius: 22px;
  background: #f8f9fc;
  border: 1px solid #e5e9f1;
  box-shadow: 0 24px 70px rgba(27, 38, 64, .07);
}
.workspace-sidebar {
  position: sticky;
  top: 10px;
  display: flex;
  flex-direction: column;
  align-self: start;
  min-height: 695px;
  height: min(850px, calc(100vh - 123px));
  padding: 29px 16px 20px;
  color: #fff;
  background:
    radial-gradient(circle at 9% 4%, rgba(236, 99, 67, .16), transparent 31%),
    linear-gradient(167deg, #222b41, #172134 62%, #10192b);
  border-radius: 21px 0 0 21px;
}
.workspace-identity { display: flex; align-items: center; gap: 11px; padding: 0 8px 37px; }
.workspace-monogram {
  flex: 0 0 40px; display: grid; place-items: center;
  height: 40px; background: linear-gradient(135deg, #f59814, #c40d02);
  border-radius: 12px; font-size: 22px; font-weight: 900;
  box-shadow: 0 9px 20px #0003;
}
.workspace-identity strong { display: block; font-size: 13px; letter-spacing: .065em; }
.workspace-identity small { display: block; font-size: 9px; font-weight: 750; letter-spacing: .13em; color: #a0adc4; margin-top: 4px; }
.workspace-nav-caption { color: #72819a; font-size: 9px; font-weight: 850; letter-spacing: .14em; padding: 0 12px 14px; }
.workspace-navigation { display: grid; gap: 7px; }
#teacher .workspace-nav {
  width: 100%; display: flex; align-items: center; gap: 13px;
  text-align: left; color: #b4bfd1; background: transparent;
  border: 1px solid transparent; border-radius: 11px;
  padding: 13px 14px; font-size: 13px;
}
.workspace-nav > span { display: grid; place-items: center; font-size: 19px; width: 21px; }
#teacher .workspace-nav:hover { color: #fff; background: rgba(255, 255, 255, .055); transform: none; }
#teacher .workspace-nav.is-active {
  color: #fff; background: rgba(236, 97, 66, .17);
  border-color: rgba(255, 168, 137, .14);
  box-shadow: inset 3px 0 0 #f59664;
}
.workspace-sidebar-bottom { margin-top: auto; display: grid; gap: 15px; }
.workspace-sidebar { overflow-y: auto; overflow-x: hidden; scrollbar-width: thin; }
.workspace-sidebar > * { flex-shrink: 0; min-width: 0; }
.workspace-sidebar-bottom { flex-shrink: 0; padding-top: 14px; }
.workspace-test-note > div { min-width: 0; overflow-wrap: anywhere; }
.workspace-test-note { min-width: 0; max-width: 100%; box-sizing: border-box; }
@media(min-width:991px){
  .workspace-sidebar-bottom { position: sticky; bottom: -1px; background: #172134; z-index: 2; }
}
.workspace-test-note {
  display: flex; align-items: flex-start; gap: 9px;
  border: 1px solid rgba(245, 174, 115, .19);
  background: rgba(247, 172, 91, .075);
  border-radius: 12px; padding: 14px 11px;
}
.workspace-test-icon { display: grid; place-items: center; flex: 0 0 22px; height: 22px; background: #a67237; color: #fff4db; border-radius: 7px; font-weight: 900; }
.workspace-test-note strong { display: block; color: #f3e2ce; font-size: 11px; }
.workspace-test-note small { display: block; line-height: 1.6; font-size: 10px; color: #a9b5c9; margin-top: 5px; }
#teacher .workspace-logout {
  display: flex; gap: 11px; align-items: center; width: 100%; text-align: left;
  padding: 13px 12px; color: #c0cbdb; background: transparent;
  border: 1px solid rgba(255,255,255,.1);
}
#teacher .workspace-logout:hover { color: white; background: rgba(255,255,255,.07); }
.workspace-logout > span { font-size: 19px; }

.workspace-body { padding: 0 33px 40px; }
.workspace-topbar {
  min-height: 64px; display: flex; align-items: center; justify-content: space-between;
  gap: 16px; border-bottom: 1px solid var(--eg-line);
  color: #8a96a9; font-weight: 820; font-size: 10px; letter-spacing: .12em;
}
.workspace-topbar strong { color: #37445a; }
.workspace-divider { padding: 0 8px; color: #b5bfd0; }
.workspace-online { display: inline-flex; gap: 8px; align-items: center; color: #a7742f; font-size: 9px; white-space: nowrap; }
.workspace-online > span { width: 7px; height: 7px; border-radius: 50%; background: #e4a347; box-shadow: 0 0 0 4px #fff1dc; }
.workspace-view { animation: teacher-view-in .16s ease-out both; }
@keyframes teacher-view-in { from { opacity: .3; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }
.workspace-overline { font-size: 10px; font-weight: 850; letter-spacing: .125em; color: #ba5f42; }
.workspace-page-heading {
  margin: 33px 0 23px; display: flex; align-items: center;
  justify-content: space-between; gap: 18px;
}
.workspace-page-heading h1 { font-size: clamp(27px, 3vw, 37px); letter-spacing: -.045em; margin: 7px 0 6px; line-height: 1.2; color: #202b41; }
.workspace-page-heading p { margin: 0; font-size: 13px; color: #79869b; }
#teacher .workspace-main-action { white-space: nowrap; padding: 13px 19px; }
.workspace-summary { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin-bottom: 21px; }
.summary-tile {
  display: grid; grid-template-columns: 46px 1fr; grid-template-rows: 18px auto auto;
  column-gap: 14px; row-gap: 3px;
  min-height: 135px; padding: 20px 19px;
  border: 1px solid #e8ecf2; border-radius: 15px;
  background: #fff; box-shadow: 0 7px 20px rgba(35, 50, 74, .025);
}
.summary-icon {
  grid-row: 1 / 4; display: grid; place-items: center;
  align-self: start; width: 43px; height: 43px;
  font-size: 22px; font-weight: 900; border-radius: 12px;
}
.summary-all { background: #fff1eb; color: #cf5b37; }
.summary-running { background: #e7f8f0; color: #168b69; }
.summary-ended { background: #edf1fb; color: #556fb0; }
.summary-label { color: #778499; font-size: 12px; font-weight: 700; }
.summary-tile strong { color: #263247; line-height: 1; font-size: 32px; font-weight: 850; font-variant-numeric: tabular-nums; }
.summary-tile small { color: #a0abbc; font-size: 10px; }
#teacher .panel { background: #fff; box-shadow: 0 8px 26px rgba(37, 54, 80, .032); border: 1px solid #e7ebf1; }
#teacher .room-panel { padding: 25px 27px 29px; }
.workspace-panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 15px; margin-bottom: 23px; }
.workspace-panel-heading h2 { font-size: 23px; margin: 6px 0 4px; letter-spacing: -.035em; color: #263248; }
.workspace-panel-heading p { margin: 0; font-size: 12px; }
.room-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 14px; }
.room-card {
  display: grid; gap: 8px; padding: 20px; min-width: 0;
  background: #fff; border: 1px solid #e3e9f1; border-radius: 14px;
  transition: border-color .15s, box-shadow .15s;
}
.room-card:hover, .room-card.is-selected { border-color: #e0a29a; box-shadow: 0 6px 22px rgba(185, 70, 46, .055); }
.room-card-header { display: flex; justify-content: space-between; gap: 8px; align-items: center; flex-wrap: wrap; }
.room-code { color: #ae4d3a; font-size: 10px; letter-spacing: .09em; font-weight: 850; }
.room-status { display: inline-flex; align-items: center; gap: 6px; padding: 6px 9px; border-radius: 99px; font-weight: 800; font-size: 10px; }
.room-status::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.status-lobby { color: #97712a; background: #fff5e6; }
.status-running { color: #138568; background: #eaf9f2; }
.status-closed { color: #65728a; background: #edf1f5; }
.status-released { color: #4c69a5; background: #eaf0ff; }
.status-other { color: #7e8494; background: #f0f2f5; }
.room-card h3 { margin: 7px 0 0; font-size: 17px; line-height: 1.35; color: #263249; overflow-wrap: anywhere; }
.room-meta { margin: 0; font-size: 12px; color: #8b99a9; }
.room-card-footer { display: flex; justify-content: space-between; gap: 10px; align-items: center; flex-wrap: wrap; border-top: 1px solid #eff2f6; padding-top: 15px; margin-top: 10px; }
.room-card-footer small { color: #a0abba; font-size: 10px; }
#teacher .room-card-footer button { color: #bc2b1d; font-weight: 800; }
.room-empty { grid-column: 1 / -1; text-align: center; border: 1px dashed #d5dfea; border-radius: 15px; padding: 45px 18px; background: #fbfcfe; }
.room-empty-icon { display: grid; place-items: center; width: 56px; height: 56px; border-radius: 16px; margin: 0 auto 12px; font-size: 31px; background: #f4edea; color: #bb6b50; }
.room-empty h3 { margin: 3px 0 7px; font-size: 18px; }
.room-empty p { margin: 0 auto 18px; font-size: 12px; }

#teacher .detail { margin-top: 22px; padding: 29px 28px; scroll-margin-top: 22px; }
#teacher .detail > .section-heading { gap: 17px; flex-wrap: wrap; }
#teacher .detail > .section-heading h2 { font-size: 25px; letter-spacing: -.04em; overflow-wrap: anywhere; }
#teacher .detail .pill { font-weight: 820; white-space: nowrap; }
#teacher .metrics { display: grid; grid-template-columns: repeat(5,minmax(0,1fr)); gap: 10px; margin: 21px 0; }
#teacher .metrics > div { min-width: 0; padding: 18px 13px; border-radius: 12px; }
#teacher .metrics small { line-height: 1.4; font-size: 10px; font-weight: 700; }
#teacher .metrics strong { margin-top: 9px; font-size: 27px; }
#teacher .detail .actions { gap: 9px; margin: 16px 0; }
#teacher .detail .actions button { padding: 11px 14px; white-space: normal; }
#teacher .detail .notice { font-size: 12px; line-height: 1.7; padding: 13px 16px; }
#teacher .tablewrap { border-radius: 13px; border: 1px solid var(--eg-line); overflow-x: auto; }
#teacher table { min-width: 925px; width: 100%; }
#teacher th { font-size: 10px; letter-spacing: .06em; color: #768399; white-space: nowrap; }
#teacher td { font-size: 12px; }
#teacher td:first-child { min-width: 140px; }
#teacher td:last-child { min-width: 90px; }
#teacher tbody tr:hover { background: #fbfcff; }
#teacher .manual-panel { padding: 19px; border-radius: 13px; }

.builder-layout { display: grid; grid-template-columns: minmax(0,1fr) 245px; gap: 19px; align-items: start; }
#teacher .builder-panel { padding: 27px 29px; }
#teacher .builder-panel form { margin: 0; gap: 17px; }
#teacher .builder-section-heading { border-top: 1px solid var(--eg-line); margin-top: 10px; padding-top: 21px; }
.builder-section-heading strong { display: block; margin-top: 5px; font-size: 18px; }
#teacher .section-editor { padding: 18px; gap: 13px; border: 1px solid #e1e7ef; border-radius: 13px; background: #f9fbfe; }
#teacher .section-actions { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
#teacher .section-actions strong { font-size: 11px; letter-spacing: .08em; color: #a4513b; }
#teacher .question-editor { border: 1px solid #e3e8f0; border-radius: 12px; padding: 19px; background: #fff; box-shadow: none; }
#teacher .question-editor .controls { display: grid; grid-template-columns: minmax(0,1.4fr) minmax(115px,.6fr); gap: 11px; }
#teacher .question-editor textarea { min-height: 83px; }
#teacher .hint { margin: -2px 0 2px; line-height: 1.55; color: #8e9aad; }
#teacher .section-editor > button[data-action='add-question'] { border-style: dashed; background: #fff; color: #a8412e; }
.builder-submit { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 20px 0 0; margin-top: 4px; border-top: 1px solid var(--eg-line); }
.builder-submit strong { display: block; font-size: 13px; color: #344156; }
.builder-submit small { display: block; font-size: 11px; color: #8b99aa; margin-top: 5px; line-height: 1.5; }
.builder-submit button { flex-shrink: 0; }
.builder-help { padding: 25px 22px; border: 1px solid #e5eaf2; background: #fff; border-radius: 17px; position: sticky; top: 20px; }
.builder-help h3 { font-size: 20px; margin: 9px 0 22px; letter-spacing: -.035em; }
.builder-help ol { counter-reset: step; padding: 0; margin: 0; list-style: none; display: grid; gap: 24px; }
.builder-help li { position: relative; padding-left: 42px; }
.builder-help li::before { counter-increment: step; content: counter(step); display: grid; place-items: center; position: absolute; left: 0; top: 1px; width: 29px; height: 29px; border-radius: 9px; font-size: 12px; font-weight: 900; background: #fff0eb; color: #b8412a; }
.builder-help li strong { display: block; margin-bottom: 4px; font-size: 12px; }
.builder-help li span { display: block; color: #8693a6; font-size: 11px; line-height: 1.6; }
.builder-help-note { background: #f8f9fc; border-radius: 11px; margin-top: 29px; padding: 13px; color: #7d899d; font-size: 11px; line-height: 1.7; }

@media (max-width: 1180px) {
  .workspace-shell { grid-template-columns: 208px minmax(0,1fr); }
  .workspace-body { padding: 0 23px 35px; }
  .builder-layout { grid-template-columns: 1fr; }
  .builder-help { position: static; }
  .builder-help ol { grid-template-columns: repeat(3,1fr); gap: 12px; }
}
@media (max-width: 990px) {
  main:has(> #teacher:not(.hidden)) { padding: 16px 14px 110px; }
  .workspace-shell { display: block; }
  .workspace-sidebar { position: static; width: 100%; height: auto; min-height: 0; padding: 15px 19px; border-radius: 21px 21px 0 0; }
  .workspace-identity { padding: 0 0 14px; }
  .workspace-nav-caption, .workspace-test-note { display: none; }
  .workspace-navigation { display: flex; flex-wrap: wrap; gap: 8px; }
  #teacher .workspace-nav { width: auto; padding: 10px 14px; }
  .workspace-sidebar-bottom { margin: 0; position: absolute; right: 33px; top: 33px; }
  #teacher .workspace-logout { width: auto; padding: 8px 11px; }
  .workspace-shell { position: relative; }
  .workspace-body { padding: 0 22px 30px; }
  .workspace-topbar { min-height: 51px; }
  #teacher .metrics { grid-template-columns: repeat(3,minmax(0,1fr)); }
}
@media (max-width: 680px) {
  .workspace-sidebar-bottom { top: 24px; right: 17px; }
  #teacher .workspace-logout { font-size: 0; gap: 0; padding: 8px; }
  #teacher .workspace-logout > span { font-size: 19px; }
  .workspace-body { padding: 0 14px 23px; }
  .workspace-online { display: none; }
  .workspace-page-heading { align-items: flex-start; flex-direction: column; margin-top: 25px; }
  #teacher .workspace-main-action { width: 100%; }
  .workspace-summary { grid-template-columns: 1fr; gap: 9px; }
  .summary-tile { min-height: 94px; padding: 13px 15px; grid-template-columns: 43px 1fr; }
  .summary-tile strong { font-size: 27px; }
  #teacher .room-panel, #teacher .detail, #teacher .builder-panel { padding: 19px 15px; }
  .workspace-panel-heading { align-items: flex-start; flex-direction: column; }
  .room-grid { grid-template-columns: 1fr; }
  #teacher .metrics { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .builder-submit { flex-direction: column; align-items: stretch; }
  .builder-help ol { grid-template-columns: 1fr; }
  #teacher .question-editor .controls { grid-template-columns: 1fr; }
  #teacher .section-heading.compact { align-items: flex-start; gap: 10px; flex-wrap: wrap; }
  #teacher .detail .actions button { flex: 1 1 150px; }
}
@media (prefers-reduced-motion: reduce) {
  .workspace-view { animation: none; }
}
/* Results extend the existing teacher workspace; student styles are untouched. */
#teacher #results-workspace {border-top:1px solid var(--eg-line);padding-top:24px;margin-top:24px}
#teacher #results-workspace .manual-panel {width:100%;max-width:none}
#teacher #results-workspace pre {white-space:pre-wrap;overflow-wrap:anywhere;font-family:inherit}
#teacher #results-workspace .question-nav {position:sticky;top:0;background:#fff;padding:10px;z-index:2}
#teacher #results-workspace meter {width:100%;accent-color:var(--eg-red)}
#teacher #results-workspace [data-review-question] {scroll-margin-top:80px}
#teacher #results-workspace [data-save-status] {min-height:24px}
#teacher #results-workspace h4 {white-space:pre-wrap;overflow-wrap:anywhere}
/* Five independent teacher workspaces, compact six-room catalog. */
main:has(> #teacher:not(.hidden)){max-width:1560px;padding-bottom:40px}
.workspace-shell{grid-template-columns:214px minmax(0,1fr);min-height:calc(100vh - 145px)}
.workspace-sidebar{min-height:0;height:calc(100vh - 125px);top:12px;padding:24px 13px}
.workspace-summary{grid-template-columns:repeat(5,minmax(0,1fr));gap:12px}
.summary-tile{padding:16px;min-height:0}
.room-filters{display:grid;grid-template-columns:minmax(180px,2fr) minmax(160px,1fr);gap:14px;align-items:end;margin-bottom:10px}
.room-grid{grid-template-columns:repeat(2,minmax(0,1fr));gap:14px;align-items:stretch}
.room-card{padding:16px;gap:7px;align-content:start}
.room-card .room-code{font-size:13px;letter-spacing:.03em;overflow-wrap:anywhere}
.room-card h3{font-size:16px;margin:2px 0;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden}
.room-card>small{font-size:11px;color:var(--eg-muted)}
.room-card-actions{display:flex;gap:7px;flex-wrap:wrap;align-items:center;margin-top:8px}
.room-card-actions button{padding:8px 10px}
.room-more{position:relative;margin-left:auto}
.room-more summary{cursor:pointer;padding:7px 12px;border:1px solid var(--eg-line);border-radius:8px;list-style:none}
.room-more[open] button{position:absolute;right:0;top:100%;background:white;border:1px solid var(--eg-line);min-width:180px;box-shadow:0 8px 24px #20283b22;z-index:2}
.room-pagination{display:flex;justify-content:space-between;gap:12px;align-items:center;flex-wrap:wrap;margin-top:18px;font-size:12px;color:var(--eg-muted)}
#room-pages{display:flex;gap:6px;align-items:center;flex-wrap:wrap}
#room-pages .is-active{color:white;background:var(--eg-red);border-color:var(--eg-red)}
.workspace-room-picker{display:flex;align-items:end;gap:14px;flex-wrap:wrap;padding:16px;background:white;border:1px solid var(--eg-line);border-radius:12px;margin-bottom:16px}
.workspace-room-picker label{flex:1;min-width:180px;margin:0}
.workspace-room-picker select{max-width:100%}
.workspace-room-picker [data-selected-room-label]{font-size:12px;padding-bottom:12px;color:var(--eg-muted)}
.workspace-view:focus-visible,#teacher button:focus-visible,#teacher summary:focus-visible{outline:3px solid #f5a623;outline-offset:3px}
@media(max-width:1100px){.workspace-summary{grid-template-columns:repeat(3,minmax(0,1fr))}}
@media(max-width:990px){.workspace-shell{display:block}.workspace-sidebar{position:static;height:auto;min-height:0}.workspace-navigation{display:flex;flex-wrap:wrap}.workspace-navigation .workspace-nav{flex:1 1 145px}.workspace-sidebar-bottom{position:static;margin-top:12px}.workspace-test-note{display:none}}
@media(max-width:760px){.room-grid{grid-template-columns:1fr}.room-filters{grid-template-columns:1fr}.workspace-summary{grid-template-columns:repeat(2,minmax(0,1fr))}.workspace-page-heading{flex-wrap:wrap}.workspace-body{padding:18px 14px}.workspace-sidebar{border-radius:18px 18px 0 0}}
#teacher [hidden]{display:none!important}
#teacher #grading-workspace pre{white-space:pre-wrap;overflow-wrap:anywhere;font-family:inherit}
#teacher #grading-workspace .question-nav{position:sticky;top:0;background:white;padding:10px;z-index:2}

#teacher [data-stats]{overflow-x:auto;max-width:100%}
