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

    body {
      min-height: 100vh;
      background: #0f0f0f;
      color: #f0f0f0;
      font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
      line-height: 1.6;
    }

    .dots {
      position: fixed; inset: 0; pointer-events: none;
      background-image: radial-gradient(circle, #2a2a2a 1px, transparent 1px);
      background-size: 32px 32px; opacity: 0.5; z-index: -1;
    }

    /* ── Nav ── */
    nav {
      display: flex; align-items: center; gap: 10px;
      padding: 14px 24px; border-bottom: 1px solid #1a1a1a; font-size: 0.82rem;
      position: sticky; top: 0; background: rgba(10,10,10,0.95);
      backdrop-filter: blur(8px); z-index: 50;
    }
    nav a { color: #555; text-decoration: none; transition: color 0.2s; }
    nav a:hover { color: #f0f0f0; }
    nav .sep { color: #333; }
    nav .current { color: #e0e0e0; }
    nav .spacer { flex: 1; }
    .nav-updated { font-size: 0.72rem; color: #2a2a2a; }
    /* ── Nav auth button ── */
    #nav-auth { position: relative; }
    #nav-auth-btn {
      background: none; border: 1px solid #252525; border-radius: 6px;
      color: #444; font-size: 0.75rem; padding: 4px 10px; cursor: pointer;
      font-family: inherit; transition: color 0.2s, border-color 0.2s;
      text-decoration: none; display: inline-block; line-height: 1.6;
    }
    #nav-auth-btn:hover { color: #888; border-color: #333; }
    #nav-auth-btn.authed { color: #4ade80; border-color: rgba(74,222,128,0.25); }
    #nav-auth-dropdown {
      display: none; position: absolute; right: 0; top: calc(100% + 6px);
      background: #0e0e0e; border: 1px solid #1e1e1e; border-radius: 8px;
      min-width: 160px; z-index: 200; overflow: hidden;
    }
    #nav-auth-dropdown.open { display: block; }
    .nav-dd-item {
      display: block; padding: 9px 14px; font-size: 0.8rem; color: #888;
      text-decoration: none; cursor: pointer; background: none; border: none;
      font-family: inherit; width: 100%; text-align: left; transition: background .15s, color .15s;
    }
    .nav-dd-item:hover { background: #161616; color: #ccc; }
    .nav-dd-item.danger:hover { color: #f87171; }

    /* ── Page (full width) ── */
    main { padding: 32px 32px 80px; }

    /* ── Header ── */
    .page-header { margin-bottom: 28px; }
    .page-eyebrow {
      font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.16em;
      color: #f59e0b; margin-bottom: 8px;
    }
    .page-title {
      font-size: clamp(1.5rem, 3vw, 2.2rem); font-weight: 800;
      letter-spacing: -0.02em; color: #fff; margin-bottom: 6px;
    }
    .page-subtitle { font-size: 0.86rem; color: #555; max-width: 560px; line-height: 1.7; }
    .page-subtitle a { color: #f59e0b; text-decoration: none; }
    .page-subtitle a:hover { text-decoration: underline; }

    /* ── Two-column layout ── */
    .idp-grid {
      display: flex;
      align-items: stretch;
      gap: 0;
      min-height: 0;
    }
    .idp-left {
      width: 50%;
      min-width: 240px;
      max-width: 80%;
      flex-shrink: 0;
      display: flex;
      flex-direction: column;
    }
    .idp-left .panel { flex: 1; display: flex; flex-direction: column; }
    .idp-left .panel-body { flex: 1; display: flex; flex-direction: column; }
    .idp-right {
      flex: 1;
      min-width: 240px;
      overflow: hidden;
    }
    /* Drag handle */
    .idp-resizer {
      width: 10px;
      flex-shrink: 0;
      cursor: col-resize;
      position: relative;
      display: flex;
      align-items: center;
      justify-content: center;
    }
    .idp-resizer::after {
      content: '';
      display: block;
      width: 3px;
      height: 40px;
      background: #2a2a2a;
      border-radius: 2px;
      transition: background 0.15s;
    }
    .idp-resizer:hover::after,
    .idp-resizer.dragging::after { background: #444; }

    /* ── Panels ── */
    .panel {
      background: #111; border: 1px solid #1e1e1e;
      border-radius: 12px; overflow: hidden;
    }
    .panel-header {
      padding: 13px 18px; border-bottom: 1px solid #1a1a1a;
      display: flex; align-items: center; gap: 8px; flex-shrink: 0;
    }
    .panel-title {
      font-size: 0.7rem; font-weight: 600; text-transform: uppercase;
      letter-spacing: 0.14em; color: #555;
    }
    .panel-body { padding: 16px; }

    /* ── Drop zone ── */
    #drop-zone {
      width: 100%; align-self: stretch;
      aspect-ratio: 4/3;
      border: 2px dashed #2a2a2a; border-radius: 10px;
      display: flex; flex-direction: column; align-items: center; justify-content: center;
      gap: 12px; cursor: pointer; transition: border-color 0.2s, background 0.2s;
      position: relative; overflow: hidden; text-align: center; padding: 20px;
    }
    #drop-zone:hover, #drop-zone.drag-over {
      border-color: #f59e0b; background: rgba(245,158,11,0.03);
    }
    #drop-zone.has-file {
      border-style: solid; border-color: #2a2a2a; cursor: default;
      aspect-ratio: unset; flex: 1; min-height: 400px;
      overflow-y: auto; overflow-x: hidden; padding: 0;
      align-items: flex-start; justify-content: flex-start;
    }
    #drop-zone input[type="file"] { display: none; }
    .drop-icon { font-size: 2.2rem; opacity: 0.4; }
    .drop-label { font-size: 0.86rem; color: #555; }
    .drop-hint  { font-size: 0.73rem; color: #333; }

    #preview-img { width: 100%; height: auto; display: none; object-fit: contain; background: #0d0d0d; }
    #pdf-canvas  { display: none; width: 100%; height: auto; background: #0d0d0d; }

    /* PDF navigator */
    #pdf-nav {
      display: none; position: sticky; bottom: 0; left: 0; right: 0;
      background: rgba(17,17,17,0.92); backdrop-filter: blur(6px);
      border-top: 1px solid #1e1e1e; padding: 7px 12px;
      flex-direction: row; align-items: center; justify-content: center;
      gap: 14px; z-index: 10; flex-shrink: 0;
    }
    #pdf-nav.visible { display: flex; }
    .pdf-nav-btn {
      background: none; border: 1px solid #2a2a2a; color: #888;
      border-radius: 5px; width: 26px; height: 26px; font-size: 1rem; cursor: pointer;
      display: flex; align-items: center; justify-content: center;
      transition: color 0.2s, border-color 0.2s;
    }
    .pdf-nav-btn:hover:not(:disabled) { color: #f0f0f0; border-color: #555; }
    .pdf-nav-btn:disabled { opacity: 0.3; cursor: default; }
    #page-indicator { font-size: 0.76rem; color: #555; min-width: 48px; text-align: center; }

    /* File type card (DOCX / no-preview PDF) */
    #file-card {
      display: none; flex-direction: column; align-items: center;
      gap: 10px; padding: 24px;
    }
    #file-card .fc-icon { font-size: 3rem; }
    #file-card .fc-name { font-size: 0.8rem; color: #888; word-break: break-all; text-align: center; }
    #file-card .fc-note { font-size: 0.7rem; color: #444; }

    /* Below drop zone */
    #change-btn {
      display: none; margin-top: 10px; font-size: 0.76rem; color: #555;
      background: none; border: 1px solid #2a2a2a; border-radius: 6px;
      padding: 4px 12px; cursor: pointer; transition: color 0.2s, border-color 0.2s; flex-shrink: 0;
    }
    #change-btn:hover { color: #f0f0f0; border-color: #444; }
    #compress-notice { display: none; font-size: 0.72rem; color: #f59e0b; margin-top: 6px; text-align: center; }

    /* ── In-panel sample documents ── */
    #panel-samples {
      width: 100%; margin-top: 14px; padding-top: 14px;
      border-top: 1px solid #1a1a1a; flex-shrink: 0;
    }
    .ps-header {
      display: flex; align-items: center; gap: 8px; margin-bottom: 10px;
    }
    .ps-label { font-size: 0.67rem; text-transform: uppercase; letter-spacing: 0.12em; color: #333; flex: 1; }
    #ps-upload-btn {
      display: none; font-size: 0.72rem; color: #444; background: none;
      border: 1px dashed #252525; border-radius: 5px; padding: 3px 9px; cursor: pointer;
      transition: color 0.2s, border-color 0.2s; font-family: inherit;
    }
    #ps-upload-btn:hover { color: #f59e0b; border-color: rgba(245,158,11,0.4); }
    #ps-file-input { display: none; }

    /* Inline upload form (admin) */
    #ps-upload-form {
      display: none; align-items: center; gap: 6px; margin-bottom: 10px;
      padding: 8px 10px; background: #0d0d0d; border-radius: 7px; border: 1px solid #1e1e1e;
    }
    #ps-upload-form.open { display: flex; flex-wrap: wrap; }
    .ps-chosen-name { font-size: 0.75rem; color: #888; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    #ps-template-select {
      background: #0d0d0d; border: 1px solid #2a2a2a; border-radius: 5px;
      color: #e0e0e0; font-size: 0.75rem; padding: 4px 22px 4px 8px; cursor: pointer;
      outline: none; appearance: none; font-family: inherit;
      background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='7' viewBox='0 0 10 7'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%23555' stroke-width='1.5' fill='none'/%3E%3C/svg%3E");
      background-repeat: no-repeat; background-position: right 7px center;
    }
    .ps-form-btn {
      background: none; border: 1px solid #2a2a2a; border-radius: 5px;
      color: #888; font-size: 0.73rem; padding: 4px 10px; cursor: pointer;
      font-family: inherit; transition: color 0.2s, border-color 0.2s;
    }
    .ps-form-btn.primary { border-color: rgba(245,158,11,0.4); color: #f59e0b; }
    .ps-form-btn:hover { color: #fff; border-color: #555; }

    /* Sample cards */
    .samples-row { display: flex; gap: 8px; flex-wrap: wrap; }
    .sample-card {
      position: relative; width: 86px; background: #0d0d0d;
      border: 1px solid #1e1e1e; border-radius: 7px; overflow: hidden;
      cursor: pointer; transition: border-color 0.2s, transform 0.15s; flex-shrink: 0;
    }
    .sample-card:hover { border-color: #f59e0b; transform: translateY(-2px); }
    .sample-card.active { border-color: #f59e0b; }
    .sample-thumb { width: 100%; aspect-ratio: 4/3; object-fit: cover; display: block; background: #111; }
    .sample-thumb-placeholder {
      width: 100%; aspect-ratio: 4/3; display: flex;
      align-items: center; justify-content: center; font-size: 1.5rem; background: #111;
    }
    .sample-name { font-size: 0.67rem; color: #666; padding: 4px 6px 5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .sample-del-btn {
      display: none; position: absolute; top: 3px; right: 3px;
      background: rgba(0,0,0,0.75); border: none; color: #ef4444; font-size: 0.65rem;
      width: 16px; height: 16px; border-radius: 3px; cursor: pointer;
      align-items: center; justify-content: center; line-height: 1;
    }
    .sample-card:hover .sample-del-btn { display: flex; }
    #ps-empty { font-size: 0.75rem; color: #2a2a2a; display: none; }

    /* ── Right panel: prompts ── */
    .template-row {
      display: flex; align-items: center; gap: 10px; margin-bottom: 16px;
    }
    .template-label { font-size: 0.76rem; color: #555; white-space: nowrap; }
    #template-select {
      flex: 1; background: #0d0d0d; border: 1px solid #2a2a2a; border-radius: 6px;
      color: #e0e0e0; font-size: 0.82rem; padding: 7px 28px 7px 10px; cursor: pointer;
      outline: none; appearance: none; font-family: inherit;
      background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23555' stroke-width='1.5' fill='none'/%3E%3C/svg%3E");
      background-repeat: no-repeat; background-position: right 10px center;
    }
    #template-select:focus { border-color: #444; }

    .model-row {
      display: flex; align-items: center; gap: 10px; margin-bottom: 12px;
    }
    #vision-model-select {
      flex: 1; background: #0d0d0d; border: 1px solid #2a2a2a; border-radius: 6px;
      color: #e0e0e0; font-size: 0.82rem; padding: 7px 28px 7px 10px; cursor: pointer;
      outline: none; appearance: none; font-family: inherit;
      background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23555' stroke-width='1.5' fill='none'/%3E%3C/svg%3E");
      background-repeat: no-repeat; background-position: right 10px center;
    }
    #vision-model-select:focus { border-color: #444; }
    #vision-model-select:disabled { color: #555; cursor: not-allowed; }
    #vision-model-select option:disabled { color: #555; background: #111; }
    .model-badge {
      font-size: 0.65rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.09em;
      border-radius: 4px; padding: 2px 7px; flex-shrink: 0; border: 1px solid;
    }
    .model-tier-subscription { background: rgba(245,158,11,0.1); color: #f59e0b; border-color: rgba(245,158,11,0.3); }
    .model-tier-paid         { background: rgba(96,165,250,0.1); color: #60a5fa; border-color: rgba(96,165,250,0.3); }
    .model-tier-free         { background: rgba(74,222,128,0.1); color: #4ade80; border-color: rgba(74,222,128,0.3); }
    .model-tier-no_credit    { background: rgba(239,68,68,0.1);  color: #f87171; border-color: rgba(239,68,68,0.3); }
    .model-provider-sdk        { background: rgba(245,158,11,0.1); color: #f59e0b; border-color: rgba(245,158,11,0.3); }
    .model-provider-openrouter { background: rgba(167,139,250,0.1); color: #a78bfa; border-color: rgba(167,139,250,0.3); }
    .model-provider-bedrock    { background: rgba(251,146,60,0.1);  color: #fb923c; border-color: rgba(251,146,60,0.3); }

    #prompts-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 14px; }
    .prompt-group { display: grid; grid-template-columns: 140px 1fr 30px; gap: 8px; }
    .prompt-row { grid-column: 1 / -1; }
    .prompt-result {
      display: none; align-items: center; gap: 10px;
      grid-column: 2 / 3;
      padding: 7px 10px 7px 12px; margin-top: -2px;
      border-left: 2px solid rgba(245,158,11,0.4);
      background: rgba(245,158,11,0.03); border-radius: 0 6px 6px 0; font-size: 0.84rem;
    }
    .prompt-result.visible { display: flex; }
    .pr-arrow { color: #f59e0b; font-size: 0.7rem; flex-shrink: 0; opacity: 0.8; }
    .pr-value { flex: 1; color: #e0e0e0; min-width: 0; word-break: break-word; }
    .pr-value.null-value { color: #444; font-style: italic; }

    .prompt-row {
      display: grid; grid-template-columns: 140px 1fr 30px; gap: 8px; align-items: start;
    }
    .prompt-row input, .prompt-row textarea {
      background: #0d0d0d; border: 1px solid #2a2a2a; border-radius: 6px;
      color: #e0e0e0; font-size: 0.84rem; padding: 8px 10px; outline: none;
      font-family: inherit; transition: border-color 0.2s; width: 100%;
    }
    .prompt-row input:focus, .prompt-row textarea:focus { border-color: #444; }
    .prompt-row input::placeholder, .prompt-row textarea::placeholder { color: #333; }
    .prompt-row textarea { resize: none; min-height: 64px; height: 64px; line-height: 1.55; overflow: hidden; }
    .prompt-del {
      background: none; border: none; color: #333; cursor: pointer;
      font-size: 1rem; padding: 6px 4px; line-height: 1; transition: color 0.2s;
    }
    .prompt-del:hover { color: #ef4444; }

    .prompt-headers {
      display: grid; grid-template-columns: 140px 1fr 30px; gap: 8px; margin-bottom: 6px;
    }
    .prompt-headers span { font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.12em; color: #333; }

    .add-field-row { display: flex; gap: 8px; }
    #add-field-btn, #add-suspicious-btn {
      background: none; border: 1px dashed #2a2a2a; border-radius: 6px;
      color: #444; font-size: 0.78rem; padding: 7px 14px; cursor: pointer;
      transition: color 0.2s, border-color 0.2s;
    }
    #add-field-btn:hover, #add-suspicious-btn:hover { color: #888; border-color: #444; }
    #add-field-btn { flex: 1; }
    #add-suspicious-btn { flex: 0 0 25%; }

    /* ── Run bar ── */
    .run-bar {
      display: flex; align-items: center; gap: 14px;
      margin-top: 18px; padding-top: 18px; border-top: 1px solid #1a1a1a;
    }
    #run-btn {
      display: flex; align-items: center; gap: 8px;
      background: #f59e0b; color: #000; border: none; border-radius: 8px;
      font-size: 0.88rem; font-weight: 700; padding: 10px 22px; cursor: pointer;
      transition: opacity 0.2s, transform 0.15s; white-space: nowrap;
    }
    #run-btn:hover:not(:disabled) { opacity: 0.88; transform: translateY(-1px); }
    #run-btn:disabled { opacity: 0.35; cursor: not-allowed; transform: none; }
    .run-spinner {
      width: 14px; height: 14px; border: 2px solid rgba(0,0,0,0.3);
      border-top-color: #000; border-radius: 50%;
      animation: spin 0.7s linear infinite; display: none;
    }
    #run-btn.loading .run-spinner { display: block; }
    #run-btn.loading .run-label { opacity: 0.7; }
    @keyframes spin { to { transform: rotate(360deg); } }
    #usage-counter { font-size: 0.76rem; color: #444; }
    #usage-counter.warn { color: #f59e0b; }
    #results-subtitle { font-size: 0.76rem; color: #555; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

    /* ── Save template button ── */
    #save-template-btn {
      background: none; border: 1px solid #2a2a2a; border-radius: 7px;
      color: #555; font-size: 0.78rem; padding: 7px 12px; cursor: pointer;
      font-family: inherit; transition: color 0.2s, border-color 0.2s; white-space: nowrap;
      flex-shrink: 0;
    }
    #save-template-btn:hover { color: #f0f0f0; border-color: #555; }

    /* ── Loaded-template badge ── */
    #loaded-template-badge {
      display: none; align-items: center; gap: 8px;
      font-size: 0.75rem; color: #a3e635; padding: 8px 12px;
      background: rgba(163,230,53,0.06); border: 1px solid rgba(163,230,53,0.18);
      border-radius: 7px; margin-bottom: 14px;
    }
    #loaded-template-badge.visible { display: flex; }
    .ltb-icon { font-size: 0.9rem; flex-shrink: 0; }
    .ltb-name { font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .ltb-rename-input {
      flex: 1; background: transparent; border: none; border-bottom: 1px solid rgba(163,230,53,0.4);
      color: #a3e635; font-size: 0.75rem; font-weight: 600; font-family: inherit;
      outline: none; min-width: 0; padding: 0 2px;
    }
    .ltb-edit-btn, .ltb-confirm-btn, .ltb-dismiss {
      background: none; border: none; color: #555; cursor: pointer; font-size: 0.9rem;
      padding: 0 3px; line-height: 1; flex-shrink: 0; transition: color 0.15s;
    }
    .ltb-edit-btn:hover { color: #a3e635; }
    .ltb-confirm-btn:hover { color: #4ade80; }
    .ltb-dismiss:hover { color: #888; }

    /* ── Auto-detect fields button ── */
    #auto-detect-btn {
      display: flex; align-items: center; justify-content: center; gap: 8px;
      background: rgba(245,158,11,0.07); border: 1px solid rgba(245,158,11,0.22);
      border-radius: 7px; color: #f59e0b; font-size: 0.8rem; font-weight: 600;
      padding: 10px 16px; cursor: pointer; width: 100%; margin-bottom: 16px;
      font-family: inherit; transition: background 0.2s, border-color 0.2s, opacity 0.2s;
    }
    #auto-detect-btn:hover:not(:disabled) { background: rgba(245,158,11,0.14); border-color: rgba(245,158,11,0.45); }
    #auto-detect-btn:disabled { opacity: 0.28; cursor: not-allowed; }
    .ad-spinner {
      width: 12px; height: 12px; border: 2px solid rgba(245,158,11,0.3);
      border-top-color: #f59e0b; border-radius: 50%;
      animation: spin 0.7s linear infinite; display: none; flex-shrink: 0;
    }
    #auto-detect-btn.loading .ad-spinner { display: block; }
    #auto-detect-btn.loading .ad-label { opacity: 0.7; }

    /* ── Share-template modal ── */
    #share-modal {
      display: none; position: fixed; inset: 0; z-index: 200;
      background: rgba(0,0,0,0.82); align-items: center; justify-content: center;
      padding: 20px;
    }
    #share-modal.open { display: flex; }
    .share-dialog {
      background: #111; border: 1px solid #1e1e1e; border-radius: 14px;
      padding: 28px 28px 24px; max-width: 480px; width: 100%;
      box-shadow: 0 24px 64px rgba(0,0,0,0.7);
    }
    .share-title { font-size: 1rem; font-weight: 700; color: #f0f0f0; margin-bottom: 10px; }
    .share-name-input {
      width: 100%; background: #0d0d0d; border: 1px solid #2a2a2a; border-radius: 7px;
      color: #f0f0f0; font-size: 0.92rem; font-weight: 600; font-family: inherit;
      padding: 8px 12px; outline: none; box-sizing: border-box; margin-bottom: 14px;
      transition: border-color 0.15s;
    }
    .share-name-input:focus { border-color: #555; }
    .share-name-input.saved { border-color: #4ade80; }
    .share-sub { font-size: 0.8rem; color: #555; margin-bottom: 20px; }
    .share-url-row { display: flex; gap: 8px; margin-bottom: 8px; }
    .share-url-input {
      flex: 1; background: #0d0d0d; border: 1px solid #2a2a2a; border-radius: 7px;
      color: #a3e635; font-family: 'SFMono-Regular', Consolas, monospace; font-size: 0.78rem;
      padding: 9px 12px; outline: none; min-width: 0;
    }
    .share-copy-btn {
      background: none; border: 1px solid #2a2a2a; border-radius: 7px; color: #888;
      font-size: 0.78rem; padding: 9px 14px; cursor: pointer; font-family: inherit;
      white-space: nowrap; transition: color 0.2s, border-color 0.2s; flex-shrink: 0;
    }
    .share-copy-btn:hover { color: #f0f0f0; border-color: #555; }
    .share-copied { font-size: 0.75rem; color: #4ade80; height: 18px; margin-bottom: 12px; }
    .share-footer { display: flex; align-items: center; gap: 12px; }
    .share-expiry { font-size: 0.75rem; color: #383838; flex: 1; }
    .share-close-btn {
      background: none; border: 1px solid #2a2a2a; border-radius: 7px; color: #666;
      font-size: 0.82rem; padding: 8px 20px; cursor: pointer; font-family: inherit;
      transition: color 0.2s, border-color 0.2s;
    }
    .share-close-btn:hover { color: #f0f0f0; border-color: #555; }

    /* ── Confidence badges ── */
    .confidence-badge { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
    .confidence-bar { width: 46px; height: 4px; background: #1a1a1a; border-radius: 2px; overflow: hidden; }
    .confidence-fill { height: 100%; border-radius: 2px; transition: width 0.5s ease; }
    .confidence-fill.high { background: #22c55e; }
    .confidence-fill.mid  { background: #f59e0b; }
    .confidence-fill.low  { background: #ef4444; }
    .confidence-pct { font-size: 0.7rem; font-weight: 600; min-width: 28px; text-align: right; }
    .confidence-pct.high { color: #22c55e; }
    .confidence-pct.mid  { color: #f59e0b; }
    .confidence-pct.low  { color: #ef4444; }

    /* ── Export / output section ── */
    /* ── Results section (full-width, below grid) ── */
    #results-section { display: none; margin-top: 28px; }
    .results-header {
      display: flex; align-items: center; gap: 14px;
      margin-bottom: 16px; flex-wrap: wrap;
    }
    .results-title {
      font-size: 0.82rem; font-weight: 700; text-transform: uppercase;
      letter-spacing: 0.12em; color: #e0e0e0;
    }
    .results-actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
    .results-grid {
      display: grid; grid-template-columns: 1fr 1fr; gap: 16px;
    }
    @media (max-width: 680px) { .results-grid { grid-template-columns: 1fr; } }
    .result-pane {
      background: #0d0d0d; border: 1px solid #1e1e1e; border-radius: 10px; overflow: hidden;
      display: flex; flex-direction: column;
    }
    .result-pane-header {
      display: flex; align-items: center; gap: 8px;
      padding: 10px 14px; border-bottom: 1px solid #1a1a1a;
    }
    .result-pane-label {
      font-size: 0.72rem; font-weight: 700; text-transform: uppercase;
      letter-spacing: 0.12em; color: #444;
    }
    .result-pane-notice { font-size: 0.72rem; color: #4ade80; display: none; margin-left: auto; }
    #json-code {
      font-family: 'SFMono-Regular', 'Consolas', monospace;
      font-size: 0.78rem; color: #a3e635; padding: 14px 16px;
      white-space: pre; overflow-x: auto; max-height: 360px; overflow-y: auto;
      line-height: 1.6; margin: 0; flex: 1;
    }
    #csv-code {
      font-family: 'SFMono-Regular', 'Consolas', monospace;
      font-size: 0.78rem; color: #7dd3fc; padding: 14px 16px;
      white-space: pre; overflow-x: auto; max-height: 360px; overflow-y: auto;
      line-height: 1.6; margin: 0; flex: 1;
    }
    .result-pane-actions {
      display: flex; align-items: center; gap: 8px;
      padding: 8px 12px; border-top: 1px solid #1a1a1a;
    }
    .export-dl-btn {
      display: flex; align-items: center; gap: 6px;
      background: none; border: 1px solid #2a2a2a; border-radius: 6px;
      color: #888; font-size: 0.76rem; padding: 5px 12px; cursor: pointer;
      font-family: inherit; transition: color 0.2s, border-color 0.2s;
    }
    .export-dl-btn:hover { color: #f0f0f0; border-color: #555; }
    .export-copy-notice { font-size: 0.72rem; color: #4ade80; display: none; }

    /* ── API section ── */
    #api-section {
      display: none; margin-top: 20px;
      background: #0d0d0d; border: 1px solid #1e1e1e; border-radius: 12px; overflow: hidden;
    }
    .api-section-header {
      display: flex; align-items: center; gap: 12px;
      padding: 14px 20px; border-bottom: 1px solid #1a1a1a;
    }
    .api-section-pill {
      font-size: 0.62rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.14em;
      background: rgba(167,139,250,0.12); color: #a78bfa;
      border: 1px solid rgba(167,139,250,0.25); border-radius: 4px;
      padding: 3px 8px; flex-shrink: 0;
    }
    .api-section-title {
      font-size: 0.88rem; font-weight: 700; color: #e0e0e0;
    }
    .api-section-sub {
      font-size: 0.78rem; color: #444; margin-left: auto;
    }
    .api-dismiss-btn {
      background: none; border: none; color: #333; font-size: 1rem; cursor: pointer;
      padding: 2px 6px; transition: color 0.2s; flex-shrink: 0;
    }
    .api-dismiss-btn:hover { color: #888; }
    .api-section-body { padding: 20px; display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
    @media (max-width: 760px) { .api-section-body { grid-template-columns: 1fr; } }
    .api-block { display: flex; flex-direction: column; gap: 8px; }
    .api-block-label {
      font-size: 0.66rem; text-transform: uppercase; letter-spacing: 0.14em; color: #444; font-weight: 700;
    }
    .api-code-wrap {
      position: relative; background: #080808; border: 1px solid #1a1a1a; border-radius: 8px; overflow: hidden;
    }
    .api-code {
      font-family: 'SFMono-Regular', Consolas, monospace; font-size: 0.76rem;
      color: #c4b5fd; padding: 12px 14px; white-space: pre; overflow-x: auto;
      line-height: 1.65; margin: 0; display: block;
    }
    .api-code.green { color: #a3e635; }
    .api-code.blue  { color: #7dd3fc; }
    .api-copy-btn {
      position: absolute; top: 8px; right: 8px;
      background: #111; border: 1px solid #222; border-radius: 5px;
      color: #555; font-size: 0.7rem; padding: 3px 9px; cursor: pointer;
      font-family: inherit; transition: color 0.2s, border-color 0.2s;
    }
    .api-copy-btn:hover { color: #e0e0e0; border-color: #444; }
    .api-copy-notice { font-size: 0.7rem; color: #4ade80; height: 16px; }
    .api-endpoint-row {
      display: flex; align-items: center; gap: 10px;
      background: #080808; border: 1px solid #1a1a1a; border-radius: 8px; padding: 10px 14px;
    }
    .api-method-badge {
      font-size: 0.68rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.08em;
      background: rgba(251,191,36,0.12); color: #fbbf24;
      border: 1px solid rgba(251,191,36,0.25); border-radius: 4px;
      padding: 2px 7px; flex-shrink: 0;
    }
    .api-endpoint-url {
      font-family: 'SFMono-Regular', Consolas, monospace; font-size: 0.76rem;
      color: #c4b5fd; word-break: break-all; flex: 1;
    }
    .api-copy-url-btn {
      background: none; border: 1px solid #1e1e1e; border-radius: 5px;
      color: #444; font-size: 0.7rem; padding: 3px 9px; cursor: pointer;
      font-family: inherit; transition: color 0.2s, border-color 0.2s; flex-shrink: 0;
    }
    .api-copy-url-btn:hover { color: #e0e0e0; border-color: #444; }
    .api-mode-tabs { display: flex; gap: 4px; margin-left: auto; }
    .api-mode-tab {
      background: none; border: 1px solid #222; border-radius: 6px;
      color: #444; font-size: 0.72rem; padding: 4px 11px; cursor: pointer;
      font-family: inherit; transition: color 0.2s, border-color 0.2s, background 0.2s;
    }
    .api-mode-tab:hover { color: #888; border-color: #333; }
    .api-mode-tab.active { color: #a78bfa; border-color: rgba(167,139,250,0.4); background: rgba(167,139,250,0.07); }

    .api-section-foot {
      padding: 12px 20px; border-top: 1px solid #141414;
      font-size: 0.74rem; color: #333; display: flex; gap: 20px; flex-wrap: wrap;
    }
    .api-foot-item { display: flex; align-items: center; gap: 6px; }
    .api-foot-dot { width: 5px; height: 5px; border-radius: 50%; background: #2a2a2a; flex-shrink: 0; }

    /* ── Banners ── */
    #error-banner {
      display: none; background: rgba(239,68,68,0.08); border: 1px solid rgba(239,68,68,0.25);
      border-radius: 8px; padding: 12px 16px; font-size: 0.82rem; color: #fca5a5; margin-top: 14px;
    }
    #info-banner {
      display: none; background: rgba(245,158,11,0.06); border: 1px solid rgba(245,158,11,0.2);
      border-radius: 8px; padding: 10px 16px; font-size: 0.8rem; color: #fcd34d; margin-top: 12px;
    }

    /* ── ZIP modal ── */
    #zip-modal {
      display: none; position: fixed; inset: 0; z-index: 200;
      background: rgba(0,0,0,0.82); align-items: center; justify-content: center;
      padding: 20px;
    }
    #zip-modal.open { display: flex; }
    .zip-dialog {
      background: #111; border: 1px solid #1e1e1e; border-radius: 14px;
      width: min(460px, 100%); max-height: min(560px, 90vh);
      display: flex; flex-direction: column; overflow: hidden;
      box-shadow: 0 24px 64px rgba(0,0,0,0.6);
    }
    .zip-dialog-header {
      display: flex; align-items: center; gap: 14px;
      padding: 20px 20px 16px; border-bottom: 1px solid #1a1a1a; flex-shrink: 0;
    }
    .zip-dialog-icon { font-size: 1.8rem; }
    .zip-dialog-title { font-size: 1rem; font-weight: 700; color: #e0e0e0; }
    .zip-dialog-sub { font-size: 0.76rem; color: #555; margin-top: 2px; }
    .zip-dialog-body { flex: 1; overflow: hidden; display: flex; flex-direction: column; padding: 16px 20px; gap: 10px; }
    .zip-section-label { font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.12em; color: #444; flex-shrink: 0; }
    #zip-file-list {
      flex: 1; overflow-y: auto; border: 1px solid #1a1a1a; border-radius: 8px;
      min-height: 80px;
    }
    .zip-file-item {
      display: flex; align-items: center; gap: 10px;
      padding: 9px 12px; cursor: pointer; transition: background 0.15s;
      border-bottom: 1px solid #161616;
    }
    .zip-file-item:last-child { border-bottom: none; }
    .zip-file-item:hover { background: rgba(245,158,11,0.06); }
    .zip-file-item:hover .zip-item-name { color: #f59e0b; }
    .zip-file-icon { font-size: 1rem; flex-shrink: 0; }
    .zip-item-name { font-size: 0.82rem; color: #bbb; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .zip-item-size { font-size: 0.7rem; color: #444; flex-shrink: 0; }
    .zip-or { text-align: center; font-size: 0.72rem; color: #333; flex-shrink: 0; }
    .zip-combined-btn {
      display: flex; align-items: center; justify-content: center; gap: 8px;
      background: rgba(245,158,11,0.08); border: 1px solid rgba(245,158,11,0.25);
      border-radius: 8px; color: #f59e0b; font-size: 0.84rem; font-weight: 600;
      padding: 11px 16px; cursor: pointer; transition: background 0.2s, border-color 0.2s;
      font-family: inherit; width: 100%; flex-shrink: 0;
    }
    .zip-combined-btn:hover { background: rgba(245,158,11,0.14); border-color: rgba(245,158,11,0.5); }
    .zip-dialog-footer {
      padding: 12px 20px; border-top: 1px solid #1a1a1a; display: flex;
      justify-content: flex-end; flex-shrink: 0;
    }
    .zip-cancel-btn {
      background: none; border: 1px solid #2a2a2a; border-radius: 6px;
      color: #555; font-size: 0.78rem; padding: 6px 16px; cursor: pointer;
      font-family: inherit; transition: color 0.2s, border-color 0.2s;
    }
    .zip-cancel-btn:hover { color: #f0f0f0; border-color: #555; }

    /* ── Preview sections ── */
    .preview-wrap {
      margin-top: 28px; position: relative; overflow: hidden;
    }
    .preview-section-header {
      display: flex; align-items: center; gap: 10px;
      margin-bottom: 14px; flex-wrap: wrap;
    }
    .preview-badge {
      font-size: 0.6rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.14em;
      background: rgba(100,100,100,0.12); color: #555;
      border: 1px solid #252525; border-radius: 4px;
      padding: 3px 8px; flex-shrink: 0;
    }
    .preview-section-title {
      font-size: 0.82rem; font-weight: 700; text-transform: uppercase;
      letter-spacing: 0.12em; color: #2e2e2e;
    }
    .preview-section-sub { font-size: 0.76rem; color: #2a2a2a; }
    .preview-fade {
      position: absolute; bottom: 0; left: 0; right: 0; height: 80px;
      background: linear-gradient(to bottom, transparent, #0f0f0f);
      pointer-events: none; z-index: 2;
    }
    /* Dim the code content inside previews */
    .preview-wrap .api-code   { opacity: 0.45; }
    .preview-wrap .result-pane { opacity: 0.45; }
    .preview-wrap .api-endpoint-row { opacity: 0.45; }
    .preview-wrap .api-section-body { opacity: 0.45; }
    .preview-wrap .api-section-foot { opacity: 0.3; }
    /* Preview API section reuses #api-section styles but as a class */
    .preview-api-wrap {
      background: #0d0d0d; border: 1px solid #1a1a1a; border-radius: 12px; overflow: hidden;
    }

    /* ── Responsive ── */
    @media (max-width: 960px) {
      .idp-grid { flex-direction: column; }
      .idp-left { width: 100% !important; max-width: 100%; }
      .idp-resizer { display: none; }
      .idp-right { width: 100%; }
      #drop-zone.has-file { flex: none; min-height: 260px; }
      main { padding: 24px 20px 60px; }
    }
    @media (max-width: 680px) {
      .prompt-group { grid-template-columns: 100px 1fr 26px; }
      .prompt-headers { grid-template-columns: 100px 1fr 26px; }
      nav { padding: 14px 18px; }
    }

    /* ── Search overlay ── */
    #search-overlay {
      display: none; position: fixed; inset: 0; z-index: 1000;
      background: rgba(0,0,0,0.7); backdrop-filter: blur(4px);
      align-items: flex-start; justify-content: center; padding-top: 80px;
    }
    #search-overlay.open { display: flex; }
    #search-box {
      background: #111; border: 1px solid #2a2a2a; border-radius: 10px;
      width: 100%; max-width: 580px; overflow: hidden;
      box-shadow: 0 20px 60px rgba(0,0,0,0.6);
    }
    #search-input {
      width: 100%; padding: 16px 20px; background: none; border: none; outline: none;
      color: #e0e0e0; font-size: 1rem; font-family: inherit; box-sizing: border-box;
    }
    #search-input::placeholder { color: #444; }
    #search-divider { height: 1px; background: #1e1e1e; }
    #search-results { max-height: 400px; overflow-y: auto; }
    .search-result {
      display: block; padding: 12px 20px; text-decoration: none; color: inherit;
      border-bottom: 1px solid #151515; transition: background 0.15s;
    }
    .search-result:hover, .search-result.active { background: #161616; }
    .search-result-title { color: #e0e0e0; font-size: 0.9rem; margin-bottom: 3px; }
    .search-result-snippet { color: #555; font-size: 0.78rem; line-height: 1.4; }
    .search-result-snippet mark { background: none; color: #4ade80; font-style: normal; }
    #search-empty { padding: 20px; text-align: center; color: #333; font-size: 0.85rem; }
    #search-hint {
      padding: 8px 20px; color: #2a2a2a; font-size: 0.72rem;
      border-top: 1px solid #151515; display: flex; gap: 16px;
    }
  
    /* ── Floating chat ── */
    #chat-bubble {
      position: fixed; bottom: 24px; right: 24px; z-index: 900;
      width: 48px; height: 48px; border-radius: 50%;
      background: #1a1a1a; border: 1px solid #2a2a2a;
      display: flex; align-items: center; justify-content: center;
      cursor: pointer; color: #555; transition: color 0.2s, border-color 0.2s, transform 0.2s;
      box-shadow: 0 4px 20px rgba(0,0,0,0.4);
    }
    #chat-bubble:hover { color: #4ade80; border-color: rgba(74,222,128,0.3); transform: scale(1.05); }
    #chat-panel {
      position: fixed; bottom: 84px; right: 24px; z-index: 901;
      width: 340px; max-height: 480px;
      background: #111; border: 1px solid #1e1e1e; border-radius: 12px;
      display: none; flex-direction: column;
      box-shadow: 0 8px 40px rgba(0,0,0,0.6);
      overflow: hidden;
    }
    #chat-panel.open { display: flex; }
    #chat-panel-header {
      display: flex; align-items: center; justify-content: space-between;
      padding: 12px 16px; border-bottom: 1px solid #1a1a1a;
      font-size: 0.82rem; color: #888;
    }
    #chat-messages {
      flex: 1; overflow-y: auto; padding: 12px 16px;
      display: flex; flex-direction: column; gap: 10px;
      min-height: 200px; max-height: 320px;
      font-size: 0.82rem; line-height: 1.5;
    }
    .chat-msg-user {
      align-self: flex-end; background: #1a1a1a; border-radius: 10px 10px 2px 10px;
      padding: 8px 12px; color: #d0d0d0; max-width: 85%;
    }
    .chat-msg-ai {
      align-self: flex-start; color: #aaa; max-width: 90%;
    }
    .chat-msg-ai.streaming::after {
      content: '\25ae'; animation: blink 0.8s step-end infinite;
    }
    @keyframes blink { 50% { opacity: 0; } }
    #chat-input-row {
      display: flex; padding: 10px 12px; gap: 8px; border-top: 1px solid #1a1a1a;
    }
    #chat-input {
      flex: 1; background: #1a1a1a; border: 1px solid #2a2a2a; border-radius: 6px;
      color: #e0e0e0; font-size: 0.82rem; padding: 8px 10px; outline: none; font-family: inherit;
    }
    #chat-input:focus { border-color: #333; }
    #chat-send {
      background: #1a1a1a; border: 1px solid #2a2a2a; border-radius: 6px;
      color: #555; padding: 8px 12px; cursor: pointer; font-size: 1rem;
      transition: color 0.2s;
    }
    #chat-send:hover { color: #4ade80; border-color: rgba(74,222,128,0.2); }

/* Phase 4 – extracted inline styles */
._p4-022625 {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

._p4-132b99 {
  color: #e0e0e0;
}

._p4-2b3dc0 {
  background: rgba(34,197,94,0.12);
  color: #4ade80;
  border-color: rgba(34,197,94,0.25);
}

._p4-61f6c4 {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(245,158,11,0.08);
  border: 1px solid rgba(245,158,11,0.3);
  color: #f59e0b;
  text-decoration: none;
  padding: 8px 14px;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 500;
  transition: all 0.2s;
  white-space: nowrap;
  flex-shrink: 0;
}
._p4-61f6c4:hover {
  background: rgba(245,158,11,0.15);
  border-color: rgba(245,158,11,0.6);
}

._p4-72193b {
  max-height: 220px;
  overflow: hidden;
}

._p4-83725d {
  flex: 1;
}

._p4-89a84b {
  opacity: 0.3;
}

._p4-a8dd1d {
  cursor: default;
}

._p4-ab79ea {
  margin: 0;
}

._p4-b45541 {
  align-items: center;
  justify-content: space-between;
}

._p4-b4e7d3 {
  display: flex;
  align-items: center;
  gap: 10px;
}

._p4-c02ded {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 16px;
  flex-wrap: wrap;
}

._p4-c06aef {
  color: #9ca3af;
}

._p4-d4e8f2 {
  pointer-events: none;
}

._p4-db9cb9 {
  display: none;
  flex-direction: column;
  gap: 14px;
}

._p4-ed41c2 {
  font-size: 0.88rem;
  color: #888;
}

._p4-fca065 {
  display: flex;
  flex-direction: column;
  align-items: center;
}
