/* ---------------------------------------------------------------- tokens */
:root {
  /* A warm paper tone: easier on the eyes than cool grey for long sessions. */
  --canvas-bg: #f4f1ea;
  --surface: #fffefb;
  --surface-2: #f6f2ea;
  --border: #e7e0d4;
  --border-strong: #d7cec0;
  --text: #2b2723;
  --text-soft: #6f675c;
  --root-bg: #fffefb;
  --root-text: #2b2723;
  --node-hover: rgba(43, 39, 35, 0.06);
  --hl-yellow: #fae6a3;
  --hl-green: #cbe9c4;
  --hl-blue: #c7e0f6;
  --hl-pink: #f8cedc;
  --accent: #6257e8;
  --accent-soft: #eeecff;
  --danger: #e11d48;
  --warning: #b45309;
  --success: #15803d;
  --scripture: #1d4ed8;
  --text-faint: #9d9488;
  --shadow-sm: 0 1px 2px rgba(60, 50, 35, 0.08), 0 1px 3px rgba(60, 50, 35, 0.06);
  --shadow-md: 0 6px 16px rgba(60, 50, 35, 0.12), 0 2px 4px rgba(60, 50, 35, 0.07);
  --shadow-lg: 0 18px 40px rgba(60, 50, 35, 0.18);
  --radius: 10px;
  --font: Inter, "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --topbar-h: 56px;
  color-scheme: light;
}

[data-theme='dark'] {
  --canvas-bg: #1b1917;
  --surface: #252220;
  --surface-2: #2c2825;
  --border: #383330;
  --border-strong: #4a443e;
  --text: #f0ebe4;
  --text-soft: #a9a094;
  --root-bg: #2b2724;
  --root-text: #f0ebe4;
  --node-hover: rgba(240, 235, 228, 0.08);
  --hl-yellow: #6b5a16;
  --hl-green: #1f5133;
  --hl-blue: #1d4463;
  --hl-pink: #5e2340;
  --accent: #8f87f5;
  --accent-soft: #302b46;
  --warning: #fbbf24;
  --success: #4ade80;
  --scripture: #9db8fb;
  --text-faint: #7f766b;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 8px 20px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 20px 44px rgba(0, 0, 0, 0.55);
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  font-family: var(--font);
  color: var(--text);
  background: var(--canvas-bg);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

/* ---------------------------------------------------------------- topbar */
.topbar {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 16px;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: relative;
  z-index: 20;
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: 650;
  letter-spacing: -0.01em;
  color: var(--text);
}

.brand-mark {
  width: 26px;
  height: 26px;
  color: var(--accent);
}

.topbar-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0; /* labels must never wrap onto a second line */
}

.topbar-group.right {
  margin-left: auto;
  /* The bar scrolls horizontally when it runs out of room, so the controls
     you reach for most are pinned and never scroll out of sight. */
  position: sticky;
  right: 0;
  padding-left: 28px;
  /* Fade whatever passes underneath rather than slicing it mid-word. */
  background: linear-gradient(to right, transparent, var(--surface) 26px);
}

.field {
  display: flex;
  align-items: center;
  gap: 6px;
}

.field-label {
  font-size: 12px;
  color: var(--text-soft);
}

select,
.btn {
  font: inherit;
  font-size: 13px;
  white-space: nowrap;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 11px;
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease, transform 80ms ease, opacity 120ms ease;
}

select:hover,
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }

.btn:disabled {
  opacity: 0.4;
  cursor: default;
  transform: none;
}

.btn.primary {
  background: var(--accent);
  border-color: transparent;
  color: #fff;
  font-weight: 560;
}

.btn.primary:hover { filter: brightness(1.07); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--text-soft); }
.btn.ghost:hover { background: var(--surface-2); }
.btn.small { padding: 4px 8px; font-size: 12px; }

.btn.icon {
  width: 34px;
  padding: 7px 0;
  text-align: center;
  line-height: 1;
  font-size: 15px;
}

.segmented {
  display: inline-flex;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 2px;
  gap: 2px;
}

.seg {
  font: inherit;
  font-size: 13px;
  white-space: nowrap;
  border: 0;
  background: transparent;
  color: var(--text-soft);
  padding: 5px 10px;
  border-radius: 6px;
  cursor: pointer;
}

.seg[aria-pressed='true'] {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm);
  font-weight: 560;
}

.menu { position: relative; }

