:root {
  --blue: #355a92;
  --blue-dark: #284775;
  --orange: #f0a052;
  --orange-dark: #d98532;
  --paper: #ffffff;
  --bg: #ececec;
  --line: #d7d7d7;
  --text: #161616;
  --muted: #6a6f78;
  --good: #197a49;
  --bad: #b3261e;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.22);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  margin: 0;
  color: var(--text);
  background: var(--bg);
  font-family: "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 17px;
  letter-spacing: 0;
}

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

button {
  cursor: pointer;
}

.shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.exam-header {
  min-height: 80px;
  background: var(--blue);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  gap: 20px;
}

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

.menu-button,
.header-back,
.drawer-close {
  border: 0;
  background: transparent;
}

.menu-button {
  width: 40px;
  height: 40px;
  color: #fff;
  font-size: 25px;
  line-height: 1;
}

.header-back {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
  font-size: 34px;
  line-height: 32px;
  display: grid;
  place-items: center;
  padding-bottom: 4px;
}

.crest {
  width: 42px;
  height: 42px;
  border: 2px solid rgba(255, 255, 255, 0.85);
  display: grid;
  place-items: center;
  font-size: 18px;
  font-weight: 700;
  line-height: 1;
}

.title {
  font-size: 19px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.timer {
  font-size: 20px;
  font-weight: 700;
  min-width: 94px;
  text-align: center;
}

.home {
  max-width: 1180px;
  width: 100%;
  margin: 0 auto;
  padding: 24px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
}

.topbar h1 {
  font-size: 30px;
  margin: 0 0 4px;
}

.topbar p {
  margin: 0;
  color: var(--muted);
}

.tabs {
  display: inline-flex;
  border: 1px solid var(--line);
  background: #fff;
}

.tab {
  border: 0;
  background: transparent;
  padding: 11px 16px;
}

.tab.active {
  background: var(--blue);
  color: #fff;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}

.card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 16px;
}

.test-card {
  background: #fff;
  border: 1px solid #d9dde5;
  border-radius: 8px;
  padding: 18px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-height: 210px;
}

.test-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.test-card h2 {
  margin: 0 0 6px;
  font-size: 20px;
  line-height: 1.2;
}

.test-card p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.source-pill {
  border: 1px solid #d8b071;
  background: #fff6e9;
  color: #6d4210;
  border-radius: 999px;
  padding: 4px 9px;
  font-size: 12px;
  white-space: nowrap;
}

.card-results {
  border-top: 1px solid #eceff4;
  border-bottom: 1px solid #eceff4;
  padding: 10px 0;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: #29384f;
  font-size: 14px;
}

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

.card-actions {
  margin-top: auto;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.card h2,
.card h3 {
  margin: 0 0 8px;
  font-size: 20px;
}

.meta {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.actions {
  margin-top: 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.primary,
.secondary,
.danger {
  border: 0;
  border-radius: 20px;
  padding: 10px 18px;
  min-height: 40px;
}

.primary {
  background: var(--orange);
  color: #111;
}

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

.secondary {
  background: #eef2f7;
  color: #17233a;
}

.danger {
  background: #fee9e7;
  color: var(--bad);
}

.link-danger {
  border: 0;
  background: transparent;
  color: var(--bad);
  padding: 4px 0;
  min-height: 0;
  font-size: 12px;
  text-decoration: underline;
}

.drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.32);
  z-index: 20;
}

.drawer {
  position: fixed;
  inset: 0 auto 0 0;
  width: min(360px, 92vw);
  background: #fff;
  z-index: 21;
  box-shadow: 8px 0 24px rgba(0, 0, 0, 0.22);
  transform: translateX(-100%);
  transition: transform 180ms ease;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.drawer[aria-hidden="false"] {
  transform: translateX(0);
}

.drawer-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.drawer-title {
  font-weight: 800;
  font-size: 18px;
}

.drawer-subtitle,
.drawer-note {
  color: var(--muted);
  font-size: 13px;
}

.drawer-close {
  width: 34px;
  height: 34px;
  font-size: 28px;
  line-height: 1;
}

.drawer-menu {
  display: grid;
  gap: 6px;
}

.drawer-menu a,
.drawer-menu button {
  color: var(--text);
  text-decoration: none;
  padding: 10px 0;
  border-bottom: 1px solid #edf0f4;
  border-top: 0;
  border-left: 0;
  border-right: 0;
  background: transparent;
  text-align: left;
}

.drawer-menu .active-drawer {
  color: var(--blue-dark);
  font-weight: 800;
}

.drawer-section {
  display: grid;
  gap: 12px;
}

.drawer-section h2 {
  margin: 0;
  font-size: 16px;
}

.drawer-section label {
  display: grid;
  gap: 6px;
  font-weight: 700;
}

.drawer-section .drawer-check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
}

.drawer-section .drawer-check input {
  width: auto;
}

.drawer-section input,
.drawer-section select {
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 10px;
  width: 100%;
}

.exam-start,
.exam-main {
  flex: 1;
  display: grid;
  gap: 14px;
  padding: 14px;
}

.exam-start {
  grid-template-columns: 1fr 1fr;
  align-items: stretch;
}

.paper {
  background: var(--paper);
  box-shadow: var(--shadow);
  padding: 50px 32px;
  overflow: auto;
}

.paper h1 {
  margin-top: 0;
}

.start-stats {
  display: flex;
  gap: 38px;
  margin-top: 34px;
}

.stat-box {
  width: 150px;
  border: 2px solid var(--orange);
  border-radius: 7px 7px 20px 20px;
  overflow: hidden;
  text-align: center;
}

.stat-value {
  font-size: 48px;
  padding: 18px 0 16px;
}

.stat-label {
  background: var(--orange);
  font-weight: 700;
  padding: 20px 4px;
}

.exam-main {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  min-height: 0;
}

.question-pane,
.text-pane {
  height: calc(100vh - 190px);
}

.text-pane {
  line-height: 1.45;
}

.audio-pane {
  display: flex;
  flex-direction: column;
}

.audio-stage {
  flex: 1;
  min-height: 320px;
  background: #f5f7fb;
  border: 1px solid #dce2eb;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 14px;
  text-align: center;
  padding: 24px;
}

.audio-stage h2,
.audio-stage p {
  margin: 0;
}

.audio-icon {
  width: 88px;
  height: 88px;
  border-radius: 50%;
  background: var(--blue);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 38px;
  padding-left: 5px;
}

.audio-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
}

.audio-note {
  color: var(--muted);
  font-size: 14px;
  max-width: 360px;
}

.text-pane table {
  width: 100%;
  border-collapse: collapse;
  margin: 18px 0;
}

.text-pane th,
.text-pane td {
  border: 1px solid #bcbcbc;
  padding: 8px;
  text-align: left;
}

.question-pane {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.question-text {
  line-height: 1.35;
}

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

.option {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 5px;
  min-height: 82px;
  display: grid;
  grid-template-columns: 34px 32px 1fr;
  align-items: center;
  gap: 16px;
  padding: 12px 16px;
  text-align: left;
}

.option:hover,
.option.selected {
  border-color: var(--blue);
}

.radio {
  width: 20px;
  height: 20px;
  border: 1px solid #aaa;
  border-radius: 50%;
  display: block;
}

.option.selected .radio {
  border: 6px solid var(--blue);
}

.option.correct {
  border-color: var(--good);
  background: #edf8f1;
}

.option.incorrect {
  border-color: var(--bad);
  background: #fff0ef;
}

.letter {
  font-weight: 800;
  font-size: 20px;
}

.exam-footer {
  background: var(--blue);
  color: #fff;
  min-height: 96px;
  display: grid;
  grid-template-columns: 220px 1fr 220px;
  align-items: center;
  gap: 16px;
  padding: 10px 15px;
}

.nav-button {
  border: 0;
  border-radius: 20px;
  padding: 12px 20px;
  min-width: 150px;
  background: var(--orange);
  color: #111;
}

.nav-button:disabled {
  background: #b6c0cf;
  color: #6d7480;
  cursor: default;
}

.question-map {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
}

.qnum {
  width: 32px;
  height: 28px;
  border: 1px solid rgba(255, 255, 255, 0.55);
  background: transparent;
  color: #fff;
  padding: 0;
}

.qnum.active {
  background: var(--orange);
  color: #111;
  border-color: var(--orange);
}

.qnum.answered::after {
  content: "";
  width: 6px;
  height: 6px;
  background: #fff;
  border-radius: 50%;
  display: block;
  margin: -3px auto 0;
}

.qnum.marked {
  box-shadow: inset 0 -4px 0 #fff;
}

.footer-center {
  align-self: stretch;
  display: grid;
  place-items: center;
  gap: 2px;
}

.counter {
  justify-self: start;
  align-self: end;
  background: var(--orange);
  color: #111;
  min-width: 64px;
  padding: 5px 10px;
  font-weight: 700;
}

.utility-row {
  display: flex;
  justify-content: center;
  gap: 12px;
}

.icon-button {
  width: 42px;
  height: 42px;
  border: 0;
  background: transparent;
  color: #fff;
  font-size: 25px;
}

.form {
  display: grid;
  gap: 12px;
  max-width: 860px;
}

.form label {
  display: grid;
  gap: 6px;
  font-weight: 700;
}

.form input,
.form select,
.form textarea {
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 11px;
  background: #fff;
  width: 100%;
}

.form textarea {
  min-height: 82px;
  resize: vertical;
}

.notice {
  border-left: 4px solid var(--blue);
  background: #fff;
  padding: 12px 14px;
  margin: 14px 0;
}

.results {
  max-width: 1120px;
  width: 100%;
  margin: 0 auto;
  padding: 24px;
}

.score {
  font-size: 46px;
  font-weight: 800;
  margin: 8px 0;
}

.review-list {
  display: grid;
  gap: 12px;
  margin-top: 18px;
}

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

.review-item h3 {
  margin: 0 0 8px;
  font-size: 18px;
}

.signals {
  color: var(--blue-dark);
  font-weight: 700;
}

.history-table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
}

.history-table th,
.history-table td {
  border: 1px solid var(--line);
  padding: 10px;
  text-align: left;
}

.empty {
  color: var(--muted);
  padding: 20px 0;
}

.grammar-hero {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 16px;
}

.grammar-hero h2 {
  margin: 0 0 12px;
}

.grammar-hero p {
  margin: 12px 0 0;
  color: var(--muted);
}

.grammar-map {
  display: grid;
  grid-template-columns: repeat(5, minmax(110px, 1fr));
  gap: 0;
  align-items: center;
  border: 1px solid #dbe1ea;
  border-radius: 8px;
  overflow: hidden;
  background: #f7f9fc;
}

.grammar-map div {
  min-height: 78px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 5px;
  border-right: 1px solid #dbe1ea;
  position: relative;
}

.grammar-map div:last-child {
  border-right: 0;
}

.grammar-map div + div::before {
  content: "→";
  position: absolute;
  left: -10px;
  color: #7b8798;
  background: #f7f9fc;
  padding: 0 3px;
}

.grammar-map span {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.grammar-map strong {
  text-align: center;
}

.grammar-map .verb-slot {
  background: var(--orange);
}

.grammar-map .verb-slot::before {
  background: var(--orange);
}

.grammar-map .end-slot {
  background: #eef2f7;
  color: var(--blue-dark);
}

.grammar-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 14px;
}

.grammar-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}

