:root {
  --paper: #f4eee4;
  --paper-deep: #ebe3d4;
  --ink: #1c1612;
  --muted: #5c5348;
  --subtle: #8a8073;
  --seal: #8b2e2e;
  --seal-deep: #6f2424;
  --rule: #c4b8a8;
  --white: #fffdf8;
  --shadow: 0 1px 0 color-mix(in oklab, var(--ink) 6%, transparent),
    0 18px 40px -24px color-mix(in oklab, var(--ink) 35%, transparent);
  --sans: "Source Sans 3", system-ui, sans-serif;
  --serif: "Libre Baskerville", Georgia, serif;
  --mono: "IBM Plex Mono", ui-monospace, Menlo, monospace;
  --pad: clamp(1rem, 4vw, 1.5rem);
  --max: 72rem;
  --tap: 2.75rem;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --nav-h: 4.5rem;
  --loc-h: 2.5rem;
}

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

html {
  background: var(--paper);
  color: var(--ink);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
}

body {
  margin: 0;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  font-family: var(--sans);
  line-height: 1.5;
  background:
    radial-gradient(900px 320px at 50% -60px, color-mix(in oklab, var(--seal) 10%, transparent), transparent 70%),
    var(--paper);
  color: var(--ink);
  overflow-x: hidden;
  padding-left: var(--safe-left);
  padding-right: var(--safe-right);
}

img, svg, video { max-width: 100%; height: auto; display: block; }
button, a, [role="button"] { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
button { font: inherit; color: inherit; }
a { color: inherit; }

.skip {
  position: absolute;
  left: -999px;
  top: 0;
}
.skip:focus {
  left: calc(var(--pad) + var(--safe-left));
  top: calc(0.75rem + var(--safe-top));
  z-index: 100;
  background: var(--seal);
  color: var(--paper);
  padding: 0.5rem 0.75rem;
  border-radius: 4px;
}

/* —— Header —— */
.top {
  position: sticky;
  top: 0;
  z-index: 60;
  border-bottom: 1px solid var(--rule);
  background: color-mix(in oklab, var(--paper) 92%, transparent);
  backdrop-filter: blur(10px);
  padding-top: var(--safe-top);
}

.wrap {
  width: min(100%, var(--max));
  margin: 0 auto;
  padding-left: var(--pad);
  padding-right: var(--pad);
}

.bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 3.5rem;
  padding-top: 0.5rem;
  padding-bottom: 0.5rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  min-width: 0;
  flex: 1;
  text-decoration: none;
  color: inherit;
}

.seal {
  width: 2.35rem;
  height: 2.35rem;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: var(--seal);
  color: var(--paper);
  box-shadow: inset 0 0 0 2px color-mix(in oklab, white 18%, transparent);
  flex-shrink: 0;
}

.brand > span:last-child {
  min-width: 0;
  overflow: hidden;
}

.kicker {
  display: block;
  font-family: var(--serif);
  font-size: 0.65rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--seal);
  line-height: 1.2;
}

