/* Shared by the article shell, rendered Markdown, vault components and dialogs. */
:root {
  --vault-title: clamp(1.625rem, 2.5vw, 2rem);
  --vault-section: clamp(1.3125rem, 2vw, 1.5rem);
  --vault-subhead: 1.125rem;
  --vault-body: 1rem;
  --vault-ui: .875rem;
  --vault-detail: .8125rem;
  --vault-caption: .75rem;
  --vault-leading: 1.65;
  --vault-heading-leading: 1.25;
}
.app .article > .kicker + h1 { font-size: var(--vault-title); line-height: 1.18; }
.app .kicker { letter-spacing: .1em; }
.app .sc-stat, #app[data-welcome] .stat { padding: 10px 12px; border-radius: 8px; }
.app .sc-stat .sc-num, #app[data-welcome] .stat b {
  font-size: var(--vault-section);
  font-weight: 600;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
  margin: 0;
}
.app .sc-lab, #app[data-welcome] .stat span { font-size: var(--vault-detail); line-height: 1.4; }
.app .sc-sub { font-size: var(--vault-caption); line-height: 1.4; }
.app .sc-sub:empty:not(.ac-inline) { display: none; }

@media (min-width: 641px) and (pointer: fine) {
  .app .an-newnote, .app .an-btn, #app[data-welcome] :is(.primary, .btn) {
    min-height: 34px;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: var(--vault-ui);
    font-weight: 600;
    line-height: 1.35;
  }
}

/* The note is the primary surface. Navigation and metadata use the smaller UI scale. */
.app .side-right :is(.rail-h, .toc-heading, .toc-header, h3, .toc-label) {
  font-family: inherit;
  font-size: var(--vault-detail);
  font-weight: 600;
  line-height: 1.45;
  letter-spacing: 0;
}
.app .side-right .graph > :is(.rail-h, h3) { margin: 0 0 8px; }
.app .toc-content a, .app .side-sections a { font-size: var(--vault-ui); }
.app .article > h1 { max-width: 32ch; letter-spacing: -.035em; }
.app .article > .meta { margin-block: 6px 12px; }
.app .article > .tag-row { margin-block: 8px 18px; }
.app .tag-row .tag {
  padding: 2px 7px;
  border-radius: 5px;
  border-color: var(--line);
  background: var(--panel);
  color: var(--muted);
  letter-spacing: .025em;
  text-transform: none;
}
.app .ac-props .an-table { table-layout: fixed; }
.app .ac-props .an-table :is(th, td) {
  padding: 7px 10px;
  vertical-align: middle;
  background: transparent;
  border-radius: 0;
  border-bottom: 1px solid var(--line);
  font-size: var(--vault-detail);
  line-height: 1.45;
}
.app .ac-props .an-table th {
  position: static;
  font-family: inherit;
  font-size: var(--vault-detail);
  font-weight: 500;
  color: var(--muted);
  letter-spacing: 0;
  text-transform: none;
  white-space: normal;
  overflow-wrap: anywhere;
}
.app .ac-props .an-table tr:nth-child(even) { background: transparent; }
.app .ac-props .an-table tr:last-child > * { border-bottom: 0; }
.app .ac-props summary { margin-bottom: 5px; }
.app .ac-props { margin-bottom: 16px; }
.app .sc-stats .sc-stat { background: var(--panel); }
.app .sc-stat .sc-num { color: var(--ink); }
.app .sc-stat .sc-lab { color: var(--muted); }
.app .sc-stat .sc-sub.ac-inline:empty:not(:hover):not(:focus)::before { opacity: 0; }
@media (min-width: 801px) {
  .app .ac-props .an-table th { width: 32%; }
}
@media (min-width: 1100px) {
  .app .side-left { gap: 1rem; }
  .app .side-left .ac-search { margin-bottom: 0 !important; }
  .app .side-right { padding-top: calc(62px + 40px); }
  .app .side-right .toc-content a { min-height: 30px; }
  .app .side-left .ac-search input { height: 36px; }
}

/* Let the title, instructions and wrapping legend take their natural height. */
body[data-node="graph"] .reading {
  display: flex;
  flex-direction: column;
  height: calc(100dvh - 8px);
}
body[data-node="graph"] .reading > header { flex: none; }
body[data-node="graph"] .reading :is(#content, .article, .prose) {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
}
body[data-node="graph"] .reading #content.page { padding-bottom: 8px; }
body[data-node="graph"] .prose > :not(.an-graph-page) { flex: none; }
body[data-node="graph"] .reading .an-graph-page {
  flex: 1 1 auto;
  min-height: 64px;
  height: auto;
  max-height: none;
}
.graph-outer .graph-container { max-height: 100% !important; }
.global-graph-outer.active .global-graph-container {
  position: absolute;
  inset: 0;
  margin: auto;
  transform: none;
  max-width: 100%;
  max-height: 100%;
  box-sizing: border-box;
}

