:root {
  --bg: #f7f7f2;
  --text: #1f2328;
  --muted: #5a6572;
  --accent: #0f766e;
  --accent-dark: #0b5d57;
  --card: #ffffff;
  --border: #d7dfdd;

  /* Article font scaling (controlled by html[data-font-size]). */
  --content-font-scale: 1;
}

html[data-font-size="lg"] {
  --content-font-scale: 1.08;
}

html[data-font-size="sm"] {
  --content-font-scale: 0.95;
}

html[data-theme="dark"] {
  --bg: #0b0f14;
  --text: #e6edf3;
  --muted: #9aa4af;
  --accent: #2dd4bf;
  --accent-dark: #14b8a6;
  --card: #111823;
  --border: #263241;
}

html[data-theme="dark"] body {
  background:
    radial-gradient(circle at 10% 10%, rgba(27, 72, 91, 0.55) 0%, transparent 45%),
    radial-gradient(circle at 85% 20%, rgba(120, 68, 8, 0.35) 0%, transparent 35%),
    var(--bg);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Noto Sans SC", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 10% 10%, #d8efe9 0%, transparent 45%),
    radial-gradient(circle at 85% 20%, #fce6c8 0%, transparent 35%),
    var(--bg);
  line-height: 1.6;
}

.reading-progress {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 22px;
  z-index: 1200;
  background: transparent;
  pointer-events: auto;
  cursor: ew-resize;
}

.reading-progress.is-dragging {
  cursor: ew-resize;
}

.reading-progress-bar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 3px;
  width: 0;
  background: linear-gradient(90deg, var(--accent), var(--accent-dark));
  transition: width 0.08s linear;
}

.reading-progress-label {
  position: absolute;
  top: 4px;
  right: 10px;
  font-size: 12px;
  font-weight: 700;
  color: rgba(31, 35, 40, 0.8);
  background: rgba(255, 255, 255, 0.76);
  border: 1px solid rgba(31, 35, 40, 0.12);
  border-radius: 999px;
  padding: 2px 8px;
  line-height: 1.2;
}

.reading-progress-toggle {
  position: absolute;
  top: 3px;
  left: 10px;
  height: 16px;
  min-width: 26px;
  padding: 0 8px;
  border-radius: 999px;
  border: 1px solid rgba(31, 35, 40, 0.14);
  background: rgba(255, 255, 255, 0.76);
  color: rgba(31, 35, 40, 0.8);
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
  cursor: pointer;
}

[data-theme="dark"] .reading-progress-toggle {
  border-color: rgba(255, 255, 255, 0.12);
  background: rgba(0, 0, 0, 0.32);
  color: rgba(255, 255, 255, 0.82);
}

.reading-progress.is-collapsed {
  height: 12px;
}

.reading-progress.is-collapsed .reading-progress-label {
  display: none;
}

.reading-progress.is-collapsed .reading-progress-toggle {
  top: -2px;
  height: 14px;
  padding: 0 6px;
}

[data-theme="dark"] .reading-progress-label {
  color: rgba(255, 255, 255, 0.82);
  background: rgba(0, 0, 0, 0.32);
  border-color: rgba(255, 255, 255, 0.12);
}

.skip-link {
  position: absolute;
  left: 1rem;
  top: 1rem;
  transform: translateY(-120%);
  z-index: 1000;
  background: var(--text);
  color: #fff;
  padding: 0.55rem 0.85rem;
  border-radius: 10px;
  text-decoration: none;
  font-weight: 700;
  transition: transform 0.2s ease;
}

.skip-link:focus {
  transform: translateY(0);
}

a {
  color: var(--accent);
}

:where(a, button, [role="button"], input, textarea, select, summary):focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
  border-radius: 6px;
}

.container {
  width: min(1080px, 92%);
  margin: 0 auto;
}

.hero {
  padding: 1rem 0 4rem;
}

