.ct-noscript {
  padding: var(--space-4) var(--space-6);
}

.ct-tables {
  flex: 0 0 auto;
  align-self: flex-start;
  max-width: 100%;
}

/* 並べ替えは「[配列] の [昇順 / 降順]」を 1 行の文として並べる。 */
.ct-sort {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.ct-sort__by {
  flex: 1 1 auto;
  min-width: 0;
}

.ct-sort__order {
  flex: 0 0 auto;
  width: auto;
}

.ct-sort__of {
  flex: 0 0 auto;
  font: 400 14px/22px var(--font-sans);
  color: var(--ink-2);
}

.ct-columns {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

/* 表の枠はカード。角丸の切り抜きだけをして、スクロール容器にはしない（見出し行をページに貼り付けるため clip）。 */
.ct-table-wrap {
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  background: var(--surface);
  overflow: clip;
}

/* 列幅：No. は狭く固定、データ列はすべて同じ幅（--ct-col。codetable.js が測って入れる）、
   余りは最右列の空セル（.ct-fill）が受け持つ。 */
#nlist {
  width: 100%;
  table-layout: fixed;
  border-style: hidden;
}

#nlist th,
#nlist td {
  white-space: nowrap;
}

#nlist .ct-no {
  width: 4em;
}

#nlist .ct-col {
  width: var(--ct-col, 8em);
}

/* 幅が足りないときは空セルを出さず、データ列で枠を等分して折り返す（横スクロールは作らない）。 */
#nlist.is-narrow .ct-fill {
  display: none;
}

#nlist.is-narrow th,
#nlist.is-narrow td {
  padding-left: var(--space-1);
  padding-right: var(--space-1);
  white-space: normal;
  overflow-wrap: anywhere;
}

#nlist.is-narrow .ct-no {
  white-space: nowrap;
}

/* 自然幅を測るあいだだけ、内容どおりの幅に戻す。 */
#nlist.is-measuring {
  width: max-content;
  table-layout: auto;
}

#nlist.is-measuring .ct-col {
  width: auto;
}

#nlist.is-measuring th,
#nlist.is-measuring td {
  white-space: nowrap;
}

#nlist.is-measuring .ct-fill {
  display: none;
}

#nlist thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 500;
}

/* 行番号は控えめに。 */
#nlist tbody td.ct-no {
  font-size: 12px;
  color: var(--ink-3);
  text-align: right;
}

#nlist td.ct-error {
  color: var(--danger-ink);
  font-family: var(--font-sans);
  text-align: left;
  white-space: normal;
}

/* PC：表を下までスクロールしても設定パネルが見える位置に残す。 */
@media (min-width: 641px) {
  .ct-main > .yt-panel {
    position: sticky;
    top: var(--space-5);
    align-self: start;
    max-height: calc(100dvh - 2 * var(--space-5));
  }
}

@media (max-width: 640px) {
  .ct-noscript {
    padding: var(--space-3) var(--space-4);
  }

  /* 表切替は横スクロールにする */
  .ct-tables {
    flex-wrap: nowrap;
    overflow-x: auto;
    align-self: stretch;
  }

  .ct-tables .yt-seg__btn {
    flex: 0 0 auto;
  }

  #nlist tbody td {
    font-size: 15px;
  }

  #nlist .ct-no {
    width: 3em;
  }
}
