* { box-sizing: border-box; }
:root {
  color-scheme: light;
  --ink: #17212b;
  --muted: #607080;
  --line: #d8e0e8;
  --paper: #ffffff;
  --page: #eef3f6;
  --accent: #0f766e;
  --accent-dark: #0a5c56;
  --soft: #e7f3f1;
  --danger: #b42318;
  --good: #1f7a3f;
  --warn: #a15c07;
}
body {
  margin: 0;
  min-height: 100vh;
  font-family: Arial, sans-serif;
  background: var(--page);
  color: var(--ink);
}
.layout {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 300px 1fr;
}
.sidebar {
  border-right: 1px solid var(--line);
  background: #fbfcfd;
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}
.brand-mark {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  border-radius: 8px;
  background: #12343b;
  color: #fff;
  font-size: 28px;
  font-weight: 900;
}
.brand p, .brand h1 {
  margin: 0;
}
.brand p {
  color: var(--muted);
  font-weight: 700;
}
.brand h1 {
  font-size: 30px;
}
.sidebar-section {
  min-height: 0;
}
.section-label, .eyebrow {
  margin: 0 0 10px;
  color: var(--accent-dark);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}
.topic-list {
  display: grid;
  gap: 10px;
}
.category-title {
  margin: 14px 0 0;
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}
.category-title:first-child {
  margin-top: 0;
}
.topic-btn {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 12px;
  text-align: left;
  cursor: pointer;
}
.topic-btn.active {
  border-color: var(--accent);
  background: var(--soft);
}
.topic-btn strong, .topic-btn span {
  display: block;
}
.topic-btn span {
  margin-top: 5px;
  color: var(--muted);
  font-size: 13px;
}
.compact-field {
  margin-top: 24px;
}
.field select {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: #fff;
  color: var(--ink);
  font: inherit;
}
.main {
  padding: 28px;
}
.panel {
  width: min(1100px, 100%);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 18px 50px rgba(24, 43, 61, 0.10);
  padding: clamp(22px, 4vw, 38px);
}
.hidden { display: none; }
h2 {
  margin: 0;
  line-height: 1.14;
  font-size: clamp(26px, 3vw, 40px);
}
#question-text {
  max-width: 860px;
  font-size: clamp(26px, 2.3vw, 34px);
  line-height: 1.24;
  text-align: left;
  word-spacing: 0;
  letter-spacing: 0;
}
.lead {
  max-width: 760px;
  color: var(--muted);
  font-size: 18px;
  line-height: 1.55;
}
.muted {
  color: var(--muted);
  line-height: 1.5;
}
.topic-header, .quiz-header, .result-header, .quiz-footer, .result-actions, .dialog-actions {
  display: flex;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
}
.topic-actions, .result-actions {
  flex-wrap: wrap;
}
.summary-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 26px;
}
.summary-grid div {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafb;
  padding: 16px;
}
.summary-grid strong {
  display: block;
  font-size: 28px;
}
.summary-grid span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
}
.history-panel {
  margin-top: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafb;
  padding: 16px;
}
.attempt-history {
  display: grid;
  gap: 8px;
}
.attempt-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 10px 12px;
  color: var(--muted);
  font-weight: 800;
}
.attempt-row strong {
  color: var(--ink);
}
.random-panel {
  margin-top: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafb;
  padding: 18px;
}
.random-panel h3 {
  margin: 0;
  font-size: 24px;
}
.check-list {
  display: grid;
  gap: 8px;
  margin: 16px 0;
}
.check-item {
  display: flex;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 10px 12px;
  color: var(--ink);
  font-weight: 800;
}
.check-item input {
  width: 18px;
  height: 18px;
}
button {
  min-height: 46px;
  border: 0;
  border-radius: 8px;
  padding: 0 18px;
  font-weight: 400;
  cursor: pointer;
}
.full-btn {
  width: 100%;
}
.primary-btn {
  background: var(--accent);
  color: white;
}
.primary-btn:hover {
  background: var(--accent-dark);
}
.primary-btn:disabled {
  background: #aab8c2;
  cursor: not-allowed;
}
.secondary-btn {
  background: #e8edf2;
  color: var(--ink);
}
.secondary-btn:hover {
  background: #dbe4ea;
}
.danger {
  color: var(--danger);
}
.score-chip, .result-badge {
  flex: 0 0 auto;
  border-radius: 8px;
  background: var(--soft);
  color: var(--accent-dark);
  font-weight: 900;
  padding: 12px 14px;
}
.quiz-metrics {
  display: flex;
  gap: 10px;
  align-items: center;
}
.progress-track {
  height: 10px;
  margin: 22px 0;
  border-radius: 999px;
  background: #e2e8ee;
  overflow: hidden;
}
#progress-bar {
  height: 100%;
  width: 0;
  background: var(--accent);
  transition: width .2s ease;
}
.option-list {
  display: grid;
  gap: 12px;
  margin: 24px 0;
}
.option-btn {
  width: 100%;
  display: grid;
  grid-template-columns: 30px 1fr;
  gap: 12px;
  align-items: center;
  min-height: 64px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  text-align: left;
  padding: 14px;
  font-family: Arial, sans-serif;
  font-size: 15px;
  line-height: 1.42;
}
.option-btn:hover {
  border-color: var(--accent);
  background: #f6fbfa;
}
.option-btn.selected {
  border-color: var(--accent);
  background: var(--soft);
  box-shadow: inset 0 0 0 1px var(--accent);
}
.option-letter {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: #e7edf2;
  color: var(--ink);
  font-size: 13px;
  font-weight: 900;
  text-transform: uppercase;
}
.option-text {
  text-align: justify;
  word-spacing: normal;
  letter-spacing: 0;
}
.selected .option-letter {
  background: var(--accent);
  color: white;
}
.doubt-check {
  display: inline-flex;
  gap: 10px;
  align-items: center;
  margin: 0 0 18px;
  color: var(--warn);
  font-weight: 900;
}
.doubt-check input {
  width: 18px;
  height: 18px;
}
.mistake-list {
  display: grid;
  gap: 14px;
  margin-top: 24px;
}
.mistake-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
  padding: 16px;
}
.result-option-list {
  display: grid;
  gap: 8px;
  margin: 12px 0;
}
.result-option {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  line-height: 1.45;
  text-align: justify;
}
.result-option.correct {
  border-color: #8ac79d;
  background: #e8f6ec;
  color: #14532d;
}
.result-option.wrong {
  border-color: #ef9a9a;
  background: #fdeaea;
  color: #7f1d1d;
}
.result-option.picked {
  font-weight: 900;
}
.mistake-card h3 {
  margin: 0 0 10px;
  font-size: 20px;
  line-height: 1.3;
  text-align: left;
}
.answer-line {
  margin: 8px 0;
  color: var(--muted);
  line-height: 1.45;
}
.answer-line strong {
  color: var(--ink);
}
.law-reference {
  margin-top: 12px;
  border-left: 4px solid var(--accent);
  background: var(--soft);
  padding: 12px;
  border-radius: 0 8px 8px 0;
  line-height: 1.45;
}
.law-reference a {
  color: var(--accent-dark);
  font-weight: 900;
}
.topic-dialog {
  width: min(720px, calc(100% - 24px));
  border: 0;
  border-radius: 8px;
  padding: 0;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.22);
}
.topic-dialog::backdrop {
  background: rgba(16, 28, 39, 0.45);
}
.dialog-card {
  display: grid;
  gap: 16px;
  padding: 24px;
}
.field {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-weight: 900;
}
.field input {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: #fff;
  color: var(--ink);
  font: inherit;
}
.import-status {
  min-height: 24px;
  margin: 0;
  color: var(--muted);
  font-weight: 800;
}
.import-status.error {
  color: var(--danger);
}
.import-status.ok {
  color: var(--good);
}
@media (max-width: 860px) {
  .layout {
    grid-template-columns: 1fr;
  }
  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .main {
    padding: 14px;
  }
  .topic-header, .quiz-header, .result-header, .quiz-footer, .dialog-actions {
    align-items: stretch;
    flex-direction: column;
  }
  .quiz-metrics, .attempt-row {
    grid-template-columns: 1fr;
    align-items: stretch;
  }
  .summary-grid {
    grid-template-columns: 1fr;
  }
  button {
    width: 100%;
  }
}