/* Fixed, not absolute: the top bar scrolls horizontally, and a scroll
   container would clip this dropdown to its own height. Placed by JS. */
.menu-list {
  position: fixed;
  min-width: 190px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow-md);
  padding: 5px;
  display: flex;
  flex-direction: column;
  z-index: 30;
}

.menu-list button {
  font: inherit;
  font-size: 13px;
  text-align: left;
  background: transparent;
  border: 0;
  color: var(--text);
  padding: 8px 10px;
  border-radius: 7px;
  cursor: pointer;
}

.menu-list[hidden] { display: none; }
.menu-list button:hover { background: var(--accent-soft); }

.file-state { min-width: 0; }

.file-name {
  font-size: 12.5px;
  color: var(--text-soft);
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-name.is-dirty::after {
  content: ' •';
  color: var(--accent);
  font-weight: 700;
}

.file-name.is-file { color: var(--text); }

/* Dropping a file anywhere on the canvas opens it. */
.canvas-wrap.is-drop-zone::after {
  content: 'Drop to open this map';
  position: absolute;
  inset: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px dashed var(--accent);
  border-radius: 14px;
  background: color-mix(in srgb, var(--accent) 8%, transparent);
  color: var(--accent);
  font-size: 15px;
  font-weight: 560;
  pointer-events: none;
  z-index: 12;
}

/* ------------------------------------------------------------- workspace */
.workspace {
  display: flex;
  height: calc(100% - var(--topbar-h));
}

.sidebar {
  width: 320px;
  flex: 0 0 320px;
  border-right: 1px solid var(--border);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  padding: 16px;
  gap: 10px;
  overflow: auto;
}

.sidebar[hidden] { display: none; }

.sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sidebar h2 {
  margin: 0;
  font-size: 14px;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--text-soft);
}

.hint {
  margin: 0;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--text-soft);
}

#outline {
  flex: 1;
  min-height: 240px;
  resize: none;
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  font-size: 13px;
  line-height: 1.65;
  tab-size: 2;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
}

#outline:focus-visible,
select:focus-visible,
.btn:focus-visible,
.seg:focus-visible,
.tool:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.sidebar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-status {
  font-size: 12px;
  color: var(--text-soft);
}

.shortcuts summary {
  font-size: 12.5px;
  color: var(--text-soft);
  cursor: pointer;
  padding: 4px 0;
}

.shortcuts dl {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 12px;
  margin: 6px 0 0;
  font-size: 12.5px;
}

.shortcuts dt { color: var(--text); font-weight: 560; }
.shortcuts dd { margin: 0; color: var(--text-soft); }

/* ---------------------------------------------------------------- canvas */
.canvas-wrap {
  position: relative;
  flex: 1;
  overflow: hidden;
  background: var(--canvas-bg);
}

#canvas {
  width: 100%;
  height: 100%;
  display: block;
  cursor: grab;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none; /* no iOS magnifier/callout on a long press */
}

#canvas.is-panning { cursor: grabbing; }
#canvas.is-pan-ready { cursor: grab; }
#canvas.is-pan-ready .node { cursor: grab; }
#canvas:focus { outline: none; }

/* ----------------------------------------------------------------- nodes */
.node {
  cursor: pointer;
  transition: transform 280ms cubic-bezier(0.22, 0.61, 0.36, 1), opacity 180ms ease;
}

.node.is-entering { opacity: 0; }
.node.is-dragging { opacity: 0.5; transition: none; }

/* Invisible until you interact with it: this is the hover and hit area. */
.node-hit {
  fill: transparent;
  stroke: none;
  transition: fill 120ms ease;
}

.node:hover .node-hit { fill: var(--node-hover); }

.node.is-selected .node-hit {
  fill: var(--accent-soft);
  stroke: var(--accent);
  stroke-width: 1.5;
}

.node.is-drop-target .node-hit {
  fill: var(--accent-soft);
  stroke: var(--accent);
  stroke-width: 2;
  stroke-dasharray: 5 4;
}

/* Only the root is a card. */
.node-card {
  fill: var(--root-bg);
  stroke: none;
  filter: drop-shadow(0 2px 5px rgba(24, 28, 48, 0.12)) drop-shadow(0 8px 20px rgba(24, 28, 48, 0.08));
}

[data-theme='dark'] .node-card { filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.5)); }

.node-highlight { pointer-events: none; }

.node-text {
  fill: var(--text);
  font-family: var(--font);
  pointer-events: none;
  letter-spacing: -0.005em;
}

