.grading-layout {
  grid-template-columns: minmax(215px, 260px) minmax(300px, .82fr) minmax(360px, 1.18fr);
  gap: 16px;
}

.camera-head,
.result-head {
  border-bottom-color: var(--line);
  background: #1d2434;
  color: #c7d1e6;
}

.camera-frame {
  background: radial-gradient(circle at 50% 45%, #263b67, #0d1119 72%);
}

.camera-placeholder {
  color: #aab8d5;
}

.scan-target i {
  border-color: #82a1ff;
}

.result-empty {
  color: #e1e7f4;
  background: radial-gradient(circle, rgba(79, 124, 255, .12), transparent 48%);
}

.result-empty p,
.status {
  color: #94a3c0;
}

.status-error {
  color: #ff8191;
}

.status-ok {
  color: #00d4aa;
}

.score-card {
  background: rgba(0, 212, 170, .14);
  color: #d6fff5;
  border-right-color: #00d4aa;
}

.answer-table {
  color: #e8edf8;
}

.answer-table th,
.answer-table td {
  border-bottom-color: var(--line);
}

.answer-table th {
  background: #20283a;
  color: #aebbd4;
}

.graded-student {
  margin-bottom: 18px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(18, 24, 36, .72);
}

.grading-exam-group {
  margin-bottom: 16px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(18, 24, 36, .72);
}

.grading-exam-group-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px;
  border-bottom: 1px solid var(--line);
}

.grading-exam-group-head h3 {
  margin: 0 0 5px;
}

.grading-exam-group-head span {
  color: #94a3c0;
  font-size: 12px;
}

.grading-exam-table-wrap {
  overflow-x: auto;
}

.grading-record-table {
  width: 100%;
  border-collapse: collapse;
}

.grading-record-table th,
.grading-record-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  text-align: start;
  white-space: nowrap;
}

.grading-record-table tbody tr:last-child td {
  border-bottom: 0;
}

.grading-record-open {
  border: 0;
  background: transparent;
  color: #82a1ff;
  font: inherit;
  text-decoration: underline;
  cursor: pointer;
}

.grading-record-dialog {
  width: min(760px, calc(100vw - 28px));
  max-height: min(88vh, 900px);
  overflow: auto;
}

.grading-record-answers {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  max-height: 48vh;
  overflow: auto;
  margin: 16px 0;
}

.grading-record-answers label {
  display: grid;
  gap: 5px;
}

.grading-record-answers select {
  min-width: 0;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #151b28;
  color: inherit;
}

.grading-record-dialog .project-dialog-actions {
  flex-wrap: wrap;
}

.grading-duplicate-dialog {
  width: min(520px, calc(100vw - 28px));
}

.grading-duplicate-dialog p {
  margin: 0 0 14px;
  color: var(--muted);
  line-height: 1.8;
}

.grading-duplicate-dialog [data-view-duplicate-record] {
  min-height: 40px;
}

.grading-duplicate-dialog .project-dialog-actions {
  flex-wrap: wrap;
}

