:root {
  color-scheme: light;
  --bg: #f4f6f2;
  --ink: #16201c;
  --muted: #64716b;
  --soft: #f8faf7;
  --surface: #ffffff;
  --line: #dbe3dc;
  --line-strong: #b9c7be;
  --primary: #0f6b5d;
  --primary-strong: #09483f;
  --primary-soft: #e4f3ef;
  --gold: #a76516;
  --gold-soft: #fff4df;
  --blue: #285f92;
  --blue-soft: #e8f1fb;
  --danger: #b42318;
  --danger-soft: #fff1f0;
  --ok: #247345;
  --ok-soft: #edf8f0;
  --shadow: 0 18px 42px rgba(32, 45, 38, 0.1);
  --shadow-soft: 0 8px 24px rgba(32, 45, 38, 0.08);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(15, 107, 93, 0.08), transparent 280px),
    repeating-linear-gradient(90deg, rgba(22, 32, 28, 0.025) 0 1px, transparent 1px 74px),
    var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
}

button,
input {
  font: inherit;
}

button {
  border: 0;
}

h1,
h2,
p {
  margin: 0;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: center;
  padding: 18px clamp(16px, 4vw, 48px);
  border-bottom: 1px solid rgba(219, 227, 220, 0.92);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(18px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.brand-mark {
  display: grid;
  place-items: center;
  flex: 0 0 48px;
  width: 48px;
  height: 48px;
  border-radius: var(--radius);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.18), transparent 45%),
    var(--primary);
  color: #fff;
  font-weight: 900;
  box-shadow: 0 12px 26px rgba(15, 107, 93, 0.22);
  position: relative;
  overflow: hidden;
}

.brand-mark::after {
  content: "";
  position: absolute;
  width: 34px;
  height: 3px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.5);
  bottom: 11px;
}

.brand-mark span {
  position: relative;
  z-index: 1;
}

h1 {
  font-size: clamp(19px, 2vw, 28px);
  line-height: 1.12;
  letter-spacing: 0;
  font-weight: 750;
}

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

.stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(86px, 1fr));
  gap: 10px;
}

.stats span,
.exam-meta span {
  display: grid;
  gap: 3px;
  min-width: 96px;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(248, 250, 247, 0.92);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.75);
}

.stats strong {
  font-size: 23px;
  line-height: 1;
}

small {
  color: var(--muted);
  font-size: 12px;
}

.layout {
  display: grid;
  grid-template-columns: minmax(250px, 310px) minmax(0, 1fr);
  gap: 22px;
  max-width: 1460px;
  margin: 0 auto;
  padding: 22px clamp(16px, 4vw, 48px) 42px;
}

.sidebar,
.workspace {
  min-width: 0;
}

.sidebar {
  position: sticky;
  top: 104px;
  align-self: start;
}

.panel,
.toolbar,
.question-card,
.result-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.97);
  box-shadow: var(--shadow);
}

.panel {
  padding: 15px;
  margin-bottom: 14px;
}

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

.panel h2 {
  font-size: 13px;
  color: var(--muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.mode-grid,
.category-list {
  display: grid;
  gap: 8px;
}

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--soft);
}

.category-list {
  max-height: calc(100vh - 420px);
  min-height: 120px;
  overflow: auto;
  padding-right: 2px;
}

button {
  border-radius: var(--radius);
  cursor: pointer;
  min-height: 42px;
  transition:
    background-color 0.16s ease,
    border-color 0.16s ease,
    color 0.16s ease,
    transform 0.16s ease,
    box-shadow 0.16s ease;
}

.segment,
.mode,
.category,
.option,
.secondary {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
}

.segment,
.mode,
.category {
  width: 100%;
  padding: 10px 12px;
  text-align: left;
}

.segment {
  text-align: center;
  min-height: 38px;
  font-weight: 800;
}

.mode {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 750;
}

.mode::after {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: var(--line-strong);
}

.category {
  color: #293733;
}

.segment:hover,
.mode:hover,
.category:hover,
.secondary:hover {
  border-color: var(--line-strong);
  background: var(--soft);
}

.segment.active,
.mode.active,
.category.active {
  border-color: rgba(15, 107, 93, 0.38);
  background: var(--primary-soft);
  color: var(--primary-strong);
  font-weight: 800;
}

.mode.active::after {
  background: var(--primary);
  box-shadow: 0 0 0 4px rgba(15, 107, 93, 0.12);
}

