:root {
  --paper: #f7f3ec;
  --surface: #ede6da;
  --ink: #1d1514;
  --muted: #574340;
  --rule: #d6c8be;
  --accent: #8f222a;
  --accent-2: #b84438;
  --bar-top: #b83b42;
  --bar-mid: #8f222a;
  --bar-bot: #6b171d;
  --bar-ink: #f7f3ec;
  --hover-ink: #f7f3ec;
  --highlight: rgba(255, 255, 255, 0.72);
  --back-bg: #7a1c24;
  --back-ink: #f7f3ec;
  --back-accent: #e6b89c;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-palette]) {
    --paper: #232325;
    --surface: #2c2c2f;
    --ink: #f0ede8;
    --muted: #a8a49e;
    --rule: #403f44;
    --accent: #f08a4b;
    --accent-2: #ffaa70;
    --bar-top: #c86028;
    --bar-mid: #9c4418;
    --bar-bot: #732f0e;
    --bar-ink: #fff6ef;
    --hover-ink: #1a1512;
    --highlight: rgba(255, 255, 255, 0.08);
    --back-bg: #1c1c1e;
    --back-ink: #f0ede8;
    --back-accent: #ffd0b0;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: linear-gradient(180deg, var(--surface) 0%, var(--paper) 65%);
  color: var(--ink);
  font-family: "Open Sauce Two", "Segoe UI", Tahoma, sans-serif;
  font-size: 14.5px;
  line-height: 1.54;
  padding: 28px 18px 64px;
  -webkit-font-smoothing: antialiased;
}

.frame {
  max-width: 920px;
  margin: 0 auto;
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 6px;
  overflow: clip;
  box-shadow:
    0 1px 0 var(--highlight) inset,
    0 12px 32px rgba(0, 0, 0, 0.16),
    0 2px 6px rgba(0, 0, 0, 0.08);
}

/* Monumental 22° isometric title bar */
.titlebar {
  position: relative;
  background: linear-gradient(
    180deg,
    var(--bar-top) 0%,
    var(--bar-mid) 49%,
    var(--bar-bot) 51%,
    var(--bar-mid) 100%
  );
  color: var(--bar-ink);
  padding: 10px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.34);
  border-bottom: 1px solid var(--bar-bot);
  overflow: hidden;
}