.graded-student-head,
.graded-student-actions {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.graded-student-head > div {
  display: grid;
  gap: 5px;
}

.graded-student-head span {
  color: #00d4aa;
}

.graded-student-head label {
  max-width: 220px;
}

.answer-table select {
  min-width: 118px;
  padding: 7px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #151b28;
  color: inherit;
}

.answer-correct {
  color: #00d4aa;
}

.answer-incorrect {
  color: #ff8191;
}

.answer-pending {
  color: #ffc857;
}

.graded-student-actions {
  justify-content: flex-start;
  margin: 12px 0 0;
}

.grading-source-buttons {
  display: grid;
  grid-template-columns: 1fr;
  gap: 9px;
  padding: 12px;
}

.grading-source-buttons .grading-upload {
  position: relative;
  margin: 0 !important;
  cursor: pointer;
  transition: border-color .2s ease, transform .2s ease, background .2s ease;
}

.grading-source-buttons .grading-upload:hover {
  border-color: var(--blue);
  background: rgba(79, 124, 255, .09);
  transform: translateY(-1px);
}

.grading-source-buttons .grading-upload[aria-disabled="true"] {
  opacity: .5;
  pointer-events: none;
}

.grading-source-buttons input[type="file"] {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.grading-source-buttons .grading-native-camera-input {
  position: absolute;
  inset: auto;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  opacity: 0;
  pointer-events: none;
  white-space: nowrap;
}

.grading-source-buttons .camera-capture-button {
  border-color: rgba(79, 124, 255, .55);
  background: rgba(79, 124, 255, .08);
}

.grading-source-buttons > button {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  text-align: start;
}

.grading-source-buttons .camera-capture-button[aria-busy="true"] {
  cursor: wait;
}

.grading-source-buttons .grading-pdf-upload small {
  display: block;
  margin-top: 4px;
  color: #94a3c0;
  font-size: 11px;
}

.grading-pdf-upload input:disabled {
  cursor: not-allowed;
}

.grading-pdf-batch[hidden] {
  display: none !important;
}

.grading-pdf-batch {
  margin: 0 12px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(18, 24, 36, .72);
  padding: 12px;
}

.grading-pdf-batch > p {
  margin: 0;
  color: #c7d1e6;
  line-height: 1.7;
}

.grading-pdf-progress {
  height: 7px;
  overflow: hidden;
  margin-top: 10px;
  border-radius: 99px;
  background: #101522;
}

.grading-pdf-progress[hidden] {
  display: none !important;
}

.grading-pdf-progress span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #4f7cff, #00d4aa);
  transition: width .25s ease;
}

.grading-pdf-page-list,
.grading-pdf-sheet-list {
  display: grid;
  gap: 9px;
  margin-top: 12px;
}

.grading-pdf-page,
.grading-pdf-sheet {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(9, 13, 22, .58);
  padding: 10px;
}

.grading-pdf-page {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.grading-pdf-page p,
.grading-pdf-sheet p {
  margin: 4px 0 0;
  color: #aab8d5;
  font-size: 12px;
  line-height: 1.6;
}

.grading-pdf-sheet summary {
  cursor: pointer;
  font-weight: 700;
}

.grading-pdf-sheet label {
  display: grid;
  gap: 5px;
  margin-top: 10px;
}

.grading-pdf-sheet input,
.grading-pdf-sheet select {
  min-width: 0;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #151b28;
  color: inherit;
}

.grading-pdf-answer-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
  gap: 7px;
  margin-top: 10px;
}

.grading-pdf-retry-upload {
  position: relative;
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  min-height: 34px;
  overflow: hidden;
  border: 1px solid rgba(79, 124, 255, .55);
  border-radius: 7px;
  background: rgba(79, 124, 255, .08);
  padding: 6px 10px;
  color: #dce5ff;
  cursor: pointer;
  font-size: 12px;
}

.grading-pdf-retry-upload input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.grading-pdf-retry-upload input:disabled {
  cursor: wait;
}

.grading-sessions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 14px;
}

.grading-result .grading-sessions[hidden],
.grading-result .grading-session-back[hidden],
.grading-result .grading-session-content[hidden],
.grading-result .grading-record-views[hidden] {
  display: none !important;
}

.grading-sessions > button {
  align-self: flex-start;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #151b28;
  padding: 8px 12px;
  color: #aab8d5;
  cursor: pointer;
}

.grading-sessions > button[aria-pressed="true"],
.grading-session-item.is-selected {
  border-color: rgba(79, 124, 255, .7);
  background: rgba(79, 124, 255, .15);
  color: #e8edf8;
}

.grading-session-item {
  display: flex;
  flex: 0 0 auto;
  align-items: stretch;
  overflow: hidden;
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #151b28;
  direction: rtl;
  transition: border-color .18s ease, background .18s ease;
}

.grading-session-handle,
.grading-session-main,
.grading-session-actions button {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  border: 0;
  background: transparent;
  color: #aab8d5;
}

.grading-session-handle {
  width: 40px;
  border-left: 1px solid var(--line);
  color: #82a1ff;
  cursor: grab;
  touch-action: pan-y;
}

