/* md.paste — Rosé Pine + Cyan & Teal theme inspired by palash.pro */

:root,
[data-theme="dark"] {
  color-scheme: dark;
  --bg: #191724;
  --surface: #1f1d2e;
  --surface-lift: #26233a;
  --line: #312e45;
  --line-soft: #26233a;
  --text: #e0def4;
  --muted: #908caa;
  --faint: #6e6a86;
  --accent: #c4a7e7;
  --cyan: #56e2ec;
  --teal: #1b9bb8;
  --pine: #31748f;
  --rose: #ebbcba;
  --gold: #f6c177;
  --gold-bright: #fff3d6;
  --wire: #56e2ecad;
  --ok: #5ee3d2;
  --fault: #eb6f92;
  --pill-bg: #14121f;
  --pill-bg-hover: #212035;
  --pill-border: #e0def429;
  --pill-border-hover: #56e2ecb3;
  --sans: "Geist", system-ui, -apple-system, sans-serif;
  --mono: "Geist Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  --nav-h: 64px;
  --radius: 8px;
}

[data-theme="light"] {
  color-scheme: light;
  --bg: #faf4ed;
  --surface: #fffaf3;
  --surface-lift: #f2e9e1;
  --line: #dfd6cd;
  --line-soft: #eae2d9;
  --text: #443f63;
  --muted: #575279;
  --faint: #656080;
  --accent: #7f65a6;
  --cyan: #0b7a94;
  --teal: #126176;
  --pine: #286983;
  --rose: #d7827e;
  --gold: #ea9d34;
  --gold-bright: #b86b09;
  --wire: #0b7a94a6;
  --ok: #0d7a6e;
  --fault: #b4637a;
  --pill-bg: #fffaf3;
  --pill-bg-hover: #edf5f7;
  --pill-border: #443f633d;
  --pill-border-hover: #0b7a94ad;
}

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

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 1rem;
  line-height: 1.6;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  overflow-x: clip;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a {
  color: inherit;
}

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

:focus {
  outline: none;
}

:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 2px;
}

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

.mono {
  font-family: var(--mono);
}

.muted {
  color: var(--muted);
}

.faint {
  color: var(--faint);
}

.skip {
  position: fixed;
  top: 8px;
  left: 16px;
  z-index: 90;
  padding: 8px 12px;
  background: var(--bg);
  border: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 0.8125rem;
  text-decoration: none;
  transform: translateY(-200%);
}

.skip:focus {
  transform: none;
}

/* ── Layout ──────────────────────────────────────────────────────────────── */

.wrap {
  width: min(1240px, 100%);
  margin-inline: auto;
  padding-inline: clamp(14px, 3vw, 32px);
}

.page-shell {
  padding-top: var(--nav-h);
  flex: 1;
  display: flex;
  flex-direction: column;
}

.page {
  padding-block: 24px 48px;
}

/* ── Top Navigation ──────────────────────────────────────────────────────── */

.nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--nav-h);
  z-index: 50;
  background: color-mix(in srgb, var(--bg) 90%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line-soft);
}

.nav-inner {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.nav-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.wordmark {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  font-weight: 600;
  letter-spacing: -0.02em;
  font-size: 1.05rem;
}

.wordmark-emblem {
  width: 28px;
  height: 28px;
  flex-shrink: 0;
}

.wordmark-emblem svg {
  width: 100%;
  height: 100%;
  display: block;
}

.wordmark-dot {
  color: var(--cyan);
}

.nav-pill {
  font-size: 0.72rem;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--pill-bg);
  border: 1px solid var(--pill-border);
  color: var(--cyan);
  white-space: nowrap;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 6px;
}

