/* Family Net — warm, accessible UI following the Our Stories design language. */
:root {
  color-scheme: light;
  --bg: #f6f5f0;
  --bg-elevated: #fbfaf7;
  --fg: #1e2430;
  --muted: #687080;
  --subtle: #8b92a0;
  --card: #ffffff;
  --card-soft: #f0eee8;
  --line: #dedfdc;
  --line-strong: #c9cbc8;
  --accent: #6458d6;
  --accent-hover: #5549c5;
  --accent-soft: #eeecff;
  --accent-fg: #ffffff;
  --male: #2f7dd6;
  --female: #c94b6b;
  --unknown-sex: #8b92a0;
  --danger: #bd3f4b;
  --danger-soft: #fff0f1;
  --ok: #20815a;
  --ok-soft: #e7f6ee;
  --warn: #a86417;
  --warn-soft: #fff3dd;
  --shadow-sm: 0 1px 2px rgb(30 36 48 / .04), 0 6px 18px rgb(30 36 48 / .04);
  --shadow-md: 0 18px 50px rgb(31 34 49 / .12);
  --radius-sm: 10px;
  --radius: 16px;
  --radius-lg: 24px;
  --font-sans: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-display: Iowan Old Style, Charter, "Palatino Linotype", Georgia, serif;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #121419;
  --bg-elevated: #171a20;
  --fg: #f0f1f4;
  --muted: #a2a8b3;
  --subtle: #7d8490;
  --card: #1c1f26;
  --card-soft: #242830;
  --line: #30343d;
  --line-strong: #414650;
  --accent: #a49aff;
  --accent-hover: #b8b1ff;
  --accent-soft: #2a274b;
  --accent-fg: #171525;
  --male: #78b6ff;
  --female: #ff8dad;
  --unknown-sex: #7d8490;
  --danger: #ff8b95;
  --danger-soft: #3a2328;
  --ok: #69d3a2;
  --ok-soft: #19382d;
  --warn: #f0b768;
  --warn-soft: #3b3020;
  --shadow-sm: 0 1px 2px rgb(0 0 0 / .16), 0 8px 24px rgb(0 0 0 / .13);
  --shadow-md: 0 20px 60px rgb(0 0 0 / .38);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scrollbar-gutter: stable; scroll-behavior: smooth; }
body {
  min-height: 100vh;
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
body::before {
  position: fixed;
  z-index: -1;
  inset: 0;
  background:
    radial-gradient(circle at 6% 0%, color-mix(in srgb, var(--accent) 8%, transparent), transparent 30rem),
    radial-gradient(circle at 96% 25%, color-mix(in srgb, var(--warn) 5%, transparent), transparent 28rem);
  content: "";
  pointer-events: none;
}
button, input, select, textarea { font: inherit; }
button, input, select, textarea {
  min-height: 42px;
  padding: .6rem .8rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--card);
  color: var(--fg);
  transition: border-color .16s ease, background .16s ease, box-shadow .16s ease, color .16s ease, transform .16s ease;
}
button { display: inline-flex; align-items: center; justify-content: center; gap: .45rem; cursor: pointer; font-weight: 650; }
button:hover:not(:disabled) { border-color: var(--line-strong); background: var(--card-soft); }
button:active:not(:disabled) { transform: translateY(1px); }
button:disabled { cursor: not-allowed; opacity: .5; }
button.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-fg);
  box-shadow: 0 8px 18px color-mix(in srgb, var(--accent) 20%, transparent);
}
button.primary:hover:not(:disabled) { border-color: var(--accent-hover); background: var(--accent-hover); }
button.danger { border-color: var(--danger); background: var(--danger); color: #fff; }
button.danger:hover:not(:disabled) { border-color: var(--danger); background: color-mix(in srgb, var(--danger) 88%, black); }
button.ghost { border-color: transparent; background: transparent; box-shadow: none; }
button.ghost:hover:not(:disabled) { border-color: var(--line); background: var(--card-soft); }
button.icon-button { width: 40px; min-height: 40px; padding: 0; }
button.compact { min-height: 30px; padding: .25rem .45rem; font-size: .75rem; }
input, select, textarea { width: 100%; }
textarea { min-height: 86px; resize: vertical; }
input:hover, select:hover, textarea:hover { border-color: var(--line-strong); }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 15%, transparent);
}
input[type="search"] {
  padding-left: 2.45rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%23838a96' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-4-4'/%3E%3C/svg%3E");
  background-position: .8rem center;
  background-repeat: no-repeat;
}
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent) 35%, transparent);
  outline-offset: 2px;
}
a { color: var(--accent); }
.wrap { width: min(100% - 2rem, 1180px); margin: 0 auto; }
.msym { width: 20px; height: 20px; flex: none; vertical-align: -4px; }
#theme-btn .icon-light { display: none; }
:root[data-theme="dark"] #theme-btn .icon-dark { display: none; }
:root[data-theme="dark"] #theme-btn .icon-light { display: block; }
.meta { color: var(--muted); font-size: .8rem; }
.eyebrow {
  margin: 0;
  color: var(--accent);
  font-size: .7rem;
  font-weight: 800;
  letter-spacing: .16em;
  text-transform: uppercase;
}
.error { color: var(--danger); }
.ok { color: var(--ok); }

