:root {
  color-scheme: light;
  --ink: #17211f;
  --muted: #5f6f69;
  --line: #dbe5df;
  --paper: #f7faf7;
  --panel: #ffffff;
  --mint: #2f8f74;
  --mint-dark: #1e6654;
  --mint-pale: #e4f2ec;
  --coral: #b94b2d;
  --coral-pale: #faeae5;
  --gold: #806014;
  --gold-pale: #f8f0d8;
  --shadow: 0 18px 48px rgba(23, 33, 31, 0.08);
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: var(--paper); color: var(--ink); font-family: "Segoe UI Variable", "Segoe UI", sans-serif; }
button, input { font: inherit; }
button { cursor: pointer; }
a { color: inherit; }
.hidden { display: none !important; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

button:focus-visible, a:focus-visible, input:focus-visible, summary:focus-visible {
  outline: 3px solid rgba(47, 143, 116, 0.28);
  outline-offset: 3px;
}

.report-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 76px;
  padding: 14px clamp(20px, 4vw, 64px);
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.94);
}

.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; }
.brand-mark { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 8px; background: var(--mint); color: white; font-weight: 850; }
.brand strong, .brand small { display: block; }
.brand small { margin-top: 2px; color: var(--muted); }
.header-actions { display: flex; align-items: center; gap: 12px; }
.freshness { color: var(--muted); font-size: 14px; }

.refresh-button, .tutor-link, .empty-state button, .error-state button, .login-box button {
  min-height: 42px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--ink);
  font-weight: 750;
  text-decoration: none;
}