.nav,
.article-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.nav-links {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

.nav-links a {
  text-decoration: none;
  font-weight: 600;
}

.theme-toggle,
.font-size-toggle,
.lang-toggle,
.shortcut-help-trigger {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  padding: 0.35rem 0.65rem;
  border-radius: 999px;
  font-weight: 700;
  cursor: pointer;
}

.theme-toggle:hover,
.font-size-toggle:hover,
.lang-toggle:hover,
.shortcut-help-trigger:hover {
  border-color: var(--accent);
}

.brand {
  text-decoration: none;
  color: var(--text);
  font-weight: 800;
  font-size: 1.2rem;
}

.hero-content {
  margin-top: 4rem;
  animation: slide-up 0.7s ease-out both;
}

.tag {
  letter-spacing: 0.15em;
  font-size: 0.8rem;
  color: var(--accent);
  font-weight: 700;
}

h1 {
  font-size: clamp(2rem, 6vw, 3.8rem);
  line-height: 1.15;
  margin: 0.2rem 0 1rem;
}

.subtitle {
  color: var(--muted);
  max-width: 100%;
  width: min(100%, 72ch);
}

.actions {
  display: flex;
  gap: 0.8rem;
  margin-top: 1.5rem;
  flex-wrap: wrap;
}

.btn {
  text-decoration: none;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.65rem 1rem;
  border-radius: 999px;
  font-weight: 600;
  transition: 0.2s ease;
}

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

.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.btn.primary:hover {
  background: var(--accent-dark);
}

.btn.ghost {
  background: #ffffffc9;
}

.section {
  padding: 2.4rem 0;
}

h2 {
  font-size: 1.6rem;
  margin-bottom: 1rem;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
}

.card,
.article-card,
.archive-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 1rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.04);
}

.card h3 {
  margin-top: 0;
}

.card p,
.archive-total {
  color: var(--muted);
}

.article-shell,
.archive-shell {
  padding: 1rem 0 4rem;
}

.article-shell.container,
.archive-shell.container {
  width: min(1280px, 94%);
}

.article-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 1.5rem;
  align-items: start;
}

.article-hero {
  padding: 2rem 0 2.5rem;
  max-width: 980px;
}

.breadcrumb {
  margin: 0 0 0.75rem;
}

.breadcrumb-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.35rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.breadcrumb-link {
  color: var(--muted);
  text-decoration: none;
  border-bottom: 1px solid transparent;
}

.breadcrumb-link:hover {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.breadcrumb-sep {
  opacity: 0.7;
}

.breadcrumb-current {
  color: var(--text);
  opacity: 0.85;
}

.article-meta {
  color: var(--muted);
  margin-bottom: 0.75rem;
  font-size: 0.95rem;
}

.article-link-copy {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--muted);
  border-radius: 999px;
  padding: 0.35rem 0.75rem;
  font-size: 0.9rem;
  cursor: pointer;
}

.article-link-copy:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.post-like {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--muted);
  border-radius: 999px;
  padding: 0.35rem 0.75rem;
  font-size: 0.9rem;
  cursor: pointer;
  margin-left: 0.5rem;
}

.post-like:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.post-like[aria-pressed="true"] {
  border-color: var(--accent);
  color: var(--accent);
}

.article-summary {
  color: var(--muted);
  font-size: 1.05rem;
  max-width: 100%;
  width: min(100%, 72ch);
}

.toc-card {
  position: sticky;
  top: 1rem;
  width: 100%;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 1rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.04);
}

.article-card {
  min-width: 0;
  width: 100%;
  padding: 1.25rem 1.5rem;
}

.toc-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin: 0 0 0.75rem;
}

.toc-title {
  margin: 0;
  font-weight: 800;
  color: var(--text);
}

.toc-visibility-toggle {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  border-radius: 999px;
  padding: 0.25rem 0.6rem;
  font-size: 0.9rem;
  cursor: pointer;
  line-height: 1.1;
}

.toc-visibility-toggle:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.toc-visibility-toggle:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.toc-nav,
.toc-mobile .toc-nav {
  line-height: 1.55;
}

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

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

.toc-nav li + li {
  margin-top: 0.45rem;
}

.toc-collapse-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.25rem;
  height: 1.25rem;
  margin-right: 0.15rem;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.toc-collapse-btn::before {
  content: '▾';
  font-size: 0.9rem;
  line-height: 1;
}

.toc-collapse-btn[aria-expanded="false"]::before {
  content: '▸';
}

.toc-collapse-btn:hover {
  color: var(--accent);
}

.toc-nav li.is-collapsed > ol,
.toc-nav li.is-collapsed > ul {
  display: none;
}