.mosaic {
  position: absolute;
  right: 0;
  top: 0;
  height: 100%;
  width: min(74%, 500px);
  pointer-events: none;
  -webkit-mask-image: linear-gradient(90deg, transparent 0%, rgba(0, 0, 0, 0.55) 22%, #000 46%);
  mask-image: linear-gradient(90deg, transparent 0%, rgba(0, 0, 0, 0.55) 22%, #000 46%);
}

.tb-left {
  position: relative;
  z-index: 2;
  font-weight: 700;
  font-size: 13.5px;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.36);
  display: inline-flex;
  align-items: center;
  flex-wrap: nowrap;
  gap: 6px;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
}

.tb-left a {
  color: inherit;
  text-decoration: none;
  white-space: nowrap;
}

.tb-left a:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.tb-sep {
  opacity: 0.56;
  font-weight: 500;
  user-select: none;
  flex-shrink: 0;
}

.tb-cur {
  font-weight: 600;
  opacity: 0.9;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Two-pane interior: main on left, sidebar on right (stacks below main on mobile) */
.panes {
  display: grid;
  grid-template-columns: 1fr 228px;
}

.main {
  container-type: inline-size;
  padding: 24px 26px 26px;
  background: var(--paper);
}

.hero {
  display: grid;
  gap: 10px;
  margin-bottom: 20px;
}

.hero-mark {
  display: block;
  height: 50px;
  width: auto;
  justify-self: start;
  color: var(--ink);
}

@container (min-width: 26rem) {
  .hero {
    grid-template-columns: minmax(0, 1fr) auto;
    column-gap: 24px;
    align-items: start;
  }

  .hero-mark {
    grid-column: 2;
    grid-row: 1;
    height: 64px;
  }
}

.hero h1 {
  margin: 0;
  font-size: 28px;
  font-weight: 700;
  line-height: 1.04;
}

.hero .sub {
  margin: 4px 0 10px;
  font-size: 13px;
  font-weight: 700;
  color: var(--accent);
}

.hero p {
  margin: 0;
  max-width: 52ch;
  color: var(--ink);
}

.hero-actions {
  margin-top: 13px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.hero-cta {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6.5px 12px 6.5px 10px;
  border-radius: 4px;
  color: var(--ink);
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
  background: linear-gradient(180deg, var(--paper) 0%, color-mix(in srgb, var(--surface) 55%, var(--paper)) 100%);
  border: 1px solid var(--rule);
  box-shadow: inset 0 1px 0 var(--highlight), 0 1px 2px rgba(0, 0, 0, 0.06);
  transition: border-color 0.12s ease, background 0.12s ease, color 0.12s ease;
}

.hero-cta:hover,
.hero-cta:focus-visible {
  background: linear-gradient(180deg, var(--accent-2) 0%, var(--accent) 100%);
  color: var(--hover-ink);
  border-color: var(--bar-bot);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.28);
  outline: none;
}

.hero-cta:hover .ico,
.hero-cta:focus-visible .ico {
  color: var(--hover-ink);
}

.hero-cta:hover .chev,
.hero-cta:focus-visible .chev {
  color: var(--hover-ink);
  opacity: 0.95;
  transform: translateX(2px);
}

.section-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 10px;
}

.section-bar h2 {
  margin: 0;
  font-size: 12px;
  font-weight: 700;
  color: var(--accent);
  text-transform: uppercase;
  white-space: nowrap;
}

.section-bar::after {
  content: "";
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, var(--rule) 0%, transparent 100%);
}

.notes {
  list-style: none;
  margin: 0;
  padding: 0;
}

.notes li {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 14px;
  padding: 7px 9px;
  border-radius: 4px;
}

.notes li:nth-child(even) { background: var(--surface); }

.notes a {
  color: var(--ink);
  text-decoration: none;
  font-weight: 500;
}

.notes a:hover {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.notes time {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}

/* Right sidebar — Option 1: direct beveled buttons under hairline labels */
.sidebar {
  background: linear-gradient(180deg, var(--surface) 0%, var(--paper) 100%);
  border-left: 1px solid var(--rule);
  padding: 16px 14px 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.group {
  background: transparent;
  border: none;
  border-radius: 0;
  overflow: visible;
  box-shadow: none;
}

.group-head {
  display: flex;
  align-items: center;
  gap: 8px;
  background: none;
  border: none;
  padding: 0;
  margin: 0 0 7px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--muted);
  box-shadow: none;
}

.group-head::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--rule);
  opacity: 0.75;
}

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

.group a {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 6.5px 9px;
  border-radius: 4px;
  color: var(--ink);
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
  background: linear-gradient(180deg, var(--paper) 0%, color-mix(in srgb, var(--surface) 55%, var(--paper)) 100%);
  border: 1px solid var(--rule);
  box-shadow: inset 0 1px 0 var(--highlight), 0 1px 2px rgba(0, 0, 0, 0.06);
  transition: border-color 0.12s ease, background 0.12s ease, color 0.12s ease;
}

.link-l {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.ico {
  width: 15px;
  height: 15px;
  color: var(--accent);
  flex-shrink: 0;
}

.chev {
  width: 12px;
  height: 12px;
  color: var(--accent);
  opacity: 0.72;
  flex-shrink: 0;
  transition: transform 0.12s ease, opacity 0.12s ease;
}

.group a:hover,
.group a:focus-visible,
.group a[aria-current="page"] {
  background: linear-gradient(180deg, var(--accent-2) 0%, var(--accent) 100%);
  color: var(--hover-ink);
  border-color: var(--bar-bot);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.28);
  outline: none;
}

