h2 {
  margin-top: 48px;
}

h3 {
  margin-top: 38px;
}

.ptd-top-link {
  margin-bottom: 8px;
  font-size: 0.9em;
}

.ptd-series {
  margin: 26px 0 34px;
  padding: 16px 18px;
  background: #f8f9ff;
  border: 1px solid #d9dce7;
  border-radius: 8px;
}

.ptd-series > strong {
  display: block;
  margin-bottom: 10px;
}

.ptd-series ol {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 24px;
  margin: 0;
  padding-left: 24px;
}

.ptd-series li {
  padding-left: 3px;
}

.ptd-series [aria-current="page"] {
  font-weight: bold;
}

code {
  padding: 1px 5px;
  background: rgba(27, 31, 35, 0.06);
  border-radius: 4px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.9em;
}

pre.ptd-code {
  margin: 16px 0 26px;
  padding: 14px 16px;
  overflow-x: auto;
  background: #f6f8fa;
  border: 1px solid #e1e4e8;
  border-radius: 6px;
  line-height: 1.5;
}

pre.ptd-code code {
  padding: 0;
  color: #24292e;
  background: none;
  font-size: 0.84em;
}

.ptd-token-figure,
.ptd-embedding-figure {
  margin: 18px 0 30px;
}

.ptd-token-figure figcaption,
.ptd-embedding-figure figcaption {
  margin-top: 9px;
  color: #555;
  font-size: 0.9em;
}

pre.ptd-data {
  margin: 0;
  padding: 14px 16px;
  overflow-x: auto;
  background: #f6f8fa;
  border: 1px solid #d9dce7;
  border-radius: 6px;
}

pre.ptd-data code {
  padding: 0;
  background: none;
}

.ptd-batch,
.ptd-embedding-output {
  overflow-x: auto;
  border: 1px solid #d9dce7;
  border-radius: 8px;
  background: #f8f9ff;
}

.ptd-batch-row,
.ptd-embedding-row {
  display: grid;
  grid-template-columns: 96px repeat(5, minmax(82px, 1fr));
  gap: 8px;
  align-items: stretch;
  min-width: 620px;
  padding: 10px;
}

.ptd-batch-row + .ptd-batch-row,
.ptd-embedding-row + .ptd-embedding-row {
  border-top: 1px solid #d9dce7;
}

.ptd-batch-row > strong,
.ptd-embedding-row > strong {
  align-self: center;
  color: #444;
  font-size: 0.84em;
}

.ptd-batch-row code {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 7px;
  white-space: pre;
  background: #fff;
  border: 1px solid #bfc5d8;
}

