@font-face {
  font-family: 'Atkinson Hyperlegible Mono';
  src: url('/fonts/atkinson-hyperlegible-mono-v8-latin-regular.woff2') format('woff2'),
    url('/fonts/atkinson-hyperlegible-mono-v8-latin-regular.ttf') format('truetype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

:root {
  --text-xs: 0.75rem;
  --text-sm: 0.8125rem;
  --text-base: 1rem;
  --text-lg: 1.125rem;
  --text-xl: 1.25rem;
  --text-2xl: 1.5rem;
  --text-3xl: 2rem;

  --space-2xs: 0.25rem;
  --space-xs: 0.5rem;
  --space-sm: 0.75rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2.5rem;
  --space-2xl: 4rem;

  --container: 1100px;
  --container-narrow: 720px;
  --gutter: 1.25rem;

  --ease: cubic-bezier(0.2, 0.7, 0.3, 1);
  --duration-fast: 0.15s;
  --duration: 0.25s;

  --radius-sm: 3px;
  --radius: 4px;
  --radius-lg: 6px;

  /* Default theme */
  --bg: #1e1e1e;
  --bg-2: #252526;
  --bg-3: #2d2d30;
  --line: #3e3e42;
  --line-strong: #5a5a60;
  --ink: #cccccc;
  --ink-strong: #ffffff;
  --ink-muted: #9d9d9d;
  --ink-faint: #7a7a7a;
  --accent: #4fc1ff;
  --accent-2: #75bfff;
  --accent-deep: #007acc;
  --accent-soft: #0a3a5a;
  --accent-on: #001e33;
  --status-bg: #007acc;
  --status-fg: #ffffff;
  --selection-bg: #094771;
  --selection-fg: #ffffff;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.5);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.55);
}

/* High contrast */
[data-theme="high-contrast"] {
  --bg: #000000;
  --bg-2: #0d0d0d;
  --bg-3: #161616;
  --line: #6a6a6a;
  --line-strong: #aaaaaa;
  --ink: #ffffff;
  --ink-strong: #ffffff;
  --ink-muted: #e8e8e8;
  --ink-faint: #c0c0c0;
  --accent: #ffff00;
  --accent-2: #ffff80;
  --accent-deep: #cccc00;
  --accent-soft: #2a2a00;
  --accent-on: #000000;
  --status-bg: #ffff00;
  --status-fg: #000000;
  --selection-bg: #ffff00;
  --selection-fg: #000000;
  --shadow-sm: 0 0 0 1px #aaaaaa;
  --shadow-md: 0 0 0 2px #ffffff;
}

/* Blue & yellow — protan / deutan */
[data-theme="blue-yellow"] {
  --bg: #1a2332;
  --bg-2: #243447;
  --bg-3: #2d3f56;
  --line: #3d4a5f;
  --line-strong: #5a6a82;
  --ink: #f0f4ff;
  --ink-strong: #ffffff;
  --ink-muted: #b8c4d6;
  --ink-faint: #8a96a8;
  --accent: #ffd23f;
  --accent-2: #ffe371;
  --accent-deep: #d4a700;
  --accent-soft: #3a3215;
  --accent-on: #1a1305;
  --status-bg: #4a90e2;
  --status-fg: #ffffff;
  --selection-bg: #ffd23f;
  --selection-fg: #1a2332;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.5);
}

/* Pink & teal — tritan */
[data-theme="pink-teal"] {
  --bg: #1f1f2e;
  --bg-2: #2a2a3e;
  --bg-3: #353548;
  --line: #3d3d55;
  --line-strong: #5d5d75;
  --ink: #f0e8f8;
  --ink-strong: #ffffff;
  --ink-muted: #c4b8d0;
  --ink-faint: #948aa8;
  --accent: #00d4aa;
  --accent-2: #4de3c8;
  --accent-deep: #00a888;
  --accent-soft: #053026;
  --accent-on: #001a14;
  --status-bg: #e91e63;
  --status-fg: #ffffff;
  --selection-bg: #e91e63;
  --selection-fg: #ffffff;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.5);
}

/* Monochrome — achromatopsia */
[data-theme="monochrome"] {
  --bg: #1a1a1a;
  --bg-2: #2a2a2a;
  --bg-3: #353535;
  --line: #4a4a4a;
  --line-strong: #707070;
  --ink: #e8e8e8;
  --ink-strong: #ffffff;
  --ink-muted: #b8b8b8;
  --ink-faint: #888888;
  --accent: #d8d8d8;
  --accent-2: #ffffff;
  --accent-deep: #a0a0a0;
  --accent-soft: #2f2f2f;
  --accent-on: #000000;
  --status-bg: #707070;
  --status-fg: #ffffff;
  --selection-bg: #d8d8d8;
  --selection-fg: #1a1a1a;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.5);
}

/* Light mode */
[data-theme="light"] {
  --bg: #ffffff;
  --bg-2: #f5f5f5;
  --bg-3: #ebebeb;
  --line: #d0d0d0;
  --line-strong: #999999;
  --ink: #1a1a1a;
  --ink-strong: #000000;
  --ink-muted: #4a4a4a;
  --ink-faint: #6a6a6a;
  --accent: #0066cc;
  --accent-2: #0080ff;
  --accent-deep: #004d99;
  --accent-soft: #e0eeff;
  --accent-on: #ffffff;
  --status-bg: #0066cc;
  --status-fg: #ffffff;
  --selection-bg: #0066cc;
  --selection-fg: #ffffff;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.08);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.12);
}

/* BIOS */
[data-theme="bios"] {
  --bg: #0c1f80;
  --bg-2: #0a1d70;
  --bg-3: #142a90;
  --line: #c8c8c8;
  --line-strong: #c8c8c8;
  --ink: #ffffff;
  --ink-strong: #e8d870;
  --ink-muted: #cccccc;
  --ink-faint: #a8a8a8;
  --accent: #e8d870;
  --accent-2: #f0e898;
  --accent-deep: #6fa8aa;
  --accent-soft: #000033;
  --accent-on: #000000;
  --status-bg: #a8a8a8;
  --status-fg: #000000;
  --selection-bg: #a8a8a8;
  --selection-fg: #000000;
  --shadow-sm: 3px 3px #000000;
  --shadow-md: 4px 4px #000000;
}


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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: 'Atkinson Hyperlegible Mono', 'Fira Code', 'Cascadia Code', 'JetBrains Mono', ui-monospace, 'SF Mono', Consolas, 'Courier New', monospace;
  font-size: var(--text-base);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition:
    background-color var(--duration) var(--ease),
    color var(--duration) var(--ease);
}

::selection {
  background: var(--selection-bg);
  color: var(--selection-fg);
}

/* Skip link */
.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 1000;
  padding: 0.5rem 1rem;
  background: var(--accent);
  color: var(--accent-on);
  text-decoration: none;
  font-weight: 600;
}