/* Brand */
.brand {
  display: inline-flex;
  align-items: center;
  flex: none;
  gap: .65rem;
  min-height: auto;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--fg);
  text-align: left;
  box-shadow: none;
}
.brand:hover:not(:disabled) { border: 0; background: transparent; }
.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-fg);
}
.vitruvian-icon { width: 32px; height: 32px; }
.brand-copy { display: flex; flex-direction: column; line-height: 1.18; }
.brand-copy strong { font-family: var(--font-display); font-size: 1.08rem; letter-spacing: -.015em; }
.brand-copy small { color: var(--muted); font-size: .67rem; font-weight: 500; }
.brand-context {
  display: inline-flex;
  align-items: center;
  max-width: 220px;
  gap: .42rem;
  overflow: hidden;
  color: var(--fg);
  font-size: .84rem;
  font-weight: 750;
  white-space: nowrap;
}
.brand-context span { overflow: hidden; text-overflow: ellipsis; }
.brand-context .msym { width: 18px; height: 18px; color: var(--accent); }

/* App shell */
.app-shell { padding-bottom: 0; }
.app-header {
  position: sticky;
  z-index: 30;
  top: 0;
  display: flex;
  align-items: center;
  gap: 1rem;
  min-height: 60px;
  margin-inline: calc(50% - 50vw);
  padding: .5rem 1rem;
  border-bottom: 1px solid color-mix(in srgb, var(--line) 78%, transparent);
  background: color-mix(in srgb, var(--bg-elevated) 88%, transparent);
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(18px);
}
.app-nav { display: flex; flex: 1; justify-content: center; gap: .2rem; }
.app-nav button {
  min-height: 40px;
  padding: .5rem .72rem;
  color: var(--muted);
  font-size: .78rem;
  white-space: nowrap;
}
.app-nav button .msym { width: 18px; height: 18px; }
.app-nav button.active { border-color: transparent; background: var(--accent-soft); color: var(--accent); }
.account-bar { display: flex; align-items: center; flex: none; gap: .25rem; }
/* Header + main fill the viewport exactly, so the graph view never produces
   a page scrollbar. dvh tracks the real visible viewport on mobile browsers,
   where 100vh includes the collapsed URL bar. */
.app-main {
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 60px);
  min-height: calc(100dvh - 60px);
  padding-top: 1.5rem;
}

/* Public welcome page */
.public-page { min-height: 100vh; background: var(--bg-elevated); }
.public-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: min(100% - 2rem, 1180px);
  min-height: 82px;
  margin: 0 auto;
  border-bottom: 1px solid var(--line);
}
.public-main { width: min(100% - 2rem, 1180px); margin: 0 auto; }
.public-hero {
  display: grid;
  align-content: center;
  min-height: calc(100vh - 340px);
  padding: 4rem 0 3rem;
}
.public-hero h1 {
  max-width: 860px;
  margin: .9rem 0 0;
  font-family: var(--font-display);
  font-size: clamp(2.6rem, 6vw, 5.4rem);
  font-weight: 500;
  letter-spacing: -.055em;
  line-height: .98;
}
.public-hero p:not(.eyebrow) {
  max-width: 640px;
  margin: 1.5rem 0 0;
  color: var(--muted);
  font-size: clamp(1rem, 1.6vw, 1.18rem);
  line-height: 1.7;
}
.public-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 1rem 1.25rem; margin-top: 2rem; }
.public-actions .primary { min-height: 50px; padding-inline: 1.2rem; }
.public-actions .primary::after { content: "→"; display: inline-block; transition: transform .16s ease; }
.public-actions .primary:hover::after { transform: translateX(3px); }
.public-explain {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: .9rem;
  padding: 1rem 0 3rem;
}
.public-explain article {
  min-height: 220px;
  padding: 1.5rem;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--card);
  box-shadow: var(--shadow-sm);
}
.public-explain strong { display: block; margin-bottom: 2.4rem; color: var(--accent); font-size: .7rem; font-weight: 800; letter-spacing: .12em; }
.public-explain h2 { margin: 0; font-family: var(--font-display); font-size: 1.35rem; font-weight: 600; }
.public-explain p { margin: .65rem 0 0; color: var(--muted); font-size: .85rem; line-height: 1.6; }

