:root {
  --bg: #f3f7f5;
  --surface: #ffffff;
  --ink: #18211f;
  --muted: #65736f;
  --line: #d9e3df;
  --teal: #087f72;
  --teal-dark: #075f56;
  --red: #c9342b;
  --green: #167a3d;
  --yellow: #f2c94c;
  --shadow: 0 16px 40px rgba(24, 33, 31, 0.12);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

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

button,
input,
textarea {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

.app {
  display: grid;
  grid-template-columns: 330px minmax(0, 1fr);
  min-height: 100vh;
}

.side {
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 22px;
  background: #ffffff;
  border-right: 1px solid var(--line);
}

.study-image {
  width: 100%;
  height: 160px;
  object-fit: cover;
  border-radius: 8px;
  background: #e6eeea;
}

.title-block h1,
.quiz-panel h2,
.reference-panel h2 {
  margin: 0;
}

.title-block h1 {
  font-size: 34px;
  line-height: 1;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--teal-dark);
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0;
}

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

.stats-grid div {
  min-height: 76px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbfa;
}

.stats-grid span {
  display: block;
  font-size: 25px;
  font-weight: 850;
}

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

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

.mode,
.format-button,
.ghost-button,
.secondary-button,
.primary-button {
  min-height: 44px;
  border-radius: 8px;
  transition: transform 120ms ease, background 120ms ease, border 120ms ease;
}

.mode {
  padding: 10px 12px;
  color: var(--ink);
  text-align: left;
  background: #eef5f2;
  border: 1px solid transparent;
}

.mode:hover,
.ghost-button:hover,
.secondary-button:hover,
.primary-button:hover {
  transform: translateY(-1px);
}

.mode.is-active {
  color: #ffffff;
  background: var(--teal);
}

.answer-switch {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 18px;
}

.answer-switch span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.format-button {
  min-height: 38px;
  padding: 8px 12px;
  color: var(--teal-dark);
  background: #e8f5f2;
  border: 1px solid #b9ddd6;
}

.format-button.is-active {
  color: #ffffff;
  background: var(--teal);
  border-color: var(--teal);
}

.ghost-button {
  margin-top: auto;
  color: var(--red);
  background: #fff5f4;
  border: 1px solid #f0c8c4;
}

.main {
  display: grid;
  gap: 22px;
  align-content: start;
  padding: 28px;
}

.quiz-panel,
.reference-panel {
  width: min(980px, 100%);
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.question-top,
.reference-head,
.actions {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.question-status {
  display: grid;
  gap: 8px;
  flex: 0 0 auto;
}

.quiz-panel h2 {
  max-width: 780px;
  font-size: 26px;
  line-height: 1.25;
}

.counter,
.timer-badge {
  min-width: 74px;
  padding: 8px 10px;
  border-radius: 8px;
  color: var(--muted);
  background: #f4f7f6;
  text-align: center;
  font-weight: 800;
}

.timer-badge {
  color: var(--teal-dark);
  background: #e8f5f2;
}

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

.written-answer {
  display: grid;
  gap: 10px;
  margin: 24px 0;
}

.written-answer label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.written-answer textarea {
  width: 100%;
  min-height: 112px;
  resize: vertical;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: #fbfdfc;
  line-height: 1.45;
}

.written-answer textarea:focus,
.reference-head input:focus {
  outline: 2px solid #8ed4c9;
  outline-offset: 2px;
}

.written-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.self-good {
  color: var(--green);
  background: #edf8f0;
  border-color: #b8dfc3;
}

.self-bad {
  color: var(--red);
  background: #fff0ef;
  border-color: #f0c8c4;
}

.choice {
  min-height: 64px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfc;
  color: var(--ink);
  text-align: left;
  line-height: 1.35;
}

.choice:hover {
  border-color: var(--teal);
}

.choice.correct {
  border-color: var(--green);
  background: #edf8f0;
}

.choice.wrong {
  border-color: var(--red);
  background: #fff0ef;
}

.feedback {
  min-height: 86px;
  padding: 14px 16px;
  border-left: 5px solid var(--yellow);
  border-radius: 8px;
  background: #fffbe8;
  line-height: 1.5;
  white-space: pre-line;
}

.feedback.good {
  border-color: var(--green);
  background: #edf8f0;
}

.feedback.bad {
  border-color: var(--red);
  background: #fff0ef;
}

.actions {
  margin-top: 18px;
}

.secondary-button,
.primary-button {
  padding: 10px 18px;
  font-weight: 800;
}

.secondary-button {
  color: var(--teal-dark);
  background: #e8f5f2;
  border: 1px solid #b9ddd6;
}

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

.primary-button:disabled,
.secondary-button:disabled,
.format-button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
  transform: none;
}

.dashboard-panel,
.reference-panel {
  box-shadow: none;
}

.dashboard-panel {
  width: min(980px, 100%);
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.dashboard-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.dashboard-head h2,
.dashboard-section h3 {
  margin: 0;
}

.dashboard-head p {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.45;
}

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

.dashboard-grid div {
  min-height: 86px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbfa;
}

.dashboard-grid span {
  display: block;
  font-size: 24px;
  font-weight: 850;
}

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

.dashboard-section {
  display: grid;
  gap: 10px;
}

.dashboard-columns {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-top: 18px;
}

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

.breakdown-item,
.review-item {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfc;
}

.breakdown-line {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px;
  font-weight: 800;
}

.meter {
  height: 9px;
  overflow: hidden;
  border-radius: 8px;
  background: #e8efec;
}

.meter span {
  display: block;
  height: 100%;
  border-radius: 8px;
  background: var(--teal);
}

.review-item strong {
  line-height: 1.35;
}

.review-item p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.reference-head {
  align-items: center;
  margin-bottom: 18px;
}

.reference-head input {
  width: min(300px, 100%);
  min-height: 42px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: #fbfdfc;
}

.policy-list,
.act-list {
  display: grid;
  gap: 10px;
  max-height: 430px;
  overflow: auto;
  padding-right: 4px;
}

.policy-list {
  max-height: 620px;
}

.policy-item,
.act-item {
  display: grid;
  gap: 5px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfc;
}

.policy-item {
  gap: 12px;
}

.policy-title {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px;
}

.policy-title strong {
  font-size: 18px;
}

.policy-title span {
  color: var(--teal-dark);
  font-size: 13px;
  font-weight: 800;
}

.policy-item ol {
  display: grid;
  gap: 7px;
  margin: 0;
  padding-left: 22px;
  line-height: 1.45;
}

.policy-item li::marker {
  color: var(--teal-dark);
  font-weight: 800;
}

.act-item strong {
  line-height: 1.35;
}

.act-item p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.act-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--teal-dark);
  font-size: 12px;
  font-weight: 800;
}

@media (max-width: 860px) {
  .app {
    grid-template-columns: 1fr;
  }

  .side {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .study-image {
    height: 120px;
  }

  .main {
    padding: 18px;
  }

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

  .question-top,
  .dashboard-head,
  .reference-head,
  .actions {
    flex-direction: column;
  }

  .question-status,
  .dashboard-grid,
  .dashboard-columns {
    grid-template-columns: 1fr;
    width: 100%;
  }

  .quiz-panel h2 {
    font-size: 22px;
  }

  .counter,
  .timer-badge,
  .reference-head input,
  .format-button,
  .secondary-button,
  .primary-button,
  .written-actions button {
    width: 100%;
  }
}
