html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

.article-title {
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.article-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.article-sidebar-toggle {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.article-sidebar-fab,
.article-sidebar-backdrop,
.article-desktop-toc-fab,
.article-desktop-toc-backdrop {
  display: none;
}

.article-sidebar-stack {
  display: grid;
  gap: 20px;
}

.toc-link {
  width: 100%;
  border: none;
  padding: 4px 0;
  background: transparent;
  color: var(--text-color);
  text-align: left;
  font: inherit;
  cursor: pointer;
  transition: color 0.2s;
}

.toc-link:hover {
  color: var(--link-color, #6a5af9);
}

.toc-link.active {
  color: var(--highlight-color, #ff6ad5);
  font-weight: 700;
}

@media (min-width: 901px) {
  .article-desktop-toc-fab {
    position: fixed;
    right: 18px;
    bottom: 20px;
    z-index: 1500;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 14px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.92);
    border: 1px solid rgba(106, 90, 249, 0.18);
    box-shadow: 0 14px 28px rgba(55, 74, 139, 0.16);
    backdrop-filter: blur(12px);
    color: var(--text-color);
    font-size: 0.92rem;
    font-weight: 700;
    cursor: pointer;
    user-select: none;
  }

  .article-desktop-toc-fab-icon {
    width: 16px;
    height: 12px;
    position: relative;
    display: inline-block;
  }

  .article-desktop-toc-fab-icon::before,
  .article-desktop-toc-fab-icon::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    height: 2px;
    border-radius: 999px;
    background: currentColor;
  }

  .article-desktop-toc-fab-icon::before {
    top: 2px;
    box-shadow: 0 4px 0 currentColor;
  }

  .article-desktop-toc-fab-icon::after {
    bottom: 0;
  }

  .article-desktop-toc-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1490;
    background: rgba(12, 18, 34, 0.18);
    backdrop-filter: blur(2px);
  }

  .article-desktop-toc-panel {
    position: fixed;
    top: 82px;
    right: 18px;
    bottom: 20px;
    z-index: 1501;
    width: min(320px, calc(100vw - 36px));
    box-sizing: border-box;
    pointer-events: none;
    transform: translateX(calc(100% + 20px));
    transition: transform 0.22s ease;
  }

  .article-desktop-toc-card {
    height: 100%;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 16px;
    box-sizing: border-box;
    background: rgba(246, 248, 255, 0.96);
  }

  .article-desktop-toc-card #toc-floating-desktop {
    min-height: 0;
    flex: 1;
    overflow-y: auto;
    padding-right: 4px;
  }

  .article-desktop-toc-shell.is-open .article-desktop-toc-backdrop {
    display: block;
  }

  .article-desktop-toc-shell.is-open .article-desktop-toc-fab {
    background: rgba(106, 90, 249, 0.96);
    color: #fff;
  }

  .article-desktop-toc-shell.is-open .article-desktop-toc-panel {
    transform: translateX(0);
    pointer-events: auto;
  }
}