/* The add-a-node handles: shown while a node is selected or being typed in,
   which is exactly when you want to branch off it. */
.node-handle {
  opacity: 0;
  pointer-events: none;
  cursor: pointer;
  transition: opacity 140ms ease;
}

.node.is-selected .node-handle,
.node.is-editing .node-handle,
.node:hover .node-handle {
  opacity: 1;
  pointer-events: auto;
}

.node-handle-hit { fill: transparent; }

.node-handle-dot {
  fill: var(--handle-color, var(--accent));
  stroke: var(--canvas-bg);
  stroke-width: 2;
  transition: r 120ms ease;
}

.node-handle:hover .node-handle-dot { r: 6.5; }

/* Talk mode locks the map, so there is nothing to branch off. */
.is-talk-mode .node-handle { display: none; }

.node-badge { cursor: pointer; }

.node-badge-circle {
  fill: var(--canvas-bg);
  stroke: var(--badge-color, var(--border-strong));
  stroke-width: 1.5;
  opacity: 0;
  transition: opacity 140ms ease;
}

.node-badge-text {
  fill: var(--text-soft);
  font-size: 10.5px;
  font-weight: 600;
  text-anchor: middle;
  font-family: var(--font);
  opacity: 0;
  pointer-events: none;
  transition: opacity 140ms ease;
}

.node:hover .node-badge-circle,
.node:hover .node-badge-text,
.node.is-selected .node-badge-circle,
.node.is-selected .node-badge-text,
.node.is-collapsed .node-badge-circle,
.node.is-collapsed .node-badge-text { opacity: 1; }

.node.is-collapsed .node-badge-text { fill: var(--badge-color); }
.node.is-editing .node-text,
.node.is-editing .node-highlight { opacity: 0; }

/* ----------------------------------------------------------------- edges */
.edge {
  fill: none;
  stroke-linecap: round;
  transition: d 280ms cubic-bezier(0.22, 0.61, 0.36, 1);
}

.edge-hit {
  stroke: transparent;
  stroke-width: 16;
  fill: none;
  cursor: text;
}

.edge-group:hover .edge { stroke-width: 3; }
.edge-group.is-labelling .edge { stroke-dasharray: 5 4; }

.edge-label { cursor: text; }

.edge-label-bg {
  fill: var(--canvas-bg);
  stroke: none;
}

.edge-label-text {
  fill: var(--text-soft);
  font-family: var(--font);
  font-size: 12px;
  font-weight: 500;
  text-anchor: middle;
  pointer-events: none;
}

.edge-label:hover .edge-label-text { fill: var(--text); }
.edge-label.is-editing .edge-label-text,
.edge-label.is-editing .edge-label-bg { opacity: 0; }

.drop-line {
  stroke: var(--accent);
  stroke-width: 2.5;
  stroke-linecap: round;
}

.drop-line-cap { fill: var(--accent); }

.drop-indicator {
  fill: none;
  stroke: var(--accent);
  stroke-width: 2;
  stroke-dasharray: 6 5;
  opacity: 0.9;
}

/* -------------------------------------------------------- floating chrome */
.inline-editor {
  position: absolute;
  z-index: 8;
  margin: 0;
  border: 2px solid var(--accent);
  background: var(--surface);
  color: var(--text);
  resize: none;
  overflow: hidden;
  box-shadow: var(--shadow-md);
  outline: none;
}

.node-toolbar {
  position: absolute;
  z-index: 9;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow-md);
  transform: translate(-50%, -100%);
}

.node-toolbar[hidden] { display: none; }

/* Faded out and click-through while the pointer is elsewhere on the map. */
.node-toolbar.is-away {
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease;
}

.swatches { display: flex; gap: 4px; }

.swatch {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  padding: 0;
  transition: transform 100ms ease;
}

.swatch:hover { transform: scale(1.18); }
.swatch[aria-pressed='true'] { border-color: var(--text); }

.divider {
  width: 1px;
  height: 18px;
  background: var(--border);
}

.tool {
  font: inherit;
  font-size: 12.5px;
  border: 0;
  background: transparent;
  color: var(--text);
  padding: 4px 8px;
  border-radius: 6px;
  cursor: pointer;
}

.tool:hover { background: var(--surface-2); }
.node-toolbar .tool { white-space: nowrap; }
.tool.emoji-toggle { font-size: 15px; line-height: 1; padding: 4px 6px; }
.tool.emoji-toggle[aria-expanded='true'] { background: var(--surface-2); }

