  :root {
    --bg-deep: #0a0e14;
    --bg-mid: #0f141c;
    --bg-panel: #131923;
    --bg-elevated: #1a212d;
    --line-dormant: #2a313e;
    --line-explored: #5a4a2a;
    --line-active: #d4a445;
    --line-current: #f4c668;
    --text-primary: #ece8dc;
    --text-secondary: #9a958a;
    --text-muted: #6a665e;
    --accent-objection: #c66a5e;
    --accent-response: #7ba282;
    --accent-gold: #e8b04c;
    --glow-gold: rgba(244, 198, 100, 0.4);
    --border-subtle: rgba(232, 228, 220, 0.08);
    --border-soft: rgba(232, 228, 220, 0.12);
    --display: 'EB Garamond', Georgia, serif;
    --ui: 'Manrope', system-ui, sans-serif;

    --sidebar-w: 280px;
    --detail-w: 420px;
    --splitter-w: 5px;
    --header-h: 64px;
  }

  * { box-sizing: border-box; margin: 0; padding: 0; }

  html, body {
    height: 100%; overflow: hidden;
    background: var(--bg-deep);
    color: var(--text-primary);
    font-family: var(--ui);
    font-size: 15px; line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    overscroll-behavior: none;
    -webkit-tap-highlight-color: transparent;
  }

  body::before {
    content: ''; position: fixed; inset: 0;
    background:
      radial-gradient(ellipse at 20% 100%, rgba(212, 164, 69, 0.08) 0%, transparent 50%),
      radial-gradient(ellipse at 80% 0%, rgba(123, 162, 130, 0.04) 0%, transparent 50%);
    pointer-events: none; z-index: 0;
  }

  body::after {
    content: ''; position: fixed; inset: 0;
    background-image:
      radial-gradient(circle at 17% 23%, rgba(255, 240, 210, 0.4) 0.5px, transparent 1px),
      radial-gradient(circle at 73% 41%, rgba(255, 240, 210, 0.3) 0.5px, transparent 1px),
      radial-gradient(circle at 41% 67%, rgba(255, 240, 210, 0.4) 0.4px, transparent 1px),
      radial-gradient(circle at 88% 87%, rgba(255, 240, 210, 0.25) 0.6px, transparent 1px),
      radial-gradient(circle at 12% 91%, rgba(255, 240, 210, 0.3) 0.4px, transparent 1px),
      radial-gradient(circle at 56% 12%, rgba(255, 240, 210, 0.35) 0.5px, transparent 1px),
      radial-gradient(circle at 31% 44%, rgba(255, 240, 210, 0.2) 0.4px, transparent 1px);
    pointer-events: none; opacity: 0.6; z-index: 0;
  }

  /* Phone-only drag handle — hidden everywhere except mobile explorer view */
  .mobile-splitter { display: none; }

  .app {
    position: relative; z-index: 1;
    display: grid;
    /* New layout (v20): sidebar | detail (text) | canvas (map). The map
       sits to the right of the in-depth text so reading flows left→right
       and the spatial structure follows on the right. */
    grid-template-columns: var(--sidebar-w) var(--splitter-w) var(--detail-w) var(--splitter-w) 1fr;
    grid-template-rows: var(--header-h) 1fr;
    height: 100vh; width: 100vw;
    height: 100dvh; /* dynamic viewport for mobile */
  }

  header {
    grid-column: 1 / -1;
    display: flex; align-items: center; padding: 0 16px 0 20px;
    border-bottom: 1px solid var(--border-subtle);
    background: rgba(10, 14, 20, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    z-index: 40;
    gap: 12px;
  }

  .icon-btn {
    background: transparent;
    border: 1px solid var(--border-subtle);
    color: var(--text-secondary);
    width: 36px; height: 36px;
    border-radius: 8px;
    cursor: pointer;
    display: none;
    align-items: center; justify-content: center;
    font-size: 16px;
    transition: all 0.2s ease;
    flex-shrink: 0;
  }
  .icon-btn:hover, .icon-btn:active { border-color: var(--accent-gold); color: var(--accent-gold); }

  .brand {
    display: flex; align-items: center; gap: 10px;
    font-family: var(--display);
    font-size: 22px; font-weight: 500; letter-spacing: 0.02em;
    color: var(--text-primary);
    cursor: pointer;
    flex-shrink: 0;
  }
  .brand .seed { width: 22px; height: 22px; }
  .brand .seed svg { width: 100%; height: 100%; filter: drop-shadow(0 0 6px var(--glow-gold)); }
  .brand em { color: var(--accent-gold); font-style: italic; font-weight: 600; }

  .breadcrumb {
    margin-left: auto;
    display: flex; align-items: center; gap: 10px;
    font-size: 12px; color: var(--text-secondary);
    text-transform: uppercase; letter-spacing: 0.12em;
    overflow: hidden; max-width: 50%;
    min-width: 0;
  }
  .breadcrumb span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .breadcrumb .sep { color: var(--text-muted); font-size: 10px; flex-shrink: 0; }
  .breadcrumb .current { color: var(--accent-gold); }
  .breadcrumb .link { cursor: pointer; transition: color 0.2s ease; }
  .breadcrumb .link:hover { color: var(--text-primary); }

  /* ============ SIDEBAR ============ */
  .sidebar {
    border-right: 1px solid var(--border-subtle);
    background: rgba(15, 20, 28, 0.95);
    overflow: hidden;
    min-width: 240px;
    display: flex; flex-direction: column;
  }

  .sidebar-nav {
    padding: 20px 20px 12px;
    border-bottom: 1px solid var(--border-subtle);
    display: flex; align-items: center; gap: 8px;
    flex-shrink: 0;
  }

  .nav-back {
    background: transparent;
    border: 1px solid var(--border-subtle);
    color: var(--text-secondary);
    width: 32px; height: 32px;
    border-radius: 6px;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    font-size: 14px;
    transition: all 0.2s ease;
    flex-shrink: 0;
  }
  .nav-back:hover, .nav-back:active { border-color: var(--accent-gold); color: var(--accent-gold); }

  .nav-title {
    font-family: var(--display);
    font-size: 18px;
    color: var(--text-primary);
    font-weight: 500;
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .nav-title .sub {
    display: block;
    font-family: var(--ui);
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    color: var(--text-muted);
    font-weight: 500;
    margin-bottom: 2px;
  }

  .sidebar-body {
    flex: 1;
    min-height: 0;
    padding: 16px 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .sidebar-body h3 {
    font-family: var(--ui);
    font-size: 11px; font-weight: 600;
    letter-spacing: 0.16em; text-transform: uppercase;
    color: var(--text-muted);
    padding: 8px 24px;
    margin-bottom: 8px;
  }

  .category-card {
    display: block;
    margin: 0 16px 12px;
    padding: 18px 20px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.25s ease;
    position: relative;
    overflow: hidden;
  }
  .category-card::before {
    content: '';
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 3px;
    background: var(--accent-gold);
    opacity: 0;
    transition: opacity 0.25s ease;
  }
  .category-card:hover, .category-card:active {
    border-color: var(--accent-gold);
    background: rgba(232, 176, 76, 0.04);
    transform: translateX(2px);
  }
  .category-card:hover::before, .category-card:active::before { opacity: 1; }

  .category-card .cat-icon {
    width: 32px; height: 32px;
    border-radius: 8px;
    background: rgba(232, 176, 76, 0.1);
    display: flex; align-items: center; justify-content: center;
    font-size: 16px;
    margin-bottom: 10px;
    color: var(--accent-gold);
  }
  .category-card .cat-name {
    font-family: var(--display);
    font-size: 20px;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 4px;
  }
  .category-card .cat-desc {
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.5;
    margin-bottom: 10px;
  }
  .category-card .cat-meta {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.12em;
    display: flex; align-items: center; gap: 6px;
  }
  .category-card .cat-meta .dot {
    width: 3px; height: 3px; border-radius: 50%;
    background: var(--text-muted);
  }

  .tree-list { list-style: none; }
  .tree-list li {
    padding: 14px 24px;
    border-left: 2px solid transparent;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: var(--display);
    font-size: 17px;
    color: var(--text-secondary);
    display: flex; align-items: center; justify-content: space-between; gap: 8px;
  }
  .tree-list li:hover:not(.disabled), .tree-list li:active:not(.disabled) {
    background: rgba(232, 176, 76, 0.04);
    color: var(--text-primary);
    border-left-color: var(--line-explored);
  }
  .tree-list li.active {
    background: rgba(232, 176, 76, 0.08);
    color: var(--accent-gold);
    border-left-color: var(--accent-gold);
  }
  .tree-list li.disabled { opacity: 0.4; cursor: not-allowed; font-style: italic; }
  .tree-list .badge {
    font-family: var(--ui); font-size: 10px;
    color: var(--text-muted);
    text-transform: uppercase; letter-spacing: 0.1em;
    background: rgba(232, 228, 220, 0.05);
    padding: 2px 8px; border-radius: 10px;
    flex-shrink: 0;
  }

  .tree-indicator {
    font-family: var(--ui);
    font-size: 10px; font-weight: 600;
    letter-spacing: 0.08em;
    padding: 3px 9px;
    border-radius: 10px;
    flex-shrink: 0;
    transition: all 0.2s ease;
  }
  .tree-indicator.grown {
    background: rgba(232, 176, 76, 0.12);
    color: var(--accent-gold);
    border: 1px solid rgba(232, 176, 76, 0.35);
    font-variant-numeric: tabular-nums;
    box-shadow: 0 0 8px rgba(232, 176, 76, 0.15);
  }
  .tree-indicator.empty {
    background: transparent;
    color: var(--text-muted);
    border: 1px dashed var(--line-dormant);
    font-size: 10px;
    letter-spacing: 0.06em;
    font-weight: 500;
  }
  .tree-list li:hover .tree-indicator.empty,
  .tree-list li.active .tree-indicator.empty {
    border-color: var(--line-explored);
    color: var(--text-secondary);
  }
  .tree-list li:hover .tree-indicator.grown,
  .tree-list li.active .tree-indicator.grown {
    background: rgba(232, 176, 76, 0.2);
  }

  .progress-card {
    margin: 16px 20px 20px;
    padding: 16px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
  }
  .progress-card .label {
    font-size: 10px; text-transform: uppercase;
    letter-spacing: 0.14em; color: var(--text-muted); margin-bottom: 8px;
  }
  .progress-card .stats {
    display: flex; align-items: baseline; gap: 6px;
    font-family: var(--display);
  }
  .progress-card .num { font-size: 28px; color: var(--accent-gold); font-weight: 500; }
  .progress-card .total { font-size: 16px; color: var(--text-secondary); }
  .progress-bar {
    margin-top: 10px; height: 3px;
    background: var(--bg-deep); border-radius: 2px; overflow: hidden;
  }
  .progress-bar .fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-gold), var(--line-current));
    transition: width 0.5s ease;
    box-shadow: 0 0 8px var(--glow-gold);
  }

  .legend { padding: 0 24px; margin-bottom: 20px; }
  .legend-item {
    display: flex; align-items: center; gap: 10px;
    font-size: 12px; color: var(--text-secondary);
    margin-bottom: 10px;
  }
  .legend-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
  .dot-objection { background: var(--accent-objection); box-shadow: 0 0 6px rgba(198, 106, 94, 0.5); }
  .dot-response { background: var(--accent-response); box-shadow: 0 0 6px rgba(123, 162, 130, 0.5); }
  .dot-dormant { background: var(--line-dormant); border: 1px solid var(--text-muted); }
  .dot-current { width: 14px; height: 14px; border: 2px solid var(--line-current); background: var(--bg-elevated); outline: 1px dashed var(--line-current); outline-offset: 3px; opacity: 0.85; }

  /* Legend line glyphs — small horizontal bars in each branch colour
     so the user can match what they see in the tree. */
  .legend-line {
    width: 18px;
    height: 3px;
    border-radius: 2px;
    flex-shrink: 0;
    display: inline-block;
  }
  .line-grey  { background: var(--line-dormant); opacity: 0.6; }
  .line-green { background: var(--accent-response); box-shadow: 0 0 4px rgba(123, 162, 130, 0.5); }

  .controls-help {
    padding: 12px 24px;
    font-size: 11px; color: var(--text-muted); line-height: 1.7;
    border-top: 1px solid var(--border-subtle);
  }
  .controls-help kbd {
    background: var(--bg-elevated);
    padding: 1px 6px; border-radius: 3px;
    font-family: var(--ui); color: var(--text-secondary);
    font-size: 10px;
  }

  .splitter {
    background: transparent; cursor: ew-resize;
    position: relative;
    transition: background 0.15s ease;
    user-select: none;
  }
  .splitter::before {
    content: ''; position: absolute;
    left: 50%; top: 0; bottom: 0; width: 1px;
    background: var(--border-subtle);
    transform: translateX(-50%);
  }
  .splitter:hover, .splitter.dragging { background: rgba(232, 176, 76, 0.1); }
  .splitter:hover::before, .splitter.dragging::before { background: var(--accent-gold); }
  body.resizing { cursor: ew-resize; user-select: none; }
  body.resizing * { user-select: none !important; }

  /* ============ CANVAS ============ */
  .canvas {
    position: relative; overflow: hidden;
    background: linear-gradient(180deg, transparent 0%, rgba(212, 164, 69, 0.025) 100%);
    min-width: 200px;
  }
  .tree-svg {
    width: 100%; height: 100%; display: block;
    cursor: grab;
    touch-action: none;
  }
  .tree-svg.panning { cursor: grabbing; }
  .tree-svg.hidden { display: none; }

  .canvas-controls {
    position: absolute; top: 16px; right: 16px;
    display: flex; gap: 6px; z-index: 5;
  }
  .canvas-btn {
    width: 36px; height: 36px;
    background: rgba(26, 33, 45, 0.9);
    border: 1px solid var(--border-subtle);
    color: var(--text-secondary); border-radius: 6px;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    font-size: 14px;
    backdrop-filter: blur(8px);
    transition: all 0.2s ease;
  }
  .canvas-btn:hover, .canvas-btn:active { color: var(--accent-gold); border-color: var(--accent-gold); }

  .canvas-welcome {
    position: absolute; inset: 0;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    padding: 40px 24px;
    text-align: center;
  }
  .canvas-welcome.hidden { display: none; }

  .welcome-seed {
    width: 80px; height: 80px;
    margin-bottom: 24px;
    filter: drop-shadow(0 0 16px var(--glow-gold));
    animation: float 4s ease-in-out infinite;
  }
  @keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
  }

  .canvas-welcome h1 {
    font-family: var(--display);
    font-size: 32px;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 12px;
    letter-spacing: -0.01em;
  }
  .canvas-welcome h1 em { color: var(--accent-gold); font-style: italic; }

  .canvas-welcome .verse {
    font-family: var(--display);
    font-style: italic;
    font-size: 17px;
    color: var(--text-secondary);
    max-width: 520px;
    line-height: 1.5;
    margin-bottom: 8px;
  }

  .canvas-welcome .verse-ref {
    font-family: var(--ui);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.18em;
    color: var(--text-muted);
    margin-bottom: 32px;
  }

  .canvas-welcome .instruction {
    font-size: 13px;
    color: var(--text-muted);
    max-width: 420px;
    line-height: 1.6;
  }
  .canvas-welcome .instruction strong {
    color: var(--accent-gold);
    font-weight: 500;
  }

  .branch {
    fill: none;
    stroke: var(--line-dormant);
    stroke-width: 1.2;
    /* Long, gentle transitions so colour upgrades/downgrades feel like
       organic state changes rather than abrupt jumps. */
    transition: stroke 0.6s ease, stroke-width 0.6s ease, opacity 0.6s ease, filter 0.6s ease;
    opacity: 0.5;
  }
  /* === Learning branch colours ===
     Each branch (parent → child) shows the rating given to the child node:
       no rating or missed → grey (default)
       got_it              → green */
  .branch.rank-green {
    stroke: var(--accent-response);
    stroke-width: 2.2;
    opacity: 0.95;
    filter: drop-shadow(0 0 4px rgba(123, 162, 130, 0.5));
  }

  /* Tutorial branch flash — illustrates the learning concept without
     modifying any actual rating data */
  .tutorial-flash-branches .branch,
  .tutorial-flash-branches .selection-path {
    animation: branch-flash 1.8s ease-in-out infinite;
  }

  @keyframes branch-flash {
    0%, 100% {
      stroke: var(--line-dormant);
      stroke-width: 1.2;
      opacity: 0.5;
    }
    30%, 80% {
      stroke: var(--accent-response);
      stroke-width: 2.2;
      opacity: 0.95;
    }
  }

  .node { cursor: pointer; }
  .node-circle {
    fill: var(--bg-mid);
    stroke: var(--line-dormant);
    stroke-width: 1.5;
    transition: all 0.4s ease;
  }
  .node.selected .node-circle {
    stroke: var(--line-current);
    stroke-width: 2.5;
    fill: var(--bg-elevated);
  }
  .node.objection .node-inner { fill: var(--accent-objection); }
  .node.response .node-inner { fill: var(--accent-response); }

  .node-inner { transition: all 0.4s ease; }

  .node-label {
    fill: var(--text-secondary);
    font-family: var(--ui);
    font-size: 10.5px; font-weight: 500;
    pointer-events: none;
    transition: fill 0.4s ease;
    text-anchor: middle;
    paint-order: stroke fill;
    stroke: var(--bg-deep);
    stroke-width: 3px;
    stroke-linejoin: round;
    stroke-opacity: 0.92;
  }
  .node.selected .node-label { fill: var(--accent-gold); font-weight: 600; }

  .node:hover .node-circle { stroke: var(--accent-gold); }

  .selection-ring {
    fill: none;
    stroke: var(--line-current);
    stroke-width: 1;
    stroke-dasharray: 3 3;
    opacity: 0.6;
  }

  .selection-path {
    fill: none;
    stroke: var(--line-current);
    stroke-width: 2;
    stroke-linecap: round;
    stroke-dasharray: 5 7;
    opacity: 0.9;
    pointer-events: none;
    filter: drop-shadow(0 0 4px var(--glow-gold));
  }
  .selection-path.learned {
    stroke: var(--accent-response);
    filter: drop-shadow(0 0 4px rgba(123, 162, 130, 0.6));
  }

  /* ============ DETAIL ============ */
  .detail {
    border-right: 1px solid var(--border-subtle);
    background: var(--bg-panel);
    overflow: hidden;
    display: flex; flex-direction: column;
    min-width: 300px;
    position: relative;
  }
  .detail-body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  .detail-inner {
    padding: 32px 32px 40px;
    display: flex; flex-direction: column;
  }

  .detail-empty {
    padding: 40px 32px;
    text-align: center;
    color: var(--text-muted);
    font-family: var(--display);
    font-style: italic;
    font-size: 15px;
    line-height: 1.6;
  }

  .detail-mobile-handle {
    display: none;
    padding: 12px 0 10px;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
  }
  .detail-mobile-handle .handle-bar {
    width: 52px; height: 5px;
    border-radius: 3px;
    background: var(--text-muted);
    opacity: 0.55;
    transition: opacity 0.2s ease, background 0.2s ease;
  }
  .detail-mobile-handle:active .handle-bar {
    opacity: 1;
    background: var(--accent-gold);
  }

  /* "Tree map" pill — visible only on phone, sits at top of the sheet
     so the user can dismiss it back to the spatial map. */
  .detail-mapbtn {
    display: none;
    align-items: center;
    gap: 6px;
    margin: 0 18px 12px;
    padding: 8px 14px;
    background: rgba(232, 176, 76, 0.08);
    border: 1px solid rgba(232, 176, 76, 0.3);
    color: var(--accent-gold);
    border-radius: 18px;
    font-family: var(--ui);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    cursor: pointer;
    align-self: flex-start;
    transition: all 0.2s ease;
    -webkit-tap-highlight-color: transparent;
  }
  .detail-mapbtn:active {
    background: rgba(232, 176, 76, 0.18);
    transform: scale(0.97);
  }
  .detail-mapbtn .pin {
    font-size: 13px;
    line-height: 1;
  }

  /* Lineage trail — tappable chips showing the path from root to current.
     Now shown on BOTH desktop and mobile in the detail panel — answers
     "where am I in the tree?" right next to the content. */
  .detail-lineage {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
    margin-bottom: 14px;
    padding: 10px 12px;
    background: var(--bg-deep);
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
  }
  .lineage-chip {
    font-family: var(--ui);
    font-size: 11px;
    color: var(--text-secondary);
    padding: 4px 10px;
    border-radius: 12px;
    background: transparent;
    border: 1px solid transparent;
    cursor: pointer;
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    transition: all 0.15s ease;
    -webkit-tap-highlight-color: transparent;
  }
  .lineage-chip:active { background: var(--bg-elevated); border-color: var(--border-soft); }
  .lineage-chip.current {
    color: var(--accent-gold);
    background: rgba(232, 176, 76, 0.08);
    border-color: rgba(232, 176, 76, 0.3);
    font-weight: 600;
    cursor: default;
  }
  .lineage-sep {
    color: var(--text-muted);
    font-size: 10px;
    flex-shrink: 0;
  }

  /* Sibling pager — flick between siblings of the same parent.
     Useful on both desktop (in the detail panel) and mobile (in the
     bottom split). */
  .sibling-nav {
    display: flex;
    align-items: center;
    gap: 0;
    margin-bottom: 16px;
    padding: 6px;
    background: var(--bg-deep);
    border: 1px solid var(--border-subtle);
    border-radius: 10px;
    overflow: hidden;
  }
  .sib-btn {
    flex: 0 0 auto;
    width: 44px; height: 38px;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 18px;
    cursor: pointer;
    border-radius: 6px;
    display: flex; align-items: center; justify-content: center;
    transition: all 0.15s ease;
    -webkit-tap-highlight-color: transparent;
  }
  .sib-btn:active:not(:disabled) {
    background: rgba(232, 176, 76, 0.1);
    color: var(--accent-gold);
  }
  .sib-btn:disabled { opacity: 0.25; cursor: not-allowed; }
  .sib-label {
    flex: 1;
    text-align: center;
    font-family: var(--ui);
    font-size: 11px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.12em;
    line-height: 1.3;
    padding: 0 6px;
    overflow: hidden;
  }
  .sib-label .pos {
    color: var(--accent-gold);
    font-weight: 600;
    font-variant-numeric: tabular-nums;
  }
  .sib-label .of { color: var(--text-muted); }


  .detail-close-btn {
    display: none;
    position: absolute;
    top: 10px; right: 12px;
    width: 40px; height: 40px;
    border-radius: 50%;
    border: 1px solid var(--border-soft);
    background: var(--bg-elevated);
    color: var(--text-secondary);
    align-items: center; justify-content: center;
    cursor: pointer;
    font-size: 16px; font-weight: 500;
    z-index: 10;
    appearance: none;
    -webkit-appearance: none;
    transition: all 0.15s ease;
  }
  .detail-close-btn:active {
    background: var(--accent-gold);
    color: var(--bg-deep);
    border-color: var(--accent-gold);
    transform: scale(0.92);
  }

  .type-badge {
    display: inline-flex; align-items: center; gap: 8px;
    font-family: var(--ui);
    font-size: 10px; text-transform: uppercase; letter-spacing: 0.18em;
    color: var(--text-secondary);
    margin-bottom: 18px; align-self: flex-start;
  }
  .type-badge .marker { width: 8px; height: 8px; border-radius: 50%; }
  .type-badge.objection .marker { background: var(--accent-objection); box-shadow: 0 0 6px rgba(198, 106, 94, 0.6); }
  .type-badge.response .marker { background: var(--accent-response); box-shadow: 0 0 6px rgba(123, 162, 130, 0.6); }
  .type-badge.objection { color: var(--accent-objection); }
  .type-badge.response { color: var(--accent-response); }

  .detail h2 {
    font-family: var(--display);
    font-size: 28px; font-weight: 500;
    line-height: 1.2;
    margin-bottom: 14px;
    color: var(--text-primary);
    letter-spacing: -0.01em;
  }

  .detail-content {
    font-family: var(--display);
    font-size: 17px; line-height: 1.65;
    color: var(--text-primary);
    margin-bottom: 24px;
  }

  .detail-context {
    font-family: var(--ui);
    font-size: 13px; line-height: 1.65;
    color: var(--text-secondary);
    padding: 14px 16px;
    background: var(--bg-deep);
    border-left: 2px solid var(--line-explored);
    margin-bottom: 24px;
    border-radius: 0 4px 4px 0;
  }

  .detail-source {
    font-family: var(--display);
    font-style: italic; font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 28px;
    padding-top: 16px;
    border-top: 1px solid var(--border-subtle);
  }
  .detail-source::before { content: '— '; }

  .actions { display: flex; gap: 8px; margin-bottom: 28px; flex-wrap: wrap; }

  .action-btn {
    font-family: var(--ui);
    font-size: 11px; text-transform: uppercase; letter-spacing: 0.12em;
    padding: 10px 14px;
    background: transparent;
    border: 1px solid var(--border-soft);
    color: var(--text-secondary);
    border-radius: 4px; cursor: pointer;
    transition: all 0.2s ease;
  }
  .action-btn:hover, .action-btn:active { border-color: var(--accent-gold); color: var(--accent-gold); }
  .action-btn.primary {
    border-color: var(--accent-gold); color: var(--accent-gold);
    background: rgba(232, 176, 76, 0.06);
  }
  .action-btn.branch-cta {
    border-color: var(--accent-response);
    color: var(--accent-response);
    background: rgba(123, 162, 130, 0.07);
    font-family: var(--display);
    font-size: 15px;
    font-style: italic;
    letter-spacing: 0.01em;
  }
  .action-btn.branch-cta:hover {
    background: rgba(123, 162, 130, 0.14);
    border-color: var(--accent-response);
    color: var(--accent-response);
    transform: translateY(-1px);
  }
  .action-btn.branch-cta:active {
    transform: translateY(0);
    transition: transform 0.07s ease;
  }

  .children-section h4 {
    font-family: var(--ui);
    font-size: 11px; font-weight: 600;
    text-transform: uppercase; letter-spacing: 0.16em;
    color: var(--text-muted);
    margin-bottom: 14px;
    display: flex; align-items: center; gap: 10px;
  }
  .children-section h4::after {
    content: ''; flex: 1; height: 1px; background: var(--border-subtle);
  }

  .child-card {
    padding: 16px 36px 16px 18px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: 6px;
    margin-bottom: 10px;
    cursor: pointer;
    transition: all 0.25s ease;
    position: relative; overflow: hidden;
  }
  .child-card::before {
    content: ''; position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 2px;
    background: transparent;
    transition: background 0.3s ease;
  }
  .child-card.objection::before { background: var(--accent-objection); }
  .child-card.response::before { background: var(--accent-response); }
  .child-card:hover, .child-card:active { border-color: var(--accent-gold); transform: translateX(2px); }
  .child-card .ctype {
    font-size: 9px; text-transform: uppercase; letter-spacing: 0.16em;
    color: var(--text-muted); margin-bottom: 6px;
  }
  .child-card.objection .ctype { color: var(--accent-objection); }
  .child-card.response .ctype { color: var(--accent-response); }

  .child-card .title {
    font-family: var(--display);
    font-size: 16px; font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 6px; padding-right: 24px;
  }

  .child-card .preview {
    font-size: 13px; color: var(--text-secondary);
    line-height: 1.5;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
  }
  .child-card.revealed .preview {
    overflow: visible;
    display: block;
    -webkit-line-clamp: unset;
    line-clamp: unset;
  }

  .child-card .check {
    position: absolute; top: 14px; right: 14px;
    width: 18px; height: 18px; border-radius: 50%;
    background: var(--accent-gold); display: none;
    align-items: center; justify-content: center;
    color: var(--bg-deep); font-size: 11px; font-weight: bold;
    box-shadow: 0 0 8px var(--glow-gold);
  }
  .card-chevron {
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 20px;
    color: var(--text-muted);
    opacity: 0.3;
    transition: all 0.2s ease;
    pointer-events: none;
  }
  .child-card:hover .card-chevron {
    opacity: 0.7;
    transform: translateY(-50%) translateX(3px);
    color: var(--accent-gold);
  }
  .empty-children {
    padding: 24px; text-align: center;
    font-family: var(--display);
    font-style: italic;
    color: var(--text-muted);
    border: 1px dashed var(--border-subtle);
    border-radius: 6px;
  }

  /* Backdrop for mobile drawers */
  .backdrop {
    position: fixed; inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 25;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
  }
  .backdrop.active { opacity: 1; pointer-events: auto; }

  ::-webkit-scrollbar { width: 8px; height: 8px; }
  ::-webkit-scrollbar-track { background: transparent; }
  ::-webkit-scrollbar-thumb { background: var(--bg-elevated); border-radius: 4px; }
  ::-webkit-scrollbar-thumb:hover { background: var(--line-explored); }

  /* ============================================================
     MOBILE LAYOUT (< 900px)

     v20 split layout: in explorer view the screen is divided into
     a top "map" (the SVG tree) and a bottom "reading" panel (the
     node detail). Both are visible simultaneously — selecting a
     node anywhere smoothly pans the map above. No more sheet
     toggling; the spatial structure and the content are always
     side-by-side, so the user never loses their bearings.
     ============================================================ */
  @media (max-width: 900px) {
    :root { --header-h: 54px; --tree-h-mobile: 38dvh; }

    .app {
      grid-template-columns: 1fr;
      grid-template-rows: var(--header-h) 1fr;
    }

    /* In explorer view: header | tree map | drag handle | detail */
    body[data-view="explorer"] .app {
      grid-template-rows: var(--header-h) var(--tree-h-mobile) auto 1fr;
    }

    .splitter { display: none; }

    .icon-btn { display: flex; }

    header { padding: 0 10px; gap: 8px; }
    .brand { font-size: 17px; gap: 8px; }
    .brand .seed { width: 18px; height: 18px; }

    .breadcrumb { display: none; }

    /* Sidebar: full-screen in categories/trees, drawer in explorer */
    .sidebar {
      grid-column: 1;
      grid-row: 2 / -1;
      border-right: none;
    }

    body[data-view="explorer"] .sidebar {
      position: fixed;
      top: var(--header-h);
      left: 0;
      bottom: 0;
      width: min(320px, 86vw);
      z-index: 35;
      transform: translateX(-100%);
      transition: transform 0.3s ease;
      border-right: 1px solid var(--border-subtle);
      box-shadow: 2px 0 20px rgba(0, 0, 0, 0.5);
    }
    body[data-view="explorer"] .sidebar.mobile-open { transform: translateX(0); }

    /* Canvas: hidden in categories/trees, top half of explorer */
    body[data-view="categories"] .canvas,
    body[data-view="trees"] .canvas {
      display: none;
    }
    body[data-view="explorer"] .canvas {
      grid-column: 1;
      grid-row: 2;
      border-bottom: 1px solid var(--border-subtle);
      min-height: 0;
    }

    /* Bottom-right of the tree pane (top half of viewport on mobile),
       so the buttons sit roughly mid-screen — easy thumb reach. */
    .canvas-controls {
      top: auto;
      bottom: 12px;
      right: 12px;
      gap: 6px;
      flex-direction: column;
    }
    .canvas-btn {
      width: 40px; height: 40px;
      font-size: 15px;
      background: rgba(26, 33, 45, 0.96);
    }

    /* Detail: sits in row 4 (below the drag handle) in explorer view */
    body[data-view="explorer"] .detail {
      grid-column: 1;
      grid-row: 4;
      position: relative;
      transform: none;
      height: auto;
      max-height: none;
      border-top: none;
      border-right: none;
      border-radius: 0;
      box-shadow: none;
      z-index: 1;
      min-width: 0;
    }

    /* Mobile drag-to-resize splitter */
    .mobile-splitter {
      display: none;
    }
    body[data-view="explorer"] .mobile-splitter {
      display: flex;
      align-items: center;
      justify-content: center;
      grid-column: 1;
      grid-row: 3;
      height: 20px;
      background: var(--bg-mid);
      border-top: 1px solid var(--border-subtle);
      border-bottom: 1px solid var(--border-subtle);
      cursor: ns-resize;
      touch-action: none;
      user-select: none;
      z-index: 30;
      flex-shrink: 0;
      transition: background 0.15s ease;
    }
    body[data-view="explorer"] .mobile-splitter:active,
    body[data-view="explorer"] .mobile-splitter.dragging {
      background: rgba(232, 176, 76, 0.08);
    }
    .mobile-splitter-grip {
      width: 24px;
      height: 3px;
      border-radius: 2px;
      background: repeating-linear-gradient(
        90deg,
        var(--text-muted) 0px, var(--text-muted) 3px,
        transparent 3px, transparent 6px
      );
      opacity: 0.5;
      pointer-events: none;
      flex-shrink: 0;
      transition: opacity 0.15s ease;
    }
    .mobile-splitter-label {
      font-family: var(--ui);
      font-size: 9px;
      font-weight: 600;
      letter-spacing: 0.1em;
      text-transform: uppercase;
      color: var(--text-muted);
      pointer-events: none;
      padding: 0 8px;
      transition: color 0.15s ease;
    }
    body[data-view="explorer"] .mobile-splitter.dragging .mobile-splitter-grip {
      background: repeating-linear-gradient(
        90deg,
        var(--accent-gold) 0px, var(--accent-gold) 3px,
        transparent 3px, transparent 6px
      );
      opacity: 1;
    }
    body[data-view="explorer"] .mobile-splitter.dragging .mobile-splitter-label {
      color: var(--accent-gold);
    }
    body[data-view="categories"] .detail,
    body[data-view="trees"] .detail { display: none; }

    /* Drawer-era affordances no longer apply on mobile — split view
       has the tree always visible above. */
    .detail-mobile-handle { display: none !important; }
    .detail-close-btn { display: none !important; }
    .detail-mapbtn { display: none !important; }

    .detail-inner { padding: 14px 18px 32px; }
    .detail h2 { font-size: 21px; padding-right: 0; line-height: 1.25; }
    .detail-content { font-size: 16px; line-height: 1.6; }
    .detail-context { font-size: 13px; }
    .editor-actions { margin-bottom: 16px; padding-bottom: 14px; }

    /* Lineage / sibling-nav rows show only on phone */
    .detail-lineage, .sibling-nav { display: flex !important; }

    /* Adjust category cards for mobile */
    .category-card { padding: 20px; margin: 0 14px 12px; }
    .category-card .cat-name { font-size: 22px; }
    .category-card .cat-desc { font-size: 13px; }

    /* Tree list items bigger tap targets */
    .tree-list li { padding: 18px 22px; font-size: 17px; }

    .canvas-welcome h1 { font-size: 26px; }
    .canvas-welcome .verse { font-size: 15px; }

    /* Hide desktop controls help that doesn't apply to mobile */
    .controls-help { font-size: 11px; }
  }

  @media (max-width: 400px) {
    .brand span { display: none; }
    .canvas-welcome { padding: 24px 16px; }
    .canvas-welcome h1 { font-size: 22px; }
    .category-card { margin: 0 10px 10px; padding: 18px; }
  }

  /* Compact split: shorter phones get a slightly smaller tree pane so
     the reading area doesn't feel cramped. */
  @media (max-width: 900px) and (max-height: 700px) {
    :root { --tree-h-mobile: 34dvh; }
  }

  /* ============ LOADING / ERROR STATES ============ */
  .canvas-loading {
    position: absolute; inset: 0;
    display: none;
    flex-direction: column; align-items: center; justify-content: center;
    gap: 18px;
    background: rgba(10, 14, 20, 0.6);
    backdrop-filter: blur(2px);
    z-index: 6;
    pointer-events: none;
  }
  .canvas-loading.active { display: flex; }
  .canvas-loading .spinner {
    width: 38px; height: 38px;
    border: 2px solid rgba(232, 176, 76, 0.15);
    border-top-color: var(--accent-gold);
    border-radius: 50%;
    animation: spin 0.9s linear infinite;
    filter: drop-shadow(0 0 6px var(--glow-gold));
  }
  @keyframes spin { to { transform: rotate(360deg); } }
  .canvas-loading .msg {
    font-family: var(--display);
    font-style: italic;
    font-size: 15px;
    color: var(--text-secondary);
    letter-spacing: 0.02em;
  }
  .canvas-error {
    position: absolute; inset: 0;
    display: none;
    flex-direction: column; align-items: center; justify-content: center;
    padding: 32px;
    text-align: center;
    z-index: 7;
  }
  .canvas-error.active { display: flex; }
  .canvas-error .icon {
    font-size: 32px; margin-bottom: 16px; color: var(--accent-objection);
  }
  .canvas-error .title {
    font-family: var(--display);
    font-size: 22px;
    color: var(--text-primary);
    margin-bottom: 8px;
  }
  .canvas-error .desc {
    font-size: 13px;
    color: var(--text-secondary);
    max-width: 340px;
    line-height: 1.55;
    margin-bottom: 18px;
  }
  .canvas-error button {
    font-family: var(--ui);
    font-size: 11px; text-transform: uppercase; letter-spacing: 0.14em;
    padding: 10px 18px;
    background: transparent;
    border: 1px solid var(--accent-gold);
    color: var(--accent-gold);
    border-radius: 4px; cursor: pointer;
    transition: all 0.2s ease;
  }
  .canvas-error button:hover { background: rgba(232, 176, 76, 0.1); }

  /* ============ AUTH PORTAL (full-screen welcome / sign-in) ============ */
  .auth-portal {
    position: fixed; inset: 0;
    z-index: 100;
    background: var(--bg-deep);
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    padding: 32px 24px;
    overflow-y: auto;
    overscroll-behavior: contain;
  }
  .auth-bg-canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
    touch-action: none;
  }
  /* Backdrops are fixed to viewport so they don't scroll out when the
     auth card is taller than the viewport (e.g. the register form). */
  .auth-portal::before {
    content: ''; position: fixed; inset: 0;
    background:
      radial-gradient(ellipse at 50% 100%, rgba(212, 164, 69, 0.12) 0%, transparent 60%),
      radial-gradient(ellipse at 30% 0%, rgba(123, 162, 130, 0.05) 0%, transparent 50%);
    pointer-events: none;
    z-index: 0;
  }
  .auth-portal::after {
    content: ''; position: fixed; inset: 0;
    background-image:
      radial-gradient(circle at 17% 23%, rgba(255, 240, 210, 0.4) 0.5px, transparent 1px),
      radial-gradient(circle at 73% 41%, rgba(255, 240, 210, 0.3) 0.5px, transparent 1px),
      radial-gradient(circle at 41% 67%, rgba(255, 240, 210, 0.4) 0.4px, transparent 1px),
      radial-gradient(circle at 88% 87%, rgba(255, 240, 210, 0.25) 0.6px, transparent 1px),
      radial-gradient(circle at 12% 91%, rgba(255, 240, 210, 0.3) 0.4px, transparent 1px),
      radial-gradient(circle at 56% 12%, rgba(255, 240, 210, 0.35) 0.5px, transparent 1px);
    pointer-events: none; opacity: 0.5;
    z-index: 0;
  }
  /* Hide the global body backdrops while the auth portal is up — they were
     showing through and clashing with the portal's own gradients. */
  body:has(.auth-portal:not(.hidden))::before,
  body:has(.auth-portal:not(.hidden))::after { display: none; }
  .auth-portal.hidden { display: none; }

  .auth-card {
    position: relative; z-index: 1;
    width: 100%; max-width: 420px;
    text-align: center;
    animation: portalFadeIn 0.6s ease;
  }
  @keyframes portalFadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
  }

  .auth-portal .seed {
    width: 64px; height: 64px;
    margin: 0 auto 18px;
    filter: drop-shadow(0 0 14px var(--glow-gold));
    animation: float 4s ease-in-out infinite;
  }
  .auth-portal h1 {
    font-family: var(--display);
    font-size: 36px; font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 10px;
    letter-spacing: -0.01em;
  }
  .auth-portal h1 em { color: var(--accent-gold); font-style: italic; }
  .auth-portal .verse {
    font-family: var(--display);
    font-style: italic;
    font-size: 15px;
    color: var(--text-secondary);
    line-height: 1.55;
    margin-bottom: 6px;
    max-width: 380px;
    margin-left: auto; margin-right: auto;
  }
  .auth-portal .verse-ref {
    font-family: var(--ui);
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.18em;
    color: var(--text-muted);
    margin-bottom: 32px;
  }

  .auth-form {
    background: var(--bg-panel);
    border: 1px solid var(--border-subtle);
    border-radius: 12px;
    padding: 24px;
    margin-bottom: 16px;
    text-align: left;
  }

  .auth-tabs {
    display: flex;
    gap: 4px;
    background: var(--bg-panel);
    border: 1px solid var(--border-subtle);
    border-radius: 10px;
    padding: 4px;
    margin-bottom: 12px;
  }
  .auth-tab {
    flex: 1;
    background: transparent;
    border: none;
    padding: 10px 14px;
    font-family: var(--ui);
    font-size: 12px; font-weight: 600;
    text-transform: uppercase; letter-spacing: 0.12em;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: 7px;
    transition: all 0.2s ease;
  }
  .auth-tab:hover { color: var(--text-secondary); }
  .auth-tab.active {
    background: var(--bg-elevated);
    color: var(--accent-gold);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  }
  .auth-form.auth-pane { margin-bottom: 16px; }
  .auth-pane { display: none; }
  .auth-pane.active { display: block; }

  .auth-link-row {
    margin-top: 12px;
    text-align: center;
  }
  .auth-link {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 12px;
    cursor: pointer;
    padding: 4px 8px;
    transition: color 0.2s ease;
    text-decoration: underline;
    text-decoration-color: rgba(154, 149, 138, 0.3);
    text-underline-offset: 2px;
  }
  .auth-link:hover { color: var(--accent-gold); text-decoration-color: var(--accent-gold); }

  .auth-form-title {
    font-family: var(--display);
    font-size: 18px;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 4px;
  }
  .auth-form-help {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 16px;
    line-height: 1.5;
  }
  .auth-success {
    font-size: 12px;
    color: var(--accent-response);
    margin-bottom: 12px;
    min-height: 16px;
    line-height: 1.4;
  }

  .auth-info {
    text-align: center;
  }
  .auth-info .info-icon {
    font-size: 36px;
    color: var(--accent-gold);
    margin-bottom: 12px;
    filter: drop-shadow(0 0 8px var(--glow-gold));
  }
  .auth-info h4 {
    font-family: var(--display);
    font-size: 22px;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 10px;
  }
  .auth-info p {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 18px;
  }
  .auth-info p strong {
    color: var(--text-primary);
    font-weight: 600;
  }
  .auth-btn-secondary {
    width: 100%;
    font-family: var(--ui);
    font-size: 12px; font-weight: 500;
    text-transform: uppercase; letter-spacing: 0.14em;
    padding: 11px;
    background: transparent;
    border: 1px solid var(--border-soft);
    color: var(--text-secondary);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
  }
  .auth-btn-secondary:hover { border-color: var(--accent-gold); color: var(--accent-gold); }

  .captcha-container {
    margin-bottom: 14px;
    min-height: 0;
    display: flex;
    justify-content: center;
  }
  .captcha-container.active { min-height: 78px; }

  .opt-inline {
    color: var(--text-muted);
    font-weight: 400;
    text-transform: none;
    letter-spacing: 0;
    font-size: 10px;
  }
  .auth-form .label {
    font-family: var(--ui);
    font-size: 10px; text-transform: uppercase; letter-spacing: 0.16em;
    color: var(--text-muted);
    margin-bottom: 6px; display: block;
  }
  .auth-form input {
    width: 100%; padding: 11px 14px;
    background: var(--bg-deep);
    border: 1px solid var(--border-soft);
    border-radius: 6px;
    color: var(--text-primary);
    font-family: var(--ui);
    font-size: 14px;
    margin-bottom: 14px;
    transition: border-color 0.2s ease;
  }
  .auth-form input:focus {
    outline: none;
    border-color: var(--accent-gold);
    box-shadow: 0 0 0 3px rgba(232, 176, 76, 0.1);
  }
  .auth-form .auth-error {
    font-size: 12px;
    color: var(--accent-objection);
    margin-bottom: 12px;
    min-height: 16px;
    line-height: 1.4;
  }
  /* Live confirm-password match hint */
  .auth-match-hint {
    font-size: 11px;
    line-height: 1.4;
    margin-top: -8px;
    margin-bottom: 12px;
    min-height: 14px;
    letter-spacing: 0.02em;
    transition: color 0.2s ease;
  }
  .auth-match-hint.match { color: var(--accent-response); }
  .auth-match-hint.mismatch { color: var(--accent-objection); }
  .auth-form input.input-mismatch {
    border-color: rgba(198, 106, 94, 0.55);
  }
  .auth-form input.input-match {
    border-color: rgba(123, 162, 130, 0.45);
  }
  .auth-btn {
    width: 100%;
    font-family: var(--ui);
    font-size: 12px; font-weight: 600;
    text-transform: uppercase; letter-spacing: 0.14em;
    padding: 13px;
    background: var(--accent-gold);
    border: 1px solid var(--accent-gold);
    color: var(--bg-deep);
    border-radius: 6px; cursor: pointer;
    transition: all 0.2s ease;
  }
  .auth-btn:hover { background: var(--line-current); border-color: var(--line-current); }
  .auth-btn:disabled { opacity: 0.5; cursor: not-allowed; }

  .auth-divider {
    display: flex; align-items: center; gap: 12px;
    font-size: 10px; text-transform: uppercase; letter-spacing: 0.16em;
    color: var(--text-muted);
    margin: 8px 0;
  }
  .auth-divider::before, .auth-divider::after {
    content: ''; flex: 1; height: 1px; background: var(--border-subtle);
  }

  .auth-reader-btn {
    width: 100%;
    font-family: var(--ui);
    font-size: 12px; font-weight: 500;
    text-transform: uppercase; letter-spacing: 0.14em;
    padding: 13px;
    background: transparent;
    border: 1px solid var(--border-soft);
    color: var(--text-secondary);
    border-radius: 6px; cursor: pointer;
    transition: all 0.2s ease;
  }
  .auth-reader-btn:hover { border-color: var(--accent-gold); color: var(--accent-gold); }

  .auth-portal .footnote {
    margin-top: 18px;
    font-size: 11px; color: var(--text-muted);
    line-height: 1.5;
  }

  /* ============ HEADER USER MENU (when signed in) ============ */
  .user-menu {
    display: none;
    align-items: center; gap: 10px;
    margin-left: auto;
    padding-left: 14px;
    flex-shrink: 0;
  }
  .user-menu.active { display: flex; }
  .user-menu .email {
    font-size: 12px;
    color: var(--text-secondary);
    max-width: 180px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  .user-menu .editor-badge {
    font-family: var(--ui);
    font-size: 9px; font-weight: 600;
    text-transform: uppercase; letter-spacing: 0.14em;
    padding: 3px 8px;
    background: rgba(232, 176, 76, 0.12);
    color: var(--accent-gold);
    border: 1px solid rgba(232, 176, 76, 0.3);
    border-radius: 10px;
  }
  .user-menu .signout {
    background: transparent;
    border: 1px solid var(--border-subtle);
    color: var(--text-secondary);
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-family: var(--ui);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    transition: all 0.2s ease;
  }
  .user-menu .signout:hover { border-color: var(--accent-objection); color: var(--accent-objection); }

  /* ============ ADMIN LINK BUTTON ============ */
  .admin-link {
    background: rgba(232, 176, 76, 0.1);
    border: 1px solid rgba(232, 176, 76, 0.3);
    color: var(--accent-gold);
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-family: var(--ui);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    transition: all 0.2s ease;
  }
  .admin-link:hover {
    background: rgba(232, 176, 76, 0.2);
    border-color: var(--accent-gold);
  }

  /* ============ SIGN-IN LINK (when in reader mode) ============ */
  .signin-link {
    margin-left: auto;
    display: inline-flex;
    align-items: center;
    font-family: var(--ui);
    font-size: 11px; font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    padding: 8px 16px;
    background: rgba(232, 176, 76, 0.08);
    border: 1px solid rgba(232, 176, 76, 0.35);
    color: var(--accent-gold);
    border-radius: 18px;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
  }
  .signin-link:hover {
    background: rgba(232, 176, 76, 0.18);
    border-color: var(--accent-gold);
    box-shadow: 0 0 12px rgba(232, 176, 76, 0.25);
  }

  /* ============ EDITOR ACTIONS IN DETAIL PANEL ============ */
  .editor-actions {
    margin: 0 0 24px;
    padding-bottom: 22px;
    border-bottom: 1px solid var(--border-subtle);
  }
  .editor-actions .editor-label {
    font-family: var(--ui);
    font-size: 11px; font-weight: 600;
    text-transform: uppercase; letter-spacing: 0.16em;
    color: var(--accent-gold);
    margin-bottom: 14px;
    display: flex; align-items: center; gap: 10px;
  }
  .editor-actions .editor-label::before {
    content: '✎'; font-size: 12px;
  }
  .editor-actions .editor-label::after {
    content: ''; flex: 1; height: 1px; background: rgba(232, 176, 76, 0.2);
  }
  .editor-btn-row {
    display: flex; gap: 6px; flex-wrap: wrap;
  }
  .editor-btn {
    flex: 1; min-width: 90px;
    font-family: var(--ui);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    padding: 9px 10px;
    background: rgba(232, 176, 76, 0.06);
    border: 1px solid rgba(232, 176, 76, 0.25);
    color: var(--accent-gold);
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.2s ease;
  }
  .editor-btn:hover { background: rgba(232, 176, 76, 0.14); border-color: var(--accent-gold); }
  .editor-btn.danger {
    background: rgba(198, 106, 94, 0.06);
    border-color: rgba(198, 106, 94, 0.25);
    color: var(--accent-objection);
  }
  .editor-btn.danger:hover {
    background: rgba(198, 106, 94, 0.14);
    border-color: var(--accent-objection);
  }

  /* "+ New tree" button in sidebar */
  .add-tree-btn {
    width: 100%;
    font-family: var(--ui);
    font-size: 11px; font-weight: 600;
    text-transform: uppercase; letter-spacing: 0.14em;
    padding: 11px 12px;
    background: rgba(232, 176, 76, 0.06);
    border: 1px dashed rgba(232, 176, 76, 0.4);
    color: var(--accent-gold);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
  }
  .add-tree-btn:hover {
    background: rgba(232, 176, 76, 0.14);
    border-style: solid;
    border-color: var(--accent-gold);
  }

  /* ============ EDITOR MODAL ============ */
  .modal-backdrop {
    position: fixed; inset: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 60;
    display: none;
    align-items: center; justify-content: center;
    padding: 20px;
    backdrop-filter: blur(3px);
  }
  .modal-backdrop.active { display: flex; }

  .modal {
    background: var(--bg-panel);
    border: 1px solid var(--border-soft);
    border-radius: 12px;
    width: 100%; max-width: 540px;
    max-height: 90vh;
    overflow-y: auto;
    padding: 28px 28px 24px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    animation: modalIn 0.2s ease;
  }
  @keyframes modalIn {
    from { opacity: 0; transform: translateY(10px) scale(0.97); }
    to { opacity: 1; transform: translateY(0) scale(1); }
  }
  .modal h3 {
    font-family: var(--display);
    font-size: 22px; font-weight: 500;
    margin-bottom: 4px;
    color: var(--text-primary);
  }
  .modal .modal-sub {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 20px;
  }
  .modal .field {
    margin-bottom: 14px;
  }
  .modal .field label {
    display: block;
    font-family: var(--ui);
    font-size: 10px; font-weight: 600;
    text-transform: uppercase; letter-spacing: 0.14em;
    color: var(--text-muted);
    margin-bottom: 6px;
  }
  .modal .field label .opt { color: var(--text-muted); font-weight: 400; text-transform: none; letter-spacing: 0; }
  .modal .field input,
  .modal .field textarea,
  .modal .field select {
    width: 100%;
    padding: 10px 12px;
    background: var(--bg-deep);
    border: 1px solid var(--border-soft);
    border-radius: 6px;
    color: var(--text-primary);
    font-family: var(--ui);
    font-size: 14px;
    line-height: 1.5;
    transition: border-color 0.2s ease;
  }
  .modal .field textarea {
    resize: vertical;
    min-height: 80px;
    font-family: var(--display);
    font-size: 15px;
  }
  .modal .field input:focus,
  .modal .field textarea:focus,
  .modal .field select:focus {
    outline: none;
    border-color: var(--accent-gold);
    box-shadow: 0 0 0 3px rgba(232, 176, 76, 0.1);
  }
  .modal .field .hint {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 4px;
  }
  .modal-error {
    font-size: 12px;
    color: var(--accent-objection);
    margin: 8px 0;
    min-height: 16px;
  }
  .modal-actions {
    display: flex; gap: 8px;
    margin-top: 18px;
    justify-content: flex-end;
  }
  .modal-btn {
    font-family: var(--ui);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    padding: 10px 18px;
    border-radius: 5px;
    cursor: pointer;
    border: 1px solid var(--border-soft);
    background: transparent;
    color: var(--text-secondary);
    transition: all 0.2s ease;
  }
  .modal-btn:hover { border-color: var(--text-secondary); color: var(--text-primary); }
  .modal-btn.primary {
    background: var(--accent-gold);
    border-color: var(--accent-gold);
    color: var(--bg-deep);
    font-weight: 600;
  }
  .modal-btn.primary:hover {
    background: var(--line-current);
    border-color: var(--line-current);
    color: var(--bg-deep);
  }
  .modal-btn.danger {
    background: var(--accent-objection);
    border-color: var(--accent-objection);
    color: var(--bg-deep);
    font-weight: 600;
  }
  .modal-btn:disabled { opacity: 0.5; cursor: not-allowed; }

  @media (max-width: 900px) {
    .auth-portal h1 { font-size: 30px; }
    .auth-portal .seed { width: 56px; height: 56px; }
    .signin-link { padding: 7px 12px; font-size: 10px; letter-spacing: 0.1em; }
    .modal { padding: 22px 20px 20px; }

    /* User-menu compaction. Defined HERE (after the base .user-menu rules)
       so the cascade resolves in our favour — earlier mobile rules with the
       same specificity were getting overridden by the base styles below
       them in source order. */
    .user-menu { gap: 6px; padding-left: 8px; }
    .user-menu .email { display: none; }
    .user-menu .editor-badge { display: none; }
    .user-menu .signout {
      padding: 0;
      width: 36px; height: 36px;
      border-radius: 8px;
      display: inline-flex;
      align-items: center; justify-content: center;
      font-size: 0;        /* hides the literal "Sign out" text */
      line-height: 0;
    }
    .user-menu .signout::before {
      content: '⎋';
      font-size: 16px;
      line-height: 1;
    }
    .admin-link {
      padding: 0;
      width: 36px; height: 36px;
      border-radius: 8px;
      display: inline-flex;
      align-items: center; justify-content: center;
      font-size: 0;        /* hides the literal "Admin" text */
      line-height: 0;
    }
    .admin-link::before {
      content: '★';
      font-size: 14px;
      line-height: 1;
    }
    body.detail-sheet-open .icon-btn#mobile-detail-btn { display: none; }
  }

  /* The detail-mapbtn and detail-mobile-handle classes are kept above for
     compat but are force-hidden on mobile (split layout makes them moot). */

  /* Compact the auth portal on shorter viewports so the logo stays
     visible without forcing the user to scroll up. The register form
     is the tallest pane (5 inputs + captcha + button) so this matters
     most when that pane is active. */
  @media (max-height: 820px) {
    .auth-portal { padding: 20px 24px; justify-content: flex-start; }
    .auth-portal .seed { width: 48px; height: 48px; margin: 0 auto 10px; }
    .auth-portal h1 { font-size: 28px; margin-bottom: 6px; }
    .auth-portal .verse { font-size: 13px; max-width: 340px; }
    .auth-portal .verse-ref { margin-bottom: 18px; }
    .auth-form { padding: 18px; }
    .auth-form input { margin-bottom: 10px; padding: 9px 12px; }
    .auth-portal .footnote { margin-top: 12px; }
  }
  @media (max-height: 680px) {
    .auth-portal .verse, .auth-portal .verse-ref { display: none; }
    .auth-portal h1 { font-size: 24px; margin-bottom: 14px; }
    .auth-portal .seed { width: 40px; height: 40px; margin-bottom: 8px; }
  }

  /* ============ ADMIN DASHBOARD OVERLAY ============ */
  .admin-overlay {
    position: fixed; inset: 0;
    z-index: 80;
    background: var(--bg-deep);
    display: none;
    flex-direction: column;
    overflow-y: auto;
  }

  /* The admin confirm modal must render ABOVE the admin overlay */
  #admin-confirm-backdrop { z-index: 90 !important; }
  .admin-overlay.active { display: flex; }
  .admin-overlay::before {
    content: ''; position: absolute; inset: 0;
    background: radial-gradient(ellipse at 50% 0%, rgba(212, 164, 69, 0.06) 0%, transparent 60%);
    pointer-events: none;
  }
  .admin-shell {
    position: relative; z-index: 1;
    width: 100%; max-width: 1100px;
    margin: 0 auto;
    padding: 32px 32px 60px;
    display: flex; flex-direction: column;
    flex: 1;
  }
  .admin-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 28px;
  }
  .admin-eyebrow {
    display: block;
    font-family: var(--ui);
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.18em;
    color: var(--text-muted);
    margin-bottom: 4px;
  }
  .admin-title h2 {
    font-family: var(--display);
    font-size: 32px; font-weight: 500;
    color: var(--text-primary);
    letter-spacing: -0.01em;
  }
  .admin-close {
    background: transparent;
    border: 1px solid var(--border-subtle);
    color: var(--text-secondary);
    width: 40px; height: 40px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px;
    transition: all 0.2s ease;
  }
  .admin-close:hover { border-color: var(--accent-objection); color: var(--accent-objection); }

  .admin-tabs {
    display: flex;
    gap: 4px;
    border-bottom: 1px solid var(--border-subtle);
    margin-bottom: 28px;
  }
  .admin-tab {
    background: transparent;
    border: none;
    padding: 12px 18px;
    font-family: var(--ui);
    font-size: 12px; font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    color: var(--text-muted);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    transition: all 0.2s ease;
  }
  .admin-tab:hover { color: var(--text-secondary); }
  .admin-tab.active {
    color: var(--accent-gold);
    border-bottom-color: var(--accent-gold);
  }

  .admin-pane { display: none; }
  .admin-pane.active { display: block; animation: paneFadeIn 0.25s ease; }
  @keyframes paneFadeIn { from { opacity: 0; } to { opacity: 1; } }

  .admin-pane-head {
    display: flex; align-items: flex-end; justify-content: space-between;
    margin-bottom: 22px; gap: 16px;
    flex-wrap: wrap;
  }
  .admin-pane-head h3 {
    font-family: var(--display);
    font-size: 22px; font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 4px;
  }
  .admin-sub {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.5;
    max-width: 520px;
  }

  .admin-primary-btn {
    background: var(--accent-gold);
    border: 1px solid var(--accent-gold);
    color: var(--bg-deep);
    padding: 11px 20px;
    border-radius: 6px;
    font-family: var(--ui);
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    cursor: pointer;
    transition: all 0.2s ease;
  }
  .admin-primary-btn:hover { background: var(--line-current); border-color: var(--line-current); }
  .admin-primary-btn:disabled { opacity: 0.5; cursor: not-allowed; }

  .admin-table-wrap {
    background: var(--bg-panel);
    border: 1px solid var(--border-subtle);
    border-radius: 10px;
    overflow: auto;
  }
  .admin-table {
    width: 100%;
    border-collapse: collapse;
    font-family: var(--ui);
    font-size: 13px;
  }
  .admin-table thead th {
    text-align: left;
    padding: 12px 16px;
    font-family: var(--ui);
    font-size: 10px; font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-subtle);
    background: var(--bg-elevated);
  }
  .admin-table tbody td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-subtle);
    color: var(--text-primary);
    vertical-align: middle;
  }
  .admin-table tbody tr:last-child td { border-bottom: none; }
  .admin-table tbody tr:hover { background: rgba(232, 176, 76, 0.03); }
  .admin-loading {
    text-align: center !important;
    color: var(--text-muted) !important;
    font-style: italic;
    padding: 32px !important;
  }
  .admin-empty {
    text-align: center !important;
    color: var(--text-muted) !important;
    padding: 32px !important;
    font-family: var(--display);
    font-style: italic;
  }

  .admin-code-cell {
    font-family: 'Menlo', 'Monaco', 'Courier New', monospace;
    font-size: 12px;
    color: var(--accent-gold);
    background: rgba(232, 176, 76, 0.08);
    padding: 4px 8px;
    border-radius: 4px;
    cursor: pointer;
    user-select: all;
    transition: background 0.2s ease;
  }
  .admin-code-cell:hover { background: rgba(232, 176, 76, 0.18); }
  .admin-code-cell.copied { background: var(--accent-response); color: var(--bg-deep); }

  .admin-pill {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.12em;
  }
  .admin-pill.active   { background: rgba(123, 162, 130, 0.15); color: var(--accent-response); border: 1px solid rgba(123, 162, 130, 0.4); }
  .admin-pill.used     { background: rgba(154, 149, 138, 0.1); color: var(--text-muted); border: 1px solid var(--border-soft); }
  .admin-pill.revoked  { background: rgba(198, 106, 94, 0.1); color: var(--accent-objection); border: 1px solid rgba(198, 106, 94, 0.3); }
  .admin-pill.role-owner       { background: rgba(232, 176, 76, 0.22); color: var(--accent-gold); border: 1px solid var(--accent-gold); font-weight: 600; }
  .admin-pill.role-admin       { background: rgba(232, 176, 76, 0.15); color: var(--accent-gold); border: 1px solid rgba(232, 176, 76, 0.4); }
  .admin-pill.role-contributor { background: rgba(123, 162, 130, 0.12); color: var(--accent-response); border: 1px solid rgba(123, 162, 130, 0.35); }
  .admin-pill.role-member      { background: rgba(232, 228, 220, 0.05); color: var(--text-secondary); border: 1px solid var(--border-soft); }
  /* Backwards-compat: keep .role-editor styled until any pre-migration data clears */
  .admin-pill.role-editor      { background: rgba(232, 228, 220, 0.05); color: var(--text-secondary); border: 1px solid var(--border-soft); }

  .admin-pill.action-create { background: rgba(123, 162, 130, 0.12); color: var(--accent-response); border: 1px solid rgba(123, 162, 130, 0.3); }
  .admin-pill.action-update { background: rgba(232, 176, 76, 0.1); color: var(--accent-gold); border: 1px solid rgba(232, 176, 76, 0.3); }
  .admin-pill.action-delete { background: rgba(198, 106, 94, 0.1); color: var(--accent-objection); border: 1px solid rgba(198, 106, 94, 0.3); }

  .admin-row-btn {
    background: transparent;
    border: 1px solid var(--border-soft);
    color: var(--text-secondary);
    padding: 5px 10px;
    border-radius: 4px;
    font-family: var(--ui);
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    cursor: pointer;
    margin-left: 4px;
    transition: all 0.2s ease;
  }
  .admin-row-btn:hover { border-color: var(--text-secondary); color: var(--text-primary); }
  .admin-row-btn.danger:hover { border-color: var(--accent-objection); color: var(--accent-objection); }
  .admin-row-btn.gold:hover { border-color: var(--accent-gold); color: var(--accent-gold); }

  .admin-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 14px;
  }
  .admin-stat {
    background: var(--bg-panel);
    border: 1px solid var(--border-subtle);
    border-radius: 10px;
    padding: 22px;
  }
  .admin-stat-label {
    font-family: var(--ui);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.16em;
    color: var(--text-muted);
    margin-bottom: 8px;
  }
  .admin-stat-value {
    font-family: var(--display);
    font-size: 36px;
    font-weight: 500;
    color: var(--accent-gold);
    font-variant-numeric: tabular-nums;
  }

  @media (max-width: 700px) {
    .admin-shell { padding: 22px 18px 60px; }
    .admin-title h2 { font-size: 24px; }
    .admin-tab { padding: 10px 12px; font-size: 11px; }
    .admin-table { font-size: 12px; }
    .admin-table thead th, .admin-table tbody td { padding: 10px 12px; }
    .admin-row-btn { padding: 4px 8px; font-size: 9px; margin-left: 2px; }
  }

  /* ============================================================
     LEARNING MODE — inline toggle, hidden cards, reveal, rating
     ============================================================ */

  /* iOS-style toggle */
  .learn-toggle-row {
    display: flex; align-items: center; justify-content: space-between;
    padding: 10px 0 14px;
    border-bottom: 1px solid var(--border-subtle);
    margin-bottom: 14px;
  }
  .learn-toggle-label {
    font-family: var(--ui);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-muted);
  }
  .ios-toggle {
    position: relative;
    width: 44px; height: 26px;
    border-radius: 13px;
    border: 1.5px solid var(--border-soft);
    background: var(--bg-elevated);
    cursor: pointer;
    outline: none;
    padding: 0;
    transition: background 0.22s ease, border-color 0.22s ease;
    -webkit-tap-highlight-color: transparent;
    flex-shrink: 0;
  }
  .ios-toggle.on {
    background: var(--accent-gold);
    border-color: var(--accent-gold);
  }
  .toggle-thumb {
    position: absolute;
    width: 18px; height: 18px;
    border-radius: 50%;
    background: var(--text-muted);
    top: 3px; left: 3px;
    transition: transform 0.22s cubic-bezier(0.34, 1.56, 0.64, 1), background 0.22s ease;
    box-shadow: 0 1px 4px rgba(0,0,0,0.4);
  }
  .ios-toggle.on .toggle-thumb {
    transform: translateX(18px);
    background: var(--bg-deep);
  }

  /* Hidden child cards (learning mode — not yet revealed) */
  .children-hidden-list {
    display: flex; flex-direction: column; gap: 8px;
    margin-bottom: 14px;
  }
  .child-card-hidden {
    display: flex; align-items: center; gap: 10px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: 10px;
    padding: 12px 14px;
    opacity: 0.55;
  }
  .child-hidden-type {
    font-family: var(--ui);
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    flex-shrink: 0;
    padding: 2px 7px;
    border-radius: 4px;
    background: rgba(232,228,220,0.06);
    color: var(--text-muted);
  }
  .child-hidden-type.objection { color: var(--accent-objection); background: rgba(198,106,94,0.08); }
  .child-hidden-type.response  { color: var(--accent-response);  background: rgba(123,162,130,0.08); }
  .child-hidden-bar {
    height: 8px;
    border-radius: 4px;
    background: var(--line-dormant);
    flex: 1;
    opacity: 0.5;
  }
  .child-hidden-bar.short { flex: 0 0 60px; }

  /* Reveal button */
  .reveal-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 24px;
    background: transparent;
    border: 1px solid var(--border-soft);
    border-radius: 8px;
    color: var(--text-secondary);
    font-family: var(--ui);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    cursor: pointer;
    transition: all 0.18s ease;
    margin-bottom: 12px;
  }
  .reveal-btn:hover {
    border-color: var(--accent-gold);
    color: var(--accent-gold);
    background: rgba(232,176,76,0.04);
  }

  /* Rating buttons on revealed child cards */
  .rating-row {
    display: flex; gap: 8px;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--border-subtle);
  }
  .rate-btn {
    flex: 1;
    padding: 7px 10px;
    border-radius: 6px;
    border: 1px solid var(--border-subtle);
    background: transparent;
    color: var(--text-muted);
    font-family: var(--ui);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    cursor: pointer;
    transition: all 0.16s ease;
  }
  .rate-btn.missed {
    border-color: rgba(212,164,78,0.25);
    color: var(--text-muted);
  }
  .rate-btn.missed:hover, .rate-btn.missed.active {
    background: rgba(212,164,78,0.1);
    border-color: #d4a44e;
    color: #d4a44e;
  }
  .rate-btn.gotit {
    border-color: rgba(123,162,130,0.25);
    color: var(--text-muted);
  }
  .rate-btn.gotit:hover, .rate-btn.gotit.active {
    background: rgba(123,162,130,0.1);
    border-color: var(--accent-response);
    color: var(--accent-response);
  }

  .rating-signin {
    font-size: 11px;
    color: var(--text-muted);
    padding: 4px 0 8px;
    opacity: 0.8;
  }

  @media (max-width: 700px) {
    .learn-toggle-row { padding: 8px 0 12px; }
    .rating-row { gap: 6px; }
    .rate-btn { padding: 6px 8px; font-size: 10px; }
  }

  /* ============================================================
     TUTORIAL OVERLAY
     Spotlight uses box-shadow to create a dimming mask with a
     transparent "hole" over the target element. The tooltip is
     positioned dynamically by tutorial.js.
     ============================================================ */

  .tutorial-overlay {
    position: fixed;
    inset: 0;
    z-index: 1100;
    pointer-events: all;
  }
  .tutorial-overlay[hidden] { display: none; }

  .tutorial-spotlight {
    position: fixed;
    border-radius: 10px;
    box-shadow:
      inset 0 0 0 2px rgba(244, 198, 100, 0.55),
      0 0 0 9999px rgba(0, 0, 0, 0.52);
    pointer-events: none;
    z-index: 1101;
    transition:
      top    0.38s cubic-bezier(0.4, 0, 0.2, 1),
      left   0.38s cubic-bezier(0.4, 0, 0.2, 1),
      width  0.38s cubic-bezier(0.4, 0, 0.2, 1),
      height 0.38s cubic-bezier(0.4, 0, 0.2, 1),
      opacity 0.28s ease;
  }

  .tutorial-tooltip {
    position: fixed;
    background: var(--bg-panel);
    border: 1px solid var(--line-active);
    border-radius: 12px;
    padding: 20px 22px 18px;
    pointer-events: all;
    z-index: 1102;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.65), 0 0 0 1px rgba(232, 176, 76, 0.12);
    transition:
      top  0.38s cubic-bezier(0.4, 0, 0.2, 1),
      left 0.38s cubic-bezier(0.4, 0, 0.2, 1);
  }

  .tutorial-step-label {
    font-family: var(--ui);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--accent-gold);
    margin-bottom: 8px;
  }

  .tutorial-tooltip h3 {
    font-family: var(--display);
    font-size: 19px;
    font-weight: 500;
    color: var(--text-primary);
    margin: 0 0 9px;
    line-height: 1.2;
  }

  .tutorial-tooltip p {
    font-family: var(--ui);
    font-size: 13.5px;
    color: var(--text-secondary);
    line-height: 1.55;
    margin: 0 0 18px;
  }

  .tutorial-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
  }
  .tutorial-actions-right {
    display: flex;
    align-items: center;
    gap: 8px;
  }

  .tutorial-btn-back {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-family: var(--ui);
    font-size: 12px;
    cursor: pointer;
    padding: 4px 0;
    transition: color 0.2s ease;
  }
  .tutorial-btn-back:hover { color: var(--text-primary); }

  .tutorial-btn-exit {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-family: var(--ui);
    font-size: 12px;
    cursor: pointer;
    padding: 4px 0;
    transition: color 0.2s ease;
  }
  .tutorial-btn-exit:hover { color: var(--text-secondary); }

  .tutorial-btn-next {
    background: var(--accent-gold);
    border: none;
    color: #0a0e14;
    font-family: var(--ui);
    font-size: 12px;
    font-weight: 700;
    padding: 8px 18px;
    border-radius: 8px;
    cursor: pointer;
    letter-spacing: 0.04em;
    transition: background 0.2s ease;
  }
  .tutorial-btn-next:hover { background: var(--line-current); }
  .tutorial-btn-next:disabled { opacity: 0.45; cursor: not-allowed; }
  .tutorial-btn-next.loading {
    opacity: 0.6;
    cursor: default;
    pointer-events: none;
    animation: tutorial-btn-pulse 1.2s ease-in-out infinite;
  }
  @keyframes tutorial-btn-pulse {
    0%, 100% { opacity: 0.55; }
    50%      { opacity: 0.85; }
  }

  /* ---- Guide button in header ---- */
  .tutorial-guide-btn {
    background: transparent;
    border: 1px solid var(--border-subtle);
    color: var(--text-secondary);
    height: 32px;
    padding: 0 12px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    font-family: var(--ui);
    font-size: 12px;
    letter-spacing: 0.06em;
    transition: border-color 0.2s ease, color 0.2s ease;
    flex-shrink: 0;
  }
  .tutorial-guide-btn:hover { border-color: var(--accent-gold); color: var(--accent-gold); }

  .guide-mobile { display: none; }

  @media (max-width: 900px) {
    .tutorial-guide-btn {
      width: 32px; height: 32px;
      padding: 0;
      justify-content: center;
      border-radius: 50%;
      font-size: 13px;
      font-style: italic;
      font-weight: 700;
      background: rgba(232, 176, 76, 0.1);
      border-color: rgba(232, 176, 76, 0.35);
      color: var(--accent-gold);
    }
    .guide-desktop { display: none; }
    .guide-mobile  { display: block; }
  }