.grading-session-handle:active {
  cursor: grabbing;
}

.grading-session-handle svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.grading-session-item.is-actions-open .grading-session-handle svg {
  transform: rotate(180deg);
}

.grading-session-main {
  flex: 1 1 auto;
  min-width: 0;
  max-width: none;
  overflow: hidden;
  padding: 8px 12px;
  cursor: pointer;
  touch-action: pan-y;
  justify-content: flex-start;
  text-align: right;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.grading-session-item.is-selected .grading-session-main {
  color: #e8edf8;
}

.grading-session-actions {
  display: inline-flex;
  flex: 0 0 auto;
  overflow: hidden;
  max-width: 0;
  transition: max-width .2s ease;
}

.grading-session-item.is-actions-open .grading-session-actions {
  max-width: 120px;
}

.grading-session-actions button {
  width: 40px;
  min-width: 40px;
  height: 40px;
  padding: 7px;
  border-right: 1px solid var(--line);
  cursor: pointer;
}

.grading-session-actions button:hover:not(:disabled) {
  filter: brightness(1.2);
}

.grading-session-actions svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.grading-session-actions .grading-session-action-delete {
  background: rgba(229, 83, 91, .15);
  color: #ff6b73;
}

.grading-session-actions .grading-session-action-rename {
  background: rgba(97, 189, 244, .15);
  color: #75ccff;
}

.grading-session-actions .grading-session-action-archive {
  background: rgba(50, 184, 121, .15);
  color: #45d18e;
}

.grading-session-empty {
  margin: 0;
  padding: 12px 4px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

.grading-session-back {
  padding: 12px 14px 0;
}

.grading-sessions button:disabled {
  cursor: wait;
}

.grading-sessions button:focus-visible,
.grading-record-views button:focus-visible,
.grading-pdf-retry-upload:focus-within {
  outline: 2px solid #82a1ff;
  outline-offset: 2px;
}

.grading-record-views {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px 14px 0;
}

.grading-record-views button {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #151b28;
  padding: 8px 12px;
  color: #aab8d5;
  cursor: pointer;
}

.grading-record-views button[aria-pressed="true"] {
  border-color: rgba(79, 124, 255, .7);
  background: rgba(79, 124, 255, .15);
  color: #e8edf8;
}

.grading-result .export-control:disabled {
  border-color: var(--line);
  color: #7d89a2;
  cursor: not-allowed;
  opacity: .48;
}

.camera-capture-action[hidden] {
  display: none !important;
}

.camera-capture-action {
  position: absolute;
  z-index: 3;
  inset: auto 50% 12px auto;
  transform: translateX(50%);
  min-height: 42px;
  border: 1px solid rgba(255,255,255,.3);
  border-radius: 8px;
  background: #263d75;
  padding: 8px 18px;
  color: #fff;
  cursor: pointer;
}

.camera-frame #grading-camera:not([hidden]) {
  display: block;
}

.grading-loader[hidden] {
  display: none !important;
}

.grading-loader {
  position: absolute;
  z-index: 4;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 13px;
  overflow: hidden;
  background: rgba(7, 11, 20, .74);
  backdrop-filter: blur(3px);
  color: #f3f6ff;
}

.grading-loader::before,
.grading-loader::after {
  position: absolute;
  width: 175px;
  height: 175px;
  border-radius: 50%;
  content: "";
  filter: blur(24px);
  opacity: .32;
  animation: grading-nebula 3.8s ease-in-out infinite alternate;
}

.grading-loader::before {
  background: radial-gradient(circle, #6757ff, transparent 70%);
  transform: translate(-45px, -12px);
}

.grading-loader::after {
  background: radial-gradient(circle, #12d6cc, transparent 70%);
  transform: translate(48px, 14px);
  animation-delay: -1.9s;
}

.grading-loader strong,
.grading-loader-orbit {
  position: relative;
  z-index: 1;
}

.grading-loader strong {
  font-size: 15px;
  text-shadow: 0 1px 18px rgba(104, 173, 255, .65);
}

.grading-loader-orbit {
  display: flex;
  align-items: center;
  gap: 7px;
  height: 15px;
}

.grading-loader-orbit i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #7e88ff;
  box-shadow: 0 0 12px currentColor;
  animation: grading-orbit-pulse 1.4s ease-in-out infinite;
}

.grading-loader-orbit i:nth-child(2) {
  background: #4be6dc;
  animation-delay: .2s;
}

.grading-loader-orbit i:nth-child(3) {
  background: #d06bff;
  animation-delay: .4s;
}

.camera-frame #sheet-preview:not([hidden]) {
  display: block;
  background: #090c12;
  opacity: 1;
  transition: opacity .25s ease;
}

.camera-frame.has-preview .camera-placeholder {
  display: none;
}

.camera-frame.is-analyzing #sheet-preview {
  opacity: .22;
}