.title {
  display: block;
  font-family: var(--serif);
  font-size: clamp(0.92rem, 3.6vw, 1.05rem);
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.desk {
  display: none;
  gap: 0.1rem;
  margin-left: 0.25rem;
}

.desk a,
.drawer-nav a {
  min-height: var(--tap);
  min-width: var(--tap);
  padding: 0 0.7rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  text-decoration: none;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 500;
}

.desk a.active,
.drawer-nav a.active {
  background: var(--seal);
  color: var(--paper);
}

.desk a:hover,
.drawer-nav a:hover { color: var(--ink); background: var(--paper-deep); }

.dl-btn {
  min-height: var(--tap);
  height: var(--tap);
  padding: 0 0.7rem;
  border: 0;
  border-radius: 6px;
  background: var(--seal);
  color: var(--paper);
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 600;
  flex-shrink: 0;
}

.dl-label { display: none; }
@media (min-width: 480px) {
  .dl-label { display: inline; }
}

.menu {
  min-height: var(--tap);
  min-width: var(--tap);
  height: var(--tap);
  width: var(--tap);
  padding: 0;
  border: 1px solid var(--rule);
  background: var(--paper);
  color: var(--ink);
  border-radius: 6px;
  display: grid;
  place-items: center;
  position: relative;
  z-index: 70;
  flex-shrink: 0;
}

@media (min-width: 880px) {
  .desk { display: flex; }
  .dl-btn, .menu { display: none !important; }
  .drawer { display: none !important; }
}

/* —— Drawer —— */
.drawer {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: none;
}
.drawer.open { display: block; }
.drawer-bg {
  position: absolute;
  inset: 0;
  border: 0;
  width: 100%;
  height: 100%;
  background: color-mix(in oklab, var(--ink) 48%, transparent);
}
.drawer-panel {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(20rem, calc(100vw - 2.5rem));
  max-width: 100%;
  background: var(--paper);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  padding-top: var(--safe-top);
  padding-bottom: var(--safe-bottom);
}
.drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--rule);
}
.drawer-head p {
  margin: 0;
  font-family: var(--serif);
  font-size: 0.85rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--seal);
}
.drawer-nav {
  flex: 1;
  overflow: auto;
  padding: 0.75rem;
  display: grid;
  gap: 0.3rem;
  align-content: start;
}
.drawer-nav a {
  height: 3rem;
  justify-content: flex-start;
  width: 100%;
}

/* —— Page shell —— */
main { flex: 1; min-width: 0; }

.page {
  width: min(100%, var(--max));
  margin: 0 auto;
  padding: 1.25rem var(--pad) calc(3rem + var(--safe-bottom));
  min-width: 0;
}
.page.narrow { max-width: 48rem; }

.eyebrow {
  font-size: 0.68rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--seal);
  margin: 0 0 0.65rem;
  font-weight: 600;
}

h1, h2, h3 {
  font-family: var(--serif);
  font-weight: 400;
  letter-spacing: -0.02em;
  overflow-wrap: anywhere;
  word-break: break-word;
}

h1 {
  font-size: clamp(1.45rem, 6vw, 2.35rem);
  line-height: 1.18;
  margin: 0 0 0.9rem;
}
h1 .sub {
  display: block;
  color: var(--seal);
  margin-top: 0.35rem;
  font-size: 0.72em;
}
h2 {
  font-size: clamp(1.15rem, 3.5vw, 1.35rem);
  margin: 2rem 0 0.85rem;
}
h3 { font-size: 1.05rem; margin: 0.2rem 0 0.35rem; }

.lede, .lede {
  font-size: clamp(0.98rem, 2.8vw, 1.05rem);
  color: var(--muted);
  max-width: 42rem;
  line-height: 1.65;
  margin: 0 0 0.5rem;
}

.muted { color: var(--muted); }
.subtle { color: var(--subtle); font-size: 0.8rem; }
.mark { color: var(--seal); font-weight: 600; }
.err { color: var(--seal); }

.row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  margin: 1.1rem 0 0;
}

.btn {
  min-height: var(--tap);
  min-width: var(--tap);
  padding: 0 1.05rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  border-radius: 8px;
  text-decoration: none;
  font-weight: 600;
  font-size: 0.92rem;
  border: 0;
  font-family: inherit;
  text-align: center;
}
.btn-solid, .btn-solid { background: var(--seal); color: var(--paper); }
.btn-ghost, .btn-ghost {
  border: 1px solid var(--rule);
  background: var(--paper-deep);
  color: var(--ink);
}
.btn-solid:hover { background: var(--seal-deep); }
.btn-ghost:hover { border-color: var(--seal); }

.grid-2, .grid-2 {
  display: grid;
  gap: 1.25rem;
}
@media (min-width: 900px) {
  .grid-2, .grid-2 { grid-template-columns: 1.2fr 0.8fr; gap: 2rem; }
}