.ptd-embedding-output {
  padding: 7px 0;
  background: linear-gradient(135deg, #f8f9ff, #eef1ff);
}

.ptd-embedding-row > span {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 76px;
  padding: 8px;
  background: #fff;
  border: 1px solid #aeb7d4;
  border-radius: 5px;
  box-shadow: 0 2px 5px rgba(29, 38, 75, 0.08);
}

.ptd-embedding-row > span > code {
  align-self: flex-start;
  max-width: 100%;
  overflow: hidden;
  white-space: pre;
  text-overflow: ellipsis;
}

.ptd-embedding-row small {
  margin-top: 8px;
  color: #5c6580;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.68em;
  white-space: nowrap;
}

.ptd-source-text {
  margin: 22px 0;
  padding: 14px 18px;
  background: #f6f7ff;
  border-left: 4px solid #1a0dab;
  font-size: 1.03em;
}

.ptd-source-text p {
  margin: 0;
}

.ptd-source-text footer {
  margin-top: 10px;
  color: #555;
  font-size: 0.88em;
}

.ptd-shift-figure {
  margin: 22px 0 32px;
  padding: 18px;
  background: #fafbff;
  border: 1px solid #d9dce7;
  border-radius: 8px;
}

.ptd-shift-figure figcaption {
  font-weight: bold;
}

.ptd-token-key {
  margin: 2px 0 16px;
  color: #555;
  font-size: 0.86em;
}

.ptd-pair {
  margin-top: 14px;
  padding: 14px;
  overflow-x: auto;
  background: #fff;
  border: 1px solid #e1e4e8;
  border-radius: 7px;
}

.ptd-pair > strong {
  display: block;
  min-width: 570px;
  margin-bottom: 8px;
  color: #1a0dab;
}

.ptd-token-line {
  display: grid;
  grid-template-columns: 66px minmax(480px, 1fr);
  gap: 8px;
  align-items: center;
  min-width: 570px;
}

.ptd-token-label {
  font-size: 0.86em;
  font-weight: bold;
}

.ptd-token-line ol {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.ptd-token-line code {
  display: block;
  padding: 7px 8px;
  color: #1a0dab;
  text-align: center;
  background: #eef0ff;
  border: 1px solid #c9cffa;
}

.ptd-target-line code {
  color: #5c4300;
  background: #fff2cc;
  border-color: #d8b95e;
}

.ptd-shift-arrow {
  min-width: 496px;
  margin: 4px 0 4px 74px;
  color: #666;
  font-size: 0.82em;
}

.ptd-note,
.ptd-key-point {
  margin: 22px 0;
  padding: 13px 16px;
  border-left: 4px solid #1a0dab;
  background: #f6f7ff;
}

.ptd-note {
  border-left-color: #c28a00;
  background: #fff8df;
}

.ptd-table-scroll {
  margin: 18px 0 28px;
  overflow-x: auto;
}

.ptd-table {
  width: 100%;
  min-width: 560px;
  border-collapse: collapse;
  font-size: 0.92em;
}

.ptd-table caption {
  margin-bottom: 8px;
  color: #555;
  text-align: left;
}

.ptd-table th,
.ptd-table td {
  padding: 9px 10px;
  text-align: left;
  vertical-align: top;
  border: 1px solid #d9dce7;
}

.ptd-table th {
  background: #f6f7ff;
}

.ptd-table code {
  white-space: nowrap;
}

.ptd-probabilities td:first-child {
  width: 42%;
}

.ptd-chain-rule {
  margin: 24px 0 34px;
  padding: 18px;
  background: #fafbff;
  border: 1px solid #d9dce7;
  border-radius: 8px;
}

.ptd-chain-rule figcaption {
  margin-bottom: 6px;
  font-weight: bold;
}

.ptd-chain-rule > p {
  margin: 0 0 20px;
  color: #555;
}

.ptd-chain-forward {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 46px minmax(0, 1fr) 46px minmax(0, 1fr) 46px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
}

.ptd-chain-node {
  display: flex;
  min-height: 92px;
  padding: 12px 8px;
  flex-direction: column;
  gap: 9px;
  align-items: center;
  justify-content: center;
  text-align: center;
  background: #fff;
  border: 2px solid #9aa5e8;
  border-radius: 8px;
}

.ptd-chain-node span {
  color: #555;
  font-size: 0.8em;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.ptd-chain-node code {
  color: #1a0dab;
  font-size: 0.88em;
}

.ptd-chain-loss {
  background: #fff8df;
  border-color: #c28a00;
}

.ptd-chain-loss code {
  color: #6b4e00;
}

.ptd-chain-arrow {
  display: flex;
  flex-direction: column;
  gap: 2px;
  align-items: center;
  color: #666;
  text-align: center;
}

.ptd-chain-arrow span {
  font-size: 0.76em;
}

.ptd-chain-arrow strong {
  color: #1a0dab;
  font-size: 1.45em;
}

.ptd-chain-backward {
  margin-top: 20px;
  padding: 15px 16px;
  background: #f6f7ff;
  border-left: 4px solid #1a0dab;
}

.ptd-chain-backward > strong {
  display: block;
  margin-bottom: 10px;
}

.ptd-chain-backward ol {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px 20px;
  margin: 0 0 12px;
  padding-left: 24px;
}

.ptd-chain-backward p {
  margin: 0;
  overflow-x: auto;
}

.ptd-chain-backward p code {
  display: inline-block;
  min-width: max-content;
}

.ptd-flow {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  margin: 24px 0 30px;
  padding: 0;
  list-style: none;
}

.ptd-flow li {
  position: relative;
  min-height: 96px;
  padding: 12px 10px;
  text-align: center;
  background: #fff;
  border: 1px solid #d9dce7;
  border-radius: 7px;
}

.ptd-flow li:not(:last-child)::after {
  position: absolute;
  top: 50%;
  right: -10px;
  z-index: 1;
  width: 10px;
  color: #777;
  content: "→";
  transform: translateY(-50%);
}

.ptd-flow strong {
  display: block;
  margin-bottom: 5px;
  color: #1a0dab;
}

.ptd-flow span {
  color: #555;
  font-size: 0.86em;
}

.ptd-page-nav {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  margin-top: 48px;
  padding-top: 18px;
  border-top: 1px solid #ddd;
}

.ptd-page-nav a:last-child {
  margin-left: auto;
  text-align: right;
}

@media (max-width: 620px) {
  .ptd-series ol {
    grid-template-columns: 1fr;
  }

  .ptd-pair {
    overflow-x: visible;
  }

  .ptd-pair > strong,
  .ptd-token-line,
  .ptd-shift-arrow {
    min-width: 0;
  }

  .ptd-token-line {
    display: block;
  }

  .ptd-token-label {
    display: block;
    margin-bottom: 5px;
  }

  .ptd-token-line ol {
    gap: 4px;
  }

  .ptd-token-line code {
    padding: 5px 2px;
    font-size: 0.74em;
  }

  .ptd-shift-arrow {
    margin: 4px 0;
  }

  .ptd-flow {
    grid-template-columns: 1fr;
  }

  .ptd-flow li {
    min-height: 0;
    text-align: left;
  }

  .ptd-flow li:not(:last-child)::after {
    top: auto;
    right: 50%;
    bottom: -16px;
    content: "↓";
    transform: translateX(50%);
  }

  .ptd-chain-forward {
    grid-template-columns: 1fr;
  }

  .ptd-chain-arrow {
    min-height: 42px;
    justify-content: center;
  }

  .ptd-chain-arrow strong {
    line-height: 0.8;
    transform: rotate(90deg);
  }

  .ptd-chain-backward ol {
    grid-template-columns: 1fr;
  }

  .ptd-chain-backward p code {
    display: inline;
    min-width: 0;
    white-space: normal;
  }
}

@media (max-width: 480px) {
  .ptd-table {
    min-width: 100%;
    table-layout: fixed;
    font-size: 0.84em;
  }

  .ptd-table th,
  .ptd-table td {
    padding: 7px;
    overflow-wrap: break-word;
  }

  .ptd-table code {
    white-space: normal;
  }

  .ptd-page-nav {
    flex-direction: column;
  }

  .ptd-page-nav a:last-child {
    margin-left: 0;
    text-align: left;
  }
}
