:root {
  --font-sans: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  --font-mono: "JetBrains Mono", "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  --bg: #fafaf8;
  --surface: #ffffff;
  --surface-soft: #f2f2ef;
  --text: #11110f;
  --muted: #686864;
  --faint: #92928c;
  --border: #e3e2dd;
  --border-strong: #cecdc7;
  --accent: #3287f5;
  --accent-soft: #eaf3ff;
  --code-bg: #f2f2ef;
  --selection: #cfe4ff;
  --sidebar-width: 276px;
  --radius: 14px;
  --shadow-soft: 0 16px 46px rgba(31, 31, 28, 0.06);
}

:root[data-theme="dark"] {
  --bg: #111210;
  --surface: #181916;
  --surface-soft: #20211e;
  --text: #f2f2ef;
  --muted: #aaa9a3;
  --faint: #797a74;
  --border: #30312d;
  --border-strong: #444540;
  --accent: #72adff;
  --accent-soft: #172a42;
  --code-bg: #20211e;
  --selection: #254a75;
  --shadow-soft: 0 18px 52px rgba(0, 0, 0, 0.2);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  background: var(--bg);
  color-scheme: light;
  scroll-behavior: smooth;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

html[data-theme="dark"] {
  color-scheme: dark;
}

body {
  margin: 0;
  min-width: 320px;
  background:
    radial-gradient(circle at 72% -10%, rgba(50, 135, 245, 0.035), transparent 30rem),
    var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.6;
}

::selection {
  background: var(--selection);
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
textarea {
  color: inherit;
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

svg {
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent) 50%, transparent);
  outline-offset: 3px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 100;
  padding: 9px 14px;
  border-radius: 8px;
  background: var(--text);
  color: var(--bg);
  transform: translateY(-160%);
  transition: transform 160ms ease;
}

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

.reading-progress {
  position: fixed;
  inset: 0 0 auto var(--sidebar-width);
  z-index: 60;
  height: 2px;
  background: transparent;
}

.reading-progress span {
  display: block;
  width: 100%;
  height: 100%;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: left center;
}

.site-shell {
  min-height: 100vh;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 40;
  display: flex;
  width: var(--sidebar-width);
  flex-direction: column;
  padding: 22px 14px 28px;
  border-right: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg) 96%, transparent);
  backdrop-filter: blur(16px);
}

.sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 8px;
}

.brand-mark {
  display: inline-flex;
  min-width: 48px;
  align-items: center;
  font-size: 27px;
  font-weight: 450;
  letter-spacing: -0.12em;
  line-height: 1;
}

.icon-button {
  display: inline-grid;
  width: 40px;
  height: 40px;
  padding: 0;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  cursor: pointer;
  transition: border-color 160ms ease, background 160ms ease, color 160ms ease, transform 160ms ease;
}

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

.icon-button:active {
  transform: scale(0.96);
}

.icon-button svg {
  width: 20px;
  height: 20px;
}

.theme-toggle {
  border-color: var(--accent);
  color: var(--text);
}

.theme-toggle .icon-moon,
:root[data-theme="dark"] .theme-toggle .icon-sun {
  display: none;
}

:root[data-theme="dark"] .theme-toggle .icon-moon {
  display: block;
}

.site-identity {
  padding: 20px 12px 27px;
}

.site-title {
  display: inline-block;
  font-size: 18px;
  font-weight: 720;
  letter-spacing: -0.025em;
}

.site-identity p {
  max-width: 210px;
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.primary-nav {
  display: grid;
  gap: 4px;
}

.nav-item {
  display: flex;
  min-height: 46px;
  align-items: center;
  gap: 16px;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: 10px;
  font-size: 14px;
  transition: background 160ms ease, color 160ms ease, border-color 160ms ease;
}

.nav-item svg {
  width: 20px;
  height: 20px;
}

.nav-item:hover {
  background: var(--surface-soft);
}

.nav-item.is-active {
  border-color: color-mix(in srgb, var(--border) 70%, transparent);
  background: var(--surface-soft);
  font-weight: 650;
}

.sidebar-foot {
  margin-top: auto;
  padding: 0 12px;
}

.search-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0 18px;
  color: var(--muted);
  font-size: 13px;
}

.search-link:hover {
  color: var(--text);
}