.skip-link:focus {
  left: 0;
  outline: 2px solid var(--ink-strong);
  outline-offset: 0;
}

/* Headings */
h1, h2, h3, h4, h5, h6 {
  font-family: inherit;
  color: var(--ink-strong);
  font-weight: 600;
  line-height: 1.3;
  margin: 0;
  text-wrap: balance;
}

h1 { font-size: var(--text-2xl); letter-spacing: 0.005em; }
h2 { font-size: var(--text-xl); }
h3 { font-size: var(--text-lg); }
h4 { font-size: var(--text-base); }

p {
  margin: 0;
  color: var(--ink);
  text-wrap: pretty;
}

small { font-size: var(--text-sm); color: var(--ink-muted); }

a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, var(--accent) 50%, transparent);
  text-underline-offset: 0.18em;
  transition:
    color var(--duration-fast) var(--ease),
    text-decoration-color var(--duration-fast) var(--ease);
}

a:hover {
  color: var(--accent-2);
  text-decoration-color: var(--accent-2);
}

img, svg { display: block; max-width: 100%; height: auto; }

hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: var(--space-lg) 0;
}

/* Lists */
ul, ol {
  margin: 0;
  padding-left: 1.5rem;
}

ul { list-style: none; }
ul > li { position: relative; }
ul > li::before {
  content: "▸";
  color: var(--accent-deep);
  position: absolute;
  left: -1.25rem;
  top: 0;
  font-weight: 700;
}

.list-plain {
  list-style: none;
  padding-left: 0;
}
.list-plain > li::before { content: none; }
.list-plain > li { padding-left: 0; }

ol > li { color: var(--ink); }

li { margin: 0.125rem 0; }

code, kbd, samp, pre {
  font-family: inherit;
}