/* View headings and toolbars */
.view-heading { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: .8rem; }
.view-heading > div { min-width: 0; flex: 1; }
.view-heading h1 { margin: .15rem 0; font-family: var(--font-display); font-size: 1.55rem; font-weight: 600; letter-spacing: -.02em; }
.view-heading p:not(.eyebrow) { margin: 0; color: var(--muted); font-size: .82rem; line-height: 1.4; }
.view-heading > .primary { flex: none; min-height: 40px; padding-inline: .9rem; box-shadow: none; }
.toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: .55rem;
  margin-bottom: 1rem;
  padding: .55rem;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--card);
  box-shadow: var(--shadow-sm);
}
.toolbar input, .toolbar select, .toolbar .seg { border-color: transparent; background-color: var(--card-soft); }
.toolbar > .primary { flex: none; box-shadow: none; }
.toolbar input[type="search"] { flex: 1 1 240px; width: auto; min-width: 170px; }
#contacts-copy select { flex: 1 1 200px; width: auto; }
#contacts-copy .primary { flex: none; }
.view-actions { display: flex; justify-content: flex-end; margin-bottom: .8rem; }
.view-actions .primary { box-shadow: none; }
.toolbar #graph-depth { flex: 0 0 160px; width: 160px; }
.seg { display: inline-flex; width: auto; overflow: hidden; border: 1px solid var(--line); border-radius: 10px; }
.seg button { min-height: 38px; padding: .4rem .65rem; border: 0; border-radius: 0; background: transparent; box-shadow: none; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button.active { background: var(--accent); color: var(--accent-fg); }
.graph-tools { flex: 0 0 auto; background: var(--card-soft); }
.graph-tools button { width: 40px; min-height: 40px; color: var(--accent); }
.graph-tools .msym { width: 20px; height: 20px; }

/* Grids, cards, and lists */
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: .8rem; }
.grid > .empty-state { grid-column: 1 / -1; }
.card {
  padding: 1rem 1.05rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow-sm);
  transition: border-color .16s ease, box-shadow .16s ease;
}
.card:hover { border-color: color-mix(in srgb, var(--accent) 35%, var(--line)); box-shadow: 0 12px 30px rgb(30 36 48 / .07); }
.card h3 { margin: 0 0 .35rem; font-family: var(--font-display); font-size: 1.12rem; font-weight: 600; }
.card-actions { display: flex; gap: .5rem; margin-top: .7rem; }
.empty-state {
  display: grid;
  min-height: 240px;
  place-items: center;
  align-content: center;
  padding: 2.5rem 1rem;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--card) 58%, transparent);
  text-align: center;
}
.empty-state .empty-icon {
  display: grid;
  width: 46px;
  height: 46px;
  place-items: center;
  margin-bottom: .8rem;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
}
.empty-state p { max-width: 360px; margin: 0; color: var(--muted); font-size: .88rem; }
.pill {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  min-height: 24px;
  padding: .15rem .55rem;
  border-radius: 999px;
  background: var(--card-soft);
  color: var(--muted);
  font-size: .7rem;
  font-weight: 700;
  line-height: 1.25;
}
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.stack { display: grid; gap: .7rem; }
.mini-list { display: grid; gap: .45rem; margin-top: .8rem; }
.card > .mini-list:first-child { margin-top: 0; }
.row-select {
  display: flex;
  align-items: flex-start;
  flex-direction: column;
  gap: .1rem;
  width: 100%;
  border-color: transparent;
  background: transparent;
  text-align: left;
}
.row-select.active { border-color: var(--accent); background: var(--accent-soft); }
.mini-row { display: flex; align-items: center; justify-content: space-between; gap: .6rem; color: var(--muted); font-size: .82rem; }
.field-label { margin: 0 0 .35rem; color: var(--muted); font-size: .82rem; font-weight: 700; }
.flag-picker { display: flex; gap: .4rem; }
.flag-picker button { width: 48px; min-height: 42px; padding: 0; font-size: 1.25rem; }
.flag-picker button.active { border-color: var(--accent); background: var(--accent-soft); }

