:root {
  --bg: #0d0b12;
  --bg2: #14111c;
  --bg3: #1c1826;
  --border: #2a2438;
  --text: #ece9f4;
  --muted: #8b85a0;
  --accent: #a78bfa;
  --accent2: #f472b6;
  --grad: linear-gradient(90deg, #a78bfa, #f472b6);
  --ok: #34d399;
  --warn: #fbbf24;
  --err: #f87171;
  --radius: 12px;
}
:root[data-theme="light"] {
  --bg: #f7f6fb;
  --bg2: #ffffff;
  --bg3: #f0edf7;
  --border: #e3ddf0;
  --text: #1a1626;
  --muted: #6b6580;
  --accent: #7c3aed;
  --accent2: #db2777;
  --grad: linear-gradient(90deg, #7c3aed, #db2777);
}
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body { font-family: 'Segoe UI', system-ui, sans-serif; background: var(--bg); color: var(--text); font-size: 15px; overflow-x: hidden; }
a { color: var(--accent); text-decoration: none; }
button { font: inherit; cursor: pointer; border: none; }
input, textarea, select { font: inherit; background: var(--bg3); color: var(--text); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; outline: none; width: 100%; }
input:focus, textarea:focus { border-color: var(--accent); }
::placeholder { color: #5c5670; }
h1, h2, h3 { font-weight: 700; }
code { background: var(--bg3); padding: 1px 6px; border-radius: 5px; font-size: 13px; }

.btn { background: var(--grad); color: #fff; padding: 10px 20px; border-radius: 10px; font-weight: 600; transition: opacity .15s, transform .1s; display: inline-flex; align-items: center; gap: 8px; }
.btn:hover { opacity: .9; }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .4; cursor: default; }
.btn.ghost { background: var(--bg3); border: 1px solid var(--border); color: var(--text); }
.btn.ghost:hover { border-color: var(--accent); opacity: 1; }
.btn.danger { background: #7f1d1d; }
.btn.sm { padding: 6px 12px; font-size: 13px; border-radius: 8px; }

.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 99px; font-size: 12px; font-weight: 600; background: var(--bg3); border: 1px solid var(--border); }
.badge.gold { color: #fbbf24; border-color: #fbbf2455; }
.badge.silver { color: #cbd5e1; border-color: #cbd5e155; }
.badge.bronze { color: #d8a47f; border-color: #d8a47f55; }
.badge.ok { color: var(--ok); }
.badge.warn { color: var(--warn); }
.badge.err { color: var(--err); }

/* ---------- шапка ---------- */
.topbar { display: flex; align-items: center; gap: 16px; padding: 12px 24px; border-bottom: 1px solid var(--border); background: rgba(13,11,18,.85); backdrop-filter: blur(10px); position: sticky; top: 0; z-index: 50; }
.logo { font-size: 19px; font-weight: 800; background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; letter-spacing: -.5px; cursor: pointer; }
.topbar .spacer { flex: 1; }
.topbar .nav-link { color: var(--muted); font-weight: 600; font-size: 14px; padding: 6px 10px; border-radius: 8px; position: relative; }
.topbar .nav-link:hover { color: var(--text); background: var(--bg3); }
.dot { position: absolute; top: 2px; right: 2px; width: 8px; height: 8px; border-radius: 50%; background: var(--accent2); }
.credits-pill { display: flex; align-items: center; gap: 6px; background: var(--bg3); border: 1px solid var(--border); padding: 6px 14px; border-radius: 99px; font-weight: 700; font-size: 14px; }

/* ---------- лендинг ---------- */
.hero { max-width: 900px; margin: 0 auto; text-align: center; padding: 90px 24px 50px; }
.hero h1 { font-size: clamp(34px, 6vw, 58px); line-height: 1.1; letter-spacing: -1.5px; }
.hero h1 span { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero p { color: var(--muted); font-size: 19px; margin: 22px auto 34px; max-width: 640px; line-height: 1.55; }
.hero-input { max-width: 680px; margin: 0 auto; display: flex; gap: 10px; background: var(--bg2); border: 1px solid var(--border); padding: 10px; border-radius: 16px; box-shadow: 0 0 80px #a78bfa22; }
.hero-input input { border: none; background: transparent; font-size: 16px; }
.features { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; max-width: 1080px; margin: 40px auto 80px; padding: 0 24px; }
.feature { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; text-align: left; transition: border-color .2s, transform .2s; }
.feature:hover { border-color: var(--accent); transform: translateY(-3px); }
.feature .ico { font-size: 28px; }
.feature h3 { margin: 12px 0 8px; font-size: 16px; }
.feature p { color: var(--muted); font-size: 14px; line-height: 1.5; }

/* ---------- переключатель темы ---------- */
.theme-toggle { background: var(--bg3); border: 1px solid var(--border); width: 38px; height: 38px; border-radius: 10px; font-size: 17px; display: flex; align-items: center; justify-content: center; }
.theme-toggle:hover { border-color: var(--accent); }

/* ---------- продающий лендинг ---------- */
.lp { overflow: hidden; }
.lp .hero { max-width: 900px; padding: 70px 24px 40px; }
.hero-badge { display: inline-block; background: var(--bg3); border: 1px solid var(--border); color: var(--accent); font-weight: 700; font-size: 13px; padding: 6px 16px; border-radius: 99px; margin-bottom: 22px; }
.hero-sub { color: var(--muted); font-size: 13px; margin-top: 14px; }
.lp-sec { max-width: 1160px; margin: 0 auto; padding: 56px 24px; }
.lp-h2 { font-size: clamp(26px, 4vw, 40px); text-align: center; letter-spacing: -1px; line-height: 1.15; }
.lp-lead { color: var(--muted); font-size: 17px; text-align: center; max-width: 640px; margin: 12px auto 30px; line-height: 1.5; }
.lp-grid { display: grid; gap: 16px; }
.lp-grid.cards8 { grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }
.lp-card { background: var(--bg2); border: 1px solid var(--border); border-radius: 16px; padding: 22px; transition: .2s; }
.lp-card:hover { border-color: var(--accent); transform: translateY(-4px); box-shadow: 0 12px 40px rgba(124,58,237,.12); }
.lp-card .ico { font-size: 30px; }
.lp-card h3 { margin: 12px 0 7px; font-size: 16px; }
.lp-card p { color: var(--muted); font-size: 14px; line-height: 1.5; }
.accent-band { background: var(--bg2); border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); max-width: none; }
.accent-band .lp-2col { max-width: 1160px; margin: 0 auto; }
.lp-2col { display: grid; grid-template-columns: 1fr 1fr; gap: 44px; align-items: center; }
.lp-tag { display: inline-block; background: var(--grad); color: #fff; font-weight: 700; font-size: 13px; padding: 5px 14px; border-radius: 99px; margin-bottom: 16px; }
.lp-tag.center { display: block; width: fit-content; margin: 0 auto 16px; }
.lp-list { list-style: none; display: flex; flex-direction: column; gap: 10px; }
.lp-list li { padding-left: 28px; position: relative; color: var(--text); line-height: 1.5; }
.lp-list li::before { content: '✓'; position: absolute; left: 0; color: var(--accent); font-weight: 800; }
.lp-chatdemo { background: var(--bg3); border: 1px solid var(--border); border-radius: 18px; padding: 20px; display: flex; flex-direction: column; gap: 10px; }
.cd-msg { padding: 11px 15px; border-radius: 14px; font-size: 14px; line-height: 1.45; }
.cd-msg.user { align-self: flex-end; background: var(--accent); color: #fff; border-bottom-right-radius: 4px; max-width: 85%; }
.cd-msg.bot { align-self: flex-start; background: var(--bg2); border: 1px solid var(--border); border-bottom-left-radius: 4px; max-width: 90%; }
.cd-msg.files { align-self: flex-start; font-size: 12px; color: var(--accent); font-family: Consolas, monospace; }
.seller-block { background: radial-gradient(120% 100% at 50% 0%, rgba(124,58,237,.10), transparent); border-radius: 28px; }
.lp-chips { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; max-width: 900px; margin: 0 auto; }
.lp-chip { background: var(--bg2); border: 1px solid var(--border); border-radius: 99px; padding: 10px 18px; font-size: 14px; font-weight: 600; transition: .15s; }
.lp-chip:hover { border-color: var(--accent); color: var(--accent); }
.lp-chip.alt { background: var(--bg3); }
.lp-steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; max-width: 900px; margin: 0 auto; }
.lp-step { text-align: center; padding: 20px; }
.lp-step .num { width: 52px; height: 52px; border-radius: 50%; background: var(--grad); color: #fff; font-size: 22px; font-weight: 800; display: flex; align-items: center; justify-content: center; margin: 0 auto 16px; }
.lp-step h3 { font-size: 18px; margin-bottom: 8px; }
.lp-step p { color: var(--muted); font-size: 14px; line-height: 1.5; }
.lp-cta { text-align: center; padding: 70px 24px; background: var(--bg2); border-top: 1px solid var(--border); }
.lp-cta h2 { font-size: clamp(26px, 4vw, 38px); letter-spacing: -1px; }
.lp-cta p { color: var(--muted); font-size: 17px; margin: 14px 0 28px; }
.btn.btn-lg { font-size: 17px; padding: 15px 36px; }
.lp-footer { text-align: center; padding: 30px 24px; color: var(--muted); font-size: 14px; border-top: 1px solid var(--border); }
@media (max-width: 780px) { .lp-2col { grid-template-columns: 1fr; } .lp-steps { grid-template-columns: 1fr; } }

/* ---------- модалки ---------- */
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.65); display: grid; place-items: center; z-index: 100; padding: 20px; }
.modal { background: var(--bg2); border: 1px solid var(--border); border-radius: 16px; padding: 28px; width: 100%; max-width: 420px; max-height: 90vh; overflow: auto; }
.modal h2 { margin-bottom: 18px; font-size: 22px; }
.modal .row { margin-bottom: 12px; }
.modal label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 5px; font-weight: 600; }
.modal.wide { max-width: 640px; }

/* ---------- дашборд ---------- */
.page { max-width: 1100px; margin: 0 auto; padding: 32px 24px; }
.page-head { display: flex; align-items: center; gap: 14px; margin-bottom: 24px; flex-wrap: wrap; }
.page-head h1 { font-size: 26px; flex: 1; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.card { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; transition: border-color .2s; }
.card:hover { border-color: var(--accent); }
.card h3 { font-size: 16px; margin-bottom: 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card .meta { color: var(--muted); font-size: 13px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.card .actions { display: flex; gap: 8px; margin-top: 14px; }
.kind-chip { font-size: 11px; padding: 2px 8px; border-radius: 99px; background: #a78bfa22; color: var(--accent); font-weight: 700; }
.empty-state { text-align: center; color: var(--muted); padding: 70px 20px; }
.empty-state .big { font-size: 44px; margin-bottom: 12px; }

/* ---------- редактор ---------- */
.editor { display: grid; grid-template-columns: 420px 1fr; height: calc(100vh - 57px); }
.chat-col { border-right: 1px solid var(--border); display: flex; flex-direction: column; min-width: 0; background: var(--bg2); }
.chat-log { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.msg { max-width: 92%; padding: 11px 14px; border-radius: 14px; line-height: 1.5; font-size: 14px; white-space: pre-wrap; word-break: break-word; }
.msg.user { align-self: flex-end; background: #3b2f5e; border-bottom-right-radius: 4px; }
.msg.assistant { align-self: flex-start; background: var(--bg3); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.msg .files { margin-top: 8px; display: flex; flex-wrap: wrap; gap: 5px; }
.msg .files code { font-size: 11px; background: #a78bfa1e; color: var(--accent); }
.msg.typing::after { content: '▍'; animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: 0; } }
.chat-controls { display: flex; gap: 8px; padding: 8px 12px 0; align-items: center; }
.chat-controls select { flex: 1; padding: 7px 10px; font-size: 13px; }
.model-fixed { flex: 1; padding: 8px 12px; font-size: 13px; font-weight: 600; color: var(--accent); background: var(--bg3); border: 1px solid var(--border); border-radius: 8px; }
.mode-toggle { display: flex; background: var(--bg3); border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.mode-btn { background: transparent; color: var(--muted); padding: 7px 10px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.mode-btn.active { background: var(--accent); color: #fff; }
.btn.active-sel { background: var(--accent); color: #fff; }
.target-chip { margin: 0 12px; padding: 7px 10px; background: #7c5cff22; border: 1px solid var(--accent); border-radius: 8px; font-size: 12px; display: flex; align-items: center; gap: 6px; }
.target-chip button { margin-left: auto; background: none; color: var(--muted); font-size: 16px; line-height: 1; }
.attach-row { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 12px; }
.attach-row:empty { display: none; }
.att-chip { display: inline-flex; align-items: center; gap: 5px; background: var(--bg3); border: 1px solid var(--border); border-radius: 8px; padding: 4px 6px 4px 8px; font-size: 12px; }
.att-chip img { width: 26px; height: 26px; object-fit: cover; border-radius: 4px; }
.att-chip button { background: none; border: none; color: var(--muted); font-size: 15px; cursor: pointer; line-height: 1; }
.icon-btn { padding: 8px 10px; font-size: 17px; }
#chat-mic.rec { background: var(--err); color: #fff; animation: micpulse 1s infinite; }
@keyframes micpulse { 50% { opacity: .55; } }
.chat-input { padding: 12px; border-top: 1px solid var(--border); display: flex; gap: 6px; align-items: flex-end; }
.chat-input textarea { resize: none; max-height: 140px; min-height: 44px; }
.chat-hint { padding: 0 14px 10px; color: var(--muted); font-size: 12px; }

.work-col { display: flex; flex-direction: column; min-width: 0; }
.work-tabs { display: flex; gap: 4px; padding: 8px 12px; border-bottom: 1px solid var(--border); align-items: center; }
.work-tabs .tab { padding: 7px 14px; border-radius: 8px; background: transparent; color: var(--muted); font-weight: 600; font-size: 14px; }
.work-tabs .tab.active { background: var(--bg3); color: var(--text); }
.work-body { flex: 1; overflow: hidden; position: relative; }
.preview-frame { width: 100%; height: 100%; border: none; background: #fff; }
.preview-frame.mobile { width: 390px; margin: 12px auto; display: block; border: 8px solid #26202f; border-radius: 30px; height: calc(100% - 24px); }
.device-btns { margin-left: auto; display: flex; gap: 6px; }

.code-view { display: grid; grid-template-columns: 220px 1fr; height: 100%; }
.file-tree { border-right: 1px solid var(--border); overflow-y: auto; padding: 10px; }
.file-item { padding: 6px 10px; border-radius: 7px; cursor: pointer; font-size: 13px; color: var(--muted); font-family: Consolas, monospace; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-item:hover { background: var(--bg3); color: var(--text); }
.file-item.active { background: #a78bfa22; color: var(--accent); }
.code-pane { display: flex; flex-direction: column; min-width: 0; }
.code-pane textarea { flex: 1; border: none; border-radius: 0; background: #0a0810; font-family: Consolas, monospace; font-size: 13px; line-height: 1.55; padding: 14px; white-space: pre; overflow: auto; }
.code-toolbar { padding: 8px 12px; border-bottom: 1px solid var(--border); display: flex; gap: 8px; align-items: center; font-size: 13px; color: var(--muted); }

.pane { padding: 20px; overflow-y: auto; height: 100%; }
.fl { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; font-weight: 600; }
.seller-nav { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 18px; border-bottom: 1px solid var(--border); padding-bottom: 12px; }
.snav-btn { background: var(--bg3); border: 1px solid var(--border); color: var(--muted); padding: 8px 14px; border-radius: 8px; font-weight: 600; font-size: 13px; }
.snav-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }
input.mini { width: 74px; padding: 5px 7px; font-size: 13px; }
.muted { color: var(--muted); }
.pane h3 { margin: 18px 0 10px; font-size: 16px; }
.pane h3:first-child { margin-top: 0; }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th, table.data td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
table.data th { color: var(--muted); font-weight: 600; }
.tbl-chip { display: inline-flex; gap: 6px; align-items: center; padding: 6px 12px; background: var(--bg3); border: 1px solid var(--border); border-radius: 8px; cursor: pointer; margin: 0 6px 6px 0; font-size: 13px; }
.tbl-chip.active { border-color: var(--accent); color: var(--accent); }

.asset-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
.asset-card { background: var(--bg3); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; font-size: 12px; }
.asset-card img { width: 100%; aspect-ratio: 16/10; object-fit: cover; display: block; background: #0a0810; }
.asset-card .cap { padding: 8px 10px; color: var(--muted); }

/* ---------- тикеты / аккаунт ---------- */
.list-row { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border: 1px solid var(--border); border-radius: 10px; margin-bottom: 8px; background: var(--bg2); cursor: pointer; }
.list-row:hover { border-color: var(--accent); }
.list-row .grow { flex: 1; min-width: 0; }
.ticket-thread { display: flex; flex-direction: column; gap: 10px; margin: 18px 0; }
.stat-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 24px; }
.stat-card { background: var(--bg2); border: 1px solid var(--border); border-radius: 10px; padding: 16px; }
.stat-card .num { font-size: 26px; font-weight: 800; }
.stat-card .lbl { color: var(--muted); font-size: 12px; margin-top: 4px; }

/* ---------- помощь по токену в мастере ---------- */
.tok-help { margin: 4px 0 10px; font-size: 13px; background: var(--bg3); border: 1px solid var(--border); border-radius: 8px; padding: 8px 12px; }
.tok-help summary { cursor: pointer; color: var(--accent); font-weight: 600; }
.tok-help ol { margin: 10px 0 8px 18px; color: var(--muted); line-height: 1.6; }
.tok-help ol b { color: var(--text); }

/* ---------- AI-помощник платформы ---------- */
.helper-fab { position: fixed; bottom: 22px; right: 22px; z-index: 150; width: 58px; height: 58px; border-radius: 50%; background: var(--grad); color: #fff; font-size: 26px; box-shadow: 0 10px 30px rgba(124,58,237,.4); display: flex; align-items: center; justify-content: center; transition: transform .15s; }
.helper-fab:hover { transform: scale(1.08); }
.helper-fab.hidden { display: none; }
.helper-panel { position: fixed; bottom: 22px; right: 22px; z-index: 151; width: min(400px, calc(100vw - 32px)); height: min(600px, calc(100vh - 100px)); background: var(--bg2); border: 1px solid var(--border); border-radius: 18px; box-shadow: 0 24px 70px rgba(0,0,0,.4); display: none; flex-direction: column; overflow: hidden; }
.helper-panel.open { display: flex; }
.helper-head { display: flex; align-items: center; gap: 8px; padding: 14px 16px; background: var(--grad); color: #fff; }
.helper-head b { font-size: 15px; }
.helper-sub { font-size: 11px; opacity: .85; }
.helper-close { margin-left: auto; background: none; border: none; color: #fff; font-size: 24px; cursor: pointer; line-height: 1; }
.helper-log { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.hmsg { max-width: 90%; padding: 10px 13px; border-radius: 13px; font-size: 14px; line-height: 1.5; }
.hmsg.user { align-self: flex-end; background: var(--accent); color: #fff; border-bottom-right-radius: 4px; }
.hmsg.assistant { align-self: flex-start; background: var(--bg3); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.hmsg.assistant code { background: rgba(128,128,128,.18); padding: 1px 5px; border-radius: 4px; font-size: 12px; }
.helper-input { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--border); align-items: flex-end; }
.helper-input textarea { flex: 1; resize: none; max-height: 120px; min-height: 42px; }
.helper-input .btn { padding: 10px 14px; }

/* ---------- онбординг-тур ---------- */
.tour-ov { position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 200; }
.tour-hl { position: fixed; z-index: 201; border: 2px solid var(--accent); border-radius: 10px; box-shadow: 0 0 0 4px rgba(124,58,237,.3), 0 0 0 9999px rgba(0,0,0,.55); pointer-events: none; transition: .25s; }
.tour-pop { position: fixed; z-index: 202; background: var(--bg2); border: 1px solid var(--accent); border-radius: 14px; padding: 16px 18px; max-width: 320px; box-shadow: 0 16px 50px rgba(0,0,0,.45); }
.tour-pop h4 { font-size: 15px; margin-bottom: 6px; }
.tour-pop p { font-size: 13px; color: var(--muted); line-height: 1.5; }
.tour-actions { display: flex; gap: 8px; margin-top: 12px; align-items: center; }
.tour-step { font-size: 12px; color: var(--muted); margin-right: auto; }

/* ---------- тосты ---------- */
#toasts { position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 200; }
.toast { background: var(--bg3); border: 1px solid var(--border); border-left: 3px solid var(--accent); padding: 12px 16px; border-radius: 10px; max-width: 360px; font-size: 14px; animation: slideIn .25s ease; box-shadow: 0 8px 30px rgba(0,0,0,.4); }
.toast.err { border-left-color: var(--err); }
.toast.ok { border-left-color: var(--ok); }
@keyframes slideIn { from { transform: translateX(30px); opacity: 0; } }

@media (max-width: 900px) {
  .editor { grid-template-columns: 1fr; grid-template-rows: 45% 55%; }
  .chat-col { border-right: none; border-bottom: 1px solid var(--border); }
  .code-view { grid-template-columns: 160px 1fr; }
}
