.viewer-wrap {
  position: relative;
  flex: 1;
  min-width: 0;
  display: flex;
}

.viewer-wrap::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 3px;
  background: linear-gradient(90deg, rgba(112, 118, 128, 0.22) 0%, rgba(175, 181, 191, 0.76) 50%, rgba(112, 118, 128, 0.22) 100%);
  opacity: 0;
  pointer-events: none;
  transition: opacity 90ms ease;
  z-index: 5;
}

.content-panel.page-loading .viewer-wrap::before {
  opacity: 0.92;
  animation: page-load-bar 720ms ease-in-out infinite;
}

.viewer {
  flex: 1;
  min-height: 0;
  overflow: auto;
  scrollbar-width: auto;
  scrollbar-color: var(--scrollbar-thumb-2) var(--scrollbar-track);
  line-height: 1.58;
  padding: 18px;
}

.toc-panel {
  width: var(--toc-width);
  min-width: 154px;
  border-left: 0;
  background: var(--toc-bg);
  padding: 14px 12px;
  overflow: auto;
}

.toc-panel h3 {
  margin: 0 0 10px;
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.toc-nav ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.toc-nav {
  font-size: 14px;
}

.toc-nav li + li {
  margin-top: 6px;
}

.toc-link {
  display: block;
  border: 0;
  background: transparent;
  color: var(--link);
  text-align: left;
  font: inherit;
  padding: 0;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.toc-link:hover {
  color: var(--link-hover);
  text-decoration: none;
}

.toc-depth-2 {
  padding-left: 12px;
}

.toc-nav.toc-all-second-level .toc-depth-2 {
  padding-left: 0;
}

.toc-depth-3 {
  padding-left: 27px;
}

.toc-depth-4 {
  padding-left: 24px;
}

.viewer > :first-child {
  margin-top: 0;
}

.viewer p {
  margin: 0.55em 0;
}

.viewer h1,
.viewer h2,
.viewer h3 {
  font-family: var(--font-heading);
  line-height: 1.2;
}

.viewer * + h1,
.viewer * + h2,
.viewer * + h3 {
  margin-top: 1.8em;
}

.viewer h1 {
  font-size: 2em;
  padding-bottom: 0.22em;
  border-bottom: 1px solid var(--line);
}

.viewer h2 {
  font-size: 1.5em;
  padding-bottom: 0.2em;
  border-bottom: 1px solid var(--line);
}

.viewer h3 {
  font-size: 1.25em;
}

.viewer h1 a[href],
.viewer h2 a[href],
.viewer h3 a[href] {
  font-family: inherit;
  font-size: inherit;
  font-weight: inherit;
  line-height: inherit;
  color: var(--link);
  text-decoration: none !important;
}

.viewer h1 a[href]:hover,
.viewer h2 a[href]:hover,
.viewer h3 a[href]:hover {
  color: var(--link-hover);
  background: transparent;
}

.viewer-load-state {
  max-width: 700px;
  margin: 28px auto;
  padding: 18px 20px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(17, 21, 27, 0.82);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.25);
}

.viewer-load-state .hourglass {
  display: inline-block;
  font-size: 26px;
  line-height: 1;
  animation: hourglass-pulse 1.15s ease-in-out infinite;
}

.viewer-load-state h3 {
  margin: 10px 0 8px;
  font-size: 19px;
  color: var(--text);
}

.viewer-load-state p {
  margin: 8px 0;
}

.viewer-load-state .muted {
  color: var(--muted);
  font-size: 13px;
}

.viewer-load-state.load-error {
  border-color: rgba(176, 0, 32, 0.45);
}

.viewer-error-state {
  max-width: 760px;
  margin: 36px auto;
  padding: 28px 30px 24px;
  border-radius: 24px;
  border: 1px solid rgba(220, 224, 230, 0.2);
  background:
    radial-gradient(circle at 9% -6%, rgba(246, 248, 252, 0.12) 0%, transparent 38%),
    radial-gradient(circle at 94% 2%, rgba(215, 222, 233, 0.09) 0%, transparent 34%),
    linear-gradient(160deg, rgba(22, 25, 32, 0.95), rgba(17, 20, 26, 0.94));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    0 28px 60px rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(12px);
}

.viewer-error-head {
  display: grid;
  grid-template-columns: 42px 1fr;
  column-gap: 14px;
  row-gap: 6px;
  align-items: center;
}

.viewer-error-icon {
  grid-row: span 3;
  width: 42px;
  height: 42px;
  border-radius: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #ff8f83;
  border: 1px solid rgba(255, 155, 143, 0.36);
  background: linear-gradient(180deg, rgba(255, 113, 95, 0.28), rgba(255, 113, 95, 0.1));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.22);
}