.grammar-card.grammar-done {
  background: #edf8f1;
  border-color: #8dc9a9;
}

.grammar-card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.grammar-card h2 {
  margin: 0 0 8px;
  font-size: 19px;
}

.got-it {
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--blue-dark);
  font-size: 13px;
  font-weight: 800;
}

.grammar-card p {
  margin: 0 0 12px;
  color: #334155;
}

.formula {
  background: #f7f9fc;
  border-left: 4px solid var(--blue);
  padding: 10px 12px;
  font-weight: 800;
  margin-bottom: 12px;
}

.grammar-card ul {
  margin: 0;
  padding-left: 18px;
  line-height: 1.55;
}

.remember {
  margin-top: 12px;
  padding: 9px 10px;
  background: #fff6e9;
  border: 1px solid #ead2ad;
  border-radius: 6px;
  color: #60400f;
  font-weight: 700;
}

.grammar-check {
  margin-top: 16px;
}

.vocab-toolbar {
  margin-bottom: 14px;
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 14px;
}

.vocab-toolbar label,
.vocab-practice-setup label {
  display: grid;
  gap: 6px;
  font-weight: 700;
}

.vocab-toolbar select,
.vocab-practice-setup select,
.vocab-practice input {
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 10px;
}

.vocab-table {
  font-size: 15px;
}

