.qb-panel {
  --qb-ink: #182b4b;
  --qb-muted: #536782;
  --qb-border: #dce5f1;
  --qb-accent: #164b95;
  --qb-blue: #edf5ff;
  max-width: 1260px;
  min-width: 0;
}

.qb-head,
.qb-actions,
.qb-filter-strip,
.qb-filter-tabs,
.qb-card-top,
.qb-card-foot,
.qb-tags,
.qb-pager,
.qb-dialog-head {
  display: flex;
  align-items: center;
  gap: 8px;
}

.qb-head,
.qb-filter-strip,
.qb-card-top {
  justify-content: space-between;
}

.qb-head,
.qb-actions,
.qb-filter-strip,
.qb-filter-tabs,
.qb-card-foot,
.qb-tags {
  flex-wrap: wrap;
}

.qb-head {
  margin: 0 0 8px;
}

.qb-head h2,
.qb-dialog-head h2 {
  margin: 0;
  color: var(--qb-ink, #182b4b);
  font-size: clamp(1.18rem, 2vw, 1.48rem);
  line-height: 1.3;
}

.qb-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 7px;
  margin-bottom: 10px;
}

.qb-metrics article {
  min-width: 0;
  padding: 9px 10px;
  border: 1px solid var(--qb-border);
  border-radius: 10px;
  background: #fff;
}

.qb-metrics h3 {
  min-height: 1.4em;
  margin: 0;
  color: var(--qb-muted);
  font-size: 13px;
  font-weight: 650;
  line-height: 1.4;
}

.qb-metrics article > strong {
  display: block;
  margin: 1px 0;
  color: var(--qb-ink);
  font-size: 24px;
  line-height: 1.3;
  font-variant-numeric: tabular-nums;
}

