* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: #1b1f24;
  background: #f5f7fa;
  font-family: Arial, sans-serif;
  font-size: 14px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 24px;
  background: #ffffff;
  border-bottom: 1px solid #d7dde5;
}

.pageNav {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.pageNav a {
  min-height: 36px;
  border: 1px solid #b8c2cf;
  border-radius: 4px;
  padding: 8px 12px;
  color: #1b1f24;
  background: #ffffff;
  text-decoration: none;
}

.pageNav a.active {
  border-color: #2b65d9;
  color: #ffffff;
  background: #2b65d9;
}

.studentPage .teacherOnly,
.teacherPage .studentOnly {
  display: none !important;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 20px;
}

h2 {
  margin-bottom: 12px;
  font-size: 16px;
}

ol {
  margin: 0;
}

.layout {
  display: grid;
  gap: 16px;
  max-width: 1500px;
  margin: 0 auto;
  padding: 16px;
}

.introPanel {
  background: #fbfcff;
}

.scenarioList {
  display: grid;
  gap: 6px;
  padding-left: 20px;
  color: #3c4653;
  line-height: 1.45;
}

.panel,
.viewerPanel {
  background: #ffffff;
  border: 1px solid #d7dde5;
  border-radius: 6px;
  padding: 16px;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 16px;
}

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

.drawingViewport {
  min-height: 520px;
  margin-top: 12px;
  overflow: auto;
  border: 1px solid #c7d0db;
  background: #e8edf3;
}

.drawingStage {
  position: relative;
  width: 100%;
  min-width: 720px;
  background: #ffffff;
}

.drawingStage img {
  display: block;
  width: 100%;
  height: auto;
  min-height: 0;
  background: #ffffff;
}

.overlay {
  position: absolute;
  inset: 0;
  cursor: crosshair;
}

.regionBox {
  position: absolute;
  border: 2px solid #f04438;
  background: rgba(240, 68, 56, 0.12);
  pointer-events: none;
}

.regionExpected {
  border-color: #2b65d9;
  background: rgba(43, 101, 217, 0.12);
}

.regionStudent {
  border-color: #2e7d32;
  background: rgba(46, 125, 50, 0.12);
}

.regionSelected {
  border-color: #f04438;
  background: rgba(240, 68, 56, 0.12);
}

.regionSystem {
  border-color: #7c3aed;
  background: rgba(124, 58, 237, 0.12);
}

.regionSummary {
  display: grid;
  gap: 6px;
  margin-top: 10px;
}

.ruleGlossary {
  display: grid;
  gap: 6px;
  margin: 10px 0 14px;
}

.ruleGlossary div {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid #d7dde5;
  border-radius: 4px;
  background: #fbfcff;
}

.ruleGlossary strong {
  font-size: 12px;
}

.ruleGlossary span {
  color: #3c4653;
  font-size: 12px;
}

.regionLegend {
  padding: 8px;
  border: 1px solid #d7dde5;
  border-radius: 4px;
  background: #ffffff;
  font-size: 12px;
}

.expectedLegend {
  border-left: 4px solid #2b65d9;
}

.studentLegend {
  border-left: 4px solid #2e7d32;
}

.systemLegend {
  border-left: 4px solid #7c3aed;
}

.grid {
  display: grid;
  gap: 12px;
}

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

.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.four {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.five {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.compact label {
  margin-bottom: 0;
}

label {
  display: grid;
  gap: 5px;
  margin-bottom: 10px;
  font-weight: 600;
}

input,
textarea,
select,
button {
  font: inherit;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid #b8c2cf;
  border-radius: 4px;
  padding: 8px;
  background: #ffffff;
}

textarea {
  min-height: 72px;
  resize: vertical;
}

button {
  min-height: 36px;
  border: 1px solid #2b65d9;
  border-radius: 4px;
  padding: 8px 12px;
  color: #ffffff;
  background: #2b65d9;
  cursor: pointer;
}

button.secondary {
  color: #1b1f24;
  background: #ffffff;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0;
}

.actionStatus {
  margin: 8px 0;
  padding: 10px;
  border: 1px solid #d7dde5;
  border-radius: 4px;
  line-height: 1.45;
}

.actionStatusEmpty,
.actionStatusLoading {
  color: #5d6978;
  background: #f8fafc;
}

.actionStatusSuccess {
  border-color: #2e7d32;
  background: #f0f8f1;
}

.actionStatusError {
  border-color: #c62828;
  background: #fff1f1;
}

.small,
.hint,
.jsonHelp {
  color: #5d6978;
  font-size: 12px;
}

.hint {
  margin-bottom: 12px;
  line-height: 1.45;
}

.jsonHelp {
  margin-top: 10px;
  line-height: 1.45;
}

.scoreSummary {
  display: grid;
  gap: 12px;
  margin-top: 12px;
  padding: 14px;
  border: 1px solid #d7dde5;
  border-radius: 6px;
  background: #f8fafc;
}

.scorePassed {
  border-color: #2e7d32;
  background: #f0f8f1;
}

.scoreFailed {
  border-color: #c62828;
  background: #fff1f1;
}

.scoreReview {
  border-color: #b26a00;
  background: #fff7e8;
}

.scoreEmpty {
  border-color: #d7dde5;
  background: #f8fafc;
}

.aiSummary {
  margin-top: 10px;
  padding: 12px;
  border: 1px solid #d7dde5;
  border-radius: 4px;
  line-height: 1.45;
}

.aiSummaryEmpty,
.aiSummaryLoading {
  color: #5d6978;
  background: #f8fafc;
}

.aiSummarySuccess {
  border-color: #2e7d32;
  background: #f0f8f1;
}

.aiSummaryWarning {
  border-color: #b26a00;
  background: #fff7e8;
}

.aiSummaryError {
  border-color: #c62828;
  background: #fff1f1;
}

.verdict {
  display: grid;
  gap: 4px;
}

.verdictLabel {
  color: #5d6978;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.verdict strong {
  font-size: 18px;
}

.scoreDetails,
.matchDetails {
  display: grid;
  gap: 8px;
}

.scoreDetails {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.scoreDetails span,
.matchItem {
  padding: 10px;
  border: 1px solid #d7dde5;
  border-radius: 4px;
  background: #ffffff;
}

.matchDetails {
  margin-top: 10px;
}

.matchItem {
  display: grid;
  gap: 4px;
}

.matchTitle {
  font-weight: 700;
}

.matchMeta {
  color: #5d6978;
  font-size: 12px;
}

pre {
  max-height: 360px;
  overflow: auto;
  margin: 10px 0 0;
  padding: 12px;
  border: 1px solid #d7dde5;
  border-radius: 4px;
  background: #0f172a;
  color: #e5e7eb;
  white-space: pre-wrap;
}

.logPanel pre {
  max-height: 520px;
}

@media (max-width: 900px) {
  .workspace,
  .two,
  .three,
  .four,
  .five,
  .ruleGlossary div,
  .scoreDetails {
    grid-template-columns: 1fr;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }
}