.search-link svg {
  width: 18px;
  height: 18px;
}

.search-link kbd {
  margin-left: auto;
}

kbd {
  min-width: 25px;
  padding: 1px 6px;
  border: 1px solid var(--border);
  border-bottom-color: var(--border-strong);
  border-radius: 5px;
  background: var(--surface);
  color: var(--faint);
  font-family: var(--font-mono);
  font-size: 10px;
  text-align: center;
}

.footer-copy {
  padding-top: 19px;
  border-top: 1px solid var(--border);
  color: var(--faint);
  font-size: 11px;
  line-height: 1.55;
}

.footer-copy p {
  margin: 0 0 3px;
}

.mobile-header {
  display: none;
}

.site-main {
  min-height: 100vh;
  margin-left: var(--sidebar-width);
  padding: 68px clamp(32px, 6vw, 88px) 100px;
}

.site-main > * {
  width: min(100%, 860px);
  margin-right: auto;
  margin-left: auto;
}

.site-main > .article-page {
  width: min(100%, 1080px);
}

.eyebrow {
  margin: 0 0 17px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.2em;
  line-height: 1.2;
  text-transform: uppercase;
}

.home-hero {
  padding: 0 0 35px;
}

.home-hero h1,
.page-heading h1,
.article-header h1 {
  margin: 0;
  font-size: clamp(34px, 4.3vw, 50px);
  font-weight: 790;
  letter-spacing: -0.055em;
  line-height: 1.06;
}

.home-hero h1 {
  max-width: 780px;
}

.hero-description,
.page-heading > p:last-child,
.article-deck {
  max-width: 710px;
  margin: 17px 0 0;
  color: var(--muted);
  font-size: clamp(16px, 1.7vw, 19px);
  line-height: 1.55;
}

.post-list {
  display: grid;
  gap: 14px;
}

.post-card {
  position: relative;
  display: grid;
  min-height: 164px;
  grid-template-columns: 1fr auto;
  grid-template-rows: 1fr auto;
  padding: 27px 32px 25px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--surface) 64%, transparent);
  transition: border-color 180ms ease, background 180ms ease, box-shadow 180ms ease, transform 180ms ease;
}

.post-card:hover {
  border-color: color-mix(in srgb, var(--accent) 58%, var(--border));
  background: var(--surface);
  box-shadow: var(--shadow-soft);
  transform: translateY(-2px);
}

.post-card-link {
  position: absolute;
  inset: 0;
  z-index: 1;
  border-radius: inherit;
}

.post-card-copy {
  align-self: start;
}

.post-card h2 {
  margin: 0;
  font-size: clamp(18px, 2vw, 22px);
  font-weight: 735;
  letter-spacing: -0.035em;
  line-height: 1.25;
}

.post-card-copy p {
  max-width: 680px;
  margin: 5px 42px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
}

.post-card-arrow {
  width: 23px;
  height: 23px;
  transition: color 180ms ease, transform 180ms ease;
}

.post-card:hover .post-card-arrow {
  color: var(--accent);
  transform: translate(3px, -3px);
}

.post-meta {
  z-index: 2;
  display: flex;
  grid-column: 1 / -1;
  align-items: center;
  gap: 12px;
  margin-top: 20px;
  color: var(--muted);
  font-size: 11px;
  pointer-events: none;
}

.meta-divider {
  width: 1px;
  height: 22px;
  margin: 0 2px;
  background: var(--border);
}

.meta-pill {
  padding: 3px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: color-mix(in srgb, var(--surface) 60%, transparent);
  letter-spacing: 0.03em;
}

.page-heading {
  padding-bottom: 46px;
}

.page-heading h1 {
  max-width: 800px;
}

.compact-heading h1 {
  font-size: clamp(32px, 4vw, 46px);
}

.archive-list {
  display: grid;
  gap: 52px;
}

.archive-year {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 22px;
}

.archive-year > h2 {
  position: sticky;
  top: 32px;
  align-self: start;
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 15px;
  font-weight: 650;
}

.archive-entries {
  border-top: 1px solid var(--border);
}

.archive-entry {
  display: grid;
  min-height: 72px;
  grid-template-columns: 62px minmax(0, 1fr) auto 20px;
  align-items: center;
  gap: 16px;
  border-bottom: 1px solid var(--border);
  transition: color 160ms ease, padding 160ms ease;
}

