.post-details-layout {
  align-items: start;
}

.post-details-aside-collapsible {
  display: block;
  min-width: 0;
}

.post-details-aside-collapsible > summary {
  list-style: none;
}

.post-details-aside-collapsible > summary::-webkit-details-marker {
  display: none;
}

.post-details-aside-toggle {
  cursor: pointer;
  user-select: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
}

.post-details-aside-toggle:hover {
  border-color: var(--theme-frontend-card-border-hover);
  box-shadow: var(--theme-frontend-card-shadow-hover);
}

.post-details-aside-toggle:focus-visible {
  outline: none;
  box-shadow: var(--theme-frontend-action-focus-ring);
}

.post-details-aside-toggle-meta {
  width: 100%;
  min-width: 0;
}

.post-details-aside-toggle > * {
  min-width: 0;
}

.post-details-aside-toggle-state {
  color: var(--theme-text-muted);
}

.post-details-aside-toggle-state-collapsed {
  display: none;
}

.post-details-aside-toggle-icon {
  display: inline-flex;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  border: 1px solid var(--theme-frontend-card-border);
  border-radius: 9999px;
  background: var(--theme-frontend-subpanel-background);
  color: var(--theme-text-secondary);
  transition: transform 0.2s ease, border-color 0.2s ease, background-color 0.2s ease, color 0.2s ease;
}

.post-details-aside-toggle-icon svg {
  width: 1.125rem;
  height: 1.125rem;
}

.post-details-aside-collapsible:not([open]) .post-details-aside-toggle-icon {
  transform: rotate(180deg);
}

.post-details-aside-collapsible:not([open]) .post-details-aside-toggle-state-expanded {
  display: none;
}

.post-details-aside-collapsible:not([open]) .post-details-aside-toggle-state-collapsed {
  display: inline;
}

.post-details-aside-content {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  min-width: 0;
}

.post-toc-panel {
  min-height: 0;
}

.post-toc-count {
  flex-shrink: 0;
}

.post-toc-nav {
  max-height: min(52vh, 28rem);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-right: 0.25rem;
}

.post-aside-panel {
  flex-shrink: 0;
}

.post-aside-tag-list {
  overscroll-behavior: contain;
}

