/* Character profile companion view */

.ch-modeswitch{
  display:flex; gap:2px; padding:3px;
  background: var(--paper-2); border: 0.5px solid var(--rule); border-radius: 8px;
}
.ch-mode{
  appearance:none; border:0; background:transparent; cursor:default;
  display:inline-flex; align-items:center; gap:6px;
  padding: 5px 10px; border-radius: 6px;
  font: inherit; font-family: var(--sans); font-size: 12px;
  color: var(--ink-3); text-decoration:none;
}
.ch-mode:hover{ color: var(--ink); }
.ch-mode.is-on{ background: var(--ink); color: var(--paper); }

/* ── Cast list ─────────────────────────────────────────────────────────── */
.ch-cast{ list-style:none; margin:0; padding:0; display:flex; flex-direction:column; gap: 1px; }
.ch-cast-row{ position:relative; }
.ch-cast-btn{
  appearance:none; border:0; background:transparent; width:100%;
  display:grid; grid-template-columns: 30px 1fr auto; align-items:center; gap:10px;
  padding: 7px 8px; border-radius: 7px;
  cursor:default; font: inherit; color: inherit; text-align:left;
}
.ch-cast-btn:hover{ background: var(--paper-2); }
.ch-cast-row.is-active .ch-cast-btn{
  background: var(--paper-2);
  box-shadow: inset 2px 0 0 var(--ink-2);
}
.ch-cast-btn .chr-bubble{ width:28px; height:28px; font-size: 13px; }
.ch-cast-flag{
  font-family: var(--serif); color: var(--ink-4); font-size: 14px;
}

.ch-filter-chips{ display:flex; flex-wrap:wrap; gap: 4px; padding: 0 4px; }
.ch-recent{ list-style:none; margin:0; padding: 0 6px;
  display:flex; flex-direction:column; gap: 5px;
  font-size: 11.5px; color: var(--ink-3); font-family: var(--sans); }
.ch-recent li em{ font-style: italic; color: var(--ink-4); font-size: 10.5px; }

/* ── Main canvas ───────────────────────────────────────────────────────── */
.ch-canvas{
  position:absolute; inset:0; overflow-y:auto;
  background:
    radial-gradient(ellipse at 25% 0%, rgba(168, 138, 90, .06), transparent 55%),
    var(--paper-2);
}
.ch-canvas::before{
  content:""; position:absolute; inset:0; pointer-events:none;
  background-image:
    repeating-linear-gradient(0deg, rgba(80,60,30,.02) 0 1px, transparent 1px 3px),
    repeating-linear-gradient(90deg, rgba(80,60,30,.014) 0 1px, transparent 1px 3px);
  background-size: 3px 3px;
  mix-blend-mode: multiply; opacity:.4;
}
.ch-canvas::-webkit-scrollbar{ width: 10px; }
.ch-canvas::-webkit-scrollbar-thumb{ background: var(--rule); border-radius: 5px; }

.ch-canvas-inner{
  position:relative;
  max-width: 880px;
  margin: 0 auto;
  padding: 36px 40px 120px;
  display:flex; flex-direction:column; gap: 22px;
}

/* ── Hero ──────────────────────────────────────────────────────────────── */
.ch-hero{
  position:relative;
  display:grid;
  grid-template-columns: 168px 1fr auto;
  gap: 28px;
  align-items: center;
  padding: 28px 28px 26px;
  background: var(--paper);
  border: 0.5px solid var(--rule);
  border-radius: 6px;
  box-shadow:
    0 1px 0 rgba(255,255,255,.6) inset,
    0 1px 2px rgba(42,36,25,.04),
    0 18px 36px -22px rgba(42,36,25,.18);
}
.ch-hero::before{
  content:""; position:absolute; left:0; top: 18px; bottom: 18px; width: 3px;
  background: var(--ch-accent);
  border-radius: 0 2px 2px 0;
}

.ch-hero-portrait{ display:flex; align-items:center; justify-content:center; }
.ch-portrait-frame{
  position:relative; width:152px; height:152px;
  border: 0.5px solid var(--rule);
  background: var(--paper-2);
  border-radius: 4px;
  box-shadow:
    inset 0 0 0 6px var(--paper),
    inset 0 0 0 7px var(--rule),
    0 8px 22px -10px rgba(42,36,25,.18);
  display:flex; align-items:center; justify-content:center;
}
.ch-portrait-inner{
  width:124px; height:124px; border-radius: 4px;
  display:flex; align-items:center; justify-content:center;
  font-family: var(--serif);
  font-size: 64px;
  font-weight: 500;
  letter-spacing: 0.005em;
}
.ch-portrait-drop{
  position:absolute; bottom: -10px; left:50%; transform: translateX(-50%);
  display:inline-flex; align-items:center; gap: 5px;
  font-family: var(--sans); font-size: 10px; letter-spacing: 0.05em;
  text-transform: uppercase; color: var(--ink-3);
  padding: 4px 8px; border-radius: 4px;
  background: var(--paper);
  border: 0.5px dashed var(--rule);
  white-space: nowrap;
}

.ch-hero-body{ min-width:0; display:flex; flex-direction:column; gap: 10px; }
.ch-hero-eyebrow{
  display:flex; align-items:center; gap: 8px;
  font-family: var(--sans); font-size: 11px;
  color: var(--ink-3); flex-wrap: wrap;
}
.ch-hero-role-pill{
  display:inline-block;
  padding: 2px 9px; border-radius: 3px;
  color: var(--paper);
  font-family: var(--sans); font-size: 10px;
  letter-spacing: 0.1em; text-transform: uppercase; font-weight: 600;
}
.ch-hero-archetype{ font-family: var(--serif); font-style: italic; font-size: 13px; color: var(--ink-2); }
.ch-hero-flag{
  margin-left: auto;
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.06em;
  color: var(--ink-3); padding: 2px 7px;
  background: var(--paper-2); border: 0.5px solid var(--rule); border-radius: 3px;
  text-transform: uppercase;
}
.ch-hero-name{
  margin: 2px 0 4px;
  font-family: var(--serif); font-weight: 500;
  font-size: 38px; line-height: 1.05; letter-spacing: -0.005em;
  color: var(--ink); outline: 0;
  text-wrap: balance;
}
.ch-hero-name:focus{ border-bottom: 1px solid var(--ink-3); }

.ch-hero-vitals{
  display:flex; flex-wrap:wrap; gap: 0;
  font-family: var(--sans); font-size: 12.5px;
  margin-top: 4px;
}
.ch-vital{
  display:flex; flex-direction:column; gap: 1px;
  padding: 0 18px 0 0;
  margin-right: 18px;
  border-right: 0.5px solid var(--rule);
}
.ch-vital:last-child{ border-right: 0; }
.ch-vital label{
  font-size: 9.5px; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--ink-4); font-weight: 600;
}
.ch-vital span{ font-family: var(--serif); font-size: 14px; color: var(--ink); outline:0; }
.ch-vital span:focus{ background: var(--paper-2); }