.group a:hover .ico,
.group a:focus-visible .ico,
.group a[aria-current="page"] .ico { color: var(--hover-ink); }

.group a:hover .chev,
.group a:focus-visible .chev {
  color: var(--hover-ink);
  opacity: 0.95;
  transform: translateX(2px);
}

.group a .tag { font-size: 11px; font-weight: 500; color: var(--muted); }

.group a:hover .tag,
.group a:focus-visible .tag,
.group a[aria-current="page"] .tag { color: var(--hover-ink); opacity: 0.9; }

.statusbar {
  border-top: 1px solid var(--rule);
  background: linear-gradient(180deg, var(--paper) 0%, var(--surface) 100%);
  padding: 8px 16px;
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px 16px;
  font-size: 12px;
  color: var(--muted);
  box-shadow: inset 0 1px 0 var(--highlight);
}

.statusbar a { color: var(--accent); text-decoration: none; font-weight: 700; }
.statusbar a:hover { text-decoration: underline; }

/* Single-column article & digital-garden page layouts (no sidebar) */
.page {
  padding: 26px 32px 32px;
  background: var(--paper);
}

.page-head {
  margin-bottom: 22px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--rule);
}

.page-head h1 {
  margin: 0;
  font-size: 26px;
  font-weight: 700;
  line-height: 1.12;
  letter-spacing: -0.015em;
}

.page-sub {
  margin: 6px 0 0;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--accent);
}

.page-meta {
  margin: 8px 0 0;
  font-size: 12px;
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
}

.prose {
  max-width: 66ch;
}

.page > article.prose {
  margin: 0 auto;
}

.page-panes {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 224px;
}

.page-panes .page > article.prose {
  max-width: none;
  margin: 0;
}

.rail {
  background: linear-gradient(180deg, var(--surface) 0%, var(--paper) 100%);
  border-left: 1px solid var(--rule);
  padding: 20px 16px 24px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 28px;
}

.rail-inner {
  position: sticky;
  top: 18px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.rail-colophon {
  display: flex;
  justify-content: center;
  padding-top: 8px;
}

.rail-mark {
  height: 44px;
  width: auto;
  color: var(--muted);
  opacity: 0.22;
}

.rail-toc ul,
.rail-links {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.rail-toc ul ul {
  margin-top: 2px;
  padding-left: 11px;
  border-left: 1px solid var(--rule);
}

.rail-toc a,
.rail-links a {
  display: block;
  padding: 4px 7px;
  border-radius: 4px;
  font-size: 12.5px;
  font-weight: 500;
  line-height: 1.35;
  color: var(--muted);
  text-decoration: none;
  transition: background 0.12s ease, color 0.12s ease;
}

.rail-toc a:hover,
.rail-toc a:focus-visible,
.rail-links a:hover,
.rail-links a:focus-visible {
  background: color-mix(in srgb, var(--accent) 11%, transparent);
  color: var(--accent);
  outline: none;
}

.rail-tags {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.rail-tags a {
  display: inline-block;
  padding: 2.5px 8px;
  border-radius: 4px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--ink);
  text-decoration: none;
  background: linear-gradient(180deg, var(--paper) 0%, color-mix(in srgb, var(--surface) 55%, var(--paper)) 100%);
  border: 1px solid var(--rule);
  box-shadow: inset 0 1px 0 var(--highlight);
}

.rail-tags a:hover,
.rail-tags a:focus-visible {
  background: linear-gradient(180deg, var(--accent-2) 0%, var(--accent) 100%);
  color: var(--hover-ink);
  border-color: var(--bar-bot);
  outline: none;
}

.prose p {
  margin: 0 0 14px;
}

.prose h2 {
  margin: 24px 0 10px;
  font-size: 16px;
  font-weight: 700;
  color: var(--accent);
  display: flex;
  align-items: center;
  gap: 10px;
}

.prose h2::after {
  content: "";
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, var(--rule) 0%, transparent 100%);
}

.prose :where(ol, ul):not([class]) {
  margin: 0 0 16px;
  padding-inline-start: 22px;
}

.prose :where(ol, ul):not([class]) > li + li {
  margin-block-start: 6px;
}

.prose :where(ol, ul):not([class]) > li > :where(ol, ul):not([class]) {
  margin-block: 4px 0;
}

.prose :where(ol, ul):not([class]) > li > :where(ol, ul):not([class]) > li + li {
  margin-block-start: 4px;
}

.prose a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
  font-weight: 500;
}

