:root {
  --bg: #f5f7f8;
  --surface: #ffffff;
  --surface-2: #eef4f2;
  --text: #182326;
  --muted: #647174;
  --line: #d7e0e2;
  --accent: #176b5d;
  --accent-strong: #0f4f45;
  --bad: #a63f3f;
  --good: #1d7654;
  --warn: #8a6219;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
  letter-spacing: 0;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

a {
  color: inherit;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 12;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 82px;
  padding: 18px clamp(16px, 4vw, 48px);
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
}

.support-open-button {
  position: absolute;
  z-index: 13;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  min-height: 42px;
  border: 1px solid rgba(23, 107, 93, 0.35);
  border-radius: 999px;
  padding: 9px 18px;
  background: #e8f7ef;
  color: var(--accent-strong);
  font-weight: 800;
  box-shadow: 0 6px 18px rgba(24, 35, 38, 0.08);
  white-space: nowrap;
}

.support-open-button:hover {
  background: #d8f0e5;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(24px, 3vw, 34px);
  line-height: 1.1;
}

h2 {
  font-size: 21px;
  line-height: 1.25;
}

.topbar p {
  margin-top: 6px;
  color: var(--muted);
}

#datasetInfo {
  display: none;
}

.profile {
  display: grid;
  gap: 6px;
  min-width: 220px;
}

.profile label {
  color: var(--muted);
  font-size: 13px;
}

.profile input {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  background: var(--surface);
}

.page-shell {
  display: grid;
  grid-template-columns: minmax(130px, 190px) minmax(0, 1120px);
  gap: 16px;
  width: min(1340px, calc(100% - 24px));
  margin: 28px auto 48px;
  align-items: start;
}

.app-ad-panel {
  position: sticky;
  top: 104px;
}

.app-ad-panel a {
  display: block;
  max-width: 190px;
  height: 650px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
  box-shadow: 0 8px 22px rgba(24, 35, 38, 0.08);
}

.app-ad-panel a:hover {
  border-color: rgba(23, 107, 93, 0.5);
}

.app-ad-panel img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top center;
}

main {
  min-width: 0;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}

.metric,
.panel,
.question-panel,
.summary {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.metric {
  min-height: 94px;
  padding: 18px;
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 14px;
}

.metric strong {
  display: block;
  margin-top: 8px;
  font-size: 32px;
  line-height: 1;
}

.panel {
  margin-top: 16px;
  padding: 22px;
}

.panel h2 {
  margin-bottom: 14px;
}

.mode-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.browse-tools {
  display: grid;
  grid-template-columns: minmax(160px, 220px) minmax(220px, 1fr) minmax(220px, 1fr);
  gap: 14px;
  margin-bottom: 14px;
}

.browse-field {
  display: grid;
  gap: 6px;
}

.browse-field label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.inline-search {
  display: flex;
  gap: 8px;
}

.inline-search input {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px 11px;
  background: #fff;
}

.browse-results {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.browse-result {
  display: grid;
  gap: 4px;
  width: 100%;
  min-height: 58px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 12px;
  background: #fff;
  color: var(--text);
  text-align: left;
  font-weight: 400;
}

.browse-result:hover {
  background: var(--surface-2);
}

.browse-result strong {
  font-size: 14px;
}

.browse-result span {
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.browse-result small {
  color: var(--muted);
  line-height: 1.35;
}

.size-button,
.primary-button,
.secondary-button,
.primary-link,
.secondary-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  border-radius: 6px;
  padding: 10px 16px;
  border: 1px solid transparent;
  font-weight: 700;
  text-decoration: none;
}

.size-button,
.primary-button,
.primary-link {
  background: var(--accent);
  color: #fff;
}

.size-button:hover,
.primary-button:hover,
.primary-link:hover {
  background: var(--accent-strong);
}

.secondary-button,
.secondary-link {
  background: #fff;
  color: var(--text);
  border-color: var(--line);
}

.secondary-button:hover,
.secondary-link:hover {
  background: var(--surface-2);
}

.session-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.session-head div {
  display: grid;
  justify-items: end;
  gap: 3px;
  color: var(--muted);
}

.session-head strong {
  color: var(--text);
}

.learning-score {
  position: sticky;
  top: 83px;
  z-index: 8;
  margin-bottom: 14px;
  border: 1px solid #d2c28b;
  border-radius: 8px;
  padding: 12px 14px;
  background: #fff8df;
  color: var(--warn);
  font-weight: 700;
}

.question-panel {
  padding: clamp(18px, 3vw, 30px);
}

.question-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 14px;
  margin-bottom: 12px;
}

#questionText {
  margin-bottom: 18px;
  font-size: clamp(22px, 2.4vw, 30px);
  line-height: 1.25;
}

.question-note-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  width: auto;
  margin: -6px 0 16px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  background: #fff;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.question-note-toggle input {
  width: 18px;
  height: 18px;
  margin: 0;
}