.pending-review > #accept-pending-scan {
  margin-top: 14px;
}

.grading-upload input:disabled {
  cursor: not-allowed;
}

.pending-review {
  margin: 14px;
  border: 1px solid rgba(255, 200, 87, .4);
  border-radius: 10px;
  background: rgba(255, 200, 87, .06);
  padding: 12px;
}

.pending-review[hidden] {
  display: none !important;
}

.pending-review > header {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: #e8edf8;
}

.pending-review > header span,
.pending-review > p {
  color: #aebbd4;
  font-size: 11px;
}

.pending-review > p {
  line-height: 1.7;
}

.pending-answer-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 8px;
  max-height: 220px;
  overflow: auto;
}

.pending-answer-list label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  color: #e8edf8;
  font-size: 11px;
}

.pending-answer-list select {
  min-width: 90px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #151b28;
  padding: 6px;
  color: inherit;
}

.grading-state[data-state="analyzing"] i {
  background: #ffc857;
  animation: grading-pulse 1s ease-in-out infinite alternate;
}

.grading-state[data-state="review"] i {
  background: #ffc857;
}

.grading-state[data-state="saved"] i {
  background: #00d4aa;
}

.grading-controls [hidden],
.camera-frame [hidden] {
  display: none !important;
}

.grading-identity,
.grading-upload-list {
  display: grid;
  gap: 8px;
}

.grading-identity label {
  margin-bottom: 4px;
}

.grading-student-number small {
  display: block;
  margin-top: 4px;
  color: #94a3c0;
  font-weight: 400;
}

.grading-results-tools {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 5px 12px;
  margin: 14px;
}

.grading-results-tools[hidden] {
  display: none !important;
}

.grading-results-tools label {
  color: #bdc8de;
  font-size: 11px;
  font-weight: 700;
}

.grading-results-tools input {
  grid-column: 1;
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line-dark);
  border-radius: 8px;
  background: #111722;
  color: var(--ink);
  padding: 8px 11px;
}

.grading-results-tools > span {
  grid-column: 2;
  grid-row: 2;
  color: #94a3c0;
  font-size: 10px;
}

.graded-student[hidden] {
  display: none !important;
}

.grading-export-dialog {
  width: min(1050px, calc(100% - 32px));
  max-height: min(92vh, 900px);
  overflow: hidden;
}

.grading-export-dialog form {
  display: grid;
  grid-template-rows: auto auto auto minmax(0, 1fr) auto auto;
  max-height: calc(92vh - 52px);
  gap: 12px;
}

.grading-export-dialog h2 {
  margin: 0;
}

.export-file-name {
  display: grid;
  gap: 6px;
  color: #bdc8de;
  font-size: 12px;
}

.export-file-name input {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line-dark);
  border-radius: 8px;
  background: #111722;
  color: var(--ink);
  padding: 8px 11px;
}

.export-columns {
  min-width: 0;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
}

.export-columns legend {
  padding: 0 6px;
  color: #bdc8de;
  font-size: 11px;
}

.export-column-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
  max-height: 110px;
  overflow: auto;
}

.export-column-list label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #d3dbed;
  font-size: 10px;
}

.export-column-list input {
  accent-color: var(--blue);
}

