:root {
  color-scheme: light;
  /* Editorial Directory (Ledger-B) palette, app-wide since 2026-11-05:
     warm paper, brass, deep green, hairline rules. */
  --bg: #f6f1e5;
  --card-bg: #fffdf6;
  --border: #ddd2bd;
  --border-dark: #b8a888;
  --text: #2b2119;
  --soft: #57493a;
  --muted: #8a7a63;
  --accent: #a87f3d;
  --accent-dark: #8a6527;
  --green: #33513f;
  --danger: #b3382e;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Source Serif 4", Georgia, "Times New Roman", serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
}

a { color: var(--accent-dark); text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 12px 24px;
  background: var(--card-bg);
  border-bottom: 3px double var(--text);
}
.topbar .brand { font-family: "Playfair Display", Georgia, serif; font-weight: 800; font-size: 1.25em; color: var(--text); letter-spacing: .01em; }
.topbar nav { display: flex; gap: 18px; flex: 1; }
.topbar nav a { font-size: .78em; letter-spacing: .16em; text-transform: uppercase; color: var(--soft); }
.topbar nav a:hover { color: var(--accent-dark); text-decoration: none; border-bottom: 2px solid var(--accent); }
.logout-form { display: flex; align-items: center; gap: 10px; margin: 0; }
.logout-form button { font-size: .78em; letter-spacing: .12em; text-transform: uppercase; padding: 6px 12px; }
.current-user { color: var(--muted); font-size: 0.9em; font-style: italic; }

.container {
  max-width: 960px;
  margin: 0 auto;
  padding: 24px 16px 64px;
}

h1 { font-family: "Playfair Display", Georgia, serif; font-size: 2em; font-weight: 800; margin: 0 0 12px; padding-bottom: 8px; border-bottom: 3px double var(--text); }
h2 { font-size: .82em; letter-spacing: .2em; text-transform: uppercase; margin: 0 0 10px; color: var(--accent-dark); font-weight: 700; }

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 16px;
}

