/* Primary content is first in the DOM; desktop columns retain their positions. */
html body.page-not-found .page-grid .not-found-panel { min-height: 320px; padding: clamp(20px, 4vw, 40px); background: var(--panel); border: 1px solid var(--line); border-radius: 12px; }
.not-found-kicker { margin: 0 0 16px; color: var(--muted); }
.not-found-code { display: block; font-size: clamp(42px, 8vw, 80px); line-height: 1; font-weight: 800; color: var(--accent); }
.not-found-state h1 { margin: 18px 0; font-size: clamp(24px, 3vw, 34px); }
.not-found-state > p { line-height: 1.7; color: var(--muted); }
.not-found-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 24px; }
.not-found-actions a { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 10px 18px; text-decoration: none; }
.expert-badge { display: inline-flex; align-items: center; width: max-content; gap: 4px; padding: 3px 8px; border: 1px solid var(--accent); border-radius: 6px; color: var(--accent); background: var(--panel-2); font-size: 12px; line-height: 1.4; font-weight: 700; text-decoration: none; }
.user-link-wrap .expert-badge { margin-left: 6px; }
.experts-panel > h1 { margin-top: 0; }
.experts-panel p, .expert-profile-details p { line-height: 1.7; overflow-wrap: anywhere; }
.experts-method, .experts-empty { padding: 16px; border: 1px solid var(--line); border-radius: 10px; margin: 20px 0; background: var(--panel-2); }
.experts-method > summary { cursor: pointer; font-weight: 700; }
.expert-directory-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 16px; margin-top: 24px; }
.expert-card { display: flex; flex-direction: column; min-width: 0; padding: 18px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel-2); }
.expert-card-head { display: flex; gap: 14px; align-items: center; min-width: 0; }
.expert-card-head h2 { font-size: 18px; overflow-wrap: anywhere; margin: 0 0 8px; }
.expert-card-head .avatar-xl { flex-shrink: 0; width: 60px; height: 60px; }
.expert-card > .button-secondary { margin-top: auto; align-self: flex-start; }
.expert-specialty { font-weight: 700; }
.expert-profile-details { margin: 16px 0; padding: 16px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel-2); }
.expert-profile-details h2 { font-size: 18px; margin-top: 0; }
.expert-review-date { color: var(--muted); font-size: 13px; }
.expert-admin-form, .expert-search-form { display: grid; gap: 12px; max-width: 760px; margin: 20px 0; }
.expert-admin-form label, .expert-search-form label { display: grid; gap: 6px; }
.expert-admin-form input:not([type=checkbox]), .expert-admin-form textarea, .expert-search-form input { box-sizing: border-box; width: 100%; min-width: 0; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel-2); color: var(--text); font: inherit; }
.expert-admin-form .expert-checkbox { display: flex; align-items: center; gap: 8px; }
@media (max-width: 720px) { .expert-directory-grid { grid-template-columns: minmax(0,1fr); } .not-found-actions { flex-direction: column; } }
@media (min-width: 961px) {
  .seo-main-first > .left-col { grid-column: 1; grid-row: 1; }
  .seo-main-first > .center-col { grid-column: 2; grid-row: 1; }
  .seo-main-first > .right-col { grid-column: 3; grid-row: 1; }
}
.seo-editor-note { padding: 16px; margin: 14px 0; background: var(--panel-2); border-left: 3px solid var(--accent); border-radius: 8px; }
.seo-editor-note h2, .seo-section-heading { font-size: 19px; margin: 0 0 10px; }
.seo-editor-summary { width: 100%; margin: 12px 0; }
.seo-editor-summary > summary {
  display: flex;
  align-items: center;
  gap: 10px;
  width: max-content;
  max-width: 100%;
  margin-left: auto;
  padding: 9px 13px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel-2);
  color: var(--text);
  font-size: .86rem;
  font-weight: 700;
  line-height: 1.3;
  list-style: none;
  cursor: pointer;
}
.seo-editor-summary > summary::-webkit-details-marker { display: none; }
.seo-editor-summary > summary::after {
  content: '';
  width: 7px;
  height: 7px;
  margin-top: -3px;
  border-right: 2px solid var(--accent);
  border-bottom: 2px solid var(--accent);
  transform: rotate(45deg);
  transition: transform .22s ease;
}
.seo-editor-summary[open] > summary::after { transform: rotate(225deg); margin-top: 3px; }
.seo-editor-summary > summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.seo-editor-summary-content { overflow: hidden; }
.seo-editor-summary .seo-editor-note { margin: 12px 0 0; text-align: left; }
@media (prefers-reduced-motion: reduce) {
  .seo-editor-summary > summary::after { transition: none; }
}
.seo-origin-badge { display: inline-block; margin: 5px 0; padding: 3px 8px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 6px; font-size: 12px; color: var(--muted); }
/* Standalone entries use normal flow, independent of the topic feed layout. */
html body.page-entry .entry-page-grid .topic-main.panel { display: block; }
html body.page-entry .entry-page-grid .entry-detail-heading {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 14px;
  min-width: 0;
}
html body.page-entry .entry-page-grid .entry-detail-heading h1 {
  width: 100%;
  margin: 0;
  overflow-wrap: anywhere;
}
html body.page-entry .entry-page-grid .entry-detail-topic-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  align-self: flex-end;
  flex: 0 0 auto;
  width: auto;
  max-width: 100%;
  min-height: 40px;
  padding: 8px 14px;
  box-sizing: border-box;
  white-space: nowrap;
}
html body.page-entry .entry-page-grid .entry-card.full {
  grid-template-columns: 54px minmax(0, 1fr);
  gap: 16px;
}
html body.page-entry .entry-page-grid .comment-vote-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}
html body.page-entry .entry-page-grid .entry-content > .entry-body { padding: 0; }
html body.page-entry .entry-page-grid .entry-detail-annotations {
  margin-top: 10px;
  min-width: 0;
  overflow-wrap: anywhere;
}
html body.page-entry .entry-page-grid .entry-detail-annotations .seo-origin-badge {
  width: auto;
  max-width: 100%;
  box-sizing: border-box;
  line-height: 1.4;
}
html body.page-entry .entry-page-grid .entry-meta-right {
  position: static;
  width: 100%;
  max-width: 100%;
  margin: 14px 0 0;
}
html body.page-entry .entry-page-grid .entry-meta-right__identity,
html body.page-entry .entry-page-grid .entry-meta-right__submeta {
  flex-wrap: wrap;
  overflow-wrap: anywhere;
}
html body.page-entry .entry-page-grid .report-box-right {
  position: static;
  width: auto;
  max-width: 100%;
  margin: 14px 0 0;
  justify-content: flex-start;
}
@media (max-width: 720px) {
  html body.page-entry .entry-page-grid .entry-card.full {
    grid-template-columns: 44px minmax(0, 1fr);
    gap: 10px;
  }
}
.seo-updated, .seo-content-note { font-size: 13px; color: var(--muted); line-height: 1.6; }
.discussion-topic-meta .stream-topic-author { flex-wrap: wrap; }
.discussion-topic-meta .seo-updated-inline { margin: 0; font-size: 12px; }
.seo-hub-links { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.seo-hub-links a { padding: 7px 10px; background: var(--panel-2); border-radius: 7px; }
.seo-home-hubs h2 { font-size: 18px; }
.seo-home-title { font-size: 20px; line-height: 1.4; margin: 14px 18px; }
.seo-home-hubs summary { font-size: 16px; font-weight: 600; cursor: pointer; }
.seo-admin-form { display: grid; gap: 14px; }
.seo-admin-form label { display: grid; gap: 5px; }
.seo-admin-form textarea { width: 100%; min-height: 100px; }
.seo-admin-list { width: 100%; border-collapse: collapse; }
.seo-admin-list th, .seo-admin-list td { padding: 10px; border-bottom: 1px solid var(--line); text-align: left; }

/* Shared desktop rails: eleven complete rows with room around each heading. */
@media (min-width: 961px) {
  html body .page-grid > .left-col > .panel.left-topic-panel[data-sidebar-topics] {
    --sidebar-topic-padding: 13px;
    --sidebar-topics-height: 660px;
    position: sticky !important;
    top: calc(var(--header-sticky-offset, 162px) + 8px) !important;
    display: grid !important;
    grid-template-rows: auto auto auto !important;
    height: auto !important;
    max-height: none !important;
    min-height: 0 !important;
    overflow: hidden !important;
  }
  html body .page-grid > .left-col > .panel.left-topic-panel[data-sidebar-topics] .topic-list {
    display: block !important;
    height: var(--sidebar-topics-height) !important;
    max-height: var(--sidebar-topics-height) !important;
    min-height: 0 !important;
    margin: 0 !important;
    padding: 0 7px 0 0 !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    overscroll-behavior-y: contain;
    scrollbar-width: thin !important;
    scrollbar-color: var(--muted) transparent !important;
    scrollbar-gutter: stable !important;
  }
  html body .page-grid > .left-col > .panel.left-topic-panel[data-sidebar-topics] .topic-list li {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) !important;
    box-sizing: border-box;
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
    margin: 0 !important;
    padding: var(--sidebar-topic-padding) 0 !important;
    border: 0 !important;
    border-bottom: 1px solid color-mix(in srgb, var(--line) 68%, transparent) !important;
    box-shadow: none !important;
    align-items: center !important;
  }
  html body .page-grid > .left-col > .panel.left-topic-panel[data-sidebar-topics] .panel-title {
    margin: 15px 0 8px !important;
    padding: 0 !important;
    line-height: 1.2 !important;
  }
  html body .page-grid > .left-col > .panel.left-topic-panel[data-sidebar-topics] .topic-list.with-count li span {
    display: none !important;
  }
  html body .page-grid > .left-col > .panel.left-topic-panel[data-sidebar-topics] .topic-list li a {
    display: -webkit-box !important;
    -webkit-box-orient: vertical !important;
    -webkit-line-clamp: 2 !important;
    overflow: hidden !important;
    white-space: normal !important;
    line-height: 1.42 !important;
    font-size: 0.94rem !important;
  }
  html body .page-grid > .left-col > .panel.left-topic-panel[data-sidebar-topics] .topic-list::-webkit-scrollbar {
    display: block !important;
    width: 6px !important;
    background: transparent;
  }
  html body .page-grid > .left-col > .panel.left-topic-panel[data-sidebar-topics] .topic-list::-webkit-scrollbar-thumb {
    background: var(--muted) !important;
    border-radius: 6px;
  }
  html body .page-grid > .left-col > .panel.left-topic-panel[data-sidebar-topics] > .left-topic-scrollbar:not([hidden]) {
    display: block !important;
    width: 6px;
    background: var(--muted);
    touch-action: none;
  }
  html body .page-grid > .left-col > .panel.left-topic-panel[data-sidebar-topics]:has(> .left-topic-scrollbar:not([hidden])) .topic-list {
    scrollbar-width: none !important;
    scrollbar-gutter: auto !important;
    scroll-behavior: auto !important;
  }
  html body .page-grid > .left-col > .panel.left-topic-panel[data-sidebar-topics]:has(> .left-topic-scrollbar:not([hidden])) .topic-list::-webkit-scrollbar {
    display: none !important;
  }
}