.grading-export-preview {
  display: grid;
  min-height: 0;
  grid-template-rows: auto minmax(0, 1fr);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.grading-export-preview > header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border-bottom: 1px solid var(--line);
  background: #20283a;
  padding: 9px 12px;
  color: #e8edf8;
  font-size: 11px;
}

.grading-export-preview > header span {
  color: #94a3c0;
  font-size: 9px;
}

.grading-export-preview-table {
  min-height: 0;
  overflow: auto;
}

.grading-export-preview-table table {
  width: max-content;
  min-width: 100%;
  border-collapse: collapse;
  direction: rtl;
  color: #e8edf8;
  font-size: 10px;
}

.grading-export-preview-table th,
.grading-export-preview-table td {
  min-width: 82px;
  border-bottom: 1px solid var(--line);
  border-inline-start: 1px solid var(--line);
  padding: 7px 9px;
  text-align: right;
  white-space: nowrap;
}

.grading-export-preview-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #20283a;
  color: #aebbd4;
}

.grading-export-error {
  margin: 0;
  color: #ff8191;
  font-size: 11px;
}

.grading-export-error[hidden] {
  display: none;
}

.grading-upload[aria-disabled="true"] {
  opacity: .48;
}

.grading-cancel {
  width: 100%;
}

.camera-frame video,
.camera-frame #sheet-preview {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.camera-frame.has-preview #camera {
  display: none;
}

.camera-frame #sheet-preview:not([hidden]) {
  display: block;
  background: #090c12;
}

.camera-live-status {
  position: absolute;
  z-index: 3;
  inset: auto 10px 10px auto;
  border: 1px solid rgba(255,255,255,.2);
  border-radius: 20px;
  background: rgba(8,12,20,.78);
  padding: 5px 9px;
  color: #e8edf8;
  font-size: 10px;
}

.scan-target {
  pointer-events: none;
}

.scan-target i {
  position: absolute;
  width: 18px;
  height: 18px;
  border-color: #82a1ff;
}

.scan-target i:nth-child(1) { top: -1px; right: -1px; border-top: 2px solid; border-right: 2px solid; }
.scan-target i:nth-child(2) { top: -1px; left: -1px; border-top: 2px solid; border-left: 2px solid; }
.scan-target i:nth-child(3) { bottom: -1px; right: -1px; border-bottom: 2px solid; border-right: 2px solid; }
.scan-target i:nth-child(4) { bottom: -1px; left: -1px; border-bottom: 2px solid; border-left: 2px solid; }

.camera-actions {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.camera-actions #scan-button {
  grid-column: 1 / -1;
}

.camera-help {
  margin: 0;
  padding: 0 14px 14px;
  color: #94a3c0;
  font-size: 11px;
  line-height: 1.7;
}

@keyframes grading-pulse {
  to { box-shadow: 0 0 0 7px rgba(255,200,87,.08); }
}

@keyframes grading-nebula {
  from { opacity: .2; scale: .88; }
  to { opacity: .48; scale: 1.12; }
}

@keyframes grading-orbit-pulse {
  0%, 100% { opacity: .38; transform: scale(.75); }
  50% { opacity: 1; transform: scale(1.2); }
}

.toast {
  border: 1px solid var(--line-dark);
  background: #20283a;
  color: #f0f3fb;
  box-shadow: 0 12px 35px rgba(0, 0, 0, .4);
}

.toast.success {
  border-color: #00a985;
  color: #74e6cd;
}

.toast.error {
  border-color: #b64259;
  color: #ff9aa8;
}

@media (max-width: 760px) {
  .grading-source-buttons {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .grading-source-buttons .grading-upload {
    min-width: 0;
  }

  .grading-source-buttons .grading-upload > span:last-of-type {
    min-width: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .grading-loader::before,
  .grading-loader::after,
  .grading-loader-orbit i {
    animation: none;
  }
}

body.login-page {
  background:
    radial-gradient(ellipse at 15% 15%, rgba(79, 124, 255, .2), transparent 32rem),
    #0b0e14;
  color: #e8edf8;
  font-family: var(--font-ar);
}