.archive-entry:hover {
  padding-left: 7px;
  color: var(--accent);
}

.archive-entry time,
.archive-category {
  color: var(--muted);
  font-size: 11px;
}

.archive-title {
  overflow: hidden;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.archive-entry svg {
  width: 18px;
  height: 18px;
}

.notes-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.note-card {
  min-height: 240px;
  padding: 27px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--surface) 64%, transparent);
  transition: border-color 180ms ease, transform 180ms ease;
}

.note-card:hover {
  border-color: color-mix(in srgb, var(--accent) 58%, var(--border));
  transform: translateY(-2px);
}

.note-meta {
  color: var(--faint);
  font-size: 11px;
}

.note-card h2 {
  margin: 15px 0 8px;
  font-size: 19px;
  letter-spacing: -0.025em;
  line-height: 1.3;
}

.note-card h2 a:hover {
  color: var(--accent);
}

.note-card > p {
  margin: 0 0 18px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
}

.text-link {
  color: var(--accent);
  font-size: 12px;
  font-weight: 650;
}

.article-header {
  max-width: 760px;
  padding-bottom: 45px;
}

.article-header .eyebrow {
  margin-top: 43px;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
  transition: color 160ms ease;
}

.back-link:hover {
  color: var(--accent);
}

.back-link svg {
  width: 17px;
  height: 17px;
}

.article-header h1 {
  font-size: clamp(36px, 4.6vw, 54px);
}

.article-deck {
  font-size: clamp(16px, 1.7vw, 19px);
}

.article-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 24px;
  color: var(--faint);
  font-size: 12px;
}

.article-layout {
  display: grid;
  grid-template-columns: minmax(0, 730px) minmax(160px, 220px);
  align-items: start;
  gap: clamp(48px, 7vw, 88px);
}

.prose {
  min-width: 0;
  font-size: 16px;
  line-height: 1.86;
}

.prose > :first-child {
  margin-top: 0;
}

.prose h2,
.prose h3,
.prose h4 {
  scroll-margin-top: 30px;
  color: var(--text);
  letter-spacing: -0.025em;
  line-height: 1.35;
}

.prose h2 {
  margin: 2.7em 0 0.75em;
  font-size: 1.5em;
}

.prose h3 {
  margin: 2.1em 0 0.65em;
  font-size: 1.18em;
}

.prose p,
.prose ul,
.prose ol {
  margin: 1.25em 0;
}

.prose ul,
.prose ol {
  padding-left: 1.4em;
}

.prose li + li {
  margin-top: 0.42em;
}

.prose a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, var(--accent) 36%, transparent);
  text-decoration-thickness: 1px;
  text-underline-offset: 4px;
}

.prose strong {
  font-weight: 720;
}

.prose blockquote {
  margin: 2em 0;
  padding: 4px 0 4px 22px;
  border-left: 3px solid var(--accent);
  color: var(--muted);
  font-size: 1em;
}

.prose blockquote p {
  margin: 0;
}

.prose img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 2.2em auto;
  border: 1px solid var(--border);
  border-radius: 12px;
}

.prose code {
  padding: 0.16em 0.38em;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--code-bg);
  font-family: var(--font-mono);
  font-size: 0.84em;
}

.prose figure.highlight,
.prose pre {
  margin: 2em 0;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--code-bg);
}

.prose pre {
  padding: 20px 22px;
}

.prose figure.highlight table {
  width: 100%;
  margin: 0;
  border: 0;
}

.prose figure.highlight td {
  padding: 20px 22px;
  border: 0;
}

.prose figure.highlight .gutter {
  display: none;
}

.prose pre code,
.prose figure.highlight code {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  font-size: 12px;
  line-height: 1.7;
}

.prose table:not(.highlight table) {
  display: block;
  width: 100%;
  margin: 2em 0;
  overflow-x: auto;
  border-collapse: collapse;
}

.prose table:not(.highlight table) th,
.prose table:not(.highlight table) td {
  padding: 10px 14px;
  border: 1px solid var(--border);
  text-align: left;
}

.prose hr {
  margin: 3em 0;
  border: 0;
  border-top: 1px solid var(--border);
}

