:root {
  /* colours — dark only */
  --bg: #0d1218;
  --surface: #131a23;
  --surface-elevated: #1a2430;
  --surface-muted: #1b2532;
  --text: #e6edf3;
  --muted: #9aa7b4;
  --border: #364152;
  --border-strong: #4b576b;
  --link: #7ab6ff;
  --link-visited: #c5b7ff;
  --focus: #7ab6ff;
  --success: #23472f;
  --danger: #5a252b;
  --shadow-sm: 0 1px 2px rgba(2, 6, 23, 0.45);
  --shadow-md: 0 12px 32px rgba(2, 6, 23, 0.45);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-pill: 999px;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-7: 32px;
  --content-max: 1560px;
  --trans-fast: 140ms ease;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  font-family: Georgia, "Times New Roman", serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
}

a {
  color: var(--link);
  text-decoration: none;
  transition: color var(--trans-fast);
}

a:visited {
  color: var(--link-visited);
}

a:hover {
  text-decoration: underline;
}

.topbar {
  display: grid;
  grid-template-columns: minmax(160px, 280px) minmax(280px, 1fr) auto;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-2) var(--space-4);
  background: var(--surface);
  border-bottom: 1px solid var(--border-strong);
  position: sticky;
  top: 0;
  z-index: 40;
  box-shadow: var(--shadow-sm);
}

.topbar-left {
  display: flex;
  align-items: baseline;
  gap: var(--space-3);
}

.mobile-nav-toggle {
  display: none;
}

.nav-backdrop {
  display: none;
}

.logo a {
  color: var(--text);
  font-size: 25px;
  font-weight: 700;
  letter-spacing: 0.2px;
}

.topbar-tagline {
  color: var(--muted);
  font-size: 13px;
}

.topbar-search {
  max-width: 720px;
}

.topbar-search-placeholder {
  min-height: 1px;
}

.search-form,
.search-form-inline {
  display: flex;
  gap: var(--space-2);
}

.search-form input {
  width: 100%;
}

.search-form input,
.search-form-inline input,
input,
textarea,
select {
  border: 1px solid var(--border-strong);
  background: var(--surface-elevated);
  color: var(--text);
  padding: 9px 11px;
  font-size: 14px;
  border-radius: var(--radius-sm);
  transition: border-color var(--trans-fast), box-shadow var(--trans-fast);
}

input:focus-visible,
textarea:focus-visible,
select:focus-visible,
button:focus-visible,
a:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

button {
  border: 1px solid var(--border-strong);
  background: linear-gradient(var(--surface-elevated), var(--surface-muted));
  color: var(--text);
  padding: 9px 13px;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: transform var(--trans-fast), border-color var(--trans-fast),
    background var(--trans-fast);
}

button:hover {
  border-color: var(--focus);
}

button:active {
  transform: translateY(1px);
}

.theme-toggle {
  white-space: nowrap;
  min-width: 98px;
}

.top-right {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-2);
}

.user-chip {
  font-size: 13px;
  color: var(--muted);
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
}

.wiki-shell {
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr);
  min-height: calc(100vh - 56px);
  max-width: var(--content-max);
  margin: 0 auto;
  width: 100%;
}

.sidebar {
  background: var(--surface-muted);
  border-right: 1px solid var(--border);
  padding: var(--space-5) var(--space-4);
}

.sidebar h4 {
  font-family: Arial, Helvetica, sans-serif;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 11px;
  margin: 0 0 var(--space-2);
  color: var(--muted);
}

.side-nav {
  margin-bottom: var(--space-5);
}

.sidebar a {
  display: block;
  margin: var(--space-1) 0;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  color: var(--text);
  transition: background var(--trans-fast), color var(--trans-fast);
}

.sidebar a:hover {
  background: var(--surface-elevated);
  color: var(--link);
  text-decoration: none;
}

.content {
  padding: var(--space-6);
  background: var(--surface);
  min-width: 0;
}

