/* Конструктор расширений: дополнение к дизайн-системе платформы (app.css, токены те же). */

/* ---------------------------------------------------------------- навигация раздела */
.x-switch { display: flex; gap: 6px; margin: 0 0 18px; padding: 4px; background: var(--surface-2); border-radius: 12px; width: max-content; max-width: 100%; overflow-x: auto; }
.x-switch a { padding: 7px 14px; border-radius: 9px; color: var(--text-2); font-weight: 600; font-size: 14px; white-space: nowrap; }
.x-switch a:hover { text-decoration: none; background: var(--surface); }
.x-switch a.active { background: var(--surface); color: var(--primary); box-shadow: var(--shadow-sm); }

/* ---------------------------------------------------------------- создание по описанию */
.x-create { position: relative; overflow: hidden; border-radius: var(--radius-lg); padding: 28px; color: #fff;
  background: radial-gradient(1200px 400px at 0% 0%, #4f46e5 0%, transparent 60%), radial-gradient(900px 400px at 100% 100%, #db2777 0%, transparent 55%), #1e1b4b; box-shadow: var(--shadow-lg); }
.x-create h1, .x-create h2 { color: #fff; margin-bottom: 6px; }
.x-create p { color: rgba(255,255,255,.82); }
.x-prompt { display: flex; gap: 10px; align-items: flex-end; margin-top: 16px; background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.18); border-radius: 16px; padding: 10px; }
.x-prompt textarea { flex: 1; min-height: 56px; max-height: 220px; resize: vertical; border: 0; outline: 0; background: transparent; color: #fff; font: inherit; font-size: 16px; padding: 6px 8px; }
.x-prompt textarea::placeholder { color: rgba(255,255,255,.6); }
.x-prompt .btn { white-space: nowrap; }
.x-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.x-chip { border: 1px solid rgba(255,255,255,.25); background: rgba(255,255,255,.08); color: #fff; border-radius: 999px; padding: 5px 12px; font: inherit; font-size: 13px; cursor: pointer; }
.x-chip:hover { background: rgba(255,255,255,.18); }
.x-chip-light { border-color: var(--border); background: var(--surface); color: var(--text-2); }
.x-chip-light:hover { background: var(--primary-50); border-color: var(--primary-200); color: var(--primary-700); }
.x-note { font-size: 13px; color: rgba(255,255,255,.75); margin-top: 10px; }
.x-usage { display: flex; gap: 18px; flex-wrap: wrap; font-size: 13px; color: rgba(255,255,255,.8); margin-top: 14px; }
.x-usage a { color: #fff; text-decoration: underline; }

/* ---------------------------------------------------------------- прогресс генерации */
.x-overlay { position: fixed; inset: 0; z-index: 1000; display: grid; place-items: center; background: rgba(15,23,42,.55); backdrop-filter: blur(3px); }
.x-overlay[hidden] { display: none; }
.x-progress { width: min(440px, calc(100vw - 32px)); background: var(--surface); border-radius: var(--radius-lg); padding: 26px; box-shadow: var(--shadow-lg); }
.x-progress h3 { margin-bottom: 14px; }
.x-steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.x-steps li { display: flex; gap: 10px; align-items: center; color: var(--muted); }
.x-steps li::before { content: ""; width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--border-strong); flex: none; }
.x-steps li.is-active { color: var(--text); font-weight: 600; }
.x-steps li.is-active::before { border-color: var(--primary); border-right-color: transparent; animation: x-spin .8s linear infinite; }
.x-steps li.is-done { color: var(--success-700); }
.x-steps li.is-done::before { border-color: var(--success); background: var(--success) var(--check-white) center / 12px no-repeat; }
@keyframes x-spin { to { transform: rotate(360deg); } }

/* ---------------------------------------------------------------- галерея и карточки */
.x-section-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin: 30px 0 14px; flex-wrap: wrap; }
.x-section-head h2 { margin: 0; }
.x-filters { display: flex; gap: 6px; flex-wrap: wrap; }
.x-filters button { border: 1px solid var(--border); background: var(--surface); border-radius: 999px; padding: 5px 12px; font: inherit; font-size: 13px; cursor: pointer; color: var(--text-2); }
.x-filters button.active { background: var(--text); border-color: var(--text); color: #fff; }
.x-gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; }
.x-recipe { display: flex; flex-direction: column; gap: 8px; padding: 16px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); transition: transform .15s, box-shadow .15s, border-color .15s; }
.x-recipe:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--primary-200); }
.x-recipe-top { display: flex; gap: 10px; align-items: center; }
.x-recipe-icon { width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center; font-size: 21px; flex: none; }
.x-recipe h3 { font-size: 15px; margin: 0; }
.x-recipe p { font-size: 13px; color: var(--muted); margin: 0; flex: 1; }
.x-cat { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.x-recipe form { display: grid; gap: 8px; }
.x-recipe input[type=text], .x-recipe input[type=url] { font: inherit; font-size: 13px; padding: 7px 9px; border: 1px solid var(--border-strong); border-radius: 8px; }

.x-projects { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.x-project { display: flex; gap: 14px; padding: 16px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); color: inherit; }
.x-project:hover { text-decoration: none; border-color: var(--primary-200); box-shadow: var(--shadow); }
.x-project img { width: 44px; height: 44px; border-radius: 10px; flex: none; }
.x-project h3 { font-size: 15px; margin: 0 0 2px; color: var(--text); }
.x-project p { font-size: 13px; color: var(--muted); margin: 0 0 8px; }
.x-empty { text-align: center; padding: 26px; border: 2px dashed var(--border); border-radius: var(--radius); color: var(--muted); }

/* ---------------------------------------------------------------- редактор */
.x-editor-head { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.x-editor-head img { width: 48px; height: 48px; border-radius: 12px; }
.x-editor-head h1 { margin: 0; font-size: 24px; }
.x-editor-head .spacer { flex: 1; }
.x-editor { display: grid; grid-template-columns: minmax(340px, 5fr) minmax(0, 7fr); gap: 18px; align-items: start; }
.x-editor > * { min-width: 0; }
.x-side { display: grid; gap: 14px; }
.x-ai textarea { width: 100%; min-height: 76px; resize: vertical; font: inherit; padding: 10px 12px; border: 1px solid var(--border-strong); border-radius: 10px; }
.x-ai textarea:focus { outline: 0; border-color: var(--primary); box-shadow: var(--ring); }
.x-ai-row { display: flex; gap: 8px; align-items: center; margin-top: 8px; flex-wrap: wrap; }
.x-ai-msg { font-size: 13px; }
.x-ai-msg.error { color: var(--danger-700); }
.x-ai-msg.ok { color: var(--success-700); }
.x-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.x-list li { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; }
.x-list .x-dot { width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center; flex: none; background: var(--primary-50); color: var(--primary); font-size: 13px; }
.x-list small { display: block; color: var(--muted); }
.x-check { display: flex; gap: 8px; align-items: center; font-size: 14px; font-weight: 600; }
.x-check.ok { color: var(--success-700); }
.x-check.bad { color: var(--danger-700); }
.x-issues { margin: 8px 0 0; padding-left: 18px; font-size: 13px; }
.x-issues code { font-size: 12px; }
.x-code { width: 100%; min-height: 420px; font: 12.5px/1.5 var(--font-mono); padding: 12px; border: 1px solid var(--border-strong); border-radius: 10px; background: #0b1020; color: #e2e8f0; tab-size: 2; resize: vertical; }
.x-pre { white-space: pre-wrap; font: 12.5px/1.5 var(--font-mono); background: var(--surface-3); border: 1px solid var(--border); border-radius: 10px; padding: 12px; max-height: 360px; overflow: auto; }
.x-versions li { justify-content: space-between; align-items: center; border-bottom: 1px solid var(--border); padding-bottom: 8px; }
.x-versions form { margin: 0; }
.x-steps-install { margin: 0; padding-left: 20px; display: grid; gap: 6px; font-size: 14px; }
.x-download { display: flex; gap: 8px; flex-wrap: wrap; }
.x-tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin: -4px 0 14px; overflow-x: auto; }
.x-tabs button { border: 0; background: none; font: inherit; font-weight: 600; font-size: 14px; color: var(--muted); padding: 8px 12px; border-bottom: 2px solid transparent; cursor: pointer; white-space: nowrap; }
.x-tabs button.active { color: var(--primary); border-bottom-color: var(--primary); }
.x-tabs .x-count { display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--danger); color: #fff; font-size: 11px; margin-left: 4px; }
[data-pane][hidden] { display: none !important; }

/* ---------------------------------------------------------------- симулятор браузера */
.sim { position: sticky; top: 12px; }
.sim-browser { border-radius: 14px; overflow: hidden; border: 1px solid #cfd6e2; background: #fff; box-shadow: var(--shadow-lg); }
.sim-tabs { display: flex; align-items: flex-end; gap: 6px; padding: 8px 10px 0; background: #dfe3ea; }
.sim-dots { display: flex; gap: 6px; padding: 0 6px 10px 2px; }
.sim-dots i { width: 11px; height: 11px; border-radius: 50%; background: #f87171; }
.sim-dots i:nth-child(2) { background: #fbbf24; } .sim-dots i:nth-child(3) { background: #34d399; }
.sim-tab { display: flex; gap: 8px; align-items: center; max-width: 280px; padding: 7px 14px; background: #fff; border-radius: 10px 10px 0 0; font-size: 12.5px; color: #334155; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sim-bar { display: flex; align-items: center; gap: 8px; padding: 7px 10px; border-bottom: 1px solid #e5e7eb; background: #fff; }
.sim-nav { display: flex; gap: 2px; }
.sim-nav button, .sim-icon-btn { border: 0; background: none; width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; color: #475569; cursor: pointer; font-size: 15px; }
.sim-nav button:hover, .sim-icon-btn:hover { background: #f1f5f9; }
.sim-address { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; height: 32px; padding: 0 14px; border-radius: 16px; background: #f1f3f6; font-size: 13px; color: #334155; }
.sim-address span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sim-address .sim-lock { color: #16a34a; }
.sim-ext { position: relative; width: 34px; height: 34px; border: 0; border-radius: 50%; background: none; cursor: pointer; display: grid; place-items: center; }
.sim-ext:hover, .sim-ext.is-open { background: #e8eefc; }
.sim-ext img { width: 20px; height: 20px; border-radius: 5px; }
.sim-ext.pulse::after { content: ""; position: absolute; inset: 2px; border-radius: 50%; border: 2px solid var(--primary); animation: sim-pulse 1.6s ease-out infinite; }
@keyframes sim-pulse { from { opacity: .9; transform: scale(.8); } to { opacity: 0; transform: scale(1.5); } }
.sim-badge { position: absolute; right: -2px; bottom: 1px; min-width: 16px; height: 15px; padding: 0 4px; border-radius: 5px; color: #fff; font: 700 10px/15px system-ui, sans-serif; text-align: center; }
.sim-badge[hidden] { display: none; }
.sim-viewport { position: relative; height: 560px; background: #fff; }
.sim-viewport > iframe { width: 100%; height: 100%; border: 0; display: block; }
.sim-popup { position: absolute; top: 4px; right: 10px; z-index: 5; background: #fff; border-radius: 10px; box-shadow: 0 12px 40px rgba(15,23,42,.28), 0 0 0 1px rgba(15,23,42,.08); overflow: hidden; animation: sim-in .14s ease-out; }
.sim-popup[hidden] { display: none; }
.sim-popup iframe { display: block; width: 320px; height: 220px; border: 0; }
@keyframes sim-in { from { opacity: 0; transform: translateY(-6px); } }
.sim-menu { position: absolute; z-index: 6; min-width: 230px; max-width: 360px; padding: 5px 0; background: #fff; border-radius: 8px; box-shadow: 0 10px 30px rgba(15,23,42,.25), 0 0 0 1px rgba(15,23,42,.08); font-size: 13px; }
.sim-menu[hidden] { display: none; }
.sim-menu button { display: flex; gap: 8px; align-items: center; width: 100%; text-align: left; border: 0; background: none; padding: 7px 14px; font: inherit; cursor: pointer; color: #1f2937; }
.sim-menu button:hover { background: #eef2ff; }
.sim-menu button img { width: 16px; height: 16px; border-radius: 4px; }
.sim-menu .sim-menu-muted { padding: 6px 14px; color: #94a3b8; }
.sim-menu hr { border: 0; border-top: 1px solid #e5e7eb; margin: 4px 0; }
.sim-notices { position: absolute; right: 12px; bottom: 12px; z-index: 7; display: grid; gap: 8px; width: min(320px, calc(100% - 24px)); }
.sim-notice { display: flex; gap: 10px; padding: 12px; border-radius: 12px; background: #fff; box-shadow: 0 10px 30px rgba(15,23,42,.22), 0 0 0 1px rgba(15,23,42,.06); font-size: 13px; animation: sim-in .2s ease-out; }
.sim-notice img { width: 28px; height: 28px; border-radius: 7px; flex: none; }
.sim-notice strong { display: block; }
.sim-notice a { word-break: break-all; }
.sim-warning { margin: 0; padding: 8px 12px; font-size: 13px; background: var(--warning-50); color: var(--warning-700); border-bottom: 1px solid #fde68a; }
.sim-panel { margin-top: 12px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px 14px; }
.sim-log { list-style: none; margin: 0; padding: 0; max-height: 210px; overflow: auto; font: 12px/1.45 var(--font-mono); }
.sim-log li { display: flex; gap: 8px; padding: 4px 0; border-bottom: 1px dashed var(--border); }
.sim-log li b { flex: none; width: 70px; color: var(--muted); font-weight: 600; }
.sim-log li.error { color: var(--danger-700); }
.sim-log li.warn { color: var(--warning-700); }
.sim-log li span { white-space: pre-wrap; word-break: break-word; }
.sim-row { display: flex; gap: 10px; align-items: center; justify-content: space-between; padding: 7px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.sim-hint { font-size: 13px; color: var(--muted); }
.sim-demo-form { display: grid; gap: 10px; }
.sim-demo-form textarea { font: 12px/1.4 var(--font-mono); min-height: 90px; padding: 8px; border: 1px solid var(--border-strong); border-radius: 8px; }
.sim-demo-form input[type=url] { font: inherit; padding: 8px 10px; border: 1px solid var(--border-strong); border-radius: 8px; flex: 1; }
.sim-pages { display: flex; gap: 8px; flex-wrap: wrap; }
dialog.sim-options { width: min(720px, calc(100vw - 32px)); height: min(640px, calc(100vh - 64px)); padding: 0; border: 0; border-radius: 14px; box-shadow: var(--shadow-lg); }
dialog.sim-options::backdrop { background: rgba(15,23,42,.5); }
.sim-options-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px; border-bottom: 1px solid var(--border); font-weight: 600; }
dialog.sim-options iframe { width: 100%; height: calc(100% - 50px); border: 0; }

/* ---------------------------------------------------------------- лендинг */
.x-hero-mock { position: relative; }
.x-hero-mock .sim-browser { transform: rotate(-1deg); }
.x-mock-site { padding: 22px 26px; height: 320px; background: linear-gradient(180deg, #fbfaf7, #f3f4f6); font: 14px/1.6 Georgia, serif; color: #334155; }
.x-mock-site h4 { font: 700 20px/1.3 Georgia, serif; color: #0f3d5e; margin: 0 0 8px; }
.x-mock-site mark { background: #fde68a; padding: 0 2px; border-radius: 2px; }
.x-mock-popup { position: absolute; right: 14px; top: 96px; width: 250px; background: #fff; border-radius: 10px; box-shadow: 0 16px 40px rgba(15,23,42,.28), 0 0 0 1px rgba(15,23,42,.08); overflow: hidden; font: 13px/1.4 system-ui, sans-serif; }
.x-mock-popup header { padding: 10px 12px; color: #fff; font-weight: 600; background: #0f766e; }
.x-mock-popup div { padding: 10px 12px; display: grid; gap: 7px; }
.x-mock-popup span.b { display: block; text-align: center; padding: 7px; border-radius: 7px; background: #0f766e; color: #fff; font-weight: 600; }
.x-browsers { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 18px; }
.x-browsers span { padding: 5px 11px; border-radius: 999px; background: var(--surface); border: 1px solid var(--border); font-size: 13px; font-weight: 600; color: var(--text-2); }
.x-compare { width: 100%; border-collapse: collapse; background: var(--surface); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-sm); }
.x-compare th, .x-compare td { padding: 12px 14px; border-bottom: 1px solid var(--border); text-align: left; font-size: 14px; vertical-align: top; }
.x-compare th { background: var(--surface-2); }
.x-compare td:last-child { color: var(--success-700); font-weight: 600; }

/* ---------------------------------------------------------------- заявка, установка, ссылка */
.x-order { display: grid; grid-template-columns: 1fr 1fr; gap: 28px; align-items: start; }
.x-order-form textarea, .x-order-form input:not([type=checkbox]) { width: 100%; }
.x-hp { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
.x-install { max-width: 860px; margin: 0 auto; }
.x-install-head { display: flex; gap: 16px; align-items: center; margin-bottom: 18px; }
.x-install-head img { border-radius: 16px; flex: none; }
.x-install-head h1 { margin: 0 0 4px; }
.x-made { text-align: center; margin-top: 18px; }
.x-share { display: grid; gap: 10px; padding: 14px; border: 1px solid var(--primary-200); background: var(--primary-50); border-radius: var(--radius); }
.x-share-url { flex: 1; min-width: 220px; font: 13px var(--font-mono); padding: 7px 9px; border: 1px solid var(--border-strong); border-radius: 8px; background: var(--surface); }
.x-share form { margin: 0; }

@media (max-width: 1100px) {
  .x-editor { grid-template-columns: 1fr; }
  .sim { position: static; }
}
@media (max-width: 860px) { .x-order { grid-template-columns: 1fr; } }
@media (max-width: 640px) {
  .x-create { padding: 20px 16px; }
  .x-install-head { align-items: flex-start; }
  .x-prompt { flex-direction: column; align-items: stretch; }
  .sim-viewport { height: 460px; }
  .sim-tabs { display: none; }
  .x-mock-popup { position: static; width: auto; margin: 12px; }
  .x-mock-site { height: auto; }
}

/* ---------- настройки в админке ---------- */
.x-settings { max-width: 860px; }
.x-settings code { font-size: 13px; }
.x-status { display: flex; align-items: center; gap: 8px; margin: 0; font-weight: 600; flex-wrap: wrap; }
.x-status::before { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--border-strong); flex: none; }
.x-status.ok::before { background: var(--success); box-shadow: 0 0 0 3px color-mix(in srgb, var(--success) 20%, transparent); }
/* поля сервиса видны, только когда он выбран (без :has — видны все) */
@supports selector(:has(a)) {
  .x-settings:not(:has(option[value="yandexgpt"]:checked)) [data-for="yandexgpt"],
  .x-settings:not(:has(option[value="gigachat"]:checked)) [data-for="gigachat"],
  .x-settings:not(:has(option[value="openai"]:checked)) [data-for="openai"] { display: none; }
}