/* Buttons */
button {
  font-family: inherit;
  font-size: inherit;
  cursor: pointer;
  background: var(--bg-3);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.4375rem 0.875rem;
  line-height: 1.2;
  transition-property: background-color, border-color, color, transform;
  transition-duration: var(--duration-fast);
  transition-timing-function: var(--ease);
}

button:hover {
  background: var(--bg-3);
  border-color: var(--line-strong);
  color: var(--ink-strong);
}

button:active { transform: scale(0.96); }

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  padding: 0.4375rem 0.875rem;
  font-family: inherit;
  font-size: var(--text-sm);
  font-weight: 500;
  line-height: 1.2;
  color: var(--accent-on);
  background: var(--accent-deep);
  border: 1px solid var(--accent-deep);
  border-radius: var(--radius);
  text-decoration: none;
  cursor: pointer;
  transition-property: background-color, border-color, color, transform;
  transition-duration: var(--duration-fast);
  transition-timing-function: var(--ease);
  min-height: 36px;
  white-space: nowrap;
}

.btn:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-on);
  text-decoration: none;
}

.btn:active { transform: scale(0.96); }

.btn-ghost {
  background: transparent;
  color: var(--ink);
  border-color: var(--line);
}

.btn-ghost:hover {
  background: var(--bg-2);
  color: var(--ink-strong);
  border-color: var(--line-strong);
}

/* Tag / pill */
.tag {
  display: inline-flex;
  align-items: center;
  padding: 0.1875rem 0.5rem;
  font-size: var(--text-xs);
  color: var(--ink);
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  text-decoration: none;
  transition-property: background-color, border-color, color;
  transition-duration: var(--duration-fast);
  transition-timing-function: var(--ease);
  min-height: 24px;
}

.tag:hover {
  color: var(--ink-strong);
  background: var(--bg-3);
  border-color: var(--accent);
  text-decoration: none;
}

.tag.is-active,
.tag[aria-current="page"] {
  background: var(--accent-deep);
  color: var(--accent-on);
  border-color: var(--accent-deep);
}

.tag.is-active::before {
  content: "✓ ";
  font-weight: 700;
}

/* Form elements */
input, textarea, select {
  font-family: inherit;
  font-size: var(--text-sm);
  background: var(--bg-2);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.5rem 0.75rem;
  transition: border-color var(--duration-fast) var(--ease);
  min-height: 36px;
}

input:hover, textarea:hover, select:hover {
  border-color: var(--line-strong);
}

input:focus, textarea:focus, select:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: var(--accent);
}

::placeholder { color: var(--ink-faint); opacity: 1; }

/* Layout */
.container {
  width: 100%;
  max-width: var(--container);
  margin: 0 auto;
  padding-left: var(--gutter);
  padding-right: var(--gutter);
}

.container-narrow { max-width: var(--container-narrow); }

/* Panel */
.panel {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  position: relative;
  transition: border-color var(--duration-fast) var(--ease);
}

.panel:has(.panel-link:hover),
.panel:has(.panel-link:focus-visible) {
  border-color: var(--accent);
}

.panel-link {
  color: var(--ink-strong);
  text-decoration: none;
  transition: color var(--duration-fast) var(--ease);
}

.panel-link::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 0;
}

.panel-link:hover,
.panel-link:focus-visible {
  color: var(--accent);
  text-decoration: none;
}

.panel .tag {
  position: relative;
  z-index: 1;
}

.panel-title {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-xs) var(--space-md);
  background: var(--bg-3);
  border-bottom: 1px solid var(--line);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--ink-strong);
  letter-spacing: 0.02em;
  border-radius: var(--radius) var(--radius) 0 0;
  margin: 0;
}