/* Opens below the toolbar, over the card, or above it near the map's foot. */
.emoji-picker {
  --emoji-cell: 32px;
  position: absolute;
  top: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 2px;
  width: max-content;
  max-width: calc(100vw - 24px);
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow-md);
}

.emoji-picker[hidden] { display: none; }
.emoji-picker.is-above { top: auto; bottom: calc(100% + 6px); }
.emoji-row,
.emoji-results {
  display: grid;
  grid-template-columns: repeat(10, var(--emoji-cell));
  gap: 2px;
}

.emoji-row[hidden],
.emoji-results[hidden] { display: none; }
.emoji-results { max-height: calc(var(--emoji-cell) * 5 + 8px); overflow-y: auto; }
.emoji-none { grid-column: 1 / -1; margin: 6px 4px; color: var(--text-soft); font-size: 12.5px; }

.emoji-search {
  font: inherit;
  font-size: 13px;
  margin-bottom: 4px;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--text);
}

.emoji-search:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

.emoji-choice {
  width: var(--emoji-cell);
  height: var(--emoji-cell);
  font-size: 18px;
  line-height: 1;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  cursor: pointer;
}

.emoji-choice:hover { background: var(--surface-2); }
.emoji-choice[aria-pressed='true'] { box-shadow: inset 0 0 0 2px var(--text); }
.emoji-choice:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
@media (max-width: 480px) { .emoji-picker { --emoji-cell: 30px; } }

.emoji-remove { align-self: flex-end; margin-top: 4px; color: var(--text-soft); }

.tool.danger:hover { background: color-mix(in srgb, var(--danger) 14%, transparent); color: var(--danger); }

.zoom-controls {
  position: absolute;
  right: calc(16px + env(safe-area-inset-right, 0px));
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  display: flex;
  gap: 6px;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-md);
}

.zoom-level { min-width: 56px; text-align: center; font-variant-numeric: tabular-nums; }

.sidebar-reveal {
  position: absolute;
  left: calc(16px + env(safe-area-inset-left, 0px));
  top: 16px;
  font: inherit;
  font-size: 13px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 11px;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  color: var(--text);
}

.sidebar-reveal[hidden] { display: none; }

.toast {
  position: absolute;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  background: var(--root-bg);
  color: var(--root-text);
  font-size: 13px;
  padding: 9px 16px;
  border-radius: 999px;
  box-shadow: var(--shadow-lg);
  animation: toast-in 180ms ease;
}

[data-theme='dark'] .toast { background: var(--surface); color: var(--text); border: 1px solid var(--border); }
.toast[hidden] { display: none; }

.toast-link {
  color: inherit;
  font-weight: 650;
  text-decoration: underline;
  text-underline-offset: 2px;
}

@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, 8px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

/* ---------------------------------------------------------------- dialog */
dialog {
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  color: var(--text);
  max-width: 520px;
  padding: 24px;
  box-shadow: var(--shadow-lg);
}

dialog::backdrop { background: rgba(16, 18, 30, 0.45); }
dialog h2 { margin: 0 0 8px; font-size: 19px; }
dialog h3 { margin: 18px 0 6px; font-size: 13px; text-transform: uppercase; letter-spacing: 0.03em; color: var(--text-soft); }
dialog p, dialog li { font-size: 13.5px; line-height: 1.6; color: var(--text); }
dialog ul { margin: 0; padding-left: 18px; }
dialog menu { display: flex; justify-content: flex-end; margin: 20px 0 0; padding: 0; }

kbd {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 5px;
  padding: 1px 5px;
}

/* --------------------------------------------------------------- responsive */
@media (max-width: 1100px) {
  .topbar { gap: 10px; }
  .sidebar {
    position: absolute;
    z-index: 15;
    width: min(340px, 88vw);
    flex-basis: auto;
    height: calc(100% - var(--topbar-h));
    box-shadow: var(--shadow-lg);
  }
  .brand span { display: none; } /* the mark alone carries it on a narrow bar */
}

@media (prefers-reduced-motion: reduce) {
  .node, .edge, .toast { transition: none; animation: none; }
}

/* ------------------------------------------------- formatting + history UI */
.tool.fmt {
  width: 28px;
  padding: 4px 0;
  text-align: center;
  font-size: 13px;
}

.tool.fmt[aria-pressed='true'] {
  background: var(--accent-soft);
  color: var(--accent);
}

.tool:disabled { opacity: 0.35; cursor: default; }