.nav-auth-slot {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.nav-link {
  text-decoration: none;
  font-size: 0.875rem;
  color: var(--muted);
  padding: 6px 10px;
  border-radius: 6px;
  transition: color 0.15s var(--ease), background 0.15s var(--ease);
  white-space: nowrap;
}

.nav-link:hover,
.nav-link.active {
  color: var(--text);
  background: var(--surface);
}

.nav-link.active {
  color: var(--cyan);
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  transition: border-color 0.15s var(--ease), color 0.15s var(--ease), background 0.15s var(--ease);
}

.icon-btn:hover {
  border-color: var(--cyan);
  color: var(--cyan);
  background: var(--surface-lift);
}

.icon-btn svg {
  width: 16px;
  height: 16px;
}

[data-theme="dark"] .icon-sun {
  display: block;
}
[data-theme="dark"] .icon-moon {
  display: none;
}
[data-theme="light"] .icon-sun {
  display: none;
}
[data-theme="light"] .icon-moon {
  display: block;
}

/* ── Buttons & Inputs ────────────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 8px 14px;
  border-radius: 7px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  font-size: 0.875rem;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  transition: border-color 0.15s var(--ease), background 0.15s var(--ease), transform 0.15s var(--ease), color 0.15s var(--ease);
  white-space: nowrap;
}

.btn:hover:not(:disabled) {
  border-color: var(--cyan);
  background: var(--surface-lift);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: linear-gradient(135deg, color-mix(in srgb, var(--cyan) 22%, var(--surface)), color-mix(in srgb, var(--teal) 26%, var(--surface)));
  border-color: color-mix(in srgb, var(--cyan) 65%, var(--line));
  color: var(--text);
}

.btn-primary:hover:not(:disabled) {
  border-color: var(--cyan);
  background: linear-gradient(135deg, color-mix(in srgb, var(--cyan) 34%, var(--surface)), color-mix(in srgb, var(--teal) 38%, var(--surface)));
}

.btn-danger {
  border-color: color-mix(in srgb, var(--fault) 45%, var(--line));
  color: var(--fault);
}

.btn-danger:hover:not(:disabled) {
  border-color: var(--fault);
  background: color-mix(in srgb, var(--fault) 12%, var(--surface));
}

.btn-sm {
  padding: 5px 10px;
  font-size: 0.8rem;
}

.chip-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--pill-border);
  background: var(--pill-bg);
  color: var(--muted);
  font-size: 0.78rem;
  cursor: pointer;
  text-decoration: none;
  transition: border-color 0.15s var(--ease), color 0.15s var(--ease), background 0.15s var(--ease);
}

.chip-btn:hover,
.chip-btn.active {
  border-color: var(--pill-border-hover);
  background: var(--pill-bg-hover);
  color: var(--cyan);
}

.text-btn {
  background: none;
  border: none;
  padding: 0;
  color: inherit;
  cursor: pointer;
}

.text-btn:hover {
  color: var(--cyan);
}

.field-input,
.field-select {
  background: var(--pill-bg);
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 7px 11px;
  font-size: 0.875rem;
  color: var(--text);
  transition: border-color 0.15s var(--ease), box-shadow 0.15s var(--ease);
}

.field-input:focus,
.field-select:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--cyan) 18%, transparent);
}

.field-input::placeholder {
  color: var(--faint);
}

kbd {
  display: inline-block;
  padding: 1px 6px;
  font-family: var(--mono);
  font-size: 0.75rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--text);
}

/* ── Editor Workspace ────────────────────────────────────────────────────── */

.editor-shell {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-block: 18px 28px;
  flex: 1;
}

.editor-topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.editor-meta-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 240px;
}

.editor-title-input {
  min-width: 200px;
  flex: 1;
  max-width: 340px;
}

.segmented {
  display: inline-flex;
  padding: 3px;
  background: var(--pill-bg);
  border: 1px solid var(--line);
  border-radius: 7px;
  gap: 2px;
}

.segmented button {
  border: none;
  background: transparent;
  color: var(--muted);
  padding: 5px 10px;
  border-radius: 5px;
  font-size: 0.8rem;
  font-family: var(--mono);
  cursor: pointer;
  transition: background 0.15s var(--ease), color 0.15s var(--ease);
}

.segmented button.active {
  background: var(--surface-lift);
  color: var(--cyan);
}

.editor-dest-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.dest-fields {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  flex: 1;
}

.dest-prefix {
  font-family: var(--mono);
  font-size: 0.82rem;
  color: var(--teal);
}

.editor-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-bottom: none;
  border-radius: var(--radius) var(--radius) 0 0;
}

.toolbar-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
}

.tool-btn {
  padding: 4px 8px;
  border-radius: 5px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.78rem;
  cursor: pointer;
  transition: color 0.12s var(--ease), background 0.12s var(--ease), border-color 0.12s var(--ease);
}

.tool-btn:hover {
  color: var(--cyan);
  background: var(--surface-lift);
  border-color: var(--line);
}

.editor-stage-wrap {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 540px;
}

.editor-panes {
  display: grid;
  grid-template-columns: 1fr 1fr;
  flex: 1;
  min-height: 520px;
  border: 1px solid var(--line);
  border-radius: 0 0 var(--radius) var(--radius);
  overflow: hidden;
  background: var(--surface);
}

