.ai-v17-panel {
    --ai-navy: #172033;
    --ai-blue: #2563eb;
    --ai-indigo: #4f46e5;
    --ai-teal: #0f766e;
    --ai-red: #b91c1c;
    --ai-amber: #b45309;
    margin: 1rem 0 1.25rem;
    border: 1px solid #c7d2fe;
    border-left: 5px solid var(--ai-indigo);
    border-radius: 18px;
    background: linear-gradient(145deg, rgba(255,255,255,.99), rgba(245,247,255,.98));
    box-shadow: 0 18px 44px rgba(30, 41, 59, .10);
    color: var(--ai-navy);
    overflow: hidden;
}

.ai-v17-panel * { box-sizing: border-box; }

.ai-v17-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    padding: 1.25rem 1.35rem;
    border-bottom: 1px solid #dbe3f3;
    background: linear-gradient(120deg, rgba(238,242,255,.95), rgba(240,253,250,.85));
}
.ai-v17-header h3 { margin: .25rem 0 .25rem; font-size: 1.2rem; line-height: 1.25; }
.ai-v17-header p { margin: 0; color: #64748b; font-size: .9rem; }
.ai-v17-eyebrow { color: var(--ai-indigo); font-size: .76rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
.ai-v17-engine { flex: 0 0 auto; padding: .45rem .7rem; border-radius: 999px; background: #e0e7ff; color: #4338ca; font-size: .72rem; font-weight: 800; letter-spacing: .04em; }

.ai-v17-quality { display: flex; flex-wrap: wrap; gap: .55rem; padding: .9rem 1.35rem; border-bottom: 1px solid #e2e8f0; }
.ai-v17-quality span { display: inline-flex; align-items: center; gap: .35rem; padding: .42rem .65rem; border-radius: 999px; background: #ecfdf5; color: #047857; font-size: .78rem; font-weight: 750; }
.ai-v17-quality span.neutral { background: #f1f5f9; color: #64748b; }

.ai-v17-metrics,
.ai-v17-context-grid { display: grid; gap: .75rem; padding: 1rem 1.35rem 0; }
.ai-v17-metrics { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.ai-v17-context-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.ai-v17-metrics article,
.ai-v17-context-grid article { min-width: 0; padding: .9rem 1rem; border: 1px solid #dbe3f3; border-radius: 13px; background: rgba(255,255,255,.92); }
.ai-v17-metrics span,
.ai-v17-context-grid span { display: block; color: #64748b; font-size: .72rem; font-weight: 800; letter-spacing: .045em; text-transform: uppercase; margin-bottom: .35rem; }
.ai-v17-metrics strong,
.ai-v17-context-grid strong { display: block; color: var(--ai-navy); font-size: .96rem; line-height: 1.35; overflow-wrap: anywhere; }
.ai-v17-metrics .risk-critical { color: #b91c1c; }
.ai-v17-metrics .risk-high { color: #c2410c; }
.ai-v17-metrics .risk-medium { color: #a16207; }
.ai-v17-metrics .risk-low { color: #047857; }

.ai-v17-language-section,
.ai-v17-corrections-section,
.ai-v17-review-notes,
.ai-v17-lower-grid { margin: 1rem 1.35rem 0; }
.ai-v17-language-section { padding: 1rem; border: 1px solid #93c5fd; border-radius: 15px; background: #f8fbff; }
.ai-v17-section-heading { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: .85rem; }
.ai-v17-section-heading > div { display: flex; align-items: center; gap: .55rem; color: #0369a1; }
.ai-v17-section-heading > span { padding: .38rem .62rem; border-radius: 999px; font-size: .7rem; font-weight: 850; letter-spacing: .04em; }
.ai-v17-section-heading .ready { background: #fef3c7; color: #92400e; }
.ai-v17-section-heading .no-change { background: #f1f5f9; color: #64748b; }
.ai-v17-section-heading .applied { background: #dcfce7; color: #166534; }

.ai-v17-drafts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .75rem; }
.ai-v17-drafts article { min-width: 0; min-height: 150px; padding: .9rem; border: 1px solid #dbe3f3; border-radius: 12px; background: #fff; }
.ai-v17-drafts article.refined { border-color: #7dd3fc; background: linear-gradient(145deg, #fff, #f0f9ff); }
.ai-v17-drafts span { display: block; margin-bottom: .55rem; color: #64748b; font-size: .72rem; font-weight: 850; letter-spacing: .045em; text-transform: uppercase; }
.ai-v17-drafts p { margin: 0; color: #1e293b; font-size: .94rem; line-height: 1.62; white-space: pre-wrap; overflow-wrap: anywhere; }
.ai-v17-actions { display: flex; flex-wrap: wrap; gap: .65rem; margin-top: .9rem; }
.ai-v17-actions button { min-height: 42px; }
.ai-v17-actions button:disabled { opacity: .45; cursor: not-allowed; }

.ai-v17-corrections-section { padding: 1rem; border: 1px solid #dbe3f3; border-radius: 15px; background: rgba(255,255,255,.84); }
.ai-v17-corrections-section h4,
.ai-v17-review-notes h4,
.ai-v17-missing h4,
.ai-v17-recommendations h4 { margin: 0 0 .35rem; font-size: .95rem; }
.ai-v17-corrections-section > p,
.ai-v17-missing > p { margin: 0 0 .8rem; color: #64748b; font-size: .82rem; }
.ai-v17-corrections { display: grid; gap: .65rem; }
.ai-v17-correction { display: grid; grid-template-columns: 38px minmax(0, 1fr); gap: .65rem; padding: .75rem; border: 1px solid #e2e8f0; border-radius: 11px; background: #fff; }
.ai-v17-correction.requires-review { border-color: #fdba74; background: #fff7ed; }
.ai-v17-correction-icon { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; background: #eef2ff; color: #4f46e5; }
.ai-v17-correction-body { min-width: 0; }
.ai-v17-correction-body strong { display: block; font-size: .82rem; margin-bottom: .3rem; }
.ai-v17-change-line { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; margin-bottom: .25rem; font-size: .86rem; }
.ai-v17-change-line del { color: #991b1b; background: #fee2e2; padding: .15rem .3rem; border-radius: 5px; overflow-wrap: anywhere; }
.ai-v17-change-line ins { color: #166534; background: #dcfce7; padding: .15rem .3rem; border-radius: 5px; text-decoration: none; font-weight: 700; overflow-wrap: anywhere; }
.ai-v17-correction-body small { color: #64748b; line-height: 1.4; }
.ai-v17-empty { padding: .75rem; border: 1px dashed #cbd5e1; border-radius: 10px; color: #64748b; background: #f8fafc; }

.ai-v17-review-notes { padding: .9rem 1rem; border: 1px solid #fdba74; border-left: 4px solid #f97316; border-radius: 12px; background: #fff7ed; }
.ai-v17-review-notes h4 { color: #9a3412; }
.ai-v17-review-notes p { margin: .4rem 0 0; color: #7c2d12; font-size: .86rem; line-height: 1.5; }

.ai-v17-lower-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .75rem; }
.ai-v17-missing,
.ai-v17-recommendations { padding: 1rem; border: 1px solid #dbe3f3; border-radius: 13px; background: #fff; }
.ai-v17-missing ul,
.ai-v17-recommendations ul { margin: .55rem 0 0; padding-left: 1.15rem; color: #334155; }
.ai-v17-missing li,
.ai-v17-recommendations li { margin: .35rem 0; line-height: 1.45; font-size: .86rem; }
.ai-v17-complete { padding: 1rem; border: 1px solid #86efac; border-radius: 13px; background: #f0fdf4; color: #166534; }

.ai-v17-footer { display: grid; gap: .5rem; margin-top: 1rem; padding: .9rem 1.35rem 1.1rem; border-top: 1px solid #dbe3f3; background: #f8fafc; color: #64748b; font-size: .78rem; }
.ai-v17-footer > div { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; }
.ai-v17-title-btn { border: 1px solid #a5b4fc; border-radius: 7px; padding: .3rem .55rem; background: #eef2ff; color: #4338ca; font-weight: 750; cursor: pointer; }
.ai-v17-title-btn:hover { background: #e0e7ff; }

.dark-mode .ai-v17-panel { background: linear-gradient(145deg, #111827, #172033); color: #e5e7eb; border-color: #4f46e5; }
.dark-mode .ai-v17-header,
.dark-mode .ai-v17-footer { background: #111827; border-color: #334155; }
.dark-mode .ai-v17-metrics article,
.dark-mode .ai-v17-context-grid article,
.dark-mode .ai-v17-drafts article,
.dark-mode .ai-v17-corrections-section,
.dark-mode .ai-v17-correction,
.dark-mode .ai-v17-missing,
.dark-mode .ai-v17-recommendations { background: #1f2937; border-color: #374151; }
.dark-mode .ai-v17-language-section { background: #172033; border-color: #3b82f6; }
.dark-mode .ai-v17-drafts p,
.dark-mode .ai-v17-metrics strong,
.dark-mode .ai-v17-context-grid strong { color: #f8fafc; }

@media (max-width: 1100px) {
    .ai-v17-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .ai-v17-drafts { grid-template-columns: 1fr; }
    .ai-v17-drafts article { min-height: auto; }
}

@media (max-width: 720px) {
    .ai-v17-header { flex-direction: column; }
    .ai-v17-engine { align-self: flex-start; }
    .ai-v17-metrics,
    .ai-v17-context-grid,
    .ai-v17-lower-grid { grid-template-columns: 1fr; }
    .ai-v17-section-heading { align-items: flex-start; flex-direction: column; }
    .ai-v17-actions { flex-direction: column; }
    .ai-v17-actions button { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
    .ai-v17-panel *, .ai-v17-panel *::before, .ai-v17-panel *::after {
        scroll-behavior: auto !important;
        transition: none !important;
        animation: none !important;
    }
}

/* Runtime activation and visible diagnostic feedback */
.ai-v18-runtime-message {
    margin: 0 0 1rem;
    padding: 0.9rem 1rem;
    border-radius: 12px;
    border: 1px solid #bfdbfe;
    background: #eff6ff;
    color: #1e3a8a;
    font-weight: 700;
    line-height: 1.45;
}
.ai-v18-runtime-message.error {
    border-color: #fecaca;
    background: #fef2f2;
    color: #991b1b;
}
.ai-v18-runtime-message.success {
    border-color: #a7f3d0;
    background: #ecfdf5;
    color: #065f46;
}
[data-ai-bound="true"] {
    position: relative;
}
[data-ai-bound="true"]::after {
    content: "";
    position: absolute;
    width: 7px;
    height: 7px;
    right: -3px;
    top: -3px;
    border-radius: 999px;
    background: #10b981;
    box-shadow: 0 0 0 3px rgba(16,185,129,.14);
}