.post-toc {
  position: sticky;
  top: 30px;
  max-height: calc(100vh - 60px);
  overflow-y: auto;
  color: var(--faint);
  font-size: 11px;
}

.post-toc > p {
  margin: 0 0 12px;
  color: var(--text);
  font-weight: 700;
  letter-spacing: 0.08em;
}

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

.post-toc ol ol,
.post-toc ul ul {
  padding-left: 12px;
}

.post-toc a {
  display: block;
  padding: 4px 0;
  transition: color 160ms ease;
}

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

.article-footer {
  max-width: 730px;
  margin-top: 64px;
  padding-top: 28px;
  border-top: 1px solid var(--border);
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tag-list a {
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--muted);
  font-size: 11px;
  transition: border-color 160ms ease, color 160ms ease;
}

.tag-list a:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.post-neighbors {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 34px;
}

.post-neighbors a {
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: 10px;
  transition: border-color 160ms ease, transform 160ms ease;
}

.post-neighbors a:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}

.post-neighbors span,
.post-neighbors strong {
  display: block;
}

.post-neighbors span {
  margin-bottom: 5px;
  color: var(--faint);
  font-size: 10px;
}

.post-neighbors strong {
  font-size: 13px;
  line-height: 1.4;
}

.simple-page .prose {
  max-width: 730px;
}

.search-panel {
  max-width: 760px;
}

.search-box {
  display: grid;
  grid-template-columns: 24px 1fr auto;
  align-items: center;
  gap: 13px;
  padding: 8px 10px 8px 18px;
  border: 1px solid var(--border-strong);
  border-radius: 13px;
  background: var(--surface);
  box-shadow: var(--shadow-soft);
}

.search-box:focus-within {
  border-color: var(--accent);
}

.search-box svg {
  width: 22px;
  height: 22px;
  color: var(--muted);
}

.search-box input {
  width: 100%;
  padding: 10px 0;
  border: 0;
  outline: 0;
  background: transparent;
  font-size: 17px;
}

.search-status {
  margin: 18px 2px;
  color: var(--faint);
  font-size: 12px;
}

.search-results {
  display: grid;
  gap: 10px;
}

.search-result {
  display: block;
  padding: 22px;
  border: 1px solid var(--border);
  border-radius: 11px;
  transition: border-color 160ms ease, transform 160ms ease;
}

.search-result:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}

.search-result h2 {
  margin: 0 0 4px;
  font-size: 17px;
  letter-spacing: -0.02em;
}

.search-result p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.search-result-meta {
  display: flex;
  gap: 10px;
  margin-top: 10px;
  color: var(--faint);
  font-size: 10px;
}

.message-panel {
  max-width: 760px;
}

.message-form,
.message-receipt,
.private-message-view,
.admin-login,
.admin-inbox {
  padding: clamp(24px, 4vw, 38px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--surface) 78%, transparent);
  box-shadow: var(--shadow-soft);
}

.message-form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.form-field {
  display: grid;
  gap: 9px;
  margin-bottom: 22px;
  font-size: 13px;
  font-weight: 650;
}

.form-field small {
  color: var(--faint);
  font-size: 11px;
  font-weight: 400;
}

.form-field input,
.form-field textarea,
.private-link-row input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border-strong);
  border-radius: 9px;
  outline: 0;
  background: var(--surface);
  resize: vertical;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

.form-field input:focus,
.form-field textarea:focus,
.private-link-row input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 14%, transparent);
}

.field-meta {
  display: flex;
  justify-content: space-between;
  color: var(--faint);
  font-size: 10px;
  font-weight: 400;
}

.message-trap {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
}

.message-actions,
.admin-toolbar,
.private-message-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.primary-button,
.secondary-button {
  min-height: 42px;
  padding: 0 18px;
  border-radius: 9px;
  cursor: pointer;
  white-space: nowrap;
  transition: transform 160ms ease, border-color 160ms ease, opacity 160ms ease;
}

.primary-button {
  border: 1px solid var(--text);
  background: var(--text);
  color: var(--bg);
  font-weight: 650;
}

.secondary-button {
  border: 1px solid var(--border-strong);
  background: var(--surface);
}

.primary-button:hover,
.secondary-button:hover {
  transform: translateY(-1px);
}

.primary-button:disabled {
  cursor: wait;
  opacity: 0.55;
}