.toc-nav a {
  text-decoration: none;
  color: var(--muted);
  display: inline-block;
  word-break: keep-all;
  overflow-wrap: normal;
  line-break: strict;
}

.toc-nav .toc-nav-level-2 > .toc-nav-link {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
}

.toc-nav .toc-nav-level-3 {
  margin-left: 0.9rem;
  padding-left: 0.85rem;
  border-left: 1px solid var(--border);
}

.toc-nav .toc-nav-level-3 > .toc-nav-link {
  font-size: 0.86rem;
  color: var(--muted);
}

.toc-nav .toc-nav-level-4 {
  margin-left: 1.7rem;
  padding-left: 0.75rem;
  border-left: 1px dashed var(--border);
}

.toc-nav .toc-nav-level-4 > .toc-nav-link {
  font-size: 0.8rem;
  color: var(--muted);
  opacity: 0.9;
}

.toc-nav a:hover {
  color: var(--accent);
}

.toc-nav a.is-active {
  color: var(--accent);
  font-weight: 700;
}

.toc-link-copy-button {
  margin-left: 0.35rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--card);
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1;
  padding: 0.1rem 0.28rem;
  cursor: pointer;
}

.toc-link-copy-button:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.toc-link-copy-toast {
  position: fixed;
  left: 50%;
  bottom: 1.4rem;
  transform: translateX(-50%);
  background: rgba(17, 24, 39, 0.9);
  color: #fff;
  font-size: 0.82rem;
  border-radius: 999px;
  padding: 0.35rem 0.7rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 40;
}

.toc-link-copy-toast.is-visible {
  opacity: 1;
}

.toc-mobile {
  display: none;
  margin-bottom: 1rem;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #fcfdfa;
  padding: 0.9rem 1rem;
}

.toc-mobile summary {
  cursor: pointer;
  font-weight: 700;
}

.toc-mobile-body {
  margin-top: 0.8rem;
}

.article-content {
  max-width: 100%;
  overflow-wrap: anywhere;
  font-size: calc(1rem * var(--content-font-scale));
}

.article-content a.external-link::after {
  content: '↗';
  display: inline-block;
  margin-left: 0.15em;
  font-size: 0.78em;
  opacity: 0.55;
}

.article-content h1,
.article-content h2,
.article-content h3 {
  overflow-wrap: anywhere;
}

.article-content .heading-anchor-host {
  position: relative;
}

.heading-anchor-button {
  margin-left: 0.5rem;
  vertical-align: middle;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.75);
  color: var(--muted);
  border-radius: 999px;
  padding: 0.05rem 0.45rem;
  font-size: 0.85rem;
  cursor: pointer;
  opacity: 0.25;
  transform: translateY(-1px);
  transition: opacity 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.article-content h1:hover .heading-anchor-button,
.article-content h2:hover .heading-anchor-button,
.article-content h3:hover .heading-anchor-button,
.article-content h4:hover .heading-anchor-button,
.article-content h5:hover .heading-anchor-button,
.article-content h6:hover .heading-anchor-button {
  opacity: 1;
}

.heading-anchor-button:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.heading-anchor-button.is-copied {
  opacity: 1;
  border-color: var(--accent);
  color: var(--accent);
}

.article-content blockquote {
  margin: 1.5rem 0;
  padding: 0.75rem 1rem;
  border-left: 4px solid var(--accent);
  background: #eef8f6;
  border-radius: 0 12px 12px 0;
  color: var(--muted);
}

.article-content table {
  width: 100%;
  max-width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
}

.article-content th,
.article-content td {
  border: 1px solid var(--border);
  padding: 0.75rem;
  text-align: left;
  vertical-align: top;
  background: #fff;
}

.article-content th {
  background: #eef8f6;
}

.article-content pre {
  position: relative;
  max-width: 100%;
  background: #f6f7f9;
  color: #111827;
  padding: 0.95rem 1rem;
  border-radius: 6px;
  border: 1px solid #e5e7eb;
  box-shadow: none;
  overflow: auto;
  line-height: 1.6;
  font-size: 0.95rem;
  margin: 1rem 0;
}

.article-content figure.highlight {
  position: relative;
  max-width: 100%;
  background: transparent;
  color: inherit;
  padding: 0;
  border-radius: 0;
  border: 0;
  box-shadow: none;
  overflow: auto;
  margin: 1rem 0;
  line-height: 1.6;
  font-size: 0.95rem;
}