.button, button {
  display: inline-block;
  padding: 8px 16px;
  border-radius: 3px;
  border: 1px solid var(--border-dark);
  background: var(--card-bg);
  color: var(--text);
  cursor: pointer;
  font-family: inherit;
  font-size: .85em;
  letter-spacing: .1em;
  text-transform: uppercase;
}
.button.primary, button[type="submit"] {
  background: var(--green);
  border-color: var(--green);
  color: #fffdf6;
}
.button.primary:hover, button[type="submit"]:hover { background: #27402f; border-color: #27402f; }
.button.danger, .danger button { background: #fdf3f1; border-color: var(--danger); color: var(--danger); text-transform: uppercase; }
.button.danger:hover { background: #fbe7e3; }
.danger-zone { border-color: var(--danger); }
.danger-zone h2 { color: var(--danger); }
.button-row { display: flex; gap: 10px; }
.button-row form { margin: 0; }

button.link-button, .link-button {
  background: none;
  border: none;
  padding: 0;
  color: var(--accent-dark);
  cursor: pointer;
  font-family: inherit;
  font-size: 0.88em;
  letter-spacing: normal;
  text-transform: none;
  text-decoration: underline;
}
.link-button:hover { background: none; color: var(--text); }

.search-bar { display: flex; gap: 10px; margin-bottom: 20px; flex-wrap: wrap; }
.search-bar input[type="text"] { flex: 1; min-width: 180px; }
.search-bar select, .search-bar input, input[type="text"], input[type="email"], input[type="password"],
input[type="date"], input[type="file"], select, textarea {
  padding: 8px 10px;
  border: 1px solid var(--border-dark);
  border-radius: 3px;
  font-family: inherit;
  font-size: 0.95em;
  background: var(--card-bg);
  color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px rgba(168, 127, 61, .18); }
textarea { width: 100%; font-family: inherit; }
.clear-link { align-self: center; }

.contact-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
}
.contact-card {
  display: flex;
  gap: 12px;
  padding: 14px;
  background: var(--card-bg);
  border: 1px solid var(--border-dark);
  border-radius: 4px;
  color: var(--text);
  box-shadow: 0 1px 0 rgba(43,33,25,.05);
}
.contact-card:hover { border-color: var(--accent); text-decoration: none; background: rgba(168, 127, 61, .05); }
.avatar {
  width: 48px; height: 48px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fffdf6, #f1e7cf); flex-shrink: 0;
  border: 1.5px solid var(--accent);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden; position: relative; color: var(--accent-dark);
  font-family: "Playfair Display", Georgia, serif;
  font-weight: 700;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; position: absolute; inset: 0; }
.contact-name { font-weight: 600; }
.contact-sub { color: var(--muted); font-size: 0.88em; }
.nickname { color: var(--muted); font-weight: 400; font-size: 0.85em; margin-left: 6px; }
.favorite-star { color: var(--accent); margin-right: 4px; }

.empty-state { color: var(--muted); padding: 24px 0; font-style: italic; }

.auth-card {
  max-width: 380px;
  margin: 48px auto;
  background: var(--card-bg);
  border: 1px solid var(--border-dark);
  border-radius: 4px;
  padding: 28px;
  box-shadow: 0 1px 0 rgba(43,33,25,.06), 0 10px 30px rgba(43,33,25,.07);
}
.auth-card form { display: flex; flex-direction: column; gap: 14px; }
.auth-card label { display: flex; flex-direction: column; gap: 4px; font-size: 0.9em; color: var(--muted); }
.auth-alt { margin-top: 16px; font-size: 0.9em; text-align: center; }
.flash-error { color: var(--danger); background: #fdf3f1; border: 1px solid #e5b6b0; padding: 8px 12px; border-radius: 3px; }
.flash-success { color: var(--green); background: #f2f5ec; border: 1px solid #b9c4a5; padding: 8px 12px; border-radius: 3px; }
.hint { color: var(--muted); font-size: 0.9em; font-style: italic; }

.detail-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 24px; align-items: start; }
.detail-section {
  background: var(--card-bg);
  border: 1px solid var(--border-dark);
  border-radius: 4px;
  padding: 18px 20px;
  margin-bottom: 18px;
  box-shadow: 0 1px 0 rgba(43,33,25,.05), 0 8px 24px rgba(43,33,25,.05);
}
.detail-line { color: var(--muted); }
.field-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.field-type { display: inline-block; min-width: 70px; color: var(--muted); font-size: 0.85em; text-transform: uppercase; letter-spacing: 0.03em; }
.primary-badge { font-size: 0.75em; color: var(--accent-dark); border: 1px solid var(--accent); border-radius: 10px; padding: 1px 6px; margin-left: 6px; }
.muted { color: var(--muted); }
.notes-block { white-space: pre-wrap; }

.tag-list { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; }
.tag-pill { background: #f1e7cf; color: var(--text); border: 1px solid var(--border); border-radius: 14px; padding: 3px 10px; font-size: 0.82em; }
.tag-checkboxes { display: flex; gap: 12px; flex-wrap: wrap; }
.checkbox-label { display: inline-flex; align-items: center; gap: 6px; font-size: 0.9em; }
.checkbox-label.small { font-size: 0.8em; color: var(--muted); }

.relationship-form { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.inline-form { display: inline; margin-left: 6px; }

.image-gallery { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 12px; }
.image-tile { position: relative; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.image-tile img { width: 100%; height: 110px; object-fit: cover; display: block; }
.image-tile-actions { display: flex; flex-direction: column; gap: 2px; padding: 6px; font-size: 0.78em; background: var(--card-bg); }
.upload-form { display: flex; flex-direction: column; gap: 8px; }

.contact-form .form-row { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.contact-form label { display: flex; flex-direction: column; gap: 4px; font-size: 0.85em; color: var(--muted); flex: 1; min-width: 160px; }
.repeat-row { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; flex-wrap: wrap; }
.address-row input { flex: 1; min-width: 100px; }
.remove-row-btn { background: none; border: none; color: var(--danger); cursor: pointer; font-size: 1em; }
.add-row-btn { background: none; border: 1px dashed var(--border-dark); color: var(--accent-dark); text-transform: none; letter-spacing: normal; font-size: .92em; }

.tag-form { display: flex; gap: 8px; margin-bottom: 16px; align-items: center; }
.tag-manage-list { list-style: none; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.tag-manage-list li { display: flex; align-items: center; gap: 12px; }

@media (max-width: 720px) {
  .detail-grid { grid-template-columns: 1fr; }
  .topbar { flex-wrap: wrap; }
}

/* Google import preview / mapping tables */
.data-table { width: 100%; border-collapse: collapse; margin: 12px 0; font-size: 0.95em; }
.data-table th, .data-table td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
.data-table th { color: var(--accent-dark); font-weight: 700; font-size: 0.78em; text-transform: uppercase; letter-spacing: 0.14em; border-bottom: 1px solid var(--border-dark); }
.data-table tbody tr:hover td { background: rgba(168, 127, 61, .05); }
.data-table tr.dup-row td { background: #fdf6e0; }
.dup-badge { display: inline-block; font-size: 0.8em; font-weight: 600; color: #7c4a03; background: #f7e8c3; border: 1px solid #d9b96a; border-radius: 999px; padding: 1px 8px; margin-left: 8px; white-space: nowrap; }
.tag-chip { display: inline-block; font-size: 0.8em; background: #f1e7cf; border: 1px solid var(--border); border-radius: 999px; padding: 1px 8px; margin: 1px 2px; white-space: nowrap; }
.preview-actions { display: flex; gap: 10px; align-items: center; margin: 14px 0; flex-wrap: wrap; }

/* =====================================================================
   Constellation home page (dashboard). Dark "night sky" panels inside
   the regular app chrome; all classes are cx- prefixed to avoid
   clashing with the light theme used by the other pages.
   ===================================================================== */
main.container:has(.constellation-wrap) { max-width: 1480px; }

.constellation-wrap {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --cx-panel: rgba(13, 25, 45, .97);
  --cx-line: rgba(148, 178, 220, .18);
  --cx-ink: #F4EDDE;
  --cx-muted: #A8B4C6;
  --cx-faint: #71809A;
  --cx-brass: #C9A86A;
  --cx-brass2: #E7CD8F;
  --cx-teal: #6FD3C2;
  display: grid;
  grid-template-columns: 272px minmax(0, 1fr) 330px;
  gap: 16px;
  align-items: start;
  color: var(--cx-ink);
}
.constellation-wrap .cx-h {
  font-size: 11.5px; letter-spacing: .18em; text-transform: uppercase;
  color: var(--cx-brass2); margin: 18px 0 9px; font-weight: 700;
}
.constellation-wrap .cx-h:first-child { margin-top: 0; }
.cx-hint { color: var(--cx-faint); font-size: 12.5px; margin: 8px 2px 0; }

.cx-rail, .cx-stage, .cx-dossier {
  background: var(--cx-panel);
  border: 1px solid var(--cx-line);
  border-radius: 18px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, .18);
}
.cx-rail { padding: 16px; position: sticky; top: 16px; }
.cx-search { position: relative; }
.cx-search input {
  width: 100%; padding: 12px 38px 12px 14px; border-radius: 12px;
  border: 1px solid var(--cx-line); background: rgba(255, 255, 255, .05);
  color: var(--cx-ink); font-size: 15px; outline: none;
}
.cx-search input:focus { border-color: var(--cx-brass); }
.cx-key {
  position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
  color: var(--cx-faint); font-size: 13px; border: 1px solid var(--cx-line);
  border-radius: 6px; padding: 1px 6px;
}
.cx-seg { display: grid; grid-template-columns: 1fr 1fr 1fr; background: rgba(255, 255, 255, .05); border: 1px solid var(--cx-line); border-radius: 999px; padding: 3px; gap: 3px; }
.cx-seg button { border: 0; background: transparent; color: var(--cx-muted); border-radius: 999px; padding: 8px 4px; font-size: 13px; cursor: pointer; }
.cx-seg button.active { background: var(--cx-brass); color: #1B1405; font-weight: 650; }
.cx-chips { display: flex; flex-wrap: wrap; gap: 7px; }
.cx-chip { border: 1px solid var(--cx-line); background: rgba(255, 255, 255, .04); color: var(--cx-muted); border-radius: 999px; padding: 6px 11px; font-size: 12.5px; cursor: pointer; }
.cx-chip.active { border-color: var(--cx-brass); color: #1B1405; background: var(--cx-brass); font-weight: 650; }
.cx-toggle { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 9px 0; border-bottom: 1px dashed rgba(148, 178, 220, .14); font-size: 14px; cursor: pointer; }
.cx-toggle small { display: block; color: var(--cx-faint); font-size: 12px; margin-top: 2px; }
.cx-switch { position: relative; width: 46px; height: 26px; flex: 0 0 auto; }
.cx-switch input { opacity: 0; width: 0; height: 0; }
.cx-track { position: absolute; inset: 0; border-radius: 999px; background: rgba(255, 255, 255, .12); border: 1px solid var(--cx-line); transition: .18s; }
.cx-track:before { content: ""; position: absolute; width: 20px; height: 20px; left: 2px; top: 2px; border-radius: 50%; background: #D8DEE9; transition: .18s; }
.cx-switch input:checked + .cx-track { background: rgba(201, 168, 106, .85); border-color: var(--cx-brass); }
.cx-switch input:checked + .cx-track:before { transform: translateX(20px); background: #1B1405; }
.cx-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.cx-stat { border: 1px solid var(--cx-line); border-radius: 14px; padding: 11px 12px; background: rgba(255, 255, 255, .03); }
.cx-stat b { font-family: Georgia, 'Times New Roman', serif; font-size: 25px; font-weight: 500; display: block; line-height: 1; color: var(--cx-ink); }
.cx-stat span { color: var(--cx-faint); font-size: 11.5px; letter-spacing: .08em; text-transform: uppercase; }
.cx-btn {
  display: block; text-align: center; border: 1px solid var(--cx-line);
  background: rgba(255, 255, 255, .04); color: var(--cx-ink);
  border-radius: 999px; padding: 9px 14px; font-size: 13.5px; cursor: pointer;
  text-decoration: none;
}
.cx-btn:hover { border-color: var(--cx-brass); color: var(--cx-brass2); text-decoration: none; }
.cx-wide { width: 100%; margin-top: 9px; }

.cx-stage { overflow: hidden; }
.cx-stagebar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 13px 16px; border-bottom: 1px solid var(--cx-line); flex-wrap: wrap; }
.cx-stagebar h2 { font-family: Georgia, 'Times New Roman', serif; font-size: 21px; font-weight: 500; margin: 0; color: var(--cx-ink); display: inline; }
.cx-sub { color: var(--cx-faint); font-size: 12.5px; margin-left: 9px; }
.cx-zoom { display: flex; gap: 7px; align-items: center; }
.cx-zoom button { width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--cx-line); background: rgba(255, 255, 255, .04); color: var(--cx-ink); font-size: 17px; line-height: 1; cursor: pointer; }
.cx-zoom button:hover { border-color: var(--cx-brass); color: var(--cx-brass2); }
.cx-zoom .cx-reset { width: auto; border-radius: 999px; padding: 0 12px; font-size: 12.5px; }
.cx-graphwrap {
  background:
    radial-gradient(600px 300px at 28% 30%, rgba(88, 120, 190, .13), transparent 65%),
    radial-gradient(520px 300px at 76% 62%, rgba(111, 211, 194, .08), transparent 65%);
  background-color: #040912;
}
svg#cxGraph { display: block; width: 100%; height: 640px; touch-action: none; cursor: grab; }
svg#cxGraph:active { cursor: grabbing; }
.cx-edge { stroke: rgba(168, 190, 225, .48); stroke-width: 1.4; }
.cx-edge.inferred { stroke: rgba(201, 168, 106, .75); stroke-width: 1.3; stroke-dasharray: 5 6; }
.cx-edge.faded { opacity: .07; }
.cx-edge.hot { stroke: var(--cx-brass2); stroke-width: 2.4; opacity: 1; }
.cx-edge-label { font-size: 11px; fill: #C7D3E8; paint-order: stroke; stroke: rgba(4, 9, 18, .9); stroke-width: 4px; }
.cx-edge-label.inferred { fill: var(--cx-brass2); }
.cx-edge-label.faded { opacity: .05; }
.cx-node { cursor: pointer; }
.cx-node .cx-halo { fill: transparent; stroke: rgba(201, 168, 106, 0); stroke-width: 1.5; transition: .15s; }
.cx-node:hover .cx-halo, .cx-node.selected .cx-halo { stroke: var(--cx-brass); }
.cx-node .cx-face { stroke: rgba(244, 237, 222, .75); stroke-width: 1.4; }
.cx-node .cx-face-img { fill: transparent; stroke: rgba(244, 237, 222, .75); stroke-width: 1.4; }
.cx-node.selected .cx-face, .cx-node.selected .cx-face-img { stroke: var(--cx-brass2); stroke-width: 2.6; }
.cx-node text.cx-initials { font-family: Georgia, 'Times New Roman', serif; fill: #0A1424; font-weight: 700; text-anchor: middle; dominant-baseline: central; pointer-events: none; }
.cx-node text.cx-nodename { fill: var(--cx-ink); font-size: 13.5px; text-anchor: middle; paint-order: stroke; stroke: rgba(4, 9, 18, .92); stroke-width: 5px; pointer-events: none; }
.cx-node text.cx-noderole { fill: var(--cx-muted); font-size: 11px; text-anchor: middle; paint-order: stroke; stroke: rgba(4, 9, 18, .92); stroke-width: 5px; pointer-events: none; }
.cx-node.faded { opacity: .13; }
.cx-favmark { fill: var(--cx-brass2); font-size: 15px; text-anchor: middle; pointer-events: none; }
.cx-legend { display: flex; gap: 16px; flex-wrap: wrap; padding: 11px 16px; border-top: 1px solid var(--cx-line); color: var(--cx-muted); font-size: 12.5px; }
.cx-legend i { display: inline-block; width: 26px; height: 0; border-top: 2px solid rgba(168, 190, 225, .6); vertical-align: middle; margin-right: 7px; }
.cx-legend i.dash { border-top: 2px dashed var(--cx-brass); }
.cx-legend i.dot { width: 11px; height: 11px; border-radius: 50%; background: #8FB7FF; border: 0; vertical-align: -1px; }

.cx-directory, .cx-shelves { padding: 16px; display: none; }
.cx-directory.on, .cx-shelves.on { display: block; }
.cx-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(228px, 1fr)); gap: 12px; }
.cx-card { border: 1px solid var(--cx-line); background: rgba(255, 255, 255, .035); border-radius: 16px; padding: 14px; color: var(--cx-ink); text-decoration: none; display: block; position: relative; cursor: pointer; }
.cx-card .cx-open { position: absolute; top: 8px; right: 10px; }
.cx-card:hover { border-color: var(--cx-brass); text-decoration: none; }
.cx-cardtop { display: flex; gap: 11px; align-items: center; }
.cx-cardavatar, .cx-miniavatar, .cx-bigavatar {
  border-radius: 50%; display: grid; place-items: center; overflow: hidden;
  font-family: Georgia, 'Times New Roman', serif; font-weight: 700; color: #0A1424;
  background: linear-gradient(135deg, #F0D9A0, #C9A86A); flex: 0 0 auto;
}
.cx-cardavatar { width: 46px; height: 46px; }
.cx-cardavatar img, .cx-miniavatar img, .cx-bigavatar img { width: 100%; height: 100%; object-fit: cover; }
.cx-card h3 { margin: 0; font-size: 16px; font-weight: 650; color: var(--cx-ink); }
.cx-card p { margin: 3px 0 0; color: var(--cx-muted); font-size: 12.5px; }
.cx-cardmeta { display: block; margin-top: 10px; color: var(--cx-faint); font-size: 12.5px; line-height: 1.55; }
.cx-shelfgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; }
.cx-shelf { border: 1px solid var(--cx-line); border-radius: 16px; padding: 15px; background: rgba(255, 255, 255, .03); }
.cx-shelf h3 { margin: 0 0 4px; font-family: Georgia, 'Times New Roman', serif; font-weight: 500; font-size: 19px; color: var(--cx-ink); }
.cx-shelf p { color: var(--cx-muted); font-size: 13px; margin: 0 0 10px; }
.cx-shelf ul { margin: 0; padding: 0; list-style: none; }
.cx-shelf li { padding: 7px 0; border-top: 1px dashed rgba(148, 178, 220, .14); font-size: 13.5px; display: flex; justify-content: space-between; gap: 10px; }
.cx-shelf li button { background: none; border: 0; color: #8FB7FF; padding: 0; font-size: 13.5px; text-align: left; cursor: pointer; }
.cx-shelf li span { color: var(--cx-faint); white-space: nowrap; }

.cx-dossier { padding: 18px; position: sticky; top: 16px; max-height: calc(100vh - 32px); overflow: auto; }
.cx-hero { display: flex; gap: 14px; align-items: center; }
.cx-bigavatar { width: 74px; height: 74px; font-size: 26px; border: 2px solid rgba(244, 237, 222, .7); }
.cx-dossier h3 { margin: 0; font-family: Georgia, 'Times New Roman', serif; font-size: 25px; font-weight: 500; line-height: 1.1; color: var(--cx-ink); }
.cx-who { color: var(--cx-muted); font-size: 13px; margin-top: 4px; }
.cx-star { color: var(--cx-brass2); }
.cx-tags { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.cx-tag { font-size: 11.5px; border: 1px solid rgba(201, 168, 106, .45); color: var(--cx-brass2); border-radius: 999px; padding: 3px 9px; background: rgba(201, 168, 106, .07); }
.cx-quick { display: grid; grid-template-columns: repeat(4, 1fr); gap: 7px; margin: 15px 0 4px; }
.cx-quick a, .cx-quick span.off {
  border: 1px solid var(--cx-line); background: rgba(255, 255, 255, .04); color: var(--cx-ink);
  border-radius: 11px; padding: 8px 2px; font-size: 12.5px; text-align: center; text-decoration: none;
}
.cx-quick a:hover { border-color: var(--cx-brass); color: var(--cx-brass2); text-decoration: none; }
.cx-quick span.off { color: var(--cx-faint); }
.cx-openfull { margin-top: 10px; }
.cx-fact { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px dashed rgba(148, 178, 220, .14); font-size: 13.5px; }
.cx-fact span { color: var(--cx-faint); }
.cx-fact b { font-weight: 550; text-align: right; color: var(--cx-ink); }
.cx-meter { height: 7px; border-radius: 99px; background: rgba(255, 255, 255, .09); overflow: hidden; margin-top: 7px; }
.cx-meter i { display: block; height: 100%; background: linear-gradient(90deg, var(--cx-teal), var(--cx-brass)); border-radius: 99px; }
.cx-rellist { display: flex; flex-direction: column; gap: 7px; }
.cx-rel { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; border: 1px solid var(--cx-line); background: rgba(255, 255, 255, .03); color: var(--cx-ink); border-radius: 12px; padding: 8px 10px; cursor: pointer; }
.cx-rel:hover { border-color: var(--cx-brass); }
.cx-rel.inferred { border-style: dashed; }
.cx-miniavatar { width: 34px; height: 34px; font-size: 13px; }
.cx-relmain { flex: 1; min-width: 0; }
.cx-relmain b { font-size: 13.5px; display: block; }
.cx-relmain small { color: var(--cx-faint); font-size: 12px; }
.cx-kind { color: var(--cx-brass2); font-size: 11px; letter-spacing: .06em; text-transform: uppercase; white-space: nowrap; }
.cx-open { color: var(--cx-muted); text-decoration: none; padding: 2px 4px; }
.cx-open:hover { color: var(--cx-brass2); }
.cx-notes { color: var(--cx-muted); font-size: 13.5px; line-height: 1.6; background: rgba(255, 255, 255, .03); border: 1px solid var(--cx-line); border-radius: 12px; padding: 11px 12px; white-space: pre-wrap; }

@media (max-width: 1180px) {
  .constellation-wrap { grid-template-columns: 250px minmax(0, 1fr); }
  .cx-dossier { grid-column: 1 / -1; position: static; max-height: none; }
}
@media (max-width: 760px) {
  .constellation-wrap { grid-template-columns: 1fr; }
  .cx-rail { position: static; }
  svg#cxGraph { height: 520px; }
}

/* ============================================================
   Editorial Directory home view (ed-) + home mode switch.
   Ledger-B treatment: warm paper, brass, serif, hairline rules.
   Scoped under .ed-sheet so nothing leaks into the rest of the app.
   ============================================================ */
.home-mode-bar { display: flex; align-items: center; gap: 10px; margin: 4px 0 16px; }
.home-mode-bar .home-mode-lbl { font-size: 11px; letter-spacing: .22em; text-transform: uppercase; color: #8a7a63; }
.home-mode-seg { display: inline-flex; border: 1px solid #c9b992; border-radius: 999px; overflow: hidden; background: #fffdf6; }
.home-mode-btn { border: 0; background: transparent; padding: 7px 16px; font-size: 13.5px; cursor: pointer; color: #57493a; font-family: Georgia, 'Times New Roman', serif; }
.home-mode-btn.active { background: #a87f3d; color: #fffdf6; }

.ed-sheet {
  --ed-paper: #f6f1e5; --ed-panel: #fffdf6; --ed-ink: #2b2119; --ed-soft: #57493a;
  --ed-muted: #8a7a63; --ed-brass: #a87f3d; --ed-brass-deep: #8a6527; --ed-green: #33513f;
  --ed-rule: #ddd2bd; --ed-rule-dark: #b8a888;
  background: var(--ed-paper); color: var(--ed-ink);
  font-family: "Source Serif 4", "Iowan Old Style", Palatino, Georgia, serif;
  border: 1px solid var(--ed-rule-dark); border-radius: 4px;
  padding: 26px 30px 34px; margin-bottom: 26px;
}
.ed-masthead { position: relative; text-align: center; border-bottom: 3px double var(--ed-ink); padding-bottom: 13px; }
.ed-header-form { margin-top: 14px; border-top: 1px solid var(--ed-rule); padding-top: 13px; display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px 16px; text-align: left; }
.ed-header-form[hidden] { display: none; }
.ed-header-form label { display: flex; flex-direction: column; gap: 4px; font-size: 10.5px; letter-spacing: .16em; text-transform: uppercase; color: var(--ed-muted); }
.ed-header-form label.wide { grid-column: span 2; }
.ed-header-form label.full { grid-column: 1 / -1; }
.ed-header-form input { font: inherit; font-size: 15px; letter-spacing: normal; text-transform: none; color: var(--ed-ink); background: var(--ed-panel); border: 1px solid var(--ed-rule-dark); border-radius: 3px; padding: 6px 8px; }
.ed-header-form input:focus { outline: none; border-color: var(--ed-brass); box-shadow: 0 0 0 2px rgba(168, 127, 61, .18); }
.ed-header-form-actions { grid-column: 1 / -1; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.ed-header-form-actions button { font-family: inherit; font-size: 11px; letter-spacing: .14em; text-transform: uppercase; padding: 6px 14px; border-radius: 999px; border: 1px solid var(--ed-rule-dark); background: transparent; color: var(--ed-soft); cursor: pointer; }
.ed-header-form-actions button.ed-hf-save { background: var(--ed-green); border-color: var(--ed-green); color: var(--ed-panel); }
.ed-header-form-actions button:hover { border-color: var(--ed-brass); }
.ed-hf-note { font-size: 12.5px; font-style: italic; letter-spacing: normal; text-transform: none; color: var(--ed-muted); }
.ed-masthead .ed-over { font-size: 11px; letter-spacing: .32em; text-transform: uppercase; color: var(--ed-brass-deep); display: flex; justify-content: space-between; border-bottom: 1px solid var(--ed-rule-dark); padding-bottom: 8px; margin-bottom: 11px; }
.ed-masthead h2 { font-family: "Playfair Display", Georgia, serif; font-weight: 900; font-size: clamp(38px, 5vw, 62px); margin: 2px 0 4px; color: var(--ed-ink); }
.ed-masthead .ed-sub { font-style: italic; color: var(--ed-soft); font-size: 16.5px; }
.ed-masthead .ed-meta { margin-top: 10px; font-size: 11.5px; letter-spacing: .2em; text-transform: uppercase; color: var(--ed-muted); display: flex; justify-content: space-between; }

.ed-digest { display: grid; grid-template-columns: 1fr 1fr 1fr; border-bottom: 1px solid var(--ed-rule-dark); }
.ed-digest[hidden] { display: none; }
.ed-digest-bar { display: flex; align-items: center; justify-content: space-between; padding: 7px 2px 5px; }
.ed-digest-label { font-size: 11px; letter-spacing: .22em; text-transform: uppercase; color: var(--ed-soft); }
.ed-digest-toggle { background: none; border: none; cursor: pointer; font: inherit; font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--ed-brass-deep); padding: 2px 4px; }
.ed-digest-toggle:hover { color: var(--ed-ink); }
.ed-digest > section { padding: 15px 20px 13px; }
.ed-digest > section + section { border-left: 1px solid var(--ed-rule); }
.ed-digest h2 { font-size: 11px; letter-spacing: .24em; text-transform: uppercase; color: var(--ed-brass-deep); margin: 0 0 7px; font-weight: 600; }
.ed-digest ul { list-style: none; margin: 0; padding: 0; }
.ed-digest li { padding: 3px 0; display: flex; justify-content: space-between; gap: 12px; }
.ed-digest li button { all: unset; cursor: pointer; font: inherit; color: var(--ed-ink); border-bottom: 1px dotted transparent; }
.ed-digest li button:hover { border-bottom-color: var(--ed-brass); color: var(--ed-brass-deep); }
.ed-digest .ed-when { color: var(--ed-muted); font-size: 14px; white-space: nowrap; }
.ed-digest .ed-none { color: var(--ed-muted); font-style: italic; }

.ed-finder { display: flex; align-items: baseline; gap: 16px; flex-wrap: wrap; padding: 13px 2px 10px; border-bottom: 1px solid var(--ed-rule); }
.ed-finder .ed-lbl { font-size: 11px; letter-spacing: .24em; text-transform: uppercase; color: var(--ed-muted); }
.ed-finder input { flex: 1 1 240px; font: inherit; font-size: 18px; font-style: italic; background: transparent; border: none; border-bottom: 1px solid var(--ed-rule-dark); padding: 4px 2px; color: var(--ed-ink); outline: none; }
.ed-finder input:focus { border-bottom-color: var(--ed-brass); }
.ed-chips { display: flex; gap: 13px; flex-wrap: wrap; }
.ed-chips button { all: unset; cursor: pointer; font-size: 12px; letter-spacing: .16em; text-transform: uppercase; color: var(--ed-soft); padding: 2px 1px; border-bottom: 2px solid transparent; }
.ed-chips button.active { color: var(--ed-brass-deep); border-bottom-color: var(--ed-brass); }
.ed-count { margin-left: auto; font-style: italic; color: var(--ed-muted); font-size: 14px; }

.ed-main { display: grid; grid-template-columns: 44px 1fr 330px; gap: 28px; margin-top: 16px; align-items: start; }
.ed-rail { position: sticky; top: 16px; display: flex; flex-direction: column; gap: 1px; text-align: center; }
.ed-rail button { all: unset; cursor: pointer; font-family: "Playfair Display", Georgia, serif; font-size: 14.5px; color: var(--ed-muted); padding: 2.5px 0; border-radius: 2px; }
.ed-rail button:hover { color: var(--ed-brass-deep); }
.ed-rail button.active { color: var(--ed-panel); background: var(--ed-brass); }
.ed-rail button.absent { opacity: .28; pointer-events: none; }
.ed-rail .ed-all { font-family: inherit; font-size: 9.5px; letter-spacing: .12em; text-transform: uppercase; margin-bottom: 6px; color: var(--ed-soft); }
.ed-rail .ed-all.active { color: var(--ed-panel); }

.ed-letterhead { display: flex; align-items: baseline; gap: 14px; margin: 20px 0 4px; }
.ed-letterhead .ed-glyph { font-family: "Playfair Display", Georgia, serif; font-weight: 900; font-size: 40px; color: var(--ed-brass); line-height: 1; }
.ed-letterhead .ed-rule { flex: 1; border-top: 1px solid var(--ed-rule-dark); transform: translateY(-5px); }
.ed-letterhead .ed-n { font-style: italic; color: var(--ed-muted); font-size: 13.5px; }
.ed-plates { display: grid; grid-template-columns: 1fr 1fr; gap: 0 30px; }
.ed-plate { padding: 12px 10px 11px 13px; border-bottom: 1px solid var(--ed-rule); border-left: 3px solid transparent; cursor: pointer; }
.ed-plate:hover { background: rgba(168, 127, 61, .05); }
.ed-plate.selected { border-left-color: var(--ed-brass); background: rgba(168, 127, 61, .07); }
.ed-plate h3 { font-family: "Playfair Display", Georgia, serif; font-weight: 700; font-size: 20px; margin: 0; color: var(--ed-ink); }
.ed-plate .ed-star { color: var(--ed-brass); font-size: 14px; }
.ed-plate .ed-meta { font-size: 11px; letter-spacing: .16em; text-transform: uppercase; color: var(--ed-muted); margin: 2px 0 4px; }
.ed-plate .ed-facts { font-size: 14.5px; color: var(--ed-soft); }
.ed-plate .ed-relline { font-style: italic; color: var(--ed-green); font-size: 14px; margin-top: 3px; }
.ed-plate .ed-tags { margin-top: 4px; font-size: 10.5px; letter-spacing: .15em; text-transform: uppercase; color: var(--ed-brass-deep); }
.ed-noresults { font-style: italic; color: var(--ed-muted); padding: 24px 4px; }

.ed-panel { position: sticky; top: 16px; background: var(--ed-panel); border: 1px solid var(--ed-rule-dark); padding: 20px 20px 16px; box-shadow: 0 1px 0 rgba(43,33,25,.06), 0 10px 30px rgba(43,33,25,.07); }
.ed-panel .ed-kicker { font-size: 10px; letter-spacing: .26em; text-transform: uppercase; color: var(--ed-brass-deep); text-align: center; }
.ed-panel .ed-mono { width: 72px; height: 72px; margin: 11px auto 8px; border: 1.5px solid var(--ed-brass); border-radius: 50%; display: flex; align-items: center; justify-content: center; font-family: "Playfair Display", Georgia, serif; font-size: 26px; color: var(--ed-brass-deep); background: radial-gradient(circle at 35% 30%, #fffdf6, #f1e7cf); overflow: hidden; }
.ed-panel .ed-mono img { width: 100%; height: 100%; object-fit: cover; }
.ed-panel h2 { font-family: "Playfair Display", Georgia, serif; font-weight: 700; font-size: 25px; text-align: center; margin: 2px 0 0; color: var(--ed-ink); }
.ed-panel h2 .ed-star { color: var(--ed-brass); font-size: 18px; }
.ed-panel .ed-who { text-align: center; font-style: italic; color: var(--ed-soft); }
.ed-panel .ed-ptags { text-align: center; font-size: 10.5px; letter-spacing: .17em; text-transform: uppercase; color: var(--ed-brass-deep); margin: 5px 0 8px; }
.ed-panel table { width: 100%; border-collapse: collapse; margin: 6px 0 2px; }
.ed-panel td { padding: 6px 0; border-top: 1px solid var(--ed-rule); font-size: 14.5px; vertical-align: top; color: var(--ed-ink); }
.ed-panel td.k { width: 94px; font-size: 10.5px; letter-spacing: .16em; text-transform: uppercase; color: var(--ed-muted); padding-top: 8px; }
.ed-panel h4 { font-size: 10.5px; letter-spacing: .22em; text-transform: uppercase; color: var(--ed-brass-deep); margin: 15px 0 5px; border-top: 3px double var(--ed-rule-dark); padding-top: 11px; }
.ed-panel .ed-rel { display: flex; justify-content: space-between; gap: 10px; padding: 4px 0; border-top: 1px solid var(--ed-rule); }
.ed-panel .ed-rel button { all: unset; cursor: pointer; font: inherit; color: var(--ed-ink); }
.ed-panel .ed-rel button:hover { color: var(--ed-brass-deep); }
.ed-panel .ed-kind { font-style: italic; color: var(--ed-muted); font-size: 13.5px; white-space: nowrap; }
.ed-panel .ed-kind.inf { color: var(--ed-brass-deep); }
.ed-panel .ed-notes { font-style: italic; color: var(--ed-soft); font-size: 14.5px; white-space: pre-wrap; margin: 0; }
.ed-panel .ed-more { margin-top: 15px; border-top: 3px double var(--ed-rule-dark); padding-top: 11px; }
.ed-more-toggle { width: 100%; display: flex; justify-content: space-between; align-items: baseline; gap: 10px; background: none; border: none; padding: 0; cursor: pointer; font: inherit; font-size: 10.5px; letter-spacing: .22em; text-transform: uppercase; color: var(--ed-brass-deep); text-align: left; }
.ed-more-toggle:hover { color: var(--ed-ink); }
.ed-more-body[hidden] { display: none; }
.ed-more-body h4:first-child { border-top: none; margin-top: 8px; padding-top: 0; }
.ed-panel .ed-actions { display: flex; justify-content: center; gap: 15px; flex-wrap: wrap; margin-top: 15px; border-top: 1px solid var(--ed-rule-dark); padding-top: 11px; }
.ed-panel .ed-actions a, .ed-panel .ed-actions span.off { font-size: 11.5px; letter-spacing: .16em; text-transform: uppercase; color: var(--ed-brass-deep); text-decoration: none; }
.ed-panel .ed-actions a:hover { color: var(--ed-ink); text-decoration: none; }
.ed-panel .ed-actions span.off { color: var(--ed-muted); opacity: .6; }
.ed-panel .ed-empty { text-align: center; font-style: italic; color: var(--ed-muted); padding: 20px 0; }

.ed-colophon { margin-top: 38px; border-top: 3px double var(--ed-ink); padding-top: 9px; display: flex; justify-content: space-between; font-size: 11px; letter-spacing: .16em; text-transform: uppercase; color: var(--ed-muted); }

/* Frozen header + reading panel on wide screens: the sheet becomes a
   fixed-height frame -- masthead, digest, finder, the A-Z rail (with
   ALL pinned at its top) and the selected contact's panel never move;
   only the entries column scrolls. The frozen head is deliberately
   compact (smaller masthead, capped digest lists, denser plates) so
   the entries still get most of the frame -- about five contacts
   visible at a time, as in the old flowing layout. */
@media (min-width: 1121px) {
  .ed-sheet { display: flex; flex-direction: column; height: calc(100vh - 138px); height: calc(100dvh - 138px); min-height: 620px; padding-top: 16px; padding-bottom: 18px; }
  .ed-masthead, .ed-digest, .ed-digest-bar, .ed-finder, .ed-colophon { flex: none; }
  .ed-colophon { margin-top: 12px; padding-top: 6px; }
  .ed-masthead { padding-bottom: 8px; }
  .ed-masthead .ed-over { padding-bottom: 5px; margin-bottom: 6px; }
  .ed-masthead h2 { font-size: 36px; margin: 0 0 2px; }
  .ed-masthead .ed-sub { font-size: 14.5px; }
  .ed-masthead .ed-meta { margin-top: 6px; }
  .ed-digest > section { padding: 9px 16px 7px; }
  .ed-digest li { padding: 1.5px 0; }
  .ed-digest ul { max-height: 132px; overflow-y: auto; }
  .ed-digest-bar { padding: 5px 2px 3px; }
  .ed-finder { padding: 8px 2px 6px; }
  .ed-main { flex: 1 1 auto; min-height: 0; align-items: stretch; margin-top: 10px; }
  .ed-main > * { min-height: 0; }
  .ed-rail { position: static; overflow-y: auto; padding-right: 2px; }
  .ed-rail .ed-all { position: sticky; top: 0; background: var(--ed-paper); z-index: 1; }
  #edEntries { overflow-y: auto; padding-right: 6px; scrollbar-gutter: stable; }
  .ed-plate { padding: 9px 10px 8px 13px; }
  .ed-plate h3 { font-size: 18px; }
  .ed-letterhead { margin: 12px 0 2px; }
  .ed-letterhead .ed-glyph { font-size: 30px; }
  .ed-panel { position: static; overflow-y: auto; }
}

@media (max-width: 1120px) {
  .ed-main { grid-template-columns: 44px 1fr; }
  .ed-panel { position: static; grid-column: 2; margin-top: 10px; }
  .ed-digest { grid-template-columns: 1fr; }
  .ed-digest > section + section { border-left: none; border-top: 1px solid var(--ed-rule); }
  .ed-digest ul { max-height: 132px; overflow-y: auto; }
}
@media (max-width: 700px) {
  .ed-sheet { padding: 18px 14px 26px; }
  .ed-plates { grid-template-columns: 1fr; }
  .ed-main { grid-template-columns: 32px 1fr; gap: 14px; }
  .ed-panel { grid-column: 1 / -1; }
  .ed-masthead .ed-over, .ed-masthead .ed-meta { flex-direction: column; gap: 2px; }
  .ed-header-form { grid-template-columns: 1fr; }
  .ed-panel table td { overflow-wrap: anywhere; }
  .ed-actions { gap: 10px; }
}

/* Account Management — mirrors Ledger's account screens (stacked
   panels, status pills, small action buttons) in this app's
   editorial palette. */
.acct-panel { background: #fff; border: 1px solid var(--border-dark); border-radius: 6px; padding: 18px 20px; margin: 0 0 18px; }
.acct-panel-title { font-family: 'Playfair Display', Georgia, serif; font-size: 20px; font-weight: 700; letter-spacing: 0; text-transform: none; color: inherit; margin: 0 0 10px; }
.acct-facts { margin: 0 0 6px; }
.acct-facts th { width: 180px; }
.acct-btnrow { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 12px; }
.acct-fieldrow { display: flex; gap: 14px; flex-wrap: wrap; }
.acct-fieldrow label { flex: 1 1 180px; display: flex; flex-direction: column; gap: 4px; font-size: 0.9em; }
.acct-fieldrow input[type="text"] { padding: 7px 9px; border: 1px solid var(--border-dark); border-radius: 3px; font: inherit; }
.acct-actions { white-space: nowrap; text-align: right; }
.acct-actions form { display: inline; }
.acct-reset { display: inline-block; text-align: left; }
.acct-reset summary { list-style: none; cursor: pointer; display: inline-block; }
.acct-reset summary::-webkit-details-marker { display: none; }
.acct-reset-form { display: block; margin-top: 8px; white-space: normal; max-width: 320px; }
.acct-reset-form label { display: flex; flex-direction: column; gap: 4px; font-size: 0.88em; margin-bottom: 8px; }
.acct-reset-form input[type="text"] { padding: 7px 9px; border: 1px solid var(--border-dark); border-radius: 3px; font: inherit; }
.pill { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 600; background: rgba(168, 127, 61, .14); color: var(--accent-dark); vertical-align: middle; }
.pill-cat { background: var(--green); color: #fff; }
.pill-pos { background: rgba(51, 81, 63, .14); color: var(--green); }
.pill-neg { background: rgba(163, 51, 51, .12); color: #a33333; }
.button.small { padding: 3px 10px; font-size: 0.85em; }
.button.secondary { background: transparent; }
.button.danger { color: #a33333; border-color: #a33333; }
.button.danger:hover { background: rgba(163, 51, 51, .08); }