.card, .sheet {
  background: var(--white);
  border: 1px solid var(--rule);
  border-radius: 12px;
  box-shadow: var(--shadow);
  min-width: 0;
}
.card { padding: 1.1rem; }
.sheet {
  padding: clamp(1rem, 3vw, 1.5rem);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.dl {
  display: grid;
  grid-template-columns: minmax(6.5rem, 8rem) 1fr;
  gap: 0.45rem 0.75rem;
  margin: 0;
}
.dl dt {
  color: var(--subtle);
  font-size: 0.8rem;
  margin: 0;
}
.dl dd {
  margin: 0;
  font-weight: 600;
  overflow-wrap: anywhere;
}
@media (max-width: 420px) {
  .dl { grid-template-columns: 1fr; gap: 0.15rem 0; }
  .dl dd { margin-bottom: 0.65rem; }
}

.figures, .figures {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.65rem;
}
@media (min-width: 900px) {
  .figures, .figures { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 380px) {
  .figures, .figures { grid-template-columns: 1fr; }
}
.fig .label, .fig .label {
  font-size: 0.68rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--subtle);
  margin: 0;
}
.fig .val, .fig .val {
  font-family: var(--serif);
  font-size: clamp(1.05rem, 3.5vw, 1.25rem);
  margin: 0.3rem 0 0.2rem;
  overflow-wrap: anywhere;
}
.fig .note, .fig .note {
  font-size: 0.82rem;
  color: var(--muted);
  margin: 0;
}

.cards3, .cards3 {
  display: grid;
  gap: 0.85rem;
}
@media (min-width: 800px) {
  .cards3, .cards3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
.cards3 a, .cards3 a, .doc-card, .doc-card {
  color: inherit;
  text-decoration: none;
}
.cards3 a:hover,
.secgrid a:hover,
.list a:hover,
.page-card:hover,
.doc-card:hover { border-color: var(--seal); }

.search, .search {
  width: 100%;
  min-height: var(--tap);
  height: var(--tap);
  border: 1px solid var(--rule);
  border-radius: 8px;
  padding: 0 0.9rem;
  font: inherit;
  background: var(--white);
  margin: 0.85rem 0 1rem;
}

/* —— Tables —— */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: 12px;
  border: 1px solid var(--rule);
  background: var(--white);
  box-shadow: var(--shadow);
}
table {
  width: 100%;
  min-width: 28rem;
  border-collapse: collapse;
  font-size: 0.88rem;
  background: var(--white);
}
th {
  text-align: left;
  background: var(--seal);
  color: var(--paper);
  font-weight: 600;
  padding: 0.55rem 0.75rem;
  white-space: nowrap;
}
td {
  padding: 0.6rem 0.75rem;
  border-top: 1px solid var(--rule);
  vertical-align: top;
  overflow-wrap: anywhere;
}
tr:nth-child(even) td { background: var(--paper); }

/* —— Tree —— */
.tree, .tree { display: grid; gap: 0.75rem; }
.bundle, .bundle {
  border: 1px solid var(--rule);
  background: var(--white);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: var(--shadow);
}
.bundle summary, .bundle summary {
  cursor: pointer;
  padding: 0.95rem 1rem;
  font-family: var(--serif);
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  align-items: flex-start;
  min-height: var(--tap);
}
@media (min-width: 640px) {
  .bundle summary, .bundle summary {
    flex-direction: row;
    justify-content: space-between;
    align-items: baseline;
    gap: 1rem;
  }
}
.bundle summary::-webkit-details-marker { display: none; }
.bundle summary::before {
  content: "+";
  display: inline-grid;
  place-items: center;
  width: 1.25rem;
  height: 1.25rem;
  margin-right: 0.45rem;
  border-radius: 4px;
  background: var(--paper-deep);
  color: var(--seal);
  font-family: var(--sans);
  font-weight: 700;
  flex-shrink: 0;
}
.bundle[open] summary::before { content: "–"; }
.bundle-note, .bundle-note {
  margin: 0 1rem 0.75rem;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.45;
}
.bundle[open] summary {
  border-bottom: 1px solid var(--rule);
  margin-bottom: 0.35rem;
}
.kids, .kids {
  padding: 0 0.85rem 0.95rem;
  display: grid;
  gap: 0.5rem;
}
.doc-card, .doc-card {
  display: block;
  padding: 0.85rem 0.95rem;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: var(--paper);
  text-decoration: none;
  color: inherit;
}

.secgrid, .secgrid {
  display: grid;
  gap: 0.55rem;
  margin-top: 1rem;
  list-style: none;
  padding: 0;
}
@media (min-width: 700px) {
  .secgrid, .secgrid { grid-template-columns: 1fr 1fr; }
}

.pagegrid, .pagegrid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.65rem;
  margin-top: 1.25rem;
}
@media (min-width: 520px) {
  .pagegrid, .pagegrid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (min-width: 800px) {
  .pagegrid, .pagegrid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (min-width: 1100px) {
  .pagegrid, .pagegrid { grid-template-columns: repeat(6, minmax(0, 1fr)); }
}

.page-card, .page-card {
  display: block;
  background: var(--white);
  border: 1px solid var(--rule);
  border-radius: 8px;
  overflow: hidden;
  color: inherit;
  text-decoration: none;
  font-size: 0.8rem;
}
.page-card img {
  width: 100%;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  background: var(--paper-deep);
}
.page-card span {
  display: block;
  padding: 0.45rem 0.55rem;
  color: var(--muted);
}

.scan, .scan {
  margin: 1.15rem 0 0;
  background: var(--white);
  border: 1px solid var(--rule);
  border-radius: 12px;
  padding: 0.55rem;
  overflow: hidden;
}
.scan img { width: 100%; border-radius: 8px; }

.thumbs, .thumbs {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding: 0.25rem 0 1rem;
  scroll-snap-type: x mandatory;
}
.thumbs a { flex: 0 0 88px; scroll-snap-align: start; }
.thumbs img {
  width: 88px;
  height: 118px;
  object-fit: cover;
  border: 1px solid var(--rule);
  border-radius: 6px;
  background: var(--paper-deep);
}

.list, .list { display: grid; gap: 0.55rem; }
.list a, .list a {
  display: block;
  padding: 0.95rem 1rem;
  border: 1px solid var(--rule);
  background: var(--white);
  border-radius: 8px;
  text-decoration: none;
  color: inherit;
  overflow-wrap: anywhere;
}

.legal, .legal {
  font-family: var(--serif);
  font-size: 0.95rem;
  line-height: 1.7;
  max-width: 48rem;
}
.legal h1 { font-size: 1.35rem; color: var(--seal); }
.legal a { color: var(--seal); }
.legal table { font-family: var(--sans); font-size: 0.8rem; min-width: 0; }
.legal th, .legal td { border: 1px solid var(--rule); padding: 0.45em 0.55em; }
.legal blockquote {
  margin: 1em 0;
  padding: 0.85em 1em 0.7em;
  border: 1px solid color-mix(in oklab, var(--seal) 22%, var(--rule));
  border-top: 3px solid var(--seal);
  background: color-mix(in oklab, var(--seal) 6%, var(--paper));
  color: var(--seal-deep);
  font-family: var(--sans);
  font-size: 0.85rem;
  font-style: italic;
}

footer {
  border-top: 1px solid var(--rule);
  background: var(--paper-deep);
  padding: 1.25rem 0 calc(1.25rem + var(--safe-bottom));
  color: var(--muted);
  font-size: 0.88rem;
}
.foot-title, .foot-title {
  font-family: var(--serif);
  color: var(--ink);
  margin: 0 0 0.4rem;
  overflow-wrap: anywhere;
}

/* —— Mindmap —— */
.mindmap-shell {
  margin-top: 1rem;
  border: 1px solid var(--rule);
  border-radius: 14px;
  background: linear-gradient(180deg, var(--white), var(--paper));
  box-shadow: var(--shadow);
  overflow: hidden;
}

.mindmap-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 0.9rem;
  border-bottom: 1px solid var(--rule);
  background: color-mix(in oklab, var(--paper-deep) 70%, var(--white));
}

.mindmap-toolbar .hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.mindmap-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.chip {
  min-height: 2.25rem;
  padding: 0 0.75rem;
  border-radius: 999px;
  border: 1px solid var(--rule);
  background: var(--white);
  color: var(--ink);
  font-size: 0.82rem;
  font-weight: 600;
}

.mindmap-scroll {
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  max-height: min(78dvh, 820px);
  padding: 1rem 0.75rem 1.25rem;
}

.mindmap {
  display: grid;
  gap: 1rem;
  min-width: 0;
}

.mm-root {
  justify-self: center;
  text-align: center;
  max-width: 28rem;
  width: 100%;
}

.mm-node {
  display: block;
  border: 1px solid var(--rule);
  border-radius: 12px;
  background: var(--white);
  padding: 0.85rem 1rem;
  text-decoration: none;
  color: inherit;
  box-shadow: var(--shadow);
  transition: border-color 0.15s ease, transform 0.15s ease;
}
.mm-node:hover { border-color: var(--seal); }
.mm-node.mm-cause {
  background: var(--seal);
  color: var(--paper);
  border-color: var(--seal-deep);
}
.mm-node.mm-cause .mm-meta {
  color: color-mix(in oklab, var(--paper) 75%, transparent);
}
.mm-node.mm-cause .mm-label {
  color: color-mix(in oklab, var(--paper) 82%, transparent);
}
.mm-node h3 {
  margin: 0.15rem 0 0.25rem;
  font-size: clamp(0.95rem, 3.2vw, 1.1rem);
}
.mm-label {
  display: block;
  font-size: 0.68rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-weight: 700;
  opacity: 0.85;
}
.mm-meta {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.mm-parties {
  display: grid;
  gap: 0.65rem;
}
@media (min-width: 720px) {
  .mm-parties { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

.mm-spine {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.35rem;
  color: var(--seal);
  font-size: 0.75rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-weight: 700;
}
.mm-spine::before,
.mm-spine::after {
  content: "";
  height: 1px;
  width: min(28vw, 6rem);
  background: var(--rule);
}

.mm-branches {
  display: grid;
  gap: 0.7rem;
}

.mm-branch {
  border: 1px solid var(--rule);
  border-radius: 12px;
  background: var(--white);
  overflow: hidden;
}

.mm-branch > summary {
  list-style: none;
  cursor: pointer;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.65rem;
  align-items: center;
  padding: 0.85rem 0.95rem;
  min-height: var(--tap);
}
.mm-branch > summary::-webkit-details-marker { display: none; }
.mm-branch .dot {
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 999px;
  background: var(--seal);
  box-shadow: 0 0 0 4px color-mix(in oklab, var(--seal) 15%, transparent);
}
.mm-branch .mm-count {
  font-size: 0.78rem;
  color: var(--subtle);
  white-space: nowrap;
}
.mm-branch[open] { border-color: color-mix(in oklab, var(--seal) 35%, var(--rule)); }
.mm-branch[open] > summary {
  border-bottom: 1px solid var(--rule);
  background: color-mix(in oklab, var(--seal) 5%, var(--white));
}

.mm-docs {
  display: grid;
  gap: 0.4rem;
  padding: 0.75rem;
}
.mm-docs a {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.55rem 0.7rem;
  align-items: start;
  padding: 0.7rem 0.8rem;
  border-radius: 8px;
  border: 1px solid var(--rule);
  background: var(--paper);
  text-decoration: none;
  color: inherit;
}
.mm-docs a:hover { border-color: var(--seal); }
.mm-docs .mm-kind {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--seal);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  grid-column: 1 / -1;
}
a.chip {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
}
.mm-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 0.85rem;
  margin-top: 0.85rem;
  color: var(--muted);
  font-size: 0.82rem;
}
.mm-legend span { display: inline-flex; align-items: center; gap: 0.35rem; }
.mm-legend i {
  display: inline-block;
  width: 0.65rem;
  height: 0.65rem;
  border-radius: 999px;
  background: var(--seal);
}
.mm-docs strong {
  font-size: 0.92rem;
  font-weight: 600;
  overflow-wrap: anywhere;
}
.mm-docs span {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 0.8rem;
}

.mm-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 0.85rem;
  margin-top: 0.85rem;
  color: var(--muted);
  font-size: 0.82rem;
}
.mm-legend i {
  display: inline-block;
  width: 0.65rem;
  height: 0.65rem;
  border-radius: 999px;
  background: var(--seal);
  margin-right: 0.35rem;
}

@media (min-width: 960px) {
  .mm-branches {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .row .btn { flex: 1 1 calc(50% - 0.65rem); }
  .row .btn-solid { flex: 1 1 100%; }
  .bar { gap: 0.4rem; }
  .seal { width: 2.1rem; height: 2.1rem; }
  .card { padding: 0.95rem; }
  .page { padding-top: 1rem; }
  .mindmap-scroll { padding-left: 0.55rem; padding-right: 0.55rem; }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; transition: none !important; }
}

/* —— Header search trigger —— */
.search-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  height: 2.35rem;
  padding: 0 0.6rem;
  border: 1px solid var(--rule);
  border-radius: 999px;
  background: var(--white);
  color: var(--muted);
  cursor: pointer;
  flex-shrink: 0;
}
.search-btn:hover { border-color: var(--seal); color: var(--seal); }
.search-btn-label { font-size: 0.85rem; }
.search-kbd {
  font-family: var(--sans);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--subtle);
  border: 1px solid var(--rule);
  border-radius: 5px;
  padding: 0.1rem 0.3rem;
  background: var(--paper);
}
@media (max-width: 900px) {
  .search-btn { padding: 0; width: 2.35rem; justify-content: center; }
  .search-btn-label, .search-kbd { display: none; }
}

