/* ============================================================
   CAD & 3D — "Rich Light" shell. Category accent: CAD = teal.
   Reuses shared editor-shell class names; tokens from style.css :root.
   ============================================================ */
:root { --pg: #0d9488; --pg-hover: #0f766e; --pg-text: #0f766e;
        --pg-subtle: #f0fdfa; --pg-border: #99f6e4; --pg-ring: rgba(13, 148, 136, 0.16);
        --cad-grad: linear-gradient(135deg, #2dd4bf, #0d9488); }

.editor-main { padding-top: 60px; min-height: 100vh; background: var(--bg-inset); }
.editor-section { display: flex; flex-direction: column; height: calc(100vh - 60px); }

/* Toolbar */
.editor-toolbar {
    display: flex; align-items: center; justify-content: space-between;
    height: 48px; padding: 0 12px; background: #fff;
    border-bottom: 1px solid var(--border); box-shadow: 0 1px 8px rgba(30, 27, 75, 0.04);
    position: relative; z-index: 20; gap: 12px; flex-shrink: 0;
}
.toolbar-left, .toolbar-center, .toolbar-right { display: flex; align-items: center; gap: 6px; }
.toolbar-center { flex: 1; justify-content: center; }
.toolbar-btn {
    display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px;
    background: #fff; border: 1px solid var(--border-strong); border-radius: var(--r-sm);
    color: var(--text-secondary); font-family: var(--font-sans); font-size: 0.8125rem;
    font-weight: 500; cursor: pointer; text-decoration: none;
    transition: background var(--t-fast), border-color var(--t-fast), color var(--t-fast);
}
.toolbar-btn:hover { background: var(--bg-inset); color: var(--text-primary); }
.toolbar-btn.primary { background: var(--grad-btn); border: none; color: #fff; box-shadow: var(--shadow-btn-brand); }
.toolbar-btn.primary:hover { background: var(--grad-btn-hover); box-shadow: var(--shadow-btn-brand-hover); }
.toolbar-btn:focus-visible { outline: none; box-shadow: var(--focus-ring); }
/* Which tier the loaded file uses — stated in the toolbar, next to its name,
   so "free and instant" vs "Autodesk, 10-60s" is never a surprise. */
.cad-tier-badge {
    display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 10px;
    border-radius: var(--r-full); font-size: 0.6875rem; font-weight: 600;
    letter-spacing: 0.01em; white-space: nowrap; box-shadow: var(--e1);
}
.cad-tier-badge::before {
    content: ''; width: 6px; height: 6px; border-radius: var(--r-full); background: currentColor;
    box-shadow: 0 0 0 3px currentColor; opacity: 0.85; margin-right: 2px;
}
.cad-tier-badge.tier-local { color: var(--pg-text); background: var(--pg-subtle); border: 1px solid var(--pg-border); }
.cad-tier-badge.tier-cloud { color: var(--accent-text); background: var(--accent-subtle); border: 1px solid var(--accent-border); }

.cad-info {
    font-family: var(--font-mono); font-size: 0.75rem; font-weight: 500;
    font-variant-numeric: tabular-nums; color: var(--text-muted);
    background: #fff; border: 1px solid var(--border); border-radius: var(--r-full);
    padding: 4px 12px; white-space: nowrap; box-shadow: var(--shadow-xs);
}

/* Container */
.editor-container { display: flex; flex: 1; gap: 0; overflow: hidden; }

/* Preview / viewer stage */
.preview-area {
    flex: 1; display: flex; align-items: center; justify-content: center;
    background: var(--bg-inset); overflow: hidden; min-width: 0; position: relative;
}

/* Upload placeholder */
.cad-upload-placeholder {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    width: 100%; max-width: 600px; margin: auto; padding: 44px 40px 36px; position: relative;
    background: #fff; border: 1.5px dashed var(--border-strong); border-radius: var(--r-xl);
    box-shadow: var(--e1); transition: border-color var(--t-base), box-shadow var(--t-base);
}
.cad-upload-placeholder:hover { border-color: var(--pg-border); box-shadow: var(--e2); }
.cad-upload-placeholder.dragover { border-color: var(--pg); border-style: solid; box-shadow: 0 0 0 4px var(--pg-ring), var(--e2); }
.cad-upload-placeholder .file-input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.cad-upload-placeholder .upload-content { display: flex; flex-direction: column; align-items: center; text-align: center; pointer-events: none; }
.dz-icon {
    width: 64px; height: 64px; margin: 0 auto 20px; display: flex; align-items: center; justify-content: center;
    border-radius: 18px; background: var(--cad-grad); color: #fff; box-shadow: var(--e1);
}
.dz-icon svg { width: 28px; height: 28px; }
.upload-content h2 { font-size: 1.125rem; font-weight: 600; color: var(--text-primary); margin-bottom: 8px; }
.upload-content p { font-size: 0.875rem; color: var(--text-muted); margin-bottom: 16px; }
.upload-button.primary-button {
    pointer-events: auto; height: 40px; padding: 0 20px; border: none; border-radius: var(--r-sm);
    background: var(--grad-btn); color: #fff; font-family: var(--font-sans); font-size: 0.875rem;
    font-weight: 600; cursor: pointer; box-shadow: var(--shadow-btn-brand);
}
.upload-button.primary-button:hover { background: var(--grad-btn-hover); box-shadow: var(--shadow-btn-brand-hover); }
.upload-hint { margin-top: 12px !important; font-size: 0.8125rem; }
.supported-formats { font-family: var(--font-mono); font-size: 0.75rem; color: var(--text-disabled); margin-top: 4px !important; }

/* ------------------------------------------------------------------
   Format browser — what "93 formats" looks like without a wall of text.
   Two tier lines, one chip per family (its extensions on hover), and the
   full list one click away. Teal = opened here; indigo = Autodesk cloud.
   ------------------------------------------------------------------ */
.cad-format-browser {
    /* .upload-content is pointer-events:none and the file input covers the whole
       card, so this subtree has to opt back in and sit above it. */
    pointer-events: auto; position: relative; z-index: 2;
    width: 100%; margin-top: 20px; padding-top: 18px;
    border-top: 1px solid var(--border); text-align: center;
}
.fmt-tiers { display: flex; flex-wrap: wrap; gap: 6px 18px; justify-content: center; margin-bottom: 14px; }
.fmt-tier {
    display: inline-flex; align-items: center; gap: 7px;
    font-size: 0.75rem; font-weight: 500; color: var(--text-secondary);
}
.fmt-dot {
    width: 8px; height: 8px; border-radius: var(--r-full); flex-shrink: 0;
    background: var(--cad-grad); box-shadow: 0 0 0 3px var(--pg-subtle);
}
.tier-cloud > .fmt-dot, .fmt-dot.tier-cloud {
    background: var(--grad-brand); box-shadow: 0 0 0 3px var(--accent-subtle);
}
.tier-mixed > .fmt-dot, .fmt-dot.tier-mixed {
    background: linear-gradient(135deg, #2dd4bf 0%, #0d9488 45%, #6366f1 100%);
    box-shadow: 0 0 0 3px var(--bg-inset);
}
.fmt-chips { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.fmt-chip {
    display: inline-flex; align-items: center; gap: 6px; padding: 5px 11px;
    border-radius: var(--r-full); border: 1px solid var(--border);
    background: linear-gradient(180deg, #ffffff 0%, var(--bg-subtle) 100%);
    color: var(--text-secondary); font-family: var(--font-sans); font-size: 0.75rem;
    font-weight: 500; line-height: 1.2; cursor: pointer; box-shadow: var(--e1);
    transition: border-color var(--t-fast), color var(--t-fast), transform var(--t-lift), box-shadow var(--t-lift);
}
.fmt-chip:hover { transform: translateY(-1px); box-shadow: var(--e2); color: var(--text-primary); }
.fmt-chip.tier-local:hover, .fmt-chip.tier-mixed:hover { border-color: var(--pg-border); }
.fmt-chip.tier-cloud:hover { border-color: var(--accent-border); }
.fmt-chip:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.fmt-count {
    font-family: var(--font-mono); font-size: 0.6875rem; font-variant-numeric: tabular-nums;
    color: var(--text-muted); background: var(--bg-inset); border-radius: var(--r-full);
    padding: 1px 6px;
}
.fmt-chip.fmt-more { font-family: var(--font-mono); color: var(--text-muted); }

.fmt-toggle {
    display: inline-flex; align-items: center; gap: 6px; margin-top: 12px;
    padding: 4px 8px; border: none; background: none; cursor: pointer;
    font-family: var(--font-sans); font-size: 0.75rem; font-weight: 600; color: var(--pg-text);
    border-radius: var(--r-sm);
}
.fmt-toggle:hover { background: var(--pg-subtle); }
.fmt-toggle:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.fmt-caret { transition: transform var(--t-fast); font-size: 0.625rem; }
.cad-format-browser.is-open .fmt-caret { transform: rotate(180deg); }

.fmt-all {
    margin-top: 10px; max-height: 216px; overflow-y: auto; text-align: left;
    padding: 10px 12px; border-radius: var(--r-md);
    background: var(--bg-subtle); border: 1px solid var(--border);
    box-shadow: inset 0 1px 3px rgba(30, 27, 75, 0.05);
}
.fmt-row { padding: 7px 6px; border-radius: var(--r-sm); border-bottom: 1px solid var(--border); }
.fmt-row:last-child { border-bottom: none; }
.fmt-row.is-target { background: #fff; box-shadow: var(--e1); }
.fmt-row-head { display: flex; align-items: center; gap: 7px; }
.fmt-row-name { font-size: 0.75rem; font-weight: 600; color: var(--text-primary); }
.fmt-row-tier {
    margin-left: auto; font-size: 0.625rem; font-weight: 600; letter-spacing: 0.04em;
    text-transform: uppercase; padding: 2px 7px; border-radius: var(--r-full);
    color: var(--pg-text); background: var(--pg-subtle); border: 1px solid var(--pg-border);
}
.fmt-row-tier.tier-cloud { color: var(--accent-text); background: var(--accent-subtle); border-color: var(--accent-border); }
.fmt-row-tier.tier-mixed { color: var(--text-secondary); background: var(--bg-inset); border-color: var(--border-strong); }
.fmt-row-exts { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; padding-left: 15px; }
.fmt-row-exts code {
    font-family: var(--font-mono); font-size: 0.6875rem; color: var(--text-muted);
    background: #fff; border: 1px solid var(--border); border-radius: var(--r-xs); padding: 1px 6px;
}

/* 3D viewer */
/* Light stage, deliberately.
   This was #0f1114 -- the one dark surface on an otherwise light page (the
   parts rows are #fff, the loading overlay is a light scrim), and pale CAD
   parts disappeared into it. --bg-inset rather than pure white: a hair of
   tint keeps light-coloured bodies readable and avoids the glare a full-white
   stage gives a large viewport.
   NOTE: the three.js scene.background in static/js/cad.js must match this
   value, or the canvas and its container disagree while a model loads. */
.cad-viewer { position: absolute; inset: 0; width: 100%; height: 100%; background: var(--bg-inset); }
.cad-viewer canvas { display: block; }
.cad-viewer-hint {
    position: absolute; bottom: 12px; left: 50%; transform: translateX(-50%);
    font-family: var(--font-mono); font-size: 0.6875rem; color: var(--text-secondary);
    background: rgba(255,255,255,0.82); border: 1px solid var(--border);
    border-radius: var(--r-full); padding: 4px 12px; pointer-events: none;
}
.cad-viewer-controls { position: absolute; top: 12px; right: 12px; display: flex; gap: 6px; }
.vc-btn {
    height: 28px; padding: 0 12px; border-radius: var(--r-sm); border: 1px solid var(--border-strong);
    background: var(--bg); color: var(--text-secondary); font-family: var(--font-sans); font-size: 0.75rem;
    font-weight: 500; cursor: pointer; transition: background var(--t-fast);
}
.vc-btn:hover { background: var(--bg-inset); }
/* Square, so +/- read as a matched pair next to the text buttons. The glyphs
   are punctuation at body size, so they get bumped and centred explicitly
   rather than inheriting the text button's metrics. */
.vc-icon {
    width: 28px; padding: 0; font-size: 1rem; line-height: 1;
    display: inline-flex; align-items: center; justify-content: center;
}

/* 2D image preview */
.cad-image-preview { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; padding: 32px; }
.cad-image-preview img { max-width: 100%; max-height: 100%; background: #fff; border-radius: var(--r-sm); box-shadow: var(--e2); }

/* Loading overlay */
.cad-loading {
    position: absolute; inset: 0; z-index: 5; display: flex; flex-direction: column; gap: 14px;
    align-items: center; justify-content: center; background: rgba(241, 242, 249, 0.72);
    color: var(--text-secondary); font-size: 0.875rem;
}
.progress-spinner {
    width: 34px; height: 34px; border: 2.5px solid var(--border-strong); border-top-color: var(--pg);
    border-radius: 50%; animation: cad-spin 0.8s linear infinite;
}
@keyframes cad-spin { to { transform: rotate(360deg); } }

/* Options panel */
.options-panel { width: 288px; background: #fff; border-left: 1px solid var(--border); padding: 20px; overflow-y: auto; flex-shrink: 0; }
.options-empty { color: var(--text-muted); font-size: 0.875rem; }
.options-panel h3 { font-size: 1rem; font-weight: 600; color: var(--text-primary); margin-bottom: 6px; }
.opt-hint { font-size: 0.8125rem; color: var(--text-muted); margin-bottom: 14px; }
.opt-label { display: block; font-size: 0.8125rem; font-weight: 500; color: var(--text-secondary); margin: 16px 0 6px; }
/* The other half of the tier promise: what this conversion costs, in the rail
   where the user is about to press the button. */
.tier-note {
    display: flex; gap: 7px; align-items: flex-start; margin: -6px 0 4px;
    padding: 8px 10px; border-radius: var(--r-sm);
    font-size: 0.6875rem; line-height: 1.5;
}
.tier-note::before { font-weight: 700; line-height: 1.35; }
.tier-note.local { background: var(--pg-subtle); border: 1px solid var(--pg-border); color: var(--pg-text); }
.tier-note.local::before { content: '⚡'; }
.tier-note.cloud { background: var(--accent-subtle); border: 1px solid var(--accent-border); color: var(--accent-text); }
.tier-note.cloud::before { content: '☁'; }
.opt-mono { font-family: var(--font-mono); font-size: 0.75rem; color: var(--text-muted); font-weight: 400; }
.options-panel select, .options-panel input[type="number"] {
    width: 100%; height: 36px; padding: 0 10px; font-family: var(--font-sans); font-size: 0.875rem;
    color: var(--text-primary); background: #fff; border: 1px solid var(--border-strong);
    border-radius: var(--r-sm); box-shadow: inset 0 1px 2px rgba(30, 27, 75, 0.04);
}
.options-panel select:focus-visible, .options-panel input:focus-visible {
    outline: none; border-color: var(--pg); box-shadow: 0 0 0 3px var(--pg-ring);
}
.cad-run-btn.primary-button {
    width: 100%; height: 40px; margin-top: 14px; border: none; border-radius: var(--r-sm);
    background: var(--grad-btn); color: #fff; font-family: var(--font-sans); font-size: 0.875rem;
    font-weight: 600; cursor: pointer; box-shadow: var(--shadow-btn-brand);
}
.cad-run-btn.primary-button:hover { background: var(--grad-btn-hover); box-shadow: var(--shadow-btn-brand-hover); }
.cad-run-btn.secondary {
    width: 100%; height: 38px; margin-top: 8px; border: 1px solid var(--border-strong);
    border-radius: var(--r-sm); background: #fff; color: var(--text-primary);
    font-family: var(--font-sans); font-size: 0.875rem; font-weight: 500; cursor: pointer;
}
.cad-run-btn.secondary:hover { background: var(--bg-inset); }

/* ============================================================
   Parts list — one row per solid of a multi-body CAD model
   ============================================================ */

/* The rail is 288px (248px under 1024px), and a row has to carry a colour
   swatch, a label, three dimensions, a volume and two controls. That is two
   lines, not one. The list itself scrolls so a 40-body assembly cannot push
   "Convert & download" off the bottom of the panel. */
.cad-bodies { margin: 4px 0 6px; }
.body-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.body-head h4 {
    display: flex; align-items: center; gap: 6px;
    font-size: 0.875rem; font-weight: 600; color: var(--text-primary); margin: 0;
}
.body-count {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 20px; height: 18px; padding: 0 6px; border-radius: var(--r-full);
    background: var(--pg-subtle); border: 1px solid var(--pg-border);
    color: var(--pg-text); font-size: 0.6875rem; font-weight: 600;
}
.body-showall {
    border: none; background: none; padding: 0; cursor: pointer;
    font-family: inherit; font-size: 0.75rem; font-weight: 500; color: var(--pg-text);
}
.body-showall:hover { text-decoration: underline; }
.cad-bodies .body-hint { margin: 4px 0 8px; }
.body-list {
    display: flex; flex-direction: column; gap: 4px;
    max-height: 232px; overflow-y: auto; margin-bottom: 10px;
}
.body-row {
    display: flex; align-items: center; gap: 8px; padding: 6px 8px;
    border: 1px solid var(--border); border-radius: var(--r-sm); background: #fff;
    cursor: pointer; transition: background var(--t-fast), border-color var(--t-fast);
}
.body-row:hover { background: var(--bg-inset); }
.body-row:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.body-row.is-isolated { border-color: var(--pg); background: var(--pg-subtle); }
/* Hidden bodies stay legible and stay clickable — greying the row out is the
   whole affordance for putting one back. */
.body-row.is-hidden { opacity: 0.5; }
.body-row.is-hidden .body-swatch { filter: grayscale(1); }
.body-swatch {
    width: 12px; height: 12px; border-radius: 3px; flex-shrink: 0;
    box-shadow: inset 0 0 0 1px rgba(30, 27, 75, 0.18);
}
.body-text { display: flex; flex-direction: column; gap: 1px; min-width: 0; flex: 1; }
.body-name { font-size: 0.8125rem; font-weight: 500; color: var(--text-primary); }
/* Dimensions and volume are the only things that tell two bodies apart: a real
   Fusion export gives both of its solids the same CAD name. Monospace so the
   numbers line up down the column. */
.body-meta {
    font-family: var(--font-mono); font-size: 0.6875rem; color: var(--text-muted);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.body-btn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 24px; height: 24px; flex-shrink: 0; padding: 0; cursor: pointer;
    border: 1px solid transparent; border-radius: var(--r-sm);
    background: none; color: var(--text-muted);
}
.body-btn:hover { background: #fff; border-color: var(--border-strong); color: var(--text-primary); }
.body-btn:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.cad-bodies .body-zip { margin-top: 0; }
.body-note { font-size: 0.6875rem; line-height: 1.5; color: var(--text-muted); margin: 8px 0 0; }

/* ============================================================
   Fusion (.f3d / .f3z) — Autodesk cloud translation
   ============================================================ */

/* Stage cards share one plate: white, layered shadow, teal hairline. */
.cad-fusion-stage, .cad-fusion-setup {
    position: absolute; inset: 0; display: flex; align-items: center;
    justify-content: center; padding: 32px; overflow-y: auto;
}
.fusion-card, .fusion-setup-card {
    background: linear-gradient(180deg, #ffffff 0%, var(--pg-subtle) 100%);
    border: 1px solid var(--pg-border); border-radius: var(--r-xl);
    box-shadow: var(--e2); margin: auto;
}
.fusion-card {
    width: 100%; max-width: 440px; padding: 32px 32px 28px;
    text-align: center; display: flex; flex-direction: column; align-items: center;
}
.fusion-badge {
    display: inline-flex; align-items: center; justify-content: center;
    height: 34px; min-width: 54px; padding: 0 12px; border-radius: var(--r-sm);
    background: var(--cad-grad); color: #fff; box-shadow: var(--e1);
    font-family: var(--font-mono); font-size: 0.8125rem; font-weight: 600;
    letter-spacing: 0.04em; flex-shrink: 0;
}
.fusion-card .fusion-badge { margin-bottom: 18px; }
.fusion-card h2 { font-size: 1.125rem; font-weight: 600; color: var(--text-primary); margin-bottom: 6px; }
.fusion-card .fusion-file {
    font-family: var(--font-mono); font-size: 0.75rem; color: var(--pg-text);
    background: #fff; border: 1px solid var(--pg-border); border-radius: var(--r-full);
    padding: 3px 12px; margin-bottom: 14px; max-width: 100%;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.fusion-card p { font-size: 0.875rem; line-height: 1.55; color: var(--text-muted); margin: 0; }
.fusion-chips { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin-top: 18px; }
.fusion-chip {
    font-family: var(--font-mono); font-size: 0.6875rem; font-weight: 500; letter-spacing: 0.03em;
    color: var(--pg-text); background: #fff; border: 1px solid var(--pg-border);
    border-radius: var(--r-full); padding: 4px 11px; box-shadow: var(--e1);
}

/* Opt-in cloud preview. Deliberately a quiet secondary control, not a primary
   call to action: pressing it spends one of the operator's real Autodesk
   translations, and the cost is written on the button rather than in a tooltip. */
.fusion-preview-btn {
    margin-top: 18px; padding: 9px 16px;
    font-family: inherit; font-size: 0.8125rem; font-weight: 500; line-height: 1.3;
    color: var(--pg-text); background: #fff;
    border: 1px solid var(--pg-border); border-radius: var(--r-full);
    box-shadow: var(--e1); cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}
.fusion-preview-btn:hover:not(:disabled) {
    background: var(--accent-subtle); border-color: var(--accent-border);
    color: var(--accent-text); box-shadow: var(--e2);
}
.fusion-preview-btn:disabled { opacity: 0.5; cursor: default; }

/* Stage card, "translating" mode: the honest 10–60s wait for Autodesk's cloud.
   Same teal bar as the rail so the two readouts read as one process. */
.fusion-card .fusion-stage-status { color: var(--text-secondary); }
.fusion-stage-progress { margin-top: 18px; width: 100%; }
.fusion-stage-progress .fusion-bar { background: #fff; border: 1px solid var(--pg-border); height: 8px; }
.fusion-stage-progress .fusion-progress-row { margin-top: 9px; }
#fusion-stage-live, #fusion-stage-error, #fusion-stage-static { width: 100%; }
/* A failed translation falls back to this card, never to a blank viewer. */
.fusion-stage-errmsg {
    margin: 0 0 16px !important; padding: 11px 13px; border-radius: var(--r-md);
    background: var(--error-subtle); border: 1px solid var(--error-border);
    color: var(--error) !important; font-size: 0.8125rem !important;
    line-height: 1.55; text-align: left;
}

/* Setup card — shown instead of the convert panel when APS is unconfigured.
   Deliberately reads as an instruction, not as an error. */
.fusion-setup-card { width: 100%; max-width: 560px; padding: 28px 30px 24px; }
.fusion-setup-head { display: flex; gap: 16px; align-items: flex-start; }
.fusion-setup-head h2 { font-size: 1.0625rem; font-weight: 600; color: var(--text-primary); margin-bottom: 6px; }
.fusion-setup-lead { font-size: 0.875rem; line-height: 1.6; color: var(--text-secondary); margin: 0; }
.fusion-steps { list-style: none; counter-reset: fstep; margin: 20px 0 0; padding: 0; }
.fusion-steps li {
    counter-increment: fstep; position: relative; padding: 0 0 0 34px; margin-bottom: 11px;
    font-size: 0.8125rem; line-height: 1.55; color: var(--text-secondary);
}
.fusion-steps li::before {
    content: counter(fstep); position: absolute; left: 0; top: 0;
    width: 22px; height: 22px; display: flex; align-items: center; justify-content: center;
    border-radius: var(--r-full); background: var(--cad-grad); color: #fff;
    font-family: var(--font-mono); font-size: 0.6875rem; font-weight: 600; box-shadow: var(--e1);
}
.fusion-setup-foot { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--pg-border); }
.fusion-env-row {
    display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
    font-size: 0.75rem; font-weight: 500; color: var(--text-muted);
}
.fusion-env, .fusion-doc {
    font-family: var(--font-mono); font-size: 0.75rem; color: var(--pg-text);
    background: #fff; border: 1px solid var(--pg-border); border-radius: var(--r-xs);
    padding: 3px 8px; white-space: nowrap;
}
.fusion-setup-note { font-size: 0.75rem; line-height: 1.55; color: var(--text-muted); margin: 10px 0 0; }

/* Options-rail companion to the setup card */
#options-fusion-setup .fusion-rail-card {
    display: flex; flex-direction: column; align-items: flex-start; gap: 6px;
    margin-top: 4px; padding: 12px; border-radius: var(--r-md);
    background: var(--pg-subtle); border: 1px solid var(--pg-border);
}
.fusion-rail-label { font-size: 0.75rem; font-weight: 500; color: var(--text-muted); }

/* Translation progress */
.fusion-progress { margin-top: 14px; }
.fusion-bar {
    height: 6px; border-radius: var(--r-full); background: var(--bg-inset);
    box-shadow: inset 0 1px 2px rgba(30, 27, 75, 0.08); overflow: hidden;
}
.fusion-bar-fill {
    height: 100%; width: 0%; border-radius: var(--r-full);
    background: var(--cad-grad); transition: width var(--t-base);
}
.fusion-progress-row {
    display: flex; align-items: center; justify-content: space-between; gap: 8px;
    margin-top: 7px; font-size: 0.75rem; color: var(--text-muted);
}
.fusion-pct { font-family: var(--font-mono); font-variant-numeric: tabular-nums; color: var(--pg-text); font-weight: 500; }
#fusion-convert:disabled { opacity: 0.6; cursor: default; box-shadow: none; }

/* "Already translated" reassurance under the target select. Reads as a saving,
   not as a warning, so it borrows the success plate rather than the teal one. */
.fusion-reuse-note {
    display: flex; gap: 7px; align-items: flex-start;
    margin-top: 8px; padding: 9px 11px; border-radius: var(--r-sm);
    background: var(--success-subtle); border: 1px solid var(--success-border);
    color: var(--success); font-size: 0.75rem; line-height: 1.5;
}
.fusion-reuse-note::before { content: '↺'; font-weight: 700; line-height: 1.35; }

.fusion-note {
    margin-top: 14px; padding: 10px 12px; border-radius: var(--r-sm);
    background: var(--pg-subtle); border: 1px solid var(--pg-border);
    font-size: 0.75rem; line-height: 1.55; color: var(--text-secondary);
}
.fusion-note .fusion-doc { white-space: normal; }

/* Result banner */
.cad-result-banner {
    margin-top: 18px; padding: 14px; border-radius: var(--r-md);
    background: var(--success-subtle); border: 1px solid var(--success-border);
    display: flex; flex-direction: column; gap: 8px; font-size: 0.8125rem; color: var(--success);
}
.cad-link-btn {
    display: inline-flex; align-items: center; justify-content: center; height: 32px; padding: 0 14px;
    border-radius: var(--r-sm); font-size: 0.8125rem; font-weight: 600; text-decoration: none; cursor: pointer;
    border: 1px solid var(--border-strong); background: #fff; color: var(--text-primary);
}
.cad-link-btn.primary { background: var(--grad-btn); color: #fff; border: none; box-shadow: var(--shadow-btn-brand); }

/* Toasts */
.toast-host { position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 200; }
.toast {
    background: #fff; border-radius: var(--r-md); box-shadow: var(--e3); padding: 12px 16px;
    font-size: 0.875rem; color: var(--text-primary); border-left: 3px solid var(--text-muted);
    max-width: 340px; transition: opacity var(--t-base), transform var(--t-base);
}
.toast.success { border-left-color: var(--success); }
.toast.error { border-left-color: var(--error-strong); }
.toast.fade-out { opacity: 0; transform: translateY(8px); }

@media (max-width: 1024px) { .options-panel { width: 248px; } }
@media (max-width: 768px) {
    .editor-container { flex-direction: column; }
    .options-panel { width: 100%; border-left: none; border-top: 1px solid var(--border); }
    .editor-section { height: auto; }
    .preview-area { min-height: 55vh; }
    .cad-fusion-stage, .cad-fusion-setup { padding: 16px; }
    .fusion-card { padding: 24px 20px 20px; }
    .fusion-setup-card { padding: 20px 18px 18px; }
    .fusion-setup-head { flex-direction: column; gap: 12px; }
}