.ch-flesh-btn{
  align-self: flex-start;
  margin-top: 10px;
  appearance:none; border:0; cursor: default;
  display:inline-flex; align-items:center; gap: 8px;
  padding: 9px 14px;
  background: var(--ink); color: var(--paper);
  font-family: var(--sans); font-size: 13px; font-weight: 500;
  border-radius: 8px;
  box-shadow:
    0 1px 0 rgba(255,255,255,.12) inset,
    0 6px 14px -6px rgba(42,36,25,.36);
}
.ch-flesh-btn:hover{ background: var(--ink-2); }
.ch-flesh-btn svg{ color: color-mix(in oklch, var(--ch-accent, #d4a85a) 90%, var(--paper)); }

.ch-hero-tally{
  display:grid; grid-template-columns: repeat(2, auto); gap: 12px 20px;
  align-self: stretch;
  padding-left: 18px;
  border-left: 0.5px solid var(--rule);
}
.ch-tally{ display:flex; flex-direction:column; align-items: flex-start; gap: 2px; min-width: 64px; }
.ch-tally-num{
  font-family: var(--serif); font-size: 30px; font-weight: 500;
  line-height: 1; color: var(--ink);
}
.ch-tally-lab{
  font-family: var(--sans); font-size: 10px; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--ink-4); font-weight: 600;
}

/* ── Cards (motivation, presence, etc.) ────────────────────────────────── */
.ch-card{
  position:relative;
  background: var(--paper);
  border: 0.5px solid var(--rule);
  border-radius: 6px;
  padding: 22px 26px 22px;
  box-shadow:
    0 1px 0 rgba(255,255,255,.6) inset,
    0 1px 2px rgba(42,36,25,.04);
}
.ch-card-head{
  display:flex; align-items: baseline; gap: 14px;
  margin-bottom: 14px;
}
.ch-card-head h2{
  margin: 0;
  font-family: var(--serif); font-weight: 500;
  font-size: 18px; letter-spacing: 0.005em; color: var(--ink);
  display:flex; align-items: center; gap: 9px;
}
.ch-card-dot{
  display:inline-block; width: 8px; height: 8px; border-radius: 50%;
  background: var(--ink-2);
}
.ch-card-dot.dim{ background: var(--ink-4); }
.ch-card-hint{
  font-family: var(--serif); font-style: italic; font-size: 12.5px;
  color: var(--ink-4);
}

.ch-empty-line{ color: var(--ink-4); font-style: italic; font-family: var(--serif); font-size: 13px; }

/* Motivation */
.ch-motivation-text{
  font-family: var(--serif); font-size: 17px; line-height: 1.5;
  color: var(--ink); outline: 0;
  padding: 10px 14px 12px 16px;
  background: color-mix(in oklch, var(--ch-accent, #a37b2a) 6%, var(--paper-2));
  border: 0.5px solid var(--rule);
  border-left: 3px solid var(--ch-accent, var(--ink-3));
  border-radius: 0 4px 4px 0;
  text-wrap: pretty;
}
.ch-motivation-text:focus{ background: var(--paper-2); }

.ch-goals{ margin-top: 18px; }
.ch-goals-head{
  display:flex; align-items: center; justify-content: space-between;
  margin-bottom: 8px;
}
.ch-goals-head h3{
  margin:0; font-family: var(--sans); font-weight: 600;
  font-size: 10px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-3);
}
.ch-goals-add{
  appearance:none; border: 0.5px dashed var(--rule); background:transparent;
  color: var(--ink-3); font: inherit; font-size: 11px;
  padding: 3px 9px; border-radius: 4px; cursor:default;
}
.ch-goals-add:hover{ color: var(--ink); border-color: var(--ink-3); border-style: solid; }
.ch-goals-list{
  list-style:none; margin:0; padding:0;
  display:flex; flex-direction:column; gap: 4px;
  counter-reset: g;
}
.ch-goal{
  display:grid; grid-template-columns: 28px 18px 1fr;
  align-items:flex-start; gap: 10px;
  padding: 8px 10px;
  border-radius: 5px;
  border: 0.5px solid var(--rule);
  background: var(--paper-2);
}
.ch-goal.s-done{ background: color-mix(in oklch, var(--st-done) 8%, var(--paper-2)); }
.ch-goal.s-draft{ background: color-mix(in oklch, var(--st-draft) 8%, var(--paper-2)); }
.ch-goal-num{
  font-family: var(--mono); font-size: 11px;
  color: var(--ink-4); letter-spacing: 0.05em; padding-top: 2px;
}
.ch-goal-status{
  font-size: 14px; color: var(--ink-3); padding-top: 1px;
  text-align:center;
}
.ch-goal.s-done .ch-goal-status{ color: var(--st-done); }
.ch-goal.s-draft .ch-goal-status{ color: var(--st-draft); }
.ch-goal-text{
  font-family: var(--serif); font-size: 14.5px; line-height: 1.45;
  color: var(--ink); outline: 0; text-wrap: pretty;
}
.ch-goal.s-done .ch-goal-text{ color: var(--ink-2); }

/* Presence */
.ch-presence-grid{
  display:grid; grid-template-columns: 1fr 1fr; gap: 28px;
  margin-bottom: 18px;
}
.ch-presence-col h4,
.ch-presence-chapters h4{
  margin: 0 0 8px;
  font-family: var(--sans); font-weight: 600;
  font-size: 10px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-3);
}
.ch-count{
  font-family: var(--mono); font-size: 10.5px; color: var(--ink-4);
  margin-left: 4px; letter-spacing: 0.03em;
}

.ch-pill-list{ display:flex; flex-wrap:wrap; gap: 6px; align-items:center; }
.ch-pill-list.sm .ch-plot-pill, .ch-pill-list.sm .ch-book-pill{ font-size: 11.5px; padding: 3px 8px; }
.ch-plot-pill{
  display:inline-flex; align-items:center; gap: 6px;
  font-family: var(--serif); font-size: 13px; color: var(--ink);
  padding: 4px 10px; border-radius: 14px;
  background: var(--paper-2); border: 0.5px solid var(--rule);
}
.ch-plot-swatch{ width: 9px; height: 9px; border-radius: 50%; }
.ch-pill-add, .ch-pill-list button.ch-pill-add{
  appearance:none; border: 0.5px dashed var(--rule); background: transparent;
  color: var(--ink-3); font: inherit; font-size: 11px;
  padding: 3px 9px; border-radius: 14px; cursor:default;
}
.ch-pill-add:hover{ color: var(--ink); border-style: solid; border-color: var(--ink-3); }
.ch-book-pill{
  display:inline-flex; align-items:center; gap: 6px;
  font-family: var(--serif); font-size: 12.5px;
  padding: 3px 9px; border-radius: 4px;
  background: var(--paper-2);
  border: 1px solid currentColor;
}

.ch-book-spines{ display:flex; flex-direction:column; gap: 5px; }
.ch-book-spine{
  display:grid; grid-template-columns: 44px 1fr; align-items:center; gap: 10px;
}
.ch-book-spine-bar{
  height: 22px; display:flex; align-items:center; justify-content:center;
  border-radius: 2px 4px 4px 2px;
  border: 1px solid var(--rule);
  font-family: var(--serif); font-size: 11px; font-weight: 600;
  letter-spacing: 0.05em;
  color: var(--paper);
}
.ch-book-spine.is-off .ch-book-spine-bar{
  background: transparent !important;
  color: var(--ink-4);
}
.ch-book-spine.is-off .ch-book-spine-title{ color: var(--ink-4); text-decoration: line-through; }
.ch-book-spine-title{
  font-family: var(--serif); font-size: 13.5px; color: var(--ink);
  text-wrap: balance;
}

.ch-chapter-grid{
  display:flex; flex-direction:column; gap: 10px;
  padding: 12px 14px;
  background: var(--paper-2);
  border: 0.5px solid var(--rule); border-radius: 4px;
}
.ch-chapter-book{ display:grid; grid-template-columns: 110px 1fr; align-items:center; gap: 14px; }
.ch-chapter-book-head{
  font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.04em;
  font-weight: 600; text-transform: uppercase;
}
.ch-chapter-book-head em{ font-style: italic; color: var(--ink-3); font-family: var(--serif); font-weight: 400; text-transform: none; font-size: 12px; }
.ch-chapter-dots{ display:flex; flex-wrap:wrap; gap: 4px; }
.ch-chapter-dot{
  appearance:none; border: 0.5px solid var(--rule); background: var(--paper);
  font-family: var(--mono); font-size: 10px;
  color: var(--ink-4); padding: 0; cursor:default;
  width: 26px; height: 22px;
  border-radius: 3px;
}
.ch-chapter-dot:hover{ color: var(--ink-2); }
.ch-chapter-dot.is-on{
  color: var(--paper) !important;
  border: 0 !important;
}

/* Description */
.ch-desc-body{
  font-family: var(--serif); font-size: 16px; line-height: 1.55;
  color: var(--ink); outline: 0;
  text-wrap: pretty;
  padding: 4px 0;
}

/* Relationships */
.ch-rel-list{ list-style:none; margin:0; padding:0; display:flex; flex-direction:column; gap: 4px; }
.ch-rel{
  display:grid; grid-template-columns: 34px 1fr; align-items:center; gap: 12px;
  padding: 9px 10px;
  border-radius: 5px;
}
.ch-rel:hover{ background: var(--paper-2); }
.ch-rel .chr-bubble{ width: 32px; height: 32px; font-size: 14px; }
.ch-rel-body{ min-width: 0; display:flex; flex-direction:column; gap: 1px; }
.ch-rel-top{ display:flex; align-items:center; gap: 8px; }
.ch-rel-name{ font-family: var(--serif); font-size: 14.5px; color: var(--ink); }
.ch-rel-kind{
  font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--ink-3);
  padding: 2px 6px; border-radius: 3px;
  background: var(--paper-2); border: 0.5px solid var(--rule);
}
.ch-rel-kind.k-family{ background: color-mix(in oklch, var(--plot-rose) 14%, var(--paper)); color: var(--plot-rose); border-color: transparent; }
.ch-rel-kind.k-foil  { background: color-mix(in oklch, var(--plot-slate) 14%, var(--paper)); color: var(--plot-slate); border-color: transparent; }
.ch-rel-kind.k-mentor{ background: color-mix(in oklch, var(--plot-ochre) 14%, var(--paper)); color: var(--plot-ochre); border-color: transparent; }
.ch-rel-label{
  font-family: var(--serif); font-size: 13px; color: var(--ink-2);
  font-style: italic;
}
.ch-rel-add{ padding: 4px 10px; }
.ch-rel-add button{
  appearance:none; border: 0.5px dashed var(--rule); background:transparent;
  color: var(--ink-3); padding: 6px 12px; border-radius: 5px;
  font: inherit; font-size: 11.5px; cursor:default;
}
.ch-rel-add button:hover{ color: var(--ink); border-color: var(--ink-3); border-style: solid; }

/* Resources */
.ch-res-grid{
  margin-top: 14px;
  display:grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
}
.ch-res-card{
  display:flex; flex-direction:column;
  background: var(--paper);
  border: 0.5px solid var(--rule);
  border-radius: 4px;
  overflow: hidden;
}
.ch-res-thumb{
  height: 88px;
  background: var(--paper-2);
  display:flex; align-items:center; justify-content:center;
  border-bottom: 0.5px solid var(--rule);
}
.ch-res-img-placeholder{
  width: 100%; height: 100%;
  display:flex; align-items:center; justify-content:center;
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.1em;
  color: var(--ink-3); font-weight: 600;
}
.ch-res-glyph{
  font-family: var(--mono); font-weight: 600; font-size: 13px;
  color: var(--ink-3); letter-spacing: 0.08em;
  padding: 14px 16px;
  border: 0.5px dashed var(--rule);
  border-radius: 4px;
}
.ch-res-meta{ padding: 7px 10px 9px; }
.ch-res-name{
  font-family: var(--sans); font-size: 12px; color: var(--ink);
  white-space: nowrap; overflow:hidden; text-overflow:ellipsis;
}
.ch-res-sub{
  font-family: var(--mono); font-size: 10px;
  color: var(--ink-4); margin-top: 2px;
}

/* Notes */
.ch-notes-stream{
  display:flex; flex-direction:column; gap: 6px;
  padding: 10px 12px;
  background: var(--paper-2);
  border: 0.5px solid var(--rule);
  border-radius: 4px;
  max-height: 240px; overflow-y: auto;
  margin-bottom: 10px;
}
.ch-note-entry{
  display:grid; grid-template-columns: 60px 1fr; gap: 12px;
  padding: 3px 0;
  font-size: 13px;
  border-bottom: 0.5px solid var(--rule-2);
}
.ch-note-entry:last-child{ border-bottom: 0; }
.ch-note-date{
  font-family: var(--mono); font-size: 10.5px;
  color: var(--ink-4); padding-top: 2px;
}
.ch-note-body{
  font-family: var(--serif); font-size: 13.5px; line-height: 1.45;
  color: var(--ink-2); text-wrap: pretty;
}

.ch-notes-compose{ display:flex; gap: 8px; align-items: flex-end; }
.ch-notes-compose textarea{
  flex:1; resize: vertical;
  font: inherit; font-family: var(--serif); font-size: 13.5px;
  padding: 8px 10px;
  background: var(--paper);
  border: 0.5px solid var(--rule); border-radius: 5px;
  color: var(--ink); outline:0;
}
.ch-notes-compose textarea:focus{ border-color: var(--ink-4); }
.ch-notes-compose .btn-ghost-sm{
  appearance:none; border: 0.5px solid var(--rule); background: var(--paper-2);
  padding: 7px 12px; border-radius: 5px;
  font: inherit; font-size: 12px; color: var(--ink-2); cursor:default;
}
.ch-notes-compose .btn-ghost-sm:hover{ background: var(--paper); color: var(--ink); }

/* ── Right context panel: appearances ─────────────────────────────────── */
.ch-context{ width: 340px; }
.ch-ctx-book{
  display:flex; flex-direction: column; gap: 4px;
  margin-bottom: 18px;
}
.ch-ctx-book-head{
  display:grid; grid-template-columns: 30px 1fr auto; align-items:center; gap: 10px;
  margin-bottom: 6px;
}
.ch-ctx-book-abbr{
  font-family: var(--mono); font-size: 10px; font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--paper);
  padding: 3px 6px; border-radius: 3px;
  text-align:center;
}
.ch-ctx-book-title{
  font-family: var(--serif); font-style: italic;
  font-size: 14px; color: var(--ink-2);
}
.ch-ctx-book-count{
  font-family: var(--mono); font-size: 10.5px; color: var(--ink-4);
}
.ch-ctx-beats{ list-style:none; margin:0; padding:0; display:flex; flex-direction:column; gap: 2px; }
.ch-ctx-beat{
  display:grid; grid-template-columns: 3px 1fr; align-items:stretch; gap: 10px;
  padding: 7px 8px;
  border-radius: 5px;
  cursor:default;
}
.ch-ctx-beat:hover{ background: var(--paper-2); }
.ch-ctx-spine{ border-radius: 2px; min-height: 28px; }
.ch-ctx-beat-body{ display:flex; flex-direction:column; gap: 2px; min-width: 0; }
.ch-ctx-beat-top{ display:flex; align-items:center; gap: 8px; }
.ch-ctx-beat-ch{ font-family: var(--mono); font-size: 10px; color: var(--ink-3); }
.ch-ctx-beat-status{
  font-family: var(--sans); font-size: 9px; letter-spacing: 0.08em;
  text-transform: uppercase; padding: 1px 5px; border-radius: 2px;
  color: var(--ink-3);
}
.ch-ctx-beat-status.s-done { color: var(--st-done); }
.ch-ctx-beat-status.s-draft{ color: var(--st-draft); }
.ch-ctx-beat-status.s-idea { color: var(--ink-4); }
.ch-ctx-beat-title{
  font-family: var(--serif); font-size: 13.5px; color: var(--ink); font-weight: 500;
  line-height: 1.2;
}
.ch-ctx-beat-snip{
  font-family: var(--serif); font-size: 11.5px; color: var(--ink-4);
  line-height: 1.35;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
  margin-top: 2px;
}