.article-content figure.highlight pre {
  background: #f6f7f9;
  color: #111827;
  padding: 0.95rem 1rem;
  border-radius: 6px;
  border: 1px solid #e5e7eb;
  box-shadow: none;
  margin: 0;
}

html[data-theme="dark"] .article-content table {
  background: transparent;
}

html[data-theme="dark"] .article-content th,
html[data-theme="dark"] .article-content td {
  background: #0f1722;
  color: var(--text);
  border-color: #253042;
}

html[data-theme="dark"] .article-content th {
  background: #121c28;
}

html[data-theme="dark"] .article-content pre,
html[data-theme="dark"] .article-content figure.highlight pre {
  background: #0f1722;
  color: #e6edf3;
  border-color: #253042;
}

html[data-theme="dark"] .article-content :not(pre) > code {
  background: #0f1722;
  color: #e6edf3;
  border-color: #253042;
}

.article-content figure.highlight .gutter {
  display: none;
}

.code-copy-button,
.code-copy-toast {
  display: block;
}

.code-collapse-button {
  display: none;
}

.article-content figure.highlight table {
  background: transparent;
}

.article-content figure.highlight table {
  width: 100%;
  border-collapse: collapse;
}

.article-content figure.highlight td {
  padding: 0;
  border: none;
}

.article-content figure.highlight .line {
  display: block;
}

.code-copy-button {
  position: absolute;
  top: 0.5rem;
  right: 0.6rem;
  border: 1px solid #d1d5db;
  background: #ffffff;
  color: #111827;
  border-radius: 999px;
  padding: 0.2rem 0.6rem;
  font-size: 0.78rem;
  cursor: pointer;
}

.code-collapse-button {
  position: absolute;
  top: 0.5rem;
  left: 0.6rem;
  border: 1px solid #d1d5db;
  background: #ffffff;
  color: #111827;
  border-radius: 999px;
  padding: 0.2rem 0.6rem;
  font-size: 0.78rem;
  cursor: pointer;
}

.code-collapse-button:hover {
  background: #f3f4f6;
}

.article-content pre.is-collapsed,
.article-content figure.highlight.is-collapsed {
  max-height: 22rem;
  overflow-y: hidden;
}

.code-copy-button:hover {
  background: #f3f4f6;
}

.article-content pre,
.article-content figure.highlight {
  transition: box-shadow 0.18s ease;
}

.article-content pre.is-copied,
.article-content figure.highlight.is-copied {
  box-shadow: 0 0 0 2px rgba(15, 118, 110, 0.35);
}

