:root {
  --bg: #f3f5f9;
  --card: #ffffff;
  --text: #1e2430;
  --muted: #5c667a;
  --line: #d9dfeb;
  --primary: #1f6feb;
  --danger: #c62828;
  --warning: #a15f00;
  --ok: #0f7a33;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.container {
  max-width: 1180px;
  margin: 0 auto;
  padding: 20px 16px 40px;
}

.hero h1 {
  margin: 0 0 4px;
}

.hero p {
  margin: 0 0 18px;
  color: var(--muted);
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 14px;
}

.hidden {
  display: none;
}

.setup-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  align-items: end;
}

.setup-wide {
  grid-column: 1 / -1;
}

label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 14px;
}

.inline-label {
  flex-direction: row;
  align-items: center;
  gap: 8px;
}

.source-wrap {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
}

.source-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
  font-size: 14px;
  font-weight: 600;
}

.source-actions {
  display: flex;
  gap: 8px;
}

.source-actions button {
  padding: 6px 10px;
  font-size: 12px;
}

.source-selector {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 8px;
}

.source-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fafcff;
  font-size: 13px;
}

.hint-inline {
  margin-top: 8px;
  font-size: 12px;
  color: var(--muted);
}

input[type="number"],
select {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 14px;
}

button {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 14px;
  background: #f7f9fd;
  cursor: pointer;
}

button:hover {
  border-color: #b8c2d8;
}

#startBtn,
#newAttemptBtn {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.danger {
  color: #fff;
  background: var(--danger);
  border-color: var(--danger);
}

.hint {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 13px;
}

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

.history-actions {
  display: flex;
  gap: 8px;
}

.empty {
  color: var(--muted);
  font-size: 14px;
}

.table-wrap {
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

th,
td {
  border-bottom: 1px solid var(--line);
  text-align: left;
  padding: 8px;
}

.exam-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.timer {
  font-weight: 600;
}

.timer.warning {
  color: var(--warning);
}

.timer.danger {
  color: var(--danger);
}

.exam-layout {
  display: grid;
  grid-template-columns: 250px 1fr;
  gap: 16px;
}

.palette {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  margin-bottom: 12px;
}

.palette button {
  padding: 6px 0;
  font-size: 13px;
}

.palette .current {
  border-color: var(--primary);
  background: #eaf1ff;
}

.palette .answered {
  background: #e8f7ee;
  border-color: #a5d8b6;
}

.palette .consulted {
  box-shadow: inset 0 0 0 2px #ffc26b;
}

.case-box {
  border: 1px dashed #9cb5e8;
  background: #f4f8ff;
  border-radius: 8px;
  padding: 10px;
  margin-bottom: 10px;
}

.question-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}

.badge {
  border: 1px solid #bdd0f8;
  background: #ebf2ff;
  color: #1b4db0;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
}

.badge.muted {
  border-color: #d6dbe8;
  background: #f4f6fb;
  color: #495066;
}

.badge.warning {
  border-color: #ffd49c;
  background: #fff6e8;
  color: var(--warning);
}

.badge.info {
  border-color: #b3e5fc;
  background: #edf9ff;
  color: #0f4f71;
}

.source-link {
  text-decoration: none;
}

.source-link:hover {
  text-decoration: underline;
}

.options {
  display: grid;
  gap: 8px;
  margin: 12px 0;
}

.option {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  gap: 8px;
}

.option input[type="radio"] {
  margin-top: 3px;
}

.question-actions {
  display: flex;
  gap: 8px;
  margin: 8px 0 14px;
}

.assist {
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

.assist h4 {
  margin: 0 0 8px;
}

.assist-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.assist-output {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  min-height: 54px;
  font-size: 14px;
  white-space: pre-wrap;
}

.result-headline {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 6px;
}

.result-meta {
  color: var(--muted);
  margin-bottom: 12px;
}

#reviewList {
  padding-left: 20px;
}

@media (max-width: 900px) {
  .exam-layout {
    grid-template-columns: 1fr;
  }
}