/* ── Wizard modal ─────────────────────────────────────────────────────── */
.ch-wizard-veil{
  position: fixed; inset: 0; z-index: 100;
  background: rgba(42, 36, 25, 0.42);
  display:flex; align-items:flex-start; justify-content:center;
  padding: 60px 30px;
  backdrop-filter: blur(2px);
  overflow-y: auto;
}
.ch-wizard{
  width: 720px; max-width: 100%;
  background: var(--paper);
  border: 0.5px solid var(--rule);
  border-radius: 10px;
  box-shadow:
    0 1px 0 rgba(255,255,255,.7) inset,
    0 30px 80px -20px rgba(42,36,25,.4);
  overflow: hidden;
  display:flex; flex-direction:column;
}
.ch-wizard-head{
  display:flex; align-items:center; justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 0.5px solid var(--rule);
  background: var(--paper-2);
}
.ch-wizard-eyebrow{
  display:inline-flex; align-items:center; gap: 8px;
  font-family: var(--sans); font-size: 12px; font-weight: 600;
  color: var(--ink-2);
}
.ch-wizard-eyebrow svg{ color: var(--plot-ochre); }
.ch-wizard-body{ padding: 6px 24px 24px; }

.ch-wizard-step{
  display:grid; grid-template-columns: 40px 1fr; gap: 14px;
  padding: 22px 0;
  border-bottom: 0.5px dashed var(--rule);
}
.ch-wizard-step:last-child{ border-bottom: 0; }
.ch-wizard-step-num{
  font-family: var(--mono); font-size: 11px;
  font-weight: 600; color: var(--ink-4); letter-spacing: 0.04em;
  padding-top: 4px;
}
.ch-wizard-step-content h3{
  margin: 0 0 4px;
  font-family: var(--serif); font-weight: 500;
  font-size: 19px; color: var(--ink); letter-spacing: 0.005em;
}
.ch-wizard-help{
  margin: 0 0 14px;
  font-family: var(--serif); font-size: 13.5px; line-height: 1.5;
  color: var(--ink-3); text-wrap: pretty;
}
.ch-wizard-help em{ font-style: italic; color: var(--ink-2); }

.ch-wizard-field{
  margin: 14px 0 0;
}
.ch-wizard-field-label{
  display: block;
  font-family: var(--sans);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--ink-2);
  margin-bottom: 6px;
}
.ch-wizard-field-hint{
  margin: 6px 0 0;
  font-family: var(--serif);
  font-size: 12px;
  font-style: italic;
  color: var(--ink-4);
}
.ch-wizard-select{
  width: 100%;
  max-width: 100%;
  font: inherit;
  font-family: var(--sans);
  font-size: 13px;
  padding: 9px 12px;
  background: var(--paper-2);
  border: 0.5px solid var(--rule);
  border-radius: 6px;
  color: var(--ink);
  outline: 0;
  cursor: default;
}
.ch-wizard-select:focus{
  border-color: var(--ink-4);
  background: var(--paper);
}
.ch-wizard-origin-textarea{
  width: 100%;
  font: inherit;
  font-family: var(--serif);
  font-size: 14px;
  line-height: 1.5;
  padding: 10px 12px;
  background: var(--paper-2);
  border: 0.5px solid var(--rule);
  border-radius: 6px;
  color: var(--ink);
  outline: 0;
  resize: vertical;
  min-height: 4.5em;
}
.ch-wizard-origin-textarea:focus{
  border-color: var(--ink-4);
  background: var(--paper);
}
.ch-wizard-origin-textarea::placeholder{
  color: var(--ink-4);
  font-style: italic;
}

.ch-wizard-draft{
  width: 100%;
  font: inherit; font-family: var(--serif); font-size: 15px; line-height: 1.5;
  padding: 12px 14px;
  background: var(--paper-2);
  border: 0.5px solid var(--rule);
  border-radius: 6px;
  color: var(--ink); outline:0; resize: vertical;
}
.ch-wizard-draft:focus{ border-color: var(--ink-4); background: var(--paper); }
.ch-wizard-draft::placeholder{ color: var(--ink-4); font-style: italic; }

.ch-canvas-inner--wizard-dock{
  padding-bottom: calc(140px + var(--if-ai-dock-clearance, 124px));
}