.panel-title-index {
  color: var(--ink-faint);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.panel-body {
  padding: var(--space-md);
}

.panel-body > :first-child { margin-top: 0; }
.panel-body > :last-child { margin-bottom: 0; }

/* Empty state */
.empty {
  padding: var(--space-xl);
  text-align: center;
  color: var(--ink-muted);
  font-style: italic;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
}

/* Scrollbars */
::-webkit-scrollbar { width: 12px; height: 12px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb {
  background: var(--line);
  border-radius: var(--radius);
  border: 2px solid var(--bg);
}
::-webkit-scrollbar-thumb:hover { background: var(--line-strong); }

/* Screen reader only */
.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;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

button:focus-visible,
.btn:focus-visible,
.tag:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: no-preference) {
  @view-transition { navigation: auto; }

  @keyframes fade-in-up {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
  }

  .stagger-children > * {
    animation: fade-in-up 0.4s var(--ease) both;
  }
  .stagger-children > *:nth-child(2) { animation-delay: 80ms; }
  .stagger-children > *:nth-child(3) { animation-delay: 160ms; }
  .stagger-children > *:nth-child(4) { animation-delay: 240ms; }
  .stagger-children > *:nth-child(n+5) { animation-delay: 320ms; }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* Print */
@media print {
  body { background: white; color: black; }
  .site-header, .site-footer, .skip-link, dialog { display: none !important; }
  a { color: black; text-decoration: underline; }
  a[href^="http"]::after {
    content: " <" attr(href) ">";
    font-size: 90%;
    color: #666;
  }
}

@media (min-width: 1280px) {
  body { font-size: 1.0625rem; }
}

@media (max-width: 640px) {
  :root {
    --gutter: 1rem;
    --space-2xl: 2.5rem;
  }
  body { font-size: 0.9375rem; }
  h1 { font-size: var(--text-xl); }
  h2 { font-size: var(--text-lg); }
}

/* ---------- Navigation / title bar ---------- */

.site-header {
  position: relative;
  border-bottom: 1px solid var(--line);
  background: var(--bg-3);
}

.title-bar {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: 0.625rem var(--gutter);
  min-height: 44px;
}

.title-bar-brand {
  color: var(--ink);
  text-decoration: none;
  font-weight: 600;
  font-size: var(--text-sm);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
  flex-shrink: 1;
}

.title-bar-brand:hover {
  color: var(--ink-strong);
  text-decoration: none;
}

.title-bar-sep {
  margin: 0 0.5rem;
  color: var(--ink-faint);
}

.title-bar-section {
  color: var(--accent);
}

.title-bar-nav {
  margin-left: auto;
}

.title-bar-nav-list {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  margin: 0;
  padding: 0;
}

.nav-link {
  display: inline-flex;
  align-items: center;
  padding: 0 0.75rem;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--ink);
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  text-decoration: none;
  transition-property: background-color, border-color, color;
  transition-duration: var(--duration-fast);
  transition-timing-function: var(--ease);
  height: 32px;
  box-sizing: border-box;
}

.nav-link:hover {
  background: var(--bg-3);
  color: var(--ink-strong);
  border-color: var(--line-strong);
  text-decoration: none;
}

.nav-link.is-current {
  background: var(--accent-deep);
  color: var(--accent-on);
  border-color: var(--accent-deep);
}

.title-bar-actions {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  flex-shrink: 0;
}

.kbd-trigger {
  width: 32px;
  height: 32px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  background: var(--bg-2);
  box-sizing: border-box;
  line-height: 1;
}

.kbd-trigger:hover {
  color: var(--accent);
  border-color: var(--accent);
}

/* ---------- Footer / status bar ---------- */

.status-bar {
  border-top: 1px solid var(--line);
  background: var(--status-bg);
  color: var(--status-fg);
  padding: 0.5rem var(--gutter);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
  flex-wrap: wrap;
  font-size: var(--text-sm);
  min-height: 36px;
}

.status-bar-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem var(--space-md);
}

.status-bar a {
  color: var(--status-fg);
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, var(--status-fg) 50%, transparent);
}

.status-bar a:hover {
  color: var(--status-fg);
  text-decoration-color: var(--status-fg);
}

.status-bar a:focus-visible {
  outline: 2px solid var(--status-fg);
  outline-offset: 2px;
}

.status-bar .nav-link {
  color: var(--status-fg);
  background: color-mix(in srgb, var(--status-fg) 8%, transparent);
  border-color: color-mix(in srgb, var(--status-fg) 40%, transparent);
  text-decoration: none;
}

.status-bar .nav-link:hover {
  color: var(--status-fg);
  background: color-mix(in srgb, var(--status-fg) 18%, transparent);
  border-color: var(--status-fg);
  text-decoration: none;
}

.status-bar .nav-link:focus-visible {
  outline: 2px solid var(--status-fg);
  outline-offset: 2px;
}

