body {
  font-family: JetBrains Mono, monospace;
  max-width: 800px;
  margin: 20px auto;
  padding: 20px;
  line-height: 1.6;
}

h1 {
  color: #003262;
  border-bottom: 3px solid #003262;
  padding-bottom: 10px;
}

.controls {
  text-align: center;
  margin: 20px 0;
}

button {
  background-color: #003262;
  color: white;
  padding: 12px 24px;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  font-size: 16px;
  margin: 5px;
}

button:hover {
  background-color: #004a99;
}

button.save-btn {
  background-color: #28a745;
}

button.save-btn:hover {
  background-color: #218838;
}

button.clear-btn {
  background-color: #dc3545;
}

button.clear-btn:hover {
  background-color: #c82333;
}

#score {
  font-size: 28px;
  font-weight: bold;
  text-align: center;
  margin: 20px 0;
}

#score-bottom {
  font-size: 28px;
  font-weight: bold;
  text-align: center;
  margin: 20px 0;
}

#cat-container {
  text-align: center;
  margin: 20px 0;
}

#cat-container img {
  max-width: 400px;
	/* max-height: 300px; */
  width: 100%;
  height: auto;
  border-radius: 8px;
}

/* Note / instruction block */
.note {
  background-color: #eef2f7;
  border-left: 8px solid #003262;
  padding: 12px 15px;
  margin: 20px 0;
  font-style: normal;
  color: #333;
}

.question {
  background-color: #f9f9f9;
  border-left: 4px solid #003262;
  padding: 15px;
  margin: 20px 0;
}

.choice {
  display: block;
  margin: 6px 0;
  padding: 0 5px;
  border-radius: 3px;
}

input[type="radio"],
input[type="checkbox"] {
  margin-right: 10px;
}

input[type="text"] {
  border: 1px solid #333;
  padding: 3px 4px;
  font-family: monospace;
  font-size: 13px;
  margin: 0 3px;
	width: 60px;

}

.feedback-container {
  margin-top: 15px;
}

.feedback {
  padding: 10px;
  border-radius: 5px;
  margin-top: 10px;
}

.feedback.correct {
  background-color: #d4edda;
  border: 2px solid #28a745;
  color: #155724;
}

.feedback.incorrect {
  background-color: #f8d7da;
  border: 2px solid #dc3545;
  color: #721c24;
}

.feedback.partial {
  background-color: #fff3cd;
  border: 2px solid #ffc107;
  color: #856404;
}

/* Layout Variants */

/* Horizontal choices for MCQ/Multi */
.horizontal-choices .choice {
  display: inline-block;
  margin-right: 20px;
  margin-bottom: 10px;
}

/* Side-by-side layout (e.g., inputs next to image) */
.side-by-side {
  display: flex;
  align-items: flex-start;
  gap: 20px;
}