@media (max-width: 900px) {
  .article-layout {
    grid-template-columns: 1fr;
    gap: 16px;
    padding: 18px 14px 0;
  }

  .article-main,
  .article-comments-shell {
    width: 100%;
    box-sizing: border-box;
  }

  .article-main {
    padding: 20px 18px;
    border-radius: 20px;
  }

  .article-main > .article-title,
  .article-main > .article-meta,
  .article-main > .article-cover,
  .article-main > .article-actions,
  .article-main > .article-feedback,
  .article-main > .article-series-inline,
  .article-main > .markdown-body {
    width: 100%;
  }

  .article-title {
    font-size: 1.62rem;
    margin-bottom: 8px;
  }

  .article-meta {
    margin-bottom: 15px;
    font-size: 0.84rem;
    gap: 6px;
  }

  .article-cover {
    margin: 16px 0 18px;
    border-radius: 14px;
  }

  .article-actions {
    margin: 0 0 18px;
  }

  .article-series-inline {
    margin: 0 0 18px;
    padding: 14px;
  }

  .article-series-inline-head {
    flex-direction: column;
    align-items: flex-start;
  }

  .article-sidebar {
    width: 100%;
    gap: 0;
  }

  .article-sidebar-fab {
    position: fixed;
    right: 14px;
    bottom: 18px;
    z-index: 1400;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    max-width: min(72vw, 280px);
    padding: 12px 14px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.92);
    border: 1px solid rgba(106, 90, 249, 0.18);
    box-shadow: 0 14px 28px rgba(55, 74, 139, 0.16);
    backdrop-filter: blur(12px);
    color: var(--text-color);
    font-size: 0.92rem;
    font-weight: 700;
    cursor: pointer;
    user-select: none;
  }

  .article-sidebar-fab-text {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .article-sidebar-fab-icon {
    width: 16px;
    height: 12px;
    flex-shrink: 0;
    position: relative;
    display: inline-block;
  }

  .article-sidebar-fab-icon::before,
  .article-sidebar-fab-icon::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    height: 2px;
    border-radius: 999px;
    background: currentColor;
  }

  .article-sidebar-fab-icon::before {
    top: 2px;
    box-shadow: 0 4px 0 currentColor;
  }

  .article-sidebar-fab-icon::after {
    bottom: 0;
  }

  .article-sidebar-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1390;
    background: rgba(12, 18, 34, 0.22);
    backdrop-filter: blur(2px);
  }

  .article-sidebar-stack {
    position: fixed;
    top: 70px;
    right: 0;
    bottom: 0;
    z-index: 1401;
    width: min(86vw, 340px);
    padding: 12px 12px 22px;
    box-sizing: border-box;
    overflow-y: auto;
    display: grid;
    gap: 12px;
    background: rgba(246, 248, 255, 0.94);
    border-left: 1px solid rgba(106, 90, 249, 0.14);
    box-shadow: -16px 0 38px rgba(28, 41, 86, 0.18);
    backdrop-filter: blur(16px);
    transform: translateX(108%);
    transition: transform 0.22s ease;
  }

  .article-sidebar-toggle:not(:checked) + .article-sidebar-fab + .article-sidebar-backdrop {
    display: none;
  }

  .article-sidebar-toggle:checked + .article-sidebar-fab + .article-sidebar-backdrop {
    display: block;
  }

  .article-sidebar-toggle:checked + .article-sidebar-fab {
    background: rgba(106, 90, 249, 0.96);
    color: #fff;
  }

  .article-sidebar-toggle:checked + .article-sidebar-fab + .article-sidebar-backdrop + .article-sidebar-stack {
    transform: translateX(0);
  }

  .article-comments-layout {
    grid-template-columns: 1fr;
    margin: 16px auto 34px;
    padding: 0 14px;
  }

  .article-comments-shell {
    border-radius: 20px;
    padding: 22px 18px;
  }

  .markdown-body {
    max-width: none;
    font-size: 15px;
    line-height: 1.82;
  }
}

