/* Clean, typographic study-feedback styling (quiz explanations + AI tutor),
   modeled on the SAA-C03 prep app. Theme-aware via .study vars. */
.study {
  --se-ink: #191c22; --se-muted: #5c6672; --se-line: #e4e7ec; --se-card: #ffffff;
  /* Text colours here have to pass AA on white: #2f9e44 was 3.45:1, #e8990c
     2.4:1 and #1c7ed6 4.2:1. The *-bg tints are backgrounds and stay light. */
  --se-soft: #f6f7f9; --se-good: #237b34; --se-good-bg: #e7f5eb;
  --se-warn: #9a6700; --se-warn-bg: #fdf3e0; --se-primary: #1864ab; --se-primary-bg: #eef4fd;
  --se-mono: ui-monospace, SFMono-Regular, Menlo, monospace;
}
/* The app has an explicit dark-mode toggle. Do not mix the OS preference with
   a still-light page; that produced white history text and black cards. */
.dark-mode .study, body.dark-mode .study {
  --se-ink:#e9ebf1; --se-muted:#8b93a3; --se-line:#252932; --se-card:#171a21;
  --se-soft:#1c2027; --se-good:#51cf66; --se-good-bg:#14241a; --se-warn:#f0b429;
  --se-warn-bg:#2a2113; --se-primary:#4dabf7; --se-primary-bg:#16283b;
}

.study { color: var(--se-ink); }
/* small uppercase mono section label */
.se-label { font-family: var(--se-mono); font-size: .75rem; text-transform: uppercase;
  letter-spacing: .09em; color: var(--se-muted); margin: 1rem 0 .35rem; }
.se-label:first-child { margin-top: 0; }
/* "in plain english" callout */
.se-callout { background: var(--se-good-bg); border-left: 3px solid var(--se-good);
  border-radius: 8px; padding: .75rem .9rem; line-height: 1.55; margin: 0 0 .4rem; }
.se-principle { font-weight: 700; line-height: 1.5; margin: .1rem 0 .4rem; }
.se-body { line-height: 1.6; margin: 0 0 .4rem; }
/* per-option why-wrong list */
.se-why { list-style: none; padding: 0; margin: 0; }
.se-why li { display: flex; gap: .75rem; align-items: flex-start; padding: .18rem 0; line-height: 1.55; }
.se-why li > div { flex: 1 1 auto; min-width: 0; }
.se-why li b { color: var(--se-muted); }
/* option letter badge */
.se-key { display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto;
  min-width: 1.7em; height: 1.7em; padding: 0 .3em;
  font-family: var(--se-mono); font-weight: 700; font-size: .75rem; color: var(--se-muted);
  background: var(--se-soft); border: 1px solid var(--se-line); border-radius: 6px; }
/* subtle "show more depth" pill */
.se-pill { display: inline-flex; align-items: center; gap: .35em; font-family: var(--se-mono);
  font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; color: var(--se-primary);
  background: var(--se-primary-bg); border: 1px solid var(--se-line); border-radius: 999px;
  padding: .3em .75em; cursor: pointer; margin: .75rem 0; }
.se-pill:hover { border-color: var(--se-primary); }
.se-pill .chev { transition: transform .15s ease; }
.se-pill[aria-expanded="true"] .chev { transform: rotate(90deg); }
.se-deeper { background: var(--se-soft); border-radius: 8px; padding: .75rem .9rem;
  line-height: 1.6; color: var(--se-ink); }
.se-trap { background: var(--se-warn-bg); border-left: 3px solid var(--se-warn);
  border-radius: 8px; padding: .75rem .9rem; line-height: 1.55; margin: .75rem 0; }
/* source/reference link under an explanation */
.ref-src { font-size: .8rem; color: var(--se-muted); margin-top: .75rem; }
.ref-src a { color: var(--se-primary); text-decoration: none; font-weight: 500; }
.ref-src a:hover { text-decoration: underline; }
/* diagram card */
.dg-card { border: 1px solid var(--se-line); border-radius: 10px; padding: .85rem 1rem;
  background: var(--se-card); margin: 0 0 .75rem; }
.dg-card .dg-label { font-family: var(--se-mono); font-size: .75rem; text-transform: uppercase;
  letter-spacing: .08em; color: var(--se-muted); margin-bottom: .75rem; }
.dg-card .dg-caption { font-size: .8rem; color: var(--se-muted); margin-top: .4rem; }

/* AI tutor history — flat, clean list (not chunky cards) */
.tutor-history { border: 1px solid var(--se-line); border-radius: 12px; overflow: hidden; }
.th-item + .th-item { border-top: 1px solid var(--se-line); }
.th-head { display: flex; align-items: center; gap: .75rem; padding: .75rem .9rem; }
.th-toggle { background: none; border: 0; padding: 0; display: flex; align-items: center;
  gap: .75rem; text-align: left; flex: 1 1 auto; min-width: 0; cursor: pointer; color: var(--se-ink); }
.th-toggle .chev { color: var(--se-muted); transition: transform .15s ease; flex: none; }
.th-toggle[aria-expanded="true"] .chev { transform: rotate(90deg); }
.th-q { font-weight: 600; overflow-wrap: anywhere; }
.th-meta { font-family: var(--se-mono); font-size: .75rem; text-transform: uppercase;
  letter-spacing: .05em; color: var(--se-muted); white-space: nowrap; flex: none; }
.th-del { background: none; border: 0; color: var(--se-muted); padding: .15rem .3rem;
  cursor: pointer; flex: none; line-height: 1; }
.th-del:hover { color: #e03131; }
.th-body { padding: 0 .9rem .9rem 2rem; }
@media (max-width: 520px) { .th-meta { display: none; } }

/* Markdown rendered inside the explanation sections (deeper/why-correct/etc.) */
.study .se-callout p, .study .se-principle p, .study .se-body p,
.study .se-deeper p { margin: 0 0 .75rem; }
.study .se-callout p:last-child, .study .se-principle p:last-child,
.study .se-body p:last-child, .study .se-deeper p:last-child { margin-bottom: 0; }
.study ul, .study ol { margin: 0 0 .75rem 1.15rem; padding: 0; }
.study ul.se-why { margin: 0 0 .4rem; padding: 0; list-style: none; }
.study li { margin-bottom: .2rem; }
.study code { background: rgba(0,0,0,.06); padding: .08em .35em; border-radius: .25rem;
  font-family: var(--se-mono); font-size: .88em; }
.dark-mode .study code, body.dark-mode .study code { background: rgba(255,255,255,.12); }

/* Answer review: an explanation diagram shrinks to its card. Some are drawn 640 px wide; at 390 one
   widened the whole page to 730 px and pushed the full-size view's Close button off screen
   (independent review v4, rank 3). */
.rv-diagram svg { max-width: 100%; height: auto; display: block; margin: 0 auto; }

/* Instant feedback on phones: the panel sits inside the question card, so two cards' padding left
   "why the other options are wrong" about 145 px wide at 390 (independent review v4, rank 8).
   Under 576 px the panel uses the question card's inner padding and keeps one thin layer of its own. */
@media (max-width: 575.98px) {
  #quiz-feedback-container { margin-left: -1rem; margin-right: -1rem; }
  #quiz-feedback-panel { padding: 0; }
  #quiz-feedback-panel > .card-header { padding: .6rem .75rem; }
  #quiz-feedback-panel > .card-body { padding: .75rem !important; }   /* base.html sets 1rem !important */
}