.vocab-table th:nth-child(1),
.vocab-table th:nth-child(2) {
  width: 18%;
}

.vocab-mini {
  white-space: nowrap;
  color: var(--muted);
  font-size: 13px;
}

.vocab-practice-setup,
.vocab-practice {
  max-width: 760px;
}

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

.vocab-practice h2 {
  font-size: 44px;
  margin: 10px 0;
}

.vocab-options .option {
  grid-template-columns: 32px 1fr;
}

.flash-wrap {
  display: grid;
  justify-items: center;
  gap: 16px;
  padding: 8px 0 2px;
}

.flash-card {
  width: min(100%, 430px);
  min-height: 310px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 12px;
  padding: 28px;
  text-align: center;
  touch-action: pan-y;
  user-select: none;
  transition: transform 140ms ease, border-color 140ms ease, box-shadow 140ms ease;
}

.flash-card h2 {
  margin: 0;
  font-size: 52px;
  line-height: 1.05;
}

.flash-label,
.flash-answer span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
}

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

.flash-answer strong {
  font-size: 28px;
}

.flash-answer p {
  margin: 0;
  color: var(--muted);
}

.flash-known {
  border-color: var(--good);
  box-shadow: 0 0 0 3px rgba(25, 122, 73, 0.12);
}

.flash-unknown {
  border-color: var(--bad);
  box-shadow: 0 0 0 3px rgba(179, 38, 30, 0.12);
}

.flash-actions {
  display: flex;
  justify-content: center;
  gap: 18px;
}

.flash-button {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  border: 0;
  display: grid;
  place-items: center;
  font-size: 28px;
  font-weight: 800;
}

.flash-next {
  min-width: 150px;
}

.flash-no {
  background: #fee9e7;
  color: var(--bad);
}

.flash-yes {
  background: #e8f6ee;
  color: var(--good);
}

@media (max-width: 860px) {
  body {
    font-size: 16px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .exam-start,
  .exam-main {
    grid-template-columns: 1fr;
  }

  .question-pane,
  .text-pane {
    height: auto;
    max-height: none;
  }

  .paper {
    padding: 28px 20px;
  }

  .start-stats {
    flex-wrap: wrap;
  }

  .exam-footer {
    grid-template-columns: 1fr;
  }

  .exam-footer > :last-child {
    justify-self: start;
  }

  .vocab-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .grammar-map {
    grid-template-columns: 1fr;
  }

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

  .flash-card {
    min-height: 270px;
  }

  .flash-card h2 {
    font-size: 42px;
  }
}
