:root {
  --bg: #f5f6f3;
  --surface: #ffffff;
  --surface-strong: #eef2ed;
  --text: #20242a;
  --muted: #67706f;
  --line: #d8ded8;
  --primary: #0c716b;
  --primary-dark: #075650;
  --primary-soft: #dcefed;
  --accent: #b85d3c;
  --success: #2f7d4e;
  --danger: #a43d3d;
  --warning: #9a7617;
  --shadow: 0 14px 40px rgba(32, 36, 42, 0.08);
  --shadow-soft: 0 8px 24px rgba(32, 36, 42, 0.06);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.5;
  text-rendering: optimizeLegibility;
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
select,
input,
textarea {
  border-radius: 8px;
}

button {
  border: 0;
  cursor: pointer;
  transition: background-color 160ms ease, border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

a {
  color: var(--primary-dark);
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
a:focus-visible {
  outline: 3px solid rgba(12, 113, 107, 0.24);
  outline-offset: 2px;
}

code {
  padding: 1px 5px;
  background: rgba(12, 113, 107, 0.09);
  border: 1px solid rgba(12, 113, 107, 0.14);
  border-radius: 6px;
  color: var(--primary-dark);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 0.9em;
}

.noscript-warning {
  padding: 12px 16px;
  background: #fff0ef;
  border-bottom: 1px solid #e4aaa4;
  color: var(--danger);
  font-weight: 750;
  text-align: center;
}

.app-header {
  background: linear-gradient(180deg, #eef6f4 0%, #e8eee9 100%);
  border-bottom: 1px solid var(--line);
}

.header-inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: 28px 20px 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.brand-heading {
  display: flex;
  gap: 12px;
  align-items: center;
}

.brand-icon {
  width: 50px;
  height: 50px;
  flex: 0 0 auto;
  border-radius: 14px;
  box-shadow: 0 10px 22px rgba(7, 86, 80, 0.18);
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 0.82rem;
  font-weight: 800;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 2rem;
  line-height: 1.1;
}

h2 {
  font-size: 1.35rem;
  line-height: 1.25;
}

h3 {
  font-size: 1.02rem;
}

.source-badge {
  max-width: none;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  font-size: 0.92rem;
  box-shadow: var(--shadow-soft);
  white-space: nowrap;
}

.app-shell {
  max-width: 1180px;
  margin: 0 auto;
  padding: 18px 20px 42px;
}

.notice {
  margin-bottom: 14px;
  padding: 12px 14px;
  border: 1px solid #e2c997;
  background: #fff8e8;
  border-radius: 8px;
  color: #5b4520;
}

.privacy-notice {
  margin-bottom: 16px;
  padding: 12px 14px;
  border: 1px solid #b8d8d5;
  background: #eef8f6;
  border-radius: 8px;
  color: #264c4a;
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.tab-button,
.secondary-button,
.primary-button,
.danger-button {
  min-height: 40px;
  padding: 9px 13px;
  font-weight: 750;
}

.tab-button {
  color: var(--muted);
  background: transparent;
  border: 1px solid transparent;
}

.tab-button.is-active {
  color: var(--primary-dark);
  background: var(--surface);
  border-color: var(--line);
  box-shadow: var(--shadow);
}

.tab-button:hover,
.secondary-button:hover,
.review-item:hover {
  border-color: #9ab9b6;
  box-shadow: var(--shadow-soft);
}

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

.primary-button:hover {
  background: var(--primary-dark);
}

.secondary-button {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--line);
}

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

.stats-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}

.stat-card {
  position: relative;
  overflow: hidden;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.stat-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 3px;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  opacity: 0.8;
}

.stat-value {
  display: block;
  font-size: 1.45rem;
  font-weight: 850;
}

.stat-label {
  color: var(--muted);
  font-size: 0.88rem;
}

.tab-panel {
  display: none;
}

.tab-panel.is-active {
  display: block;
}

.tool-layout {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.sidebar,
.question-card,
.exam-start,
.result-card,
.source-section,
.empty-state {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.sidebar {
  padding: 14px;
  position: sticky;
  top: 14px;
}

.control-group {
  margin-bottom: 12px;
}

.control-group label {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 800;
}

.control-group select,
.control-group input,
.notes-area {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  padding: 10px 11px;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

.control-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 12px 0;
}

.progress-box {
  padding-top: 12px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.92rem;
}

.meter {
  width: 100%;
  height: 10px;
  overflow: hidden;
  appearance: none;
  background: #e6e9e5;
  border: 0;
  border-radius: 999px;
}

.meter::-webkit-progress-bar {
  background: #e6e9e5;
  border-radius: 999px;
}

.meter::-webkit-progress-value {
  background: var(--primary);
  border-radius: 999px;
}

.meter::-moz-progress-bar {
  background: var(--primary);
  border-radius: 999px;
}

.work-area {
  min-width: 0;
}

.question-card {
  padding: 20px;
}

.question-topline,
.exam-topline {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--surface-strong);
  color: #3b4645;
  font-size: 0.82rem;
  font-weight: 780;
}

.chip.category {
  background: #e4f0ef;
  color: var(--primary-dark);
}

.chip.warning {
  background: #fff3ce;
  color: #684b00;
}

.question-title {
  margin: 0 0 18px;
  font-size: 1.28rem;
  line-height: 1.35;
}

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

.answer-button {
  width: 100%;
  min-height: 54px;
  padding: 12px;
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  text-align: left;
  color: var(--text);
  background: #fff;
  border: 1px solid var(--line);
}

.answer-button:hover {
  border-color: #9ab9b6;
  box-shadow: var(--shadow-soft);
}

.answer-letter {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: var(--primary-soft);
  color: var(--primary-dark);
  font-weight: 850;
}

.answer-button.is-selected {
  border-color: var(--primary);
  box-shadow: inset 0 0 0 1px var(--primary);
}

.answer-button.is-correct {
  border-color: var(--success);
  background: #edf7ef;
}

.answer-button.is-wrong {
  border-color: var(--danger);
  background: #fff0ef;
}

.feedback {
  margin-top: 14px;
  padding: 12px;
  border-radius: 8px;
  background: var(--surface-strong);
  border: 1px solid var(--line);
}

.feedback.good {
  border-color: #a7d2b6;
  background: #edf7ef;
}

.feedback.bad {
  border-color: #e4aaa4;
  background: #fff0ef;
}

.question-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: space-between;
  margin-top: 16px;
}

.action-cluster {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.notes-panel {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.notes-area {
  min-height: 96px;
  resize: vertical;
}

.muted {
  color: var(--muted);
}

.exam-start,
.result-card,
.source-section,
.empty-state {
  padding: 20px;
}

.exam-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 260px;
  gap: 18px;
  align-items: start;
}

.exam-side {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  position: sticky;
  top: 14px;
}

.timer {
  font-size: 1.4rem;
  font-weight: 900;
  color: var(--primary-dark);
}

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

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

.nav-dot {
  min-height: 36px;
  background: #fff;
  border: 1px solid var(--line);
  color: var(--text);
  font-weight: 800;
}

.nav-dot:hover {
  border-color: #9ab9b6;
}

.nav-dot.is-current {
  border-color: var(--primary);
  box-shadow: inset 0 0 0 1px var(--primary);
}

.nav-dot.is-answered {
  background: #e6f3f1;
}

.nav-dot.is-wrong {
  background: #fff0ef;
  border-color: #e4aaa4;
}

.nav-dot.is-correct {
  background: #edf7ef;
  border-color: #a7d2b6;
}

.exam-controls {
  display: grid;
  gap: 10px;
}

.result-score {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  margin: 10px 0 18px;
}

.score-number {
  font-size: 2rem;
  font-weight: 900;
}

.pass {
  color: var(--success);
}

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

.review-list {
  display: grid;
  gap: 10px;
}

.review-item {
  width: 100%;
  padding: 13px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  text-align: left;
}

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

.source-list {
  display: grid;
  gap: 12px;
}

.source-item {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.source-item p:last-child {
  margin-bottom: 0;
}

.site-footer {
  border-top: 1px solid var(--line);
  background: #eef2ed;
}

.footer-inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: 18px 20px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
  align-items: center;
  justify-content: space-between;
  color: var(--muted);
  font-size: 0.92rem;
}

.footer-inner a {
  color: var(--primary-dark);
  font-weight: 800;
  text-decoration: none;
}

.footer-inner a:hover {
  text-decoration: underline;
}

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

  .header-inner {
    display: grid;
    align-items: start;
  }

  .source-badge {
    justify-self: start;
  }

  .sidebar,
  .exam-side {
    position: static;
  }

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

@media (max-width: 560px) {
  .app-shell {
    padding: 14px 12px 30px;
  }

  .header-inner {
    padding: 22px 12px 18px;
  }

  .brand-heading {
    gap: 10px;
  }

  .brand-icon {
    width: 42px;
    height: 42px;
    border-radius: 12px;
  }

  h1 {
    font-size: 1.55rem;
  }

  .source-badge {
    padding: 9px 10px;
    font-size: 0.74rem;
  }

  .stats-strip,
  .control-row,
  .question-actions {
    grid-template-columns: 1fr;
  }

  .question-card,
  .exam-start,
  .result-card,
  .source-section,
  .empty-state {
    padding: 15px;
  }

  .answer-button {
    grid-template-columns: 30px minmax(0, 1fr);
  }

  .question-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}