.secondary.active {
  border-color: rgba(167, 101, 22, 0.45);
  background: var(--gold-soft);
  color: var(--gold);
}

.full-width {
  width: 100%;
}

.compact-panel {
  box-shadow: var(--shadow-soft);
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 17px 18px;
  margin-bottom: 16px;
}

#modeLabel {
  display: inline-flex;
  color: var(--primary);
  font-size: 13px;
  font-weight: 850;
  margin-bottom: 5px;
}

#categoryLabel {
  display: block;
  font-size: clamp(21px, 2vw, 27px);
  line-height: 1.18;
}

.progress-track {
  width: min(360px, 52vw);
  height: 7px;
  margin-top: 12px;
  border-radius: 999px;
  background: #e8eee9;
  overflow: hidden;
}

.progress-track span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--primary), var(--blue));
  transition: width 0.2s ease;
}

.exam-meta {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.question-bank-pill {
  align-self: center;
  padding: 5px 9px;
  border: 1px solid #d8e4df;
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
}

.exam-meta b {
  font-size: 18px;
  line-height: 1.1;
}

.question-card {
  min-height: 500px;
  padding: clamp(20px, 3vw, 38px);
}

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

.question-header span {
  min-width: 0;
}

.question-header span:first-child {
  display: inline-flex;
  align-items: center;
  border: 1px solid #cddfd8;
  border-radius: 999px;
  padding: 6px 11px;
  background: var(--primary-soft);
  color: var(--primary-strong);
  font-weight: 800;
}

.question-header span:last-child {
  font-variant-numeric: tabular-nums;
  font-weight: 800;
}

.question-tools {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  flex: 0 0 auto;
  gap: 10px;
}

.listen-btn {
  min-height: 34px;
  padding: 7px 11px;
  border: 1px solid rgba(36, 95, 145, 0.3);
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 13px;
  font-weight: 750;
  white-space: nowrap;
}

.listen-btn:hover {
  border-color: rgba(36, 95, 145, 0.48);
  background: #dceaf6;
}

.audio-mode-note {
  max-width: 980px;
  margin: -6px 0 16px;
  padding: 10px 12px;
  border: 1px solid rgba(36, 95, 145, 0.22);
  border-radius: var(--radius);
  background: var(--accent-soft);
  color: #28577e;
  line-height: 1.45;
  font-size: 13px;
  font-weight: 650;
}

.question-text {
  max-width: 980px;
  font-size: clamp(23px, 2.3vw, 33px);
  line-height: 1.34;
  margin-bottom: 24px;
}

.question-image {
  margin: 0 0 22px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    linear-gradient(135deg, rgba(40, 95, 146, 0.08), transparent 40%),
    #fbfcfd;
}

.question-image img {
  display: block;
  width: 100%;
  max-height: 360px;
  object-fit: contain;
}

.options {
  display: grid;
  gap: 12px;
}

.option {
  width: 100%;
  display: flex;
  gap: 13px;
  align-items: flex-start;
  padding: 15px;
  text-align: left;
  box-shadow: none;
  line-height: 1.55;
}

.option:hover {
  border-color: var(--primary);
  background: #fbfefd;
  transform: translateY(-1px);
}

.option.selected {
  border-color: var(--primary);
  background: var(--primary-soft);
  box-shadow: 0 10px 24px rgba(15, 107, 93, 0.12);
}

.option.correct {
  border-color: var(--ok);
  background: var(--ok-soft);
}

.option.wrong {
  border-color: var(--danger);
  background: var(--danger-soft);
}

.option-key {
  display: inline-grid;
  place-items: center;
  flex: 0 0 31px;
  width: 31px;
  height: 31px;
  border-radius: var(--radius);
  background: #edf2ee;
  color: var(--primary-strong);
  font-weight: 900;
}

.option.selected .option-key,
.option.correct .option-key {
  background: var(--primary);
  color: #fff;
}

.option.wrong .option-key {
  background: var(--danger);
  color: #fff;
}

.explanation {
  margin-top: 18px;
  padding: 15px 16px;
  border: 1px solid rgba(167, 101, 22, 0.3);
  border-left: 4px solid var(--gold);
  border-radius: var(--radius);
  background: var(--gold-soft);
  color: var(--ink);
  line-height: 1.65;
}

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

.actions button {
  padding: 11px 18px;
  font-weight: 850;
}

#checkBtn {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 12px 26px rgba(15, 107, 93, 0.24);
}