.subtitle {
  color: var(--muted);
  margin-top: -4px;
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  border-bottom: 1px solid var(--border);
  margin-bottom: var(--space-5);
  padding-bottom: var(--space-1);
}

.tabs a {
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  color: var(--muted);
  transition: background var(--trans-fast), color var(--trans-fast);
}

.tabs a.active {
  border: 1px solid var(--border);
  background: var(--surface-muted);
  color: var(--text);
  font-weight: 600;
}

.article-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 290px;
  gap: var(--space-6);
}

.article-layout.no-infobox {
  grid-template-columns: minmax(0, 1fr);
}

.article-main {
  min-width: 0;
}

.article-header {
  margin-bottom: var(--space-3);
}

.article-header h1 {
  margin: 0;
  font-size: clamp(30px, 4vw, 38px);
  line-height: 1.15;
}

.article-meta {
  margin: var(--space-2) 0 0;
  font-size: 13px;
  color: var(--muted);
}

.toc,
.infobox,
.categories,
.talk-post,
.diff {
  border: 1px solid var(--border);
  background: var(--surface-muted);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}

.toc {
  width: min(100%, 360px);
  padding: var(--space-3) var(--space-4);
}

.toc ol {
  margin: 0;
  padding-left: 20px;
}

.toc h3 {
  margin: 0 0 var(--space-2);
  font-size: 16px;
}

.lvl-2 {
  margin-left: 14px;
}

.lvl-3 {
  margin-left: 28px;
}

.lvl-4 {
  margin-left: 42px;
}

.infobox {
  padding: var(--space-3);
  height: max-content;
  position: sticky;
  top: 72px;
}

.infobox table {
  width: 100%;
  border-collapse: collapse;
}

.infobox th,
.infobox td,
.table th,
.table td {
  border: 1px solid var(--border);
  padding: 6px;
  font-size: 13px;
  vertical-align: top;
}

.infobox h4 {
  margin: 0 0 var(--space-2);
}

.article-surface {
  max-width: 110ch;
}

.wiki-body h1,
.wiki-body h2,
.wiki-body h3,
.wiki-body h4 {
  line-height: 1.22;
  margin-top: 1.4em;
  margin-bottom: 0.45em;
}

.wiki-body p,
.wiki-body li {
  line-height: 1.7;
}

.wiki-body p {
  margin: 0.6em 0;
}

.wiki-body code {
  font-family: "Courier New", Courier, monospace;
  background: var(--surface-muted);
  border: 1px solid var(--border);
  padding: 1px 4px;
  border-radius: 4px;
}

.wiki-image {
  margin: var(--space-4) 0;
}

.wiki-image img {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 4px;
  border: 1px solid var(--border);
}

.wiki-image figcaption {
  font-size: 13px;
  color: var(--muted);
  margin-top: var(--space-1);
}

.wiki-image.size-100 {
  width: 100%;
}

.wiki-image.size-75 {
  width: 75%;
}

.wiki-image.size-60 {
  width: 60%;
}

.wiki-image.size-50 {
  width: 50%;
}

.wiki-image.size-40 {
  width: 40%;
}

.wiki-image.size-33 {
  width: 33%;
}

.wiki-image.size-25 {
  width: 25%;
}

.wiki-image.align-center {
  margin-left: auto;
  margin-right: auto;
}

.wiki-image.align-right {
  float: right;
  margin-left: var(--space-4);
  margin-right: 0;
}

.wiki-image.align-left {
  float: left;
  margin-right: var(--space-4);
  margin-left: 0;
}

.wiki-body::after {
  content: "";
  display: table;
  clear: both;
}

.wiki-body img {
  max-width: 100%;
  height: auto;
}

.references {
  margin-top: var(--space-6);
}

.categories {
  margin-top: 24px;
  padding: var(--space-3) var(--space-4);
}