@media (max-width: 600px) {
  body {
    padding-top: 64px;
  }

  .article-layout {
    padding: 16px 12px 0;
    gap: 14px;
  }

  .article-main {
    padding: 17px 15px 18px;
    border-radius: 18px;
  }

  .article-title {
    font-size: 1.42rem;
  }

  .article-meta {
    font-size: 0.8rem;
    margin-bottom: 13px;
  }

  .article-actions {
    flex-direction: column;
    gap: 10px;
  }

  .article-series-inline-head p {
    white-space: normal;
  }

  .article-action-btn {
    width: 100%;
    min-height: 44px;
    justify-content: center;
  }

  .article-sidebar-fab {
    right: 12px;
    bottom: 14px;
    max-width: min(78vw, 250px);
    padding: 11px 13px;
    font-size: 0.88rem;
  }

  .article-sidebar-stack {
    top: 70px;
    width: min(90vw, 320px);
    padding: 12px 12px 22px;
  }

  .sidebar-card {
    padding: 15px;
    border-radius: 16px;
  }

  .sidebar-card h3 {
    margin-bottom: 10px;
    padding-bottom: 6px;
    font-size: 1rem;
  }

  .stats-card {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    padding: 12px;
  }

  .article-comments-layout {
    padding: 0 12px;
    margin: 14px auto 26px;
  }

  .article-comments-shell {
    padding: 17px 15px 18px;
    border-radius: 18px;
  }

  .comments-header {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: start;
    gap: 10px;
    margin-bottom: 14px;
  }

  .comments-header h2 {
    font-size: 1.18rem;
  }

  .comments-caption {
    margin-top: 4px;
    font-size: 0.82rem;
    line-height: 1.5;
  }

  .comments-total {
    min-width: 58px;
    padding: 8px 12px;
    font-size: 0.9rem;
    justify-self: end;
  }

  .comment-form {
    padding: 15px;
    border-radius: 16px;
  }

  .comment-input {
    padding: 11px 12px;
  }

  .comment-textarea {
    min-height: 120px;
    padding: 12px;
  }

  .comment-form-footer {
    gap: 12px;
  }

  .comment-card {
    padding: 14px;
    border-radius: 16px;
  }

  .comment-card-header {
    gap: 10px;
    margin-bottom: 10px;
  }

  .comment-avatar {
    width: 34px;
    height: 34px;
    font-size: 0.9rem;
  }

  .comment-actions {
    gap: 8px;
  }

  .comment-action-button {
    flex: 1 1 calc(50% - 8px);
    justify-content: center;
  }

  .markdown-body {
    font-size: 14.5px;
    line-height: 1.8;
  }

  .markdown-body h1,
  .markdown-body h2,
  .markdown-body h3,
  .markdown-body h4,
  .markdown-body h5,
  .markdown-body h6 {
    margin-top: 1.4em;
  }

  .markdown-body h1 {
    font-size: 1.5em;
  }

  .markdown-body h2 {
    font-size: 1.18em;
    padding: 6px 10px;
    border-left-width: 3px;
  }

  .markdown-body h3 {
    font-size: 1.04em;
    padding-left: 8px;
  }

  .markdown-body ul,
  .markdown-body ol {
    margin-left: 1.1em;
    padding-left: 0.2em;
  }

  .markdown-body blockquote {
    padding: 12px 13px 12px 16px;
    margin: 1.15em 0;
    border-radius: 0 12px 12px 0;
  }

  .markdown-body blockquote::before {
    left: 8px;
    font-size: 2.2em;
  }

  .markdown-body pre {
    margin: 1.1em 0;
    padding: 14px;
    padding-top: 34px;
    border-radius: 12px;
    font-size: 12.5px;
  }

  .markdown-body pre .code-dots-bar {
    padding: 0 8px;
  }

  .markdown-body pre .copy-btn,
  .markdown-body pre .lang-label {
    font-size: 10px;
  }

  .markdown-body table {
    display: block;
    width: 100%;
    overflow-x: auto;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
  }

  .markdown-body th,
  .markdown-body td {
    padding: 8px 10px;
    font-size: 0.84em;
  }

  .markdown-body img,
  .markdown-body video,
  .markdown-body iframe {
    margin: 1.05em auto;
    border-radius: 12px;
  }

  .article-image-lightbox {
    padding: 14px;
  }

  .article-image-lightbox-panel {
    padding: 14px 14px 12px;
    border-radius: 18px;
  }

  .article-image-lightbox-close {
    top: 10px;
    right: 10px;
    width: 36px;
    height: 36px;
  }

  .article-image-lightbox-image {
    max-height: 72vh;
    border-radius: 12px;
  }

  .article-image-lightbox-caption {
    font-size: 0.86rem;
  }

  .markdown-body hr {
    margin: 1.8em 0;
  }
}