.qb-metrics p,
.qb-hint,
.qb-message {
  margin: 5px 0;
  color: var(--qb-muted, #536782);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.qb-good,
.qb-metrics article > strong.qb-good {
  color: #147344;
}

.qb-bad {
  color: #b23934;
}

.qb-browser {
  margin-bottom: 8px;
  padding: 10px;
  border: 1px solid var(--qb-border);
  border-radius: 10px;
  background: #fff;
}

.qb-facets {
  display: grid;
  grid-template-columns: minmax(80px, .75fr) minmax(84px, .75fr) repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.qb-field,
.qb-answer-label {
  display: grid;
  gap: 3px;
  min-width: 0;
  color: var(--qb-muted, #536782);
  font-size: 13px;
  font-weight: 700;
}

.qb-field select,
.qb-answer-label textarea {
  width: 100%;
  min-width: 0;
}

.qb-field select {
  height: 35px;
}

.qb-filter-strip {
  margin-top: 8px;
}

.qb-filter-strip > span {
  color: var(--qb-muted);
  font-size: 13px;
}

.qb-filter-tabs {
  gap: 4px;
}

.qb-filter-tabs button {
  min-height: 34px;
  padding: 4px 8px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: var(--qb-muted);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}

.qb-filter-tabs button:hover,
.qb-filter-tabs button[aria-pressed="true"] {
  border-color: #cbddf4;
  background: var(--qb-blue);
  color: var(--qb-accent);
}

.qb-selection,
.qb-pager {
  margin-bottom: 8px;
}

.qb-selection > span,
.qb-pager > span {
  color: var(--qb-muted);
  font-size: 13px;
}

.qb-pager {
  justify-content: center;
  margin-top: 8px;
}

.qb-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr));
  gap: 8px;
  padding: 0;
  margin: 0;
  list-style: none;
}

.qb-question {
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 6px;
  min-width: 0;
  padding: 9px 10px;
  border: 1px solid var(--qb-border);
  border-radius: 9px;
  background: #fff;
}

.qb-card-top label,
.qb-tags,
.qb-card-foot {
  color: var(--qb-muted);
  font-size: 12px;
}

.qb-card-top label {
  white-space: nowrap;
}

.qb-card-foot > span {
  flex: 1 1 112px;
  min-width: 0;
  overflow-wrap: anywhere;
}

.qb-question-stem {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  align-self: start;
  min-width: 0;
  padding: 2px 0;
  overflow: hidden;
  border: 0;
  background: none;
  color: var(--qb-ink);
  font: inherit;
  line-height: 1.5;
  text-align: start;
  overflow-wrap: anywhere;
  cursor: pointer;
}

.qb-question-stem:hover {
  color: var(--qb-accent);
}

.qb-tag {
  display: inline-flex;
  padding: 2px 5px;
  border-radius: 5px;
  background: #eff4fa;
  color: #39536f;
  font-size: 12px;
  font-weight: 700;
}

.qb-tag-mother {
  background: #e9f3ff;
  color: #184d8f;
}

.qb-tag-wrong {
  background: #fff0ed;
  color: #a33427;
}

.qb-tag-correct {
  background: #e8f7ed;
  color: #196a41;
}

.qb-empty {
  padding: 13px;
  margin: 7px 0;
  border: 1px dashed var(--qb-border);
  border-radius: 8px;
  color: var(--qb-muted);
}

.qb-dialog {
  width: min(92vw, 850px);
  max-height: min(90vh, 870px);
  padding: 0;
  border: 1px solid #dce5f1;
  border-radius: 13px;
  background: #fff;
  color: #182b4b;
}

.qb-dialog::backdrop {
  background: rgb(15 27 48 / 52%);
}

.qb-dialog-head {
  position: sticky;
  z-index: 1;
  top: 0;
  justify-content: space-between;
  padding: 10px 13px;
  border-bottom: 1px solid #dce5f1;
  background: #fff;
}

.qb-dialog-head button {
  flex: none;
}

.qb-dialog-body {
  padding: 12px 13px;
}

.qb-attempt,
.qb-result {
  min-width: 0;
  margin: 0 0 12px;
  padding: 10px;
  border: 1px solid #dce5f1;
  border-radius: 9px;
}

.qb-option-list,
.qb-choice-list {
  margin: 5px 0;
  overflow-wrap: anywhere;
}

.qb-choice-list label {
  display: flex;
  gap: 6px;
  align-items: baseline;
  padding: 6px;
  border-bottom: 1px solid #eef2f7;
}

.qb-full-stem,
.qb-analysis p,
.qb-passage p {
  margin: 5px 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.qb-result h3,
.qb-analysis h4 {
  margin: 4px 0;
  font-size: 15px;
}

.qb-figure {
  display: block;
  max-width: 100%;
  max-height: 320px;
  margin: 5px 0;
  object-fit: contain;
}

.qb-analysis details,
.qb-writing,
.qb-self-check,
.qb-result > details {
  margin: 6px 0;
  padding: 4px 7px;
  border: 1px solid #e3eaf3;
  border-radius: 6px;
}

.qb-note {
  background: #fff8ed;
}

.qb-dialog summary {
  cursor: pointer;
  font-weight: 700;
}

.qb-writing [data-hw-wrap] {
  min-height: 150px;
  margin: 6px 0;
}

.qb-offline-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(92px, 1fr));
  gap: 6px;
}

.qb-offline-grid label {
  padding: 5px;
  border: 1px solid #dce5f1;
  border-radius: 6px;
  cursor: pointer;
}

.qb-results-status {
  margin: 0 0 9px;
  padding: 7px 9px;
  border-radius: 7px;
  background: #eef6ff;
  font-weight: 700;
}

.qb-share-card {
  padding: 10px;
  margin-bottom: 9px;
  border: 1px solid #dce5f1;
  border-radius: 9px;
}

.qb-share-card dl {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  margin: 7px 0;
}

.qb-share-card dl div {
  padding: 7px;
  border-radius: 7px;
  background: #eef5ff;
}

.qb-share-card dd {
  margin: 0;
  font-weight: 750;
}

.qb-share-card h3,
.qb-share-card p {
  margin: 3px 0;
}

.qb-panel :is(button, select, input):focus-visible,
.qb-dialog :is(button, summary, input, textarea):focus-visible {
  outline: 2px solid #1c62bd;
  outline-offset: 2px;
}

@media (max-width: 680px) {
  .qb-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .qb-facets {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media print {
  body.qbank-printing .v2-main {
    display: none !important;
  }
}