/* Settings tabs */
.settings-tabs {
  display: flex;
  gap: .25rem;
  width: fit-content;
  max-width: 100%;
  margin-bottom: 1rem;
  padding: .25rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card-soft);
}
.settings-tabs button { min-height: 36px; padding: .4rem .85rem; border: 0; background: transparent; box-shadow: none; color: var(--muted); font-size: .78rem; }
.settings-tabs button.active { background: var(--card); color: var(--fg); box-shadow: 0 1px 5px rgb(30 36 48 / .1); }
.settings-panels { max-width: 680px; }

/* Help view */
.help-flow {
  display: grid;
  grid-template-columns: 1fr auto 1fr auto 1fr auto 1fr;
  align-items: stretch;
  gap: .6rem;
  margin-bottom: 2rem;
}
.help-role {
  padding: 1.1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow-sm);
}
.help-role h2 { margin: .65rem 0 .3rem; font-family: var(--font-display); font-size: 1.1rem; font-weight: 600; }
.help-role p { margin: 0; color: var(--muted); font-size: .8rem; line-height: 1.5; }
.help-role.vault {
  border-color: color-mix(in srgb, var(--accent) 35%, var(--line));
  background: color-mix(in srgb, var(--accent-soft) 40%, var(--card));
}
.help-icon {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
}
.help-arrow {
  display: grid;
  align-content: center;
  justify-items: center;
  max-width: 120px;
  gap: .2rem;
  color: var(--muted);
  font-size: .68rem;
  font-weight: 700;
  text-align: center;
}
.help-arrow::before { content: "→"; color: var(--accent); font-size: 1.35rem; font-weight: 700; }
.help-section { margin: 0 0 .8rem; }
.help-principles .card h3 { margin-top: .65rem; }
.help-note { margin-top: 1.2rem; }

/* Tables */
.table-wrap { overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); box-shadow: var(--shadow-sm); }
table { width: 100%; border-collapse: collapse; }
th, td { padding: .75rem .7rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; font-size: .84rem; }
th { background: var(--card-soft); color: var(--muted); font-size: .68rem; font-weight: 750; letter-spacing: .06em; text-transform: uppercase; }
tbody tr:last-child td { border-bottom: 0; }

/* Relationship graph: full-bleed, flexing to fill the space below the header. */
#view-tree {
  display: flex;
  flex: 1;
  flex-direction: column;
  margin-top: -1.5rem;
}
.graph-shell {
  position: relative;
  flex: 1;
  min-height: 360px;
  margin-inline: calc(50% - 50vw);
  overflow: hidden;
  border: 0;
  background: var(--card);
}
.graph-shell:fullscreen {
  width: 100vw;
  height: 100vh;
  border: 0;
  border-radius: 0;
}
.graph-toolbar {
  position: absolute;
  z-index: 5;
  top: 0;
  right: 0;
  left: 0;
  margin: 0;
  padding: .32rem;
  border: 0;
  border-radius: 0;
  background: var(--card);
  box-shadow: none;
}
.graph-toolbar input,
.graph-toolbar select,
.graph-toolbar button {
  min-height: 32px;
  padding: .35rem .55rem;
}
.graph-toolbar input[type="search"] { padding-left: 2.2rem; background-position: .6rem center; }
.graph-shell:fullscreen .relationship-graph {
  height: 100vh !important;
  min-height: 100vh;
}
.relationship-graph {
  display: block;
  width: 100%;
  max-width: none;
  min-height: 420px;
  cursor: grab;
  touch-action: none;
  user-select: none;
}
.relationship-graph.dragging { cursor: grabbing; }
.graph-edge {
  fill: none;
  stroke: var(--line-strong);
  stroke-width: 2;
}
.graph-edge.parent { stroke: var(--accent); }
.family-connector.hover-focus .graph-edge.parent {
  stroke-width: 3.2;
  filter: drop-shadow(0 0 5px color-mix(in srgb, var(--accent) 45%, transparent));
}
.graph-edge.spouse {
  stroke: var(--warn);
  stroke-dasharray: 7 5;
}
.marriage-marker {
  cursor: help;
  fill: var(--card);
  stroke: var(--warn);
  stroke-width: 2;
}
.marriage-marker:hover { fill: var(--warn-soft); }
.family-marker {
  fill: var(--card);
  stroke: var(--accent);
  stroke-width: 2;
}
.family-marker:hover { fill: var(--accent-soft); }
.family-connector.hover-focus .family-marker { fill: var(--accent-soft); }
.graph-node { cursor: pointer; }
.graph-node rect {
  fill: var(--bg-elevated);
  stroke: var(--unknown-sex);
  stroke-width: 1.3;
}
.graph-node.male rect { stroke: var(--male); }
.graph-node.female rect { stroke: var(--female); }
.graph-node.unknown-sex rect { stroke: var(--unknown-sex); }
.graph-node:hover rect,
.graph-node.focused rect,
.graph-node.hover-focus rect {
  fill: var(--accent-soft);
  stroke-width: 2;
}
.graph-node.deceased rect { fill: var(--warn-soft); }
.graph-node text {
  fill: var(--fg);
  font-size: 12px;
  font-weight: 750;
  pointer-events: none;
}
.graph-node .graph-date {
  fill: var(--muted);
  font-size: 10px;
  font-weight: 550;
}
.graph-empty { fill: var(--muted); font-size: 14px; }