.swatches.highlights .swatch {
  border-radius: 4px;
  border: 1px solid var(--border-strong);
}

.swatch.is-none {
  background: var(--surface);
  position: relative;
  overflow: hidden;
}

.swatch.is-none::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom right, transparent 45%, var(--danger) 45%, var(--danger) 55%, transparent 55%);
}

dialog.wide { max-width: 560px; width: calc(100vw - 48px); }

.dialog-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.dialog-sub {
  margin: 4px 0 0;
  font-size: 12.5px;
  color: var(--text-soft);
}

.version-list {
  list-style: none;
  margin: 16px 0 0;
  padding: 0;
  max-height: min(52vh, 420px);
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
}

.version-list:empty::after {
  content: 'No versions saved yet — they appear here as you edit.';
  display: block;
  padding: 24px 16px;
  text-align: center;
  font-size: 13px;
  color: var(--text-soft);
}

.version-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}

.version-row:last-child { border-bottom: 0; }
.version-row.is-current { background: var(--accent-soft); }

.version-main { flex: 1; min-width: 0; }

.version-title {
  font-size: 13.5px;
  font-weight: 560;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.version-meta {
  font-size: 12px;
  color: var(--text-soft);
  margin-top: 2px;
}

.btn.ghost.danger { color: var(--danger); }
.btn.ghost.danger:hover { background: color-mix(in srgb, var(--danger) 12%, transparent); }

dialog menu { gap: 8px; align-items: center; justify-content: space-between; }
.confirm-actions { display: flex; gap: 8px; margin-left: auto; }
#confirm-dialog { max-width: 420px; }
#confirm-dialog p { color: var(--text-soft); }

@media (max-width: 1100px) {
  .node-toolbar { max-width: calc(100vw - 24px); flex-wrap: wrap; justify-content: center; }
}


/* --------------------------------------------------------- touch devices */
@media (pointer: coarse) {
  /* Comfortable finger targets without changing how anything reads. */
  .btn,
  .seg,
  select { padding-top: 10px; padding-bottom: 10px; }

  .btn.icon { width: 42px; }

  /* The toolbar floats above the selected card, which on a map means over a
     neighbouring one. A mouse makes it fade as the pointer moves away; a
     finger gives no such warning, so at least its padding and the gaps
     between its buttons let a tap through to the card underneath. */
  .node-toolbar { pointer-events: none; }
  .node-toolbar > * { pointer-events: auto; }

  .tool {
    padding: 9px 11px;
    font-size: 13.5px;
  }

  .tool.fmt { width: 36px; }
  .emoji-picker { --emoji-cell: 38px; }
  .emoji-choice { font-size: 22px; }
  .emoji-search { font-size: 16px; padding: 9px 10px; } /* 16px keeps iOS from zooming in */

  .swatch {
    width: 22px;
    height: 22px;
  }

  .node-toolbar { gap: 8px; padding: 8px; }

  .version-row { padding: 14px 12px; }
}

/* ------------------------------------------------------------- talk mode */
.scripture {
  fill: var(--scripture);
  font-weight: 600;
  cursor: pointer;
  /* The node's text is pointer-transparent so the box behind it takes drags;
     a reference opts back in so it can be tapped. Dragging still works: the
     event bubbles up to the node either way. */
  pointer-events: all;
}

.scripture:hover { text-decoration: underline; }

.node-meta {
  fill: var(--text-faint);
  font-size: 0.82em;
  font-weight: 500;
}

.node.is-root .node-meta { fill: var(--text-soft); }

.tabs {
  display: inline-flex;
  gap: 2px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 2px;
}

.tab {
  font: inherit;
  font-size: 12.5px;
  border: 0;
  background: transparent;
  color: var(--text-soft);
  padding: 5px 12px;
  border-radius: 6px;
  cursor: pointer;
}

.tab[aria-selected='true'] {
  background: var(--surface);
  color: var(--text);
  font-weight: 560;
  box-shadow: var(--shadow-sm);
}

.panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1;
  min-height: 0;
}

.panel[hidden] { display: none; }

#panel-talk { overflow-y: auto; gap: 18px; }

.talk-block {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.talk-heading {
  margin: 0;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-soft);
}

.talk-count { color: var(--text-faint); font-weight: 500; }

/* The scripture list folds away like the shortcuts do, closed to begin with,
   and the speaker notes take the room it leaves. */