.refresh-button { display: inline-flex; align-items: center; gap: 8px; }
.refresh-button svg { width: 17px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.refresh-button:hover { background: #f0f5f2; }
.refresh-button:disabled { cursor: wait; opacity: 0.6; }
.tutor-link { display: inline-grid; place-items: center; border-color: var(--mint); background: var(--mint); color: white; }
.tutor-link:hover { background: var(--mint-dark); }

.report { width: min(1240px, calc(100% - 40px)); margin: 0 auto; padding: 54px 0 72px; }
.report-intro { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(260px, 0.7fr); align-items: end; gap: 48px; padding-bottom: 30px; }
h1, h2, p, dl { margin: 0; }
h1 { max-width: 760px; font-size: clamp(34px, 5vw, 64px); line-height: 1.02; letter-spacing: -0.035em; }
.report-intro > div > p { margin-top: 14px; color: var(--muted); font-size: 17px; }
.method-note { max-width: 42ch; color: var(--muted); line-height: 1.55; }

.summary { min-width: 0; overflow: hidden; border-radius: 14px; background: var(--ink); color: white; box-shadow: var(--shadow); }
.verdict { padding: clamp(26px, 4vw, 48px); }
.verdict-label { display: block; margin-bottom: 10px; color: #b9cbc5; font-size: 13px; font-weight: 750; text-transform: uppercase; }
.verdict h2 { max-width: 850px; font-size: clamp(26px, 3vw, 42px); line-height: 1.12; letter-spacing: -0.025em; }
.verdict p { max-width: 72ch; margin-top: 14px; color: #d2dfdb; line-height: 1.55; }
.verdict[data-tone="attention"] { background: #512a20; }
.verdict[data-tone="positive"] { background: #173e34; }

.fact-strip { display: grid; grid-template-columns: repeat(4, 1fr); border-top: 1px solid #3b4744; }
.fact-strip > div { padding: 20px clamp(18px, 3vw, 34px); }
.fact-strip > div + div { border-left: 1px solid #3b4744; }
.fact-strip dt { color: #b9cbc5; font-size: 13px; }
.fact-strip dd { margin: 7px 0 0; font-size: clamp(20px, 2vw, 28px); font-weight: 800; }

.report-section { margin-top: 52px; }
.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 24px; margin-bottom: 20px; }
.section-heading h2 { font-size: clamp(24px, 3vw, 34px); letter-spacing: -0.025em; }
.section-heading p { max-width: 50ch; color: var(--muted); line-height: 1.45; text-align: right; }

.exam-report {
  padding: 26px 0 4px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.exam-report .section-heading > div p {
  margin-top: 7px;
  text-align: left;
}

.exam-score {
  flex: 0 0 auto;
  padding: 8px 11px;
  border-radius: 999px;
  background: var(--gold-pale);
  color: var(--gold);
  font-size: 14px;
}

.exam-score[data-status="completed"] {
  background: var(--mint-pale);
  color: var(--mint-dark);
}

.exam-report-body > p {
  max-width: 72ch;
  margin-bottom: 16px;
  color: var(--muted);
  line-height: 1.55;
}

.exam-report-topics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  column-gap: 28px;
}

.exam-report-topic {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  padding: 12px 0;
  border-top: 1px solid var(--line);
}

.exam-report-topic strong[data-outcome="correct"] { color: var(--mint-dark); }
.exam-report-topic strong[data-outcome="incorrect"] { color: var(--coral); }

.exam-history {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}

.exam-history-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 8px;
}

.exam-history-heading h3 { font-size: 18px; }
.exam-history-heading p { color: var(--muted); font-size: 13px; }
.exam-history-list, .exam-answer-list { margin: 0; padding: 0; list-style: none; }
.exam-history-item { border-top: 1px solid var(--line); }

.exam-history-attempt > summary,
.exam-history-static {
  min-height: 56px;
  padding: 12px 0;
}

.exam-history-attempt > summary { cursor: pointer; }
.exam-history-attempt > summary::marker { color: var(--mint-dark); }

.exam-history-summary {
  display: inline-grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 18px;
  width: calc(100% - 22px);
  vertical-align: middle;
}

.exam-history-static .exam-history-summary { width: 100%; }

.exam-history-meta {
  color: var(--muted);
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.exam-history-summary strong {
  color: var(--ink);
  font-size: 14px;
  white-space: nowrap;
}

.exam-answer-list { padding: 0 0 10px 22px; }
.exam-answer { padding: 18px 0; border-top: 1px solid var(--line); }
.exam-answer h4 { font-size: 16px; line-height: 1.35; }
.exam-answer-prompt { max-width: 72ch; margin-top: 8px; line-height: 1.55; overflow-wrap: anywhere; }

.exam-answer-facts {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(170px, 0.38fr);
  gap: 14px 24px;
  margin: 14px 0 0;
}

.exam-answer-facts div { min-width: 0; }
.exam-answer-facts dt { color: var(--muted); font-size: 12px; font-weight: 750; }
.exam-answer-facts dd { margin: 5px 0 0; line-height: 1.45; overflow-wrap: anywhere; }
.exam-answer-facts dd[data-outcome="correct"] { color: var(--mint-dark); font-weight: 750; }
.exam-answer-facts dd[data-outcome="incorrect"] { color: var(--coral); font-weight: 750; }
.exam-answer-feedback { max-width: 72ch; margin-top: 12px; color: var(--muted); line-height: 1.5; overflow-wrap: anywhere; }

.topic-head, .topic-row { display: grid; grid-template-columns: minmax(230px, 1.2fr) minmax(250px, 1.4fr) minmax(180px, 0.7fr); gap: 24px; align-items: center; }
.topic-head { padding: 0 18px 10px; color: var(--muted); font-size: 12px; font-weight: 750; text-transform: uppercase; }
.topic-row { padding: 18px; border-top: 1px solid var(--line); background: rgba(255, 255, 255, 0.55); }
.topic-row:last-child { border-bottom: 1px solid var(--line); }
.topic-name strong { display: block; line-height: 1.3; }
.topic-name small { display: block; margin-top: 6px; color: var(--muted); }
.topic-reason { color: var(--muted); line-height: 1.45; }
.status { justify-self: start; padding: 7px 10px; border-radius: 999px; background: #edf1ef; font-size: 13px; font-weight: 800; }
.status[data-status="Похоже, поняла"] { background: var(--mint-pale); color: var(--mint-dark); }
.status[data-status="Есть трудности"] { background: var(--coral-pale); color: var(--coral); }
.status[data-status="В процессе"] { background: var(--gold-pale); color: var(--gold); }

.report-grid { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(340px, 0.95fr); gap: 48px; }
.activity-chart { display: grid; grid-template-columns: repeat(14, minmax(12px, 1fr)); align-items: end; gap: 8px; min-height: 238px; padding-top: 28px; border-bottom: 1px solid var(--line); }
.activity-day { display: grid; grid-template-rows: 1fr auto; align-items: end; gap: 9px; height: 210px; text-align: center; }
.activity-bar-wrap { display: flex; align-items: end; justify-content: center; height: 100%; }
.activity-bar { width: min(24px, 75%); height: 100%; min-height: 2px; background: var(--mint); border-radius: 5px 5px 0 0; transform: scaleY(var(--bar-scale, 0.01)); transform-origin: bottom; transition: transform 420ms cubic-bezier(.16,1,.3,1); }
.activity-day time { color: var(--muted); font-size: 11px; }

.effectiveness-title { align-items: center; }
.effectiveness-title strong { padding: 8px 11px; border-radius: 999px; background: var(--gold-pale); color: var(--gold); font-size: 13px; }
.evidence-list { border-top: 1px solid var(--line); }
.evidence-list > div { display: grid; grid-template-columns: 150px 1fr; gap: 22px; padding: 15px 0; border-bottom: 1px solid var(--line); }
.evidence-list dt { font-weight: 750; }
.evidence-list dd { margin: 0; color: var(--muted); line-height: 1.45; }

.methodology { margin-top: 52px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.methodology summary { padding: 18px 0; cursor: pointer; font-weight: 800; }
.methodology ul { max-width: 82ch; margin: 0 0 22px; padding-left: 21px; color: var(--muted); line-height: 1.55; }
.methodology li + li { margin-top: 8px; }

.empty-state, .error-state { max-width: 740px; padding: 38px; border-radius: 14px; background: white; box-shadow: var(--shadow); }
.empty-state h2, .error-state h2 { font-size: 28px; }
.empty-state p, .error-state p { margin: 12px 0 22px; color: var(--muted); line-height: 1.55; }
.empty-state button, .error-state button, .login-box button { border-color: var(--mint); background: var(--mint); color: white; }

.login-overlay { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: 20px; background: rgba(247, 250, 247, 0.96); }
.login-box { display: grid; gap: 14px; width: min(400px, 100%); padding: 30px; border-radius: 14px; background: white; box-shadow: var(--shadow); }
.login-box h2 { font-size: 28px; }
.login-box p { color: var(--muted); line-height: 1.5; }
.login-box label { font-size: 13px; font-weight: 750; }
.login-box input { min-height: 46px; padding: 11px 12px; border: 1px solid var(--line); border-radius: 8px; }
.login-error { min-height: 20px; color: var(--coral); font-size: 14px; }

.learning-settings {
  display: grid;
  grid-template-columns: minmax(240px, 0.8fr) minmax(480px, 1.2fr);
  align-items: center;
  gap: 24px 38px;
  margin-top: 28px;
  padding: 22px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.learning-settings h2 { font-size: 22px; letter-spacing: -0.015em; }
.learning-settings > div p { max-width: 54ch; margin-top: 7px; color: var(--muted); line-height: 1.45; }
.difficulty-options { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; min-width: 0; margin: 0; padding: 5px; border: 1px solid var(--line); border-radius: 12px; background: #edf2ef; }
.difficulty-options label { position: relative; min-width: 0; cursor: pointer; }
.difficulty-options input { position: absolute; opacity: 0; pointer-events: none; }
.difficulty-options span { display: grid; align-content: center; min-height: 62px; padding: 9px 11px; border-radius: 8px; color: var(--muted); font-weight: 750; text-align: center; }
.difficulty-options small { display: block; margin-top: 3px; font-size: 11px; font-weight: 400; line-height: 1.25; }
.difficulty-options input:checked + span { background: white; color: var(--ink); box-shadow: 0 5px 16px rgba(23, 33, 31, 0.08); }
.difficulty-options input:focus-visible + span { outline: 3px solid rgba(47, 143, 116, 0.28); outline-offset: 2px; }
.difficulty-options input:disabled + span { cursor: wait; opacity: 0.55; }
.setting-status { grid-column: 2; min-height: 18px; color: var(--muted); font-size: 13px; }
.setting-status.error { color: var(--coral); }

@media (max-width: 900px) {
  .report-header { align-items: flex-start; }
  .header-actions { flex-wrap: wrap; justify-content: flex-end; }
  .freshness { width: 100%; text-align: right; }
  .report-intro, .report-grid { grid-template-columns: 1fr; gap: 18px; }
  .learning-settings { grid-template-columns: 1fr; }
  .setting-status { grid-column: 1; }
  .method-note { max-width: 65ch; }
  .section-heading { align-items: start; flex-direction: column; }
  .section-heading p { text-align: left; }
  .report-grid { gap: 0; }
}

@media (max-width: 680px) {
  .report-header { display: block; padding: 14px 16px; }
  .header-actions { justify-content: flex-start; margin-top: 14px; }
  .freshness { width: 100%; text-align: left; }
  .report { width: min(100% - 32px, 1240px); padding-top: 34px; }
  .report-intro { padding-bottom: 22px; }
  .fact-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .fact-strip > div { min-width: 0; padding: 18px; }
  .fact-strip dd { overflow-wrap: anywhere; }
  .fact-strip > div + div { border-left: 0; }
  .fact-strip > div:nth-child(even) { border-left: 1px solid #3b4744; }
  .fact-strip > div:nth-child(n+3) { border-top: 1px solid #3b4744; }
  .topic-head { display: none; }
  .topic-row { grid-template-columns: 1fr; gap: 10px; padding: 16px 0; background: transparent; }
  .exam-report-topics { grid-template-columns: 1fr; }
  .exam-report-topic { align-items: flex-start; }
  .exam-history-heading { align-items: flex-start; flex-direction: column; gap: 4px; }
  .exam-history-summary { grid-template-columns: 1fr; gap: 5px; }
  .exam-history-summary strong { white-space: normal; }
  .exam-answer-list { padding-left: 0; }
  .exam-answer-facts { grid-template-columns: 1fr; }
  .topic-reason { max-width: 58ch; }
  .activity-chart { gap: 4px; }
  .activity-day time { font-size: 9px; }
  .evidence-list > div { grid-template-columns: 1fr; gap: 5px; }
  .difficulty-options { grid-template-columns: 1fr; }
  .difficulty-options span { min-height: 54px; text-align: left; }
  .empty-state, .error-state { padding: 26px; }
}

@media (prefers-reduced-motion: reduce) { .activity-bar { transition: none; } }