.prose a:hover {
  color: var(--accent-2);
}

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

.prose sup:has(.footnote-ref) {
  line-height: 0;
  margin-inline-start: .12em;
}

.prose .footnotes {
  margin-block-start: 28px;
  font-size: .88em;
  color: var(--muted);
}

.prose .footnotes hr {
  border: 0;
  border-block-start: 1px solid var(--rule);
  margin: 0 0 12px;
}

.prose .footnotes li > :last-child {
  margin-block-end: 0;
}

.prose .footnotes li:target,
.prose sup:has(.footnote-ref):target {
  background: var(--surface);
}

.prose code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.88em;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 3px;
  padding: 1px 5px;
}

.prose code:not(pre code) {
  overflow-wrap: anywhere;
}

.quote {
  margin: 0 0 20px;
  padding: 12px 16px;
  background: linear-gradient(180deg, var(--surface) 0%, var(--paper) 100%);
  border: 1px solid var(--rule);
  border-left: 3px solid var(--accent);
  border-radius: 4px;
  box-shadow: inset 0 1px 0 var(--highlight);
}

.quote p {
  margin: 0 0 6px;
  font-style: italic;
}

.quote cite {
  font-style: normal;
  font-size: 12px;
  color: var(--muted);
}

/* Hardware / spec cards (used on /now) */
.rig-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 14px 0 20px;
}