/* —— Locator: sits in the flow, scrolls away, never covers the page —— */
.locator {
  border-bottom: 1px solid var(--rule);
  background: color-mix(in oklab, var(--paper-deep) 55%, var(--paper));
}
.locator-inner {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-height: 3rem;
  padding-top: 0.45rem;
  padding-bottom: 0.45rem;
}
.tree-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  min-height: 2.25rem;
  padding: 0 0.75rem;
  border: 1px solid color-mix(in oklab, var(--seal) 30%, var(--rule));
  border-radius: 999px;
  background: var(--white);
  color: var(--seal);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  flex-shrink: 0;
}
.tree-toggle:hover { background: color-mix(in oklab, var(--seal) 8%, var(--white)); }
.tree-toggle[aria-expanded="true"] {
  background: var(--seal);
  border-color: var(--seal-deep);
  color: var(--paper);
}
.crumbs {
  display: flex;
  align-items: center;
  gap: 0.15rem;
  min-width: 0;
  overflow: hidden;
  font-size: 0.84rem;
  color: var(--muted);
}
.crumb {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-decoration: none;
  color: var(--muted);
  padding: 0.2rem 0.3rem;
  border-radius: 5px;
  max-width: 12rem;
}
a.crumb:hover { color: var(--seal); background: color-mix(in oklab, var(--seal) 8%, transparent); }
.crumb.current { color: var(--ink); font-weight: 600; max-width: 20rem; }
.crumb-sep { color: var(--subtle); flex-shrink: 0; }
@media (max-width: 640px) {
  .locator-inner { gap: 0.5rem; }
  .tree-toggle-label { display: none; }
  .tree-toggle { padding: 0 0.6rem; }
  .crumbs { font-size: 0.8rem; }
  .crumb { max-width: 7.5rem; }
  .crumb.current { max-width: 11rem; }
}