#checkBtn:hover {
  background: var(--primary-strong);
  transform: translateY(-1px);
}

.secondary {
  padding-inline: 16px;
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

button:focus-visible {
  outline: 3px solid rgba(40, 95, 146, 0.24);
  outline-offset: 2px;
}

.result-panel {
  margin-top: 16px;
  padding: 18px;
  border-color: rgba(40, 95, 146, 0.28);
}

.result-panel h2 {
  margin-bottom: 8px;
}

.result-panel p {
  color: var(--muted);
  line-height: 1.6;
}

.hidden {
  display: none;
}

.is-hidden {
  display: none !important;
}

.site-shell {
  min-height: 100vh;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 30;
  border-bottom: 1px solid rgba(219, 227, 220, 0.92);
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(18px);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 13px clamp(14px, 4vw, 36px);
}

.brand {
  color: inherit;
  text-decoration: none;
}

.brand-name,
.brand-sub {
  display: block;
}

.brand-name {
  font-size: 17px;
  font-weight: 760;
  line-height: 1.15;
}

.brand-sub {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.site-header .brand-mark {
  flex-basis: 40px;
  width: 40px;
  height: 40px;
  font-size: 18px;
  font-weight: 760;
}

.nav {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  flex-wrap: wrap;
  min-width: 0;
}

.nav a,
.lang-btn,
.btn {
  min-height: 36px;
  border-radius: var(--radius);
  text-decoration: none;
  font-size: 14px;
  font-weight: 680;
}

.nav a {
  display: inline-flex;
  align-items: center;
  padding: 8px 10px;
  color: var(--muted);
}

.nav a.active,
.nav a:hover {
  background: var(--primary-soft);
  color: var(--primary-strong);
}

.lang-toggle {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, auto));
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--soft);
}

.lang-btn {
  min-width: 58px;
  min-height: 32px;
  padding: 6px 9px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  white-space: nowrap;
}

.lang-btn.active {
  border-color: rgba(15, 107, 93, 0.32);
  background: #fff;
  color: var(--primary-strong);
  box-shadow: var(--shadow-soft);
}

.main {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 26px clamp(14px, 4vw, 36px) 46px;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 24px;
  align-items: stretch;
  padding: 34px 0 26px;
}

.eyebrow {
  display: inline-flex;
  margin-bottom: 10px;
  color: var(--primary);
  font-size: 13px;
  font-weight: 760;
}

.hero h1,
.content-page > h1 {
  max-width: 860px;
  font-size: clamp(30px, 5vw, 58px);
  line-height: 1.02;
  font-weight: 760;
}

.hero-copy,
.page-intro,
.section-intro,
.content-block p,
.card p,
.trust-note,
.disclaimer-small {
  color: var(--muted);
  line-height: 1.62;
}

.hero-copy {
  max-width: 680px;
  margin-top: 14px;
  font-size: 18px;
}

.hero-actions,
.card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 20px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 9px 13px;
  border: 1px solid var(--line);
  color: var(--ink);
  background: #fff;
}

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

.btn.secondary:hover,
.btn.primary:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-soft);
}

.hero-panel,
.card,
.content-block,
.term-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow-soft);
}

.hero-panel {
  display: grid;
  align-content: center;
  gap: 14px;
  padding: 18px;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.stat {
  padding: 13px;
  border-radius: var(--radius);
  background: var(--soft);
}

.stat strong,
.stat span {
  display: block;
}

.stat strong {
  font-size: 22px;
  line-height: 1;
}

.stat span {
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
}

.section,
.content-page {
  margin-top: 26px;
}

.section-head {
  margin-bottom: 14px;
}

.section h2,
.content-block h2 {
  font-size: clamp(20px, 2.4vw, 28px);
  line-height: 1.18;
  font-weight: 740;
}

.feature-grid,
.country-grid,
.term-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.two-col {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.card,
.content-block,
.term-card {
  padding: 18px;
}

.card h3,
.term-card strong {
  margin: 0 0 8px;
  font-size: 17px;
  font-weight: 740;
}

.steps {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 9px;
}

.step {
  min-height: 76px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--soft);
  font-weight: 700;
  line-height: 1.35;
}

.app-layout {
  display: grid;
  grid-template-columns: minmax(250px, 310px) minmax(0, 1fr);
  gap: 22px;
}

.site-footer {
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.7);
}

