/* 비교 표: 좁은 화면에서는 래퍼가 스크롤을 담당한다. */
.table-scroll {
  width: 100%;
  max-width: 100%;
  margin: 1.5rem 0;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  -webkit-overflow-scrolling: touch;
}

article .box .table-scroll table {
  margin: 0;
}

/* 4열 표만 최소 너비를 유지하고, 필요한 경우 가로로 스크롤한다. */
article .box .table-scroll.table-cols-4 table {
  min-width: 660px;
}

@media screen and (max-width: 740px) {
  article .box .table-scroll table {
    display: table;
    width: 100%;
    white-space: normal;
    font-size: 0.82rem;
  }

  article .box .table-scroll th,
  article .box .table-scroll td {
    padding: 0.5rem 0.45rem;
  }

  article .box .table-scroll th {
    white-space: normal;
  }

  article .box .table-scroll code {
    word-break: normal;
    overflow-wrap: normal;
    white-space: nowrap;
  }

  article .box .table-cols-2 table,
  article .box .table-cols-3 table {
    table-layout: fixed;
  }

  article .box .table-cols-2 th:first-child,
  article .box .table-cols-2 td:first-child {
    width: 62%;
  }

  article .box .table-cols-3 th:first-child,
  article .box .table-cols-3 td:first-child {
    width: 44%;
  }

  article .box .table-cols-3 th:not(:first-child),
  article .box .table-cols-3 td:not(:first-child) {
    width: 28%;
  }

  article .box .table-scroll.table-cols-4 {
    overflow: visible;
  }

  article .box .table-scroll.table-cols-4 table {
    display: block;
    min-width: 0;
    border: none;
    background: transparent;
  }

  article .box .table-cols-4 thead {
    display: none;
  }

  article .box .table-cols-4 tbody {
    display: grid;
    gap: 0.85rem;
  }

  article .box .table-cols-4 tr {
    display: block;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--card);
  }

  article .box .table-cols-4 td {
    width: 100%;
    border-right: none;
  }

  article .box .table-cols-4 td:first-child {
    display: block;
    padding: 0.6rem 0.7rem;
    background: #f1f3f5;
    text-align: left !important;
  }

  article .box .table-cols-4 td:first-child::before {
    display: none;
  }

  article .box .table-cols-4 td:not(:first-child) {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 0.8rem;
    align-items: baseline;
    padding: 0.55rem 0.7rem;
  }

  article .box .table-cols-4 td:not(:first-child)::before {
    content: attr(data-label);
    color: var(--muted);
    font-weight: 600;
    text-align: left;
  }

  article .box .table-cols-4 td:not(:last-child) {
    border-bottom: 1px solid var(--border);
  }

  article .box .table-cols-4 td:last-child {
    border-bottom: none;
  }
}

/* ── 본문 각주와 원문 출처 ─────────────────────────────── */
article .box .citation {
  margin-left: 0.08em;
  vertical-align: super;
  line-height: 0;
}

article .box .citation-ref {
  border-bottom: none;
  color: #1976d2;
  font-size: 0.7em;
  font-weight: 650;
  white-space: nowrap;
}

article .box .citation-ref:hover,
article .box .citation-ref:focus-visible {
  border-bottom: none;
  background: rgba(25, 118, 210, 0.1);
  border-radius: 3px;
  outline: none;
}

article .box .source-note {
  margin: 0.55rem 0 1.35rem;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.6;
}

article .box .table-scroll + .source-note {
  margin-top: -0.8rem;
}

.article-sources {
  margin: 3rem 0 0;
  border-top: 1px solid var(--border-strong);
  border-bottom: 1px solid var(--border);
  scroll-margin-top: 1rem;
}

article .box .article-sources-heading {
  margin: 0;
  padding: 0;
  border: 0;
  font-size: 1rem;
  line-height: 1.4;
}

.article-sources-toggle {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.9rem 0.25rem;
  border: 0;
  background: transparent;
  color: var(--heading);
  cursor: pointer;
  font: inherit;
  text-align: left;
}

.article-sources-toggle:hover {
  background: #f7f8fa;
}

.article-sources-summary,
.article-sources-action {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.article-sources-label {
  font-weight: 700;
}

.article-sources-count,
.article-sources-action {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 500;
}

.article-sources-chevron {
  width: 0.48rem;
  height: 0.48rem;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(45deg) translateY(-2px);
  transition: transform 0.16s ease;
}

.article-sources[data-expanded="true"] .article-sources-chevron {
  transform: rotate(225deg) translate(-2px, -1px);
}

article .box .article-sources ol {
  margin: 0;
  padding: 0.25rem 0.25rem 1rem;
  list-style: none;
}

article .box .article-sources ol[hidden] {
  display: none;
}

article .box .article-sources li {
  display: grid;
  grid-template-columns: 2.2rem minmax(0, 1fr);
  gap: 0.3rem;
  margin: 0;
  padding: 0.48rem 0;
  line-height: 1.55;
}

article .box .article-sources .source-index {
  border-bottom: none;
  color: var(--muted);
  font-size: 0.78rem;
}

article .box .article-sources .source-link {
  border-bottom: none;
  color: var(--accent);
  font-size: 0.86rem;
}

.article-sources .source-name {
  font-weight: 700;
}

.article-sources time {
  margin-left: 0.5rem;
  color: var(--muted);
  font-size: 0.74rem;
  white-space: nowrap;
}

.citation-dialog {
  position: fixed;
  inset: auto 1.5rem 1.5rem auto;
  z-index: 1000;
  width: min(380px, calc(100vw - 2rem));
  max-height: min(70vh, 480px);
  margin: 0;
  padding: 1rem 1.1rem;
  overflow: auto;
  border: 1px solid var(--border-strong);
  border-radius: 11px;
  background: var(--card);
  color: var(--text);
  box-shadow: 0 16px 40px rgba(20, 23, 28, 0.2);
  font-family: var(--font-sans);
}

.citation-dialog:not([open]) {
  display: none;
}

.citation-dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.citation-dialog-close {
  padding: 0.1rem 0.25rem;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font: inherit;
  font-size: 1.2rem;
  line-height: 1;
}

.citation-dialog-meta {
  margin-top: 0.65rem;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 600;
}

.citation-dialog-title {
  margin-top: 0.45rem;
  font-size: 0.9rem;
  line-height: 1.6;
}

.citation-dialog-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.85rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--border);
}

.citation-dialog .citation-dialog-open {
  padding: 0.5rem 0.7rem;
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  font-size: 0.82rem;
  font-weight: 700;
  white-space: nowrap;
}

.citation-dialog-all {
  padding: 0.45rem 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 650;
}

@media screen and (max-width: 740px) {
  .citation-dialog {
    inset: auto 0.75rem 0.75rem;
    width: auto;
    max-height: 60vh;
  }

  article .box .article-sources li {
    grid-template-columns: 1.8rem minmax(0, 1fr);
  }

  .article-sources time {
    display: block;
    margin: 0.15rem 0 0;
  }
}