.code-copy-toast {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 1200;
  background: #0f766e;
  color: #fff;
  border-radius: 999px;
  padding: 0.45rem 0.85rem;
  font-size: 0.85rem;
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.code-copy-toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.article-content code {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 0.94em;
}

.article-content img {
  display: block;
  max-width: 100%;
  width: auto;
  height: auto;
  margin: 1.25rem auto;
  border-radius: 12px;
}

/* Click-to-open original image affordance */
.article-content img[data-image-open="1"] {
  cursor: zoom-in;
}

.article-content :not(pre) > code {
  background: #e9f3f5;
  color: #0b5d57;
  padding: 0.15rem 0.4rem;
  border-radius: 6px;
  border: 1px solid rgba(15, 118, 110, 0.2);
}

.mermaid {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1rem;
  margin: 1.5rem 0;
  overflow-x: auto;
}

html[data-theme="dark"] .article-content blockquote {
  background: #0f1722;
  color: #cbd5e1;
}

html[data-theme="dark"] .article-content th {
  background: #121c28;
}

html[data-theme="dark"] .mermaid {
  background: #0f1722;
  border-color: #253042;
}

html[data-theme="dark"] .toc-mobile {
  background: #0f1722;
  border-color: #253042;
}

.related-posts {
  margin-top: 2.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

.post-comments {
  margin-top: 2.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

.post-comments-title {
  margin: 0 0 1rem;
  font-size: 1.1rem;
}

.post-comments-box {
  min-height: 220px;
}

.related-posts-title {
  margin: 0 0 1rem;
  font-size: 1.1rem;
}

.related-posts-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 0.85rem;
}

.related-posts-item {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
}

.related-posts-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.related-posts-head {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  flex-wrap: wrap;
  min-width: 0;
}

.related-posts-reason {
  font-size: 0.72rem;
  color: var(--muted);
  background: rgba(0, 0, 0, 0.03);
  border: 1px solid var(--border);
  padding: 0.05rem 0.4rem;
  border-radius: 999px;
  white-space: nowrap;
}

html[data-theme="dark"] .related-posts-reason {
  background: rgba(255, 255, 255, 0.06);
}

.related-posts-tags,
.related-posts-keywords {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.related-posts-tag,
.related-posts-keyword {
  font-size: 0.78rem;
  color: var(--muted);
  background: rgba(0, 0, 0, 0.04);
  border: 1px solid var(--border);
  padding: 0.1rem 0.45rem;
  border-radius: 999px;

  /* When rendered as <button>, keep it looking like a chip. */
  appearance: none;
  font-family: inherit;
  line-height: 1.2;
  cursor: pointer;
}

.related-posts-keyword {
  color: var(--accent);
}

html[data-theme="dark"] .related-posts-tag,
html[data-theme="dark"] .related-posts-keyword {
  background: rgba(255, 255, 255, 0.06);
}

.related-posts-link {
  flex: 1;
  min-width: 0;
  text-decoration: none;
  color: var(--text);
}

.related-posts-link:hover {
  text-decoration: underline;
}

.related-posts-meta {
  color: var(--muted);
  font-size: 0.85rem;
  white-space: nowrap;
}

.archive-year {
  margin-top: 2rem;
}

.archive-item {
  display: flex;
  gap: 1rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
}

.archive-item time {
  color: var(--muted);
  min-width: 3.5rem;
}

.footer {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--muted);
}

@keyframes slide-up {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 640px) {
  .hero,
  .article-shell,
  .archive-shell {
    padding-bottom: 2rem;
  }

  .hero-content,
  .article-hero {
    margin-top: 2rem;
    padding-bottom: 1.5rem;
  }

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

  .toc-card {
    display: none;
  }

  .toc-mobile {
    display: block;
  }

  .archive-item {
    flex-direction: column;
    gap: 0.2rem;
  }
}

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

  .toc-card {
    display: none;
  }

  .toc-mobile {
    display: block;
  }
}

/* Site search modal */
.site-search-trigger {
  border: 1px solid rgba(15, 118, 110, 0.35);
  background: rgba(15, 118, 110, 0.08);
  color: var(--text);
  border-radius: 999px;
  padding: 0.35rem 0.85rem;
  cursor: pointer;
}

.site-search-trigger:hover {
  background: rgba(15, 118, 110, 0.14);
}

.site-search-overlay {
  position: fixed;
  inset: 0;
  z-index: 1400;
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: 6vh 1rem 1rem;
  background: rgba(0, 0, 0, 0.55);
}

.site-search-overlay.is-open {
  display: flex;
}

.site-search-modal {
  width: min(720px, 100%);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.22);
  overflow: hidden;
}

.site-search-header {
  display: flex;
  gap: 0.65rem;
  padding: 0.85rem;
  border-bottom: 1px solid var(--border);
  background: var(--card);
}

.site-search-input {
  flex: 1;
  padding: 0.65rem 0.85rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
}

.site-search-close {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  border-radius: 12px;
  padding: 0.65rem 0.85rem;
  cursor: pointer;
}

.site-search-body {
  padding: 0.85rem;
  /* Make long result lists scroll inside the modal (better keyboard nav UX). */
  max-height: min(68vh, 520px);
  overflow: auto;
}

.site-search-results {
  margin-top: 0.75rem;
}

.site-search-count {
  font-size: 0.9rem;
  color: var(--muted);
  margin: 0 0 0.65rem;
}

.site-search-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 0.65rem;
}

.site-search-item {
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
}

.site-search-row {
  display: flex;
  align-items: stretch;
}

.site-search-row .site-search-link {
  flex: 1;
}

.site-search-copy-link {
  flex: none;
  border: 0;
  border-left: 1px solid var(--border);
  background: var(--card);
  color: var(--muted);
  padding: 0 0.85rem;
  font-size: 0.82rem;
  cursor: pointer;
  white-space: nowrap;
}

.site-search-copy-link:hover {
  background: var(--card-hover, rgba(15, 118, 110, 0.06));
  color: var(--text);
}