.categories-label {
  font-weight: 600;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 900px;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.table {
  width: 100%;
  border-collapse: collapse;
  margin-top: var(--space-3);
  background: var(--surface-elevated);
}

.table th {
  text-align: left;
  background: var(--surface-muted);
}

.talk-post {
  margin: var(--space-3) 0;
  padding: var(--space-4);
}

.diff {
  padding: var(--space-4);
  white-space: pre-wrap;
  overflow: auto;
  max-height: 70vh;
}

.add {
  background: var(--success);
}

.remove {
  background: var(--danger);
}

.guest-shell .wiki-shell {
  grid-template-columns: 1fr;
}

.login-shell {
  max-width: 1100px;
  margin: 64px auto;
  padding: 0 var(--space-4);
  display: grid;
  gap: var(--space-6);
  grid-template-columns: minmax(0, 1.3fr) minmax(320px, 420px);
}

.login-brand {
  padding: var(--space-5);
  border: 1px solid var(--border);
  background: var(--surface-muted);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}

.auth-kicker {
  font-family: Arial, Helvetica, sans-serif;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 12px;
  color: var(--muted);
  margin: 0 0 var(--space-2);
}

.login-brand h1 {
  font-size: 44px;
  margin: 0 0 var(--space-2);
  line-height: 1.12;
}

.login-brand p {
  font-size: 19px;
  color: var(--muted);
}

.login-card {
  border: 1px solid var(--border);
  background: var(--surface-elevated);
  padding: var(--space-6);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
}

.auth-form label {
  font-size: 14px;
}

.auth-form button {
  margin-top: var(--space-2);
}

.auth-footnote {
  margin-top: var(--space-4);
  color: var(--muted);
}

.editor-page {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.editor-header h1 {
  margin: 0;
}

.editor-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.editor-meta-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-3);
  padding: var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-muted);
}

.editor-meta-grid label {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  font-size: 14px;
}

.editor-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: var(--space-4);
  align-items: start;
}

.editor-main {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-elevated);
  overflow: hidden;
}

.editor-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  padding: var(--space-3);
  border-bottom: 1px solid var(--border);
  background: var(--surface-muted);
}

.snippet-btn {
  font-size: 13px;
  padding: 6px 10px;
}

.editor-label {
  display: block;
  padding: var(--space-3);
}

.editor-label textarea {
  width: 100%;
  resize: vertical;
  min-height: 58vh;
  font-family: "Courier New", Courier, monospace;
  line-height: 1.55;
}

.editor-status-row {
  display: flex;
  justify-content: space-between;
  gap: var(--space-3);
  flex-wrap: wrap;
  padding: var(--space-2) var(--space-3) var(--space-3);
  color: var(--muted);
  font-size: 13px;
}

.editor-muted {
  color: var(--muted);
  font-size: 13px;
}

.editor-sidepanel {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-muted);
  padding: var(--space-4);
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 72px;
}

.editor-sidepanel h3 {
  margin: 0 0 var(--space-2);
}

.editor-sidepanel ul {
  margin: 0;
  padding-left: 18px;
}

.editor-details {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: var(--space-2);
  background: var(--surface-elevated);
}

.editor-details+.editor-details {
  margin-top: var(--space-2);
}

.editor-details summary {
  cursor: pointer;
  font-weight: 600;
}

.editor-subdetails {
  margin-top: var(--space-2);
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  padding: var(--space-2);
}

.editor-subdetails summary {
  cursor: pointer;
  font-size: 13px;
  color: var(--muted);
}

.ai-generate-panel {
  margin-top: var(--space-2);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.ai-generate-panel textarea {
  width: 100%;
  resize: vertical;
}

.editor-image-layout-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-2);
}

.editor-dropzone {
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  padding: var(--space-3);
  text-align: center;
  color: var(--muted);
  background: var(--surface-elevated);
}

.editor-dropzone.is-dragover {
  border-color: var(--focus);
  background: color-mix(in srgb, var(--surface-elevated) 75%, var(--focus));
}