/* Wizard panel — sticky band above fixed Coauthor dock */
.ch-wizard-dock-panel{
  position: sticky;
  bottom: var(--if-ai-dock-clearance, 124px);
  z-index: 35;
  margin-top: 20px;
  background: var(--paper);
  border: 0.5px solid var(--rule);
  border-radius: 10px;
  box-shadow:
    0 1px 0 rgba(255,255,255,.65) inset,
    0 -8px 28px -12px rgba(42,36,25,.12);
  max-width: 880px;
  margin-left: auto;
  margin-right: auto;
}
.ch-wizard-dock-head{
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 0.5px solid var(--rule);
  background: var(--paper-2);
  border-radius: 10px 10px 0 0;
}
.ch-wizard-dock-title{
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-2);
}
.ch-wizard-dock-title svg{ color: var(--plot-ochre); flex-shrink: 0; }
.ch-wizard-dock-body{
  padding: 16px 18px 18px;
}
.ch-wizard-dock-grid{
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 16px;
}
.ch-wizard-field-span2{ grid-column: 1 / -1; }
.ch-wizard-input{
  width: 100%;
  font: inherit;
  font-family: var(--serif);
  font-size: 15px;
  padding: 10px 12px;
  background: var(--paper-2);
  border: 0.5px solid var(--rule);
  border-radius: 6px;
  color: var(--ink);
  outline: 0;
}
.ch-wizard-input:focus{
  border-color: var(--ink-4);
  background: var(--paper);
}
.ch-wizard-field-label-row{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}
.ch-wizard-link-add{
  appearance: none;
  border: 0;
  background: transparent;
  font: inherit;
  font-size: 11px;
  font-weight: 600;
  color: var(--plot-ochre);
  cursor: default;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.ch-wizard-faction-chips{
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.ch-wiz-fac-chip{
  appearance: none;
  border: 0.5px solid var(--rule);
  background: var(--paper-2);
  font: inherit;
  font-size: 12px;
  padding: 5px 11px;
  border-radius: 14px;
  cursor: default;
  color: var(--ink-2);
}
.ch-wiz-fac-chip.is-on{
  background: color-mix(in oklch, var(--plot-ochre) 10%, var(--paper));
  font-weight: 600;
  color: var(--ink);
}
.ch-wizard-rel-list{
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.ch-wizard-rel-row{
  display: grid;
  grid-template-columns: minmax(0, 38%) 1fr 28px;
  gap: 8px;
  align-items: center;
}
.ch-wizard-rel-remove{
  appearance: none;
  border: 0.5px solid var(--rule);
  background: var(--paper-2);
  width: 28px;
  height: 28px;
  border-radius: 4px;
  cursor: default;
  color: var(--ink-3);
  font-size: 16px;
  line-height: 1;
}
.ch-wizard-rel-remove:hover{ color: var(--ink); background: var(--paper); }
.ch-wizard-aware-inline{
  margin-top: 14px;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}
.ch-wizard-aware-inline .ch-wizard-aware-head{
  width: auto;
  margin-right: 6px;
}
.ch-wizard-dock-actions{
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 0.5px dashed var(--rule);
}
.ch-wizard-dock-proposal{
  margin-top: 18px;
  padding-top: 16px;
  border-top: 0.5px solid var(--rule);
}
.ch-wizard-dock-proposal-h{
  margin: 0 0 10px;
  font-family: var(--serif);
  font-size: 17px;
  font-weight: 500;
  color: var(--ink);
}

.ch-wizard-examples{
  display:flex; flex-wrap:wrap; gap: 6px; align-items:center;
  margin: 10px 0 4px;
}
.ch-wizard-examples-label{
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--ink-4); margin-right: 4px;
}
.ch-wizard-example{
  appearance:none; border: 0.5px solid var(--rule); background: var(--paper-2);
  color: var(--ink-2); font: inherit; font-family: var(--serif); font-style: italic;
  font-size: 12px;
  padding: 4px 10px; border-radius: 14px;
  cursor:default; text-align:left;
}
.ch-wizard-example:hover{ background: var(--paper); color: var(--ink); border-color: var(--ink-4); }

.ch-wizard-aware{
  display:flex; align-items:center; gap: 12px; flex-wrap: wrap;
  margin-top: 14px;
  padding: 10px 14px;
  background: color-mix(in oklch, var(--plot-ochre) 6%, var(--paper-2));
  border: 0.5px solid color-mix(in oklch, var(--plot-ochre) 18%, var(--rule));
  border-radius: 6px;
}
.ch-wizard-aware-head{
  font-family: var(--sans); font-size: 11px; font-weight: 600;
  color: var(--ink-2);
}
.ch-wizard-aware-chips{ display:flex; flex-wrap:wrap; gap: 5px; }
.ch-wizard-aware-chip{
  font-family: var(--mono); font-size: 10.5px; color: var(--ink-2);
  padding: 2px 7px; background: var(--paper); border: 0.5px solid var(--rule);
  border-radius: 11px;
}

.ch-wizard-cta-row{
  display:flex; justify-content:flex-end; gap: 8px;
  margin-top: 18px;
}
.ch-wizard-cancel{
  appearance:none; border: 0.5px solid var(--rule); background: transparent;
  color: var(--ink-2); font: inherit; font-size: 12.5px;
  padding: 8px 16px; border-radius: 6px; cursor:default;
}
.ch-wizard-cancel:hover{ background: var(--paper-2); color: var(--ink); }
.ch-wizard-go{
  appearance:none; border:0; cursor:default;
  display:inline-flex; align-items:center; gap: 7px;
  padding: 8px 18px;
  background: var(--ink); color: var(--paper);
  font: inherit; font-size: 13px; font-weight: 500;
  border-radius: 6px;
}
.ch-wizard-go:hover:not(:disabled){ background: var(--ink-2); }
.ch-wizard-go:disabled{ opacity: 0.4; }

/* Thinking spinner */
.ch-wizard-thinking{
  display:flex; flex-direction:column; gap: 8px;
  padding: 14px 16px;
  background: var(--paper-2);
  border: 0.5px solid var(--rule); border-radius: 6px;
}
.ch-wizard-think-line{
  display:flex; align-items:center; gap: 10px;
  font-family: var(--serif); font-style: italic; font-size: 13px;
  color: var(--ink-3);
}
.ch-think-dot{
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--plot-ochre);
  animation: ch-think 1.4s ease-in-out infinite;
}
.ch-wizard-think-line:nth-child(2) .ch-think-dot{ animation-delay: 0.35s; }
.ch-wizard-think-line:nth-child(3) .ch-think-dot{ animation-delay: 0.7s; }
@keyframes ch-think{
  0%,100%{ opacity: 0.25; transform: scale(0.85); }
  50%    { opacity: 1;    transform: scale(1.1); }
}

.ch-wizard-error{
  padding: 12px 14px;
  background: color-mix(in oklch, var(--plot-burgundy) 8%, var(--paper));
  border: 0.5px solid color-mix(in oklch, var(--plot-burgundy) 24%, var(--rule));
  color: var(--plot-burgundy);
  font-family: var(--serif); font-size: 13px;
  border-radius: 6px;
}

/* Proposal card */
.ch-proposal{ display:flex; flex-direction:column; gap: 14px; }
.ch-proposal-card{
  background: var(--paper-2);
  border: 0.5px solid var(--rule);
  border-radius: 6px;
  padding: 18px 20px;
  display:flex; flex-direction:column; gap: 14px;
  position: relative;
}
.ch-proposal-card::before{
  content:"Coauthor proposal"; position:absolute; top: -8px; left: 16px;
  font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.1em;
  text-transform: uppercase;
  background: var(--paper);
  color: var(--plot-ochre);
  padding: 1px 8px; border: 0.5px solid var(--rule); border-radius: 3px;
}
.ch-proposal-row{
  display:flex; align-items:center; gap: 14px;
}
.ch-proposal-portrait{
  width: 52px; height: 52px; border-radius: 4px;
  background: color-mix(in oklch, var(--plot-slate) 18%, var(--paper));
  color: var(--plot-slate);
  display:flex; align-items:center; justify-content:center;
  font-family: var(--serif); font-size: 26px; font-weight: 500;
  border: 0.5px solid var(--rule);
}
.ch-proposal-name{ font-family: var(--serif); font-size: 22px; font-weight: 500; color: var(--ink); line-height: 1.1; }
.ch-proposal-role{ font-family: var(--serif); font-style: italic; font-size: 13.5px; color: var(--ink-3); margin-top: 2px; }

.ch-proposal-field{ display:flex; flex-direction:column; gap: 5px; }
.ch-proposal-field label{
  font-family: var(--sans); font-size: 9.5px; letter-spacing: 0.12em;
  text-transform: uppercase; color: var(--ink-4); font-weight: 600;
}
.ch-proposal-motivation{
  font-family: var(--serif); font-size: 14.5px; line-height: 1.5;
  color: var(--ink);
  padding: 8px 12px;
  background: var(--paper);
  border: 0.5px solid var(--rule);
  border-left: 3px solid var(--plot-ochre);
  border-radius: 0 4px 4px 0;
}
.ch-proposal-goals{
  list-style: decimal-leading-zero;
  margin: 0; padding: 0 0 0 26px;
  display:flex; flex-direction:column; gap: 3px;
  font-family: var(--serif); font-size: 13.5px; line-height: 1.5;
  color: var(--ink-2);
}
.ch-proposal-grid{
  display:grid; grid-template-columns: 1fr 1fr; gap: 14px;
}
.ch-proposal-desc{
  font-family: var(--serif); font-style: italic; font-size: 13.5px; line-height: 1.5;
  color: var(--ink-2);
}

.ch-proposal-actions{
  display:flex; justify-content: flex-end; gap: 8px;
}

/* tag x button */
.dp-tag-x{
  appearance:none; border:0; background:transparent;
  color: var(--ink-4); cursor:default; font-size: 12px;
  margin-left: 4px; line-height: 1;
}
.dp-tag-x:hover{ color: var(--ink); }
.dp-tag{
  display:inline-flex; align-items:center; gap: 0;
}

/* Description sub-sections */
.ch-desc-sub{ display:flex; flex-direction:column; gap: 5px; margin-bottom: 14px; }
.ch-desc-sub:last-child{ margin-bottom: 0; }
.ch-desc-sub label{
  font-family: var(--sans); font-size: 10px; letter-spacing: 0.12em;
  text-transform: uppercase; color: var(--ink-4); font-weight: 600;
}

/* Traits */
.ch-traits{
  display:flex; flex-wrap:wrap; gap: 6px;
  margin-bottom: 12px;
}
.ch-trait-chip{
  display:inline-flex; align-items:center;
  font-family: var(--serif); font-size: 13.5px; font-style: italic;
  color: var(--ink);
  padding: 4px 10px; border-radius: 3px;
  background: color-mix(in oklch, var(--plot-burgundy) 9%, var(--paper-2));
  border: 0.5px solid color-mix(in oklch, var(--plot-burgundy) 22%, var(--rule));
}
.ch-trait-add{
  appearance:none; border: 0.5px dashed var(--rule); background: transparent;
  color: var(--ink-3); font: inherit; font-size: 11.5px;
  padding: 3px 10px; border-radius: 3px; cursor:default;
}
.ch-trait-add:hover{ color: var(--ink); border-style: solid; border-color: var(--ink-3); }
.ch-trait-suggest{
  display:flex; flex-wrap:wrap; align-items:center; gap: 4px;
  padding-top: 6px; border-top: 0.5px dashed var(--rule);
}
.ch-trait-suggest-label{
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--ink-4); margin-right: 4px;
}
.ch-trait-suggest-chip{
  appearance:none; border: 0.5px solid var(--rule); background: transparent;
  color: var(--ink-3); font: inherit; font-family: var(--serif);
  font-style: italic; font-size: 12px;
  padding: 2px 8px; border-radius: 11px; cursor: default;
}
.ch-trait-suggest-chip:hover{ background: var(--paper-2); color: var(--ink); border-color: var(--ink-4); }