/* Laid out as a plain block: older Safari will not make a <details> a flex
   box, so the spacing is margins rather than the gap the other blocks use. */
.talk-refs { display: block; }
.talk-refs > :not(summary) { display: block; width: 100%; margin-top: 8px; }
.talk-refs > .ref-list { display: flex; }
.talk-refs > [hidden] { display: none; }
.talk-refs > summary {
  cursor: pointer;
  padding: 4px 0;
}
.talk-refs > summary::marker { color: var(--text-faint); }

.talk-part {
  flex: 1 0 auto;
  min-height: 0;
}

#talk-note {
  flex: 1 0 auto;
  min-height: 180px;
}

.talk-field {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-soft);
}

.talk-field input {
  font: inherit;
  font-size: 14px;
  width: 74px;
  padding: 6px 8px;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 7px;
}

.talk-field input:disabled { opacity: 0.5; }

.talk-total {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}

.talk-total.is-over { color: var(--danger); }
.talk-total.is-short { color: var(--warning); }
.talk-total.is-ok { color: var(--success); }

.talk-bar {
  height: 6px;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
}

.talk-bar-fill {
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: var(--success);
  transition: width 220ms ease, background 220ms ease;
}

.talk-bar-fill.is-over { background: var(--danger); }
.talk-bar-fill.is-short { background: var(--warning); }

.talk-selection {
  font-size: 13.5px;
  font-weight: 560;
  color: var(--text);
  padding: 8px 10px;
  background: var(--surface-2);
  border-radius: 8px;
  word-break: break-word;
}

.talk-selection.is-empty { color: var(--text-soft); font-weight: 400; }

.talk-sub { margin: 0; font-size: 12px; color: var(--text-soft); }

.talk-label {
  font-size: 12px;
  color: var(--text-soft);
}

#talk-note,
#talk-link,
#talk-link-custom {
  font: inherit;
  font-size: 13px;
  width: 100%;
  padding: 8px 10px;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  resize: vertical;
}

#talk-note:disabled { opacity: 0.5; }

.ref-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 210px;
  overflow-y: auto;
}

.ref-list:empty::after {
  content: 'No scripture references found yet.';
  font-size: 12.5px;
  color: var(--text-soft);
}

.ref-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 7px;
  cursor: pointer;
  font-size: 13px;
}

.ref-row:hover { background: var(--accent-soft); }

.ref-cite {
  font-weight: 600;
  color: var(--scripture);
  white-space: nowrap;
}

.ref-where {
  color: var(--text-soft);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.btn.block { width: 100%; justify-content: center; }

/* ------------------------------------------------------------------ print */
.print-view { display: none; }

@media print {
  .topbar,
  .workspace,
  .node-toolbar,
  .zoom-controls,
  .toast,
  dialog { display: none !important; }

  body { overflow: visible; background: #fff; }

  .print-view {
    display: block;
    padding: 0;
    color: #000;
    font-size: 11.5pt;
    line-height: 1.5;
  }

  .print-title { font-size: 20pt; margin: 0 0 2pt; }
  .print-meta { font-size: 10pt; color: #555; margin: 0 0 18pt; }

  .print-item { break-inside: avoid; margin: 0 0 3pt; }
  .print-item .print-row { display: flex; gap: 10pt; align-items: baseline; }
  .print-text { flex: 1; }
  .print-time { font-variant-numeric: tabular-nums; color: #444; white-space: nowrap; }
  /* Only section headings and scripture are bold: indentation carries the
     rest of the structure, so bold keeps meaning something. */
  .print-depth-1 { font-weight: 700; font-size: 13pt; margin-top: 12pt; }
  .print-note {
    font-size: 10pt;
    color: #444;
    border-left: 2pt solid #bbb;
    padding-left: 8pt;
    margin: 2pt 0 4pt;
    white-space: pre-wrap;
  }
  .print-scripture { font-weight: 700; }
}

/* ------------------------------------------------- rehearsal timer + verse */
.timer-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.timer-clock {
  font-size: 26px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  color: var(--text);
}

.timer-clock.is-over { color: var(--danger); }
.timer-clock.is-close { color: var(--warning); }

.timer-buttons { display: flex; gap: 6px; }

.canvas-timer {
  position: absolute;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 11;
  padding: 7px 16px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
  font-size: 15px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  pointer-events: none;
}

.canvas-timer[hidden] { display: none; }
.canvas-timer.is-over { color: var(--danger); border-color: var(--danger); }
.canvas-timer.is-close { color: var(--warning); }