.status-bar-hint {
  color: color-mix(in srgb, var(--status-fg) 80%, transparent);
  font-size: var(--text-xs);
}

.status-bar-hint kbd {
  background: color-mix(in srgb, var(--status-fg) 20%, transparent);
  color: var(--status-fg);
  border-color: color-mix(in srgb, var(--status-fg) 40%, transparent);
}

@media (max-width: 720px) {
  .status-bar-hint {
    display: none;
  }
}
/* ---------- Dialogue ---------- */

.dialogue {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  flex-wrap: wrap;
}

.dialogue-img-wrapper {
  position: relative;
  flex-shrink: 0;
}

.dialogue img {
  width: 120px;
  height: 120px;
  object-fit: contain;
}

.dialogue-text {
  margin: 0;
  font-size: var(--text-base);
  line-height: 1.6;
  color: var(--ink);
  flex: 1;
  min-width: 240px;
}

@media (max-width: 480px) {
  .dialogue {
    gap: var(--space-sm);
  }
  .dialogue img {
    width: 96px;
    height: 96px;
  }
}

.dialogue-cursor {
  color: var(--accent);
  animation: dialogue-blink 0.7s step-end infinite;
}

@keyframes dialogue-blink {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0;
  }
}

/* ---------- Post panel ---------- */

.post-panel-date {
  color: var(--accent);
  font-size: var(--text-sm);
  margin: 0 0 var(--space-xs);
  font-variant-numeric: tabular-nums;
}

.post-panel-desc {
  margin: 0 0 var(--space-sm);
}

.post-panel-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
  margin: 0;
}

/* ---------- Home page ---------- */

.home {
  padding: var(--space-md) 0;
}

.home-intro {
  margin-bottom: var(--space-xl);
  padding: var(--space-md) var(--gutter);
}

.home-about {
  margin-bottom: var(--space-xl);
  padding: 0 var(--gutter);
}

.prose p + p {
  margin-top: var(--space-md);
}

.section-divider {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  margin: var(--space-xl) var(--gutter) var(--space-md);
}

.section-divider hr {
  flex: 1;
  margin: 0;
  border: 0;
  border-top: 1px dashed var(--line);
}

.section-divider h2 {
  color: var(--ink-strong);
  font-size: var(--text-lg);
  text-align: center;
  margin: 0;
}

.post-feed {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  margin: 0 0 var(--space-md);
  padding: 0 var(--gutter);
}

.post-feed > li::before {
  content: none;
}

.home-posts-more {
  text-align: center;
  margin: var(--space-md) 0 0;
  padding: 0 var(--gutter);
}

/* ---------- Generic page header / blog / tag pages ---------- */

.page {
  padding: var(--space-md) var(--gutter);
}

.page-header {
  margin-bottom: var(--space-lg);
}

.page-header h1 {
  margin: 0 0 var(--space-xs);
}

.page-header-link {
  font-size: var(--text-sm);
}

.page-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
  flex-wrap: wrap;
}

.page-header-row h1 {
  margin: 0;
}

.tag-name {
  color: var(--accent);
  font-weight: 600;
}

/* ---------- Artwork index ---------- */

.nsfw-notice {
  margin: var(--space-md) 0;
  font-size: var(--text-sm);
  color: var(--ink-muted);
  font-style: italic;
}

.nsfw-flag {
  color: var(--accent);
  font-style: normal;
  font-weight: 600;
}

.artwork-panels {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-md);
  margin: 0;
  padding: 0;
}

/* Basis wraps the two panels to a single column under ~640px, no media query. */
.artwork-panels > li {
  flex: 1 1 20rem;
  min-width: 0;
}

.artwork-panels > li .artwork-panel {
  height: 100%;
}

.artwork-panels > li::before {
  content: none;
}

.artwork-hero {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border-bottom: 1px solid var(--line);
}

.artwork-panel .panel-body p {
  margin: 0;
}

/* ---------- Links page ---------- */

.links-groups {
  display: flex;
  flex-direction: column;
  gap: var(--space-xl);
}

.wads-hero {
  display: block;
  width: 100%;
  max-width: 640px;
  height: auto;
  margin: 0 auto var(--space-xl);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.links-group-head {
  margin-bottom: var(--space-md);
  padding-bottom: var(--space-xs);
  border-bottom: 1px dashed var(--line);
}

.links-group-title {
  margin: 0;
  font-size: var(--text-base);
  color: var(--ink-strong);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.links-group-marker {
  color: var(--accent);
  font-weight: 700;
  margin-right: 0.375rem;
}

.links-group-desc {
  margin: var(--space-2xs) 0 0;
  font-size: var(--text-sm);
  color: var(--ink-muted);
}

.link-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--space-sm);
}

