/* Hộp «Xem đề» — chỉ dùng biến hệ thiết kế từ app.css */

.modal.wide.ep-modal {
  width: min(1040px, 94vw);
  max-width: 1040px;
  height: calc(100vh / var(--uiz, 1) - 48px);
  height: calc(100dvh / var(--uiz, 1) - 48px);
  max-height: calc(100vh / var(--uiz, 1) - 48px);
  max-height: calc(100dvh / var(--uiz, 1) - 48px);
  padding: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal.wide.ep-modal:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.ep-shell {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  background: var(--surface);
}

.ep-head {
  position: sticky;
  top: 0;
  z-index: 2;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px 12px;
  padding: 12px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border-soft);
}

.ep-head-left {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  min-width: 0;
}

.ep-head-right {
  display: flex;
  align-items: center;
  flex: 0 0 auto;
}

.ep-icon-btn,
.ep-close-btn {
  min-width: 38px;
  min-height: 38px;
  padding: 0;
  display: inline-grid;
  place-items: center;
  border-color: var(--border);
  background: var(--surface-2);
}

.ep-copy-btn,
.ep-exp-all {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  padding: 6px 12px;
  border-color: var(--border);
  white-space: nowrap;
}

.ep-exp-all[aria-pressed="true"] {
  background: color-mix(in srgb, var(--accent) 12%, var(--surface));
  border-color: color-mix(in srgb, var(--accent) 45%, var(--border));
  color: var(--accent-text);
}

.ep-exp-all:disabled {
  opacity: .48;
  cursor: not-allowed;
  transform: none;
}

.ep-head button:focus-visible,
.ep-foot button:focus-visible,
.ep-exp-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.ep-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 20px 28px 28px;
}

.ep-doc-head {
  margin-bottom: 20px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border-soft);
}

.modal .ep-doc-title {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  line-height: 1.35;
  color: var(--text-strong);
  overflow-wrap: anywhere;
}

.modal .ep-doc-meta {
  margin: 4px 0 0;
  font-size: 13px;
  line-height: 1.45;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.ep-part {
  margin-bottom: 24px;
}

.ep-part:last-child {
  margin-bottom: 4px;
}

.ep-part-title {
  margin: 0 0 4px;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.4;
  color: var(--text-strong);
  letter-spacing: .01em;
}

.modal .ep-part-hint {
  margin: 0 0 12px;
  font-size: 13px;
  line-height: 1.45;
  font-style: italic;
  color: var(--text-muted);
}

.ep-q {
  padding: 16px 0;
  border-top: 1px solid var(--border-soft);
}

.ep-part > .ep-q:first-of-type {
  border-top: 0;
  padding-top: 8px;
}

.ep-q-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 6px;
}

.ep-q-no {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-strong);
}

.ep-q-pts {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.ep-stem {
  font-size: 15px;
  line-height: 1.6;
  color: var(--text-strong);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.ep-fig {
  margin: 12px 0;
}

.ep-fig .figure {
  margin: 0;
  text-align: left;
}

.ep-fig img {
  display: block;
  max-width: min(100%, 420px);
  height: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 6px;
}

.ep-fig-err {
  font-size: 13px;
  color: var(--text-muted);
}

.ep-opts {
  display: grid;
  gap: 8px 16px;
  margin-top: 10px;
}

.ep-opts.cols-4 {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.ep-opts.cols-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.ep-opts.cols-1 {
  grid-template-columns: minmax(0, 1fr);
}

.ep-opt {
  display: flex;
  align-items: baseline;
  gap: 6px;
  min-width: 0;
  font-size: 14px;
  line-height: 1.55;
  color: var(--text);
  overflow-wrap: anywhere;
}

.ep-opt-let {
  flex: 0 0 auto;
  font-weight: 600;
  color: var(--text-strong);
}

.ep-opt-txt {
  min-width: 0;
  white-space: pre-wrap;
}

.ep-tf-list,
.ep-subs {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.ep-tf-item,
.ep-sub-stem {
  display: flex;
  align-items: baseline;
  gap: 6px;
  font-size: 14px;
  line-height: 1.55;
  color: var(--text);
  overflow-wrap: anywhere;
}

.ep-tf-let,
.ep-sub-let {
  flex: 0 0 auto;
  font-weight: 600;
  color: var(--text-strong);
}

.ep-tf-txt,
.ep-sub-txt {
  min-width: 0;
  white-space: pre-wrap;
}

.ep-sub {
  display: grid;
  gap: 4px;
}

.ep-sub-ans {
  padding-left: 18px;
}

.ep-q-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 10px;
  flex-wrap: wrap;
}

.ep-ans {
  display: flex;
  align-items: baseline;
  gap: 6px;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.5;
  color: var(--green);
  overflow-wrap: anywhere;
}

.ep-ans-val {
  white-space: pre-wrap;
}

.ep-ans.ep-ans-empty {
  color: var(--text-muted);
  font-weight: 500;
  font-size: 13px;
}

.ep-ans-spacer {
  flex: 1 1 auto;
}

.ep-exp-btn {
  margin-left: auto;
  min-height: 36px;
  white-space: nowrap;
  border-color: var(--border);
}

.ep-exp-box {
  margin-top: 10px;
  padding: 12px 14px;
  border-radius: var(--r);
  background: var(--surface-2);
  border: 1px solid var(--border-soft);
  border-left: 3px solid var(--amber);
  display: grid;
  gap: 6px;
}

.ep-exp-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--amber);
}

.ep-exp-txt,
.ep-exp-part {
  font-size: 14px;
  line-height: 1.55;
  color: var(--text);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.ep-foot {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 20px;
  background: var(--surface);
  border-top: 1px solid var(--border-soft);
}

.ep-foot-meta {
  font-size: 13px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.ep-edit-btn {
  flex: 0 0 auto;
  min-height: 36px;
  border-color: var(--border);
}

.ep-skel-wrap {
  display: grid;
  gap: 16px;
}

.ep-skel-q {
  display: grid;
  gap: 10px;
  padding: 16px 0;
  border-top: 1px solid var(--border-soft);
}

.ep-skel-opts {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px 16px;
  margin-top: 4px;
}

.ep-state {
  margin: 24px 0;
}

@media (max-width: 767px) {
  .modal-back:has(.ep-modal) {
    padding: 0;
    align-items: stretch;
  }

  .modal.wide.ep-modal {
    width: 100%;
    max-width: none;
    height: calc(100vh / var(--uiz, 1));
    height: calc(100dvh / var(--uiz, 1));
    max-height: none;
    border-radius: 0;
  }

  .ep-head {
    padding: 10px 14px;
  }

  .ep-icon-btn,
  .ep-close-btn,
  .ep-copy-btn,
  .ep-exp-all,
  .ep-exp-btn,
  .ep-edit-btn {
    min-height: 44px;
    min-width: 44px;
  }

  .ep-body {
    padding: 16px;
  }

  .ep-opts.cols-4,
  .ep-opts.cols-2,
  .ep-skel-opts {
    grid-template-columns: minmax(0, 1fr);
  }

  .ep-foot {
    padding: 10px 14px;
  }
}