/* Keep the reading rhythm consistent when moving between the hub and its notes. */
.app .reading #content.page {
  padding-block: clamp(20px, 3vw, 40px) clamp(40px, 5vw, 72px);
}
.app .reading .article { margin-block: 0; }
.app .reading .article > :first-child { margin-block-start: 0; }
.app .reading .article > .kicker + h1 { margin-block: 8px 12px; }
.app .reading details.ac-props { margin-block: 18px 16px; }

.app .side-sections a {
  color: var(--muted);
  padding-inline: 11px;
  border-radius: 6px;
}
.app .side-sections a:hover { color: var(--ink); }
.app .side-sections a[aria-current="page"] {
  background: transparent;
  box-shadow: none;
}
.app .ac-top .menu-btn,
.app .ac-actions .ac-theme { border-radius: 7px; }
.app .ac-actions { gap: 6px; }
.app .ac-user { margin-left: 0; }
.app button.ac-avatar {
  width: 34px;
  height: 34px;
  min-width: 34px;
  border-radius: 50%;
  border: 0;
  padding: 0;
  box-shadow: none;
}
.app button.ac-avatar:focus-visible, .app button.ac-avatar[aria-expanded="true"] {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
@media (pointer: coarse), (max-width: 640px) {
  .app button.ac-avatar { width: 44px; height: 44px; }
}
.app .ac-menu {
  width: min(248px, calc(100vw - 24px));
  min-width: 0;
  max-height: calc(100dvh - 80px);
  overflow-y: auto;
  box-sizing: border-box;
  padding: 5px;
  border-color: var(--line);
  border-radius: 12px;
  box-shadow: 0 8px 28px rgb(0 0 0 / 16%);
}
.app .ac-menu .ac-who { padding: 9px 8px 12px; }
.app .ac-menu .ac-who .ac-avatar {
  display: grid;
  place-items: center;
  color: white;
  box-shadow: none;
}
.app .ac-menu .ac-who > div { min-width: 0; overflow-wrap: anywhere; }
.app .ac-menu .ac-out { margin-top: 3px; }
@media (min-width: 1100px) and (pointer: fine) {
  .app .ac-actions :is(.ac-theme, button.ac-avatar) { height: 34px; }
  .app .ac-actions .ac-theme { width: 34px; }
  .app .ac-menu :is(a, button) { min-height: 34px; padding: 6px 9px; font-size: var(--vault-detail); }
}

@media (min-width: 1100px) {
  .app { --vault-header-height: 52px; }
  .app > .reading { grid-row: 1 / span 2; }
  .app > .side-left { padding-top: 0 !important; }
  .app .side-brand, .app .reading > .ac-top {
    box-sizing: border-box;
    height: var(--vault-header-height);
    min-height: var(--vault-header-height);
    flex-shrink: 0;
    align-items: center;
    padding-block: 0;
  }
  .app .side-brand { display: flex; border-bottom: 1px solid transparent; }
}

.app .ac-actions .an-newnote {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: 44px;
  min-width: 44px;
  height: 44px;
  padding: 0;
  border: none;
  color: var(--ink);
  background: transparent;
  box-shadow: none;
  font-size: 0;
}
.app .ac-actions .an-newnote::before {
  content: "";
  position: absolute;
  inset: 0;
  margin: auto;
  width: 14px;
  height: 14px;
  background:
    linear-gradient(currentColor, currentColor) center / 2px 100% no-repeat,
    linear-gradient(currentColor, currentColor) center / 100% 2px no-repeat;
}
.app .ac-actions .ac-theme { display: grid; place-items: center; padding: 0; }
.app .ac-actions .ac-theme svg { margin: 0; grid-area: 1 / 1; }
/* Center the asymmetric crescent path within its 18px viewport. */
.app .ac-actions .ac-moon { transform: translateY(.24px); }
.app .ac-actions .an-newnote:hover { color: var(--accent); }
@media (min-width: 641px) and (pointer: fine) {
  .app .ac-actions .an-newnote { width: 34px; min-width: 34px; height: 34px; }
}
:is(.ac-menu, .portal-nav, .utilities) a[href$="/admin"]::before {
  content: "";
  display: inline-block;
  width: 16px;
  height: 16px;
  flex: none;
  vertical-align: -.15em;
  background-color: currentColor;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.7' stroke-linecap='round'%3E%3Cpath d='M3 7h7m5 0h6M3 17h12m5 0h1'/%3E%3Ccircle cx='12.5' cy='7' r='2.5'/%3E%3Ccircle cx='17.5' cy='17' r='2.5'/%3E%3C/svg%3E") center / contain no-repeat;
}
:is(.portal-nav, .utilities) a[href$="/admin"]::before { margin-inline-end: 6px; }

dialog:is(.an-new, .an-add) form {
  border-radius: 10px;
  padding: 20px;
  background: var(--panel);
  box-shadow: none;
  overflow-y: auto;
}
dialog:is(.an-new, .an-add) :is(input, select, button) { border-radius: 6px; }
.an-new select {
  width: 100%; min-height: 40px; padding: 6px 10px;
  font: inherit; font-size: var(--vault-body); background: var(--panel); color: var(--ink);
  border: 1px solid var(--line-strong);
}
.an-new-lead a { color: var(--link); }

/* Content and navigation keep their semantic levels across old and current shells. */
.app .article > h1, #app[data-welcome] h1 { font-size: var(--vault-title); line-height: 1.18; }
.app .prose { font-size: var(--vault-body); line-height: var(--vault-leading); }
.app .prose :is(h1, h2, h3, h4, h5, h6):not(.kicker) {
  font-weight: 600;
  line-height: var(--vault-heading-leading);
  letter-spacing: -.02em;
  overflow-wrap: anywhere;
}
.app .prose :is(h1, h2):not(.kicker), #app[data-welcome] h2 { font-size: var(--vault-section); }
.app .prose h3:not(.kicker), dialog:is(.an-new, .an-add) h2 { font-size: var(--vault-subhead); }
.app .prose :is(h4, h5, h6):not(.kicker), .app :is(.deck, .sc-lede, .callout) { font-size: var(--vault-body); }
.app .prose :is(pre, code) { font-family: var(--mono); font-size: var(--vault-ui); }
.app .prose pre { line-height: 1.5; }
.app .prose :is(table, .sc-card, .sc-tl-what, .an-db-tab, .an-db-add),
.app :is(.ac-crumbs, .side-brand .ac-brand, .tree a, .tree summary, .row, .backlink),
dialog:is(.an-new, .an-add) :is(button, .an-new-lead) { font-size: var(--vault-ui); }
.app :is(.meta, .sc-legend, .an-legend, .an-db-meta, .sc-tl-sub, .sc-type, .ac-menu a, .ac-menu button),
dialog:is(.an-new, .an-add) label { font-size: var(--vault-detail); }
.app :is(.kicker, .sc-eyebrow, .tag, .sc-due, .sc-pill, .sc-tl-when) { font-size: var(--vault-caption); }
.app .ac-actions, .app .ac-user { display: flex; align-items: center; }
.app .ac-top { align-items: center; }
@media (min-width: 801px) and (max-width: 1099px) {
  .app .topbar.ac-top { flex-wrap: nowrap; padding-block: 0; min-height: 52px; }
  .app .ac-top .ac-brand { flex: 0 1 auto; }
  .app .ac-top .ac-crumbs { order: 0; flex: 1 1 0; padding-block: 0; overflow: hidden; }
}

@media (max-width: 800px) {
  .app .topbar.ac-top { gap: 0; padding: 4px 6px; min-height: 52px; }
  .app .ac-top .ac-brand { flex: 1 1 0; min-height: 44px; gap: 6px; }
  .app .ac-top .ac-brand .ac-ws { min-width: 0; max-width: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .app .ac-top .ac-brand .ac-logo { flex: none; width: 20px; height: 20px; }
  .app .ac-top:has([data-search-open]) .ac-top-search { display: none; }
  .app .ac-top .ac-actions [data-search-open] { display: inline-grid !important; place-items: center; width: 44px; height: 44px; }
  .app .ac-top .ac-actions { gap: 0; }
  .app .article > .meta { margin-block: 4px 6px; }
  .app .article > .tag-row { margin-block: 6px; }
  .app .article .ac-props { margin-block: 0 8px; }
  .app .sc-stats:has(> :nth-child(3):last-child) {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
  }
  .app .sc-stats .sc-stat { min-width: 0; min-height: 0; padding: 10px 8px; overflow-wrap: anywhere; }
  .app .sc-stat :is(.sc-num, .sc-lab, .sc-sub) { margin: 0; }
  .app .sc-stat .sc-lab { margin-top: 2px; }
  .app .sc-stat .sc-sub:empty:not(:focus) { min-height: 0; margin: 0; }
}