.editor-gallery {
  margin-top: var(--space-2);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.editor-gallery-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  max-height: 42vh;
  overflow: auto;
}

.gallery-item {
  display: grid;
  grid-template-columns: 84px 1fr;
  gap: var(--space-2);
  padding: var(--space-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-elevated);
  margin: 0;
}

.gallery-item img {
  width: 84px;
  height: 84px;
  object-fit: cover;
  border-radius: 4px;
  border: 1px solid var(--border);
}

.gallery-item-meta {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.gallery-item-meta strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.gallery-item-meta small {
  color: var(--muted);
}

.gallery-insert-btn {
  width: fit-content;
}

.hidden {
  display: none !important;
}

.editor-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  position: sticky;
  bottom: var(--space-2);
  padding: var(--space-3);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  backdrop-filter: blur(4px);
  box-shadow: var(--shadow-sm);
}

.editor-preview-wrap {
  margin-top: var(--space-6);
  padding-top: var(--space-4);
  border-top: 1px solid var(--border);
}

.error {
  color: #d22;
}

.site-footer {
  margin-top: var(--space-6);
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.site-footer-inner {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: var(--space-3) var(--space-4);
  color: var(--muted);
  font-size: 13px;
}

.article-chat-toggle {
  position: fixed;
  right: 22px;
  bottom: 22px;
  width: 54px;
  height: 54px;
  padding: 0;
  border-radius: 999px;
  z-index: 55;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  box-shadow: var(--shadow-md);
}

.article-chat-toggle-avatar {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.article-chat-toggle-fallback {
  display: none;
  position: absolute;
  font-weight: 700;
  color: var(--text);
}

.article-chat-panel {
  position: fixed;
  right: 22px;
  bottom: 86px;
  width: min(92vw, 360px);
  height: min(72vh, 560px);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-elevated);
  box-shadow: var(--shadow-md);
  z-index: 56;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.article-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--border);
  background: var(--surface-muted);
}

.article-chat-messages {
  padding: var(--space-3);
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  flex: 1;
  min-height: 0;
}

.article-chat-msg-row {
  display: flex;
  align-items: flex-end;
  gap: var(--space-2);
}

.article-chat-msg-row.user {
  justify-content: flex-end;
}

.article-chat-avatar {
  width: 28px;
  height: 28px;
  object-fit: cover;
  border-radius: 999px;
  border: 1px solid var(--border);
  flex-shrink: 0;
}

.article-chat-msg {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: var(--space-2);
  font-size: 14px;
  line-height: 1.45;
}

.article-chat-msg.user {
  background: var(--surface-muted);
}

.article-chat-msg.bot {
  background: var(--surface-elevated);
}

.article-chat-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: var(--space-2);
  padding: var(--space-3);
  border-top: 1px solid var(--border);
  background: var(--surface-muted);
}

@media (max-width: 1100px) {
  .article-layout {
    grid-template-columns: 1fr;
  }

  .infobox {
    position: static;
  }

  .article-surface {
    max-width: 100%;
  }

  .wiki-image.size-75,
  .wiki-image.size-60,
  .wiki-image.size-50,
  .wiki-image.size-40,
  .wiki-image.size-33,
  .wiki-image.size-25 {
    width: min(100%, 520px);
  }

  .wiki-image.align-right,
  .wiki-image.align-left {
    float: none;
    margin-left: auto;
    margin-right: auto;
  }

  .editor-workspace {
    grid-template-columns: 1fr;
  }

  .editor-sidepanel {
    position: static;
  }
}

