        * { box-sizing: border-box; }
        body {
            font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
            max-width: 1100px;
            margin: 0 auto;
            padding: 20px;
            background: #fafaf7;
            min-height: 100vh;
        }
        body::before {
            content: '';
            position: fixed;
            top: 0;
            left: 0;
            right: 0;
            height: 4px;
            background: linear-gradient(90deg, #4a6fa5, #5a8fd5, #0d8a8a);
            z-index: 1000;
        }
        .container {
            padding: 30px;
        }
        @media (max-width: 768px) {
            body { padding: 10px; }
            .container { padding: 12px 6px; }
            h1 { font-size: 22px; }
            .subtitle { font-size: 13px; }
            .params-grid { grid-template-columns: 1fr; gap: 10px; }
            .btn-row { flex-direction: column; }
            .btn-row button { width: 100%; }
            .target-display { flex-direction: column; align-items: flex-start; gap: 12px; }
            .target-display svg { max-width: 100%; width: 100%; height: auto; }
            .target-info .smiles { font-size: 12px; }
            .precursors-grid { grid-template-columns: 1fr; }
            .precursor-actions { flex-direction: column; }
            .precursor-actions .btn-lookup,
            .precursor-actions .btn-inpaint { width: 100%; }
            .info-banner { flex-direction: column; gap: 8px; padding: 12px 14px; font-size: 13px; }
            .info-banner-dismiss { align-self: flex-end; }
            .title-row { row-gap: 4px; }
            .inpaint-toolbar .toolbar-row { flex-wrap: wrap; }
            .mode-toggle { width: 100%; }
            .mode-btn { flex: 1; padding: 8px 6px; font-size: 11px; }
            .inpaint-focus-panel .mol-svg svg { max-width: 100%; height: auto; }
            /* Tooltip bodies: keep them on-screen on narrow viewports */
            .info-tip .info-tip-body { max-width: min(220px, 80vw); }
        }
        @media (max-width: 420px) {
            .examples code { display: inline-block; margin: 2px 2px; }
            .container { padding: 10px 4px; }
        }
        h1 { color: #1a1a2e; margin-bottom: 8px; }
        .subtitle { color: #666; margin-bottom: 25px; }
        .form-group { margin-bottom: 20px; }
        label { display: block; font-weight: 600; margin-bottom: 6px; color: #333; }
        .label-hint { font-weight: normal; color: #888; font-size: 13px; }
        input[type="text"] {
            width: 100%;
            padding: 12px;
            font-size: 15px;
            font-family: 'SF Mono', Monaco, 'Courier New', monospace;
            border: 2px solid #e0e0e0;
            border-radius: 6px;
        }
        input[type="text"]:focus { border-color: #0d8a8a; outline: none; }
        .params-grid {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
            gap: 15px;
            margin-bottom: 20px;
        }
        .param-box { background: #f8f9fa; padding: 15px; border-radius: 8px; }
        .param-box label { font-size: 13px; margin-bottom: 8px; }
        .param-hint { font-size: 11px; color: #888; margin-top: 4px; }
        input[type="number"], select {
            width: 100%;
            padding: 10px;
            font-size: 15px;
            border: 1px solid #ddd;
            border-radius: 4px;
            background: white;
        }
        /* Polished model picker: native <select> with a custom chevron + teal focus. */
        .model-select-wrap { position: relative; }
        .model-select {
            width: 100%;
            padding: 12px 42px 12px 14px;
            font-size: 15px;
            font-weight: 600;
            color: #1a1a2e;
            border: 2px solid #e0e0e0;
            border-radius: 8px;
            background: #fff;
            appearance: none;
            -webkit-appearance: none;
            -moz-appearance: none;
            cursor: pointer;
            transition: border-color 0.2s, box-shadow 0.2s;
        }
        .model-select:hover { border-color: #b9d4d4; }
        .model-select:focus {
            outline: none;
            border-color: #0d8a8a;
            box-shadow: 0 0 0 3px rgba(13, 138, 138, 0.15);
        }
        .model-select-wrap::after {
            content: '';
            position: absolute;
            right: 18px;
            top: 50%;
            width: 9px;
            height: 9px;
            margin-top: -7px;
            border-right: 2px solid #0d8a8a;
            border-bottom: 2px solid #0d8a8a;
            transform: rotate(45deg);
            pointer-events: none;
        }
        .model-desc {
            margin-top: 8px;
            font-size: 13px;
            color: #666;
            line-height: 1.45;
        }
        .btn-row { display: flex; gap: 10px; margin-top: 20px; }
        button {
            padding: 12px 28px;
            font-size: 15px;
            font-weight: 600;
            border: none;
            border-radius: 6px;
            cursor: pointer;
            transition: background 0.2s;
        }
        .btn-primary { background: #0d8a8a; color: white; }
        .btn-primary:hover { background: #0a6e6e; }
        .btn-primary:disabled { background: #7ab8b8; cursor: not-allowed; }
        .btn-secondary { background: #e9ecef; color: #495057; }
        .btn-secondary:hover { background: #dee2e6; }
        .examples { margin-top: 12px; font-size: 13px; color: #666; }
        .examples code {
            background: #e9ecef;
            padding: 3px 8px;
            border-radius: 4px;
            cursor: pointer;
            transition: background 0.2s;
        }
        .examples code:hover { background: #dee2e6; }
        .results-section {
            margin-top: 30px;
            padding-top: 25px;
            border-top: 2px solid #e9ecef;
        }
        .results-header { display: flex; align-items: center; gap: 15px; margin-bottom: 20px; flex-wrap: wrap; }
        .results-header h2 { margin: 0; color: #1a1a2e; }
        .results-export { display: flex; align-items: center; gap: 10px; margin-left: auto; flex-wrap: wrap; }
        .btn-download-csv { padding: 8px 14px; font-size: 13px; }
        .results-export-note { font-size: 11px; color: #888; max-width: 320px; line-height: 1.35; }
        .target-display {
            display: flex;
            align-items: center;
            gap: 20px;
            background: #f8f9fa;
            padding: 15px;
            border-radius: 8px;
            margin-bottom: 20px;
        }
        .target-display svg {
            border: 1px solid #ddd;
            border-radius: 6px;
            background: white;
            max-width: 150px;
            height: auto;
            flex-shrink: 0;
        }
        .target-info h3 { margin: 0 0 5px 0; color: #333; }
        .target-info .smiles {
            font-family: 'SF Mono', Monaco, monospace;
            font-size: 13px;
            color: #666;
            word-break: break-all;
        }
        .precursors-grid {
            display: grid;
            grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
            gap: 15px;
        }
        .precursor-card {
            background: white;
            border: 1px solid #e0e0e0;
            border-radius: 8px;
            padding: 15px;
            transition: box-shadow 0.2s;
        }
        .precursor-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,0.1); }
        .precursor-card .mol-svg { width: 100%; border-radius: 4px; background: #fafafa; overflow: hidden; }
        .mol-svg svg { display: block; width: 100%; height: auto; max-width: 100%; }
        .precursor-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 10px;
        }
        .precursor-rank { font-weight: 700; color: #0d8a8a; }
        .precursor-score {
            background: #e8f4e8;
            color: #2d6a2d;
            padding: 3px 10px;
            border-radius: 12px;
            font-size: 13px;
            font-weight: 600;
        }
        .precursor-smiles {
            font-family: 'SF Mono', Monaco, monospace;
            font-size: 11px;
            color: #888;
            word-break: break-all;
            overflow-wrap: anywhere;
            max-height: 60px;
            overflow-y: auto;
            margin-top: 10px;
            padding: 8px;
            background: #f8f9fa;
            border-radius: 4px;
        }
        .error {
            color: #c0392b;
            background: #fdf0ef;
            padding: 15px;
            border-radius: 8px;
            border-left: 4px solid #c0392b;
        }
        .inpaint-empty {
            color: #7a5b00;
            background: #fff8e1;
            padding: 15px;
            border-radius: 8px;
            border-left: 4px solid #e0a800;
            margin-top: 8px;
        }
        .inpaint-empty strong { color: #5a4300; }
        .inpaint-empty details { margin-top: 8px; }
        .inpaint-empty code {
            background: rgba(0,0,0,0.05);
            padding: 1px 4px;
            border-radius: 3px;
            font-size: 12px;
        }
        .reaction-class-badge {
            display: inline-block;
            padding: 3px 10px;
            border-radius: 12px;
            font-size: 12px;
            font-weight: 600;
        }
        .reaction-class-broad { background: #e8eaf6; color: #3949ab; }
        .reaction-class-name  { background: #f3e5f5; color: #6a1b9a; }
        .reaction-class-row {
            display: flex;
            align-items: center;
            gap: 6px;
            flex-wrap: wrap;
            margin-bottom: 8px;
        }
        .precursor-formula {
            margin-top: 6px;
            font-size: 12px;
            color: #333;
            font-family: 'SF Mono', Monaco, monospace;
        }
        .precursor-formula strong { font-weight: 700; }
        .precursor-actions {
            display: flex;
            gap: 8px;
            margin-top: 10px;
        }
        .btn-lookup, .btn-inpaint {
            flex: 1;
            padding: 8px;
            font-size: 13px;
            font-weight: 600;
            border: 1px solid #0d8a8a;
            border-radius: 6px;
            background: white;
            color: #0d8a8a;
            cursor: pointer;
            transition: background 0.2s, color 0.2s;
        }
        .btn-lookup:hover, .btn-inpaint:hover { background: #0d8a8a; color: white; }
        .btn-lookup:disabled, .btn-inpaint:disabled { opacity: 0.6; cursor: not-allowed; }
        .btn-inpaint { border-color: #e67e22; color: #e67e22; }
        .btn-inpaint:hover { background: #e67e22; color: white; }
        .compound-info {
            margin-top: 10px;
            padding: 10px;
            background: #f8f9fa;
            border-radius: 6px;
            font-size: 12px;
            line-height: 1.6;
        }
        .compound-info .compound-entry { margin-bottom: 8px; padding-bottom: 8px; border-bottom: 1px solid #e9ecef; }
        .compound-info .compound-entry:last-child { margin-bottom: 0; padding-bottom: 0; border-bottom: none; }
        .compound-info .compound-name { font-weight: 600; color: #333; }
        .compound-info .compound-detail { color: #666; }
        .pubchem-loading { font-size: 12px; color: #555; }
        .pubchem-loading-msg { margin-bottom: 6px; font-style: italic; }
        .pubchem-progress {
            background: #e9ecef;
            border-radius: 6px;
            overflow: hidden;
            height: 8px;
        }
        .pubchem-progress-bar {
            height: 100%;
            width: 0%;
            background: linear-gradient(90deg, #0a6e6e, #0d8a8a);
            transition: width 0.2s ease;
        }
        .fame-score {
            display: inline-block;
            background: #fff3e0;
            color: #e65100;
            padding: 2px 8px;
            border-radius: 10px;
            font-size: 11px;
            font-weight: 600;
        }
        .info-banner {
            display: flex;
            align-items: flex-start;
            gap: 12px;
            background: #edf2f7;
            border-left: 4px solid #0d8a8a;
            padding: 14px 18px;
            border-radius: 6px;
            margin-bottom: 25px;
            font-size: 14px;
            color: #333;
            line-height: 1.5;
        }
        .info-banner-content { flex: 1; }
        .info-banner-content a { color: #0d8a8a; text-decoration: underline; }
        .info-banner-dismiss {
            background: none;
            border: none;
            font-size: 20px;
            color: #888;
            cursor: pointer;
            padding: 0 4px;
            line-height: 1;
        }
        .info-banner-dismiss:hover { color: #333; }
        .title-row { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; margin-bottom: 8px; }
        .title-row h1 { margin: 0; }
        .beta-pill {
            font-size: 0.7rem;
            font-weight: 600;
            letter-spacing: 0.05em;
            text-transform: uppercase;
            padding: 0.15rem 0.5rem;
            border-radius: 999px;
            background: #fff8f0;
            color: #b8651a;
            border: 1px solid #e67e22;
        }

        /* ── Inpainting styles ── */
        .inpaint-mode .precursor-card { border-color: #e67e22; }
        .inpaint-toolbar {
            display: none;
            background: #fff8f0;
            border: 1px solid #e67e22;
            border-radius: 8px;
            padding: 12px;
            margin-top: 10px;
        }
        .inpaint-mode .inpaint-toolbar { display: block; }
        .inpaint-toolbar .toolbar-row {
            display: flex;
            align-items: center;
            gap: 10px;
            margin-bottom: 8px;
        }
        .inpaint-toolbar .toolbar-row:last-child { margin-bottom: 0; }
        .inpaint-counter {
            font-size: 13px;
            color: #666;
            flex: 1;
        }
        .btn-keep-mol {
            padding: 6px 14px;
            font-size: 12px;
            font-weight: 600;
            border: 1px solid #2d6a2d;
            border-radius: 4px;
            background: white;
            color: #2d6a2d;
            cursor: pointer;
        }
        .btn-keep-mol:hover, .btn-keep-mol.active { background: #2d6a2d; color: white; }
        .btn-regenerate {
            padding: 8px 20px;
            font-size: 14px;
            font-weight: 600;
            border: none;
            border-radius: 6px;
            background: #e67e22;
            color: white;
            cursor: pointer;
        }
        .btn-regenerate:hover { background: #d35400; }
        .btn-regenerate:disabled { background: #f0c8a0; cursor: not-allowed; }
        .btn-cancel-inpaint {
            padding: 8px 16px;
            font-size: 13px;
            border: 1px solid #ccc;
            border-radius: 6px;
            background: white;
            color: #666;
            cursor: pointer;
        }
        .btn-cancel-inpaint:hover { background: #f5f5f5; }

        /* Inpaint focus panel — expanded card in inpaint mode */
        .inpaint-focus-panel {
            grid-column: 1 / -1;
            max-width: 100%;
        }
        .inpaint-focus-panel .mol-svg {
            display: flex;
            flex-wrap: wrap;
            gap: 12px;
            justify-content: center;
        }
        .inpaint-focus-panel .rdkit-mol {
            display: inline-block;
        }

        /* Hover feedback on atoms in inpaint mode */
        .inpaint-mode .rdkit-mol svg { cursor: pointer; }
        /* Hit-area circles: invisible but respond to hover/click */
        .atom-hit-area {
            cursor: pointer !important;
            pointer-events: all !important;
        }
        .inpaint-mode .atom-hit-area:hover {
            fill: rgba(100, 100, 200, 0.2) !important;
            stroke: rgba(100, 100, 200, 0.5) !important;
            stroke-width: 1 !important;
        }

        /* Mode toggle (regenerate/keep) */
        .mode-toggle {
            display: flex;
            border: 1px solid #ddd;
            border-radius: 6px;
            overflow: hidden;
        }
        .mode-btn {
            padding: 6px 14px;
            font-size: 12px;
            font-weight: 600;
            border: none;
            background: white;
            color: #555;
            cursor: pointer;
            transition: background 0.15s, color 0.15s;
        }
        .mode-btn:hover { background: #f0f0f0; }
        .mode-btn.active-regenerate { background: #e74c3c; color: white; }
        .mode-btn.active-keep { background: #2e86c1; color: white; }

        /* Lasso button */
        .btn-lasso {
            padding: 8px 16px;
            font-size: 13px;
            font-weight: 600;
            border: 1px solid #8e44ad;
            border-radius: 6px;
            background: white;
            color: #8e44ad;
            cursor: pointer;
        }
        .btn-lasso:hover { background: #f5eef8; }
        .btn-lasso.active { background: #8e44ad; color: white; }

        /* ── Generation timeline ── */
        .generation-section {
            position: relative;
            margin-bottom: 20px;
        }
        .generation-section.previous { opacity: 0.7; }
        .generation-section.previous:hover { opacity: 1; }
        .generation-header {
            display: flex;
            align-items: center;
            gap: 12px;
            margin-bottom: 12px;
        }
        .generation-badge {
            background: #0d8a8a;
            color: white;
            padding: 4px 12px;
            border-radius: 12px;
            font-size: 12px;
            font-weight: 600;
        }
        .generation-info {
            font-size: 13px;
            color: #666;
        }
        .generation-connector {
            width: 2px;
            height: 20px;
            background: #0d8a8a;
            margin: 0 auto 10px;
        }
        .generation-connector-label {
            text-align: center;
            font-size: 11px;
            color: #888;
            margin-bottom: 10px;
        }
        .btn-reinpaint {
            padding: 6px 14px;
            font-size: 12px;
            font-weight: 600;
            border: 1px dashed #e67e22;
            border-radius: 6px;
            background: white;
            color: #e67e22;
            cursor: pointer;
        }
        .btn-reinpaint:hover { background: #fff8f0; }

        /* ── Multi-step search ── */
        .search-mode-label {
            display: flex; align-items: center; gap: 8px;
            font-weight: 600; cursor: pointer; user-select: none;
        }
        .search-mode-label input { width: 16px; height: 16px; cursor: pointer; }
        .route-summary {
            font-size: 14px; color: #555; margin-bottom: 18px;
            padding: 10px 14px; background: #f4f9f9; border-radius: 8px;
        }
        .route-block {
            border: 1px solid #e3eaea; border-radius: 10px;
            padding: 16px 18px; margin-bottom: 16px; background: #fff;
        }
        .route-title { font-weight: 700; color: #0a6e6e; margin-bottom: 10px; }
        .route-describe-btn {
            font-size: 12px; padding: 4px 10px; margin-bottom: 10px;
            border: 1px solid #cdd9d9; border-radius: 6px; background: #fff;
            color: #0d8a8a; cursor: pointer;
        }
        .route-describe-btn:hover { background: #f1fbf7; }
        .route-describe-btn:disabled { opacity: 0.6; cursor: default; }
        .route-desc {
            margin-bottom: 14px; padding: 10px 14px; border-radius: 8px;
            background: #f4f9f9; border: 1px solid #e3eaea;
        }
        .route-desc-summary { font-size: 14px; color: #234; line-height: 1.5; }
        .route-desc-steps { margin: 8px 0 0; padding-left: 20px; font-size: 13px; color: #445; }
        .route-desc-steps li { margin: 2px 0; }
        .route-desc-detail { color: #889; font-size: 12px; }
        .route-node {
            display: flex; flex-direction: column; align-items: center;
            position: relative;
        }
        .route-mol-card {
            display: inline-flex; flex-direction: column; align-items: center;
            border: 1px solid #e3eaea; border-radius: 8px; padding: 8px;
            background: #fafbfb; width: 168px;
        }
        .route-mol-card.buy { border-color: #2e9e7f; background: #f1fbf7; }
        .route-mol { width: 150px; height: 110px; }
        .route-smiles {
            font-family: monospace; font-size: 11px; color: #667;
            word-break: break-all; text-align: center; margin-top: 4px;
        }
        .route-badge {
            margin-top: 4px; font-size: 11px; font-weight: 700; color: #2e9e7f;
            text-transform: uppercase; letter-spacing: 0.04em;
        }
        .route-rxn { font-size: 12px; color: #888; margin: 6px 0 0; text-align: center; }
        .route-rxn-named { font-weight: 600; color: #0a6e6e; }
        .route-rxn-unidentified { color: #b06a00; font-style: italic; font-weight: 600; }
        .route-lookup-btn {
            margin-top: 6px; font-size: 11px; padding: 3px 8px;
            border: 1px solid #cdd9d9; border-radius: 5px; background: #fff;
            color: #0d8a8a; cursor: pointer;
        }
        .route-lookup-btn:hover { background: #f1fbf7; }
        .route-lookup-btn:disabled { opacity: 0.6; cursor: default; }
        .route-compound-info {
            margin-top: 6px; font-size: 11px; text-align: center;
            width: 152px; word-break: break-word;
        }
        .route-compound-name { font-weight: 700; color: #244; }
        .route-compound-detail { color: #667; }
        .route-compound-info a { color: #0d8a8a; text-decoration: none; }

        /* ── top-down branching tree: connectors via pseudo-elements ── */
        .route-tree-scroll { overflow-x: auto; padding-bottom: 6px; }
        .route-children {
            display: flex; justify-content: center; align-items: flex-start;
            position: relative; padding-top: 22px; margin-top: 8px;
        }
        /* stem coming down from the parent reaction into the children bus */
        .route-children::before {
            content: ''; position: absolute; top: 0; left: 50%;
            width: 0; height: 22px; border-left: 2px solid #cdd9d9;
        }
        .route-children > .route-node { padding: 22px 12px 0; }
        /* horizontal bus (top-border halves) + vertical drop into each child */
        .route-children > .route-node::before,
        .route-children > .route-node::after {
            content: ''; position: absolute; top: 0;
            width: 50%; height: 22px; border-top: 2px solid #cdd9d9;
        }
        .route-children > .route-node::before { right: 50%; }
        .route-children > .route-node::after { left: 50%; border-left: 2px solid #cdd9d9; }
        .route-children > .route-node:first-child::before { border: 0; }
        .route-children > .route-node:last-child::after { border: 0; }
        .route-children > .route-node:last-child::before { border-right: 2px solid #cdd9d9; }
        /* single child: straight vertical drop, no horizontal bus */
        .route-children > .route-node:only-child::after { display: none; }
        .route-children > .route-node:only-child::before {
            border-top: 0; right: auto; left: 50%; border-left: 2px solid #cdd9d9;
        }