/* Dialogs and notifications */
.banner {
  position: fixed;
  z-index: 90;
  top: 1rem;
  left: 50%;
  width: max-content;
  max-width: min(640px, 92vw);
  margin: 0;
  padding: .75rem 1rem;
  transform: translateX(-50%);
  border: 1px solid color-mix(in srgb, var(--danger) 40%, var(--line));
  border-radius: 12px;
  background: var(--card);
  box-shadow: var(--shadow-md);
  cursor: pointer;
  font-size: .84rem;
}
.banner.success { border-color: color-mix(in srgb, var(--ok) 40%, var(--line)); color: var(--ok); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .7rem; }
.form-grid .full { grid-column: 1 / -1; }
.form-actions { display: flex; justify-content: flex-end; gap: .5rem; }
.checkbox-label { display: flex; align-items: center; gap: .5rem; }
.checkbox-label input { width: auto; min-height: auto; }
.modal-backdrop {
  position: fixed;
  z-index: 80;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgb(11 13 18 / .55);
  backdrop-filter: blur(7px);
}
.modal {
  width: min(720px, 100%);
  max-height: 88vh;
  overflow-y: auto;
  padding: 1.25rem 1.35rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--card);
  box-shadow: var(--shadow-md);
  animation: modal-in .18s ease-out;
}
.modal h1 { font-family: var(--font-display); font-weight: 600; letter-spacing: -.02em; }
@keyframes modal-in { from { opacity: 0; transform: translateY(8px) scale(.985); } }
.modal-auth { width: min(520px, 100%); }
.modal-application { width: min(540px, 100%); }
.modal-person { width: min(620px, 100%); }
.modal-invite { width: min(620px, 100%); }
.modal-contact { width: min(560px, 100%); }
.modal-report { width: min(560px, 100%); }
.modal-confirm { width: min(480px, 100%); }
.modal-actions { display: flex; justify-content: flex-end; gap: .5rem; margin-top: 1rem; }
.complaint-modal {
  border-color: var(--danger);
  background: color-mix(in srgb, var(--danger-soft) 54%, var(--card));
}
.complaint-modal .eyebrow,
.complaint-modal h1,
.complaint-modal #abuse-recipient-note { color: var(--danger); }

.version-tag {
  flex: none;
  color: var(--subtle);
  font-size: .66rem;
  white-space: nowrap;
}