.post-toc-list {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.post-toc-item {
  min-width: 0;
}

.post-toc-link {
  display: block;
  border: 1px solid transparent;
  border-radius: 0.9rem;
  padding: 0.55rem 0.75rem 0.55rem calc(0.75rem + (var(--toc-depth, 0) * 0.75rem));
  color: var(--theme-text-muted);
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1.45;
  text-decoration: none;
  overflow-wrap: anywhere;
  transition: border-color 0.2s ease, background-color 0.2s ease, color 0.2s ease;
}

.post-toc-link:hover,
.post-toc-link:focus-visible {
  border-color: var(--theme-frontend-card-border-hover);
  background: var(--theme-frontend-subpanel-background);
  color: var(--theme-brand-text);
  text-decoration: none;
  outline: none;
}

.post-toc-link-active {
  border-color: color-mix(in srgb, var(--theme-brand-text) 22%, var(--theme-frontend-card-border));
  background: var(--theme-brand-surface);
  color: var(--theme-brand-text-strong);
}

.markdown-content h2,
.markdown-content h3,
.markdown-content h4 {
  scroll-margin-top: calc(var(--sticky-header-offset, 5.5rem) + 1.25rem);
}

.post-floating-actions {
  position: fixed;
  right: max(1rem, calc((100vw - min(100vw, 96rem)) / 2 + 1rem));
  bottom: 1.25rem;
  z-index: 40;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.post-floating-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-width: 4.75rem;
  min-height: 2.75rem;
  border: 1px solid var(--theme-frontend-card-border);
  border-radius: 9999px;
  background: var(--theme-frontend-glass-background);
  color: var(--theme-text-secondary);
  font-size: 0.8125rem;
  font-weight: 700;
  text-decoration: none;
  box-shadow: var(--theme-frontend-card-shadow);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  transition: border-color 0.2s ease, background-color 0.2s ease, color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

.post-floating-action:hover,
.post-floating-action:focus-visible {
  border-color: var(--theme-frontend-card-border-hover);
  color: var(--theme-brand-text);
  text-decoration: none;
  box-shadow: var(--theme-frontend-card-shadow-hover);
  outline: none;
  transform: translateY(-1px);
}

.post-floating-action svg {
  width: 1rem;
  height: 1rem;
  flex-shrink: 0;
}

.comment-list-section[data-comment-list-collapsed="true"] .comment-list-body {
  display: none;
}

.comment-list-header {
  align-items: flex-start;
  border-bottom: 1px solid var(--theme-frontend-card-border);
  padding-bottom: 1rem;
}

.comment-list-controls {
  min-width: min(100%, 18rem);
}

.comment-sort-control {
  width: min(100%, 9.5rem);
}

.comment-sort-select {
  min-height: 2.25rem;
  border-radius: 9999px;
  padding: 0.45rem 2.25rem 0.45rem 0.85rem;
  font-size: 0.8125rem;
  font-weight: 700;
  line-height: 1.25rem;
}

.comment-sort-control .frontend-select-icon {
  right: 0.85rem;
  width: 1rem;
  height: 1rem;
}

.comment-toggle-button {
  min-height: 2.25rem;
  padding: 0.45rem 0.85rem;
  font-size: 0.8125rem;
}

@media (min-width: 1024px) {
  .post-details-layout {
    --post-details-aside-viewport-gap: 1.25rem;
    --post-details-aside-collapsed-height: 24rem;
    --post-details-aside-available-height: calc(100dvh - var(--sticky-header-offset, 5.5rem) - var(--post-details-aside-viewport-gap, 4rem));
    --post-details-aside-shell-height: var(--post-details-aside-available-height);
    --post-toc-nav-available-height: clamp(7rem, 32vh, 24rem);
    grid-template-columns: minmax(0, 2.15fr) minmax(22rem, 0.85fr);
    transition: grid-template-columns 0.25s ease, gap 0.25s ease;
  }

  .post-details-layout.post-details-layout-sidebar-collapsed,
  .post-details-layout[data-sidebar-collapsed="true"] {
    grid-template-columns: minmax(0, 1fr) 4.75rem;
    gap: 1rem;
  }

  .post-details-layout:has(.post-details-aside-collapsible:not([open])) {
    grid-template-columns: minmax(0, 1fr) 4.75rem;
    gap: 1rem;
  }

  .post-details-aside {
    position: sticky;
    top: var(--sticky-header-offset, 5.5rem);
    align-self: start;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-gutter: stable;
    padding-right: 0.25rem;
    max-height: var(--post-details-aside-shell-height, var(--post-details-aside-available-height));
  }

  .post-details-aside-collapsible {
    box-sizing: border-box;
    width: min(100%, 22rem);
    margin-left: auto;
    max-height: none;
    overflow: visible;
    transition: width 0.25s ease;
  }

  .post-details-aside-collapsible[open] {
    height: auto;
  }

  .post-details-aside-collapsible > summary {
    flex-shrink: 0;
  }

  .post-details-aside-collapsible[open] .post-details-aside-content {
    display: grid;
    grid-template-rows: auto auto auto;
    min-height: 0;
    overflow: visible;
    padding-right: 0;
  }

  .post-toc-panel {
    display: flex;
    flex-direction: column;
    min-height: 0;
    padding: 1.25rem;
  }

  .post-toc-nav {
    min-height: min(7rem, var(--post-toc-nav-available-height, 7rem));
    max-height: var(--post-toc-nav-available-height, clamp(7rem, 32vh, 24rem));
    margin-top: 0.75rem;
  }

  .post-details-aside-collapsible[data-toc-layout-constrained="true"] .post-details-aside-content {
    gap: 0.75rem;
  }

  .post-details-aside-collapsible[data-toc-layout-constrained="true"] .post-toc-panel,
  .post-details-aside-collapsible[data-toc-layout-constrained="true"] .post-aside-panel {
    padding: 0.875rem;
  }

  .post-details-aside-collapsible[data-toc-layout-constrained="true"] .post-toc-panel .frontend-muted-text,
  .post-details-aside-collapsible[data-toc-layout-constrained="true"] .post-aside-panel .frontend-muted-text {
    line-height: 1.5rem;
  }

  .post-aside-panel {
    padding: 1.25rem;
  }

  .post-aside-info-panel .frontend-divider-y {
    margin-top: 0.75rem;
  }

  .post-aside-info-panel .frontend-divider-y > div {
    padding-top: 0.5rem;
    padding-bottom: 0.5rem;
  }

  .post-aside-tags-panel > p,
  .post-aside-tag-list {
    margin-top: 0.75rem;
  }

  .post-aside-tag-list {
    max-height: 8.5rem;
    overflow-y: auto;
    padding-right: 0.125rem;
  }

  .post-aside-tag-list .frontend-badge {
    padding: 0.375rem 0.75rem;
    font-size: 0.8125rem;
    line-height: 1.125rem;
  }

  .post-details-aside-collapsible:not([open]) {
    width: 4.75rem;
  }

  .post-details-aside-collapsible:not([open]) .post-details-aside-toggle {
    align-items: center;
    justify-content: center;
    min-height: min(var(--post-details-aside-collapsed-height, 26rem), var(--post-details-aside-available-height));
    padding: 1rem 0.875rem;
  }

  .post-details-aside-collapsible:not([open]) .post-details-aside-toggle > .min-w-0 {
    display: none;
  }

  .post-details-aside-collapsible:not([open]) .post-details-aside-toggle-meta {
    width: auto;
    flex-direction: column-reverse;
    justify-content: center;
    gap: 0.875rem;
  }

  .post-details-aside-collapsible:not([open]) .post-details-aside-toggle-state {
    writing-mode: vertical-rl;
    text-orientation: mixed;
    letter-spacing: 0.08em;
  }

  .post-details-aside-collapsible:not([open]) .post-details-aside-content {
    display: none;
  }
}

@media (min-width: 1280px) {
  .post-details-layout {
    grid-template-columns: minmax(0, 2.35fr) minmax(23rem, 0.9fr);
  }

  .post-details-layout.post-details-layout-sidebar-collapsed,
  .post-details-layout[data-sidebar-collapsed="true"] {
    grid-template-columns: minmax(0, 1fr) 4.75rem;
    gap: 1.25rem;
  }

  .post-details-layout:has(.post-details-aside-collapsible:not([open])) {
    grid-template-columns: minmax(0, 1fr) 4.75rem;
    gap: 1.25rem;
  }

  .post-details-aside-collapsible {
    width: min(100%, 23rem);
  }
}

@media (min-width: 1024px) and (max-height: 980px) {
  .post-details-layout {
    --post-details-aside-viewport-gap: 1rem;
    --post-details-aside-collapsed-height: 22rem;
  }

  .post-details-aside-content {
    gap: 1rem;
  }

  .post-toc-panel,
  .post-aside-panel {
    padding: 1rem;
  }

  .post-aside-tag-list {
    max-height: 7rem;
  }
}

@media (min-width: 1024px) and (max-height: 860px) {
  .post-details-layout {
    --post-details-aside-viewport-gap: 0.875rem;
    --post-details-aside-collapsed-height: 19.5rem;
  }

  .post-details-aside-toggle.frontend-panel {
    padding: 1rem;
  }

  .post-details-aside-content {
    gap: 0.875rem;
    margin-top: 0.75rem;
  }

  .post-toc-panel,
  .post-aside-panel {
    padding: 0.875rem;
  }

  .post-toc-panel .frontend-muted-text,
  .post-aside-panel .frontend-muted-text {
    line-height: 1.5rem;
  }

  .post-aside-info-panel .frontend-divider-y > div {
    padding-top: 0.375rem;
    padding-bottom: 0.375rem;
  }

  .post-aside-tag-list {
    max-height: 5.75rem;
  }

}

@media (min-width: 1024px) and (max-height: 760px) {
  .post-details-layout {
    --post-details-aside-viewport-gap: 0.75rem;
    --post-details-aside-collapsed-height: 17rem;
  }

  .post-toc-panel {
    min-height: 0;
  }

  .post-aside-info-panel .frontend-divider-y > div {
    padding-top: 0.25rem;
    padding-bottom: 0.25rem;
  }

  .post-aside-tag-list {
    max-height: 4.5rem;
  }

}

@media (min-width: 640px) {
  .post-details-aside-toggle-meta {
    width: auto;
    justify-content: flex-end;
  }
}

@media (max-width: 640px) {
  .post-floating-actions {
    right: 0.875rem;
    bottom: 0.875rem;
    gap: 0.5rem;
  }

  .post-floating-action {
    min-width: 2.75rem;
    width: 2.75rem;
    padding-inline: 0;
  }

  .post-floating-action span {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
  }

  .post-details-aside-toggle {
    gap: 0.75rem;
  }

  .post-details-aside-toggle-meta {
    justify-content: space-between;
  }

  .post-details-aside-content {
    margin-top: 1rem;
  }

  .post-toc-nav {
    max-height: min(18rem, 52vh);
  }

  .post-toc-link {
    padding-top: 0.65rem;
    padding-bottom: 0.65rem;
  }

  .comment-list-controls {
    width: 100%;
    justify-content: flex-start;
  }

  .comment-sort-control {
    width: 100%;
  }

  .comment-toggle-button {
    width: 100%;
  }
}