.editor-panes.mode-edit {
  grid-template-columns: 1fr;
}

.editor-panes.mode-edit .preview-pane {
  display: none;
}

.editor-panes.mode-preview {
  grid-template-columns: 1fr;
}

.editor-panes.mode-preview .write-pane {
  display: none;
}

.write-pane {
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--line);
  background: var(--pill-bg);
}

.editor-panes.mode-edit .write-pane {
  border-right: none;
}

.editor-textarea {
  width: 100%;
  height: 100%;
  min-height: 520px;
  flex: 1;
  resize: none;
  border: none;
  background: transparent;
  padding: 18px 20px;
  font-family: var(--mono);
  font-size: 0.9rem;
  line-height: 1.65;
  color: var(--text);
  tab-size: 2;
}

.editor-textarea:focus {
  outline: none;
}

.preview-pane {
  padding: 20px 26px;
  overflow-y: auto;
  max-height: 75vh;
  background: var(--surface);
}

/* ── Dropzone Overlay ────────────────────────────────────────────────────── */

.drop-banner {
  border: 1px dashed var(--teal);
  background: color-mix(in srgb, var(--cyan) 6%, var(--surface));
  border-radius: var(--radius);
  padding: 10px 14px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 0.85rem;
}

.drop-banner.drag-over {
  border-color: var(--cyan);
  background: color-mix(in srgb, var(--cyan) 14%, var(--surface));
}

/* ── Reader View & TOC ───────────────────────────────────────────────────── */

.reader-header {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 24px;
}

.breadcrumbs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  font-family: var(--mono);
  font-size: 0.82rem;
  color: var(--muted);
}

.breadcrumbs a {
  text-decoration: none;
  color: var(--cyan);
}

.breadcrumbs a:hover {
  text-decoration: underline;
}

.reader-title-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.reader-title {
  margin: 0;
  font-size: clamp(1.5rem, 2.2vw + 0.8rem, 2.25rem);
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1.15;
}

.reader-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--muted);
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-family: var(--mono);
  font-size: 0.72rem;
  border: 1px solid var(--line);
  background: var(--pill-bg);
}

.badge-public {
  border-color: color-mix(in srgb, var(--ok) 45%, var(--line));
  color: var(--ok);
}

.badge-unlisted {
  border-color: color-mix(in srgb, var(--gold) 45%, var(--line));
  color: var(--gold);
}

.badge-private {
  border-color: color-mix(in srgb, var(--fault) 45%, var(--line));
  color: var(--fault);
}

.badge-cyan {
  border-color: color-mix(in srgb, var(--cyan) 45%, var(--line));
  color: var(--cyan);
}

.reader-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.reader-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 240px;
  gap: 32px;
  align-items: start;
}

.reader-grid.no-toc {
  grid-template-columns: minmax(0, 1fr);
}

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

.toc-sidebar {
  position: sticky;
  top: calc(var(--nav-h) + 20px);
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  max-height: calc(100vh - var(--nav-h) - 48px);
  overflow-y: auto;
}

.toc-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  font-family: var(--mono);
  font-size: 0.76rem;
  color: var(--cyan);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.toc-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.toc-item a {
  display: block;
  padding: 3px 6px;
  border-left: 2px solid transparent;
  font-size: 0.82rem;
  color: var(--muted);
  text-decoration: none;
  border-radius: 0 4px 4px 0;
  transition: color 0.12s var(--ease), border-color 0.12s var(--ease), background 0.12s var(--ease);
}

.toc-item a:hover,
.toc-item a.active {
  color: var(--cyan);
  border-left-color: var(--cyan);
  background: color-mix(in srgb, var(--cyan) 7%, transparent);
}

.toc-item.level-2 {
  padding-left: 10px;
}

.toc-item.level-3 {
  padding-left: 20px;
  font-size: 0.78rem;
}

/* ── Sequential Navigation Footer ────────────────────────────────────────── */

.seq-nav {
  margin-top: 36px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 12px;
  align-items: stretch;
}

.seq-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  text-decoration: none;
  transition: border-color 0.15s var(--ease), background 0.15s var(--ease), transform 0.15s var(--ease);
}

.seq-card:hover {
  border-color: var(--cyan);
  background: var(--surface-lift);
  transform: translateY(-1px);
}

.seq-card.next {
  text-align: right;
}

.seq-card.disabled {
  opacity: 0.38;
  pointer-events: none;
}