.footer-inner {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 18px clamp(14px, 4vw, 36px);
  color: var(--muted);
  font-size: 13px;
}

.footer-links {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.footer-links a {
  color: inherit;
}

[dir="rtl"] .nav,
[dir="rtl"] .hero-actions,
[dir="rtl"] .card-actions,
[dir="rtl"] .actions {
  direction: rtl;
}

.empty-state {
  display: grid;
  place-items: center;
  min-height: 360px;
  color: var(--muted);
  text-align: center;
}

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

  .stats,
  .exam-meta {
    justify-content: stretch;
  }

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

  .sidebar {
    position: static;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
  }

  .panel {
    margin-bottom: 0;
  }

  .panel:nth-child(3) {
    grid-column: 1 / -1;
  }

  .category-list {
    max-height: 230px;
  }

  .progress-track {
    width: 100%;
  }
}

@media (max-width: 560px) {
  body {
    background: var(--bg);
  }

  .topbar {
    padding: 14px 14px 12px;
  }

  .brand {
    align-items: flex-start;
  }

  .brand-mark {
    width: 40px;
    height: 40px;
    flex-basis: 40px;
  }

  h1 {
    font-size: 20px;
  }

  .topbar p {
    font-size: 13px;
  }

  .stats {
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
  }

  .stats span,
  .exam-meta span {
    min-width: 0;
    padding: 9px 8px;
  }

  .stats strong {
    font-size: 19px;
  }

  .layout {
    padding: 14px 12px 98px;
    gap: 14px;
  }

  .workspace {
    order: 1;
  }

  .sidebar {
    order: 2;
  }

  .toolbar,
  .question-card,
  .panel {
    box-shadow: var(--shadow-soft);
  }

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

  .panel {
    padding: 13px;
  }

  .question-card {
    min-height: 430px;
    padding: 18px;
  }

  .question-header {
    flex-direction: column;
    margin-bottom: 15px;
  }

  .question-text {
    font-size: 22px;
  }

  .option {
    padding: 13px;
  }

  .actions {
    position: sticky;
    bottom: 0;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    padding: 10px 0 calc(10px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.94);
    backdrop-filter: blur(18px);
    z-index: 20;
    margin-top: 12px;
  }

  .actions button {
    min-height: 44px;
    padding: 10px 12px;
  }

  #checkBtn {
    grid-column: 1 / -1;
    order: -1;
  }
}

@media (max-width: 900px) {
  .header-inner {
    align-items: stretch;
    flex-direction: column;
    gap: 10px;
  }

  .nav {
    justify-content: flex-start;
  }

  .lang-toggle {
    order: -1;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    width: 100%;
  }

  .lang-btn {
    min-width: 0;
  }

  .hero,
  .two-col,
  .app-layout {
    grid-template-columns: 1fr;
  }

  .feature-grid,
  .country-grid,
  .term-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .steps {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 560px) {
  body {
    font-size: 14px;
  }

  .header-inner {
    padding: 10px 12px;
  }

  .brand-sub {
    display: none;
  }

  .nav {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    width: 100%;
    min-width: 0;
  }

  .nav a,
  .lang-btn {
    justify-content: center;
    width: 100%;
    min-width: 0;
    min-height: 32px;
    padding: 7px 6px;
    font-size: 12px;
    white-space: normal;
    overflow-wrap: anywhere;
  }

  .nav a {
    flex: 1 1 calc(33.333% - 5px);
  }

  .lang-toggle {
    flex: 0 0 100%;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
    min-width: 0;
  }

  .main {
    padding: 16px 12px 38px;
  }

  .hero {
    gap: 14px;
    padding: 16px 0 10px;
  }

  .hero h1,
  .content-page > h1 {
    font-size: 28px;
    line-height: 1.06;
  }

  .hero-copy {
    font-size: 15px;
  }

  .hero-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .btn {
    width: 100%;
    min-width: 0;
    padding-inline: 8px;
    white-space: normal;
    overflow-wrap: anywhere;
  }

  .feature-grid,
  .country-grid,
  .term-grid,
  .stat-grid,
  .steps {
    grid-template-columns: 1fr;
  }

  .question-text {
    font-size: 20px;
    line-height: 1.38;
  }

  .footer-inner {
    flex-direction: column;
  }
}