.link-cards > li::before {
  content: none;
}

.link-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-2xs);
  padding: var(--space-sm) var(--space-md);
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--ink);
  text-decoration: none;
  transition:
    background var(--duration-fast) var(--ease),
    border-color var(--duration-fast) var(--ease),
    transform var(--duration-fast) var(--ease);
  height: 100%;
}

.link-card:hover,
.link-card:focus-visible {
  background: var(--bg-3);
  border-color: var(--accent);
  color: var(--ink);
  text-decoration: none;
  transform: translateY(-1px);
}

.link-card-title {
  margin: 0;
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--accent);
  display: flex;
  align-items: baseline;
  gap: var(--space-xs);
  line-height: 1.3;
}

.link-card-name {
  flex: 1;
}

.link-card-arrow {
  color: var(--ink-faint);
  font-size: var(--text-sm);
  flex-shrink: 0;
  transition:
    transform var(--duration-fast) var(--ease),
    color var(--duration-fast) var(--ease);
}

.link-card:hover .link-card-arrow,
.link-card:focus-visible .link-card-arrow {
  color: var(--accent);
  transform: translate(2px, -2px);
}

.link-card-desc {
  margin: 0;
  color: var(--ink);
  font-size: var(--text-sm);
  line-height: 1.55;
  overflow-wrap: break-word;
}

/* ---------- Gallery / lightbox ---------- */

.nsfw-switch {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  font-size: var(--text-sm);
  color: var(--ink-muted);
  cursor: pointer;
  user-select: none;
}

.nsfw-switch-input {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: 0;
  padding: 0;
  border: 0;
  opacity: 0;
  pointer-events: none;
}

.nsfw-switch-track {
  position: relative;
  display: inline-block;
  width: 34px;
  height: 18px;
  background: var(--bg-3);
  border: 1px solid var(--line);
  border-radius: 999px;
  flex-shrink: 0;
  transition:
    background var(--duration-fast) var(--ease),
    border-color var(--duration-fast) var(--ease);
}

.nsfw-switch-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 12px;
  height: 12px;
  background: var(--ink-muted);
  border-radius: 50%;
  transition:
    transform var(--duration-fast) var(--ease),
    background var(--duration-fast) var(--ease);
}

.nsfw-switch-input:checked ~ .nsfw-switch-track {
  background: var(--accent);
  border-color: var(--accent);
}

.nsfw-switch-input:checked ~ .nsfw-switch-track .nsfw-switch-thumb {
  transform: translateX(16px);
  background: var(--bg);
}

.nsfw-switch-input:focus-visible ~ .nsfw-switch-track {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.nsfw-switch:hover .nsfw-switch-label {
  color: var(--ink);
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: var(--space-sm);
  padding: 0;
  margin: 0;
}

.gallery-grid > li::before {
  content: none;
}

.gallery-divider {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin: var(--space-sm) 0;
}

.gallery-divider::before,
.gallery-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}

.gallery-divider-label {
  margin: 0;
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--ink-muted);
  letter-spacing: 0.15em;
}

.gallery-thumb {
  display: block;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg-2);
  transition:
    border-color var(--duration-fast) var(--ease),
    transform var(--duration-fast) var(--ease);
  aspect-ratio: 1 / 1;
}

.gallery-thumb:hover,
.gallery-thumb:focus-visible {
  border-color: var(--accent);
  transform: translateY(-2px);
  text-decoration: none;
}

.gallery-thumb-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: saturate(0.85);
  transition:
    filter var(--duration-fast) var(--ease),
    transform 0.5s var(--ease);
}

.gallery-thumb:hover .gallery-thumb-img,
.gallery-thumb:focus-visible .gallery-thumb-img {
  filter: saturate(1);
  transform: scale(1.04);
}



[hidden] {
  display: none !important;
}

e-json {
  display: contents;
}

/* ---------- Window ---------- */