/* Open edit/report forms occupy their own row instead of covering other entries. */
html body.page-topic .topic-page-grid .stream-topic-author:has(> details.topic-owner-menu[open]) {
  flex-wrap: wrap !important;
}
html body.page-topic .topic-page-grid .stream-topic-author > details.topic-owner-menu[open] {
  flex-basis: 100%;
  order: 1;
}
html body.page-topic .topic-page-grid .topic-main.panel details:is(.owner-menu, .report-box)[open] {
  position: relative !important;
  inset: auto !important;
  display: block !important;
  width: 100% !important;
  max-width: 100% !important;
  height: auto !important;
  margin: 12px 0 !important;
  transform: none !important;
}
html body.page-topic .topic-page-grid .topic-main.panel details.owner-menu[open] > .owner-menu-panel,
html body.page-topic .topic-page-grid .topic-main.panel details.report-box[open] > .inline-report-form {
  position: static !important;
  inset: auto !important;
  box-sizing: border-box;
  width: 100% !important;
  max-width: 100% !important;
  max-height: min(70dvh, 560px) !important;
  margin: 8px 0 0 !important;
  overflow-x: hidden !important;
  overflow-y: auto !important;
  transform: none !important;
}
html body.page-topic .topic-page-grid .topic-main.panel .comment-entry-content:has(> details.owner-menu[open], > details.report-box[open]) > :is(.entry-meta-right, details.owner-menu, details.report-box) {
  position: relative !important;
  inset: auto !important;
  margin: 8px 0 !important;
  transform: none !important;
}
html body.page-topic .topic-page-grid .topic-main.panel .comment-entry-content:has(> details.owner-menu[open], > details.report-box[open]) > .entry-body {
  padding-bottom: 0 !important;
}
html body.page-topic .topic-page-grid .topic-main.panel .comment-entry-content:has(> details.owner-menu[open], > details.report-box[open]) > .entry-meta-right {
  display: grid !important;
  width: 100% !important;
  max-width: 100% !important;
  justify-items: end !important;
  text-align: right;
}
@media (max-width: 720px) {
  html body.page-topic .topic-page-grid {
    grid-template-columns: minmax(0, 1fr) !important;
  }
  html body.page-topic .topic-page-grid > .center-col {
    width: 100% !important;
    max-width: 100% !important;
  }
  html body.page-topic .topic-page-grid .topic-main.panel details.report-box[open] > .inline-report-form {
    grid-template-columns: minmax(0, 1fr) !important;
  }
}
html body.page-topic .topic-page-grid .topic-main.panel details.owner-menu[open] .owner-edit-form,
html body.page-topic .topic-page-grid .topic-main.panel details.owner-menu[open] .owner-edit-form label {
  min-width: 0;
  grid-template-columns: minmax(0, 1fr);
}
html body.page-topic .topic-page-grid .topic-main.panel details.owner-menu[open] textarea {
  min-width: 0;
  max-width: 100%;
}

.admin-expert-fields { margin-top: 14px; border: 1px solid var(--line); border-radius: 10px; padding: 12px; }
.admin-expert-fields > summary { cursor: pointer; font-weight: 700; }
.admin-expert-fields .expert-admin-form { max-width: none; margin-bottom: 0; }
.admin-user-role-form .expert-secondary-role { display: flex; align-items: center; gap: 8px; margin-top: 12px; }
.admin-user-role-form .expert-secondary-role[hidden] { display: none; }