.site-search-copy-link:focus-visible {
  outline: 2px solid rgba(15, 118, 110, 0.55);
  outline-offset: -2px;
}

.site-search-link {
  display: block;
  padding: 0.85rem;
  text-decoration: none;
  color: var(--text);
  background: var(--card);
}

.site-search-link:hover {
  background: var(--card-hover, rgba(15, 118, 110, 0.06));
}

.site-search-item.is-selected .site-search-link {
  background: rgba(15, 118, 110, 0.12);
  outline: 3px solid rgba(15, 118, 110, 0.35);
  outline-offset: -3px;
}

.site-search-title mark,
.site-search-tag mark,
.site-search-snippet mark {
  background: rgba(15, 118, 110, 0.22);
  color: inherit;
  padding: 0 0.15em;
  border-radius: 6px;
}

.site-search-meta {
  margin-top: 0.25rem;
  font-size: 0.82rem;
  color: var(--muted);
}

.site-search-snippet {
  margin-top: 0.35rem;
  font-size: 0.9rem;
  line-height: 1.45;
  color: var(--muted);
}

.site-search-tags {
  margin-top: 0.55rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.site-search-tag {
  font-size: 0.82rem;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(15, 118, 110, 0.06);
  color: inherit;
  cursor: pointer;
  appearance: none;
}

.site-search-tag:hover {
  border-color: rgba(15, 118, 110, 0.55);
}

.site-search-tag:focus-visible {
  outline: 2px solid rgba(15, 118, 110, 0.55);
  outline-offset: 2px;
}

.site-search-empty {
  border: 1px dashed var(--border);
  border-radius: 14px;
  padding: 0.85rem;
  color: var(--muted);
}

.site-search-empty a {
  color: var(--link);
}

.site-search-suggest {
  margin: 0.65rem 0 0.75rem;
}

.site-search-suggest-title-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
}

.site-search-suggest-title {
  margin: 0 0 0.5rem;
  color: var(--text);
}

.site-search-clear-recent {
  appearance: none;
  border: 0;
  padding: 0;
  margin: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.82rem;
}

.site-search-clear-recent:hover {
  color: var(--text);
  text-decoration: underline;
}

.site-search-suggest-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.site-search-suggest-chip {
  appearance: none;
  border: 1px solid var(--border);
  background: rgba(15, 118, 110, 0.06);
  color: var(--text);
  border-radius: 999px;
  padding: 0.2rem 0.7rem;
  cursor: pointer;
}

.site-search-suggest-chip:hover {
  background: rgba(15, 118, 110, 0.12);
}

/* Back to top */
.back-to-top {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 1100;
  width: 44px;
  height: 44px;
  border-radius: 999px;
  border: 1px solid rgba(0, 0, 0, 0.12);
  background: rgba(255, 255, 255, 0.86);
  color: var(--text);
  font-size: 18px;
  font-weight: 900;
  display: grid;
  place-items: center;
  cursor: pointer;
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.12);
  backdrop-filter: blur(10px);
}

html[data-theme="dark"] .back-to-top {
  border-color: rgba(255, 255, 255, 0.14);
  background: rgba(17, 24, 35, 0.72);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.42);
}

.back-to-top:hover {
  transform: translateY(-1px);
}

.back-to-top:active {
  transform: translateY(0);
}

/* Shortcut help overlay */
.shortcut-help {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: none;
}

.shortcut-help.is-open {
  display: block;
}

.shortcut-help-mask {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.48);
}

.shortcut-help-panel {
  position: relative;
  max-width: 560px;
  width: calc(100% - 2rem);
  margin: 10vh auto 0;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 1rem;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.2);
}

.shortcut-help-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.shortcut-help-title {
  margin: 0;
  font-size: 1.1rem;
}

.shortcut-help-close {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  width: 36px;
  height: 36px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 1.2rem;
  line-height: 1;
}

.shortcut-help-close:hover {
  border-color: var(--accent);
}

.shortcut-help-list {
  margin: 0.75rem 0 0;
  padding-left: 1.1rem;
}

.shortcut-help-list li {
  margin: 0.4rem 0;
  color: var(--text);
}

.shortcut-help kbd {
  display: inline-block;
  padding: 0.15rem 0.45rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: rgba(127, 127, 127, 0.08);
  font-weight: 800;
}