.window {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

.window > main {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-block: var(--space-lg) var(--space-xl);
}

.window > main:focus {
  outline: none;
}

@media (min-width: 768px) {
  .window {
    max-width: 1100px;
    width: calc(100% - 2.5rem);
    margin: 1.25rem auto;
    height: calc(100vh - 2.5rem);
    height: calc(100dvh - 2.5rem);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    background: var(--bg);
    box-shadow: var(--shadow-md);
  }
}

.site-header,
.site-footer {
  position: relative;
  z-index: 50;
  transition: box-shadow var(--duration-fast) var(--ease);
}

@media print {
  .window,
  .window > main {
    height: auto;
    overflow: visible;
  }
}

[data-scrolled] .site-header {
  box-shadow: var(--shadow-md);
}

[data-more] .site-footer {
  box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.45);
}

.title-bar {
  flex-wrap: wrap;
}

.title-bar-menu {
  display: contents;
}

.title-bar-burger {
  display: none;
  width: 36px;
  height: 36px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  margin-left: auto;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
}

.burger-line {
  display: block;
  width: 18px;
  height: 2px;
  background: var(--ink);
  transition:
    transform var(--duration-fast) var(--ease),
    opacity var(--duration-fast) var(--ease);
}

#menu-toggle:focus-visible + .title-bar-burger {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

#menu-toggle:checked + .title-bar-burger .burger-line:nth-child(1) {
  transform: translateY(6px) rotate(45deg);
}

#menu-toggle:checked + .title-bar-burger .burger-line:nth-child(2) {
  opacity: 0;
}

#menu-toggle:checked + .title-bar-burger .burger-line:nth-child(3) {
  transform: translateY(-6px) rotate(-45deg);
}

@media (max-width: 720px) {
  .title-bar-burger {
    display: flex;
  }
  .title-bar-menu {
    display: none;
  }
  #menu-toggle:checked ~ .title-bar-menu {
    display: flex;
    flex-direction: column;
    flex-basis: 100%;
    gap: var(--space-sm);
    padding-top: var(--space-sm);
    border-top: 1px solid var(--line);
  }
  .title-bar-nav {
    margin-left: 0;
    width: 100%;
  }
  .title-bar-nav-list {
    flex-direction: column;
    align-items: stretch;
  }
  .title-bar-nav-list .nav-link {
    display: flex;
    width: 100%;
    height: 44px;
  }
  .title-bar-actions {
    width: 100%;
  }
  .title-bar-actions .theme-select {
    flex: 1;
    height: 44px;
  }
  .kbd-trigger {
    width: 44px;
    height: 44px;
  }
}

.dialogue img {
  cursor: grab;
  touch-action: none;
  will-change: transform;
  -webkit-user-drag: none;
}

.dialogue img:active {
  cursor: grabbing;
}

.dialogue-weee {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  padding: 0.25rem 0.625rem;
  background: var(--bg-3);
  color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  font-size: var(--text-xs);
  font-weight: 600;
  white-space: nowrap;
  opacity: 0;
  transition:
    opacity 1.2s var(--ease),
    transform 1.2s var(--ease);
  pointer-events: none;
  z-index: 5;
}

.dialogue-weee.is-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
  transition:
    opacity 0.15s var(--ease),
    transform 0.15s var(--ease);
}

.nav-link[aria-current="page"] {
  background: var(--accent-deep);
  color: var(--accent-on);
  border-color: var(--accent-deep);
}

.theme-select {
  height: 32px;
  min-height: 0;
  padding: 0 2rem 0 0.5rem;
  appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--ink) 50%),
    linear-gradient(135deg, var(--ink) 50%, transparent 50%);
  background-position:
    calc(100% - 1.1rem) 50%,
    calc(100% - 0.8rem) 50%;
  background-size: 0.3rem 0.3rem;
  background-repeat: no-repeat;
}

/* ---------- Typewriter (CSS only) ---------- */

.dialogue-typed span {
  position: relative;
  opacity: 0;
  animation: type-in 10ms linear forwards;
  animation-delay: calc(0.4s + var(--i) * 70ms);
}

.dialogue-typed span::after {
  content: "█";
  position: absolute;
  left: 100%;
  top: 50%;
  transform: translateY(-50%);
  line-height: 1;
  color: var(--accent);
  opacity: 0;
  animation: cursor-step 70ms linear forwards;
  animation-delay: calc(0.4s + var(--i) * 70ms);
}

.dialogue-cursor {
  opacity: 0;
  animation-delay: 3.2s;
}

