:root {
  --bg: #f5f7fa;
  --surface: #ffffff;
  --border: #d7dde6;
  --text: #152232;
  --muted: #5f6f82;
  --primary: #0f6c5f;
  --primary-hover: #0a584d;
  --danger: #a12a2a;
  --danger-hover: #842222;
  --ok: #dbf5de;
  --ok-text: #1f6f31;
  --bad: #ffe5e5;
  --bad-text: #8e2222;
  --hint: #e5efff;
  --hint-text: #194a99;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", Tahoma, sans-serif;
  color: var(--text);
  background: linear-gradient(180deg, #eef2f7 0%, var(--bg) 100%);
}

.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  min-height: 78px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 18px;
  z-index: 10;
}

.topbar-left h1 {
  margin: 0;
  font-size: 1.3rem;
}

.topbar-left p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.timer {
  padding: 6px 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
  font-weight: 600;
  background: #f0f3f8;
}

.container {
  max-width: 1060px;
  margin: 96px auto 18px;
  padding: 0 14px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px;
  box-shadow: 0 2px 10px rgba(33, 50, 72, 0.05);
}

.page-questions {
  margin-top: 14px;
  display: grid;
  gap: 16px;
}

.question-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  background: #fbfcfe;
}

.question-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.question-card-head h3 {
  margin: 0;
  font-size: 1.05rem;
}

.question-card-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 240px;
  gap: 18px;
}

.question-card-body.no-image {
  grid-template-columns: 1fr;
}

.question-content {
  min-width: 0;
}

.question-theme {
  margin: 0 0 6px;
  font-size: 0.82rem;
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.question-description {
  margin: 0 0 12px;
  color: var(--muted);
  line-height: 1.45;
}

.hidden {
  display: none !important;
}

.btn {
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 8px 12px;
  cursor: pointer;
  font-weight: 600;
}

.btn:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.btn.primary {
  background: var(--primary);
  color: #fff;
}

.btn.primary:hover:not(:disabled) {
  background: var(--primary-hover);
}

.btn.secondary {
  background: #f4f6fb;
  border-color: var(--border);
  color: var(--text);
}

.btn.secondary:hover:not(:disabled) {
  background: #e9edf5;
}

.btn.danger {
  background: var(--danger);
  color: #fff;
}

.btn.danger:hover:not(:disabled) {
  background: var(--danger-hover);
}

.setup-grid {
  display: grid;
  grid-template-columns: minmax(220px, 300px) 1fr;
  gap: 14px;
}

.options-grid {
  margin-top: 14px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
}

.options-grid label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.95rem;
}

.options-grid input,
.options-grid select,
.setup-grid select {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px;
  font-size: 0.95rem;
}

.check-row {
  flex-direction: row !important;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  background: #f9fbfd;
}

.setup-actions {
  margin-top: 18px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.link-btn {
  margin-top: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--primary);
  font-weight: 600;
  text-decoration: underline;
  cursor: pointer;
}

.link-btn:hover {
  color: var(--primary-hover);
}

.question-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.question-text {
  margin: 0 0 14px;
  font-size: 1.1rem;
  line-height: 1.5;
}

.answers {
  display: grid;
  gap: 10px;
}

.answer-item {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  background: #fff;
}

.question-image-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.image-thumb {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0;
  width: 220px;
  height: 220px;
  overflow: hidden;
  background: #f3f5fa;
  cursor: pointer;
}

.image-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.image-label {
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.9rem;
}

.summary {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  background: #f7f9fc;
}

.filter-row {
  margin: 14px 0;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.filter-btn.active {
  border-color: #365ea8;
  box-shadow: 0 0 0 2px rgba(54, 94, 168, 0.15);
}

.review-list {
  display: grid;
  gap: 12px;
}

.review-item {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
}

.review-item.success {
  border-left: 6px solid #2d8a44;
}

.review-item.blank {
  border-left: 6px solid #74839a;
}

.review-item.failed {
  border-left: 6px solid #b53a3a;
}

.review-answer {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px;
  margin-top: 6px;
}

.review-explanation {
  margin: 8px 0 0;
  font-style: italic;
}

.review-correct-green {
  background: var(--ok);
  color: var(--ok-text);
  border-color: #b4dfbb;
}

.review-wrong-red {
  background: var(--bad);
  color: var(--bad-text);
  border-color: #f3bcbc;
}

.review-correct-blue {
  background: var(--hint);
  color: var(--hint-text);
  border-color: #c6d9fd;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(20, 30, 44, 0.68);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 40;
}

.modal-panel {
  background: #fff;
  border-radius: 10px;
  width: min(860px, 100%);
  max-height: 92vh;
  overflow: auto;
  border: 1px solid #c9d1dd;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px;
  border-bottom: 1px solid #dce2ec;
  position: sticky;
  top: 0;
  background: #fff;
}

.modal-panel img {
  width: 100%;
  height: auto;
  display: block;
}

@media (max-width: 900px) {
  .topbar {
    height: auto;
    min-height: 78px;
    align-items: flex-start;
    gap: 10px;
    flex-direction: column;
  }

  .container {
    margin-top: 150px;
  }

  .setup-grid {
    grid-template-columns: 1fr;
  }

  .question-card-body {
    grid-template-columns: 1fr;
  }

  .question-image-panel {
    align-items: flex-start;
  }
}