@media (max-width: 980px) {
  .topbar {
    grid-template-columns: 1fr;
    gap: 8px;
    align-items: stretch;
  }

  .topbar-left {
    justify-content: flex-start;
    align-items: center;
  }

  .topbar-tagline {
    display: none;
  }

  .mobile-nav-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-right: var(--space-1);
  }

  .top-right {
    justify-content: space-between;
    flex-wrap: wrap;
  }

  .wiki-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    display: block;
    position: fixed;
    top: 124px;
    left: 0;
    width: min(74vw, 290px);
    height: calc(100vh - 124px);
    transform: translateX(-105%);
    transition: transform var(--trans-fast);
    z-index: 35;
    border-right: 1px solid var(--border);
    border-bottom: none;
    padding: var(--space-4);
    box-shadow: var(--shadow-md);
    overflow: auto;
  }

  .nav-open .sidebar {
    transform: translateX(0);
  }

  .side-nav {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
  }

  .side-nav a {
    margin: 0;
  }

  .nav-backdrop {
    display: block;
    position: fixed;
    inset: 124px 0 0 0;
    background: rgba(0, 0, 0, 0.45);
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--trans-fast);
    z-index: 30;
  }

  .nav-open .nav-backdrop {
    opacity: 1;
    pointer-events: auto;
  }

  .nav-open {
    overflow: hidden;
  }

  .content {
    padding: 14px;
  }

  .login-shell {
    grid-template-columns: 1fr;
    margin: 30px auto;
  }

  .login-brand {
    padding: 0;
  }

  .login-brand h1 {
    font-size: 34px;
  }

  .editor-meta-grid {
    grid-template-columns: 1fr;
  }

  .editor-label textarea {
    min-height: 44vh;
  }

  .editor-image-layout-grid {
    grid-template-columns: 1fr;
  }

  .editor-actions {
    position: static;
    background: var(--surface);
    backdrop-filter: none;
  }
}

@media (max-width: 580px) {
  .side-nav {
    grid-template-columns: 1fr;
  }

  .tabs a {
    width: 100%;
  }

  .article-chat-toggle {
    right: 14px;
    bottom: 14px;
  }

  .article-chat-panel {
    right: 10px;
    left: 10px;
    width: auto;
    bottom: 78px;
    height: min(68vh, 520px);
  }
}

/* =============================================
   HOME PAGE
   ============================================= */

/* Hero -------------------------------------------------------- */
.home-hero {
  /* bleed out of .content padding */
  margin: calc(-1 * var(--space-6));
  margin-bottom: 0;
  padding: 40px 40px 32px;
  background: linear-gradient(140deg, #152349 0%, #1a3460 55%, #0e1f3c 100%);
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: var(--space-6);
  align-items: end;
  position: relative;
  overflow: hidden;
}

:root[data-theme="dark"] .home-hero {
  background: linear-gradient(140deg, #0c1829 0%, #10213e 55%, #080f1e 100%);
}

.home-hero::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 60% 100% at 80% 50%, rgba(79, 125, 249, 0.12) 0%, transparent 70%),
    radial-gradient(ellipse 40% 70% at 10% -10%, rgba(120, 80, 255, 0.08) 0%, transparent 60%);
  pointer-events: none;
}

.home-hero-inner {
  position: relative;
  z-index: 1;
}

.home-kicker {
  font-family: Arial, Helvetica, sans-serif;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.52);
  margin: 0 0 10px;
  letter-spacing: 0.01em;
}

.home-kicker strong {
  color: rgba(255, 255, 255, 0.82);
  font-weight: 600;
}

.home-title {
  font-size: clamp(28px, 4.5vw, 44px);
  font-weight: 700;
  color: #fff;
  margin: 0 0 10px;
  line-height: 1.08;
  letter-spacing: -0.6px;
}

.home-desc {
  font-size: 15px;
  color: rgba(255, 255, 255, 0.55);
  margin: 0 0 28px;
  line-height: 1.55;
  max-width: 480px;
}

.home-hero-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* Stat cluster in hero */
.home-hero-stats {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 18px;
  flex-shrink: 0;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 20px 28px;
  backdrop-filter: blur(8px);
  min-width: 140px;
}

