/* ---------- BaseLayout / window ---------- */

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

.window-main {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: var(--space-lg) 0 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);
  }
}

/* ---------- Keyboard help modal ---------- */

.kbd-help[hidden] { display: none; }

.kbd-help {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-md);
}

.kbd-help-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  cursor: pointer;
}

.kbd-help-modal {
  position: relative;
  max-width: 560px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  background: var(--bg-2);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  padding: var(--space-lg);
  box-shadow: var(--shadow-md);
}

.kbd-help-art {
  display: none;
  margin: 0 0 var(--space-sm);
  color: var(--accent);
  font-size: 0.875rem;
  line-height: 1.15;
  text-align: center;
  white-space: pre;
  overflow-x: auto;
}

.kbd-help-version {
  display: none;
  text-align: center;
  color: var(--ink-faint);
  font-size: var(--text-sm);
  letter-spacing: 0.1em;
  margin-bottom: var(--space-md);
}

.kbd-help-title {
  margin: 0 0 var(--space-md);
  font-size: var(--text-lg);
  color: var(--ink-strong);
  letter-spacing: 0.02em;
}

.kbd-help-list {
  display: grid;
  grid-template-columns: max-content 1fr;
  column-gap: var(--space-md);
  row-gap: var(--space-xs);
  margin: 0 0 var(--space-md);
}

.kbd-help-list dt {
  color: var(--ink);
  white-space: nowrap;
}

.kbd-help-list dd {
  margin: 0;
  color: var(--ink-muted);
}

kbd {
  display: inline-block;
  padding: 0.125rem 0.4rem;
  font-family: inherit;
  font-size: 0.8125rem;
  color: var(--ink-strong);
  background: var(--bg-3);
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: var(--radius-sm);
  line-height: 1;
}

.kbd-help-toggle-note {
  margin: 0 0 var(--space-sm);
  padding: var(--space-xs) var(--space-sm);
  background: var(--bg-3);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  color: var(--ink-muted);
  line-height: 1.5;
}

.kbd-help-toggle-note kbd {
  font-size: 0.6875rem;
  padding: 0 0.3rem;
}

.kbd-help-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-sm);
  flex-wrap: wrap;
  padding-top: var(--space-sm);
  border-top: 1px solid var(--line);
}

.kbd-help-toggle-btn { font-size: var(--text-xs); }
.kbd-help-toggle-btn[aria-pressed="false"] {
  color: var(--ink-muted);
  background: var(--bg);
}

/* ---------- 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);
  color: var(--ink);
  box-sizing: border-box;
  line-height: 1;
}

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

.title-bar-burger {
  display: none;
  width: 36px;
  height: 36px;
  padding: 0;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  background: var(--bg-2);
  margin-left: auto;
}

.burger-line {
  display: block;
  width: 18px;
  height: 2px;
  background: var(--ink);
}

.title-bar-burger[aria-expanded="true"] .burger-line:nth-child(2) {
  transform: translateY(6px) rotate(45deg);
}
.title-bar-burger[aria-expanded="true"] .burger-line:nth-child(3) { opacity: 0; }
.title-bar-burger[aria-expanded="true"] .burger-line:nth-child(4) {
  transform: translateY(-6px) rotate(-45deg);
}

.mobile-nav {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 90;
  max-height: calc(100dvh - 45px);
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: var(--bg-2);
  padding: var(--space-sm) var(--gutter);
  box-shadow: var(--shadow-md);
}

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

.mobile-nav ul {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin: 0;
  padding: 0;
}

.mobile-nav-link {
  display: block;
  padding: 0.625rem 0.75rem;
  color: var(--ink);
  text-decoration: none;
  border: 1px solid transparent;
  border-radius: var(--radius);
  min-height: 44px;
  line-height: 1.4;
  font-size: var(--text-sm);
}

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

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

.mobile-nav-extras {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  margin-top: var(--space-sm);
  padding-top: var(--space-sm);
  border-top: 1px solid var(--line);
}

.mobile-nav-help { align-self: flex-start; }

@media (max-width: 720px) {
  .title-bar-nav, .title-bar-actions { display: none; }
  .title-bar-burger { display: flex; }
  .title-bar { gap: var(--space-sm); }
}

/* ---------- 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-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; }
}

@media (max-width: 480px) {
  .status-bar-links { flex-direction: column; gap: 0.25rem; }
}

/* ---------- Theme switcher ---------- */