body.locked { overflow: hidden; }

/* —— Filing tree: right drawer on desktop, bottom sheet on phone —— */
.tree-sheet {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: block;
}
.tree-sheet-bg {
  position: absolute;
  inset: 0;
  border: 0;
  width: 100%;
  height: 100%;
  background: color-mix(in oklab, var(--ink) 40%, transparent);
  opacity: 0;
  transition: opacity 0.2s ease;
}
.tree-sheet.open .tree-sheet-bg { opacity: 1; }
.tree-panel {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(25rem, 92vw);
  background: var(--paper);
  border-left: 1px solid var(--rule);
  box-shadow: -24px 0 60px -30px color-mix(in oklab, var(--ink) 55%, transparent);
  display: flex;
  flex-direction: column;
  padding-top: var(--safe-top);
  transform: translateX(100%);
  transition: transform 0.24s cubic-bezier(0.22, 0.61, 0.36, 1);
}
.tree-sheet.open .tree-panel { transform: translateX(0); }
.tree-grab { display: none; }
.tree-panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.9rem 1rem 0.75rem;
  border-bottom: 1px solid var(--rule);
}
.tree-panel-title {
  margin: 0.1rem 0 0;
  font-family: var(--serif);
  font-size: 1.05rem;
}
.tree-panel-tools {
  padding: 0.8rem 1rem;
  display: grid;
  gap: 0.6rem;
  border-bottom: 1px solid var(--rule);
}
.tree-search { margin: 0; }
.tree-actions { display: flex; gap: 0.4rem; }
.file-tree {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 0.7rem 0.8rem calc(1.5rem + var(--safe-bottom));
  display: grid;
  gap: 0.4rem;
  align-content: start;
}
.ft-empty { color: var(--muted); font-size: 0.88rem; padding: 0.5rem 0.25rem; }
.ft-branch {
  border: 1px solid var(--rule);
  border-radius: 12px;
  background: var(--white);
}
.ft-branch.here { border-color: color-mix(in oklab, var(--seal) 45%, var(--rule)); }
.ft-summary {
  list-style: none;
  cursor: pointer;
  display: grid;
  grid-template-columns: 1rem 1.15rem 1fr auto;
  gap: 0.5rem;
  align-items: center;
  min-height: 2.9rem;
  padding: 0.5rem 0.75rem;
  border-radius: 12px;
}
.ft-summary::-webkit-details-marker { display: none; }
.ft-summary:hover { background: color-mix(in oklab, var(--seal) 5%, var(--white)); }
.ft-branch[open] > .ft-summary {
  border-bottom: 1px solid var(--rule);
  border-radius: 12px 12px 0 0;
}
.ft-branch.here > .ft-summary { background: color-mix(in oklab, var(--seal) 7%, var(--white)); }
.ft-chev { display: inline-flex; color: var(--subtle); transition: transform 0.18s ease; }
.ft-chev svg { width: 1rem; height: 1rem; }
.ft-branch[open] > .ft-summary .ft-chev { transform: rotate(90deg); }
.ft-ico { display: inline-flex; color: var(--seal); }
.ft-ico svg { width: 1.15rem; height: 1.15rem; }
.ft-summary .ft-label {
  font-family: var(--serif);
  font-size: 0.88rem;
  font-weight: 400;
  line-height: 1.3;
  white-space: normal;
  overflow: visible;
}
.ft-label { min-width: 0; }
.ft-meta {
  color: var(--subtle);
  font-size: 0.72rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.ft-children { display: grid; gap: 0.15rem; padding: 0.35rem; }
.ft-file {
  display: grid;
  grid-template-columns: 1.05rem 1fr auto;
  gap: 0.5rem;
  align-items: center;
  min-height: 2.6rem;
  padding: 0.45rem 0.55rem;
  border: 1px solid transparent;
  border-radius: 9px;
  text-decoration: none;
  color: var(--ink);
}
.ft-file .ft-ico { color: var(--subtle); }
.ft-file .ft-ico svg { width: 1.05rem; height: 1.05rem; }
.ft-file .ft-label {
  font-size: 0.83rem;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.ft-file:hover { border-color: var(--rule); background: var(--paper); }
.ft-doc.here > .ft-file {
  border-color: color-mix(in oklab, var(--seal) 45%, var(--rule));
  background: color-mix(in oklab, var(--seal) 9%, var(--paper));
}
.ft-doc.here > .ft-file .ft-ico { color: var(--seal); }
.ft-doc.here > .ft-file .ft-label { font-weight: 600; }
.ft-leaves {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  padding: 0.4rem 0.55rem 0.5rem 1.6rem;
}
.ft-leaves a {
  font-size: 0.72rem;
  font-weight: 600;
  text-decoration: none;
  color: var(--muted);
  border: 1px solid var(--rule);
  border-radius: 999px;
  padding: 0.3rem 0.6rem;
  background: var(--white);
}
.ft-leaves a.on, .ft-leaves a:hover {
  color: var(--paper);
  background: var(--seal);
  border-color: var(--seal);
}

@media (max-width: 640px) {
  .tree-panel {
    top: auto;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 82dvh;
    border-left: 0;
    border-top: 1px solid var(--rule);
    border-radius: 18px 18px 0 0;
    padding-top: 0;
    transform: translateY(100%);
  }
  .tree-sheet.open .tree-panel { transform: translateY(0); }
  .tree-grab {
    display: block;
    width: 2.5rem;
    height: 0.25rem;
    border-radius: 999px;
    background: var(--rule);
    margin: 0.6rem auto 0.1rem;
  }
  .tree-panel-head { padding: 0.5rem 1rem 0.7rem; }
  .tree-actions { display: none; }
}

/* —— Command palette (⌘K) —— */
.cp {
  position: fixed;
  inset: 0;
  z-index: 95;
  display: block;
}
.cp-bg {
  position: absolute;
  inset: 0;
  border: 0;
  width: 100%;
  height: 100%;
  background: color-mix(in oklab, var(--ink) 45%, transparent);
  opacity: 0;
  transition: opacity 0.18s ease;
}
.cp.open .cp-bg { opacity: 1; }
.cp-panel {
  position: absolute;
  top: 12vh;
  left: 50%;
  transform: translate(-50%, -8px);
  width: min(40rem, calc(100vw - 2rem));
  max-height: min(70vh, 34rem);
  display: flex;
  flex-direction: column;
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 16px;
  box-shadow: 0 40px 80px -40px color-mix(in oklab, var(--ink) 70%, transparent);
  overflow: hidden;
  opacity: 0;
  transition: opacity 0.18s ease, transform 0.18s ease;
}
.cp.open .cp-panel { opacity: 1; transform: translate(-50%, 0); }
.cp-head {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.75rem 0.9rem;
  border-bottom: 1px solid var(--rule);
}
.cp-search-ico { color: var(--subtle); flex-shrink: 0; }
.cp-input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  font: inherit;
  font-size: 1rem;
  color: var(--ink);
  outline: none;
  min-height: 2rem;
}
.cp-close {
  border: 1px solid var(--rule);
  border-radius: 6px;
  background: var(--white);
  color: var(--subtle);
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.25rem 0.4rem;
  cursor: pointer;
  flex-shrink: 0;
}
.cp-list { flex: 1; overflow-y: auto; padding: 0.4rem; }
.cp-group {
  margin: 0.5rem 0.5rem 0.25rem;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--subtle);
}
.cp-item {
  display: grid;
  grid-template-columns: 1.4rem 1fr;
  gap: 0.65rem;
  align-items: start;
  width: 100%;
  text-align: left;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  padding: 0.55rem 0.6rem;
  cursor: pointer;
}
.cp-item .cp-ico { color: var(--subtle); display: inline-flex; padding-top: 0.1rem; }
.cp-item .cp-ico svg { width: 1.15rem; height: 1.15rem; }
.cp-text { display: grid; gap: 0.1rem; min-width: 0; }
.cp-label {
  font-size: 0.9rem;
  color: var(--ink);
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.cp-sub {
  font-size: 0.76rem;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cp-item:hover, .cp-item.active {
  background: var(--white);
  border-color: color-mix(in oklab, var(--seal) 35%, var(--rule));
}
.cp-item.active .cp-ico { color: var(--seal); }
.cp-empty { color: var(--muted); font-size: 0.88rem; padding: 1.25rem 0.75rem; text-align: center; }
.cp-foot {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.5rem 0.9rem;
  border-top: 1px solid var(--rule);
  background: color-mix(in oklab, var(--paper-deep) 50%, var(--paper));
  font-size: 0.72rem;
  color: var(--subtle);
}
.cp-foot span:last-child { margin-left: auto; }
.cp-foot kbd {
  font-family: var(--sans);
  font-size: 0.7rem;
  border: 1px solid var(--rule);
  border-radius: 4px;
  padding: 0 0.25rem;
  margin-right: 0.15rem;
  background: var(--white);
}
@media (max-width: 640px) {
  .cp-panel {
    top: 0;
    left: 0;
    right: 0;
    transform: none;
    width: 100%;
    max-height: 100dvh;
    height: 100dvh;
    border: 0;
    border-radius: 0;
    padding-top: var(--safe-top);
  }
  .cp.open .cp-panel { transform: none; }
  .cp-foot { display: none; }
}

.tree-sheet[hidden], .cp[hidden] { display: none; }