.home-hero-stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.home-hero-stat-num {
  font-size: 28px;
  font-weight: 700;
  color: #fff;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.home-hero-stat-label {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.45);
  font-family: Arial, Helvetica, sans-serif;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* Buttons inside hero */
.home-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 17px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 600;
  text-decoration: none !important;
  transition: transform 110ms ease, box-shadow 110ms ease, background 110ms ease;
  border: 1px solid transparent;
  white-space: nowrap;
  cursor: pointer;
}

.home-btn:hover {
  transform: translateY(-2px);
}

.home-btn:active {
  transform: none;
}

.home-btn-primary {
  background: #4f7df9;
  color: #fff;
  box-shadow: 0 3px 12px rgba(79, 125, 249, 0.4);
}

.home-btn-primary:hover {
  background: #3b6af0;
  box-shadow: 0 5px 18px rgba(79, 125, 249, 0.5);
  color: #fff;
}

.home-btn-secondary {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.18);
  color: rgba(255, 255, 255, 0.88);
}

.home-btn-secondary:hover {
  background: rgba(255, 255, 255, 0.17);
  color: #fff;
}

/* Body layout ------------------------------------------------- */
.home-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 248px;
  gap: 28px;
  padding-top: 28px;
}

/* Section header */
.home-section-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: 16px;
}

.home-section-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-family: Arial, Helvetica, sans-serif;
}

.home-section-link {
  font-size: 13px;
  color: var(--link);
  white-space: nowrap;
  font-family: Arial, Helvetica, sans-serif;
}

/* Article card grid */
.home-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.home-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  text-decoration: none !important;
  color: var(--text);
  transition: border-color 120ms ease, box-shadow 120ms ease, transform 120ms ease;
  min-width: 0;
}

.home-card:hover {
  border-color: var(--focus);
  box-shadow: 0 3px 14px rgba(47, 129, 247, 0.12);
  transform: translateY(-2px);
  color: var(--text);
}

.home-card:visited {
  color: var(--text);
}

.home-card-avatar {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  flex-shrink: 0;
  font-family: Arial, Helvetica, sans-serif;
}

/* Show light-mode avatar by default, swap in dark */
.dark-avatar {
  display: none;
}

:root[data-theme="dark"] .light-avatar {
  display: none;
}

:root[data-theme="dark"] .dark-avatar {
  display: flex;
}

.home-card-content {
  min-width: 0;
  flex: 1;
}

.home-card-title {
  font-size: 14px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 1.3;
  color: var(--text);
}

.home-card-time {
  font-size: 12px;
  color: var(--muted);
  margin-top: 3px;
  font-family: Arial, Helvetica, sans-serif;
}

.home-card-chevron {
  color: var(--border-strong);
  flex-shrink: 0;
  opacity: 0;
  transition: opacity 120ms ease;
}

.home-card:hover .home-card-chevron {
  opacity: 1;
}

/* Empty state */
.home-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 56px 24px;
  text-align: center;
  color: var(--muted);
  border: 1px dashed var(--border);
  border-radius: var(--radius-md);
  grid-column: 1 / -1;
}

/* Sidebar ------------------------------------------------------- */
.home-side {
  display: flex;
  flex-direction: column;
  gap: 14px;
  position: sticky;
  top: 72px;
}

.home-widget {
  background: var(--surface-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 18px;
}

.home-widget-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin: 0 0 12px;
  font-family: Arial, Helvetica, sans-serif;
}

.home-quick-nav {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.home-quick-link {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 9px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  color: var(--text);
  text-decoration: none !important;
  transition: background 110ms ease, color 110ms ease;
}

.home-quick-link:hover {
  background: var(--surface-elevated);
  color: var(--link);
}

.home-quick-link svg {
  flex-shrink: 0;
  opacity: 0.55;
}

.home-tips-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.5;
}

.home-tips-list li {
  padding-left: 12px;
  border-left: 2px solid var(--border);
}