.viewer-error-icon svg {
  width: 22px;
  height: 22px;
  display: block;
}

.viewer-error-kicker {
  margin: 0;
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(231, 236, 242, 0.66);
}

.viewer-error-state h3 {
  margin: 0;
  font-size: clamp(22px, 3vw, 30px);
  line-height: 1.08;
  letter-spacing: -0.02em;
  color: #f2f4f8;
}

.viewer-error-copy {
  margin: 0;
  color: rgba(215, 221, 229, 0.86);
  font-size: 15px;
}

.viewer-error-copy code {
  padding: 1px 7px;
  border-radius: 999px;
  border: 1px solid rgba(192, 201, 214, 0.24);
  background: rgba(14, 17, 22, 0.72);
  color: #edf1f7;
  font-size: 13px;
}

.viewer-error-actions {
  margin-top: 18px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.viewer-error-btn {
  appearance: none;
  border: 1px solid transparent;
  border-radius: 999px;
  font: inherit;
  font-weight: 500;
  font-size: 14px;
  line-height: 1;
  text-decoration: none;
  color: inherit;
  padding: 11px 16px;
  cursor: pointer;
  transition: transform 120ms ease, box-shadow 120ms ease, background 120ms ease, border-color 120ms ease;
}

.viewer-error-btn:hover {
  transform: translateY(-1px);
}

.viewer-error-btn:focus-visible {
  outline: 1px solid rgba(224, 231, 241, 0.9);
  outline-offset: 1px;
}

.viewer-error-btn.primary {
  color: #f6f8fb;
  border-color: rgba(152, 164, 182, 0.52);
  background: linear-gradient(180deg, rgba(122, 134, 151, 0.54), rgba(87, 97, 112, 0.76));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.28), 0 14px 22px rgba(0, 0, 0, 0.24);
}

.viewer-error-btn.primary:hover {
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.3), 0 16px 24px rgba(0, 0, 0, 0.28);
}

.viewer-error-btn.ghost {
  border-color: rgba(190, 200, 214, 0.32);
  background: rgba(23, 27, 34, 0.76);
  color: rgba(230, 235, 242, 0.9);
}

.viewer-error-details {
  margin-top: 16px;
  border-top: 1px solid rgba(193, 201, 214, 0.2);
  padding-top: 14px;
}

.viewer-error-details summary {
  list-style: none;
  cursor: pointer;
  font-size: 13px;
  color: rgba(206, 214, 225, 0.84);
}

.viewer-error-details summary::-webkit-details-marker {
  display: none;
}

.viewer-error-details pre {
  margin: 10px 0 0;
  max-height: 220px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  border-radius: 12px;
  border: 1px solid rgba(175, 184, 196, 0.2);
  background: rgba(13, 15, 20, 0.84);
  color: rgba(223, 229, 239, 0.9);
  padding: 12px 14px;
  font-size: 12px;
}

@keyframes hourglass-pulse {
  0% {
    transform: translateY(0) scale(1);
    opacity: 0.92;
  }
  50% {
    transform: translateY(-1px) scale(1.08);
    opacity: 1;
  }
  100% {
    transform: translateY(0) scale(1);
    opacity: 0.92;
  }
}