.seq-label {
  font-family: var(--mono);
  font-size: 0.74rem;
  color: var(--teal);
}

.seq-name {
  font-weight: 500;
  font-size: 0.92rem;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.seq-index-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--pill-bg);
  text-decoration: none;
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--muted);
}

.seq-index-link:hover {
  border-color: var(--cyan);
  color: var(--cyan);
}

/* ── Directory Index View ────────────────────────────────────────────────── */

.dir-hero {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 20px;
}

.dir-list {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
}

.dir-row {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1.6fr) auto auto;
  gap: 12px;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line-soft);
  text-decoration: none;
  transition: background 0.14s var(--ease);
}

.dir-row:last-child {
  border-bottom: none;
}

.dir-row:hover {
  background: var(--surface-lift);
}

.dir-row-name {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--mono);
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text);
  min-width: 0;
}

.dir-row-name span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dir-row:hover .dir-row-name {
  color: var(--cyan);
}

.dir-row-title {
  color: var(--muted);
  font-size: 0.875rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dir-icon {
  width: 17px;
  height: 17px;
  flex-shrink: 0;
  color: var(--cyan);
}

.dir-icon.file {
  color: var(--teal);
}

/* ── Auth & Settings Cards ───────────────────────────────────────────────── */

.auth-wrap {
  max-width: 460px;
  margin-inline: auto;
  padding-block: 42px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
}

.stack-sm > * + * {
  margin-top: 12px;
}

.stack-md > * + * {
  margin-top: 18px;
}

.form-label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.85rem;
  color: var(--muted);
}

.token-box {
  padding: 12px 14px;
  border-radius: 7px;
  border: 1px solid color-mix(in srgb, var(--cyan) 45%, var(--line));
  background: var(--pill-bg);
  font-family: var(--mono);
  font-size: 0.82rem;
  word-break: break-all;
  color: var(--cyan);
}

.callout {
  padding: 12px 16px;
  border-radius: var(--radius);
  border: 1px solid color-mix(in srgb, var(--gold) 50%, var(--line));
  background: color-mix(in srgb, var(--gold) 8%, var(--surface));
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 18px;
  font-size: 0.875rem;
}

/* ── Markdown Prose & Syntax Highlighting (Rosé Pine) ────────────────────── */

.markdown-body {
  color: var(--text);
  font-size: 1rem;
  line-height: 1.72;
  max-width: 78ch;
  word-wrap: break-word;
}

.markdown-body > *:first-child {
  margin-top: 0;
}

.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4 {
  margin-top: 1.7em;
  margin-bottom: 0.6em;
  font-weight: 600;
  letter-spacing: -0.025em;
  line-height: 1.25;
  scroll-margin-top: calc(var(--nav-h) + 20px);
}

.markdown-body h1 {
  font-size: 1.85rem;
  padding-bottom: 0.35em;
  border-bottom: 1px solid var(--line);
}

.markdown-body h2 {
  font-size: 1.42rem;
  padding-bottom: 0.25em;
  border-bottom: 1px solid var(--line-soft);
}

.markdown-body h3 {
  font-size: 1.15rem;
  color: var(--rose);
}

.markdown-body p {
  margin-block: 0.9em;
}

.markdown-body a {
  color: var(--cyan);
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, var(--cyan) 45%, transparent);
  text-underline-offset: 3px;
}

.markdown-body a:hover {
  text-decoration-color: var(--cyan);
}

.markdown-body ul,
.markdown-body ol {
  padding-left: 1.5em;
  margin-block: 0.9em;
}

.markdown-body li + li {
  margin-top: 0.35em;
}

.markdown-body input[type="checkbox"] {
  accent-color: var(--cyan);
  margin-right: 6px;
}

.markdown-body blockquote {
  margin: 1.1em 0;
  padding: 0.5em 1em;
  border-left: 3px solid var(--teal);
  background: color-mix(in srgb, var(--teal) 7%, var(--surface));
  color: var(--muted);
  border-radius: 0 6px 6px 0;
}

.markdown-body hr {
  border: none;
  border-top: 1px solid var(--line);
  margin: 1.8em 0;
}

.markdown-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.2em 0;
  font-size: 0.92rem;
  display: block;
  overflow-x: auto;
}

.markdown-body th,
.markdown-body td {
  border: 1px solid var(--line);
  padding: 8px 12px;
  text-align: left;
}

.markdown-body th {
  background: var(--surface-lift);
  color: var(--cyan);
  font-weight: 600;
}