.rig {
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 5px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.rig-head {
  background: linear-gradient(180deg, var(--paper) 0%, var(--surface) 100%);
  border-bottom: 1px solid var(--rule);
  padding: 6px 11px;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  box-shadow: inset 0 1px 0 var(--highlight);
}

.rig-head strong {
  font-size: 13px;
  color: var(--ink);
}

.rig-head span {
  font-size: 11px;
  color: var(--accent);
  font-weight: 600;
}

.rig p {
  margin: 0;
  padding: 9px 11px 11px;
  font-size: 13px;
  line-height: 1.48;
}

/* Two-column compact playlist grid */
.playlist {
  list-style: none;
  margin: 0 0 18px;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 5px 16px;
}

.playlist li {
  margin: 0;
  padding: 5px 8px;
  border-radius: 4px;
  font-size: 13px;
  background: var(--surface);
  border: 1px solid var(--rule);
}

.playlist .artist {
  font-weight: 700;
  color: var(--ink);
}

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

@media (max-width: 680px) {
  .panes { grid-template-columns: 1fr; }
  .sidebar { border-left: none; border-top: 1px solid var(--rule); }
  .notes li { flex-direction: column; gap: 2px; }
  .page { padding: 20px 18px 24px; }
  .rig-grid,
  .playlist { grid-template-columns: 1fr; }
}

@media (max-width: 520px) {
  .mosaic {
    width: calc(100% - 92px);
    -webkit-mask-image: linear-gradient(90deg, transparent 0%, rgba(0, 0, 0, 0.34) 34%, #000 70%);
    mask-image: linear-gradient(90deg, transparent 0%, rgba(0, 0, 0, 0.34) 34%, #000 70%);
  }
  .titlebar.has-crumb .mosaic {
    width: 68%;
    -webkit-mask-image: linear-gradient(90deg, transparent 0%, rgba(0, 0, 0, 0.24) 40%, #000 78%);
    mask-image: linear-gradient(90deg, transparent 0%, rgba(0, 0, 0, 0.24) 40%, #000 78%);
  }
}

/* Obsidian / GitHub-style callouts */
.callout {
  margin: 0 0 16px;
  padding: 11px 14px;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-left: 3px solid var(--accent);
  border-radius: 4px;
}
.callout-title {
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--accent);
  margin-bottom: 4px;
}
.callout p:last-child { margin-bottom: 0; }

/* Backlinks footer on notes/articles */
.backlinks {
  margin-top: 28px;
  padding-top: 16px;
  border-top: 1px solid var(--rule);
}
.backlinks h3 {
  margin: 0 0 8px;
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--muted);
}
.backlinks ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
}
.backlinks a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
  font-size: 13px;
}
.backlinks a:hover { text-decoration: underline; }

/* Bookmarks directory */
.bm-head-no-intro {
  border-bottom: 0;
  padding-bottom: 0;
}

.bm-directory .bm-category {
  margin: 32px 0 10px;
  font-size: 18px;
}

.bm-directory .bm-category:first-of-type {
  margin-top: 22px;
}

.bm-intro {
  font-size: 13px;
  color: var(--muted);
  margin: -4px 0 12px;
}
.bm-subgroup + .bm-subgroup {
  margin-top: 18px;
}

.bm-subhead {
  margin: 0 0 4px;
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
}
.prose ul.bm-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.bm-subgroup > ul.bm-list {
  border-inline-start: 1px solid var(--rule);
  padding-inline-start: 12px;
}
.bm-list > li {
  margin-inline: -6px;
  padding: 5px 6px;
  border-radius: 3px;
  overflow-wrap: anywhere;
}
.bm-list > li:hover,
.bm-list > li:focus-within {
  background: var(--surface);
}

.bm-title {
  font-weight: 600;
}
.bm-collection-title {
  display: block;
}
.bm-note-separator {
  margin-inline: .3em;
}
.bm-list a {
  text-underline-offset: .1em;
  text-decoration-thickness: 1px;
}
.bm-title a,
a.bm-title {
  color: var(--ink);
  text-decoration: underline;
  text-decoration-color: var(--muted);
}
.bm-title a:hover,
.bm-title a:focus-visible,
a.bm-title:hover,
a.bm-title:focus-visible {
  color: var(--accent);
  text-decoration-color: currentColor;
}
.bm-collection-links,
.bm-note {
  font-size: 12.5px;
  color: var(--muted);
  overflow-wrap: anywhere;
}
.bm-collection-links a,
.bm-note a {
  font-weight: 600;
  color: var(--accent);
  text-decoration: underline;
}
.bm-note a:hover {
  color: var(--accent-2);
}

@media (max-width: 760px) {
  .page-panes {
    grid-template-columns: 1fr;
  }
  .rail {
    border-left: none;
    border-top: 1px solid var(--rule);
    padding: 16px 18px 20px;
  }
  .rail-inner {
    position: static;
  }
  .rail-colophon {
    display: none;
  }
  .rail--toc-first {
    order: -1;
    border-top: none;
    border-bottom: 1px solid var(--rule);
  }
  .rail--toc-first .rail-toc ul {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 5px;
  }
  .rail--toc-first .rail-toc a {
    padding: 4px 8px;
    font-size: 12px;
    font-weight: 600;
    color: var(--ink);
    background: linear-gradient(180deg, var(--paper) 0%, color-mix(in srgb, var(--surface) 55%, var(--paper)) 100%);
    border: 1px solid var(--rule);
    box-shadow: inset 0 1px 0 var(--highlight);
  }
  .rail--toc-first .rail-toc a:hover,
  .rail--toc-first .rail-toc a:focus-visible {
    background: linear-gradient(180deg, var(--accent-2) 0%, var(--accent) 100%);
    color: var(--hover-ink);
    border-color: var(--bar-bot);
  }
}
