/* Unified workspace: one navigation tree and one question renderer for both banks. */

.library-tree {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 2px 12px 18px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.24) transparent;
}

.library-group {
  margin-bottom: 8px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  background: rgba(3, 18, 31, 0.1);
  overflow: hidden;
}

.library-group.active {
  border-color: rgba(135, 193, 255, 0.22);
  background: rgba(3, 18, 31, 0.18);
}

.library-group-trigger {
  width: 100%;
  min-height: 64px;
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto 16px;
  align-items: center;
  gap: 9px;
  padding: 10px 11px;
  border: 0;
  color: rgba(255, 255, 255, 0.76);
  background: transparent;
  cursor: pointer;
  text-align: left;
}

.library-group-trigger:hover { color: #ffffff; background: rgba(255, 255, 255, 0.06); }
.library-group-trigger:focus-visible { outline: 3px solid rgba(255, 255, 255, 0.4); outline-offset: -3px; }
.library-group.active > .library-group-trigger { color: #ffffff; }

.library-group-icon {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  color: rgba(255, 255, 255, 0.86);
  background: rgba(255, 255, 255, 0.1);
}

.library-group.active .library-group-icon { color: #143a5b; background: #ffffff; }
.library-group-icon svg,
.library-chevron { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.library-group-copy { min-width: 0; display: grid; line-height: 1.35; }
.library-group-copy strong { font-size: 13px; font-weight: 730; }
.library-group-copy small { overflow: hidden; color: rgba(255, 255, 255, 0.47); font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.library-group-count { padding: 2px 6px; border-radius: 999px; color: rgba(255, 255, 255, 0.58); background: rgba(255, 255, 255, 0.08); font-size: 10px; font-weight: 720; white-space: nowrap; }
.library-chevron { color: rgba(255, 255, 255, 0.45); transition: transform 150ms ease; }
.library-group-trigger[aria-expanded="true"] .library-chevron { transform: rotate(180deg); }

.library-children { padding: 2px 6px 8px; border-top: 1px solid rgba(255, 255, 255, 0.07); }
.library-children .chapter-list { flex: none; overflow: visible; padding: 4px 0 0; }
.library-children .chapter-button,
.library-overview-button { min-height: 43px; grid-template-columns: 27px minmax(0, 1fr) auto; padding: 7px 8px; }
.library-overview-button {
  width: 100%;
  display: grid;
  align-items: center;
  gap: 9px;
  margin-top: 4px;
  border: 0;
  border-radius: 10px;
  color: rgba(255, 255, 255, 0.72);
  background: transparent;
  cursor: pointer;
  text-align: left;
}
.library-overview-button:hover { color: #ffffff; background: rgba(255, 255, 255, 0.08); }
.library-overview-button.active { color: #ffffff; background: rgba(255, 255, 255, 0.14); box-shadow: inset 3px 0 0 #7ab8ff; }
.library-overview-button.active .chapter-index { color: var(--navy-900); background: #ffffff; }

.library-tools {
  flex: 0 0 auto;
  margin: 0 12px 10px;
  padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.library-tools-label {
  padding: 0 7px 7px;
  color: rgba(255, 255, 255, 0.46);
  font-size: 10px;
  font-weight: 720;
  letter-spacing: 0.12em;
}

.library-tool-link {
  min-height: 58px;
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
  padding: 9px 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 13px;
  color: rgba(255, 255, 255, 0.76);
  background: rgba(3, 18, 31, 0.12);
  text-decoration: none;
}

.library-tool-link:hover { color: #ffffff; background: rgba(255, 255, 255, 0.08); }
.library-tool-link:focus-visible { outline: 3px solid rgba(255, 255, 255, 0.4); outline-offset: 2px; }
.library-tool-link.active { color: var(--navy-950); border-color: rgba(255, 255, 255, 0.88); background: #ffffff; box-shadow: 0 9px 22px rgba(2, 20, 34, 0.2); }
.library-tool-link.active .library-group-icon { color: #2563eb; background: #edf4ff; }
.library-tool-link.active .library-group-copy small { color: #6d7b8a; }

.library-tool-count {
  min-width: 27px;
  padding: 3px 7px;
  border-radius: 999px;
  color: #dcecff;
  background: rgba(122, 184, 255, 0.17);
  font-size: 11px;
  font-weight: 760;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.library-tool-link.active .library-tool-count { color: #1d5faf; background: #e9f2ff; }
.mistakes-storage-notice { margin: 0 12px 10px; padding: 9px 10px; border: 1px solid rgba(240, 182, 77, 0.35); border-radius: 10px; color: #ffe1a8; background: rgba(92, 57, 4, 0.25); font-size: 10px; line-height: 1.5; }
.mistakes-page .workspace-shortcuts { flex: 0 0 auto; overflow: visible; padding-bottom: 2px; }
.library-navigation-link { grid-template-columns: 34px minmax(0, 1fr) auto; text-decoration: none; }

.inline-analysis {
  margin-top: 24px;
  padding: 20px;
  border: 1px solid var(--line-100);
  border-radius: 14px;
  background: var(--surface-soft);
  scroll-margin-block: 92px 85px;
}
.inline-analysis:focus { outline: none; }
.inline-analysis .result-banner {
  gap: 10px;
  margin: 0;
  padding: 0 0 14px;
  border: 0;
  border-bottom: 1px solid var(--line-100);
  border-radius: 0;
  background: transparent;
}
.inline-analysis .result-icon { width: 25px; height: 25px; font-size: 13px; }
.inline-analysis .result-title { font-size: 14px; }
.inline-analysis .analysis-card { padding: 0; border: 0; background: transparent; grid-template-columns: 32px minmax(0, 1fr); gap: 12px; }
.inline-analysis .analysis-card-icon { width: 32px; height: 32px; }
.inline-analysis .analysis-card h3 { margin: 4px 0 10px; font-size: 14px; }
.inline-analysis .reasoning-list { gap: 10px; }
.inline-analysis .reasoning-item { font-size: 14px; line-height: 1.85; }
.inline-analysis .original-analysis { margin-top: 14px; }
.inline-analysis .original-analysis summary { padding-top: 12px; }

.topbar-heading { min-width: 0; }
.topbar-actions { display: flex; align-items: center; justify-content: flex-end; gap: 10px; flex: 0 0 auto; }
.topbar-status {
  padding: 7px 10px;
  border: 1px solid #cbd9e8;
  border-radius: 999px;
  color: var(--navy-800);
  background: var(--blue-50);
  font-size: 12px;
  font-weight: 680;
  white-space: nowrap;
}
.topbar-primary { min-height: 42px; padding-inline: 15px; }

.collection-view {
  width: min(100% - 48px, 980px);
  margin: 34px auto 80px;
}

.collection-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 17px;
  padding: 0 2px;
}

.collection-heading h1 { margin: 3px 0 4px; font-size: clamp(23px, 2.5vw, 30px); line-height: 1.3; }
.collection-heading p { margin: 0; color: var(--ink-500); font-size: 13px; }
.collection-total { flex: 0 0 auto; color: var(--ink-500); font-size: 12px; font-weight: 680; }

.set-list {
  overflow: hidden;
  border: 1px solid var(--line-200);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: var(--shadow-card);
}

.set-row {
  display: grid;
  grid-template-columns: minmax(210px, 1.2fr) minmax(170px, 0.8fr) auto;
  align-items: center;
  gap: 24px;
  min-height: 94px;
  padding: 17px 20px;
  border-bottom: 1px solid var(--line-100);
}
.set-row:last-child { border-bottom: 0; }
.set-row:hover { background: #fbfcfe; }
.set-row-heading { min-width: 0; display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 12px; }
.set-row-title { min-width: 0; }
.set-row-title h2 { overflow: hidden; margin: 0; font-size: 16px; line-height: 1.45; text-overflow: ellipsis; white-space: nowrap; }
.set-row-title p { margin: 3px 0 0; color: var(--ink-500); font-size: 11px; }
.set-status {
  min-width: 56px;
  padding: 5px 8px;
  border-radius: 999px;
  color: var(--ink-500);
  background: #eef2f6;
  font-size: 10px;
  font-weight: 740;
  text-align: center;
  white-space: nowrap;
}
.set-status.started { color: #1d5faf; background: #e9f2ff; }
.set-status.submitted { color: var(--green-700); background: var(--green-100); }
.set-progress { min-width: 0; display: grid; gap: 7px; }
.set-progress-copy { display: flex; justify-content: space-between; gap: 8px; color: var(--ink-500); font-size: 11px; }
.set-progress-track { height: 6px; overflow: hidden; border-radius: 999px; background: #e9eef4; }
.set-progress-fill { display: block; width: 0; height: 100%; border-radius: inherit; background: var(--blue-600); }
.set-row.submitted .set-progress-fill { background: var(--green-700); }
.set-row-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; }
.set-row-actions .button { min-height: 39px; padding: 7px 12px; font-size: 12px; }

.score-summary {
  display: grid;
  grid-template-columns: 1.3fr repeat(3, minmax(76px, 0.55fr)) minmax(180px, 1.4fr);
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  padding: 16px 18px;
  border: 1px solid #b9d7c8;
  border-radius: 17px;
  background: linear-gradient(105deg, #f1fbf6, #ffffff 62%);
  box-shadow: 0 10px 28px rgba(20, 112, 74, 0.08);
}
.score-summary:focus { outline: none; }
.score-main { display: grid; grid-template-columns: auto auto; align-items: baseline; column-gap: 8px; line-height: 1.15; }
.score-kicker { grid-column: 1 / -1; color: var(--green-700); font-size: 10px; font-weight: 760; letter-spacing: 0.1em; }
.score-main strong { color: var(--green-700); font-size: 30px; font-variant-numeric: tabular-nums; }
.score-main > span:last-child { color: var(--ink-500); font-size: 12px; font-weight: 650; }
.score-stat { display: grid; place-items: center; padding: 7px; border-left: 1px solid var(--line-100); line-height: 1.25; }
.score-stat span { color: var(--ink-500); font-size: 10px; }
.score-stat strong { margin-top: 2px; font-size: 18px; font-variant-numeric: tabular-nums; }
.score-stat.correct strong { color: var(--green-700); }
.score-stat.wrong strong { color: var(--red-700); }
.score-stat.unanswered strong { color: var(--amber-800); }
.score-summary > p { margin: 0; color: var(--ink-500); font-size: 11px; line-height: 1.55; }

.stem-images,
.option-images { display: grid; gap: 10px; margin-top: 14px; }
.option-text { min-width: 0; display: grid; gap: 9px; }
.question-image { margin: 0; }
.question-image img { display: block; max-width: min(100%, 720px); max-height: 440px; border: 1px solid var(--line-200); border-radius: 12px; background: #ffffff; object-fit: contain; }
.option-images .question-image img { max-height: 300px; }
.question-image figcaption { padding: 9px 11px; border: 1px solid #ecd386; border-radius: 10px; color: var(--amber-800); background: var(--amber-50); font-size: 12px; }

.question-number-button.status-answered { color: var(--blue-600); border-color: #b8d1f4; background: var(--blue-50); }
.legend-dot.answered { border-color: #85afe9; background: var(--blue-100); }
.legend-dot.unanswered { border-color: var(--line-200); background: #ffffff; }

.answer-correction-note {
  margin: 0 0 4px;
  padding: 10px 12px;
  border-left: 3px solid var(--amber-800);
  color: var(--amber-800);
  background: var(--amber-50);
  font-weight: 650;
}
.missing-explanation { color: var(--amber-800); }

.confirm-dialog {
  width: min(440px, calc(100vw - 32px));
  padding: 0;
  border: 0;
  border-radius: 18px;
  color: var(--ink-900);
  background: var(--surface);
  box-shadow: 0 26px 80px rgba(10, 29, 47, 0.3);
}
.confirm-dialog::backdrop { background: rgba(11, 29, 47, 0.5); backdrop-filter: blur(3px); }
.confirm-dialog form { padding: 24px; }
.confirm-icon { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 12px; color: var(--blue-600); background: var(--blue-50); font-size: 18px; font-weight: 780; }
.confirm-dialog h2 { margin: 15px 0 6px; font-size: 21px; }
.confirm-dialog p { margin: 0; color: var(--ink-500); line-height: 1.7; }
.confirm-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }
.button-danger { color: #ffffff; background: var(--red-700); box-shadow: 0 8px 18px rgba(180, 58, 67, 0.18); }
.button-danger:hover:not(:disabled) { background: #9f2f38; }

@media (max-width: 1050px) {
  .topbar-status { display: none; }
  .score-summary { grid-template-columns: 1.1fr repeat(3, minmax(64px, 0.5fr)); }
  .score-summary > p { display: none; }
  .set-row { grid-template-columns: minmax(220px, 1fr) minmax(150px, 0.65fr) auto; gap: 16px; }
}

@media (max-width: 900px) {
  .library-tree { padding-inline: 10px; }
  .library-tools { margin-inline: 10px; }
  .collection-view { width: min(100% - 34px, 900px); }
  .set-row { grid-template-columns: minmax(0, 1fr) auto; }
  .set-progress { grid-column: 1 / -1; grid-row: 2; }
  .set-row-actions { grid-column: 2; grid-row: 1; }
}

@media (max-width: 720px) {
  .inline-analysis { padding: 15px; margin-top: 20px; scroll-margin-top: 78px; }
  .inline-analysis .analysis-card { gap: 9px; grid-template-columns: 28px minmax(0, 1fr); }
  .inline-analysis .analysis-card-icon { width: 28px; height: 28px; border-radius: 8px; }
  .inline-analysis .result-detail { line-height: 1.6; }
  .topbar { align-items: center; }
  .topbar-actions { gap: 7px; }
  .topbar-primary { display: none !important; }
  .question-directory-control { flex: 0 0 auto; }
  .collection-view { width: 100%; margin: 0 auto 76px; padding: 22px 16px; }
  .collection-heading { align-items: flex-start; gap: 10px; }
  .collection-heading h1 { font-size: 22px; }
  .collection-total { padding-top: 4px; }
  .set-list { border-radius: 15px; }
  .set-row { grid-template-columns: 1fr; gap: 12px; min-height: 0; padding: 16px; }
  .set-row-heading,
  .set-progress,
  .set-row-actions { grid-column: 1; grid-row: auto; }
  .set-row-actions { justify-content: stretch; }
  .set-row-actions .button { flex: 1; }
  .score-summary { grid-template-columns: 1.2fr repeat(3, 0.65fr); margin: 0; border-width: 0 0 1px; border-radius: 0; box-shadow: none; }
  .score-summary > p { display: none; }
  .score-main strong { font-size: 25px; }
  .stem-images { margin-bottom: 18px; }
  .question-image img { max-height: 52vh; }
  .confirm-actions .button { width: auto; }
}

@media (max-width: 480px) {
  .collection-heading { display: block; }
  .collection-total { margin-top: 8px; }
  .set-row-heading { grid-template-columns: 1fr; gap: 7px; }
  .set-status { width: fit-content; }
  .score-summary { grid-template-columns: repeat(3, 1fr); gap: 7px; padding: 12px; }
  .score-main { grid-column: 1 / -1; display: flex; align-items: baseline; gap: 8px; }
  .score-kicker { grid-column: auto; }
  .score-stat { border-left: 0; border-top: 1px solid var(--line-100); }
  .question-id { max-width: 42vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}

@media (prefers-reduced-motion: reduce) {
  .library-chevron { transition-duration: 0.01ms !important; }
}