#viewerTitle {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: nowrap;
  white-space: nowrap;
  overflow: visible;
  text-overflow: ellipsis;
  clip-path: inset(0 0 -100px 0);
  text-transform: none;
  letter-spacing: 0.01em;
  font-weight: 400;
}

#viewerTitle.breadcrumb-compact {
  gap: 4px;
  font-size: 13px;
}

.breadcrumb-btn {
  border: 0;
  background: transparent;
  color: var(--accent-2);
  font: inherit;
  font-weight: 400;
  padding: 0;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

#viewerTitle.breadcrumb-compact .breadcrumb-btn {
  gap: 6px;
}

.breadcrumb-btn:hover {
  color: var(--link-hover);
  text-decoration: none;
}

.breadcrumb-btn.active {
  color: var(--text);
}

.breadcrumb-separator {
  color: var(--muted);
}

.breadcrumb-text {
  color: var(--text);
  font-weight: 400;
}

.breadcrumb-home-icon {
  width: 16px;
  height: 16px;
  flex: 0 0 16px;
  color: var(--muted);
}

#viewerTitle.breadcrumb-compact .breadcrumb-home-icon {
  width: 14px;
  height: 14px;
  flex: 0 0 14px;
}

.breadcrumb-home-icon svg {
  display: block;
  width: 100%;
  height: 100%;
}

.breadcrumb-copy-icon {
  width: 16px;
  height: 16px;
  flex: 0 0 16px;
}

.breadcrumb-copy-icon svg {
  display: block;
  width: 100%;
  height: 100%;
}

.viewer::-webkit-scrollbar {
  width: 14px;
  height: 14px;
}

.viewer::-webkit-scrollbar-track {
  background: var(--scrollbar-track);
}

.viewer::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, var(--scrollbar-thumb-1), var(--scrollbar-thumb-2));
  border: 2px solid var(--scrollbar-track);
  border-radius: 999px;
}

.viewer::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, var(--scrollbar-thumb-hover-1), var(--scrollbar-thumb-hover-2));
}

.viewer pre {
  background: var(--code-bg);
  color: #d3dae5;
  border-radius: 10px;
  padding: 14px;
  overflow: auto;
  font-size: inherit;
  line-height: 1.5;
  border: 1px solid rgba(164, 176, 194, 0.2);
}

.viewer code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.viewer :not(pre) > code {
  background: var(--inline-code-bg);
  border-radius: 6px;
  padding: 0.08em 0.38em;
}

.viewer pre code.language-yaml .yaml-key,
.viewer pre code.language-yml .yaml-key {
  color: var(--yaml-key);
}

.viewer pre code.language-yaml .yaml-value,
.viewer pre code.language-yml .yaml-value {
  color: var(--yaml-value);
}

.viewer pre code.language-yaml .yaml-comment,
.viewer pre code.language-yml .yaml-comment {
  color: var(--yaml-comment);
}