.privacy-note {
  display: flex;
  max-width: 430px;
  align-items: flex-start;
  gap: 8px;
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.55;
}

.privacy-note svg {
  width: 16px;
  min-width: 16px;
  margin-top: 1px;
}

.form-status {
  min-height: 20px;
  margin: 16px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.form-status[data-type="error"] {
  color: #d33a2c;
}

.message-receipt h2,
.private-message-view h2 {
  margin: 0 0 10px;
  font-size: 25px;
  letter-spacing: -0.035em;
}

.message-receipt > p:not(.eyebrow) {
  color: var(--muted);
}

.private-link-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  margin: 24px 0 18px;
}

.private-link-row input {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 11px;
}

.message-status-pill {
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 10px;
}

.message-status-pill[data-status="unread"] {
  border-color: color-mix(in srgb, var(--accent) 42%, var(--border));
  background: var(--accent-soft);
  color: var(--accent);
}

.message-details {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin: 26px 0;
}

.message-details div {
  padding: 13px 15px;
  border-radius: 9px;
  background: var(--surface-soft);
}

.message-details dt {
  color: var(--faint);
  font-size: 10px;
}

.message-details dd {
  margin: 3px 0 0;
  font-size: 13px;
}

.private-message-body,
.admin-message > p {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  line-height: 1.8;
}

.admin-login {
  max-width: 520px;
}

