  /* ---------------- modals ---------------- */
  .modal-overlay{
    position:fixed; inset:0; z-index:50;
    display:flex; align-items:center; justify-content:center;
    background:rgba(28,32,39,0.4);
    opacity:0; pointer-events:none; transition:opacity .2s ease;
  }
  .modal-overlay.open{ opacity:1; pointer-events:auto; }
  .modal-card{
    width:min(440px, 90vw); padding:20px 22px 18px;
    background:var(--panel); border:1px solid var(--line); border-radius:10px;
    box-shadow:0 18px 40px rgba(28,32,39,0.18);
    transform:translateY(10px); transition:transform .22s ease;
  }
  .modal-overlay.open .modal-card{ transform:translateY(0); }
  .modal-head{ display:flex; align-items:flex-start; justify-content:space-between; gap:12px; margin-bottom:14px; padding-bottom:12px; border-bottom:1px solid var(--line); }
  .modal-title{ font-size:16px; font-weight:600; }
  .modal-sub{ margin-top:4px; font-size:11px; color:var(--ink-faint); overflow-wrap:anywhere; }
  .modal-close{
    flex-shrink:0; width:25px; height:25px; border:1px solid var(--line); border-radius:6px;
    background:none; font-size:15px; line-height:1; color:var(--ink-dim); cursor:pointer;
    transition:border-color .16s, color .16s, background .16s;
  }
  .modal-close:hover{ border-color:var(--ink-faint); color:var(--ink); background:rgba(154,160,172,0.1); }
  .stats-list{ display:flex; flex-direction:column; max-height:60vh; overflow-y:auto; }
  .stat-row{ display:flex; align-items:baseline; justify-content:space-between; gap:16px; padding:9px 0; border-bottom:1px solid var(--line); }
  .stat-row:last-child{ border-bottom:none; }
  .stat-label{ font-size:13px; color:var(--ink-dim); }
  .stat-value{ font-size:13px; font-weight:600; color:var(--ink); font-variant-numeric:tabular-nums; }

  /* ---------------- turn details modal ---------------- */
  .info-card{ width:min(920px, 94vw); max-height:86vh; display:flex; flex-direction:column; padding:0; }
  .info-card .modal-head{ padding:18px 22px 12px; margin-bottom:0; }
  .tabs{ display:flex; gap:2px; padding:0 22px; border-bottom:1px solid var(--line); flex-wrap:wrap; }
  .tab{
    padding:9px 13px; border:none; border-bottom:2px solid transparent; margin-bottom:-1px; background:none;
    font-family:inherit; font-size:13px; color:var(--ink-dim); cursor:pointer;
    transition:color .16s, border-color .16s;
  }
  .tab:hover{ color:var(--ink); }
  .tab.active{ color:var(--blue); border-bottom-color:var(--blue); font-weight:600; }
  .tab-body{ padding:16px 22px 22px; overflow:auto; }
  .info-note{
    margin-bottom:16px; padding:10px 12px;
    border:1px solid rgba(37,99,235,0.18); border-radius:6px; background:rgba(37,99,235,0.05);
    font-size:12.5px; line-height:1.55; color:var(--ink-dim);
  }
  .info-note b{ color:var(--ink); font-weight:600; }
  .info-section{ margin-top:18px; }
  .info-section:first-child{ margin-top:0; }
  .info-section h3{ margin:0 0 10px; font-size:11.5px; text-transform:uppercase; letter-spacing:.06em; color:var(--ink-faint); }
  .kv{ display:grid; grid-template-columns:minmax(150px, 230px) 1fr; gap:6px 16px; align-items:baseline; }
  .kv .k{ font-size:12px; color:var(--ink-dim); }
  .kv .v{ font-size:12px; color:var(--ink); overflow-wrap:anywhere; white-space:pre-wrap; }
  /* JSON is the reading surface of this modal, so it gets generous leading and a
     clear type hierarchy rather than being packed in tight. The left rule and the
     off-white ground lift the block out of the surrounding prose, and the colours
     are tuned for contrast on that ground: keys violet, strings green, numbers
     blue, literals amber, null muted. */
  .json-block,.text-block{
    margin:0; padding:15px 18px; max-height:62vh; overflow:auto;
    border:1px solid var(--line); border-left:3px solid rgba(106,63,224,0.2);
    border-radius:8px; background:#FAFBFD;
    font-family:ui-monospace, 'SFMono-Regular', Menlo, Consolas, 'Liberation Mono', monospace;
    font-size:12.5px; line-height:1.72; color:var(--ink);
    white-space:pre-wrap; overflow-wrap:anywhere; tab-size:2;
    font-variant-ligatures:none; font-feature-settings:"liga" 0, "calt" 0;
  }
  /* One block per JSON line, indented in `ch` so a wrapped continuation lines up
     under its own key rather than at the left margin. */
  .json-line{ display:block; }
  .json-key{ color:#6A3FE0; font-weight:600; }
  .json-str{ color:#0B6B4A; }
  .json-num{ color:#1D4ED8; }
  .json-bool{ color:#B45309; font-weight:600; }
  .json-null{ color:var(--ink-faint); font-style:italic; }
  .output-viewer{ margin-bottom:14px; }
  .output-view-bar{ display:flex; align-items:center; gap:8px; margin-bottom:8px; }
  .output-view-label{ font-size:9px; font-weight:600; text-transform:uppercase; letter-spacing:.06em; color:var(--ink-faint); }
  .output-view-bar .input-view{ padding:1px; border-radius:6px; }
  .output-view-bar .input-view-btn{ min-height:26px; padding:3px 8px; font-size:10px; }
  .output-view-content{ min-width:0; }
  .output-view-content > .json-block{ max-height:62vh; }
  .output-readable{ display:flex; flex-direction:column; gap:7px; }
  .output-readable-section{ min-width:0; padding:10px 12px; border:1px solid var(--line-soft); border-radius:6px; background:var(--panel); }
  .output-readable-section h3{ margin:0 0 5px; color:var(--ink-faint); font-size:9px; line-height:1.35; font-weight:700; text-transform:uppercase; letter-spacing:.065em; }
  .output-readable-text{ color:var(--ink); font-size:12px; line-height:1.5; white-space:pre-wrap; overflow-wrap:anywhere; }
  .output-reasoning{ background:var(--panel2); }
  .output-message{ border-inline-start:3px solid rgba(37,99,235,.28); }
  .output-decision{ background:rgba(37,99,235,.035); }
  .output-value-list{ display:grid; grid-template-columns:minmax(85px,120px) minmax(0,1fr); gap:4px 10px; margin:0; }
  .output-value-list dt{ color:var(--ink-faint); font-size:10px; }
  .output-value-list dd{ min-width:0; margin:0; color:var(--ink); font-size:11.5px; line-height:1.45; white-space:pre-wrap; overflow-wrap:anywhere; }
  .output-change-groups{ display:flex; flex-direction:column; gap:10px; }
  .output-change-group{ min-width:0; }
  .output-change-group + .output-change-group{ padding-top:8px; border-top:1px solid var(--line-soft); }
  .output-change-group h4{ margin:0 0 4px; color:var(--ink-dim); font-size:10px; font-weight:600; }
  .output-change-group h5{ margin:7px 0 3px; color:var(--ink-faint); font-size:9px; font-weight:600; text-transform:uppercase; letter-spacing:.04em; }
  .output-change-item{ display:grid; grid-template-columns:minmax(48px,64px) minmax(0,1fr); gap:8px; align-items:start; padding:5px 0; border-top:1px solid var(--line-soft); }
  .output-change-item-id{ padding-top:1px; color:var(--ink-faint); font:10px/1.4 ui-monospace,Menlo,Consolas,monospace; }
  .output-change-fields{ display:flex; flex-direction:column; gap:4px; min-width:0; }
  .output-change-field{ display:grid; grid-template-columns:minmax(70px,110px) minmax(0,1fr); gap:8px; }
  .output-change-field-name{ color:var(--ink-faint); font-size:10px; }
  .output-change-field-value{ min-width:0; color:var(--ink); font-size:11.5px; line-height:1.45; white-space:pre-wrap; overflow-wrap:anywhere; }
  @media (max-width:600px){
    .output-readable-section{ padding:9px 10px; }
    .output-value-list{ grid-template-columns:minmax(75px,100px) minmax(0,1fr); gap:4px 8px; }
    .output-change-item{ grid-template-columns:minmax(40px,52px) minmax(0,1fr); gap:6px; }
    .output-change-field{ grid-template-columns:minmax(62px,82px) minmax(0,1fr); gap:6px; }
  }
  /* ---------------- turn details: screenshots ---------------- */
  .shot-grid{ display:grid; grid-template-columns:repeat(auto-fit, minmax(240px, 1fr)); gap:18px; align-items:start; }
  .shot-figure{ margin:0; display:flex; flex-direction:column; gap:10px; min-width:0; }
  .shot-figure figcaption{ display:flex; align-items:flex-start; justify-content:space-between; gap:10px; }
  .shot-caption-text{ display:flex; flex-direction:column; gap:2px; min-width:0; }
  .shot-caption-title{ font-size:12px; font-weight:600; color:var(--ink); }
  .shot-caption-sub{ font-size:11px; line-height:1.45; color:var(--ink-faint); }
  .shot-expand{
    flex-shrink:0; padding:3px 9px; border:1px solid var(--line); border-radius:6px; background:var(--panel);
    font-family:inherit; font-size:11px; color:var(--ink-dim); cursor:pointer;
    transition:border-color .18s, color .18s, background .18s;
  }
  .shot-expand:hover{ border-color:var(--blue); background:rgba(37,99,235,0.06); color:var(--blue); }
  .shot-image{
    display:block; width:100%; max-height:62vh; object-fit:contain;
    border:1px solid var(--line); border-radius:8px; background:var(--lcd-bg); cursor:zoom-in;
  }
  .shot-missing{
    display:flex; align-items:center; justify-content:center; min-height:170px; padding:24px 18px;
    border:1px dashed var(--line); border-radius:8px; background:var(--panel2);
    font-size:12px; line-height:1.5; text-align:center; color:var(--ink-faint);
  }

  /* ---------------- image lightbox ---------------- */
  /* Sits above the info modal, so an expanded screenshot is a full read of the
     annotation without losing the turn it came from. */
  .lightbox{ z-index:60; padding:32px; background:rgba(10,13,18,0.88); }
  .lightbox-img{
    max-width:94vw; max-height:90vh; object-fit:contain;
    border-radius:8px; background:var(--panel); box-shadow:0 24px 70px rgba(0,0,0,0.55);
  }
  .lightbox-caption{
    position:fixed; top:22px; left:26px; z-index:1; pointer-events:none;
    font-size:12px; font-weight:600; color:#E7EAF0; text-shadow:0 1px 5px rgba(0,0,0,0.7);
  }
  .lightbox-close{
    position:fixed; top:16px; right:20px; z-index:1;
    width:34px; height:34px; border:1px solid rgba(255,255,255,0.3); border-radius:8px;
    background:rgba(22,27,36,0.72); font-family:inherit; font-size:19px; line-height:1; color:#fff; cursor:pointer;
  }
  .lightbox-close:hover{ background:rgba(22,27,36,0.95); border-color:rgba(255,255,255,0.55); }

  .tab-actions{ display:flex; align-items:center; justify-content:space-between; gap:12px; margin-bottom:14px; }
  .tab-actions-title{ font-size:12px; font-weight:600; text-transform:uppercase; letter-spacing:.06em; color:var(--ink-faint); }
  .copy-json-btn{
    display:inline-flex; align-items:center; gap:6px;
    padding:4px 9px; border:1px solid rgba(37,99,235,0.22); border-radius:6px;
    background:rgba(37,99,235,0.07); color:var(--blue);
    font-family:inherit; font-size:11px; font-weight:600; cursor:pointer; user-select:none;
    transition:all .18s ease;
  }
  .copy-json-btn:hover{ background:var(--blue); border-color:var(--blue); color:#fff; }
  .copy-json-btn.copied{ background:rgba(21,128,61,0.12); border-color:rgba(21,128,61,0.35); color:var(--green); }
  .copy-json-btn svg{ flex-shrink:0; }