/* Origin story */
.ch-optional{
  font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--ink-4); font-weight: 500;
  padding: 1px 7px; border-radius: 11px; background: var(--paper-2);
  border: 0.5px solid var(--rule); margin-left: 8px;
}
.ch-origin-empty-cta{
  display:flex; gap: 8px; flex-wrap: wrap;
  padding: 18px 0 6px;
}
.ch-origin-add-btn{
  appearance:none; border: 0.5px dashed var(--rule); background: transparent;
  color: var(--ink-2); font: inherit; font-size: 12.5px;
  padding: 8px 14px; border-radius: 6px; cursor:default;
}
.ch-origin-add-btn:hover{ border-style: solid; border-color: var(--ink-3); color: var(--ink); }
.ch-origin-ai-btn{
  appearance:none; border: 0; cursor:default;
  display:inline-flex; align-items:center; gap: 7px;
  padding: 8px 14px;
  background: color-mix(in oklch, var(--plot-ochre) 14%, var(--paper-2));
  color: var(--ink);
  font: inherit; font-size: 12.5px; font-weight: 500;
  border-radius: 6px;
  border: 0.5px solid color-mix(in oklch, var(--plot-ochre) 32%, var(--rule));
}
.ch-origin-ai-btn:hover{ background: color-mix(in oklch, var(--plot-ochre) 22%, var(--paper-2)); }
.ch-origin-ai-btn svg{ color: var(--plot-ochre); }

.ch-origin-ai-mini{
  margin-left: auto;
  appearance:none; border: 0.5px solid var(--rule); background: var(--paper-2);
  color: var(--ink-2);
  display:inline-flex; align-items:center; gap: 5px;
  font: inherit; font-size: 11px; padding: 4px 9px; border-radius: 4px; cursor:default;
}
.ch-origin-ai-mini:hover{ background: var(--paper); color: var(--ink); }
.ch-origin-ai-mini svg{ color: var(--plot-ochre); }

.ch-origin-assist{
  display:flex; flex-direction:column; gap: 6px;
  padding: 12px 14px;
  background: color-mix(in oklch, var(--plot-ochre) 7%, var(--paper-2));
  border: 0.5px solid color-mix(in oklch, var(--plot-ochre) 22%, var(--rule));
  border-radius: 6px;
  margin-bottom: 12px;
}
.ch-origin-assist label{
  font-family: var(--sans); font-size: 10px; letter-spacing: 0.12em;
  text-transform: uppercase; color: var(--ink-3); font-weight: 600;
}
.ch-origin-assist textarea{
  font: inherit; font-family: var(--serif); font-size: 13.5px;
  padding: 8px 10px;
  background: var(--paper); border: 0.5px solid var(--rule); border-radius: 5px;
  color: var(--ink); outline: 0; resize: vertical;
}
.ch-origin-assist-row{
  display:flex; align-items:center; gap: 8px;
  margin-top: 4px;
}
.ch-origin-assist-ctx{
  flex: 1;
  font-family: var(--mono); font-size: 10px; color: var(--ink-3);
}

.ch-origin-body{
  font-family: var(--serif); font-size: 15px; line-height: 1.6;
  color: var(--ink); outline: 0;
  padding: 12px 16px;
  background: var(--paper-2);
  border: 0.5px solid var(--rule);
  border-left: 3px solid var(--ink-3);
  border-radius: 0 4px 4px 0;
  text-wrap: pretty;
}
.ch-origin-body:focus{ background: var(--paper); }

/* Make beats look clickable + selected state */
.ch-ctx-beat{ cursor: default; transition: background 120ms; position: relative; }
.ch-ctx-beat:hover{ background: var(--paper-2); }
.ch-ctx-beat.is-selected{
  background: color-mix(in oklch, var(--plot-burgundy) 8%, var(--paper));
  box-shadow: inset 2px 0 0 var(--plot-burgundy);
}