@keyframes type-in {
  to {
    opacity: 1;
  }
}

@keyframes cursor-step {
  0%,
  99% {
    opacity: 1;
  }
  100% {
    opacity: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .dialogue-typed span {
    opacity: 1;
    animation: none;
  }
  .dialogue-typed span::after,
  .dialogue-cursor {
    display: none;
  }
}

@media (max-width: 480px) {
  .dialogue-text {
    font-size: var(--text-sm);
  }
}

/* ---------- Dialogs (viewer + shortcuts) ---------- */

dialog {
  margin: auto;
  max-width: min(95vw, 1100px);
  padding: var(--space-md);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-lg);
  background: var(--bg-2);
  color: var(--ink);
  box-shadow: var(--shadow-md);
}

dialog::backdrop {
  background: rgba(0, 0, 0, 0.8);
}

dialog form {
  display: flex;
  justify-content: center;
  gap: var(--space-sm);
  margin-top: var(--space-sm);
}

#kbd-help form {
  justify-content: flex-start;
  gap: var(--space-md);
  margin-top: var(--space-lg);
}

#vk-toggle {
  flex: 1;
}

#kbd-help form button:last-child {
  flex: 0 0 20%;
}

dialog figure {
  margin: 0;
}

dialog figcaption {
  text-align: center;
  margin-top: var(--space-xs);
  color: var(--ink-muted);
  font-size: var(--text-sm);
}

.viewer-img {
  max-width: 100%;
  max-height: 75vh;
  margin: 0 auto;
  object-fit: contain;
}

kbd {
  font-family: inherit;
  font-size: var(--text-xs);
  padding: 0.0625rem 0.375rem;
  background: var(--bg-3);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
}

.kbd-list {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: var(--space-xs) var(--space-md);
  margin: var(--space-md) 0;
}

.kbd-list dd {
  margin: 0;
}

/* ---------- Gallery ---------- */

.gallery-thumb:has(img.nsfw) {
  cursor: not-allowed;
}

body:not(:has(.nsfw-switch-input:checked)) img.nsfw {
  filter: blur(20px) saturate(0.85);
  transform: none;
}

body:not(:has(.nsfw-switch-input:checked)) .gallery-thumb:has(img.nsfw):hover {
  border-color: var(--line);
  transform: none;
}

.page-header-row .nsfw-switch {
  margin-left: auto;
}

/* ---------- Post / prose ---------- */

.post-meta {
  color: var(--accent);
  font-size: var(--text-sm);
  margin: 0 0 var(--space-xs);
}

.post-hero {
  width: 100%;
  max-height: 20rem;
  object-fit: cover;
  margin: var(--space-md) 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.post-body > * + * {
  margin-top: var(--space-md);
}

.post-body h2,
.post-body h3 {
  margin-top: var(--space-xl);
}

.post-body ul,
.post-body ol {
  padding-left: 1.5rem;
}

.post-body ol {
  list-style: decimal;
}

.post-body pre {
  overflow-x: auto;
  padding: var(--space-md);
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.post-body code {
  font-size: var(--text-sm);
}

.post-body blockquote {
  margin-left: 0;
  padding-left: var(--space-md);
  border-left: 3px solid var(--accent-deep);
  color: var(--ink-muted);
}

.post-body table {
  border-collapse: collapse;
}

.post-body th,
.post-body td {
  padding: var(--space-xs) var(--space-sm);
  border: 1px solid var(--line);
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
}

/* ---------- Dice roller ---------- */

.dice-roller {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.dice-groups {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.dice-group,
.dice-actions,
.dice-config-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: var(--space-sm);
}

.dice-field {
  display: flex;
  flex-direction: column;
  gap: var(--space-2xs);
  font-size: var(--text-xs);
  color: var(--ink-muted);
}

.dice-field input {
  width: 6rem;
}

.dice-total {
  font-size: var(--text-3xl);
  color: var(--accent);
  font-weight: 700;
}

.dice-rolls {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-xs);
  margin-top: var(--space-xs);
}

.dice-rolls > li {
  min-width: 2.25rem;
  padding: 0.25rem 0.5rem;
  text-align: center;
  background: var(--bg-3);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
}

.dice-history > li {
  color: var(--ink-muted);
}

.dice-history b {
  color: var(--ink-strong);
}