.side-by-side .inputs-column {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.side-by-side .image-column {
  flex: 1;
  text-align: center;
}

.side-by-side .image-column img {
  max-width: 100%;
  height: auto;
}

/* Truth table styling */
.question table {
  border-collapse: collapse;
  margin: 15px auto;
}

.question th,
.question td {
  border: 1px solid #333;
  padding: 8px 12px;
  text-align: center;
}

.question th {
  background-color: #003262;
  color: white;
}

.question td input[type="text"] {
  width: 40px;
  text-align: center;
}

.question-text {
	margin-bottom: 1.5rem;
}

/* Hint styling */
.hint {
  background-color: #fff3cd;
  border-left: 4px solid #ffc107;
  padding: 10px 15px;
  margin: 10px 0;
  cursor: pointer;
}

.hint summary {
  font-weight: bold;
  color: #856404;
  user-select: none;
}

.hint[open] summary {
  margin-bottom: 8px;
}

/* Mobile responsiveness for side-by-side */
@media (max-width: 600px) {
  .side-by-side {
    flex-direction: column;
  }
  
  .horizontal-choices .choice {
    display: block;
    margin-right: 0;
  }
}

/* ============================================
   TIMING DIAGRAM STYLES
   ============================================ */

.timing-diagram .circuit-image,
.timing-diagram-waveform .circuit-image {
  text-align: center;
  margin: 15px 0;
}

.timing-diagram .circuit-image img,
.timing-diagram-waveform .circuit-image img {
  max-width: 100%;
  height: auto;
  border: 2px solid #003262;
  border-radius: 5px;
}

.timing-grid-container {
  overflow-x: auto;
  margin: 15px 0;
}

.timing-grid {
  border-collapse: collapse;
  margin: 0 auto;
  font-family: 'JetBrains Mono', monospace;
  font-size: 18px;
}

.timing-grid th,
.timing-grid td {
  border: 2px solid #333;
  padding: 8px 0px;
  text-align: center;
  min-width: 30px;
}

/* Waveform variant - gray borders and larger cells */
.timing-diagram-waveform .timing-grid th,
.timing-diagram-waveform .timing-grid td {
  border: 1px solid #999;
  padding: 0;
  text-align: center;
  min-width: 0;
}

.timing-grid .signal-name-header {
  background-color: #003262;
  color: white;
  font-weight: bold;
}

.timing-grid .cycle-header {
  background-color: #003262;
  color: white;
  font-weight: bold;
  font-size: 14px;
}

.timing-grid .signal-name {
  background-color: #e8e8e8;
  font-weight: bold;
  text-align: right;
  padding-right: 15px;
}

.timing-grid .timing-cell {
  cursor: pointer;
  user-select: none;
  font-weight: bold;
  font-size: 20px;
  background-color: white;
  transition: background-color 0.1s;
}

/* Waveform variant - larger font for symbols */
.timing-diagram-waveform .timing-grid .timing-cell {
  font-size: 32pt;
  transform: scaleX(1.5);
}

.timing-grid .timing-cell:hover:not(.readonly) {
  background-color: #f0f0f0;
}

.timing-grid .timing-cell.readonly {
  cursor: default;
  background-color: #f9f9f9;
  color: #666;
}

.timing-grid .timing-cell.correct {
  background-color: #d4edda !important;
}

.timing-grid .timing-cell.incorrect {
  background-color: #f8d7da !important;
}

.note pre {
  font-style: normal;
  background-color: #f0f0f0;
}

.note pre code {
  font-style: normal;
  color: #000;
}

code {
	font-family: 'JetBrains Mono', monospace;
	/* background-color: #ffeb9942; */
	color: maroon;
	font-size: 14px;
}

s1  { --n: 1; }
s2  { --n: 2; }
s3  { --n: 3; }
s4  { --n: 4; }
s5  { --n: 5; }
s6  { --n: 6; }
s7  { --n: 7; }
s8  { --n: 8; }
s9  { --n: 9; }
s10 { --n: 10; }
s11 { --n: 11; }
s12 { --n: 12; }
s13 { --n: 13; }
s14 { --n: 14; }
s15 { --n: 15; }
s16 { --n: 16; }
s17 { --n: 17; }
s18 { --n: 18; }
s19 { --n: 19; }
s20 { --n: 20; }
s21 { --n: 21; }
s22 { --n: 22; }
s23 { --n: 23; }
s24 { --n: 24; }
s25 { --n: 25; }
s26 { --n: 26; }
s27 { --n: 27; }
s28 { --n: 28; }
s29 { --n: 29; }
s30 { --n: 30; }
s31 { --n: 31; }
s32 { --n: 32; }

:is(
  s1, s2, s3, s4, s5, s6, s7, s8,
  s9, s10, s11, s12, s13, s14, s15, s16,
  s17, s18, s19, s20, s21, s22, s23, s24,
  s25, s26, s27, s28, s29, s30, s31, s32
) * {
  width: calc(var(--n) * 1.5ex) !important;
}

@media print {
  @page {
    size: letter;
    margin: 0.75in;
  }

  body {
    max-width: 100%;
    margin: 0;
    padding: 0;
  }

  .controls,
  #score-bottom,
  .hint {
    display: none !important;
  }

  .question {
    break-inside: avoid;
  }
}

@media print {
  .name-field {
    border: 2px solid #003262;
    padding: 12px 15px;
    margin: 20px 0;
  }

  .name-field input {
    border: none;
    /* border-bottom: 1px solid #333; */
    font-size: 20pt;
    width: auto;
  }
}

@media print {
  #score-pct {
    border: 2px solid #003262;
    padding: 4px 12px;
    margin: 0 36px;
  }
}