:root {
  --site-primary: #0d6efd;
  --site-primary-strong: #0b5ed7;
  --site-primary-rgb: 13, 110, 253;
  --site-accent: #facc15;
  --site-accent-strong: #fb923c;
  --site-accent-rgb: 250, 204, 21;
  --site-support: #15803d;
  --site-support-strong: #34d399;
  --site-support-rgb: 21, 128, 61;
  --site-support-text: #f0fdf4;
  --bs-primary: var(--site-primary);
  --bs-primary-rgb: var(--site-primary-rgb);
  --bs-link-color: var(--site-primary);
  --bs-link-hover-color: var(--site-primary-strong);
}

.btn-primary {
  --bs-btn-bg: var(--site-primary);
  --bs-btn-border-color: var(--site-primary);
  --bs-btn-hover-bg: var(--site-primary-strong);
  --bs-btn-hover-border-color: var(--site-primary-strong);
  --bs-btn-active-bg: var(--site-primary-strong);
  --bs-btn-active-border-color: var(--site-primary-strong);
  --bs-btn-focus-shadow-rgb: var(--site-primary-rgb);
}

.btn-outline-primary {
  --bs-btn-color: var(--site-primary);
  --bs-btn-border-color: var(--site-primary);
  --bs-btn-hover-bg: var(--site-primary);
  --bs-btn-hover-border-color: var(--site-primary);
  --bs-btn-active-bg: var(--site-primary-strong);
  --bs-btn-active-border-color: var(--site-primary-strong);
  --bs-btn-focus-shadow-rgb: var(--site-primary-rgb);
  --bs-btn-hover-color: var(--site-support-text, #fff);
  --bs-btn-active-color: var(--site-support-text, #fff);
}

html[data-bs-theme='light'] {
  --bs-body-bg: #ffffff;
  --bs-body-bg-rgb: 255, 255, 255;
}

html {
  font-size: clamp(16px, 1.2vw, 24px);
}

@media (min-width: 1600px) {
  .container {
    max-width: 90%;
  }
}

.toolbar svg {
  fill: currentColor;
}

.external-link-icon,
.dropdown-lock-icon {
  width: 0.5em;
  height: 0.5em;
  flex-shrink: 0;
}

nav.toc {
  font-size: 0.9rem;
  border-left: 1px solid #dee2e6;
  padding-left: 1rem;
  overflow-wrap: anywhere;
}

nav.toc h4 {
  font-size: 1rem;
  margin-top: 0;
  margin-bottom: 0.5rem;
}

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

nav.toc li {
  margin-bottom: 0.25rem;
}

nav.toc ul ul {
  margin-left: 1rem;
}

nav.toc a {
  text-decoration: none;
  word-break: break-word;
}

nav.toc a:hover {
  text-decoration: underline;
}

.nav-item.dropdown .nav-link::after {
  display: none;
}

@media (min-width: 992px) {
  .reader-sidebar {
    position: sticky;
    top: 1rem;
    max-height: calc(100vh - 2rem);
    display: flex;
    flex-direction: column;
  }

  .reader-sidebar nav.toc {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
  }

  .reader-sidebar .reader-qr-card {
    flex-shrink: 0;
  }
}

.reader-qr-card .card-body {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.reader-qr-card .reader-qr-image {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 180px;
  height: 180px;
  max-width: 100%;
  margin: 0 auto;
}

.reader-qr-card .reader-qr-image canvas,
.reader-qr-card .reader-qr-image img {
  max-width: 100%;
  height: auto;
}

.nav-item.dropdown:hover .badge,
.nav-item.dropdown.show .badge {
  background-color: var(--bs-primary);
  color: var(--bs-white);
}

.user-info-tooltip {
  display: none;
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  white-space: nowrap;
  margin-top: 0.25rem;
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
  border-radius: 0.25rem;
  background-color: var(--bs-dark);
  color: var(--bs-white);
  z-index: 1000;
}

.language-select {
  background-color: transparent;
  padding: 0.25rem 0.5rem;
  padding-right: 1.5rem;
  line-height: 1.5;
  height: calc(1.5em + 0.5rem + 2px);
  border-radius: 0.2rem;
  background-position: right 0.5rem center;
}

html[data-bs-theme='light'] .language-select {
  color: var(--bs-dark);
  border: 1px solid var(--bs-dark);
}

html[data-bs-theme='dark'] .language-select {
  color: var(--bs-light);
  border: 1px solid var(--bs-light);
}

.language-select option {
  background-color: var(--bs-body-bg);
  color: var(--bs-body-color);
}

.markdown-body {
  font-size: 1rem;
  line-height: 1.7;
}

.markdown-body > *:first-child {
  margin-top: 0;
}

.markdown-body ul,
.markdown-body ol {
  padding-left: 1.5rem;
  margin-bottom: 1rem;
}

.markdown-body li + li {
  margin-top: 0.25rem;
}

.markdown-body ul ul,
.markdown-body ol ul,
.markdown-body ul ol,
.markdown-body ol ol {
  margin-top: 0.5rem;
  margin-bottom: 0.5rem;
  margin-left: 0.5rem;
  padding-left: 1.25rem;
  border-left: 1px solid var(--bs-border-color-translucent, rgba(108, 117, 125, 0.35));
}

.markdown-body ul ul {
  list-style-type: circle;
}

.markdown-body ul ul ul {
  list-style-type: square;
}

.markdown-body ol ol {
  list-style-type: lower-alpha;
}

.markdown-body ol ol ol {
  list-style-type: lower-roman;
}

.markdown-body table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1.5rem;
  border-radius: 0.85rem;
  overflow: hidden;
  box-shadow: 0 1.25rem 2.5rem rgba(15, 23, 42, 0.12);
  transition: box-shadow 0.2s ease;
}

.markdown-body table:hover,
.markdown-body table:focus-within {
  box-shadow: 0 1.6rem 3.2rem rgba(15, 23, 42, 0.18);
}

.markdown-body th,
.markdown-body td {
  padding: 0.65rem 1rem;
  border: 1px solid var(--bs-border-color-translucent, rgba(108, 117, 125, 0.25));
}

html[data-bs-theme='light'] .markdown-body table {
  background: linear-gradient(180deg, rgba(248, 249, 250, 0.95), rgba(255, 255, 255, 0.98));
}

html[data-bs-theme='dark'] .markdown-body table {
  background: linear-gradient(180deg, rgba(15, 23, 42, 0.66), rgba(15, 23, 42, 0.82));
}

html[data-bs-theme='light'] .markdown-body th {
  background-color: rgba(0, 0, 0, 0.04);
}

html[data-bs-theme='dark'] .markdown-body th {
  background-color: rgba(255, 255, 255, 0.08);
}

html[data-bs-theme='dark'] .markdown-body th,
html[data-bs-theme='dark'] .markdown-body td {
  border-color: rgba(255, 255, 255, 0.14);
}

html[data-bs-theme='light'] .markdown-body tbody tr:nth-of-type(odd) td {
  background-color: rgba(0, 0, 0, 0.02);
}

html[data-bs-theme='dark'] .markdown-body tbody tr:nth-of-type(odd) td {
  background-color: rgba(255, 255, 255, 0.04);
}

.markdown-body table caption {
  caption-side: top;
  padding: 1rem;
  font-weight: 600;
  text-align: left;
  letter-spacing: 0.01em;
}

.markdown-body thead th {
  font-weight: 600;
  font-size: 0.85rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.markdown-body tbody td:first-child {
  font-weight: 500;
}

@media (max-width: 991.98px) {
  .markdown-body table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
    border-radius: 1rem;
    box-shadow: 0 1.5rem 3.25rem rgba(15, 23, 42, 0.2);
  }

  .markdown-body table::-webkit-scrollbar {
    height: 0.45rem;
  }

  .markdown-body table::-webkit-scrollbar-thumb {
    background-color: rgba(108, 117, 125, 0.5);
    border-radius: 999px;
  }

  .markdown-body table:focus-visible {
    outline: 0.2rem solid var(--bs-primary);
    outline-offset: 0.35rem;
  }

  .markdown-body th,
  .markdown-body td {
    padding: 0.65rem 0.75rem;
    min-width: 10.5rem;
  }
}

.user-story-toggle {
  position: fixed;
  right: 1.75rem;
  bottom: 1.75rem;
  width: 3rem;
  height: 3rem;
  border-radius: 50%;
  border: 0;
  background: linear-gradient(135deg, var(--site-accent), var(--site-accent-strong));
  color: #1f2937;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1.25rem 2.5rem rgba(15, 23, 42, 0.35);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  z-index: 1080;
}

.user-story-toggle:hover,
.user-story-toggle:focus-visible {
  transform: translateY(-2px) scale(1.02);
  box-shadow: 0 1.75rem 3rem rgba(15, 23, 42, 0.45);
}

.user-story-toggle svg {
  width: 1.75rem;
  height: 1.75rem;
  display: block;
}

body.user-story-open .user-story-toggle {
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
}

body.user-story-open {
  overflow: hidden;
}

.user-story-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
  padding: 1.5rem;
  background: rgba(15, 23, 42, 0.45);
  z-index: 1070;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.user-story-overlay.show {
  opacity: 1;
  pointer-events: auto;
}

.user-story-card {
  width: min(28rem, 100%);
  border-radius: 1rem;
  box-shadow: 0 1.5rem 3rem rgba(15, 23, 42, 0.45);
  background: var(--bs-body-bg);
  color: var(--bs-body-color);
  transform: translateY(1rem);
  transition: transform 0.25s ease;
}

.user-story-overlay.show .user-story-card {
  transform: translateY(0);
}

.user-story-rating {
  display: inline-flex;
  flex-direction: row-reverse;
  gap: 0.35rem;
}

.user-story-feedback-options {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.user-story-rating-hint {
  margin-left: auto;
  font-style: italic;
  color: var(--bs-secondary-color);
}

.user-story-rating input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.user-story-rating label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.75rem;
  color: rgba(148, 163, 184, 0.7);
  cursor: pointer;
  transition: transform 0.2s ease, color 0.2s ease;
}

.user-story-rating label:hover,
.user-story-rating label:focus-visible,
.user-story-rating label:hover ~ label {
  color: var(--site-accent);
}

.user-story-rating input:checked ~ label {
  color: var(--site-accent-strong);
}

.user-story-rating label:active {
  transform: scale(0.95);
}

.user-story-alert {
  transition: opacity 0.2s ease;
}

@media (max-width: 767.98px) {
  .user-story-toggle {
    right: 1.25rem;
    bottom: 1.25rem;
  }

  .user-story-overlay {
    align-items: stretch;
    padding: 1rem;
  }

  .user-story-card {
    width: 100%;
    border-radius: 1rem;
  }
}

.chat-widget {
  position: fixed;
  left: 1.5rem;
  bottom: 1.5rem;
  z-index: 1090;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.5rem;
}

.chat-toggle {
  position: relative;
  border: 0;
  border-radius: 50%;
  width: 3rem;
  height: 3rem;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--site-support), var(--site-support-strong));
  color: var(--site-support-text);
  box-shadow: 0 1.25rem 2.5rem rgba(15, 23, 42, 0.35);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.chat-toggle:hover,
.chat-toggle:focus-visible {
  transform: translateY(-2px) scale(1.02);
  box-shadow: 0 1.75rem 3rem rgba(15, 23, 42, 0.45);
}

.chat-toggle .chat-toggle-icon {
  display: inline-flex;
}

.chat-toggle .chat-toggle-icon svg {
  width: 1.5rem;
  height: 1.5rem;
  display: block;
}

.chat-toggle .chat-toggle-label {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.chat-toggle .chat-unread {
  position: absolute;
  top: -0.35rem;
  right: -0.35rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.5rem;
  height: 1.5rem;
  padding: 0 0.35rem;
  border-radius: 999px;
  font-size: 0.65rem;
  background: #16a34a;
  color: #fff;
  box-shadow: 0 0.35rem 0.85rem rgba(14, 116, 44, 0.45);
}

.chat-toggle .chat-unread[hidden] {
  display: none;
}

.chat-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: flex-end;
  justify-content: flex-start;
  padding: 1.5rem;
  background: rgba(15, 23, 42, 0.45);
  z-index: 1080;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.chat-overlay.show {
  opacity: 1;
  pointer-events: auto;
}

.chat-drawer {
  width: min(28rem, 100%);
  border-radius: 1rem;
  background: var(--bs-body-bg);
  color: var(--bs-body-color);
  box-shadow: 0 1.5rem 3rem rgba(15, 23, 42, 0.45);
  border: 1px solid rgba(21, 128, 61, 0.25);
  overflow: hidden;
  transform: translateY(1rem);
  opacity: 0;
  transition: transform 0.25s ease, opacity 0.25s ease;
  display: flex;
  flex-direction: column;
}

.chat-overlay.show .chat-drawer {
  transform: translateY(0);
  opacity: 1;
}

.chat-widget.open .chat-toggle {
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.25rem;
  background: linear-gradient(135deg, rgba(22, 163, 74, 0.18), rgba(16, 185, 129, 0.25));
  border-bottom: 1px solid rgba(21, 128, 61, 0.35);
}

.chat-header h2 {
  margin: 0;
  font-size: 1rem;
}

.chat-header small {
  display: block;
  font-size: 0.75rem;
  opacity: 0.8;
}

.chat-messages {
  flex: 1 1 auto;
  max-height: 18rem;
  overflow-y: auto;
  padding: 1rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.chat-message {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  font-size: 0.9rem;
  line-height: 1.45;
}

.chat-message .chat-body {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  flex: 1 1 auto;
  min-width: 0;
}

.chat-message.staff {
  flex-direction: row-reverse;
}

.chat-message.staff .chat-body {
  align-items: flex-end;
}

.chat-message.staff .chat-meta {
  text-align: right;
}

.chat-avatar {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  object-fit: cover;
  box-shadow: 0 0.35rem 0.75rem rgba(15, 23, 42, 0.25);
  border: 1px solid rgba(21, 128, 61, 0.25);
  background: rgba(22, 163, 74, 0.1);
  flex-shrink: 0;
}

.chat-bubble {
  padding: 0.6rem 0.9rem;
  border-radius: 0.85rem;
  background: rgba(34, 197, 94, 0.16);
  border: 1px solid rgba(22, 163, 74, 0.15);
  max-width: 100%;
  word-break: break-word;
  white-space: pre-wrap;
}

.chat-message.staff .chat-bubble {
  background: rgba(21, 128, 61, 0.22);
  border-color: rgba(21, 128, 61, 0.3);
}

.chat-meta {
  font-size: 0.75rem;
  color: rgba(21, 94, 49, 0.75);
}

.chat-form {
  border-top: 1px solid rgba(21, 128, 61, 0.25);
  padding: 0.75rem 1.25rem 1.25rem;
  background: var(--bs-body-bg);
}

.chat-form textarea {
  resize: vertical;
  min-height: 3.5rem;
}

.chat-actions {
  margin-top: 0.5rem;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
}

.chat-actions .chat-session-hint {
  color: rgba(var(--site-support-rgb), 0.65);
}

.chat-form .btn-primary {
  background: linear-gradient(135deg, var(--site-support), var(--site-support-strong));
  border-color: var(--site-support);
  color: var(--site-support-text);
  box-shadow: 0 0.75rem 1.5rem rgba(15, 23, 42, 0.25);
}

.chat-form .btn-primary:hover,
.chat-form .btn-primary:focus-visible {
  background: linear-gradient(135deg, var(--site-support-strong), var(--site-support));
  border-color: var(--site-support-strong);
  color: var(--site-support-text);
}

.chat-session-hint {
  font-size: 0.75rem;
  opacity: 0.7;
}

body.chat-open {
  overflow: hidden;
}

@media (max-width: 575.98px) {
  .chat-widget {
    left: 1rem;
    bottom: 1rem;
  }
}

@media (max-width: 767.98px) {
  .chat-overlay {
    align-items: stretch;
    justify-content: flex-start;
    padding: 1rem;
  }

  .chat-drawer {
    width: 100%;
    max-width: none;
    border-radius: 1rem;
  }
}