.markdown-body tr:nth-child(even) td {
  background: color-mix(in srgb, var(--surface-lift) 35%, transparent);
}

.markdown-body code {
  font-family: var(--mono);
  font-size: 0.86em;
  background: var(--pill-bg);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0.12em 0.4em;
  color: var(--rose);
}

.code-block-wrap {
  margin: 1.2em 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--pill-bg);
}

.code-block-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 12px;
  background: var(--surface-lift);
  border-bottom: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 0.74rem;
  color: var(--muted);
}

.code-block-wrap pre {
  margin: 0;
  padding: 14px 16px;
  overflow-x: auto;
  font-family: var(--mono);
  font-size: 0.87rem;
  line-height: 1.6;
}

.code-block-wrap pre code {
  background: none;
  border: none;
  padding: 0;
  color: var(--text);
  font-size: inherit;
}

/* Highlight.js Rosé Pine token mapping */
.hljs-keyword,
.hljs-selector-tag,
.hljs-built_in,
.hljs-name {
  color: var(--pine);
}
[data-theme="dark"] .hljs-keyword,
[data-theme="dark"] .hljs-selector-tag {
  color: var(--cyan);
}
.hljs-string,
.hljs-attr,
.hljs-symbol,
.hljs-bullet {
  color: var(--gold);
}
.hljs-title,
.hljs-section,
.hljs-function .hljs-title {
  color: var(--rose);
}
.hljs-type,
.hljs-class .hljs-title,
.hljs-variable,
.hljs-template-variable {
  color: var(--accent);
}
.hljs-number,
.hljs-literal {
  color: var(--fault);
}
.hljs-comment,
.hljs-quote {
  color: var(--faint);
  font-style: italic;
}

.mermaid-wrap {
  margin: 1.2em 0;
  padding: 16px;
  background: var(--pill-bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow-x: auto;
  display: flex;
  justify-content: center;
}

.katex-display {
  overflow-x: auto;
  overflow-y: hidden;
  padding-block: 6px;
}

/* ── Explore Grid ────────────────────────────────────────────────────────── */

.explore-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
}

.explore-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  text-decoration: none;
  transition: border-color 0.15s var(--ease), transform 0.15s var(--ease), background 0.15s var(--ease);
}

.explore-card:hover {
  border-color: var(--cyan);
  background: var(--surface-lift);
  transform: translateY(-2px);
}

/* ── Shortcuts Dialog & Toasts ───────────────────────────────────────────── */

dialog#shortcuts {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px 22px;
  max-width: 480px;
  width: calc(100% - 32px);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
}

dialog#shortcuts::backdrop {
  background: rgba(12, 10, 18, 0.72);
  backdrop-filter: blur(4px);
}

.shortcuts-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  color: var(--cyan);
}

.shortcuts-grid {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px 18px;
  margin: 0;
  align-items: center;
  font-size: 0.875rem;
}

.shortcuts-grid dd {
  margin: 0;
  color: var(--muted);
}

.toast-region {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 80;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  padding: 10px 14px;
  border-radius: 7px;
  background: var(--surface-lift);
  border: 1px solid var(--cyan);
  color: var(--text);
  font-size: 0.85rem;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.32);
}

.toast.error {
  border-color: var(--fault);
  color: var(--fault);
}

/* ── Footer ──────────────────────────────────────────────────────────────── */

.footer {
  border-top: 1px solid var(--line-soft);
  padding-block: 16px;
  margin-top: auto;
}

.footer-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 0.82rem;
}

.brand-footer {
  color: var(--cyan);
}

/* ── View Transitions & Responsive ───────────────────────────────────────── */

html.is-theme-switching::view-transition-old(root),
html.is-theme-switching::view-transition-new(root) {
  animation: none;
  mix-blend-mode: normal;
}

@media (max-width: 960px) {
  .reader-grid {
    grid-template-columns: 1fr;
  }
  .toc-sidebar {
    position: static;
    max-height: none;
    order: -1;
  }
  .editor-panes {
    grid-template-columns: 1fr;
  }
  .write-pane {
    border-right: none;
    border-bottom: 1px solid var(--line);
  }
  .editor-textarea {
    min-height: 300px;
  }
}

@media (max-width: 720px) {
  .nav-pill {
    display: none;
  }
  .dir-row {
    grid-template-columns: minmax(0, 1fr) auto;
  }
  .dir-row-title,
  .dir-row-date {
    display: none;
  }
  .seq-nav {
    grid-template-columns: 1fr;
  }
}
