/* Quest Teacher v2 — "Results" view (results.js) */

#resultsView { display: none; max-width: 1160px; margin: 0 auto; }
body.results-open #resultsView { display: block; }

.rvHead { margin: 0 0 18px; }
.rvTitle { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.rvTitle h2 { font-size: 22px; line-height: 1.25; }
.rvSub { font-size: 12.5px; color: var(--muted); }

.rvKpis { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin-bottom: 14px; }
.rvKpi {
  display: flex; flex-direction: column; gap: 6px; min-width: 0;
  padding: 14px 16px 16px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface);
}
.rvKpi .k { font-size: 12.5px; font-weight: 500; color: var(--muted); }
.rvKpi .v { font-size: 24px; font-weight: 600; letter-spacing: -.03em; line-height: 1.2; color: var(--ink); }
.rvKpi .v.small { font-family: var(--font); font-size: 16px; font-weight: 500; letter-spacing: -.01em; padding-top: 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rvKpi .s { font-size: 12.5px; color: var(--muted); }
.rvKpi .rvBar { margin-top: 6px; }
.rvKpis.compact { gap: 10px; }
.rvKpis.compact .rvKpi { padding: 12px 14px 14px; }
.rvKpis.compact .v { font-size: 26px; }

.rvBar { position: relative; display: block; height: 6px; border-radius: 3px; background: var(--surface-3); overflow: hidden; flex: 0 0 auto; }
.rvBar i { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 3px; background: var(--muted); }
.rvBar.ok i { background: #22b07d; }
.rvBar.mid i { background: #f0a92e; }
.rvBar.bad i { background: #ef5b61; }

#rvBody { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(0, 1fr); gap: 14px; align-items: start; }
.rvCard { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.rvCardHead { display: flex; align-items: baseline; gap: 8px; padding: 16px 18px 10px; }
.rvCardHead h3 { font-size: 13.5px; font-weight: 600; color: var(--ink); }
.rvCardHead .mono { font-size: 12px; color: var(--muted); }
.rvLoading { grid-column: 1 / -1; display: flex; flex-direction: column; gap: 14px; padding: 22px; }

.rvTableWrap { overflow-x: auto; }
.rvTable { width: 100%; border-collapse: collapse; }
.rvTable th {
  text-align: left; padding: 8px 18px; font-family: var(--mono); font-weight: 500; font-size: 11px;
  letter-spacing: .06em; text-transform: uppercase; color: var(--muted); border-bottom: 1px solid var(--line-2); white-space: nowrap;
}
.rvTable td { padding: 10px 18px; border-bottom: 1px solid var(--line-2); font-size: 13.5px; color: var(--text); vertical-align: middle; }
.rvTable tr:last-child td { border-bottom: 0; }
.rvTable tr.clickable { cursor: pointer; transition: background .12s ease; }
.rvTable tr.clickable:hover td, .rvTable tr.clickable:focus-visible td { background: var(--surface-2); outline: none; }
.rvTable .rvNum { text-align: right; width: 1%; white-space: nowrap; }
.rvName { font-weight: 500; }
td.rvName > span:last-child { vertical-align: middle; }
.rvName .avatar { width: 28px; height: 28px; font-size: 10.5px; margin-right: 10px; vertical-align: middle; }
.rvAcc { width: 34%; min-width: 150px; }
.rvAcc > div { display: flex; align-items: center; gap: 10px; }
.rvAcc .rvBar { flex: 1; }
.rvAcc .mono { width: 40px; text-align: right; font-size: 12.5px; color: var(--text-2); }
.rvLast { color: var(--text-2); white-space: nowrap; font-size: 13px; }
.rvLast.stale { color: var(--muted); }

.rvMistakes { display: flex; flex-direction: column; padding: 0 8px 8px; }
.rvMistake { padding: 12px 10px; border-top: 1px solid var(--line-2); }
.rvMistake:first-child { border-top: 0; }
.rvMistakeTop { display: flex; align-items: flex-start; gap: 12px; }
.rvMistakeTop .q { flex: 1; min-width: 0; font-size: 13.5px; font-weight: 500; color: var(--text); line-height: 1.45; white-space: pre-line; word-break: break-word; }
.rvCount {
  flex: 0 0 auto; min-width: 26px; height: 22px; padding: 0 7px; border-radius: 3px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--red-soft); color: var(--red-ink); font-size: 12px; font-weight: 500;
}
.rvMistakeMeta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 7px; }
.rvRight, .rvWrong {
  display: inline-flex; align-items: center; gap: 5px; height: 24px; padding: 0 9px; border-radius: 6px; font-size: 12.5px;
  max-width: 100%; min-width: 0; overflow: hidden; white-space: nowrap;
}
.rvRight { background: var(--green-soft); color: var(--t4-ink); font-weight: 500; text-overflow: ellipsis; display: inline-block; line-height: 24px; }
.rvRight::before { content: "✓ "; font-size: 11px; }
.rvWrong { background: var(--surface-3); color: var(--text-2); max-width: 220px; }
.rvWrong s { min-width: 0; overflow: hidden; text-overflow: ellipsis; text-decoration-color: rgba(229, 72, 77, .6); }
.rvWrong b { flex: 0 0 auto; font-weight: 500; color: var(--muted); }

.rvEmpty { padding: 28px 18px 30px; text-align: center; color: var(--muted); font-size: 13px; }
.rvEmpty strong { display: block; color: var(--text-2); font-weight: 500; font-size: 13.5px; }
.rvEmpty p { margin-top: 6px; }

/* drawer */
.rvDrawerBack { position: fixed; inset: 0; z-index: 150; background: rgba(15, 20, 30, .22); backdrop-filter: blur(3px); opacity: 0; pointer-events: none; transition: opacity .18s ease; }
.rvDrawerBack.open { opacity: 1; pointer-events: auto; }
.rvDrawer {
  position: fixed; top: 10px; right: 10px; bottom: 10px; z-index: 160; width: min(520px, calc(100vw - 20px));
  display: flex; flex-direction: column; background: var(--frame); border-radius: 12px; box-shadow: var(--shadow-pop);
  transform: translateX(calc(100% + 20px)); transition: transform .24s cubic-bezier(.2, .9, .3, 1);
}
.rvDrawer.open { transform: none; }
.rvDrawerHead { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 16px 12px 20px; }
.rvDrawerHead h3 { display: flex; align-items: center; gap: 12px; font-size: 17px; font-weight: 600; color: var(--ink); min-width: 0; }
.rvDrawerBody { flex: 1; min-height: 0; overflow-y: auto; padding: 4px 16px 18px; display: flex; flex-direction: column; gap: 12px; }
.rvDrawerBody .rvKpis { margin-bottom: 0; }
.rvDrawerBody > * { flex-shrink: 0; }

@media (max-width: 1100px) {
  #rvBody { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  #resultsView { padding: 14px 16px 20px; }
  .rvKpis { grid-template-columns: 1fr 1fr; }
  .rvKpi .v { font-size: 28px; }
  .rvViewSeg span { display: none; }
}
@media (max-width: 560px) {
  .rvKpis { grid-template-columns: 1fr; }
  .rvDrawer { top: auto; left: 0; right: 0; bottom: 0; width: 100%; height: 88vh; border-radius: 12px 12px 0 0; transform: translateY(100%); }
  .rvDrawer.open { transform: none; }
}

/* warm & soft */
.rvTitle h2 { font-family: var(--serif); font-size: 36px; font-weight: 400; line-height: 1.1; }
.rvKpi, .rvCard { border-radius: 18px; }
.rvKpi .v { font-family: var(--serif); font-weight: 400; font-size: 34px; letter-spacing: -.02em; }

.rvTitle h2 { font-family: var(--font); font-weight: 600; font-size: 28px; letter-spacing: -.025em; }
.rvKpi .v { font-family: var(--font); font-weight: 600; font-size: 26px; letter-spacing: -.03em; }
.rvTitle h2 { font-size: 31px; }
.rvKpi .v { font-size: 29px; }
.rvKpi .k { font-size: 13.5px; }