.image-strip {
  display: grid;
  gap: 10px;
  margin-bottom: 16px;
}

.question-image,
.answer-image {
  display: block;
  max-width: min(100%, 620px);
  height: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

.answers {
  display: grid;
  gap: 10px;
}

.answer {
  display: grid;
  grid-template-columns: 26px 1fr;
  gap: 12px;
  align-items: start;
  min-height: 56px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.answer input {
  width: 20px;
  height: 20px;
  margin-top: 2px;
}

.answer-body {
  display: grid;
  gap: 8px;
}

.answer-key {
  font-weight: 700;
}

.legal-basis {
  display: grid;
  gap: 8px;
  margin-top: 16px;
  border: 1px solid #cfded7;
  border-radius: 8px;
  padding: 14px;
  background: #f4faf7;
  color: var(--text);
}

.legal-basis.warning {
  border-color: #dfc171;
  background: #fff8df;
}

.legal-basis h3 {
  margin: 0;
  font-size: 16px;
}

.legal-basis p {
  margin: 0;
  white-space: pre-wrap;
  line-height: 1.45;
}

.legal-basis small {
  color: var(--muted);
  line-height: 1.35;
}

.answer.correct {
  border-color: rgba(29, 118, 84, 0.65);
  background: #ecf8f2;
}

.answer.wrong {
  border-color: rgba(166, 63, 63, 0.6);
  background: #fff0f0;
}

.feedback {
  margin-top: 16px;
  border-radius: 8px;
  padding: 12px 14px;
  font-weight: 700;
}

.feedback.good {
  background: #e8f7ef;
  color: var(--good);
}

.feedback.bad {
  background: #fff0f0;
  color: var(--bad);
}

.actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
}

.summary {
  padding: clamp(18px, 3vw, 30px);
}

.summary-score {
  display: grid;
  gap: 6px;
  margin: 18px 0;
  padding: 18px;
  border-radius: 8px;
  background: var(--surface-2);
}

.summary-score strong {
  font-size: 40px;
  line-height: 1;
}

.summary-list {
  display: grid;
  gap: 8px;
  margin-bottom: 18px;
}

.summary-item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

.summary-item span:first-child {
  overflow-wrap: anywhere;
}

.ok {
  color: var(--good);
}

.fail {
  color: var(--bad);
}

.hidden {
  display: none !important;
}

.support-popup {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(24, 35, 38, 0.55);
}

.support-popup-card {
  position: relative;
  width: min(1180px, calc(100vw - 48px));
  aspect-ratio: 2048 / 768;
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 20px 60px rgba(24, 35, 38, 0.28);
}

.support-popup-close {
  position: absolute;
  top: -16px;
  right: -16px;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border: 2px solid #fff;
  border-radius: 50%;
  background: #102f49;
  color: #fff;
  font-size: 34px;
  font-weight: 700;
  line-height: 1;
  box-shadow: 0 8px 22px rgba(24, 35, 38, 0.28);
}

.support-popup-close:hover {
  background: #0b2236;
}

.support-popup-media {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  border-radius: 18px;
}

.support-popup-media img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.support-donation-link {
  position: absolute;
  right: 5.2%;
  top: 28.5%;
  display: grid;
  place-items: center;
  width: 15.8%;
  aspect-ratio: 1 / 1;
  border-radius: 10px;
  padding: 12px;
  background: #d51847;
  color: #fff;
  font-size: clamp(14px, 1.5vw, 22px);
  font-weight: 800;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
  box-shadow: 0 10px 22px rgba(97, 35, 48, 0.22);
}

.support-donation-link:hover {
  background: #bd123e;
}

@media (max-width: 760px) {
  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .support-open-button {
    position: static;
    transform: none;
    align-self: center;
  }

  .page-shell {
    grid-template-columns: minmax(86px, 116px) minmax(0, 1fr);
    gap: 10px;
    margin-top: 18px;
    width: min(100% - 12px, 760px);
  }

  .app-ad-panel {
    position: static;
  }

  .app-ad-panel a {
    width: 100%;
    max-width: 116px;
    height: 650px;
    margin: 0;
  }

  .profile {
    min-width: 0;
  }

  .stats-grid {
    grid-template-columns: 1fr;
  }

  .browse-tools,
  .inline-search {
    grid-template-columns: 1fr;
  }

  .inline-search {
    display: grid;
  }

  .session-head {
    align-items: stretch;
    flex-direction: column;
  }

  .session-head div {
    justify-items: start;
  }

  .summary-item {
    flex-direction: column;
  }

  .support-popup-card {
    width: min(96vw, 520px);
    min-height: 190px;
  }

  .support-donation-link {
    right: 5%;
    top: 28%;
    width: 17%;
    padding: 8px;
    font-size: 12px;
  }

  .support-popup-close {
    top: -12px;
    right: -8px;
  }
}