.viewer img {
  display: block;
  max-width: 100%;
  height: auto;
  border-radius: 0;
  border: 1px solid var(--border);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

.viewer .inline-video {
  margin: 0 0 8px;
}

.viewer .inline-video video {
  display: block;
  width: 100%;
  max-width: 100%;
  border: 1px solid var(--border);
  background: #000;
}

.viewer table {
  width: auto;
  border-collapse: collapse;
  border-bottom: 1px solid var(--border);
  margin: 14px 0;
  font-size: inherit;
}

.viewer table.table-no-bottom-border {
  border-bottom: 0;
}

.viewer th,
.viewer td {
  border: 0;
  border-bottom: 1px solid var(--border);
  padding: 10px 12px;
  text-align: left;
  vertical-align: top;
}

.viewer thead th {
  background: transparent;
  font-family: var(--font-heading);
  font-weight: 700;
  border-bottom: 3px solid var(--border);
}

.viewer table thead + tbody tr:first-child > * {
  border-top: 3px solid var(--border);
}

.viewer table tr:last-child > td,
.viewer table tr:last-child > th {
  border-bottom: 0;
}

.viewer thead th a[href] {
  font-family: inherit;
  font-weight: 700;
}

.viewer thead th a[href] code {
  font-family: inherit;
}

.viewer table a[href] {
  font-family: var(--font-body);
  font-size: inherit;
  font-weight: inherit;
}

.viewer table a[href] code {
  font-family: var(--font-body);
  font-size: inherit;
  font-weight: inherit;
}

.viewer a[href] {
  color: var(--link);
  text-decoration: none !important;
  font-weight: 500;
  transition: color 160ms ease, background-color 160ms ease;
}

.viewer a[href]:visited {
  color: var(--link);
}

.viewer a[href]:hover {
  color: var(--link-hover);
  text-decoration: none !important;
  background: var(--link-hover-bg);
  border-radius: 4px;
}

.viewer a[href]:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

.viewer blockquote {
  margin: 14px 0;
  padding: 8px 12px;
  border-left: 3px solid var(--accent);
  background: rgba(138, 145, 157, 0.09);
  border-radius: 8px;
}

.viewer blockquote > :first-child {
  margin-top: 0;
}

.viewer blockquote > :last-child {
  margin-bottom: 0;
}

.viewer hr {
  border: 0;
  border-top: 1px solid var(--border);
}

.viewer-next-nav {
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: flex-end;
}

.viewer-next-nav.viewer-next-nav-no-divider {
  border-top: 0;
  padding-top: 0;
}

.viewer-next-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: var(--text);
}

.viewer-next-kicker {
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.viewer-next-title {
  font-weight: 400;
}

.viewer-next-arrow {
  font-size: 16px;
  line-height: 1;
}

.pdf-viewer-overlay {
  position: absolute;
  inset: 10px 10px 0 10px;
  z-index: 20;
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--panel) 92%, black 8%);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.38);
}

.pdf-viewer-shell {
  height: 100%;
  display: flex;
  flex-direction: column;
}

.pdf-viewer-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(122, 184, 255, 0.08), rgba(122, 184, 255, 0));
}

.pdf-viewer-title {
  margin: 0;
  min-width: 0;
  font-size: 14px;
  font-family: var(--font-body);
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pdf-viewer-heading {
  min-width: 0;
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.pdf-viewer-file-name {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pdf-viewer-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.pdf-viewer-btn {
  appearance: none;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 7px 10px;
  font: inherit;
  font-size: 12px;
  font-weight: 500;
  color: var(--text);
  text-decoration: none;
  background: rgba(129, 138, 152, 0.12);
  cursor: pointer;
}

.pdf-viewer-btn:hover {
  color: var(--link-hover);
  border-color: color-mix(in srgb, var(--link-hover) 45%, var(--border));
  background: var(--link-hover-bg);
}

.pdf-viewer-btn.close {
  background: rgba(170, 72, 72, 0.14);
}

.pdf-viewer-frame {
  border: 0;
  width: 100%;
  flex: 1;
  background: #1a1d24;
}

@media (max-width: 900px) {
  .toc-panel {
    display: none;
  }

  .pdf-viewer-overlay {
    inset: 0;
  }

  .pdf-viewer-toolbar {
    padding: 10px;
  }

  .pdf-viewer-title {
    font-size: 13px;
  }

  .pdf-viewer-heading {
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
  }

  .pdf-viewer-btn {
    padding: 6px 9px;
    font-size: 11px;
  }

  .viewer-error-state {
    margin: 24px 0;
    padding: 20px 18px;
    border-radius: 18px;
  }

  .viewer-error-head {
    grid-template-columns: 34px 1fr;
    column-gap: 10px;
  }

  .viewer-error-icon {
    width: 34px;
    height: 34px;
    border-radius: 11px;
  }

  .viewer-error-icon svg {
    width: 18px;
    height: 18px;
  }

  .viewer-error-copy {
    font-size: 14px;
  }
}

.toc-nav.toc-all-second-level .toc-depth-2 {
  padding-left: 0;
}
