:root {
  --ink: #172520;
  --muted: #69756f;
  --line: #dfe4df;
  --paper: #fbfcf8;
  --sidebar: #f1f4ee;
  --green: #1e5945;
  --green-soft: #dfece3;
  --cream: #f5efe2;
  --gold: #caa966;
}

* { box-sizing: border-box; }
html, body, #app { min-height: 100%; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
}
button, input { font: inherit; }
button { color: inherit; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.app-shell {
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  min-height: 100dvh;
  overflow: hidden;
}

.sidebar {
  display: flex;
  min-width: 0;
  height: 100dvh;
  flex-direction: column;
  border-right: 1px solid #d4dbd4;
  background: var(--sidebar);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 24px 22px 20px;
}
.brand--center { justify-content: center; padding: 0; }
.brand__mark {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border-radius: 10px;
  background: var(--green);
  color: white;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 21px;
  font-weight: 700;
}
.brand div { display: flex; flex-direction: column; gap: 2px; }
.brand strong { font-size: 14px; letter-spacing: .16em; }
.brand div span { color: var(--muted); font-family: Georgia, "Times New Roman", serif; font-size: 14px; }

.search-box {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 0 18px 20px;
  padding: 10px 12px;
  border: 1px solid #d5dbd4;
  border-radius: 10px;
  background: rgba(255,255,255,.75);
  color: #7b8580;
  transition: border-color .2s, box-shadow .2s, background .2s;
}
.search-box:focus-within {
  border-color: #86a394;
  background: white;
  box-shadow: 0 0 0 3px rgba(30, 89, 69, .08);
}
.search-icon { width: 12px; height: 12px; border: 1.7px solid currentColor; border-radius: 50%; position: relative; }
.search-icon::after { content: ""; position: absolute; width: 6px; height: 1.7px; right: -5px; bottom: -3px; background: currentColor; transform: rotate(45deg); border-radius: 1px; }
.search-box input { width: 100%; border: 0; outline: 0; background: transparent; color: var(--ink); font-size: 14px; }
.search-box input::placeholder { color: #8f9994; }
.search-box button { border: 0; background: transparent; cursor: pointer; color: #7e8883; font-size: 20px; line-height: 1; }

.list-label {
  display: flex;
  justify-content: space-between;
  padding: 0 22px 10px;
  color: #7d8882;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .13em;
  text-transform: uppercase;
}
.topic-list {
  min-height: 0;
  overflow-y: auto;
  padding: 0 10px 18px;
  scrollbar-color: #bec8c0 transparent;
  scrollbar-width: thin;
}
.subject-group {
  overflow: hidden;
  border: 1px solid transparent;
  border-radius: 11px;
}
.subject-group + .subject-group { margin-top: 5px; }
.subject-group.has-active { border-color: rgba(30, 89, 69, .13); background: rgba(255,255,255,.34); }
.subject-toggle {
  display: grid;
  width: 100%;
  grid-template-columns: 16px minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  padding: 10px 11px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  text-align: left;
  cursor: pointer;
  transition: background .16s, color .16s;
}
.subject-toggle:hover { background: rgba(255,255,255,.72); }
.subject-toggle:focus-visible { outline: 2px solid var(--green); outline-offset: -2px; }
.subject-group.has-active > .subject-toggle { color: var(--green); }
.subject-toggle__chevron {
  color: #7a8981;
  font-size: 22px;
  line-height: 1;
  transform: rotate(0deg);
  transition: transform .16s;
}
.subject-toggle[aria-expanded="true"] .subject-toggle__chevron { transform: rotate(90deg); }
.subject-toggle__label { display: flex; min-width: 0; flex-direction: column; gap: 2px; }
.subject-toggle__code { color: #698078; font-size: 9px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.subject-toggle__name {
  overflow: hidden;
  color: #2b3b34;
  font-size: 12px;
  font-weight: 750;
  line-height: 1.3;
  text-overflow: ellipsis;
}
.subject-toggle__count {
  min-width: 23px;
  padding: 3px 6px;
  border-radius: 999px;
  background: #e2e8e1;
  color: #617068;
  font-size: 10px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  text-align: center;
}
.subject-group.has-active .subject-toggle__count { background: var(--green-soft); color: var(--green); }
.subject-questions {
  margin: 0 7px 7px 15px;
  padding-left: 7px;
  border-left: 1px solid #d7ded7;
}
.subject-questions[hidden] { display: none; }
.topic-item {
  position: relative;
  display: grid;
  width: 100%;
  grid-template-columns: 34px 1fr 8px;
  gap: 8px;
  align-items: start;
  padding: 10px 9px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  text-align: left;
  cursor: pointer;
  transition: background .16s, color .16s, box-shadow .16s;
}
.topic-item:hover { background: rgba(255,255,255,.68); }
.topic-item:focus-visible { outline: 2px solid var(--green); outline-offset: -2px; }
.topic-item.is-active { background: var(--green); color: white; box-shadow: 0 6px 18px rgba(25,72,56,.12); }
.topic-item__number {
  padding-top: 2px;
  color: #8a948f;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}
.topic-item.is-active .topic-item__number { color: #bcd2c8; }
.topic-item__title {
  display: -webkit-box;
  overflow: hidden;
  color: #34413b;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.38;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}
.topic-item.is-active .topic-item__title { color: white; }
.topic-item__status { width: 6px; height: 6px; margin-top: 6px; border-radius: 50%; background: #6c9a80; }
.topic-item.is-active .topic-item__status { background: #bfe6ce; }
.no-results { padding: 28px 18px; color: var(--muted); font-size: 13px; line-height: 1.5; text-align: center; }
.sidebar__footer {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: auto;
  padding: 14px 22px;
  border-top: 1px solid #d9dfd8;
  color: #75817b;
  font-size: 11px;
}
.app-version {
  margin-left: auto;
  padding: 2px 5px;
  border: 1px solid #cdd6cf;
  border-radius: 5px;
  color: #65756d;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .04em;
}
.live-dot { width: 7px; height: 7px; border-radius: 50%; background: #3c9268; box-shadow: 0 0 0 3px rgba(60,146,104,.13); }

.workspace {
  display: flex;
  min-width: 0;
  height: 100dvh;
  flex-direction: column;
  background: radial-gradient(circle at 100% 0%, rgba(219,229,219,.45), transparent 34%), var(--paper);
}
.topic-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  padding: 27px 34px 22px;
  border-bottom: 1px solid var(--line);
  background: rgba(251,252,248,.88);
}
.topic-heading { max-width: 900px; }
.topic-heading__index { color: var(--green); font-size: 11px; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; }
.topic-heading h1 {
  margin: 7px 0 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(24px, 2.4vw, 36px);
  font-weight: 500;
  line-height: 1.18;
  letter-spacing: -.018em;
}
.header-actions { display: flex; flex: 0 0 auto; align-items: center; gap: 9px; margin-top: 7px; }
.reload-button {
  height: 38px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: white;
  color: var(--green);
  cursor: pointer;
  font-size: 11px;
  font-weight: 700;
}
.reload-button:hover { border-color: #aebeb5; background: var(--green-soft); }
.topic-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: white;
}
.topic-nav button { display: grid; width: 32px; height: 30px; place-items: center; border: 0; border-radius: 7px; background: transparent; cursor: pointer; }
.topic-nav button:hover:not(:disabled) { background: var(--green-soft); color: var(--green); }
.topic-nav button:disabled { opacity: .28; cursor: default; }
.topic-nav span { min-width: 52px; color: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; text-align: center; }

.answer-grid {
  display: grid;
  min-height: 0;
  flex: 1;
  grid-template-columns: minmax(320px, .82fr) minmax(460px, 1.18fr);
  gap: 18px;
  padding: 20px;
  overflow: hidden;
}
.answer-card {
  display: flex;
  min-width: 0;
  min-height: 0;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255,255,255,.9);
  box-shadow: 0 12px 35px rgba(31,49,41,.055);
}
.answer-card--flash { border-top: 3px solid var(--gold); }
.answer-card--standard { border-top: 3px solid var(--green); }
.answer-card__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 20px 22px 17px;
  border-bottom: 1px solid #e7eae6;
  background: rgba(255,255,255,.9);
}
.answer-card__eyebrow { display: block; margin-bottom: 6px; color: #987b42; font-size: 10px; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; }
.answer-card--standard .answer-card__eyebrow { color: var(--green); }
.answer-card h2 { margin: 0; font-family: Georgia, "Times New Roman", serif; font-size: 19px; font-weight: 600; line-height: 1.28; }
.duration { flex: 0 0 auto; padding: 5px 8px; border-radius: 7px; background: var(--cream); color: #806a3e; font-size: 10px; font-weight: 700; }
.answer-card--standard .duration { background: var(--green-soft); color: var(--green); }
.answer-card__body {
  min-height: 0;
  overflow-y: auto;
  padding: 22px;
  scrollbar-color: #c4cdc6 transparent;
  scrollbar-width: thin;
}
.formatted-answer { color: #29362f; font-family: Georgia, "Times New Roman", serif; font-size: 15px; line-height: 1.72; }
.formatted-answer p { margin: 0 0 1.05em; }
.formatted-answer p:last-child { margin-bottom: 0; }
.formatted-answer h4 { margin: 1.35em 0 .55em; color: #19372c; font-family: Arial, Helvetica, sans-serif; font-size: 12px; font-weight: 800; letter-spacing: .035em; text-transform: uppercase; }
.formatted-answer h4:first-child { margin-top: 0; }
.formatted-answer ul, .formatted-answer ol { margin: 0 0 1.1em; padding-left: 1.25em; }
.formatted-answer li { margin: .28em 0; padding-left: .2em; }
.formatted-answer li::marker { color: #57806c; font-weight: 700; }
.formatted-answer code { padding: .08em .32em; border-radius: 4px; background: #eef2ed; font-family: Consolas, monospace; font-size: .9em; }
.formula { margin: .7em 0 1.1em; padding: 11px 14px; border-left: 3px solid #87a594; border-radius: 0 7px 7px 0; background: #f0f5f0; color: #17382c; font-family: Consolas, monospace; font-size: 14px; font-weight: 600; }
.missing-answer { color: var(--muted); font-style: italic; }
.exam-note { margin-top: 24px; border: 1px solid #e2e6df; border-radius: 10px; background: #f7f8f4; }
.exam-note summary { padding: 12px 14px; color: #4d5d54; font-size: 11px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; cursor: pointer; }
.exam-note__content { padding: 14px; border-top: 1px solid #e2e6df; color: #56635c; font-size: 13px; line-height: 1.62; }

.error-state {
  display: grid;
  min-height: 100dvh;
  place-content: center;
  gap: 22px;
  padding: 24px;
  background: radial-gradient(circle at 50% 0%, #e4ede5, transparent 45%), var(--paper);
}
.error-card {
  width: min(560px, calc(100vw - 40px));
  padding: 32px;
  border: 1px solid var(--line);
  border-top: 3px solid #a45a4d;
  border-radius: 14px;
  background: white;
  box-shadow: 0 18px 45px rgba(31,49,41,.08);
}
.error-card__label { color: #99564a; font-size: 10px; font-weight: 800; letter-spacing: .13em; text-transform: uppercase; }
.error-card h1 { margin: 8px 0 12px; font-family: Georgia, "Times New Roman", serif; font-size: 28px; font-weight: 500; }
.error-card p { margin: 0; color: var(--muted); line-height: 1.6; }
.error-card button { margin-top: 22px; padding: 10px 14px; border: 0; border-radius: 9px; background: var(--green); color: white; cursor: pointer; font-size: 13px; font-weight: 700; }

@media (max-width: 1100px) {
  .app-shell { grid-template-columns: 290px minmax(0, 1fr); }
  .answer-grid { grid-template-columns: 1fr; overflow-y: auto; }
  .answer-card { min-height: 420px; overflow: visible; }
  .answer-card__body { overflow: visible; }
}

@media (max-width: 760px) {
  .app-shell { display: block; overflow: auto; }
  .sidebar { height: auto; max-height: 42dvh; border-right: 0; border-bottom: 1px solid #d4dbd4; }
  .brand { padding: 15px 18px 12px; }
  .search-box { margin-bottom: 12px; }
  .list-label { padding-bottom: 7px; }
  .topic-list { max-height: 210px; }
  .sidebar__footer { display: none; }
  .workspace { height: auto; min-height: 58dvh; }
  .topic-header { padding: 20px 18px 17px; }
  .topic-heading h1 { font-size: 24px; }
  .header-actions { align-self: center; }
  .topic-nav { display: none; }
  .reload-button { white-space: nowrap; }
  .answer-grid { display: block; padding: 12px; overflow: visible; }
  .answer-card { min-height: 0; margin-bottom: 12px; }
  .answer-card__header, .answer-card__body { padding: 17px; }
}