/* Responsive behavior */
@media (max-width: 1100px) {
  /* The nav buttons no longer fit beside the brand: the nav becomes a
     full-width bottom bar, and the top bar — brand and account — stays sticky.
     The shell padding reserves exactly the bar's height. */
  .app-shell { padding-bottom: calc(3.9rem + env(safe-area-inset-bottom, 0px)); }
  /* backdrop-filter makes an ancestor the containing block for fixed
     children — a solid background replaces the blur on the header. */
  .app-header { min-height: 58px; background: var(--bg-elevated); backdrop-filter: none; }
  .account-bar { margin-left: auto; }
  .app-nav {
    position: fixed;
    z-index: 35;
    right: 0;
    bottom: 0;
    left: 0;
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: 1fr;
    width: auto;
    padding: .35rem .35rem max(.35rem, env(safe-area-inset-bottom));
    border-top: 1px solid var(--line);
    background: color-mix(in srgb, var(--bg-elevated) 92%, transparent);
    box-shadow: var(--shadow-md);
    backdrop-filter: blur(18px);
  }
  .app-nav button { flex-direction: column; gap: .15rem; min-width: 0; min-height: 49px; padding: .35rem .1rem; font-size: .58rem; }
  .app-nav button span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
  .app-nav button .msym { width: 19px; height: 19px; }
  .help-flow { grid-template-columns: 1fr; }
  .help-arrow { max-width: none; padding: .15rem 0; }
  .help-arrow::before { content: "↓"; }
  /* Leave room for the fixed bottom navigation. */
  .app-main {
    min-height: calc(100vh - 58px - 3.9rem - env(safe-area-inset-bottom, 0px));
    min-height: calc(100dvh - 58px - 3.9rem - env(safe-area-inset-bottom, 0px));
  }
}

@media (max-width: 760px) {
  .wrap { width: min(100% - 1.2rem, 1180px); }
  .app-header { padding: .55rem .8rem; }
  .brand-context { max-width: 160px; }
  .brand-mark { width: 40px; height: 40px; }
  .vitruvian-icon { width: 30px; height: 30px; }
  .app-main { padding-top: 1.15rem; }
  .view-heading { align-items: center; gap: .55rem; margin-bottom: .6rem; }
  .view-heading .eyebrow { font-size: .62rem; }
  .view-heading p:not(.eyebrow) { font-size: .73rem; }
  .view-heading > .primary { padding-inline: .7rem; white-space: nowrap; }
  .toolbar { align-items: stretch; flex-direction: column; }
  /* In a column toolbar the flex-basis of inputs/selects would become their
     height: reset them to natural size, full width. */
  .toolbar input[type="search"], .toolbar select { flex: 0 0 auto; width: 100%; }
  /* The graph toolbar stays on a single compact row. */
  .graph-toolbar { flex-flow: row nowrap; align-items: center; gap: .3rem; }
  .graph-toolbar input[type="search"] { flex: 1 1 80px; width: auto; min-width: 0; padding-left: 1.9rem; background-position: .5rem center; }
  .toolbar select#graph-depth { flex: 0 0 auto; width: auto; padding: .35rem .3rem; font-size: .78rem; }
  .graph-toolbar .graph-tools button { width: 30px; min-height: 30px; }
  .graph-toolbar .graph-tools .msym { width: 17px; height: 17px; }
  .graph-toolbar #graph-reset { padding: .35rem .4rem; font-size: .78rem; }
  .settings-tabs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); width: 100%; }
  .settings-tabs button { min-width: 0; padding-inline: .35rem; font-size: .76rem; }
  .settings-panels { max-width: none; }
  .form-grid { grid-template-columns: 1fr; }
  .modal { padding: 1rem; border-radius: 18px; }
  .table-wrap { overflow: visible; border: 0; border-radius: 0; background: transparent; box-shadow: none; }
  .table-wrap table, .table-wrap tbody, .table-wrap tr, .table-wrap td { display: block; width: 100%; }
  .table-wrap thead { display: none; }
  .table-wrap tr { margin: .65rem 0; padding: .65rem .75rem; border: 1px solid var(--line); border-radius: 13px; background: var(--card); box-shadow: var(--shadow-sm); }
  .table-wrap td { display: flex; align-items: baseline; gap: .5rem; padding: .2rem 0; border: 0; }
  .table-wrap td[data-label]::before { min-width: 6.5rem; flex: none; color: var(--muted); content: attr(data-label); font-size: .68rem; font-weight: 750; text-transform: uppercase; }
  .table-wrap td:empty { display: none; }
  .public-explain { grid-template-columns: 1fr; }
  .public-explain article { min-height: 0; }
  .public-explain strong { margin-bottom: 1.6rem; }
  .public-hero { min-height: auto; padding: 3rem 0 2rem; }
}

@media (max-width: 600px) {
  .app-nav button span {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }
  .app-nav button { min-height: 44px; }
  .brand-copy small { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