.admin-toolbar {
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.admin-toolbar p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.admin-message-list {
  display: grid;
  gap: 12px;
}

.admin-message {
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
}

.admin-message header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.admin-message header strong,
.admin-message header time {
  display: block;
}

.admin-message header time,
.admin-message footer {
  color: var(--faint);
  font-size: 10px;
}

.admin-message > p {
  font-size: 14px;
}

.admin-message footer {
  margin-top: 15px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.admin-message button {
  cursor: pointer;
}

.empty-inbox {
  color: var(--muted);
  text-align: center;
}

.back-to-top {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 30;
  display: grid;
  width: 42px;
  height: 42px;
  padding: 0;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  box-shadow: var(--shadow-soft);
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity 160ms ease, transform 160ms ease, border-color 160ms ease;
  backdrop-filter: blur(10px);
  cursor: pointer;
}

.back-to-top.is-visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.back-to-top:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.back-to-top svg {
  width: 21px;
  height: 21px;
}

.nav-scrim {
  display: none;
}

@media (max-width: 1100px) {
  :root {
    --sidebar-width: 248px;
  }

  .site-main {
    padding-right: 44px;
    padding-left: 44px;
  }

  .article-layout {
    display: block;
  }

  .post-toc {
    display: none;
  }
}

@media (max-width: 780px) {
  .reading-progress {
    left: 0;
  }

  .mobile-header {
    position: sticky;
    top: 0;
    z-index: 35;
    display: flex;
    height: 64px;
    align-items: center;
    justify-content: space-between;
    padding: 0 18px;
    border-bottom: 1px solid var(--border);
    background: color-mix(in srgb, var(--bg) 90%, transparent);
    backdrop-filter: blur(16px);
  }

  .mobile-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    font-weight: 700;
  }

  .mobile-brand span {
    font-size: 20px;
    font-weight: 450;
    letter-spacing: -0.12em;
  }

  .mobile-actions {
    display: flex;
    gap: 8px;
  }

  .mobile-header .icon-button {
    width: 38px;
    height: 38px;
    background: transparent;
  }

  .sidebar {
    width: min(84vw, 310px);
    transform: translateX(-105%);
    transition: transform 220ms cubic-bezier(.2, .8, .2, 1);
  }

  .sidebar.is-open {
    box-shadow: 20px 0 60px rgba(0, 0, 0, 0.18);
    transform: translateX(0);
  }

  .nav-scrim {
    position: fixed;
    inset: 0;
    z-index: 38;
    display: block;
    border: 0;
    background: rgba(15, 16, 14, 0.42);
    backdrop-filter: blur(2px);
  }

  .nav-scrim[hidden] {
    display: none;
  }

  body.nav-open {
    overflow: hidden;
  }

  .site-main {
    margin-left: 0;
    padding: 48px 22px 80px;
  }

  .home-hero,
  .page-heading {
    padding-bottom: 32px;
  }

  .home-hero h1,
  .page-heading h1,
  .article-header h1 {
    font-size: clamp(31px, 9vw, 40px);
  }

  .hero-description,
  .page-heading > p:last-child,
  .article-deck {
    font-size: 16px;
  }

  .post-card {
    min-height: 0;
    padding: 22px;
  }

  .post-card-copy p {
    margin-right: 22px;
  }

  .archive-year {
    display: block;
  }

  .archive-year > h2 {
    position: static;
    margin-bottom: 12px;
  }

  .archive-entry {
    grid-template-columns: 54px minmax(0, 1fr) 18px;
    gap: 10px;
  }

  .archive-category {
    display: none;
  }

  .notes-list {
    grid-template-columns: 1fr;
  }

  .note-card {
    min-height: 0;
  }

  .article-header .eyebrow {
    margin-top: 36px;
  }

  .article-footer {
    margin-top: 48px;
  }

  .back-to-top {
    right: 16px;
    bottom: 16px;
  }
}

@media (max-width: 520px) {
  .site-main {
    padding-right: 17px;
    padding-left: 17px;
  }

  .post-card {
    padding: 20px 18px;
  }

  .post-card h2 {
    font-size: 18px;
  }

  .post-meta {
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 18px;
  }

  .meta-divider {
    display: none;
  }

  .article-header h1 {
    font-size: 34px;
  }

  .prose {
    font-size: 15px;
    line-height: 1.82;
  }

  .post-neighbors {
    grid-template-columns: 1fr;
  }

  .search-heading {
    padding-bottom: 24px;
  }

  .search-box kbd {
    display: none;
  }

  .message-form-grid,
  .message-details {
    grid-template-columns: 1fr;
    gap: 0;
  }

  .message-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .private-link-row {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}

.security-panel {
  max-width: 760px;
}

.security-notice {
  padding: clamp(26px, 4vw, 40px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--surface) 78%, transparent);
  box-shadow: var(--shadow-soft);
}

.security-notice-head {
  display: flex;
  align-items: flex-start;
  gap: 18px;
}

.security-notice-head .eyebrow {
  margin-bottom: 8px;
}

.security-notice h2 {
  margin: 0;
  font-size: clamp(24px, 3vw, 30px);
  letter-spacing: -0.04em;
  line-height: 1.2;
}

.security-icon {
  display: grid;
  width: 48px;
  height: 48px;
  flex: 0 0 48px;
  place-items: center;
  border: 1px solid color-mix(in srgb, #c16b14 35%, var(--border));
  border-radius: 12px;
  background: color-mix(in srgb, #c16b14 10%, var(--surface));
  color: #b8610d;
}

.security-icon svg {
  width: 25px;
  height: 25px;
}

.security-lead {
  margin: 27px 0 0;
  font-size: 16px;
  line-height: 1.75;
}

.security-rules {
  margin: 22px 0;
  padding: 20px 22px 20px 42px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 14px;
  line-height: 1.7;
}

.security-rules li + li {
  margin-top: 7px;
}

.security-rules li::marker {
  color: #b8610d;
}

.security-consequence {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.75;
}

.connection-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin-top: 30px;
  padding: 19px 21px;
  border: 1px solid
    color-mix(in srgb, var(--accent) 38%, var(--border));
  border-radius: 11px;
  background: var(--accent-soft);
}

.connection-label,
.connection-ip {
  display: block;
}

.connection-label {
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 650;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.connection-ip {
  overflow-wrap: anywhere;
  font-family: var(--font-mono);
  font-size: 17px;
  font-weight: 650;
  letter-spacing: -0.02em;
}

.connection-status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 10px;
  white-space: nowrap;
}

.connection-status > span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #39a766;
  box-shadow: 0 0 0 4px
    color-mix(in srgb, #39a766 14%, transparent);
}

.security-privacy {
  margin: 13px 0 0;
  color: var(--faint);
  font-size: 11px;
  line-height: 1.65;
}

.security-actions {
  display: flex;
  gap: 10px;
  margin-top: 30px;
}

.security-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

@media (max-width: 520px) {
  .security-notice-head {
    align-items: center;
  }

  .connection-card {
    align-items: flex-start;
    flex-direction: column;
    gap: 12px;
  }

  .security-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .security-button {
    width: 100%;
  }
}