.home-tips-list kbd {
  font-family: "Courier New", monospace;
  font-size: 11px;
  padding: 1px 5px;
  border-radius: 3px;
  background: var(--surface-elevated);
  border: 1px solid var(--border-strong);
  color: var(--text);
}

/* Responsive ---------------------------------------------------- */
@media (max-width: 980px) {
  .home-hero {
    margin: -14px;
    margin-bottom: 0;
    padding: 32px 22px 26px;
    grid-template-columns: 1fr;
  }

  .home-hero-stats {
    flex-direction: row;
    min-width: 0;
    padding: 14px 20px;
    gap: 28px;
  }
}

@media (max-width: 820px) {
  .home-body {
    grid-template-columns: 1fr;
  }

  .home-side {
    position: static;
  }
}

@media (max-width: 600px) {
  .home-grid {
    grid-template-columns: 1fr;
  }

  .home-hero {
    padding: 28px 18px 22px;
  }
}

/* =============================================
   SHARE BUTTON & TOAST
   ============================================= */

.article-header-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
  flex-wrap: wrap;
}

.article-header-top h1 {
  margin: 0;
  font-size: clamp(30px, 4vw, 38px);
  line-height: 1.15;
  flex: 1;
  min-width: 0;
}

.share-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 13px;
  font-size: 13px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-muted);
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  margin-top: 4px;
  transition: border-color var(--trans-fast), color var(--trans-fast), background var(--trans-fast);
}

.share-btn:hover {
  border-color: var(--focus);
  color: var(--text);
  background: var(--surface-elevated);
}

.share-btn svg {
  flex-shrink: 0;
}

/* Toast */
.share-toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%) translateY(12px);
  background: var(--text);
  color: var(--surface);
  font-size: 13px;
  font-family: Arial, Helvetica, sans-serif;
  padding: 9px 18px;
  border-radius: var(--radius-pill);
  box-shadow: var(--shadow-md);
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease;
  white-space: nowrap;
  z-index: 200;
}

.share-toast--show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* KaTeX math */
.katex-display {
  margin: var(--space-4) 0;
  overflow-x: auto;
  padding: var(--space-3) 0;
}

.katex-block {
  display: block;
  text-align: center;
  overflow-x: auto;
  margin: var(--space-4) 0;
  padding: var(--space-3) 0;
}

.katex-error {
  color: #f87171;
  font-family: "Courier New", monospace;
  font-size: 13px;
}

/* Did You Know widget */
.dyk-widget {
  border-color: color-mix(in srgb, var(--border) 60%, var(--focus) 40%);
}

.dyk-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.dyk-refresh {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: color var(--trans-fast), border-color var(--trans-fast);
}

.dyk-refresh:hover {
  color: var(--link);
  border-color: var(--link);
}

.dyk-refresh svg {
  flex-shrink: 0;
}

@keyframes dyk-rotate {
  from {
    transform: rotate(0deg);
  }

  to {
    transform: rotate(360deg);
  }
}

.dyk-spin svg {
  animation: dyk-rotate 0.7s linear infinite;
}

.dyk-loading {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
  font-family: Arial, Helvetica, sans-serif;
}

.dyk-spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid var(--border);
  border-top-color: var(--link);
  border-radius: 50%;
  animation: dyk-rotate 0.7s linear infinite;
  flex-shrink: 0;
}

.dyk-fact {
  font-size: 14px;
  line-height: 1.6;
  color: var(--text);
  margin: 0 0 10px;
  font-style: italic;
}

.dyk-source {
  font-size: 12px;
  color: var(--muted);
  font-family: Arial, Helvetica, sans-serif;
  text-decoration: none;
  transition: color var(--trans-fast);
}

.dyk-source:hover {
  color: var(--link);
}

.dyk-error {
  font-size: 13px;
  color: var(--muted);
  font-family: Arial, Helvetica, sans-serif;
}