.theme-switcher { position: relative; }

.theme-trigger {
  display: inline-flex;
  align-items: center;
  gap: 0.4375rem;
  padding: 0 0.625rem;
  font-size: var(--text-xs);
  font-weight: 500;
  background: var(--bg-2);
  border: 1px solid var(--line);
  color: var(--ink);
  border-radius: var(--radius);
  cursor: pointer;
  line-height: 1;
  height: 32px;
  box-sizing: border-box;
}

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

.theme-trigger-swatch {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 1px solid var(--line);
  flex-shrink: 0;
}

.theme-trigger-caret {
  color: var(--ink-faint);
  font-size: 0.75rem;
}

.theme-menu {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  min-width: 280px;
  background: var(--bg-2);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 0.25rem;
  z-index: 100;
  margin: 0;
  max-height: 70vh;
  overflow-y: auto;
}

.theme-menu[hidden] { display: none; }
.theme-menu > li::before { content: none; }

.theme-option {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  width: 100%;
  padding: 0.5rem 0.625rem;
  background: transparent;
  border: 1px solid transparent;
  color: var(--ink);
  text-align: left;
  border-radius: var(--radius);
  cursor: pointer;
  line-height: 1.3;
  min-height: 44px;
}

.theme-option:hover,
.theme-option:focus-visible {
  background: var(--bg-3);
  color: var(--ink-strong);
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.theme-option[aria-selected="true"] {
  background: var(--accent-soft);
  color: var(--ink-strong);
}

.theme-option-swatch {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 1px solid var(--line);
  flex-shrink: 0;
}

.theme-option-text {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.theme-option-name {
  font-size: var(--text-sm);
  font-weight: 600;
  color: inherit;
}

.theme-option-desc {
  font-size: var(--text-xs);
  color: var(--ink-muted);
  line-height: 1.3;
  white-space: normal;
  overflow-wrap: anywhere;
}

.theme-option-check {
  color: var(--accent);
  font-weight: 700;
  opacity: 0;
  flex-shrink: 0;
}

.theme-option[aria-selected="true"] .theme-option-check { opacity: 1; }

.theme-switcher--mobile { width: 100%; }

.theme-switcher--mobile .theme-trigger {
  width: 100%;
  justify-content: space-between;
  padding: 0.625rem 0.875rem;
  min-height: 44px;
  font-size: var(--text-sm);
}

.theme-switcher--mobile .theme-menu {
  position: static;
  width: 100%;
  margin-top: 0.5rem;
  box-shadow: none;
}

[data-theme-preview="default"]       { background: linear-gradient(135deg, #4fc1ff 50%, #1e1e1e 50%); }
[data-theme-preview="high-contrast"] { background: linear-gradient(135deg, #ffff00 50%, #000000 50%); }
[data-theme-preview="blue-yellow"]   { background: linear-gradient(135deg, #ffd23f 50%, #1a2332 50%); }
[data-theme-preview="pink-teal"]     { background: linear-gradient(135deg, #00d4aa 50%, #1f1f2e 50%); }
[data-theme-preview="monochrome"]    { background: linear-gradient(135deg, #d8d8d8 50%, #1a1a1a 50%); }
[data-theme-preview="light"]         { background: linear-gradient(135deg, #0066cc 50%, #ffffff 50%); }
[data-theme-preview="bios"]          { background: linear-gradient(135deg, #ffff54 50%, #000055 50%); }

/* ---------- 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;
  will-change: transform;
  cursor: grab;
}

.dialogue img:active { cursor: grabbing; }

.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-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::before {
  content: "";
  position: absolute;
  bottom: -6px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-top: 6px solid var(--accent);
}

.dialogue-weee::after {
  content: "";
  position: absolute;
  bottom: -4px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 5px solid var(--bg-3);
}

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

.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;
}

/* ---------- 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-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);
}

.gallery-thumb-blurred {
  cursor: not-allowed;
}

.gallery-thumb-blurred .gallery-thumb-img,
.gallery-thumb-blurred:hover .gallery-thumb-img,
.gallery-thumb-blurred:focus-visible .gallery-thumb-img {
  filter: blur(20px) saturate(0.85);
  transform: none;
}

.gallery-thumb-blurred:hover,
.gallery-thumb-blurred:focus-visible {
  border-color: var(--line);
  transform: none;
}

.lightbox[hidden] { display: none; }

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-md);
}

.lightbox-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  cursor: pointer;
}

.lightbox-modal {
  position: relative;
  max-width: 1100px;
  width: 100%;
  background: var(--bg-2);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  max-height: 90vh;
}

.lightbox-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  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);
  flex-shrink: 0;
}

.lightbox-counter {
  color: var(--ink-muted);
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}

.lightbox-close {
  width: 32px;
  height: 32px;
  padding: 0;
  font-size: var(--text-xl);
  line-height: 1;
  background: var(--bg-2);
  flex-shrink: 0;
}

.lightbox-stage {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-md);
  flex: 1;
  min-height: 0;
}

.lightbox-side-nav {
  width: 40px;
  height: 40px;
  padding: 0;
  font-size: var(--text-2xl);
  line-height: 1;
  background: var(--bg-3);
  flex-shrink: 0;
}

.lightbox-figure {
  flex: 1;
  margin: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-xs);
  min-width: 0;
  height: 100%;
}

.lightbox-img {
  max-width: 100%;
  max-height: 70vh;
  object-fit: contain;
  border: 1px solid var(--line);
}

.lightbox-caption-desktop {
  color: var(--ink-muted);
  font-size: var(--text-sm);
}

.lightbox-caption-mobile { display: none; }
.lightbox-bottom-nav { display: none; }

@media (max-width: 640px) {
  .lightbox { padding: 0; }
  .lightbox-modal {
    max-width: none;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    max-height: none;
    border: 0;
    border-radius: 0;
  }
  .lightbox-caption-mobile {
    display: block;
    flex: 1;
    min-width: 0;
    text-align: center;
    color: var(--ink);
    font-size: var(--text-sm);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    padding: 0 var(--space-xs);
  }
  .lightbox-side-nav { display: none; }
  .lightbox-caption-desktop { display: none; }
  .lightbox-stage {
    padding: var(--space-sm);
    flex: 1;
    min-height: 0;
    touch-action: pan-y pinch-zoom;
  }
  .lightbox-img {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
  }
  .lightbox-bottom-nav {
    display: flex;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    background: var(--bg-3);
    border-top: 1px solid var(--line);
    flex-shrink: 0;
  }
  .lightbox-bottom-btn {
    flex: 1;
    min-height: 48px;
    padding: 0;
    font-size: var(--text-sm);
    font-weight: 600;
    background: var(--bg-2);
    border: 1px solid var(--line);
    color: var(--ink);
    border-radius: var(--radius);
  }
  .lightbox-bottom-btn:hover,
  .lightbox-bottom-btn:focus-visible {
    background: var(--bg);
    border-color: var(--accent);
    color: var(--ink-strong);
  }
}

/* ---------- 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;
}

/* ---------- Post layout ---------- */

.post {
  padding: var(--space-md) var(--gutter) var(--space-xl);
  max-width: var(--container-narrow);
}

.post-header {
  margin-bottom: var(--space-lg);
  padding-bottom: var(--space-md);
  border-bottom: 1px solid var(--line);
}

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

.post-title {
  font-size: var(--text-2xl);
  line-height: 1.3;
  color: var(--ink-strong);
  margin: var(--space-xs) 0 var(--space-sm);
  overflow-wrap: break-word;
}

.post-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-sm);
}

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

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

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

.post-body {
  font-size: var(--text-base);
  line-height: 1.7;
  color: var(--ink);
}

.post-body p { margin: 0 0 var(--space-md); }

.post-body h1,
.post-body h2,
.post-body h3,
.post-body h4 {
  color: var(--ink-strong);
  margin: var(--space-lg) 0 var(--space-sm);
  line-height: 1.3;
}

.post-body h1 { font-size: var(--text-2xl); }
.post-body h2 { font-size: var(--text-xl); }
.post-body h3 { font-size: var(--text-lg); }
.post-body h4 { font-size: var(--text-base); }

.post-body a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, var(--accent) 50%, transparent);
  text-underline-offset: 0.18em;
}

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

.post-body ul,
.post-body ol {
  margin: var(--space-md) 0;
  padding-left: 1.5rem;
}

.post-body ul > li::before {
  content: "▸";
  position: absolute;
  left: -1.25rem;
  color: var(--accent-deep);
  font-weight: 700;
}

.post-body li {
  margin: 0.25rem 0;
  color: var(--ink);
  position: relative;
}

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

.post-body img {
  max-width: 100%;
  height: auto;
  margin: var(--space-md) 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-2);
  opacity: 0;
  transition: opacity 0.4s var(--ease);
}

.post-body img.is-loaded { opacity: 1; }

.post-body figure { margin: var(--space-md) 0; }
.post-body figure img { margin: 0; }
.post-body figcaption {
  margin-top: var(--space-xs);
  font-size: var(--text-sm);
  color: var(--ink-muted);
  text-align: center;
  font-style: italic;
}

.post-body hr {
  border: 0;
  border-top: 1px dashed var(--line);
  margin: var(--space-lg) 0;
}

.post-body code {
  background: var(--bg-2);
  color: var(--accent-2);
  padding: 0.125em 0.375em;
  font-size: 0.9em;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
}

.post-body pre {
  background: var(--bg-2);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: var(--space-md);
  overflow-x: auto;
  margin: var(--space-md) 0;
  font-size: var(--text-sm);
  line-height: 1.55;
}

.post-body pre code {
  background: transparent;
  border: 0;
  padding: 0;
  color: var(--ink);
}

.post-body table {
  width: 100%;
  border-collapse: collapse;
  margin: var(--space-md) 0;
  font-size: var(--text-sm);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

.post-body th, .post-body td {
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--line);
  border-right: 1px solid var(--line);
  color: var(--ink);
  text-align: left;
}

.post-body th:last-child, .post-body td:last-child { border-right: 0; }
.post-body tr:last-child td { border-bottom: 0; }

.post-body th {
  background: var(--bg-3);
  color: var(--ink-strong);
  font-weight: 600;
  font-size: var(--text-xs);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.post-body tr:nth-child(even) td {
  background: color-mix(in srgb, var(--bg-2) 60%, transparent);
}

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

.construction-notice {
  text-align: center;
  margin: var(--space-md) 0;
  padding: var(--space-md);
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.construction-notice h2 {
  margin: 0 0 var(--space-sm);
  font-size: var(--text-lg);
}

.progress-bar {
  width: 100%;
  height: 8px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--accent-deep);
}

.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-direction: column;
  gap: var(--space-md);
  margin: 0;
  padding: 0;
}

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

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

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

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

.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;
}

/* ---------- Tag index ---------- */

.tags-search-wrap { margin-bottom: var(--space-lg); }

.tags-search {
  position: relative;
  max-width: 360px;
}

.tags-search input {
  width: 100%;
  padding-right: 2.25rem;
}

/* Suppress the browser's built-in clear button so it doesn't sit on top of
   our custom one. */
.tags-search input[type="search"]::-webkit-search-cancel-button,
.tags-search input[type="search"]::-webkit-search-decoration {
  -webkit-appearance: none;
  appearance: none;
}

.tags-search-clear {
  position: absolute;
  right: 0.25rem;
  top: 50%;
  width: 28px;
  height: 28px;
  padding: 0;
  background: transparent;
  border: 1px solid transparent;
  color: var(--ink-faint);
  font-size: var(--text-base);
  line-height: 1;
  border-radius: var(--radius-sm);
  min-height: 28px;
  transform: translateY(-50%);
  transition: background-color var(--duration-fast) var(--ease),
              color var(--duration-fast) var(--ease),
              border-color var(--duration-fast) var(--ease);
}

/* Keep the clear button anchored to the input vertically — the global
   button:active scale would shift it off-center. */
.tags-search-clear:active { transform: translateY(-50%); }

.tags-search-clear:hover {
  background: var(--bg-3);
  color: var(--ink-strong);
  border-color: var(--line);
}

.tags-content {
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
}

.tags-group[hidden] { display: none; }

.tags-letter {
  color: var(--accent);
  font-size: var(--text-lg);
  margin: 0 0 var(--space-xs);
  padding-bottom: var(--space-xs);
  border-bottom: 1px solid var(--line);
}

.tags-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0;
  margin: 0;
}

.tags-list > li::before { content: none; }
.tags-list > li[hidden] { display: none; }

.tag-index {
  font-size: var(--text-sm);
  padding: 0.3125rem 0.625rem;
  min-height: 32px;
}

.tag-count {
  margin-left: 0.5rem;
  padding-left: 0.5rem;
  border-left: 1px solid var(--line);
  color: var(--ink-faint);
  font-size: var(--text-xs);
}

.tag-index:hover .tag-count { color: var(--accent); }