/* ── Node detail pane (rightmost) ─────────────────────────────────────── */
.ch-node-pane{
  width: 360px;
  background: var(--paper);
  border-left: 0.5px solid var(--rule);
  display: flex; flex-direction: column;
  height: 100%;
  animation: ch-node-slide-in 180ms ease-out;
}
@keyframes ch-node-slide-in{
  from { transform: translateX(8px); opacity: 0; }
  to   { transform: translateX(0);   opacity: 1; }
}
.ch-node-head{
  padding: 16px 18px 14px;
  border-bottom: 0.5px solid var(--rule);
  background: var(--paper-2);
}
.ch-node-eyebrow{
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 10px;
}
.ch-node-book{
  font-family: var(--mono); font-size: 10px; font-weight: 700;
  color: #fff; letter-spacing: 0.04em;
  padding: 2px 6px; border-radius: 3px;
}
.ch-node-chap{
  font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--ink-3);
}
.ch-node-close{
  margin-left: auto;
  appearance: none; border: 0; background: transparent;
  color: var(--ink-3); cursor: default;
  width: 24px; height: 24px; border-radius: 4px;
  display: inline-flex; align-items: center; justify-content: center;
}
.ch-node-close:hover{ background: var(--rule); color: var(--ink); }
.ch-node-title{
  font-family: var(--serif); font-size: 21px; font-weight: 500;
  color: var(--ink); margin: 0 0 8px; line-height: 1.2;
  text-wrap: pretty;
}
.ch-node-meta{
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px;
  font-family: var(--sans); font-size: 11px;
}
.ch-node-status{
  font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.1em;
  text-transform: uppercase; font-weight: 600;
  padding: 2px 7px; border-radius: 2px;
  background: var(--paper); border: 0.5px solid var(--rule); color: var(--ink-3);
}
.ch-node-status.s-done{ color: #2d6a4f; border-color: #2d6a4f55; background: #2d6a4f11; }
.ch-node-status.s-draft{ color: #a37b2a; border-color: #a37b2a55; background: #a37b2a11; }
.ch-node-status.s-idea{ color: var(--ink-4); }
.ch-node-plot{ display:inline-flex; align-items:center; gap: 5px; color: var(--ink-3); }
.ch-node-plot-dot{ width: 8px; height: 8px; border-radius: 50%; }
.ch-node-loc{ color: var(--ink-4); font-style: italic; }

.ch-node-scroll{
  flex: 1; min-height: 0; overflow-y: auto;
  padding: 18px;
  display: flex; flex-direction: column; gap: 20px;
}
.ch-node-section-label{
  font-family: var(--sans); font-size: 10px; letter-spacing: 0.12em;
  text-transform: uppercase; color: var(--ink-4); font-weight: 600;
  margin-bottom: 6px;
}
.ch-node-body{
  font-family: var(--serif); font-size: 14px; line-height: 1.55;
  color: var(--ink); margin: 0; text-wrap: pretty;
}
.ch-node-chars{ display: flex; flex-direction: column; gap: 6px; }
.ch-node-char{
  display: inline-flex; align-items: center; gap: 8px;
  font-family: var(--sans); font-size: 12.5px; color: var(--ink);
}
.ch-node-char-dot{
  width: 22px; height: 22px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  color: #fff; font-family: var(--sans); font-size: 10.5px; font-weight: 600;
}
.ch-node-tags{ display: flex; flex-wrap: wrap; gap: 5px; }
.ch-node-tag{
  font-family: var(--mono); font-size: 10.5px; color: var(--ink-3);
  padding: 2px 7px; border-radius: 3px; background: var(--paper-2);
  border: 0.5px solid var(--rule);
}
.ch-node-jump{
  font-family: var(--sans); font-size: 12px; color: var(--ink);
  text-decoration: none; padding: 8px 12px; border-radius: 4px;
  background: var(--paper-2); border: 0.5px solid var(--rule);
  display: inline-block; align-self: flex-start;
}
.ch-node-jump:hover{ background: var(--paper); border-color: var(--ink-3); }

/* Story Graph uses `.canvas-col .toolbar` and `.zoom-pill` (see app.jsx + canvas.jsx).
   Do not hide them globally here — that removed add/delete/zoom from the graph. */

/* Character top bar: List / Relationships toggle follows saved line in .story-meta (does not cover title). */
.ch-story-meta-with-viewtoggle{
  flex-wrap: wrap;
  justify-content: center;
  row-gap: 6px;
  column-gap: 8px;
}
.ch-story-meta-with-viewtoggle .ch-character-viewtoggle{
  flex-shrink: 0;
}
/* Global `.viewtoggle` is absolutely positioned (outline UI); inline in meta needs normal flow. */
.ch-story-meta-with-viewtoggle .viewtoggle{
  position: relative;
  top: auto;
  left: auto;
  transform: none;
  z-index: 1;
  box-shadow: 0 1px 5px rgba(0, 0, 0, 0.06);
}

/* Cast row: map-mode drag handle beside the pick button */
.ch-cast-row.ch-cast-row--map{
  display: flex;
  align-items: stretch;
  gap: 0;
}
.ch-cast-dnd{
  flex: 0 0 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: grab;
  color: var(--ink-4);
  font-size: 11px;
  letter-spacing: -0.06em;
  user-select: none;
  border-radius: 7px 0 0 7px;
  align-self: stretch;
}
.ch-cast-dnd:hover{
  background: var(--paper-2);
  color: var(--ink-2);
}
.ch-cast-dnd:active{ cursor: grabbing; }
.ch-cast-row.ch-cast-row--map .ch-cast-btn{
  border-radius: 0 7px 7px 0;
  flex: 1;
  min-width: 0;
}

/* ── Relationship map panel (Map view) ───────────────────────────────────── */
.ch-relmap-canvas{
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.ch-character-viewtoggle{
  flex-shrink: 0;
}
.ch-relmap-root{
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 16px 20px 100px;
  background: var(--paper-2);
}
.ch-relmap-root--detective{
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 12px 16px 20px;
  background:
    radial-gradient(ellipse 120% 80% at 50% -20%, rgba(139, 30, 30, 0.07), transparent 55%),
    linear-gradient(180deg, #2a2218 0%, #1f1a14 42%, #18140f 100%);
  color: #e8dfd0;
}
.ch-relmap-root--detective .ch-relmap-title{
  color: #f4ead8;
  letter-spacing: 0.02em;
}
.ch-relmap-root--detective .ch-relmap-lede{
  color: rgba(232, 223, 208, 0.78);
}
.ch-relmap-root--detective .ch-relmap-lede strong{
  color: #f0c9a8;
  font-weight: 600;
}
.ch-relmap-head{
  max-width: none;
  margin: 0 0 12px;
  flex-shrink: 0;
}
.ch-relmap-root--detective .ch-relmap-newrel-btn,
.ch-relmap-root--detective .ch-relmap-connect-btn,
.ch-relmap-root--detective .ch-relmap-rebuild-btn{
  background: rgba(20, 16, 12, 0.55);
  border-color: rgba(240, 201, 168, 0.22);
  color: #f4ead8;
}
.ch-relmap-root--detective .ch-relmap-newrel-btn:hover:not(:disabled),
.ch-relmap-root--detective .ch-relmap-connect-btn:hover,
.ch-relmap-root--detective .ch-relmap-rebuild-btn:hover:not(:disabled){
  background: rgba(36, 28, 20, 0.85);
  border-color: rgba(240, 201, 168, 0.38);
}
.ch-relmap-root--detective .ch-relmap-connect-btn.is-on{
  background: #8b1e1e;
  border-color: #a52828;
  color: #fff8f0;
}
.ch-relmap-body{
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: row;
  align-items: stretch;
  gap: 14px;
}
.ch-relmap-filter{
  flex: 0 0 220px;
  min-width: 200px;
  max-height: 100%;
  display: flex;
  flex-direction: column;
  background: rgba(20, 16, 12, 0.55);
  border: 1px solid rgba(240, 201, 168, 0.16);
  border-radius: 8px;
  overflow: hidden;
}
.ch-relmap-filter-head{
  padding: 12px 12px 10px;
  border-bottom: 1px solid rgba(240, 201, 168, 0.12);
}
.ch-relmap-filter-title{
  margin: 0 0 6px;
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #f0c9a8;
}
.ch-relmap-filter-lede{
  margin: 0 0 10px;
  font-size: 11px;
  line-height: 1.45;
  color: rgba(232, 223, 208, 0.68);
}
.ch-relmap-filter-actions{
  display: flex;
  gap: 8px;
  margin-bottom: 6px;
}
.ch-relmap-filter-btn{
  appearance: none;
  font-family: var(--sans);
  font-size: 11px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 6px;
  cursor: pointer;
  background: rgba(36, 28, 20, 0.8);
  border: 0.5px solid rgba(240, 201, 168, 0.22);
  color: #f4ead8;
}
.ch-relmap-filter-btn:hover:not(:disabled){
  border-color: rgba(240, 201, 168, 0.38);
}
.ch-relmap-filter-btn:disabled{
  opacity: 0.45;
  cursor: not-allowed;
}
.ch-relmap-filter-count{
  margin: 0;
  font-size: 11px;
  color: rgba(232, 223, 208, 0.55);
}
.ch-relmap-filter-list{
  list-style: none;
  margin: 0;
  padding: 6px 6px 10px;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}
.ch-relmap-filter-row{
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 8px;
  border-radius: 6px;
  cursor: pointer;
  color: rgba(244, 234, 216, 0.88);
}
.ch-relmap-filter-row:hover{
  background: rgba(255, 255, 255, 0.05);
}
.ch-relmap-filter-row.is-on{
  background: rgba(139, 30, 30, 0.22);
}
.ch-relmap-filter-check{
  flex-shrink: 0;
  accent-color: #c41e1e;
}
.ch-relmap-filter-swatch{
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.35);
}
.ch-relmap-filter-labels{
  display: flex;
  flex-direction: column;
  min-width: 0;
  gap: 1px;
}
.ch-relmap-filter-name{
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ch-relmap-filter-role{
  font-size: 10px;
  color: rgba(232, 223, 208, 0.55);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ch-relmap-work--board{
  flex: 1;
  min-height: 0;
  min-width: 0;
  max-width: none;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.ch-relmap-rel-panel{
  flex-shrink: 0;
  max-height: min(42vh, 380px);
  display: flex;
  flex-direction: column;
  background: rgba(20, 16, 12, 0.45);
  border: 1px solid rgba(240, 201, 168, 0.14);
  border-radius: 8px;
  overflow: hidden;
}
.ch-relmap-rel-panel-head{
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid rgba(240, 201, 168, 0.1);
}
.ch-relmap-rel-panel-title{
  margin: 0;
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: #f0c9a8;
}
.ch-relmap-rel-panel-count{
  font-size: 11px;
  color: rgba(232, 223, 208, 0.55);
}
.ch-relmap-rel-panel-hint{
  margin: 0;
  padding: 14px 16px;
  font-size: 12.5px;
  line-height: 1.45;
  color: rgba(232, 223, 208, 0.65);
}
.ch-relmap-rel-cards{
  overflow-y: auto;
  padding: 10px 12px 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.ch-relmap-rel-card{
  background: #f8f4ea;
  border: 1px solid rgba(42, 36, 25, 0.28);
  border-radius: 6px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  overflow: hidden;
}
.ch-relmap-rel-card.is-highlighted{
  border-color: #c41e1e;
  box-shadow: 0 0 0 1px rgba(196, 30, 30, 0.35), 0 4px 14px rgba(0, 0, 0, 0.25);
}
.ch-relmap-rel-card-head{
  width: 100%;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 4px 4px 0;
}
.ch-relmap-rel-card-head-main{
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding: 6px 8px 6px 12px;
  border: 0;
  background: transparent;
  cursor: pointer;
  text-align: left;
  font: inherit;
  color: #2a2418;
}
.ch-relmap-rel-card-head-main:hover{
  background: rgba(42, 36, 25, 0.05);
}
.ch-relmap-rel-card-pair{
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 8px;
  flex: 1;
  min-width: 0;
}
.ch-relmap-rel-card-name{
  font-weight: 600;
  font-size: 13.5px;
}
.ch-relmap-rel-card-join{
  color: #8b1e1e;
  font-weight: 700;
}
.ch-relmap-rel-card-badge{
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(139, 30, 30, 0.12);
  color: #8b1e1e;
  border: 0.5px solid rgba(139, 30, 30, 0.25);
}
.ch-relmap-rel-card-chevron{
  flex-shrink: 0;
  appearance: none;
  border: 0;
  background: transparent;
  font-size: 12px;
  color: rgba(42, 36, 25, 0.55);
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 4px;
}
.ch-relmap-rel-card-chevron:hover{
  background: rgba(42, 36, 25, 0.08);
  color: #2a2418;
}
.ch-relmap-rel-card-body{
  padding: 0 12px 12px;
  border-top: 0.5px solid rgba(42, 36, 25, 0.12);
}
.ch-relmap-rel-card-relations{
  margin: 10px 0 8px;
  font-size: 13px;
  line-height: 1.5;
  color: #2a2418;
  white-space: pre-wrap;
}
.ch-relmap-rel-card-feel{
  margin-bottom: 8px;
  padding: 8px 10px;
  background: rgba(42, 36, 25, 0.05);
  border-radius: 6px;
}
.ch-relmap-rel-card-feel-label{
  display: block;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: rgba(42, 36, 25, 0.55);
  margin-bottom: 4px;
}
.ch-relmap-rel-card-feel p{
  margin: 0;
  font-size: 12.5px;
  line-height: 1.45;
}
.ch-relmap-rel-card-incidents{
  margin: 0 0 10px;
  padding-left: 1.1rem;
  font-size: 12.5px;
}
.ch-relmap-rel-card-inc-title{
  font-weight: 600;
}
.ch-relmap-rel-card-inc-notes{
  margin: 4px 0 6px;
  color: rgba(42, 36, 25, 0.72);
}
.ch-relmap-rel-card-muted{
  margin: 8px 0 10px;
  font-size: 12px;
  font-style: italic;
  color: rgba(42, 36, 25, 0.55);
}
.ch-relmap-rel-card-actions{
  display: flex;
  justify-content: flex-end;
}
@media (max-width: 900px){
  .ch-relmap-body{
    flex-direction: column;
  }
  .ch-relmap-filter{
    flex: 0 0 auto;
    max-height: 200px;
  }
}
.ch-relmap-board-foot{
  margin: 0;
  padding: 0 4px 2px;
  font-size: 12px;
  color: rgba(232, 223, 208, 0.62);
  text-align: center;
  flex-shrink: 0;
}
.ch-relmap-head-row{
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}
.ch-relmap-toolbar{
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}
.ch-relmap-newrel-btn{
  appearance: none;
  flex-shrink: 0;
  font-family: var(--sans);
  font-size: 12.5px;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: 8px;
  cursor: pointer;
  background: var(--paper-2);
  border: 0.5px solid var(--rule);
  color: var(--ink);
}
.ch-relmap-newrel-btn:hover:not(:disabled){
  border-color: rgba(42, 36, 25, 0.22);
  background: var(--paper);
}
.ch-relmap-newrel-btn:disabled{
  opacity: 0.45;
  cursor: not-allowed;
}
.ch-relmap-connect-btn{
  appearance: none;
  flex-shrink: 0;
  font-family: var(--sans);
  font-size: 12.5px;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: 8px;
  cursor: pointer;
  background: var(--paper);
  border: 0.5px solid var(--rule);
  color: var(--ink);
  max-width: 280px;
  line-height: 1.25;
}
.ch-relmap-connect-btn:hover{
  border-color: rgba(42, 36, 25, 0.22);
  background: var(--paper-2);
}
.ch-relmap-connect-btn.is-on{
  background: #2a2418;
  color: #faf7f0;
  border-color: #2a2418;
}
.ch-relmap-connect-btn.is-on:hover{
  background: #1f1d18;
}
.ch-relmap-work{
  max-width: 920px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.ch-relmap-stage{
  position: relative;
  flex: 1;
  min-height: 360px;
  min-width: 0;
  border: 1px dashed rgba(42, 36, 25, 0.18);
  border-radius: 12px;
  background: var(--paper);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.35);
}
.ch-relmap-stage--detective{
  flex: 1;
  min-height: min(72vh, 640px);
  border: 2px solid rgba(62, 48, 34, 0.9);
  border-radius: 4px;
  background:
    radial-gradient(circle at 18% 22%, rgba(139, 30, 30, 0.12), transparent 38%),
    radial-gradient(circle at 82% 68%, rgba(42, 36, 25, 0.35), transparent 45%),
    linear-gradient(145deg, #6b4f2e 0%, #5a4228 18%, #4a3722 55%, #3d2e1c 100%);
  box-shadow:
    inset 0 0 80px rgba(0, 0, 0, 0.35),
    0 8px 28px rgba(0, 0, 0, 0.45);
  overflow: hidden;
}
.ch-relmap-stage-grain{
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.22;
  background-image:
    repeating-linear-gradient(
      -12deg,
      transparent,
      transparent 3px,
      rgba(0, 0, 0, 0.04) 3px,
      rgba(0, 0, 0, 0.04) 4px
    );
  mix-blend-mode: multiply;
}
.ch-relmap-svg{
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: auto;
}
.ch-relmap-line{
  stroke: var(--ink-3);
  stroke-width: 1.35;
  stroke-opacity: 0.5;
  pointer-events: none;
}
.ch-relmap-stage--detective .ch-relmap-line{
  stroke: #c41e1e;
  stroke-width: 2.1;
  stroke-opacity: 0.82;
  filter: drop-shadow(0 0 2px rgba(196, 30, 30, 0.35));
}
.ch-relmap-line-hit{
  stroke: transparent;
  stroke-width: 18;
  cursor: pointer;
  pointer-events: stroke;
}
.ch-relmap-stage--detective .ch-relmap-line-hit{
  stroke-width: 22;
}
.ch-relmap-edge-g:hover .ch-relmap-line{
  stroke-opacity: 0.88;
  stroke: var(--ink-2);
}
.ch-relmap-stage--detective .ch-relmap-edge-g:hover .ch-relmap-line,
.ch-relmap-stage--detective .ch-relmap-edge-g.is-selected .ch-relmap-line{
  stroke: #ff4d4d;
  stroke-width: 2.6;
  stroke-opacity: 1;
}
.ch-relmap-edge-label{
  font-family: var(--sans);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  fill: #f4ead8;
  text-anchor: middle;
  dominant-baseline: middle;
  paint-order: stroke fill;
  stroke: rgba(24, 18, 12, 0.85);
  stroke-width: 3px;
  pointer-events: all;
  cursor: pointer;
}
.ch-relmap-edge-label:hover{
  fill: #ffd4a8;
}
.ch-relmap-edge-g.is-selected .ch-relmap-edge-label{
  fill: #ffd4a8;
}
.ch-relmap-drop-hint{
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  pointer-events: none;
  max-width: 360px;
  padding: 16px 20px;
  z-index: 1;
}
.ch-relmap-drop-hint p{
  margin: 0 0 8px;
  font-size: 14px;
  color: var(--ink-2);
  line-height: 1.45;
}
.ch-relmap-stage--detective .ch-relmap-drop-hint p{
  color: rgba(244, 234, 216, 0.9);
}
.ch-relmap-drop-hint-sub{
  font-size: 12.5px !important;
  color: var(--ink-3) !important;
  margin-bottom: 0 !important;
}
.ch-relmap-stage--detective .ch-relmap-drop-hint-sub{
  color: rgba(244, 234, 216, 0.62) !important;
}
.ch-relmap-node{
  position: absolute;
  display: flex;
  flex-direction: row;
  align-items: stretch;
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 9px;
  box-shadow: 0 2px 10px rgba(42, 36, 25, 0.08);
  overflow: hidden;
  z-index: 2;
}
.ch-relmap-node.is-anchor{
  outline: 2px solid var(--ink);
  outline-offset: 1px;
}
.ch-relmap-node--pin{
  flex-direction: column;
  align-items: stretch;
  background: #f8f4ea;
  border: 1px solid rgba(42, 36, 25, 0.35);
  border-radius: 2px;
  box-shadow:
    2px 4px 12px rgba(0, 0, 0, 0.35),
    0 0 0 1px rgba(255, 255, 255, 0.25) inset;
  transform: rotate(var(--ch-relmap-pin-rotate, 0deg));
  transform-origin: 50% 12px;
}
.ch-relmap-node--pin.is-anchor{
  outline: 2px solid #ff6b4a;
  outline-offset: 2px;
}
.ch-relmap-node-pin{
  position: absolute;
  top: -7px;
  left: 50%;
  width: 11px;
  height: 11px;
  margin-left: -5px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #e8e8e8, #8a8a8a 55%, #4a4a4a);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.45);
  z-index: 3;
}
.ch-relmap-node--pin .ch-relmap-node-grip{
  flex: 0 0 22px;
  width: 100%;
  border-radius: 0;
  background: rgba(42, 36, 25, 0.06);
  border-bottom: 0.5px solid rgba(42, 36, 25, 0.12);
}
.ch-relmap-node--pin .ch-relmap-node-body{
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 4px 8px 8px;
  gap: 4px;
}
.ch-relmap-node-text{
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 0;
  gap: 1px;
}
.ch-relmap-node-role{
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ch-relmap-accent, #8b1e1e);
  opacity: 0.9;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ch-relmap-node--pin .ch-relmap-node-bubble{
  width: 32px;
  height: 32px;
  border: 2px solid var(--ch-relmap-accent, #8b1e1e);
  background: #fffdf8;
  color: var(--ch-relmap-accent, #8b1e1e);
}
.ch-relmap-root--detective .ch-relmap-empty{
  background: rgba(20, 16, 12, 0.72);
  border-color: rgba(240, 201, 168, 0.2);
  color: rgba(232, 223, 208, 0.85);
}
.ch-relmap-root--detective .ch-relmap-empty-hint{
  color: rgba(232, 223, 208, 0.62) !important;
}
.ch-relmap-node-grip{
  flex: 0 0 26px;
  border: 0;
  background: var(--paper-2);
  cursor: grab;
  font-size: 11px;
  letter-spacing: -0.06em;
  color: var(--ink-4);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.ch-relmap-node-grip:active{ cursor: grabbing; }
.ch-relmap-node-body{
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px 6px 4px;
  border: 0;
  background: transparent;
  text-align: left;
  cursor: pointer;
  font: inherit;
  min-width: 0;
}
.ch-relmap-node-body:hover{
  color: var(--ink);
}
.ch-relmap-node-bubble{
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  background: var(--paper-2);
  border: 0.5px solid var(--rule);
  flex-shrink: 0;
}
.ch-relmap-node-name{
  font-family: var(--sans);
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ch-relmap-empty-below{
  margin-top: 0;
  margin-bottom: 0;
}
.ch-relmap-rebuild-btn{
  appearance: none;
  flex-shrink: 0;
  font-family: var(--sans);
  font-size: 12.5px;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: 8px;
  cursor: pointer;
  background: var(--paper);
  border: 0.5px solid var(--rule);
  color: var(--ink);
}
.ch-relmap-rebuild-btn:hover{
  border-color: rgba(42, 36, 25, 0.22);
  background: var(--paper-2);
}
.ch-relmap-rebuild-btn.is-primary{
  margin-top: 16px;
  background: #2a2418;
  color: #faf7f0;
  border-color: #2a2418;
}
.ch-relmap-rebuild-btn.is-primary:hover{
  background: #1f1d18;
}
.ch-relmap-title{
  margin: 0 0 8px;
  font-family: var(--serif);
  font-weight: 600;
  font-style: italic;
  font-size: 1.35rem;
  color: var(--ink);
}
.ch-relmap-lede{
  margin: 0;
  font-size: 13px;
  line-height: 1.55;
  color: var(--ink-2);
  max-width: 62ch;
}
.ch-relmap-empty{
  max-width: 520px;
  margin: 40px auto;
  padding: 24px 28px;
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 10px;
  text-align: center;
}
.ch-relmap-empty p{ margin: 0 0 10px; color: var(--ink-2); font-size: 14px; line-height: 1.5; }
.ch-relmap-empty-hint{ font-size: 12.5px !important; color: var(--ink-3) !important; }
.ch-relmap-empty code{ font-size: 11px; }

.ch-relmap-grid{
  max-width: 920px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.ch-relmap-card{
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 10px;
  padding: 16px 18px;
  box-shadow: 0 1px 0 var(--rule-2);
}
.ch-relmap-pair{
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px 12px;
  margin-bottom: 12px;
  font-family: var(--sans);
}
.ch-relmap-summaries{
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 14px;
  padding: 12px 14px;
  background: var(--paper-2);
  border: 0.5px solid var(--rule-2);
  border-radius: 8px;
}
.ch-relmap-dir-label{
  display: block;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: 4px;
}
.ch-relmap-dir-text{
  margin: 0;
  font-size: 13px;
  line-height: 1.5;
  color: var(--ink);
  white-space: pre-wrap;
}
.ch-relmap-name{
  font-weight: 600;
  font-size: 15px;
  color: var(--ink);
}
.ch-relmap-join{ color: var(--ink-4); font-weight: 500; }
.ch-relmap-kind{
  margin-left: auto;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-3);
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--paper-3);
  border: 0.5px solid var(--rule);
}
.ch-relmap-no-inc{
  margin: 0;
  font-size: 13px;
  color: var(--ink-3);
  font-style: italic;
}
.ch-relmap-incidents{
  margin: 0;
  padding-left: 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.ch-relmap-inc-title{
  font-weight: 600;
  font-size: 13px;
  color: var(--ink);
}
.ch-relmap-inc-notes{
  margin: 4px 0 6px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--ink-2);
}
.ch-relmap-chap-btn{
  appearance: none;
  font-family: var(--sans);
  font-size: 12px;
  padding: 5px 12px;
  border-radius: 6px;
  cursor: pointer;
  background: var(--paper-2);
  border: 0.5px solid var(--rule);
  color: var(--ink);
}
.ch-relmap-chap-btn:hover{
  border-color: rgba(42, 36, 25, 0.22);
  background: var(--paper);
}

.ch-relmap-card--clickable{
  cursor: pointer;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.ch-relmap-card--clickable:hover{
  border-color: rgba(42, 36, 25, 0.28);
  box-shadow: 0 2px 10px rgba(42, 36, 25, 0.06);
}
.ch-relmap-card--clickable:focus-visible{
  box-shadow: 0 0 0 2px var(--paper), 0 0 0 4px var(--ink-3);
}

/* Relationship pair editor (map line or list card) */
.ch-rel-pair-overlay{
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px 14px;
  font-family: var(--sans);
}
.ch-rel-pair-backdrop{
  position: absolute;
  inset: 0;
  margin: 0;
  padding: 0;
  border: 0;
  background: rgba(42, 36, 25, 0.38);
  cursor: pointer;
}
.ch-rel-pair-dialog{
  position: relative;
  z-index: 1;
  width: min(1120px, 100%);
  max-height: min(92vh, 900px);
  display: flex;
  flex-direction: column;
  background: var(--paper);
  border: 0.5px solid var(--rule);
  border-radius: 12px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.18);
  overflow: hidden;
}
.ch-rel-new-dialog{
  width: min(440px, 100%);
  max-height: none;
}
.ch-rel-new-body{
  padding: 16px 18px 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.ch-rel-new-lede{
  margin: 0;
  font-size: 13px;
  line-height: 1.45;
  color: var(--ink-2);
}
.ch-rel-new-select{
  margin-top: 4px;
  cursor: pointer;
}
.ch-rel-new-actions{
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 4px;
}
.ch-rel-new-actions .ch-relmap-rebuild-btn.is-primary{
  margin-top: 0;
}
.ch-rel-pair-dialog-head{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 0.5px solid var(--rule);
  background: var(--paper-2);
}
.ch-rel-pair-dialog-head h2{
  margin: 0;
  font-family: var(--serif);
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--ink);
}
.ch-rel-pair-close{
  appearance: none;
  border: 0;
  background: transparent;
  font-size: 22px;
  line-height: 1;
  color: var(--ink-3);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
}
.ch-rel-pair-close:hover{
  color: var(--ink);
  background: var(--paper);
}
.ch-rel-pair-columns{
  display: grid;
  grid-template-columns: minmax(200px, 1fr) minmax(280px, 1.35fr) minmax(200px, 1fr);
  gap: 0;
  flex: 1;
  min-height: 0;
  overflow: auto;
}
@media (max-width: 900px){
  .ch-rel-pair-columns{
    grid-template-columns: 1fr;
  }
}
.ch-rel-pair-char{
  padding: 18px 16px;
  border-right: 0.5px solid var(--rule-2);
  background: var(--paper-2);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 8px;
}
.ch-rel-pair-columns .ch-rel-pair-char:last-child{
  border-right: 0;
  border-left: 0.5px solid var(--rule-2);
}
@media (max-width: 900px){
  .ch-rel-pair-char{
    border-right: 0;
    border-bottom: 0.5px solid var(--rule-2);
  }
  .ch-rel-pair-columns .ch-rel-pair-char:last-child{
    border-left: 0;
    border-top: 0.5px solid var(--rule-2);
  }
}
.ch-rel-pair-profile-link{
  appearance: none;
  align-self: flex-end;
  margin: 0 0 4px;
  font-size: 11px;
  font-weight: 600;
  color: var(--ink-3);
  background: transparent;
  border: 0;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.ch-rel-pair-profile-link:hover{
  color: var(--ink);
}
.ch-rel-pair-portrait{
  margin-top: 4px;
}
.ch-rel-pair-bubble{
  width: 64px;
  height: 64px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  font-weight: 600;
  margin: 0 auto;
}
.ch-rel-pair-name{
  margin: 10px 0 0;
  font-family: var(--serif);
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--ink);
}
.ch-rel-pair-role{
  margin: 0;
  font-size: 12.5px;
  color: var(--ink-2);
}
.ch-rel-pair-archetype{
  margin: 0;
  font-size: 11.5px;
  color: var(--ink-3);
  font-style: italic;
}
.ch-rel-pair-desc{
  margin: 8px 0 0;
  font-size: 12px;
  line-height: 1.45;
  color: var(--ink-2);
  text-align: left;
  width: 100%;
}
.ch-rel-pair-editor{
  padding: 18px 20px 22px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: var(--paper);
  min-width: 0;
}
.ch-rel-pair-field{
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.ch-rel-pair-label{
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.ch-rel-pair-input,
.ch-rel-pair-textarea{
  font: inherit;
  font-size: 13px;
  padding: 8px 10px;
  border-radius: 8px;
  border: 0.5px solid var(--rule);
  background: var(--paper);
  color: var(--ink);
  width: 100%;
  box-sizing: border-box;
}
.ch-rel-pair-textarea{
  resize: vertical;
  min-height: 72px;
  line-height: 1.45;
}
.ch-rel-pair-input:focus,
.ch-rel-pair-textarea:focus{
  outline: none;
  border-color: var(--ink-3);
  box-shadow: 0 0 0 2px rgba(42, 36, 25, 0.06);
}
.ch-rel-pair-incidents{
  margin-top: 4px;
  padding-top: 12px;
  border-top: 0.5px solid var(--rule-2);
}
.ch-rel-pair-inc-list{
  margin: 8px 0 0;
  padding-left: 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.ch-rel-pair-inc-title{
  font-weight: 600;
  font-size: 13px;
  color: var(--ink);
}
.ch-rel-pair-inc-notes{
  margin: 4px 0 0;
  font-size: 12.5px;
  color: var(--ink-2);
}
.ch-rel-pair-footer{
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 12px 18px;
  border-top: 0.5px solid var(--rule);
  background: var(--paper-2);
}
.ch-rel-pair-btn--danger{
  margin-right: auto;
  background: var(--paper);
  color: #8b1e1e;
  border-color: color-mix(in oklch, #8b1e1e 35%, var(--rule));
  font-weight: 600;
}
.ch-rel-pair-btn--danger:hover{
  border-color: #8b1e1e;
  background: color-mix(in oklch, #8b1e1e 8%, var(--paper));
}
.ch-rel-pair-btn{
  appearance: none;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 8px 18px;
  border-radius: 8px;
  cursor: pointer;
  border: 0.5px solid var(--rule);
}
.ch-rel-pair-btn--ghost{
  background: var(--paper);
  color: var(--ink);
}
.ch-rel-pair-btn--ghost:hover{
  border-color: var(--ink-3);
}
.ch-rel-pair-btn--primary{
  background: #2a2418;
  color: #faf7f0;
  border-color: #2a2418;
}
.ch-rel-pair-btn--primary:hover{
  background: #1f1d18;
}

.ch-rel-pair-section-lead{
  margin: 0 0 4px;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--ink-2);
}
.ch-rel-pair-hint{
  display: block;
  font-size: 11px;
  font-weight: 400;
  letter-spacing: 0;
  text-transform: none;
  color: var(--ink-4);
  line-height: 1.4;
  margin-bottom: 2px;
}
.ch-rel-pair-section{
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-top: 4px;
  margin-top: 4px;
  border-top: 0.5px solid var(--rule-2);
}
.ch-rel-pair-section-title{
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink);
}
.ch-relmap-relations{
  margin: 0 0 12px;
  font-size: 13px;
  line-height: 1.45;
  color: var(--ink-2);
  white-space: pre-wrap;
}
